Skip to content

Commit 2a67f58

Browse files
committed
Improved testing for fips, and added aks_command tests.
1 parent bd0798d commit 2a67f58

File tree

2 files changed

+205
-8
lines changed

2 files changed

+205
-8
lines changed

src/aks-preview/azext_aks_preview/tests/latest/test_agentpool_decorator.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,6 @@ def common_get_enable_kata_image(self):
629629
DecoratorMode.CREATE,
630630
self.agentpool_decorator_mode,
631631
)
632-
self.assertEqual(ctx_1.get_workload_runtime(), CONST_WORKLOAD_RUNTIME_OCI_CONTAINER)
633632
agentpool_1 = self.create_initialized_agentpool_instance(workload_runtime=CONST_WORKLOAD_RUNTIME_KATA_VM_ISOLATION)
634633
ctx_1.attach_agentpool(agentpool_1)
635634
self.assertEqual(ctx_1.get_workload_runtime(), CONST_WORKLOAD_RUNTIME_KATA_VM_ISOLATION)
@@ -644,7 +643,6 @@ def common_get_enable_kata_image(self):
644643
DecoratorMode.CREATE,
645644
self.agentpool_decorator_mode,
646645
)
647-
self.assertEqual(ctx_2.get_workload_runtime(), CONST_WORKLOAD_RUNTIME_OCI_CONTAINER)
648646
agentpool_2 = self.create_initialized_agentpool_instance(workload_runtime=CONST_WORKLOAD_RUNTIME_OLD_KATA_VM_ISOLATION)
649647
ctx_2.attach_agentpool(agentpool_2)
650648
self.assertEqual(ctx_2.get_workload_runtime(), CONST_WORKLOAD_RUNTIME_OLD_KATA_VM_ISOLATION)
@@ -1066,13 +1064,13 @@ def test_get_enable_vtpm(self):
10661064
def test_get_disable_vtpm(self):
10671065
self.common_get_disable_vtpm()
10681066

1069-
def common_get_enable_fips_image(self):
1067+
def test_common_get_enable_fips_image(self):
10701068
self.common_get_enable_fips_image()
10711069

1072-
def common_get_disable_fips_image(self):
1070+
def test_common_get_disable_fips_image(self):
10731071
self.common_get_disable_fips_image()
10741072

1075-
def common_get_enable_kata_image(self):
1073+
def test_common_get_enable_kata_image(self):
10761074
self.common_get_enable_kata_image()
10771075

10781076
def test_get_agentpool_windows_profile(self):
@@ -1151,10 +1149,10 @@ def test_get_disable_secure_boot(self):
11511149
def test_get_enable_vtpm(self):
11521150
self.common_get_enable_vtpm()
11531151

1154-
def common_get_enable_fips_image(self):
1152+
def test_common_get_enable_fips_image(self):
11551153
self.common_get_enable_fips_image()
11561154

1157-
def common_get_enable_kata_image(self):
1155+
def test_common_get_enable_kata_image(self):
11581156
self.common_get_enable_kata_image()
11591157

11601158
def test_get_agentpool_windows_profile(self):

src/aks-preview/azext_aks_preview/tests/latest/test_aks_commands.py

Lines changed: 200 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import tempfile
1111
import time
1212

13-
from azext_aks_preview._consts import CONST_CUSTOM_CA_TEST_CERT
13+
from azext_aks_preview._consts import CONST_CUSTOM_CA_TEST_CERT, CONST_WORKLOAD_RUNTIME_KATA_VM_ISOLATION, CONST_WORKLOAD_RUNTIME_OLD_KATA_VM_ISOLATION
1414
from azext_aks_preview._format import aks_machine_list_table_format
1515
from azext_aks_preview.tests.latest.custom_preparers import (
1616
AKSCustomResourceGroupPreparer,
@@ -3062,6 +3062,205 @@ def test_aks_nodepool_add_with_ossku_windows2025(
30623062
checks=[self.is_empty()],
30633063
)
30643064

3065+
@AllowLargeResponse()
3066+
@AKSCustomResourceGroupPreparer(
3067+
random_name_length=17, name_prefix="clitest", location="westus2"
3068+
)
3069+
def test_aks_cluster_kata(
3070+
self, resource_group, resource_group_location
3071+
):
3072+
# reset the count so in replay mode the random names will start with 0
3073+
self.test_resources_count = 0
3074+
# kwargs for string formatting
3075+
aks_name = self.create_random_name("cliakstest", 16)
3076+
self.kwargs.update(
3077+
{
3078+
"resource_group": resource_group,
3079+
"name": aks_name,
3080+
"dns_name_prefix": self.create_random_name("cliaksdns", 16),
3081+
"location": resource_group_location,
3082+
"resource_type": "Microsoft.ContainerService/ManagedClusters",
3083+
"workload_runtime": CONST_WORKLOAD_RUNTIME_KATA_VM_ISOLATION,
3084+
}
3085+
)
3086+
3087+
# create
3088+
create_cmd = (
3089+
"aks create --resource-group={resource_group} --name={name} --location={location} "
3090+
"--os-sku AzureLinux --workload-runtime {workload_runtime} --node-count 1 "
3091+
"--node-vm-size Standard_D4s_v3"
3092+
)
3093+
self.cmd(
3094+
create_cmd,
3095+
checks=[
3096+
self.exists("fqdn"),
3097+
self.exists("nodeResourceGroup"),
3098+
self.check("provisioningState", "Succeeded"),
3099+
self.check("agentPoolProfiles[0].workloadRuntime", CONST_WORKLOAD_RUNTIME_KATA_VM_ISOLATION),
3100+
],
3101+
)
3102+
3103+
# delete
3104+
self.cmd(
3105+
"aks delete -g {resource_group} -n {name} --yes --no-wait",
3106+
checks=[self.is_empty()],
3107+
)
3108+
3109+
@AllowLargeResponse()
3110+
@AKSCustomResourceGroupPreparer(
3111+
random_name_length=17, name_prefix="clitest", location="westus2"
3112+
)
3113+
def test_aks_nodepool_add_with_kata(
3114+
self, resource_group, resource_group_location
3115+
):
3116+
# reset the count so in replay mode the random names will start with 0
3117+
self.test_resources_count = 0
3118+
# kwargs for string formatting
3119+
aks_name = self.create_random_name("cliakstest", 16)
3120+
node_pool_name = self.create_random_name('c', 6)
3121+
node_pool_name_second = self.create_random_name('c', 6)
3122+
self.kwargs.update(
3123+
{
3124+
"resource_group": resource_group,
3125+
"name": aks_name,
3126+
"node_pool_name": node_pool_name,
3127+
"node_pool_name_second": node_pool_name_second,
3128+
"location": resource_group_location,
3129+
"resource_type": "Microsoft.ContainerService/ManagedClusters",
3130+
"workload_runtime": CONST_WORKLOAD_RUNTIME_KATA_VM_ISOLATION,
3131+
}
3132+
)
3133+
3134+
# create
3135+
create_cmd = (
3136+
"aks create --resource-group={resource_group} --name={name} "
3137+
"--nodepool-name {node_pool_name} -c 1"
3138+
)
3139+
self.cmd(create_cmd, checks=[
3140+
self.check('provisioningState', 'Succeeded'),
3141+
])
3142+
3143+
# nodepool update with kata
3144+
update_cmd = (
3145+
"aks nodepool add --cluster-name={name} --resource-group={resource_group} "
3146+
"--name={node_pool_name_second} --os-sku AzureLinux "
3147+
"--workload-runtime KataVmIsolation --node-vm-size Standard_D4s_v3"
3148+
)
3149+
3150+
self.cmd(
3151+
update_cmd,
3152+
checks=[
3153+
self.check("provisioningState", "Succeeded"),
3154+
self.check("workloadRuntime", "KataVmIsolation"),
3155+
],
3156+
)
3157+
3158+
# delete
3159+
self.cmd(
3160+
"aks delete -g {resource_group} -n {name} --yes --no-wait",
3161+
checks=[self.is_empty()],
3162+
)
3163+
3164+
@AllowLargeResponse()
3165+
@AKSCustomResourceGroupPreparer(
3166+
random_name_length=17, name_prefix="clitest", location="westus2"
3167+
)
3168+
def test_aks_cluster_kata_mshv_vm_isolation(
3169+
self, resource_group, resource_group_location
3170+
):
3171+
# Testing the old kata name that is still in use in aks-preview
3172+
# reset the count so in replay mode the random names will start with 0
3173+
self.test_resources_count = 0
3174+
# kwargs for string formatting
3175+
aks_name = self.create_random_name("cliakstest", 16)
3176+
self.kwargs.update(
3177+
{
3178+
"resource_group": resource_group,
3179+
"name": aks_name,
3180+
"dns_name_prefix": self.create_random_name("cliaksdns", 16),
3181+
"location": resource_group_location,
3182+
"resource_type": "Microsoft.ContainerService/ManagedClusters",
3183+
"workload_runtime": CONST_WORKLOAD_RUNTIME_OLD_KATA_VM_ISOLATION,
3184+
}
3185+
)
3186+
3187+
# create
3188+
create_cmd = (
3189+
"aks create --resource-group={resource_group} --name={name} --location={location} "
3190+
"--os-sku AzureLinux --workload-runtime {workload_runtime} --node-count 1 "
3191+
"--node-vm-size Standard_D4s_v3"
3192+
)
3193+
self.cmd(
3194+
create_cmd,
3195+
checks=[
3196+
self.exists("fqdn"),
3197+
self.exists("nodeResourceGroup"),
3198+
self.check("provisioningState", "Succeeded"),
3199+
self.check("agentPoolProfiles[0].workloadRuntime", CONST_WORKLOAD_RUNTIME_OLD_KATA_VM_ISOLATION),
3200+
],
3201+
)
3202+
3203+
# delete
3204+
self.cmd(
3205+
"aks delete -g {resource_group} -n {name} --yes --no-wait",
3206+
checks=[self.is_empty()],
3207+
)
3208+
3209+
@AllowLargeResponse()
3210+
@AKSCustomResourceGroupPreparer(
3211+
random_name_length=17, name_prefix="clitest", location="westus2"
3212+
)
3213+
def test_aks_nodepool_add_with_kata_mshv_vm_isolation(
3214+
self, resource_group, resource_group_location
3215+
):
3216+
# reset the count so in replay mode the random names will start with 0
3217+
self.test_resources_count = 0
3218+
# kwargs for string formatting
3219+
aks_name = self.create_random_name("cliakstest", 16)
3220+
node_pool_name = self.create_random_name('c', 6)
3221+
node_pool_name_second = self.create_random_name('c', 6)
3222+
self.kwargs.update(
3223+
{
3224+
"resource_group": resource_group,
3225+
"name": aks_name,
3226+
"node_pool_name": node_pool_name,
3227+
"node_pool_name_second": node_pool_name_second,
3228+
"location": resource_group_location,
3229+
"resource_type": "Microsoft.ContainerService/ManagedClusters",
3230+
"workload_runtime": CONST_WORKLOAD_RUNTIME_OLD_KATA_VM_ISOLATION,
3231+
}
3232+
)
3233+
3234+
# create
3235+
create_cmd = (
3236+
"aks create --resource-group={resource_group} --name={name} "
3237+
"--nodepool-name {node_pool_name} -c 1"
3238+
)
3239+
self.cmd(create_cmd, checks=[
3240+
self.check('provisioningState', 'Succeeded'),
3241+
])
3242+
3243+
# nodepool update with kata
3244+
update_cmd = (
3245+
"aks nodepool add --cluster-name={name} --resource-group={resource_group} "
3246+
"--name={node_pool_name_second} --os-sku AzureLinux "
3247+
"--workload-runtime {workload_runtime} --node-vm-size Standard_D4s_v3"
3248+
)
3249+
3250+
self.cmd(
3251+
update_cmd,
3252+
checks=[
3253+
self.check("provisioningState", "Succeeded"),
3254+
self.check("workloadRuntime", CONST_WORKLOAD_RUNTIME_OLD_KATA_VM_ISOLATION),
3255+
],
3256+
)
3257+
3258+
# delete
3259+
self.cmd(
3260+
"aks delete -g {resource_group} -n {name} --yes --no-wait",
3261+
checks=[self.is_empty()],
3262+
)
3263+
30653264
@AllowLargeResponse()
30663265
@AKSCustomResourceGroupPreparer(random_name_length=17, name_prefix='clitest', location='westus')
30673266
def test_aks_nodepool_add_with_ossku_ubuntu2204(self, resource_group, resource_group_location):

0 commit comments

Comments
 (0)