Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[az][load] bug fixes on kvrefid splitcsv & terminal state #8297

Merged
merged 6 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[az][load] bug fixes on kvrefid splitcsv & terminal state
  • Loading branch information
mbhardwaj-msft committed Nov 21, 2024
commit b8a52d7e729c955d5485b018cc8bcdc1bf78ef9e
4 changes: 4 additions & 0 deletions src/load/azext_load/data_plane/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ def convert_yaml_to_test(data):
"Quick start test is not supported currently in CLI. Please use portal to run quick start test"
)
if data.get("splitAllCSVs") is not None:
if not isinstance(data.get("splitAllCSVs"), bool):
raise InvalidArgumentValueError(
"Invalid value for splitAllCSVs. Allowed values are boolean true or false"
)
new_body["loadTestConfiguration"]["splitAllCSVs"] = data.get("splitAllCSVs")

if data.get("failureCriteria"):
Expand Down
8 changes: 6 additions & 2 deletions src/load/azext_load/tests/latest/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ class LoadConstants:
INVALID_ZIP_ARTIFACT_LOAD_TEST_CONFIG_FILE = os.path.join(
TEST_RESOURCES_DIR, r"invalid-config-with-zip-artifacts.yaml"
)
LOAD_TEST_CONFIG_FILE_KVREFID = os.path.join(TEST_RESOURCES_DIR, r"config-with-kvrefid.yaml")
LOAD_TEST_CONFIG_FILE_KVREFID = os.path.join(TEST_RESOURCES_DIR, r"config-kvrefid.yaml")
LOAD_TEST_CONFIG_FILE_INVALID_KVREFID = os.path.join(TEST_RESOURCES_DIR, r"config-invalid-kvrefid.yaml")
LOAD_TEST_CONFIG_FILE_SPLITCSV_FALSE = os.path.join(TEST_RESOURCES_DIR, r"config-splitcsv-false.yaml")
LOAD_TEST_CONFIG_FILE_INVALID_SPLITCSV = os.path.join(TEST_RESOURCES_DIR, r"config-invalid-splitcsv.yaml")
TEST_PLAN = os.path.join(TEST_RESOURCES_DIR, r"sample-JMX-file.jmx")
ADDITIONAL_FILE = os.path.join(TEST_RESOURCES_DIR, r"additional-data.csv")
FILE_NAME = "sample-JMX-file.jmx"
Expand Down Expand Up @@ -88,7 +91,8 @@ class LoadTestConstants(LoadConstants):
APP_COMPONENT_TEST_ID = "app-component-test-case"
SERVER_METRIC_TEST_ID = "server-metric-test-case"
FILE_TEST_ID = "file-test-case"
CREATE_TEST_KVREF_ID = "create-testwithkvrefid-case"
LOAD_TEST_KVREF_ID = "loadtest-kvrefid-case"
LOAD_TEST_SPLITCSV_ID = "loadtest-splitcsv-case"

INVALID_UPDATE_TEST_ID = "invalid-update-test-case"
INVALID_PF_TEST_ID = "invalid-pf-test-case"
Expand Down
3,025 changes: 2,850 additions & 175 deletions src/load/azext_load/tests/latest/recordings/test_load_test_kvrefid.yaml

Large diffs are not rendered by default.

1,876 changes: 1,453 additions & 423 deletions src/load/azext_load/tests/latest/recordings/test_load_test_splitcsv.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Invalid key vault reference identity value
displayName: CLI-Test
testPlan: sample-JMX-file.jmx
description: 'Test created from az load test command'
engineInstances: 1
configurationFiles:
- additional-data.csv
zipArtifacts:
- sample-ZIP-artifact.zip
failureCriteria:
- avg(requests_per_sec) > 78
- percentage(error) > 50
- GetCustomerDetails: avg(latency) > 200
env:
- name: 'rps'
value: 1
splitAllCSVs: False
autoStop:
errorPercentage: 90
timeWindow: 60
keyVaultReferenceIdentity: Random
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Invalid split csv value
testPlan: sample-JMX-file.jmx
engineInstances: 1
configurationFiles:
- additional-data.csv
zipArtifacts:
- sample-ZIP-artifact.zip
failureCriteria:
- avg(requests_per_sec) > 78
- percentage(error) > 50
- GetCustomerDetails: avg(latency) > 200
env:
- name: 'rps'
value: 1
splitAllCSVs: random
autoStop:
errorPercentage: 90
timeWindow: 60
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Valid key vault reference identity configuration
displayName: CLI-Test
testPlan: sample-JMX-file.jmx
description: 'Test created from az load test command'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Valid split csv false configuration
testPlan: sample-JMX-file.jmx
engineInstances: 1
configurationFiles:
- additional-data.csv
zipArtifacts:
- sample-ZIP-artifact.zip
failureCriteria:
- avg(requests_per_sec) > 78
- percentage(error) > 50
- GetCustomerDetails: avg(latency) > 200
env:
- name: 'rps'
value: 1
splitAllCSVs: false
autoStop:
errorPercentage: 90
timeWindow: 60
176 changes: 163 additions & 13 deletions src/load/azext_load/tests/latest/test_load_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1099,19 +1099,19 @@ def test_load_test_file(self):
@LoadTestResourcePreparer(**load_params)
@StorageAccountPreparer(**sa_params)
def test_load_test_kvrefid(self, rg, load):
# Create load test from config file with keyvault reference id
self.kwargs.update(
{
"test_id": LoadTestConstants.CREATE_TEST_KVREF_ID,
"test_id": LoadTestConstants.LOAD_TEST_KVREF_ID,
"load_test_config_file": LoadTestConstants.LOAD_TEST_CONFIG_FILE_KVREFID,
}
)
checks = [
JMESPathCheck("testId", LoadTestConstants.CREATE_TEST_KVREF_ID),
JMESPathCheck("testId", LoadTestConstants.LOAD_TEST_KVREF_ID),
JMESPathCheck(
"keyvaultReferenceIdentityId", LoadTestConstants.KEYVAULT_REFERENCE_ID
),
]
# Create load test from config file with keyvault reference id
self.cmd(
"az load test create "
"--test-id {test_id} "
Expand All @@ -1120,10 +1120,10 @@ def test_load_test_kvrefid(self, rg, load):
'--load-test-config-file "{load_test_config_file}" ',
checks=checks,
)

# Update test with keyvault reference id null using parameters
self.kwargs.update(
{
"test_id": LoadTestConstants.CREATE_TEST_KVREF_ID,
"test_id": LoadTestConstants.LOAD_TEST_KVREF_ID,
"keyvault_reference_id": "null",
}
)
Expand All @@ -1138,6 +1138,102 @@ def test_load_test_kvrefid(self, rg, load):
"--keyvault-reference-id {keyvault_reference_id} ",
checks=checks,
)
# Update test with keyvault reference id using parameters
self.kwargs.update(
{
"test_id": LoadTestConstants.LOAD_TEST_KVREF_ID,
"keyvault_reference_id": LoadTestConstants.KEYVAULT_REFERENCE_ID,
}
)
checks = [
JMESPathCheck("keyvaultReferenceIdentityType", "UserAssigned"),
JMESPathCheck(
"keyvaultReferenceIdentityId", LoadTestConstants.KEYVAULT_REFERENCE_ID
),
]
self.cmd(
"az load test update "
"--test-id {test_id} "
"--load-test-resource {load_test_resource} "
"--resource-group {resource_group} "
"--keyvault-reference-id {keyvault_reference_id} ",
checks=checks,
)
# Update test with keyvault reference id not provided in config file
self.kwargs.update(
{
"test_id": LoadTestConstants.LOAD_TEST_KVREF_ID,
"load_test_config_file": LoadTestConstants.LOAD_TEST_CONFIG_FILE,
}
)
checks = [
JMESPathCheck("keyvaultReferenceIdentityType", "SystemAssigned"),
]
self.cmd(
"az load test update "
"--test-id {test_id} "
"--load-test-resource {load_test_resource} "
'--load-test-config-file "{load_test_config_file}" '
"--resource-group {resource_group} ",
checks=checks,
)
# Update test with keyvault reference id using CLI arguments when
# both parameters and config file are provided
self.kwargs.update(
{
"test_id": LoadTestConstants.LOAD_TEST_KVREF_ID,
"keyvault_reference_id": LoadTestConstants.KEYVAULT_REFERENCE_ID,
"load_test_config_file": LoadTestConstants.LOAD_TEST_CONFIG_FILE_KVREFID,
}
)
checks = [
JMESPathCheck("keyvaultReferenceIdentityType", "UserAssigned"),
JMESPathCheck(
"keyvaultReferenceIdentityId", LoadTestConstants.KEYVAULT_REFERENCE_ID
),
]
self.cmd(
"az load test update "
"--test-id {test_id} "
"--load-test-resource {load_test_resource} "
'--load-test-config-file "{load_test_config_file}" '
"--resource-group {resource_group} "
"--keyvault-reference-id {keyvault_reference_id} ",
checks=checks,
)
# Invalid test case for keyvault reference id
self.kwargs.update(
{
"test_id": LoadTestConstants.LOAD_TEST_KVREF_ID,
"keyvault_reference_id": "Random",
}
)
try:
self.cmd(
"az load test update "
"--test-id {test_id} "
"--load-test-resource {load_test_resource} "
"--resource-group {resource_group} "
"--keyvault-reference-id {keyvault_reference_id} ",
)
except Exception as e:
assert "(InvalidManagedIdentity)" in str(e)
self.kwargs.update(
{
"test_id": LoadTestConstants.LOAD_TEST_KVREF_ID,
"load_test_config_file": LoadTestConstants.LOAD_TEST_CONFIG_FILE_INVALID_KVREFID,
}
)
try:
self.cmd(
"az load test update "
"--test-id {test_id} "
"--load-test-resource {load_test_resource} "
'--load-test-config-file "{load_test_config_file}" '
"--resource-group {resource_group} ",
)
except Exception as e:
assert "(InvalidManagedIdentity)" in str(e)

@ResourceGroupPreparer(**rg_params)
@LoadTestResourcePreparer(**load_params)
Expand All @@ -1146,7 +1242,7 @@ def test_load_test_splitcsv(self, rg, load):
# Create load test from config file with split csv true
self.kwargs.update(
{
"test_id": LoadTestConstants.CREATE_TEST_ID,
"test_id": LoadTestConstants.LOAD_TEST_SPLITCSV_ID,
"load_test_config_file": LoadTestConstants.LOAD_TEST_CONFIG_FILE,
}
)
Expand All @@ -1162,10 +1258,10 @@ def test_load_test_splitcsv(self, rg, load):
'--load-test-config-file "{load_test_config_file}" ',
checks=checks,
)
# Update test with split csv false
# Update test with split csv false from CLI arguments
self.kwargs.update(
{
"test_id": LoadTestConstants.CREATE_TEST_ID,
"test_id": LoadTestConstants.LOAD_TEST_SPLITCSV_ID,
"split_csv": LoadTestConstants.SPLIT_CSV_FALSE,
}
)
Expand All @@ -1180,10 +1276,10 @@ def test_load_test_splitcsv(self, rg, load):
"--split-csv {split_csv} ",
checks=checks,
)
# Update test with split csv true
# Update test with split csv true from CLI arguments
self.kwargs.update(
{
"test_id": LoadTestConstants.CREATE_TEST_ID,
"test_id": LoadTestConstants.LOAD_TEST_SPLITCSV_ID,
"split_csv": LoadTestConstants.SPLIT_CSV_TRUE,
}
)
Expand All @@ -1201,8 +1297,8 @@ def test_load_test_splitcsv(self, rg, load):
# Update test with split csv false using config file
self.kwargs.update(
{
"test_id": LoadTestConstants.CREATE_TEST_ID,
"load_test_config_file": LoadTestConstants.LOAD_TEST_CONFIG_FILE_KVREFID,
"test_id": LoadTestConstants.LOAD_TEST_SPLITCSV_ID,
"load_test_config_file": LoadTestConstants.LOAD_TEST_CONFIG_FILE_SPLITCSV_FALSE,
}
)
checks = [
Expand All @@ -1215,4 +1311,58 @@ def test_load_test_splitcsv(self, rg, load):
"--resource-group {resource_group} "
'--load-test-config-file "{load_test_config_file}" ',
checks=checks,
)
)
# Update test with split csv CLI parameter when
# both config file and CLI parameter are provided
self.kwargs.update(
{
"test_id": LoadTestConstants.LOAD_TEST_SPLITCSV_ID,
"split_csv": LoadTestConstants.SPLIT_CSV_TRUE,
"load_test_config_file": LoadTestConstants.LOAD_TEST_CONFIG_FILE_SPLITCSV_FALSE,
}
)
checks = [
JMESPathCheck("loadTestConfiguration.splitAllCSVs", True),
]
self.cmd(
"az load test update "
"--test-id {test_id} "
"--load-test-resource {load_test_resource} "
'--load-test-config-file "{load_test_config_file}" '
"--resource-group {resource_group} "
"--split-csv {split_csv} ",
checks=checks,
)
# Invalid test case for split csv
self.kwargs.update(
{
"test_id": LoadTestConstants.LOAD_TEST_SPLITCSV_ID,
"split_csv": "Random",
}
)
try:
self.cmd(
"az load test update "
"--test-id {test_id} "
"--load-test-resource {load_test_resource} "
"--resource-group {resource_group} "
"--split-csv {split_csv} ",
)
except Exception as e:
assert "Invalid split-csv value: Random. Allowed values: true, false, yes, no, y, n" in str(e)
self.kwargs.update(
{
"test_id": LoadTestConstants.LOAD_TEST_SPLITCSV_ID,
"load_test_config_file": LoadTestConstants.LOAD_TEST_CONFIG_FILE_INVALID_SPLITCSV,
}
)
try:
self.cmd(
"az load test update "
"--test-id {test_id} "
"--load-test-resource {load_test_resource} "
'--load-test-config-file "{load_test_config_file}" '
"--resource-group {resource_group} ",
)
except Exception as e:
assert "Invalid value for splitAllCSVs. Allowed values are boolean true or false" in str(e)
Loading