Skip to content

Commit 9fe969b

Browse files
committed
Add invalid test case
1 parent fc51508 commit 9fe969b

File tree

4 files changed

+64
-2
lines changed

4 files changed

+64
-2
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,8 @@ def validate_autostop_maximum_virtual_users_per_engine(namespace):
486486
def _validate_autostop_disable_configfile(autostop):
487487
if autostop.casefold() not in ["disable"]:
488488
raise InvalidArgumentValueError(
489-
"Invalid value for autoStop. Valid values are 'disable' or an object with errorPercentage and timeWindow"
489+
"Invalid value for autoStop. Valid values are 'disable' or an object with errorPercentage, timeWindow "
490+
"and/or maximumVirtualUsersPerEngine"
490491
)
491492

492493

src/load/azext_load/tests/latest/constants.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ class LoadConstants:
132132
LOAD_TEST_CONFIG_FILE_WITH_INVALID_AUTOSTOP_TIME_WINDOW = os.path.join(
133133
TEST_RESOURCES_DIR, r"config-invalid-autostop-criteria-time-window.yaml"
134134
)
135+
LOAD_TEST_CONFIG_FILE_WITH_INVALID_AUTOSTOP_MAX_VU_PER_ENGINE = os.path.join(
136+
TEST_RESOURCES_DIR, r"config-invalid-autostop-criteria-max-vu-per-engine.yaml"
137+
)
135138
LOAD_TEST_CONFIG_FILE_WITH_INVALID_AUTOSTOP = os.path.join(
136139
TEST_RESOURCES_DIR, r"config-invalid-autostop-criteria-random-string.yaml"
137140
)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Invalid autoStop criteria: timeWindow is negative
2+
displayName: CLI-Test
3+
testPlan: sample-JMX-file.jmx
4+
description: 'Test created from az load test command'
5+
engineInstances: 1
6+
configurationFiles:
7+
- additional-data.csv
8+
zipArtifacts:
9+
- sample-ZIP-artifact.zip
10+
failureCriteria:
11+
- avg(requests_per_sec) > 78
12+
- percentage(error) > 50
13+
- GetCustomerDetails: avg(latency) > 200
14+
env:
15+
- name: 'rps'
16+
value: 1
17+
splitAllCSVs: True
18+
autoStop:
19+
errorPercentage: 87.5
20+
timeWindow: 5
21+
maximumVirtualUsersPerEngine: 0

src/load/azext_load/tests/latest/test_load_autostop_criteria.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,20 @@ def test_load_test_autostop(self):
196196
autostop_error_rate_time_window=-1,
197197
)
198198

199+
# Invalid autostop test case: autostop maximum VU per engine = 0
200+
_configure_command_assert_exception(
201+
self,
202+
"Autostop maximum users per engine should be greater than 0",
203+
autostop_maximum_vu_per_engine=0,
204+
)
205+
206+
# Invalid autostop test case: autostop maximum VU per engine < 0
207+
_configure_command_assert_exception(
208+
self,
209+
"Autostop maximum users per engine should be greater than 0",
210+
autostop_maximum_vu_per_engine=0,
211+
)
212+
199213
# Invalid autostop test case: autostop error rate time window not of integer type
200214
# This is not needed as the argument is type checked
201215
# argument --autostop-time-window: invalid int value: '90.4'
@@ -204,7 +218,7 @@ def test_load_test_autostop(self):
204218
# Invalid autostop from config test case: autostop random string
205219
_configure_command_assert_exception(
206220
self,
207-
"Invalid value for autoStop. Valid values are 'disable' or an object with errorPercentage and timeWindow",
221+
"Invalid value for autoStop. Valid values are 'disable' or an object with errorPercentage, timeWindow and/or maximumVirtualUsersPerEngine",
208222
load_test_config_file=LoadTestConstants.LOAD_TEST_CONFIG_FILE_WITH_INVALID_AUTOSTOP,
209223
)
210224

@@ -222,13 +236,21 @@ def test_load_test_autostop(self):
222236
load_test_config_file=LoadTestConstants.LOAD_TEST_CONFIG_FILE_WITH_INVALID_AUTOSTOP_TIME_WINDOW,
223237
)
224238

239+
# Invalid autostop from config test case: autostop time window < 0
240+
_configure_command_assert_exception(
241+
self,
242+
"Invalid value for maximumVirtualUserPerEngine. Value should be an integer greater than 0",
243+
load_test_config_file=LoadTestConstants.LOAD_TEST_CONFIG_FILE_WITH_INVALID_AUTOSTOP_MAX_VU_PER_ENGINE,
244+
)
245+
225246

226247
def _configure_command_jmes_checks(
227248
self,
228249
checks,
229250
autostop=None,
230251
autostop_error_rate=None,
231252
autostop_error_rate_time_window=None,
253+
autostop_maximum_vu_per_engine=None,
232254
load_test_config_file=None,
233255
):
234256
command = (
@@ -258,6 +280,13 @@ def _configure_command_jmes_checks(
258280
}
259281
)
260282
command += "--autostop-time-window {autostop_error_rate_time_window} "
283+
if autostop_maximum_vu_per_engine is not None:
284+
self.kwargs.update(
285+
{
286+
"autostop_maximum_vu_per_engine": autostop_maximum_vu_per_engine,
287+
}
288+
)
289+
command += "--autostop-engine-users {autostop_maximum_vu_per_engine} "
261290
if load_test_config_file is not None:
262291
self.kwargs.update(
263292
{
@@ -277,6 +306,7 @@ def _configure_command_assert_exception(
277306
autostop=None,
278307
autostop_error_rate=None,
279308
autostop_error_rate_time_window=None,
309+
autostop_maximum_vu_per_engine=None,
280310
load_test_config_file=None,
281311
):
282312
command = (
@@ -306,6 +336,13 @@ def _configure_command_assert_exception(
306336
}
307337
)
308338
command += "--autostop-time-window {autostop_error_rate_time_window} "
339+
if autostop_maximum_vu_per_engine is not None:
340+
self.kwargs.update(
341+
{
342+
"autostop_maximum_vu_per_engine": autostop_maximum_vu_per_engine,
343+
}
344+
)
345+
command += "--autostop-engine-users {autostop_maximum_vu_per_engine} "
309346
if load_test_config_file is not None:
310347
self.kwargs.update(
311348
{

0 commit comments

Comments
 (0)