Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Lily Pan committed Feb 2, 2024
1 parent 4f9fa7c commit 0afcbba
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 85 deletions.
24 changes: 12 additions & 12 deletions src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -1354,13 +1354,13 @@ def load_arguments(self, _):
c.argument('skip_gpu_driver_install', action='store_true', is_preview=True)
# trusted launch
c.argument(
"enable_secure_boot",
is_preview=True,
"enable_secure_boot",
is_preview=True,
action="store_true"
)
c.argument(
"enable_vtpm",
is_preview=True,
"enable_vtpm",
is_preview=True,
action="store_true"
)

Expand Down Expand Up @@ -1420,23 +1420,23 @@ def load_arguments(self, _):
)
# trusted launch
c.argument(
"enable_secure_boot",
is_preview=True,
"enable_secure_boot",
is_preview=True,
action="store_true"
)
c.argument(
"disable_secure_boot",
is_preview=True,
"disable_secure_boot",
is_preview=True,
action="store_true"
)
c.argument(
"enable_vtpm",
is_preview=True,
"enable_vtpm",
is_preview=True,
action="store_true"
)
c.argument(
"disable_vtpm",
is_preview=True,
"disable_vtpm",
is_preview=True,
action="store_true"
)

Expand Down
8 changes: 4 additions & 4 deletions src/aks-preview/azext_aks_preview/agentpool_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def get_enable_secure_boot(self, enable_validation: bool = False) -> bool:
# In create mode, try and read the property value corresponding to the parameter from the `agentpool` object
if self.decorator_mode == DecoratorMode.CREATE:
if (
self.agentpool and
self.agentpool and
self.agentpool.security_profile is not None and
self.agentpool.security_profile.enable_secure_boot is not None
):
Expand All @@ -465,7 +465,7 @@ def get_disable_secure_boot(self, enable_validation: bool = False) -> bool:
:return: bool
"""

return self.raw_param.get("disable_secure_boot")
return self.raw_param.get("disable_secure_boot")

def get_enable_vtpm(self, enable_validation: bool = False) -> bool:
"""Obtain the value of enable_vtpm.
Expand All @@ -477,7 +477,7 @@ def get_enable_vtpm(self, enable_validation: bool = False) -> bool:
# In create mode, try and read the property value corresponding to the parameter from the `agentpool` object
if self.decorator_mode == DecoratorMode.CREATE:
if (
self.agentpool and
self.agentpool and
self.agentpool.security_profile is not None and
self.agentpool.security_profile.enable_vtpm is not None
):
Expand All @@ -496,7 +496,7 @@ def get_disable_vtpm(self, enable_validation: bool = False) -> bool:
:return: bool
"""

return self.raw_param.get("disable_vtpm")
return self.raw_param.get("disable_vtpm")

class AKSPreviewAgentPoolAddDecorator(AKSAgentPoolAddDecorator):
def __init__(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,20 +463,6 @@ def common_get_enable_secure_boot(self):
ctx_2.attach_agentpool(agentpool_2)
self.assertEqual(ctx_2.get_enable_secure_boot(), None)

# custom
ctx_3 = AKSPreviewAgentPoolContext(
self.cmd,
AKSAgentPoolParamDict(
{"enable_secure_boot": True, "disable_secure_boot": True}
),
self.models,
DecoratorMode.UPDATE,
self.agentpool_decorator_mode,
)
ctx_3.attach_agentpool(agentpool_2)
with self.assertRaises(MutuallyExclusiveArgumentError):
ctx_3.update_secure_boot(agentpool_2)

def common_get_disable_secure_boot(self):
# default
ctx_1 = AKSPreviewAgentPoolContext(
Expand All @@ -494,20 +480,6 @@ def common_get_disable_secure_boot(self):
)
ctx_1.attach_agentpool(agentpool_1)
self.assertEqual(ctx_1.get_disable_secure_boot(), True)

# custom
ctx_2 = AKSPreviewAgentPoolContext(
self.cmd,
AKSAgentPoolParamDict(
{"enable_secure_boot": True, "disable_secure_boot": True}
),
self.models,
DecoratorMode.UPDATE,
self.agentpool_decorator_mode,
)
ctx_2.attach_agentpool(agentpool_1)
with self.assertRaises(MutuallyExclusiveArgumentError):
ctx_2.update_secure_boot(agentpool_1)

def common_get_enable_vtpm(self):
# default
Expand Down Expand Up @@ -544,20 +516,6 @@ def common_get_enable_vtpm(self):
ctx_2.attach_agentpool(agentpool_2)
self.assertEqual(ctx_2.get_enable_vtpm(), None)

# custom
ctx_3 = AKSPreviewAgentPoolContext(
self.cmd,
AKSAgentPoolParamDict(
{"enable_vtpm": True, "disable_vtpm": True}
),
self.models,
DecoratorMode.UPDATE,
self.agentpool_decorator_mode,
)
ctx_3.attach_agentpool(agentpool_2)
with self.assertRaises(MutuallyExclusiveArgumentError):
ctx_3.update_vtpm(agentpool_2)

def common_get_disable_vtpm(self):
# default
ctx_1 = AKSPreviewAgentPoolContext(
Expand All @@ -576,20 +534,6 @@ def common_get_disable_vtpm(self):
ctx_1.attach_agentpool(agentpool_1)
self.assertEqual(ctx_1.get_disable_vtpm(), True)

# custom
ctx_2 = AKSPreviewAgentPoolContext(
self.cmd,
AKSAgentPoolParamDict(
{"enable_vtpm": True, "disable_vtpm": True}
),
self.models,
DecoratorMode.UPDATE,
self.agentpool_decorator_mode,
)
ctx_2.attach_agentpool(agentpool_1)
with self.assertRaises(MutuallyExclusiveArgumentError):
ctx_2.update_vtpm(agentpool_1)

class AKSPreviewAgentPoolContextStandaloneModeTestCase(
AKSPreviewAgentPoolContextCommonTestCase
):
Expand Down Expand Up @@ -1286,19 +1230,20 @@ def common_update_secure_boot(self):
# fail on passing the wrong agentpool object
with self.assertRaises(CLIInternalError):
dec_1.update_secure_boot(None)

agentpool_1 = self.create_initialized_agentpool_instance(
security_profile=self.models.AgentPoolSecurityProfile(
enable_secure_boot=True
enable_secure_boot=False
)
)
dec_1.context.attach_agentpool(agentpool_1)
dec_agentpool_1 = dec_1.update_secure_boot(agentpool_1)
grond_truth_agentpool_1 = self.create_initialized_agentpool_instance(
ground_truth_agentpool_1 = self.create_initialized_agentpool_instance(
security_profile=self.models.AgentPoolSecurityProfile(
enable_secure_boot=True
)
)
self.assertEqual(dec_agentpool_1, grond_truth_agentpool_1)
self.assertEqual(dec_agentpool_1, ground_truth_agentpool_1)

dec_2 = AKSPreviewAgentPoolUpdateDecorator(
self.cmd,
Expand All @@ -1318,12 +1263,12 @@ def common_update_secure_boot(self):
)
dec_2.context.attach_agentpool(agentpool_2)
dec_agentpool_2 = dec_2.update_secure_boot(agentpool_2)
grond_truth_agentpool_2 = self.create_initialized_agentpool_instance(
ground_truth_agentpool_2 = self.create_initialized_agentpool_instance(
security_profile=self.models.AgentPoolSecurityProfile(
enable_secure_boot=True
enable_secure_boot=False
)
)
self.assertEqual(dec_agentpool_2, grond_truth_agentpool_2)
self.assertEqual(dec_agentpool_2, ground_truth_agentpool_2)

# Should error if both set
dec_3 = AKSPreviewAgentPoolUpdateDecorator(
Expand All @@ -1348,19 +1293,20 @@ def common_update_vtpm(self):
# fail on passing the wrong agentpool object
with self.assertRaises(CLIInternalError):
dec_1.update_vtpm(None)

agentpool_1 = self.create_initialized_agentpool_instance(
security_profile=self.models.AgentPoolSecurityProfile(
enable_vtpm=True
enable_vtpm=False
)
)
dec_1.context.attach_agentpool(agentpool_1)
dec_agentpool_1 = dec_1.update_vtpm(agentpool_1)
grond_truth_agentpool_1 = self.create_initialized_agentpool_instance(
ground_truth_agentpool_1 = self.create_initialized_agentpool_instance(
security_profile=self.models.AgentPoolSecurityProfile(
enable_vtpm=True
)
)
self.assertEqual(dec_agentpool_1, grond_truth_agentpool_1)
self.assertEqual(dec_agentpool_1, ground_truth_agentpool_1)

dec_2 = AKSPreviewAgentPoolUpdateDecorator(
self.cmd,
Expand All @@ -1379,14 +1325,14 @@ def common_update_vtpm(self):
)
dec_2.context.attach_agentpool(agentpool_2)
dec_agentpool_2 = dec_2.update_vtpm(agentpool_2)
grond_truth_agentpool_2 = self.create_initialized_agentpool_instance(
ground_truth_agentpool_2 = self.create_initialized_agentpool_instance(
security_profile=self.models.AgentPoolSecurityProfile(
enable_vtpm=True
enable_vtpm=False
)
)
self.assertEqual(dec_agentpool_2, grond_truth_agentpool_2)
self.assertEqual(dec_agentpool_2, ground_truth_agentpool_2)

# Should error if both set
# Should error if both set
dec_3 = AKSPreviewAgentPoolUpdateDecorator(
self.cmd,
self.client,
Expand Down

0 comments on commit 0afcbba

Please sign in to comment.