Skip to content

Commit 3477cfa

Browse files
authored
[Azure Load Testing] Adding disable-public-ip argument in load extension (Azure#8239)
* Adding support for publicIPDisabled * Added test cases for public ip disabled param * Changing version from 1.1.2 to 1.2.0 as its minor changes and not patch * nit: condition refactoring and pushing new recordings * added more test cases * nit: fixing CI failures
1 parent 8021435 commit 3477cfa

33 files changed

+10513
-10100
lines changed

src/load/HISTORY.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
33
Release History
44
===============
5+
1.2.0
6+
++++++
7+
* Added support for disable public IP in test creation and update. This can be done by using --disable-public-ip argument in 'az load test create' and 'az load test update' commands.
8+
59
1.1.1
610
++++++
711
* Fix empty response object on CLI when using 'az load test file upload'

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def create_test(
4040
key_vault_reference_identity=None,
4141
subnet_id=None,
4242
split_csv=None,
43+
disable_public_ip=None,
4344
custom_no_wait=False,
4445
):
4546
client = get_admin_data_plane_client(cmd, load_test_resource, resource_group_name)
@@ -70,6 +71,7 @@ def create_test(
7071
key_vault_reference_identity=key_vault_reference_identity,
7172
subnet_id=subnet_id,
7273
split_csv=split_csv,
74+
disable_public_ip=disable_public_ip,
7375
)
7476
else:
7577
yaml = load_yaml(load_test_config_file)
@@ -87,6 +89,7 @@ def create_test(
8789
key_vault_reference_identity=key_vault_reference_identity,
8890
subnet_id=subnet_id,
8991
split_csv=split_csv,
92+
disable_public_ip=disable_public_ip,
9093
)
9194
logger.debug("Creating test with test ID: %s and body : %s", test_id, body)
9295
response = client.create_or_update_test(test_id=test_id, body=body)
@@ -119,6 +122,7 @@ def update_test(
119122
key_vault_reference_identity=None,
120123
subnet_id=None,
121124
split_csv=None,
125+
disable_public_ip=None,
122126
custom_no_wait=False,
123127
):
124128
client = get_admin_data_plane_client(cmd, load_test_resource, resource_group_name)
@@ -148,6 +152,7 @@ def update_test(
148152
key_vault_reference_identity=key_vault_reference_identity,
149153
subnet_id=subnet_id,
150154
split_csv=split_csv,
155+
disable_public_ip=disable_public_ip,
151156
)
152157
else:
153158
body = create_or_update_test_without_config(
@@ -162,6 +167,7 @@ def update_test(
162167
key_vault_reference_identity=key_vault_reference_identity,
163168
subnet_id=subnet_id,
164169
split_csv=split_csv,
170+
disable_public_ip=disable_public_ip,
165171
)
166172
logger.info("Updating test with test ID: %s", test_id)
167173
response = client.create_or_update_test(test_id=test_id, body=body)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def load_arguments(self, _):
2828
)
2929
c.argument("engine_instances", argtypes.engine_instances)
3030
c.argument("custom_no_wait", argtypes.custom_no_wait)
31+
c.argument("disable_public_ip", argtypes.disable_public_ip)
3132

3233
with self.argument_context("load test update") as c:
3334
c.argument("load_test_config_file", argtypes.load_test_config_file)
@@ -44,6 +45,7 @@ def load_arguments(self, _):
4445
c.argument("subnet_id", argtypes.subnet_id)
4546
c.argument("split_csv", argtypes.split_csv)
4647
c.argument("custom_no_wait", argtypes.custom_no_wait)
48+
c.argument("disable_public_ip", argtypes.disable_public_ip)
4749

4850
with self.argument_context("load test download-files") as c:
4951
c.argument("path", argtypes.dir_path)

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@
3434
help="Do not wait for the long-running operation to finish.",
3535
)
3636

37+
disable_public_ip = CLIArgumentType(
38+
validator=validators.validate_disable_public_ip,
39+
options_list=["--disable-public-ip"],
40+
type=str,
41+
help="Disable the deployment of a public IP address, load balancer, and network security group while testing a private endpoint.",
42+
)
43+
44+
3745
force = CLIArgumentType(
3846
options_list=["--force"],
3947
action="store_true",

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,8 @@ def convert_yaml_to_test(data):
301301
new_body["secrets"] = parse_secrets(data.get("secrets"))
302302
if data.get("env"):
303303
new_body["environmentVariables"] = parse_env(data.get("env"))
304-
304+
if data.get("publicIPDisabled"):
305+
new_body["publicIPDisabled"] = data.get("publicIPDisabled")
305306
# quick test and split csv not supported currently in CLI
306307
new_body["loadTestConfiguration"]["quickStartTest"] = False
307308
if data.get("quickStartTest"):
@@ -365,6 +366,7 @@ def create_or_update_test_with_config(
365366
key_vault_reference_identity=None,
366367
subnet_id=None,
367368
split_csv=None,
369+
disable_public_ip=None,
368370
):
369371
logger.info(
370372
"Creating a request body for create or update test using config and parameters."
@@ -397,6 +399,10 @@ def create_or_update_test_with_config(
397399
new_body["keyvaultReferenceIdentityType"] = IdentityType.SystemAssigned
398400
new_body.pop("keyvaultReferenceIdentityId")
399401
subnet_id = subnet_id or yaml_test_body.get("subnetId")
402+
if disable_public_ip is not None:
403+
new_body["publicIPDisabled"] = disable_public_ip
404+
else:
405+
new_body["publicIPDisabled"] = yaml_test_body.get("publicIPDisabled", False)
400406
if subnet_id:
401407
if subnet_id.casefold() in ["null", ""]:
402408
new_body["subnetId"] = None
@@ -485,6 +491,7 @@ def create_or_update_test_without_config(
485491
key_vault_reference_identity=None,
486492
subnet_id=None,
487493
split_csv=None,
494+
disable_public_ip=None,
488495
):
489496
logger.info(
490497
"Creating a request body for test using parameters and old test body (in case of update)."
@@ -549,6 +556,8 @@ def create_or_update_test_without_config(
549556
new_body["loadTestConfiguration"]["splitAllCSVs"] = body[
550557
"loadTestConfiguration"
551558
]["splitAllCSVs"]
559+
if disable_public_ip is not None:
560+
new_body["publicIPDisabled"] = disable_public_ip
552561
logger.debug("Request body for create or update test: %s", new_body)
553562
return new_body
554563

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,3 +382,23 @@ def validate_split_csv(namespace):
382382
namespace.split_csv = True
383383
else:
384384
namespace.split_csv = False
385+
386+
387+
def validate_disable_public_ip(namespace):
388+
if namespace.disable_public_ip is None:
389+
return
390+
if not isinstance(namespace.disable_public_ip, str):
391+
raise InvalidArgumentValueError(
392+
f"Invalid disable-public-ip type: {type(namespace.disable_public_ip)}"
393+
)
394+
if namespace.disable_public_ip.casefold() not in [
395+
"true",
396+
"false",
397+
]:
398+
raise InvalidArgumentValueError(
399+
f"Invalid disable-public-ip value: {namespace.disable_public_ip}. Allowed values: true, false"
400+
)
401+
if namespace.disable_public_ip.casefold() in ["true"]:
402+
namespace.disable_public_ip = True
403+
else:
404+
namespace.disable_public_ip = False

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
class LoadConstants:
1212
# Test Plan constants
1313
LOAD_TEST_CONFIG_FILE = os.path.join(TEST_RESOURCES_DIR, r"config.yaml")
14+
LOAD_TEST_CONFIG_FILE_PUBLIC_IP_DISABLED_FALSE = os.path.join(TEST_RESOURCES_DIR, r"config-disable-public-ip-false.yaml")
15+
LOAD_TEST_CONFIG_FILE_PUBLIC_IP_DISABLED_TRUE = os.path.join(TEST_RESOURCES_DIR, r"config-disable-public-ip-true.yaml")
1416
INVALID_LOAD_TEST_CONFIG_FILE = os.path.join(
1517
TEST_RESOURCES_DIR, r"invalid-config.yaml"
1618
)
@@ -48,6 +50,9 @@ class LoadConstants:
4850
SPLIT_CSV_TRUE = "true"
4951
SPLIT_CSV_FALSE = "false"
5052

53+
DISABLE_PUBLIC_IP_TRUE = "true"
54+
DISABLE_PUBLIC_IP_FALSE = "false"
55+
5156
INVALID_SUBNET_ID = r"/subscriptions/invalid/resource/id"
5257
KEYVAULT_REFERENCE_ID = r"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/sample-rg/providers/microsoft.managedidentity/userassignedidentities/sample-mi"
5358
# App Component constants
@@ -71,6 +76,7 @@ class LoadConstants:
7176
class LoadTestConstants(LoadConstants):
7277
# Test IDs for load test commands
7378
UPDATE_WITH_CONFIG_TEST_ID = "update-with-config-test-case"
79+
CREATE_AND_UPDATE_VNET_TEST_ID = "create-update-vnet-test-case"
7480
DELETE_TEST_ID = "delete-test-case"
7581
CREATE_TEST_ID = "create-test-case"
7682
UPDATE_TEST_ID = "update-test-case"
@@ -85,6 +91,7 @@ class LoadTestConstants(LoadConstants):
8591
INVALID_UPDATE_TEST_ID = "invalid-update-test-case"
8692
INVALID_PF_TEST_ID = "invalid-pf-test-case"
8793
INVALID_ZIP_COUNT_TEST_ID = "invalid-zip-count-test-case"
94+
INVALID_DISABLED_PUBLIC_IP_TEST_ID = "invalid-disable-public-ip-test-case"
8895

8996
DESCRIPTION = r"Sample_test_description"
9097
DISPLAY_NAME = r"Sample_test_display_name"

0 commit comments

Comments
 (0)