Skip to content

Commit

Permalink
az load support for zip artifacts upload (#8057)
Browse files Browse the repository at this point in the history
* az load support for zip artifacts upload

* remove large file test resource

* fix azdev style

* action on comments

* refactor and additional test cases

* update help, changelog and bump version

* action on comments
  • Loading branch information
mbhardwaj-msft authored Oct 15, 2024
1 parent 178001a commit 50493ef
Show file tree
Hide file tree
Showing 81 changed files with 48,869 additions and 21,591 deletions.
7 changes: 7 additions & 0 deletions src/load/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
Release History
===============
1.1.0
++++++
* Add support for ZIP artifacts upload to a test. Artifacts can be uploaded through YAML config when using --load-test-config-file and through cmd `az load test file upload`, the associate --file-type is `ZIPPED_ARTIFACTS`
* Upgrade vendored_sdks to use API version '2024-05-01-preview'
* Fix for uploading files from YAML config when relative path is provided for configurationFiles
* Add test cases for ZIP artifacts upload

1.0.2
++++++
* Patch for removing msrestazure dependency and using azure.mgmt.core.
Expand Down
30 changes: 15 additions & 15 deletions src/load/azext_load/data_plane/load_test/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def create_test(
response = client.get_test(test_id)
logger.info("Upload files to test %s has completed", test_id)
logger.info("Test %s has been created successfully", test_id)
return response
return response.as_dict()


def update_test(
Expand Down Expand Up @@ -175,7 +175,7 @@ def update_test(
response = client.get_test(test_id)
logger.info("Upload files to test %s has completed", test_id)
logger.info("Test %s has been updated successfully", test_id)
return response
return response.as_dict()


def list_tests(
Expand All @@ -185,9 +185,9 @@ def list_tests(
):
logger.info("Listing tests for load test resource: %s", load_test_resource)
client = get_admin_data_plane_client(cmd, load_test_resource, resource_group_name)
response = client.list_tests()
logger.debug("Retrieved tests: %s", response)
return response
response_list = client.list_tests()
logger.debug("Retrieved tests: %s", response_list)
return [response.as_dict() for response in response_list]


def get_test(
Expand All @@ -200,7 +200,7 @@ def get_test(
client = get_admin_data_plane_client(cmd, load_test_resource, resource_group_name)
response = client.get_test(test_id)
logger.debug("Retrieved test: %s", response)
return response
return response.as_dict()


def download_test_files(
Expand Down Expand Up @@ -271,7 +271,7 @@ def add_test_app_component(
response = client.create_or_update_app_components(test_id=test_id, body=body)
logger.info("Add test app component completed for test: %s", test_id)
logger.debug("Add test app component response: %s", response)
return response
return response.as_dict()


def list_test_app_component(
Expand All @@ -285,7 +285,7 @@ def list_test_app_component(
response = client.get_app_components(test_id=test_id)
logger.debug("Retrieved app components: %s", response)
logger.info("Listing app components completed")
return response
return response.as_dict()


def remove_test_app_component(
Expand All @@ -302,7 +302,7 @@ def remove_test_app_component(
response = client.create_or_update_app_components(test_id=test_id, body=body)
logger.debug("Removed app component: %s", response)
logger.info("Removing app components completed")
return response
return response.as_dict()


def add_test_server_metric(
Expand Down Expand Up @@ -335,7 +335,7 @@ def add_test_server_metric(
response = client.create_or_update_server_metrics_config(test_id=test_id, body=body)
logger.debug("Add test server metric response: %s", response)
logger.info("Add test server metric completed")
return response
return response.as_dict()


def list_test_server_metric(
Expand All @@ -349,7 +349,7 @@ def list_test_server_metric(
response = client.get_server_metrics_config(test_id=test_id)
logger.debug("Retrieved server metrics: %s", response)
logger.info("Listing server metrics completed")
return response
return response.as_dict()


def remove_test_server_metric(
Expand All @@ -366,7 +366,7 @@ def remove_test_server_metric(
response = client.create_or_update_server_metrics_config(test_id=test_id, body=body)
logger.debug("Removed server metrics: %s", response)
logger.info("Removing server metrics completed")
return response
return response.as_dict()


def upload_test_file(
Expand Down Expand Up @@ -397,10 +397,10 @@ def list_test_file(
):
logger.info("Listing files for the test")
client = get_admin_data_plane_client(cmd, load_test_resource, resource_group_name)
response = client.list_test_files(test_id)
logger.debug("Retrieved files: %s", response)
response_list = client.list_test_files(test_id)
logger.debug("Retrieved files: %s", response_list)
logger.info("Listing files for the test completed")
return response
return [response.as_dict() for response in response_list]


def download_test_file(
Expand Down
3 changes: 3 additions & 0 deletions src/load/azext_load/data_plane/load_test/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,7 @@
- name: Upload a user property file to a test.
text: |
az load test file upload --test-id sample-test-id --load-test-resource sample-alt-resource --resource-group sample-rg --path ~/Resources/user-prop.properties --file-type USER_PROPERTIES
- name: Upload zipped artifacts to a test.
text: |
az load test file upload --test-id sample-test-id --load-test-resource sample-alt-resource --resource-group sample-rg --path ~/Resources/sample-zip.zip --file-type ZIPPED_ARTIFACTS
"""
34 changes: 17 additions & 17 deletions src/load/azext_load/data_plane/load_test_run/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def create_test_run(
if not no_wait:
response = poller.result()
logger.info("Test run created with following response %s", response)
return response
return response.as_dict()


def get_test_run(cmd, load_test_resource, test_run_id, resource_group_name=None):
Expand All @@ -69,7 +69,7 @@ def get_test_run(cmd, load_test_resource, test_run_id, resource_group_name=None)
response = client.get_test_run(test_run_id=test_run_id)
logger.debug("Test run %s", response)
logger.info("Getting test run completed")
return response
return response.as_dict()


def update_test_run(
Expand Down Expand Up @@ -99,10 +99,10 @@ def update_test_run(
)
logger.info("Updating test run %s", test_run_id)
# pylint: disable-next=protected-access
response = client._test_run_initial(test_run_id=test_run_id, body=test_run_body)
response = client.begin_test_run(test_run_id=test_run_id, body=test_run_body).result()
logger.debug("Test run updated with following response %s", response)
logger.info("Update test run completed")
return response
return response.as_dict()


def delete_test_run(cmd, load_test_resource, test_run_id, resource_group_name=None):
Expand All @@ -120,13 +120,13 @@ def list_test_runs(cmd, test_id, load_test_resource, resource_group_name=None):
response = client.list_test_runs(test_id=test_id)
logger.debug("Test runs listed with following response %s", response)
logger.info("List test runs completed")
return response
return [test_run.as_dict() for test_run in response]


def stop_test_run(cmd, load_test_resource, test_run_id, resource_group_name=None):
client = get_testrun_data_plane_client(cmd, load_test_resource, resource_group_name)
logger.info("Stopping test run %s", test_run_id)
response = client.stop_test_run(test_run_id=test_run_id)
response = client.stop(test_run_id=test_run_id)
logger.debug("Test run stopped with following response %s", response)
logger.info("Stop test run completed")
return response
Expand Down Expand Up @@ -267,7 +267,7 @@ def add_test_run_app_component(
)
logger.debug("App component added with following response %s", response)
logger.info("App component completed")
return response
return response.as_dict()


def list_test_run_app_component(
Expand All @@ -283,7 +283,7 @@ def list_test_run_app_component(
"List of app components completed with following response %s", response
)
logger.info("App components completed")
return response
return response.as_dict()


def remove_test_run_app_component(
Expand All @@ -301,7 +301,7 @@ def remove_test_run_app_component(
)
logger.debug("App component removed completed with following response %s", response)
logger.info("App component completed")
return response
return response.as_dict()


# server metrics
Expand Down Expand Up @@ -341,7 +341,7 @@ def add_test_run_server_metric(
"Server metrics added completed with following response %s", test_run_id
)
logger.info("Server metrics completed")
return response
return response.as_dict()


def list_test_run_server_metric(
Expand All @@ -357,7 +357,7 @@ def list_test_run_server_metric(
"List of server metrics completed with following response %s", response
)
logger.info("Server metrics completed")
return response
return response.as_dict()


def remove_test_run_server_metric(
Expand All @@ -377,7 +377,7 @@ def remove_test_run_server_metric(
"Server metrics removed completed with following response %s", response
)
logger.info("Server metrics completed")
return response
return response.as_dict()


def get_test_run_metric_namespaces(
Expand All @@ -391,7 +391,7 @@ def get_test_run_metric_namespaces(
response,
)
logger.info("Getting client metrics namespaces completed")
return response
return response.as_dict()


def list_test_run_metrics(
Expand Down Expand Up @@ -455,7 +455,7 @@ def list_test_run_metrics(
interval=interval,
time_interval=time_interval,
)
dimension_filter["values"] = list(metric_dimensions)
dimension_filter["values"] = metric_dimensions.value

metrics = client.list_metrics(
test_run_id,
Expand All @@ -468,7 +468,7 @@ def list_test_run_metrics(
"filters": dimension_filters,
},
)
response = list(metrics)
response = [metric.as_dict() for metric in metrics]
logger.debug("All metrics: %s", response)
logger.info("List metrics completed")
return response
Expand All @@ -490,7 +490,7 @@ def list_test_run_metrics(
aggregation=aggregation,
interval=interval,
)
response = list(metrics)
response = [metric.as_dict() for metric in metrics]
aggregated_metrics[metric_name] = response
logger.debug("Aggregated metrics: %s", aggregated_metrics)
logger.info("List metrics completed")
Expand All @@ -512,7 +512,7 @@ def get_test_run_metric_definitions(
metric_definitions,
)
logger.info("Getting test run metric definitions completed")
return metric_definitions
return metric_definitions.as_dict()


def get_test_run_metric_dimensions(
Expand Down
2 changes: 1 addition & 1 deletion src/load/azext_load/data_plane/utils/argtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
),
options_list=["--file-type"],
type=str,
help=f"Type of file to be uploaded. Allowed values: {', '.join(utils.get_enum_values(models.AllowedFileTypes))}",
help=f"Type of file to be uploaded. Allowed values: {', '.join(utils.get_enum_values(models.AllowedFileTypes))}. Ensure that the ZIP file remains below 50 MB in size. Only 5 ZIP artifacts are allowed with a maximum of 1000 files in each and uncompressed size of 1 GB",
)

test_run_input = CLIArgumentType(
Expand Down
1 change: 1 addition & 0 deletions src/load/azext_load/data_plane/utils/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class AllowedFileTypes(str, Enum):
ADDITIONAL_ARTIFACTS = "ADDITIONAL_ARTIFACTS"
JMX_FILE = "JMX_FILE"
USER_PROPERTIES = "USER_PROPERTIES"
ZIPPED_ARTIFACTS = "ZIPPED_ARTIFACTS"


class AllowedIntervals(str, Enum):
Expand Down
Loading

0 comments on commit 50493ef

Please sign in to comment.