Skip to content

Commit

Permalink
{AKS} Correct the property disable_outbound_nat in windows_profile an…
Browse files Browse the repository at this point in the history
…d add UT (#7548)
  • Loading branch information
ShiqianTao authored Apr 24, 2024
1 parent 4e482fe commit 897b5ed
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ To release a new version, please select a new version number (usually plus 1 to

Pending
+++++++
* Correct the property disable_outbound_nat in windows_profile and add UT.
* Minimise the roles needed to introduce for Elastic SAN for enabling Azure Container Storage with elasticSan storagepool type.

3.0.0b6
Expand Down
5 changes: 3 additions & 2 deletions src/aks-preview/azext_aks_preview/agentpool_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,11 @@ def _get_disable_windows_outbound_nat(self) -> bool:
if self.decorator_mode == DecoratorMode.CREATE:
if (
self.agentpool and
hasattr(self.agentpool, "windows_profile") and
self.agentpool.windows_profile and
self.agentpool.windows_profile.disable_windows_outbound_nat is not None
self.agentpool.windows_profile.disable_outbound_nat is not None
):
disable_windows_outbound_nat = self.agentpool.windows_profile.disable_windows_outbound_nat
disable_windows_outbound_nat = self.agentpool.windows_profile.disable_outbound_nat

# this parameter does not need dynamic completion
# this parameter does not need validation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,33 @@ def common_get_disable_vtpm(self):
)
ctx_1.attach_agentpool(agentpool_1)
self.assertEqual(ctx_1.get_disable_vtpm(), True)


def common_get_agentpool_windows_profile(self):
ctx_1 = AKSPreviewAgentPoolContext(
self.cmd,
AKSAgentPoolParamDict({
"os_type": "windows",
"disable_windows_outbound_nat": True,
}),
self.models,
DecoratorMode.CREATE,
self.agentpool_decorator_mode,
)
# check all fields under windows_profile
self.assertEqual(ctx_1.get_disable_windows_outbound_nat(), True)

# check result when fields had been assigned values
agentpool_1 = self.create_initialized_agentpool_instance(
windows_profile=self.models.AgentPoolWindowsProfile(
disable_outbound_nat=False
)
)
ctx_1.attach_agentpool(agentpool_1)
self.assertEqual(
ctx_1.get_disable_windows_outbound_nat(),
False,
)

def common_get_node_vm_size(self):
# default
ctx_1 = AKSPreviewAgentPoolContext(
Expand Down Expand Up @@ -708,6 +734,9 @@ def test_get_enable_vtpm(self):
def test_get_disable_vtpm(self):
self.common_get_disable_vtpm()

def test_get_agentpool_windows_profile(self):
self.common_get_agentpool_windows_profile()


class AKSPreviewAgentPoolContextManagedClusterModeTestCase(
AKSPreviewAgentPoolContextCommonTestCase
Expand Down Expand Up @@ -765,6 +794,8 @@ def test_get_disable_secure_boot(self):
def test_get_enable_vtpm(self):
self.common_get_enable_vtpm()

def test_get_agentpool_windows_profile(self):
self.common_get_agentpool_windows_profile()

class AKSPreviewAgentPoolAddDecoratorCommonTestCase(unittest.TestCase):
def _remove_defaults_in_agentpool(self, agentpool):
Expand Down Expand Up @@ -987,6 +1018,29 @@ def common_set_up_vtpm(self):
)
self.assertEqual(dec_agentpool_1, ground_truth_agentpool_1)

def common_set_up_agentpool_windows_profile(self):
dec_1 = AKSPreviewAgentPoolAddDecorator(
self.cmd,
self.client,
{
"os_type": "windows",
"disable_windows_outbound_nat": True,
},
self.resource_type,
self.agentpool_decorator_mode,
)
agentpool_1 = self.create_initialized_agentpool_instance(restore_defaults=False)
dec_1.context.attach_agentpool(agentpool_1)
dec_agentpool_1 = dec_1.set_up_agentpool_windows_profile(agentpool_1)
dec_agentpool_1 = self._restore_defaults_in_agentpool(dec_agentpool_1)

ground_truth_agentpool_1 = self.create_initialized_agentpool_instance(
windows_profile=self.models.AgentPoolWindowsProfile(
disable_outbound_nat=True
)
)
self.assertEqual(dec_agentpool_1, ground_truth_agentpool_1)


class AKSPreviewAgentPoolAddDecoratorStandaloneModeTestCase(
AKSPreviewAgentPoolAddDecoratorCommonTestCase
Expand Down Expand Up @@ -1027,6 +1081,9 @@ def test_set_up_secure_boot(self):
def test_set_up_vtpm(self):
self.common_set_up_vtpm()

def test_set_up_agentpool_windows_profile(self):
self.common_set_up_agentpool_windows_profile()

def test_construct_agentpool_profile_preview(self):
import inspect

Expand Down Expand Up @@ -1141,6 +1198,9 @@ def test_set_up_secure_boot(self):
def test_set_up_vtpm(self):
self.common_set_up_vtpm()

def test_set_up_agentpool_windows_profile(self):
self.common_set_up_agentpool_windows_profile()

def test_construct_agentpool_profile_preview(self):
import inspect

Expand Down

0 comments on commit 897b5ed

Please sign in to comment.