Skip to content

Commit

Permalink
Test case fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mukhoakash committed Feb 28, 2024
1 parent 5b47e73 commit c6a6c25
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def validate_enable_azure_container_storage_params(
'Cannot set --storage-pool-option when --enable-azure-container-storage is not ephemeralDisk.'
)

_validate_storage_pool_size(storage_pool_size, storage_pool_type)
_validate_storage_pool_size(storage_pool_size, storage_pool_type)

if is_extension_installed:
if nodepool_list is not None:
Expand Down
40 changes: 25 additions & 15 deletions src/aks-preview/azext_aks_preview/tests/latest/test_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
ArgumentUsageError,
InvalidArgumentValueError,
MutuallyExclusiveArgumentError,
RequiredArgumentMissingError,
)
from azure.cli.core.util import CLIError

Expand Down Expand Up @@ -716,8 +717,7 @@ def test_disable_when_extension_not_installed(self):
is_extension_installed = False
err = (
"Invalid usage of --disable-azure-container-storage. "
"Azure Container Storage is not enabled on the cluster. "
"Aborting disabling of Azure Container Storage."
"Azure Container Storage is not enabled on the cluster."
)
with self.assertRaises(InvalidArgumentValueError) as cm:
acstor_validator.validate_disable_azure_container_storage_params(
Expand Down Expand Up @@ -805,7 +805,7 @@ def test_disable_type_when_not_enabled(self):
err = (
"Invalid --disable-azure-container-storage value. "
"Azure Container Storage is not enabled for storagepool "
"type {0} in the cluster.".format(storage_pool_type)
"type {0} in the cluster.".format(pool_type)
)
with self.assertRaises(ArgumentUsageError) as cm:
acstor_validator.validate_disable_azure_container_storage_params(
Expand Down Expand Up @@ -926,7 +926,7 @@ def test_invalid_comma_separated_nodepool_list(self):
nodepool_list = "pool1, 1pool"
storage_pool_name = "valid-name"
storage_pool_size = "5Ti"
storage_pool_type = acstor_consts.CONST_STORAGE_POOL_TYPE_EPHEMERAL_DISK
storage_pool_type = acstor_consts.CONST_STORAGE_POOL_TYPE_AZURE_DISK
err = (
"Invalid --azure-container-storage-nodepools value. "
"Accepted value is a comma separated string of valid nodepool "
Expand All @@ -943,6 +943,7 @@ def test_missing_nodepool_from_cluster_nodepool_list_single(self):
storage_pool_name = "valid-name"
storage_pool_size = "5Ti"
storage_pool_type = acstor_consts.CONST_STORAGE_POOL_TYPE_EPHEMERAL_DISK
storage_pool_option = acstor_consts.CONST_STORAGE_POOL_OPTION_NVME
nodepool_list = "pool1"
agentpools = [{"name": "nodepool1"}]
err = (
Expand All @@ -953,14 +954,15 @@ def test_missing_nodepool_from_cluster_nodepool_list_single(self):
)
with self.assertRaises(InvalidArgumentValueError) as cm:
acstor_validator.validate_enable_azure_container_storage_params(
storage_pool_type, storage_pool_name, None, None, storage_pool_size, nodepool_list, agentpools, False, False, False, False, False
storage_pool_type, storage_pool_name, None, storage_pool_option, storage_pool_size, nodepool_list, agentpools, False, False, False, False, False
)
self.assertEqual(str(cm.exception), err)

def test_missing_nodepool_from_cluster_nodepool_list_multiple(self):
storage_pool_name = "valid-name"
storage_pool_size = "5Ti"
storage_pool_type = acstor_consts.CONST_STORAGE_POOL_TYPE_EPHEMERAL_DISK
storage_pool_option = acstor_consts.CONST_STORAGE_POOL_OPTION_SSD
nodepool_list = "pool1,pool2"
agentpools = [{"name": "nodepool1"}, {"name": "nodepool2"}]
err = (
Expand All @@ -971,7 +973,7 @@ def test_missing_nodepool_from_cluster_nodepool_list_multiple(self):
)
with self.assertRaises(InvalidArgumentValueError) as cm:
acstor_validator.validate_enable_azure_container_storage_params(
storage_pool_type, storage_pool_name, None, None, storage_pool_size, nodepool_list, agentpools, False, False, False, False, False
storage_pool_type, storage_pool_name, None, storage_pool_option, storage_pool_size, nodepool_list, agentpools, False, False, False, False, False
)
self.assertEqual(str(cm.exception), err)

Expand All @@ -992,31 +994,39 @@ def test_valid_enable_for_ephemeral_disk_pool(self):
storage_pool_type = acstor_consts.CONST_STORAGE_POOL_TYPE_EPHEMERAL_DISK
storage_pool_option = acstor_consts.CONST_STORAGE_POOL_OPTION_NVME
nodepool_list = "nodepool1"
agentpools = [{"name": "nodepool1"}, {"name": "nodepool2"}]
agentpools = [{"name": "nodepool1", "vm_size": "Standard_L8s_v3"}, {"name": "nodepool2", "vm_size": "Standard_L8s_v3"}]
acstor_validator.validate_enable_azure_container_storage_params(
storage_pool_type, storage_pool_name, None, storage_pool_option, storage_pool_size, nodepool_list, agentpools, False, False, False, False, False
)

def test_extension_installed_nodepool_list_defined(self):
storage_pool_type = acstor_consts.CONST_STORAGE_POOL_TYPE_AZURE_DISK
nodepool_list = "nodepool1,nodepool2"
err = 'Cannot set --azure-container-storage-nodepools while using '
'--enable-azure-container-storage to enable a type of storagepool '
'in a cluster where Azure Container Storage is already installed.'
err = (
"Cannot set --azure-container-storage-nodepools while using "
"--enable-azure-container-storage to enable a type of storagepool "
"in a cluster where Azure Container Storage is already installed."
)
with self.assertRaises(ArgumentUsageError) as cm:
acstor_validator.validate_enable_azure_container_storage_params(
storage_pool_type, None, None, None, None, nodepool_list, None, True, False, False, False, False
)
self.assertEqual(str(cm.exception), err)

def test_extension_installed_storagepool_type_installed(self):
storage_pool_name = "valid-name"
storage_pool_size = "5Ti"
storage_pool_type = acstor_consts.CONST_STORAGE_POOL_TYPE_AZURE_DISK
err = "Invalid --enable-azure-container-storage value. "
"Azure Container Storage is already enabled for storagepool type "
"{0} in the cluster.".format(storage_pool_type)
storage_pool_sku = acstor_consts.CONST_STORAGE_POOL_SKU_PREMIUM_LRS
agentpools = [{"name": "nodepool1", "node_labels": {"acstor.azure.com/io-engine": "acstor"}}, {"name": "nodepool2"}]
err = (
"Invalid --enable-azure-container-storage value. "
"Azure Container Storage is already enabled for storagepool type "
"{0} in the cluster.".format(storage_pool_type)
)
with self.assertRaises(ArgumentUsageError) as cm:
acstor_validator.validate_enable_azure_container_storage_params(
storage_pool_type, None, None, None, None, None, None, True, True, False, False, False
storage_pool_type, storage_pool_name, storage_pool_sku, None, storage_pool_size, None, agentpools, True, True, False, False, False
)
self.assertEqual(str(cm.exception), err)

Expand All @@ -1025,7 +1035,7 @@ def test_valid_cluster_update(self):
storage_pool_size = "5Ti"
storage_pool_type = acstor_consts.CONST_STORAGE_POOL_TYPE_AZURE_DISK
storage_pool_sku = acstor_consts.CONST_STORAGE_POOL_SKU_PREMIUM_LRS
agentpools = [{"name": "nodepool1"}, {"name": "nodepool2"}]
agentpools = [{"name": "nodepool1", "node_labels": {"acstor.azure.com/io-engine": "acstor"}}, {"name": "nodepool2"}]
acstor_validator.validate_enable_azure_container_storage_params(
storage_pool_type, storage_pool_name, None, None, storage_pool_size, None, agentpools, True, False, False, False, False
)
Expand Down

0 comments on commit c6a6c25

Please sign in to comment.