Skip to content

Commit 0615649

Browse files
authored
[load] API version refresh - 2025-03-01-preview (#8682)
* Add --autostop-engine-users * Format and organize imports * Update validators * Add invalid test case * Update vendored SDK and bump version * Fix vendored SDK imports * Fix trigger * Mask secrets
1 parent 4facbad commit 0615649

88 files changed

Lines changed: 762853 additions & 293798 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/load/HISTORY.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
Release History
44
===============
55

6+
2.1.0
7+
++++++
8+
* Add option for `--autostop-engine-users` to set maximum users per engine for AutoStop criteria.
9+
* Update API version to 2025-03-01-preview.
10+
611
2.0.0
712
++++++
813
* Add commands for creating and managing notification rules using CLI.

src/load/azext_load/data_plane/load_notifications/custom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def list_notification_rules(
109109
if test_ids:
110110
test_ids = ",".join(test_ids)
111111
logger.info("Filtering notification rules by test ids: %s", test_ids)
112-
responses = client.list_notification_rule(test_ids=test_ids)
112+
responses = client.list_notification_rules(test_ids=test_ids)
113113
logger.info("Retrieved notification rules: %s", responses)
114114
return [response.as_dict() for response in responses]
115115

src/load/azext_load/data_plane/load_test/custom.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def create_test(
6060
autostop=None,
6161
autostop_error_rate=None,
6262
autostop_error_rate_time_window=None,
63+
autostop_maximum_virtual_users_per_engine=None,
6364
regionwise_engines=None,
6465
engine_ref_id_type=None,
6566
engine_ref_ids=None,
@@ -80,7 +81,10 @@ def create_test(
8081
yaml, yaml_test_body = None, None
8182
app_components, add_defaults_to_app_components, server_metrics = None, None, None
8283
autostop_criteria = create_autostop_criteria_from_args(
83-
autostop=autostop, error_rate=autostop_error_rate, time_window=autostop_error_rate_time_window)
84+
autostop=autostop,
85+
error_rate=autostop_error_rate,
86+
time_window=autostop_error_rate_time_window,
87+
max_vu_per_engine=autostop_maximum_virtual_users_per_engine)
8488
if load_test_config_file is None:
8589
test_type = test_type or infer_test_type_from_test_plan(test_plan)
8690
logger.debug("Inferred test type: %s", test_type)
@@ -198,6 +202,7 @@ def update_test(
198202
autostop=None,
199203
autostop_error_rate=None,
200204
autostop_error_rate_time_window=None,
205+
autostop_maximum_virtual_users_per_engine=None,
201206
regionwise_engines=None,
202207
engine_ref_id_type=None,
203208
engine_ref_ids=None,
@@ -215,7 +220,10 @@ def update_test(
215220
yaml, yaml_test_body = None, None
216221
app_components, server_metrics, add_defaults_to_app_components = None, None, None
217222
autostop_criteria = create_autostop_criteria_from_args(
218-
autostop=autostop, error_rate=autostop_error_rate, time_window=autostop_error_rate_time_window)
223+
autostop=autostop,
224+
error_rate=autostop_error_rate,
225+
time_window=autostop_error_rate_time_window,
226+
max_vu_per_engine=autostop_maximum_virtual_users_per_engine)
219227
if load_test_config_file is not None:
220228
yaml = load_yaml(load_test_config_file)
221229
yaml_test_body = convert_yaml_to_test(cmd, yaml)

src/load/azext_load/data_plane/load_test/help.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
az load test create --test-id sample-test-id --load-test-resource sample-alt-resource --resource-group sample-rg --display-name "Sample Name" --subnet-id "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/sample-rg/providers/Microsoft.Network/virtualNetworks/SampleVMVNET/subnets/SampleVMSubnet" --split-csv true
3535
- name: Create a test with custom defined autostop criteria or enable / disable autostop for a test.
3636
text: |
37-
az load test create --test-id sample-test-id --load-test-resource sample-alt-resource --resource-group sample-rg --display-name "Sample Name" --autostop-error-rate 80.5 --autostop-time-window 120
37+
az load test create --test-id sample-test-id --load-test-resource sample-alt-resource --resource-group sample-rg --display-name "Sample Name" --autostop-error-rate 80.5 --autostop-time-window 120 --autostop-engine-users 1000
3838
az load test create --test-id sample-test-id --load-test-resource sample-alt-resource --resource-group sample-rg --display-name "Sample Name" --autostop disable
3939
az load test create --test-id sample-test-id --load-test-resource sample-alt-resource --resource-group sample-rg --display-name "Sample Name" --autostop enable
4040
- name: Create a test with a multi-region load configuration using region names in the format accepted by Azure Resource Manager (ARM). Ensure the specified regions are supported by Azure Load Testing. Multi-region load tests are restricted to public endpoints only.

src/load/azext_load/data_plane/load_test/params.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def load_arguments(self, _):
3636
c.argument("autostop", argtypes.autostop)
3737
c.argument("autostop_error_rate", argtypes.autostop_error_rate)
3838
c.argument("autostop_error_rate_time_window", argtypes.autostop_error_rate_time_window)
39+
c.argument("autostop_maximum_virtual_users_per_engine", argtypes.autostop_maximum_virtual_users_per_engine)
3940
c.argument("regionwise_engines", argtypes.regionwise_engines)
4041
c.argument("engine_ref_id_type", argtypes.engine_ref_id_type)
4142
c.argument("engine_ref_ids", argtypes.engine_ref_ids)
@@ -62,6 +63,7 @@ def load_arguments(self, _):
6263
c.argument("autostop", argtypes.autostop)
6364
c.argument("autostop_error_rate", argtypes.autostop_error_rate)
6465
c.argument("autostop_error_rate_time_window", argtypes.autostop_error_rate_time_window)
66+
c.argument("autostop_maximum_virtual_users_per_engine", argtypes.autostop_maximum_virtual_users_per_engine)
6567
c.argument("regionwise_engines", argtypes.regionwise_engines)
6668
c.argument("engine_ref_id_type", argtypes.engine_ref_id_type)
6769
c.argument("engine_ref_ids", argtypes.engine_ref_ids)

src/load/azext_load/data_plane/load_trigger/custom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,6 @@ def list_trigger_schedules(
242242
if test_ids:
243243
test_ids = ",".join(test_ids)
244244
logger.info("Schedule trigger states: %s", trigger_states)
245-
response_list = client.list_trigger(test_ids=test_ids, states=trigger_states)
245+
response_list = client.list_triggers(test_ids=test_ids, states=trigger_states)
246246
logger.debug("Fetched list of schedule triggers: %s", response_list)
247247
return [response.as_dict() for response in response_list]

src/load/azext_load/data_plane/utils/argtypes.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,13 @@
395395
help="Time window during which the error percentage should be evaluated in seconds.",
396396
)
397397

398+
autostop_maximum_virtual_users_per_engine = CLIArgumentType(
399+
options_list=["--autostop-engine-users"],
400+
type=int,
401+
validator=validators.validate_autostop_maximum_virtual_users_per_engine,
402+
help="Maximum number of users per engine at which the test will stop.",
403+
)
404+
398405
regionwise_engines = CLIArgumentType(
399406
options_list=["--regionwise-engines"],
400407
validator=validators.validate_regionwise_engines,

src/load/azext_load/data_plane/utils/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class LoadTestConfigKeys:
2424
AUTOSTOP = "autoStop"
2525
AUTOSTOP_ERROR_RATE = "errorPercentage"
2626
AUTOSTOP_ERROR_RATE_TIME_WINDOW = "timeWindow"
27+
AUTOSTOP_MAX_VU_PER_ENGINE = "maximumVirtualUsersPerEngine"
2728
FAILURE_CRITERIA = "failureCriteria"
2829
CLIENT_METRICS_PF = "clientMetrics"
2930
SERVER_METRICS_PF = "serverMetrics"

src/load/azext_load/data_plane/utils/utils.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,15 +274,17 @@ def parse_env(envs):
274274
return env_dict
275275

276276

277-
def create_autostop_criteria_from_args(autostop, error_rate, time_window):
278-
if (autostop is None and error_rate is None and time_window is None):
277+
def create_autostop_criteria_from_args(autostop, error_rate, time_window, max_vu_per_engine):
278+
if (autostop is None and error_rate is None and time_window is None and max_vu_per_engine is None):
279279
return None
280280
autostop_criteria = {}
281281
autostop_criteria["autoStopDisabled"] = not autostop if autostop is not None else False
282282
if error_rate is not None:
283283
autostop_criteria["errorRate"] = error_rate
284284
if time_window is not None:
285285
autostop_criteria["errorRateTimeWindowInSeconds"] = time_window
286+
if max_vu_per_engine is not None:
287+
autostop_criteria["maximumVirtualUsersPerEngine"] = max_vu_per_engine
286288
return autostop_criteria
287289

288290

@@ -591,10 +593,16 @@ def create_or_update_test_with_config(
591593
):
592594
new_body["autoStopCriteria"]["errorRateTimeWindowInSeconds"] = \
593595
body["autoStopCriteria"]["errorRateTimeWindowInSeconds"]
596+
if (
597+
new_body["autoStopCriteria"].get("maximumVirtualUsersPerEngine") is None
598+
and body.get("autoStopCriteria", {}).get("maximumVirtualUsersPerEngine") is not None
599+
):
600+
new_body["autoStopCriteria"]["maximumVirtualUsersPerEngine"] = \
601+
body["autoStopCriteria"]["maximumVirtualUsersPerEngine"]
594602

595603
if (new_body["autoStopCriteria"].get("autoStopDisabled") is True):
596604
logger.warning(
597-
"Auto stop is disabled. Error rate and time window will be ignored. "
605+
"Auto stop is disabled. Error rate, time window and engine users will be ignored. "
598606
"This can lead to incoming charges for an incorrectly configured test."
599607
)
600608

@@ -749,9 +757,15 @@ def create_or_update_test_without_config(
749757
):
750758
new_body["autoStopCriteria"]["errorRateTimeWindowInSeconds"] = \
751759
body["autoStopCriteria"]["errorRateTimeWindowInSeconds"]
760+
if (
761+
new_body["autoStopCriteria"].get("maximumVirtualUsersPerEngine") is None
762+
and body.get("autoStopCriteria", {}).get("maximumVirtualUsersPerEngine") is not None
763+
):
764+
new_body["autoStopCriteria"]["maximumVirtualUsersPerEngine"] = \
765+
body["autoStopCriteria"]["maximumVirtualUsersPerEngine"]
752766
if (new_body["autoStopCriteria"].get("autoStopDisabled") is True):
753767
logger.warning(
754-
"Auto stop is disabled. Error rate and time window will be ignored. "
768+
"Auto stop is disabled. Error rate, time window and engine users will be ignored. "
755769
"This can lead to incoming charges for an incorrectly configured test."
756770
)
757771
new_body["baselineTestRunId"] = baseline_test_run_id if baseline_test_run_id else body.get("baselineTestRunId")

src/load/azext_load/data_plane/utils/utils_yaml_config.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,18 @@ def yaml_parse_autostop_criteria(data):
2828
}
2929
error_rate = data[LoadTestConfigKeys.AUTOSTOP].get(LoadTestConfigKeys.AUTOSTOP_ERROR_RATE)
3030
time_window = data[LoadTestConfigKeys.AUTOSTOP].get(LoadTestConfigKeys.AUTOSTOP_ERROR_RATE_TIME_WINDOW)
31+
max_vu_per_engine = data[LoadTestConfigKeys.AUTOSTOP].get(LoadTestConfigKeys.AUTOSTOP_MAX_VU_PER_ENGINE)
3132
# pylint: disable-next=protected-access
32-
validators._validate_autostop_criteria_configfile(error_rate, time_window)
33+
validators._validate_autostop_criteria_configfile(error_rate, time_window, max_vu_per_engine)
3334
autostop_criteria = {
3435
"autoStopDisabled": False,
3536
}
3637
if error_rate is not None:
3738
autostop_criteria["errorRate"] = error_rate
3839
if time_window is not None:
3940
autostop_criteria["errorRateTimeWindowInSeconds"] = time_window
41+
if max_vu_per_engine is not None:
42+
autostop_criteria["maximumVirtualUsersPerEngine"] = max_vu_per_engine
4043
return autostop_criteria
4144

4245

0 commit comments

Comments
 (0)