diff --git a/sdk/loadtesting/azure-developer-loadtesting/MANIFEST.in b/sdk/loadtesting/azure-developer-loadtesting/MANIFEST.in index 6ebb7e55a108..32f595395d47 100644 --- a/sdk/loadtesting/azure-developer-loadtesting/MANIFEST.in +++ b/sdk/loadtesting/azure-developer-loadtesting/MANIFEST.in @@ -4,4 +4,4 @@ include azure/developer/loadtesting/py.typed recursive-include tests *.py recursive-include samples *.py *.md include azure/__init__.py -include azure/developer/__init__.py \ No newline at end of file +include azure/developer/__init__.py diff --git a/sdk/loadtesting/azure-developer-loadtesting/_meta.json b/sdk/loadtesting/azure-developer-loadtesting/_meta.json new file mode 100644 index 000000000000..31824636bfd5 --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/_meta.json @@ -0,0 +1,6 @@ +{ + "commit": "f0143019cfea40b0257f746a6d512a83774e375e", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "typespec_src": "specification/loadtestservice/LoadTestService", + "@azure-tools/typespec-python": "0.44.1" +} \ No newline at end of file diff --git a/sdk/loadtesting/azure-developer-loadtesting/apiview-properties.json b/sdk/loadtesting/azure-developer-loadtesting/apiview-properties.json new file mode 100644 index 000000000000..72812e8578af --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/apiview-properties.json @@ -0,0 +1,133 @@ +{ + "CrossLanguagePackageId": "Microsoft.LoadTestService", + "CrossLanguageDefinitionId": { + "azure.developer.loadtesting.models.AppComponent": "Microsoft.LoadTestService.AppComponent", + "azure.developer.loadtesting.models.ArtifactsContainerInfo": "Microsoft.LoadTestService.ArtifactsContainerInfo", + "azure.developer.loadtesting.models.AutoStopCriteria": "Microsoft.LoadTestService.AutoStopCriteria", + "azure.developer.loadtesting.models.CertificateMetadata": "Microsoft.LoadTestService.CertificateMetadata", + "azure.developer.loadtesting.models.DimensionFilter": "Microsoft.LoadTestService.DimensionFilter", + "azure.developer.loadtesting.models.DimensionValue": "Microsoft.LoadTestService.DimensionValue", + "azure.developer.loadtesting.models.ErrorDetails": "Microsoft.LoadTestService.ErrorDetails", + "azure.developer.loadtesting.models.FunctionFlexConsumptionResourceConfiguration": "Microsoft.LoadTestService.FunctionFlexConsumptionResourceConfiguration", + "azure.developer.loadtesting.models.TargetResourceConfigurations": "Microsoft.LoadTestService.TargetResourceConfigurations", + "azure.developer.loadtesting.models.FunctionFlexConsumptionTargetResourceConfigurations": "Microsoft.LoadTestService.FunctionFlexConsumptionTargetResourceConfigurations", + "azure.developer.loadtesting.models.LoadTestConfiguration": "Microsoft.LoadTestService.LoadTestConfiguration", + "azure.developer.loadtesting.models.MetricAvailability": "Microsoft.LoadTestService.MetricAvailability", + "azure.developer.loadtesting.models.MetricDefinition": "Microsoft.LoadTestService.MetricDefinition", + "azure.developer.loadtesting.models.MetricDefinitionCollection": "Microsoft.LoadTestService.MetricDefinitionCollection", + "azure.developer.loadtesting.models.MetricNamespace": "Microsoft.LoadTestService.MetricNamespace", + "azure.developer.loadtesting.models.MetricNamespaceCollection": "Microsoft.LoadTestService.MetricNamespaceCollection", + "azure.developer.loadtesting.models.MetricRequestPayload": "Microsoft.LoadTestService.MetricRequestPayload", + "azure.developer.loadtesting.models.MetricValue": "Microsoft.LoadTestService.MetricValue", + "azure.developer.loadtesting.models.NameAndDescription": "Microsoft.LoadTestService.NameAndDescription", + "azure.developer.loadtesting.models.OptionalLoadTestConfiguration": "Microsoft.LoadTestService.OptionalLoadTestConfiguration", + "azure.developer.loadtesting.models.PassFailCriteria": "Microsoft.LoadTestService.PassFailCriteria", + "azure.developer.loadtesting.models.PassFailMetric": "Microsoft.LoadTestService.PassFailMetric", + "azure.developer.loadtesting.models.PassFailServerMetric": "Microsoft.LoadTestService.PassFailServerMetric", + "azure.developer.loadtesting.models.RegionalConfiguration": "Microsoft.LoadTestService.RegionalConfiguration", + "azure.developer.loadtesting.models.ResourceMetric": "Microsoft.LoadTestService.ResourceMetric", + "azure.developer.loadtesting.models.Secret": "Microsoft.LoadTestService.Secret", + "azure.developer.loadtesting.models.Test": "Microsoft.LoadTestService.Test", + "azure.developer.loadtesting.models.TestAppComponents": "Microsoft.LoadTestService.TestAppComponents", + "azure.developer.loadtesting.models.TestFileInfo": "Microsoft.LoadTestService.TestFileInfo", + "azure.developer.loadtesting.models.TestInputArtifacts": "Microsoft.LoadTestService.TestInputArtifacts", + "azure.developer.loadtesting.models.TestProfile": "Microsoft.LoadTestService.TestProfile", + "azure.developer.loadtesting.models.TestProfileRun": "Microsoft.LoadTestService.TestProfileRun", + "azure.developer.loadtesting.models.TestProfileRunRecommendation": "Microsoft.LoadTestService.TestProfileRunRecommendation", + "azure.developer.loadtesting.models.TestRun": "Microsoft.LoadTestService.TestRun", + "azure.developer.loadtesting.models.TestRunAppComponents": "Microsoft.LoadTestService.TestRunAppComponents", + "azure.developer.loadtesting.models.TestRunArtifacts": "Microsoft.LoadTestService.TestRunArtifacts", + "azure.developer.loadtesting.models.TestRunDetail": "Microsoft.LoadTestService.TestRunDetail", + "azure.developer.loadtesting.models.TestRunFileInfo": "Microsoft.LoadTestService.TestRunFileInfo", + "azure.developer.loadtesting.models.TestRunInputArtifacts": "Microsoft.LoadTestService.TestRunInputArtifacts", + "azure.developer.loadtesting.models.TestRunOutputArtifacts": "Microsoft.LoadTestService.TestRunOutputArtifacts", + "azure.developer.loadtesting.models.TestRunServerMetricsConfiguration": "Microsoft.LoadTestService.TestRunServerMetricsConfiguration", + "azure.developer.loadtesting.models.TestRunStatistics": "Microsoft.LoadTestService.TestRunStatistics", + "azure.developer.loadtesting.models.TestServerMetricsConfiguration": "Microsoft.LoadTestService.TestServerMetricsConfiguration", + "azure.developer.loadtesting.models.TimeSeriesElement": "Microsoft.LoadTestService.TimeSeriesElement", + "azure.developer.loadtesting.models.PFMetrics": "Microsoft.LoadTestService.PFMetrics", + "azure.developer.loadtesting.models.PassFailAggregationFunction": "Microsoft.LoadTestService.PassFailAggregationFunction", + "azure.developer.loadtesting.models.PassFailAction": "Microsoft.LoadTestService.PassFailAction", + "azure.developer.loadtesting.models.PassFailResult": "Microsoft.LoadTestService.PassFailResult", + "azure.developer.loadtesting.models.SecretType": "Microsoft.LoadTestService.SecretType", + "azure.developer.loadtesting.models.CertificateType": "Microsoft.LoadTestService.CertificateType", + "azure.developer.loadtesting.models.FileType": "Microsoft.LoadTestService.FileType", + "azure.developer.loadtesting.models.FileValidationStatus": "Microsoft.LoadTestService.FileValidationStatus", + "azure.developer.loadtesting.models.TestKind": "Microsoft.LoadTestService.TestKind", + "azure.developer.loadtesting.models.ManagedIdentityType": "Microsoft.LoadTestService.ManagedIdentityType", + "azure.developer.loadtesting.models.ResourceKind": "Microsoft.LoadTestService.ResourceKind", + "azure.developer.loadtesting.models.PassFailTestResult": "Microsoft.LoadTestService.PassFailTestResult", + "azure.developer.loadtesting.models.TestRunStatus": "Microsoft.LoadTestService.TestRunStatus", + "azure.developer.loadtesting.models.RequestDataLevel": "Microsoft.LoadTestService.RequestDataLevel", + "azure.developer.loadtesting.models.CreatedByType": "Microsoft.LoadTestService.CreatedByType", + "azure.developer.loadtesting.models.TimeGrain": "Microsoft.LoadTestService.TimeGrain", + "azure.developer.loadtesting.models.Aggregation": "Microsoft.LoadTestService.Aggregation", + "azure.developer.loadtesting.models.MetricUnit": "Microsoft.LoadTestService.MetricUnit", + "azure.developer.loadtesting.models.TestProfileRunStatus": "Microsoft.LoadTestService.TestProfileRunStatus", + "azure.developer.loadtesting.models.RecommendationCategory": "Microsoft.LoadTestService.RecommendationCategory", + "azure.developer.loadtesting.LoadTestAdministrationClient.create_or_update_test": "Customizations.AdministrationOperations.createOrUpdateTest", + "azure.developer.loadtesting.aio.LoadTestAdministrationClient.create_or_update_test": "Customizations.AdministrationOperations.createOrUpdateTest", + "azure.developer.loadtesting.LoadTestAdministrationClient.create_or_update_app_components": "Customizations.AdministrationOperations.createOrUpdateAppComponents", + "azure.developer.loadtesting.aio.LoadTestAdministrationClient.create_or_update_app_components": "Customizations.AdministrationOperations.createOrUpdateAppComponents", + "azure.developer.loadtesting.LoadTestAdministrationClient.create_or_update_server_metrics_config": "Customizations.AdministrationOperations.createOrUpdateServerMetricsConfig", + "azure.developer.loadtesting.aio.LoadTestAdministrationClient.create_or_update_server_metrics_config": "Customizations.AdministrationOperations.createOrUpdateServerMetricsConfig", + "azure.developer.loadtesting.LoadTestAdministrationClient.get_app_components": "Customizations.AdministrationOperations.getAppComponents", + "azure.developer.loadtesting.aio.LoadTestAdministrationClient.get_app_components": "Customizations.AdministrationOperations.getAppComponents", + "azure.developer.loadtesting.LoadTestAdministrationClient.get_server_metrics_config": "Customizations.AdministrationOperations.getServerMetricsConfig", + "azure.developer.loadtesting.aio.LoadTestAdministrationClient.get_server_metrics_config": "Customizations.AdministrationOperations.getServerMetricsConfig", + "azure.developer.loadtesting.LoadTestAdministrationClient.get_test": "Customizations.AdministrationOperations.getTest", + "azure.developer.loadtesting.aio.LoadTestAdministrationClient.get_test": "Customizations.AdministrationOperations.getTest", + "azure.developer.loadtesting.LoadTestAdministrationClient.get_test_file": "Customizations.AdministrationOperations.getTestFile", + "azure.developer.loadtesting.aio.LoadTestAdministrationClient.get_test_file": "Customizations.AdministrationOperations.getTestFile", + "azure.developer.loadtesting.LoadTestAdministrationClient.list_test_files": "Customizations.AdministrationOperations.listTestFiles", + "azure.developer.loadtesting.aio.LoadTestAdministrationClient.list_test_files": "Customizations.AdministrationOperations.listTestFiles", + "azure.developer.loadtesting.LoadTestAdministrationClient.list_tests": "Customizations.AdministrationOperations.listTests", + "azure.developer.loadtesting.aio.LoadTestAdministrationClient.list_tests": "Customizations.AdministrationOperations.listTests", + "azure.developer.loadtesting.LoadTestAdministrationClient.delete_test_file": "Customizations.AdministrationOperations.deleteTestFile", + "azure.developer.loadtesting.aio.LoadTestAdministrationClient.delete_test_file": "Customizations.AdministrationOperations.deleteTestFile", + "azure.developer.loadtesting.LoadTestAdministrationClient.delete_test": "Customizations.AdministrationOperations.deleteTest", + "azure.developer.loadtesting.aio.LoadTestAdministrationClient.delete_test": "Customizations.AdministrationOperations.deleteTest", + "azure.developer.loadtesting.LoadTestAdministrationClient.create_or_update_test_profile": "Customizations.AdministrationOperations.createOrUpdateTestProfile", + "azure.developer.loadtesting.aio.LoadTestAdministrationClient.create_or_update_test_profile": "Customizations.AdministrationOperations.createOrUpdateTestProfile", + "azure.developer.loadtesting.LoadTestAdministrationClient.delete_test_profile": "Customizations.AdministrationOperations.deleteTestProfile", + "azure.developer.loadtesting.aio.LoadTestAdministrationClient.delete_test_profile": "Customizations.AdministrationOperations.deleteTestProfile", + "azure.developer.loadtesting.LoadTestAdministrationClient.get_test_profile": "Customizations.AdministrationOperations.getTestProfile", + "azure.developer.loadtesting.aio.LoadTestAdministrationClient.get_test_profile": "Customizations.AdministrationOperations.getTestProfile", + "azure.developer.loadtesting.LoadTestAdministrationClient.list_test_profiles": "Customizations.AdministrationOperations.listTestProfiles", + "azure.developer.loadtesting.aio.LoadTestAdministrationClient.list_test_profiles": "Customizations.AdministrationOperations.listTestProfiles", + "azure.developer.loadtesting.LoadTestRunClient.create_or_update_app_components": "Customizations.TestRunOperations.createOrUpdateAppComponents", + "azure.developer.loadtesting.aio.LoadTestRunClient.create_or_update_app_components": "Customizations.TestRunOperations.createOrUpdateAppComponents", + "azure.developer.loadtesting.LoadTestRunClient.create_or_update_server_metrics_config": "Customizations.TestRunOperations.createOrUpdateServerMetricsConfig", + "azure.developer.loadtesting.aio.LoadTestRunClient.create_or_update_server_metrics_config": "Customizations.TestRunOperations.createOrUpdateServerMetricsConfig", + "azure.developer.loadtesting.LoadTestRunClient.delete_test_run": "Customizations.TestRunOperations.deleteTestRun", + "azure.developer.loadtesting.aio.LoadTestRunClient.delete_test_run": "Customizations.TestRunOperations.deleteTestRun", + "azure.developer.loadtesting.LoadTestRunClient.get_app_components": "Customizations.TestRunOperations.getAppComponents", + "azure.developer.loadtesting.aio.LoadTestRunClient.get_app_components": "Customizations.TestRunOperations.getAppComponents", + "azure.developer.loadtesting.LoadTestRunClient.get_server_metrics_config": "Customizations.TestRunOperations.getServerMetricsConfig", + "azure.developer.loadtesting.aio.LoadTestRunClient.get_server_metrics_config": "Customizations.TestRunOperations.getServerMetricsConfig", + "azure.developer.loadtesting.LoadTestRunClient.get_test_run": "Customizations.TestRunOperations.getTestRun", + "azure.developer.loadtesting.aio.LoadTestRunClient.get_test_run": "Customizations.TestRunOperations.getTestRun", + "azure.developer.loadtesting.LoadTestRunClient.get_test_run_file": "Customizations.TestRunOperations.getTestRunFile", + "azure.developer.loadtesting.aio.LoadTestRunClient.get_test_run_file": "Customizations.TestRunOperations.getTestRunFile", + "azure.developer.loadtesting.LoadTestRunClient.list_metric_dimension_values": "Customizations.TestRunOperations.listMetricDimensionValues", + "azure.developer.loadtesting.aio.LoadTestRunClient.list_metric_dimension_values": "Customizations.TestRunOperations.listMetricDimensionValues", + "azure.developer.loadtesting.LoadTestRunClient.get_metric_definitions": "Customizations.TestRunOperations.listMetricDefinitions", + "azure.developer.loadtesting.aio.LoadTestRunClient.get_metric_definitions": "Customizations.TestRunOperations.listMetricDefinitions", + "azure.developer.loadtesting.LoadTestRunClient.get_metric_namespaces": "Customizations.TestRunOperations.listMetricNamespaces", + "azure.developer.loadtesting.aio.LoadTestRunClient.get_metric_namespaces": "Customizations.TestRunOperations.listMetricNamespaces", + "azure.developer.loadtesting.LoadTestRunClient.list_metrics": "Customizations.TestRunOperations.listMetrics", + "azure.developer.loadtesting.aio.LoadTestRunClient.list_metrics": "Customizations.TestRunOperations.listMetrics", + "azure.developer.loadtesting.LoadTestRunClient.list_test_runs": "Customizations.TestRunOperations.listTestRuns", + "azure.developer.loadtesting.aio.LoadTestRunClient.list_test_runs": "Customizations.TestRunOperations.listTestRuns", + "azure.developer.loadtesting.LoadTestRunClient.stop_test_run": "Customizations.TestRunOperations.stop", + "azure.developer.loadtesting.aio.LoadTestRunClient.stop_test_run": "Customizations.TestRunOperations.stop", + "azure.developer.loadtesting.LoadTestRunClient.delete_test_profile_run": "Customizations.TestRunOperations.deleteTestProfileRun", + "azure.developer.loadtesting.aio.LoadTestRunClient.delete_test_profile_run": "Customizations.TestRunOperations.deleteTestProfileRun", + "azure.developer.loadtesting.LoadTestRunClient.get_test_profile_run": "Customizations.TestRunOperations.getTestProfileRun", + "azure.developer.loadtesting.aio.LoadTestRunClient.get_test_profile_run": "Customizations.TestRunOperations.getTestProfileRun", + "azure.developer.loadtesting.LoadTestRunClient.list_test_profile_runs": "Customizations.TestRunOperations.listTestProfileRuns", + "azure.developer.loadtesting.aio.LoadTestRunClient.list_test_profile_runs": "Customizations.TestRunOperations.listTestProfileRuns", + "azure.developer.loadtesting.LoadTestRunClient.stop_test_profile_run": "Customizations.TestRunOperations.stopTestProfileRun", + "azure.developer.loadtesting.aio.LoadTestRunClient.stop_test_profile_run": "Customizations.TestRunOperations.stopTestProfileRun" + } +} \ No newline at end of file diff --git a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_client.py b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_client.py index 3e5aa0fba177..a2f78ff57307 100644 --- a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_client.py +++ b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_client.py @@ -16,7 +16,7 @@ from ._configuration import LoadTestAdministrationClientConfiguration, LoadTestRunClientConfiguration from ._operations import LoadTestAdministrationClientOperationsMixin, LoadTestRunClientOperationsMixin -from ._serialization import Deserializer, Serializer +from ._utils.serialization import Deserializer, Serializer if TYPE_CHECKING: from azure.core.credentials import TokenCredential @@ -38,6 +38,7 @@ class LoadTestAdministrationClient(LoadTestAdministrationClientOperationsMixin): def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None: _endpoint = "https://{endpoint}" self._config = LoadTestAdministrationClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -114,6 +115,7 @@ class LoadTestRunClient(LoadTestRunClientOperationsMixin): def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None: _endpoint = "https://{endpoint}" self._config = LoadTestRunClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ diff --git a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_operations/_operations.py b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_operations/_operations.py index 2e86f4dbdb46..2a770a21ce4e 100644 --- a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_operations/_operations.py +++ b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_operations/_operations.py @@ -6,13 +6,14 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping import datetime from io import IOBase import json -import sys from typing import Any, Callable, Dict, IO, Iterable, List, Optional, TypeVar, Union, overload import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -30,16 +31,13 @@ from azure.core.utils import case_insensitive_dict from .. import models as _models -from .._model_base import SdkJSONEncoder, _deserialize -from .._serialization import Serializer +from .._configuration import LoadTestAdministrationClientConfiguration, LoadTestRunClientConfiguration +from .._utils.model_base import SdkJSONEncoder, _deserialize +from .._utils.serialization import Serializer +from .._utils.utils import ClientMixinABC from .._validation import api_version_validation -from .._vendor import LoadTestAdministrationClientMixinABC, LoadTestRunClientMixinABC -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +JSON = MutableMapping[str, Any] T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -870,6 +868,7 @@ def build_load_test_run_list_test_runs_request( # pylint: disable=name-too-long execution_to: Optional[datetime.datetime] = None, status: Optional[str] = None, maxpagesize: Optional[int] = None, + created_by_types: Optional[List[str]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -897,6 +896,8 @@ def build_load_test_run_list_test_runs_request( # pylint: disable=name-too-long _params["status"] = _SERIALIZER.query("status", status, "str") if maxpagesize is not None: _params["maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "int") + if created_by_types is not None: + _params["createdByTypes"] = _SERIALIZER.query("created_by_types", created_by_types, "[str]", div=",") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1092,7 +1093,7 @@ def build_load_test_run_stop_test_profile_run_request( # pylint: disable=name-t class LoadTestAdministrationClientOperationsMixin( # pylint: disable=name-too-long - LoadTestAdministrationClientMixinABC + ClientMixinABC[PipelineClient, LoadTestAdministrationClientConfiguration] ): @overload @@ -1851,7 +1852,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.TestFileInfo], deserialized["value"]) + list_of_elem = _deserialize(List[_models.TestFileInfo], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -1960,7 +1961,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Test], deserialized["value"]) + list_of_elem = _deserialize(List[_models.Test], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -2556,7 +2557,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.TestProfile], deserialized["value"]) + list_of_elem = _deserialize(List[_models.TestProfile], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -2579,7 +2580,7 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) -class LoadTestRunClientOperationsMixin(LoadTestRunClientMixinABC): +class LoadTestRunClientOperationsMixin(ClientMixinABC[PipelineClient, LoadTestRunClientConfiguration]): @overload def _begin_test_run( @@ -3399,7 +3400,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[str], deserialized["value"]) + list_of_elem = _deserialize(List[str], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -3788,7 +3789,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.TimeSeriesElement], deserialized["value"]) + list_of_elem = _deserialize(List[_models.TimeSeriesElement], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -3811,6 +3812,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace + @api_version_validation( + params_added_on={"2024-07-01-preview": ["created_by_types"]}, + ) def list_test_runs( self, *, @@ -3820,6 +3824,7 @@ def list_test_runs( execution_from: Optional[datetime.datetime] = None, execution_to: Optional[datetime.datetime] = None, status: Optional[str] = None, + created_by_types: Optional[List[str]] = None, **kwargs: Any ) -> Iterable["_models.TestRun"]: """Get all test runs for the given filters. @@ -3843,6 +3848,9 @@ def list_test_runs( :paramtype execution_to: ~datetime.datetime :keyword status: Comma separated list of test run status. Default value is None. :paramtype status: str + :keyword created_by_types: Comma separated list of type of entities that have created the test + run. Default value is None. + :paramtype created_by_types: list[str] :return: An iterator like instance of TestRun :rtype: ~azure.core.paging.ItemPaged[~azure.developer.loadtesting.models.TestRun] :raises ~azure.core.exceptions.HttpResponseError: @@ -3872,6 +3880,7 @@ def prepare_request(next_link=None): execution_to=execution_to, status=status, maxpagesize=maxpagesize, + created_by_types=created_by_types, api_version=self._config.api_version, headers=_headers, params=_params, @@ -3903,7 +3912,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.TestRun], deserialized["value"]) + list_of_elem = _deserialize(List[_models.TestRun], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -4345,7 +4354,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.TestProfileRun], deserialized["value"]) + list_of_elem = _deserialize(List[_models.TestProfileRun], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) diff --git a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_operations/_patch.py b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_operations/_patch.py index 026ffb5086c7..8bcb627aa475 100644 --- a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_operations/_patch.py +++ b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_operations/_patch.py @@ -1,495 +1,15 @@ -# pylint: disable=line-too-long,useless-suppression -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -import logging -import time -from functools import partial -from typing import Any, IO, List, Optional, overload, Union +from typing import List -from azure.core.polling import PollingMethod, LROPoller -from azure.core.tracing.decorator import distributed_trace - -from ._operations import JSON -from ._operations import LoadTestAdministrationClientOperationsMixin as GeneratedAdministrationClientOperations -from ._operations import LoadTestRunClientOperationsMixin as GeneratedRunClientOperations - -from .. import models as _models - -logger = logging.getLogger(__name__) - - -class LoadTestingPollingMethod(PollingMethod): - """Base class for custom sync polling methods.""" - - def _update_status(self) -> None: - raise NotImplementedError("This method needs to be implemented") - - def _update_resource(self) -> None: - self._resource = self._command() - - def initialize(self, client, initial_response, deserialization_callback) -> None: - self._command = client - self._initial_response = initial_response - self._resource = initial_response - - def status(self) -> str: - return self._status - - def finished(self) -> bool: - return self._status in self._termination_statuses - - def resource(self) -> JSON: - return self._resource - - def run(self) -> None: - try: - while not self.finished(): - self._update_resource() - self._update_status() - - if not self.finished(): - time.sleep(self._polling_interval) - except Exception as e: - logger.error(e) - raise e - - -class ValidationCheckPoller(LoadTestingPollingMethod): - """Polling method for long-running file validation operation.""" - - def __init__(self, interval=5) -> None: - self._resource = None - self._command = None - self._initial_response = None - self._polling_interval = interval - self._status = None - self._termination_statuses = [ - "VALIDATION_SUCCESS", - "VALIDATION_FAILURE", - "NOT_VALIDATED", - "VALIDATION_NOT_REQUIRED", - ] - - def _update_status(self) -> None: - self._status = self._resource["validationStatus"] - - -class TestRunStatusPoller(LoadTestingPollingMethod): - """Polling method for polling a Test Run.""" - - def __init__(self, interval=5) -> None: - self._resource = None - self._command = None - self._initial_response = None - self._polling_interval = interval - self._status = None - self._termination_statuses = ["DONE", "FAILED", "CANCELLED"] - - def _update_status(self) -> None: - self._status = self._resource["status"] - - -class TestProfileRunStatusPoller(LoadTestingPollingMethod): - """Polling method for polling a Test Profile Run.""" - - def __init__(self, interval=5) -> None: - self._resource = None - self._command = None - self._initial_response = None - self._polling_interval = interval - self._status = None - self._termination_statuses = ["DONE", "FAILED", "CANCELLED"] - - def _update_status(self): - self._status = self._resource["status"] - - -class LoadTestAdministrationClientOperationsMixin(GeneratedAdministrationClientOperations): - - def __init__(self, *args, **kwargs): - super(LoadTestAdministrationClientOperationsMixin, self).__init__(*args, **kwargs) - - @overload - def begin_upload_test_file( - self, - test_id: str, - file_name: str, - body: bytes, - *, - file_type: Optional[Union[str, _models.FileType]] = None, - **kwargs: Any - ) -> LROPoller[_models.TestFileInfo]: - """Upload input file for a given test Id. File size can't be more than 50 MB. - Existing file with same name for the given test will be overwritten. File - should be provided in the request body as application/octet-stream. - - Upload input file for a given test Id. File size can't be more than 50 MB. - Existing file with same name for the given test will be overwritten. File - should be provided in the request body as application/octet-stream. - - :param test_id: Unique name for the load test, must contain only lower-case alphabetic, - numeric, underscore or hyphen characters. Required. - :type test_id: str - :param file_name: Unique name for test file with file extension like : App.jmx. Required. - :type file_name: str - :param body: The file content as application/octet-stream. Required. - :type body: bytes - :keyword file_type: File type. Known values are: "JMX_FILE", "USER_PROPERTIES", - "ADDITIONAL_ARTIFACTS", "ZIPPED_ARTIFACTS", "URL_TEST_CONFIG", and "TEST_SCRIPT". Default value - is None. - :paramtype file_type: str or ~azure.developer.loadtesting.models.FileType - :return: An instance of LROPoller. Call `result()` on the poller object to return a :class:`~azure.developer.loadtesting.models.TestFileInfo`. - :rtype: ~azure.core.polling.LROPoller[~azure.developer.loadtesting.models.TestFileInfo] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_upload_test_file( - self, - test_id: str, - file_name: str, - body: IO, - *, - file_type: Optional[Union[str, _models.FileType]] = None, - **kwargs: Any - ) -> LROPoller[_models.TestFileInfo]: - """Upload input file for a given test Id. File size can't be more than 50 MB. - Existing file with same name for the given test will be overwritten. File - should be provided in the request body as application/octet-stream. - - Upload input file for a given test Id. File size can't be more than 50 MB. - Existing file with same name for the given test will be overwritten. File - should be provided in the request body as application/octet-stream. - - :param test_id: Unique name for the load test, must contain only lower-case alphabetic, - numeric, underscore or hyphen characters. Required. - :type test_id: str - :param file_name: Unique name for test file with file extension like : App.jmx. Required. - :type file_name: str - :param body: The file content as application/octet-stream. Required. - :type body: IO - :keyword file_type: File type. Known values are: "JMX_FILE", "USER_PROPERTIES", - "ADDITIONAL_ARTIFACTS", "ZIPPED_ARTIFACTS", "URL_TEST_CONFIG", and "TEST_SCRIPT". Default value - is None. - :paramtype file_type: str or ~azure.developer.loadtesting.models.FileType - :return: An instance of LROPoller. Call `result()` on the poller object to return a :class:`~azure.developer.loadtesting.models.TestFileInfo`. - :rtype: ~azure.core.polling.LROPoller[~azure.developer.loadtesting.models.TestFileInfo] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_upload_test_file( - self, - test_id: str, - file_name: str, - body: Union[IO, bytes], - *, - file_type: Optional[Union[str, _models.FileType]] = None, - **kwargs: Any - ) -> LROPoller[_models.TestFileInfo]: - """Upload input file for a given test Id. File size can't be more than 50 MB. - Existing file with same name for the given test will be overwritten. File - should be provided in the request body as application/octet-stream. - - Upload input file for a given test Id. File size can't be more than 50 MB. - Existing file with same name for the given test will be overwritten. File - should be provided in the request body as application/octet-stream. - - :param test_id: Unique name for the load test, must contain only lower-case alphabetic, - numeric, underscore or hyphen characters. Required. - :type test_id: str - :param file_name: Unique name for test file with file extension like : App.jmx. Required. - :type file_name: str - :param body: The file content as application/octet-stream. Required. - :type body: Is one of the following types: IO, bytes - :keyword file_type: File type. Known values are: "JMX_FILE", "USER_PROPERTIES", - "ADDITIONAL_ARTIFACTS", "ZIPPED_ARTIFACTS", "URL_TEST_CONFIG", and "TEST_SCRIPT". Default value - is None. - :paramtype file_type: str or ~azure.developer.loadtesting.models.FileType - :return: An instance of LROPoller. Call `result()` on the poller object to return a :class:`~azure.developer.loadtesting.models.TestFileInfo`. - :rtype: ~azure.core.polling.LROPoller[~azure.developer.loadtesting.models.TestFileInfo] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - polling_interval = kwargs.pop("_polling_interval", None) - if polling_interval is None: - polling_interval = 5 - upload_test_file_operation = super()._begin_upload_test_file( - test_id=test_id, file_name=file_name, file_type=file_type, body=body, **kwargs - ) - - command = partial(self.get_test_file, test_id=test_id, file_name=file_name) - file_validation_status_polling = ValidationCheckPoller(interval=polling_interval) - return LROPoller(command, upload_test_file_operation, lambda *_: None, file_validation_status_polling) - - -class LoadTestRunClientOperationsMixin(GeneratedRunClientOperations): - - def __init__(self, *args, **kwargs): - super(LoadTestRunClientOperationsMixin, self).__init__(*args, **kwargs) - - @overload - def begin_test_run( - self, - test_run_id: str, - body: _models.TestRun, - *, - content_type: str = "application/merge-patch+json", - old_test_run_id: Optional[str] = None, - **kwargs: Any - ) -> LROPoller[_models.TestRun]: - """Create and start a new test run with the given test run Id. - - Create and start a new test run with the given test run Id. - - :param test_run_id: Unique test run identifier for the load test run, must contain only - lower-case alphabetic, numeric, underscore or hyphen characters. Required. - :type test_run_id: str - :param body: The resource instance. Required. - :type body: ~azure.developer.loadtesting.models.TestRun - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :keyword old_test_run_id: Existing test run identifier that should be rerun, if this is - provided, the - test will run with the JMX file, configuration and app components from the - existing test run. You can override the configuration values for new test run - in the request body. Default value is None. - :paramtype old_test_run_id: str - :return: An instance of LROPoller. Call `result()` on the poller object to return a :class:`~azure.developer.loadtesting.models.TestRun`. - :rtype: ~azure.core.polling.LROPoller[~azure.developer.loadtesting.models.TestRun] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_test_run( - self, - test_run_id: str, - body: JSON, - *, - content_type: str = "application/merge-patch+json", - old_test_run_id: Optional[str] = None, - **kwargs: Any - ) -> LROPoller[_models.TestRun]: - """Create and start a new test run with the given test run Id. - - Create and start a new test run with the given test run Id. - - :param test_run_id: Unique test run identifier for the load test run, must contain only - lower-case alphabetic, numeric, underscore or hyphen characters. Required. - :type test_run_id: str - :param body: The resource instance. Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :keyword old_test_run_id: Existing test run identifier that should be rerun, if this is - provided, the - test will run with the JMX file, configuration and app components from the - existing test run. You can override the configuration values for new test run - in the request body. Default value is None. - :paramtype old_test_run_id: str - :return: An instance of LROPoller. Call `result()` on the poller object to return a :class:`~azure.developer.loadtesting.models.TestRun`. - :rtype: ~azure.core.polling.LROPoller[~azure.developer.loadtesting.models.TestRun] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_test_run( - self, - test_run_id: str, - body: IO[bytes], - *, - content_type: str = "application/merge-patch+json", - old_test_run_id: Optional[str] = None, - **kwargs: Any - ) -> LROPoller[_models.TestRun]: - """Create and start a new test run with the given test run Id. - - Create and start a new test run with the given test run Id. - - :param test_run_id: Unique test run identifier for the load test run, must contain only - lower-case alphabetic, numeric, underscore or hyphen characters. Required. - :type test_run_id: str - :param body: The resource instance. Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :keyword old_test_run_id: Existing test run identifier that should be rerun, if this is - provided, the - test will run with the JMX file, configuration and app components from the - existing test run. You can override the configuration values for new test run - in the request body. Default value is None. - :paramtype old_test_run_id: str - :return: An instance of LROPoller. Call `result()` on the poller object to return a :class:`~azure.developer.loadtesting.models.TestRun`. - :rtype: ~azure.core.polling.LROPoller[~azure.developer.loadtesting.models.TestRun] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_test_run( - self, - test_run_id: str, - body: Union[_models.TestRun, JSON, IO[bytes]], - *, - old_test_run_id: Optional[str] = None, - **kwargs: Any - ) -> LROPoller[_models.TestRun]: - """Create and start a new test run with the given test run Id. - - Create and start a new test run with the given test run Id. - - :param test_run_id: Unique test run identifier for the load test run, must contain only - lower-case alphabetic, numeric, underscore or hyphen characters. Required. - :type test_run_id: str - :param body: The resource instance. Is one of the following types: TestRun, JSON, IO[bytes] - Required. - :type body: ~azure.developer.loadtesting.models.TestRun or JSON or IO[bytes] - :keyword old_test_run_id: Existing test run identifier that should be rerun, if this is - provided, the - test will run with the JMX file, configuration and app components from the - existing test run. You can override the configuration values for new test run - in the request body. Default value is None. - :paramtype old_test_run_id: str - :return: An instance of LROPoller. Call `result()` on the poller object to return a :class:`~azure.developer.loadtesting.models.TestRun`. - :rtype: ~azure.core.polling.LROPoller[~azure.developer.loadtesting.models.TestRun] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - polling_interval = kwargs.pop("_polling_interval", None) - if polling_interval is None: - polling_interval = 5 - - create_or_update_test_run_operation = super()._begin_test_run( - test_run_id, body, old_test_run_id=old_test_run_id, **kwargs - ) - command = partial(self.get_test_run, test_run_id=test_run_id) - - test_run_status_polling = TestRunStatusPoller(interval=polling_interval) - return LROPoller( - command, - create_or_update_test_run_operation, - lambda *_: None, - test_run_status_polling, - ) - - @overload - def begin_test_profile_run( - self, - test_profile_run_id: str, - body: _models.TestProfileRun, - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> LROPoller[_models.TestProfileRun]: - """Create and start a new test profile run. - - Create and start a new test profile run with the given test profile run Id. - - :param test_profile_run_id: Unique identifier for the test profile run, must contain only - lower-case alphabetic, numeric, underscore or hyphen characters. Required. - :type test_profile_run_id: str - :param body: The resource instance. Required. - :type body: ~azure.developer.loadtesting.models.TestProfileRun - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: An instance of LROPoller. Call `result()` on the poller object to return a :class:`~azure.developer.loadtesting.models.TestProfileRun`. - :rtype: ~azure.core.polling.LROPoller[~azure.developer.loadtesting.models.TestProfileRun] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_test_profile_run( - self, test_profile_run_id: str, body: JSON, *, content_type: str = "application/merge-patch+json", **kwargs: Any - ) -> LROPoller[_models.TestProfileRun]: - """Create and start a new test profile run. - - Create and start a new test profile run with the given test profile run Id. - - :param test_profile_run_id: Unique identifier for the test profile run, must contain only - lower-case alphabetic, numeric, underscore or hyphen characters. Required. - :type test_profile_run_id: str - :param body: The resource instance. Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: An instance of LROPoller. Call `result()` on the poller object to return a :class:`~azure.developer.loadtesting.models.TestProfileRun`. - :rtype: ~azure.core.polling.LROPoller[~azure.developer.loadtesting.models.TestProfileRun] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_test_profile_run( - self, - test_profile_run_id: str, - body: IO[bytes], - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> LROPoller[_models.TestProfileRun]: - """Create and start a new test profile run. - - Create and start a new test profile run with the given test profile run Id. - - :param test_profile_run_id: Unique identifier for the test profile run, must contain only - lower-case alphabetic, numeric, underscore or hyphen characters. Required. - :type test_profile_run_id: str - :param body: The resource instance. Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: TestProfileRun. The TestProfileRun is compatible with MutableMapping - :return: An instance of LROPoller. Call `result()` on the poller object to return a :class:`~azure.developer.loadtesting.models.TestProfileRun`. - :rtype: ~azure.core.polling.LROPoller[~azure.developer.loadtesting.models.TestProfileRun] - """ - - @distributed_trace - def begin_test_profile_run( - self, test_profile_run_id: str, body: Union[_models.TestProfileRun, JSON, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.TestProfileRun]: - """Create and start a new test profile run. - - Create and start a new test profile run with the given test profile run Id. - - :param test_profile_run_id: Unique identifier for the test profile run, must contain only - lower-case alphabetic, numeric, underscore or hyphen characters. Required. - :type test_profile_run_id: str - :param body: The resource instance. Is one of the following types: TestProfileRun, JSON, - IO[bytes] Required. - :type body: ~azure.developer.loadtesting.models.TestProfileRun or JSON or IO[bytes] - :return: An instance of LROPoller. Call `result()` on the poller object to return a :class:`~azure.developer.loadtesting.models.TestProfileRun`. - :rtype: ~azure.core.polling.LROPoller[~azure.developer.loadtesting.models.TestProfileRun] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling_interval = kwargs.pop("_polling_interval", None) - if polling_interval is None: - polling_interval = 5 - create_or_update_test_profile_run_operation = super()._begin_test_profile_run( - test_profile_run_id, body, **kwargs - ) - command = partial(self.get_test_profile_run, test_profile_run_id=test_profile_run_id) - - test_profile_run_status_polling = TestProfileRunStatusPoller(interval=polling_interval) - return LROPoller( - command, - create_or_update_test_profile_run_operation, - lambda *_: None, - test_profile_run_status_polling, - ) - - -# Add all objects you want publicly available to users at this package level -__all__: List[str] = ["LoadTestAdministrationClientOperationsMixin", "LoadTestRunClientOperationsMixin"] +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_patch.py b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_patch.py +++ b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize diff --git a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_utils/__init__.py b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_utils/__init__.py new file mode 100644 index 000000000000..8026245c2abc --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_utils/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- diff --git a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_model_base.py b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_utils/model_base.py similarity index 98% rename from sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_model_base.py rename to sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_utils/model_base.py index 3072ee252ed9..49d5c7259389 100644 --- a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_model_base.py +++ b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_utils/model_base.py @@ -2,8 +2,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=protected-access, broad-except @@ -21,6 +22,7 @@ from datetime import datetime, date, time, timedelta, timezone from json import JSONEncoder import xml.etree.ElementTree as ET +from collections.abc import MutableMapping from typing_extensions import Self import isodate from azure.core.exceptions import DeserializationError @@ -28,11 +30,6 @@ from azure.core.pipeline import PipelineResponse from azure.core.serialization import _Null -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping - _LOGGER = logging.getLogger(__name__) __all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] @@ -347,7 +344,7 @@ def _get_model(module_name: str, model_name: str): _UNSET = object() -class _MyMutableMapping(MutableMapping[str, typing.Any]): # pylint: disable=unsubscriptable-object +class _MyMutableMapping(MutableMapping[str, typing.Any]): def __init__(self, data: typing.Dict[str, typing.Any]) -> None: self._data = data @@ -407,13 +404,13 @@ def get(self, key: str, default: typing.Any = None) -> typing.Any: return default @typing.overload - def pop(self, key: str) -> typing.Any: ... + def pop(self, key: str) -> typing.Any: ... # pylint: disable=arguments-differ @typing.overload - def pop(self, key: str, default: _T) -> _T: ... + def pop(self, key: str, default: _T) -> _T: ... # pylint: disable=signature-differs @typing.overload - def pop(self, key: str, default: typing.Any) -> typing.Any: ... + def pop(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: """ @@ -443,7 +440,7 @@ def clear(self) -> None: """ self._data.clear() - def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: + def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: # pylint: disable=arguments-differ """ Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs. @@ -454,7 +451,7 @@ def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: def setdefault(self, key: str, default: None = None) -> None: ... @typing.overload - def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... + def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: """ @@ -644,7 +641,7 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: cls._attr_to_rest_field: typing.Dict[str, _RestField] = dict(attr_to_rest_field.items()) cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") - return super().__new__(cls) # pylint: disable=no-value-for-parameter + return super().__new__(cls) def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: for base in cls.__bases__: @@ -680,7 +677,7 @@ def _deserialize(cls, data, exist_discriminators): discriminator_value = data.find(xml_name).text # pyright: ignore else: discriminator_value = data.get(discriminator._rest_name) - mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore + mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore # pylint: disable=no-member return mapped_cls._deserialize(data, exist_discriminators) def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.Any]: diff --git a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_serialization.py b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_utils/serialization.py similarity index 98% rename from sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_serialization.py rename to sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_utils/serialization.py index 7a0232de5ddc..eb86ea23c965 100644 --- a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_serialization.py +++ b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_utils/serialization.py @@ -1,28 +1,10 @@ # pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pyright: reportUnnecessaryTypeIgnoreComment=false diff --git a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_vendor.py b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_utils/utils.py similarity index 50% rename from sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_vendor.py rename to sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_utils/utils.py index 5860e8a7726a..35c9c836f85f 100644 --- a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_vendor.py +++ b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_utils/utils.py @@ -6,29 +6,20 @@ # -------------------------------------------------------------------------- from abc import ABC -from typing import TYPE_CHECKING - -from ._configuration import LoadTestAdministrationClientConfiguration, LoadTestRunClientConfiguration +from typing import Generic, TYPE_CHECKING, TypeVar if TYPE_CHECKING: - from azure.core import PipelineClient - - from ._serialization import Deserializer, Serializer - + from .serialization import Deserializer, Serializer -class LoadTestAdministrationClientMixinABC(ABC): - """DO NOT use this class. It is for internal typing use only.""" - _client: "PipelineClient" - _config: LoadTestAdministrationClientConfiguration - _serialize: "Serializer" - _deserialize: "Deserializer" +TClient = TypeVar("TClient") +TConfig = TypeVar("TConfig") -class LoadTestRunClientMixinABC(ABC): +class ClientMixinABC(ABC, Generic[TClient, TConfig]): """DO NOT use this class. It is for internal typing use only.""" - _client: "PipelineClient" - _config: LoadTestRunClientConfiguration + _client: TClient + _config: TConfig _serialize: "Serializer" _deserialize: "Deserializer" diff --git a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_version.py b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_version.py index a1f432eddc4e..be71c81bd282 100644 --- a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_version.py +++ b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.1.0b1" +VERSION = "1.0.0b1" diff --git a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/aio/_client.py b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/aio/_client.py index 20236dba0418..57366f648574 100644 --- a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/aio/_client.py +++ b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/aio/_client.py @@ -14,7 +14,7 @@ from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest -from .._serialization import Deserializer, Serializer +from .._utils.serialization import Deserializer, Serializer from ._configuration import LoadTestAdministrationClientConfiguration, LoadTestRunClientConfiguration from ._operations import LoadTestAdministrationClientOperationsMixin, LoadTestRunClientOperationsMixin @@ -38,6 +38,7 @@ class LoadTestAdministrationClient(LoadTestAdministrationClientOperationsMixin): def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs: Any) -> None: _endpoint = "https://{endpoint}" self._config = LoadTestAdministrationClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -116,6 +117,7 @@ class LoadTestRunClient(LoadTestRunClientOperationsMixin): def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs: Any) -> None: _endpoint = "https://{endpoint}" self._config = LoadTestRunClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ diff --git a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/aio/_operations/_operations.py b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/aio/_operations/_operations.py index f2e638eb48b0..0ff582a7b2f9 100644 --- a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/aio/_operations/_operations.py +++ b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/aio/_operations/_operations.py @@ -6,13 +6,14 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping import datetime from io import IOBase import json -import sys from typing import Any, AsyncIterable, Callable, Dict, IO, List, Optional, TypeVar, Union, overload import urllib.parse +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -31,7 +32,6 @@ from azure.core.utils import case_insensitive_dict from ... import models as _models -from ..._model_base import SdkJSONEncoder, _deserialize from ..._operations._operations import ( build_load_test_administration_begin_upload_test_file_request, build_load_test_administration_create_or_update_app_components_request, @@ -69,20 +69,18 @@ build_load_test_run_stop_test_profile_run_request, build_load_test_run_stop_test_run_request, ) +from ..._utils.model_base import SdkJSONEncoder, _deserialize +from ..._utils.utils import ClientMixinABC from ..._validation import api_version_validation -from .._vendor import LoadTestAdministrationClientMixinABC, LoadTestRunClientMixinABC +from .._configuration import LoadTestAdministrationClientConfiguration, LoadTestRunClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +JSON = MutableMapping[str, Any] T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class LoadTestAdministrationClientOperationsMixin( # pylint: disable=name-too-long - LoadTestAdministrationClientMixinABC + ClientMixinABC[AsyncPipelineClient, LoadTestAdministrationClientConfiguration] ): @overload @@ -842,7 +840,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.TestFileInfo], deserialized["value"]) + list_of_elem = _deserialize(List[_models.TestFileInfo], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -951,7 +949,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Test], deserialized["value"]) + list_of_elem = _deserialize(List[_models.Test], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -1544,7 +1542,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.TestProfile], deserialized["value"]) + list_of_elem = _deserialize(List[_models.TestProfile], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -1567,7 +1565,7 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) -class LoadTestRunClientOperationsMixin(LoadTestRunClientMixinABC): +class LoadTestRunClientOperationsMixin(ClientMixinABC[AsyncPipelineClient, LoadTestRunClientConfiguration]): @overload async def _begin_test_run( @@ -2387,7 +2385,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[str], deserialized["value"]) + list_of_elem = _deserialize(List[str], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -2780,7 +2778,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.TimeSeriesElement], deserialized["value"]) + list_of_elem = _deserialize(List[_models.TimeSeriesElement], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -2803,6 +2801,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace + @api_version_validation( + params_added_on={"2024-07-01-preview": ["created_by_types"]}, + ) def list_test_runs( self, *, @@ -2812,6 +2813,7 @@ def list_test_runs( execution_from: Optional[datetime.datetime] = None, execution_to: Optional[datetime.datetime] = None, status: Optional[str] = None, + created_by_types: Optional[List[str]] = None, **kwargs: Any ) -> AsyncIterable["_models.TestRun"]: """Get all test runs for the given filters. @@ -2835,6 +2837,9 @@ def list_test_runs( :paramtype execution_to: ~datetime.datetime :keyword status: Comma separated list of test run status. Default value is None. :paramtype status: str + :keyword created_by_types: Comma separated list of type of entities that have created the test + run. Default value is None. + :paramtype created_by_types: list[str] :return: An iterator like instance of TestRun :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.developer.loadtesting.models.TestRun] :raises ~azure.core.exceptions.HttpResponseError: @@ -2864,6 +2869,7 @@ def prepare_request(next_link=None): execution_to=execution_to, status=status, maxpagesize=maxpagesize, + created_by_types=created_by_types, api_version=self._config.api_version, headers=_headers, params=_params, @@ -2895,7 +2901,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.TestRun], deserialized["value"]) + list_of_elem = _deserialize(List[_models.TestRun], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -3336,7 +3342,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.TestProfileRun], deserialized["value"]) + list_of_elem = _deserialize(List[_models.TestProfileRun], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) diff --git a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/aio/_operations/_patch.py b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/aio/_operations/_patch.py index 44a11c9f19b8..8bcb627aa475 100644 --- a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/aio/_operations/_patch.py +++ b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/aio/_operations/_patch.py @@ -1,499 +1,15 @@ -# pylint: disable=line-too-long,useless-suppression -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -import asyncio -import logging -import time -from functools import partial -from typing import Any, IO, List, Optional, overload, Union +from typing import List -from azure.core.polling import AsyncPollingMethod, AsyncLROPoller -from azure.core.tracing.decorator_async import distributed_trace_async - -from ._operations import JSON -from ._operations import LoadTestAdministrationClientOperationsMixin as GeneratedAdministrationClientOperations -from ._operations import LoadTestRunClientOperationsMixin as GeneratedRunClientOperations - -from ... import models as _models - -logger = logging.getLogger(__name__) - - -class AsyncLoadTestingPollingMethod(AsyncPollingMethod): - """Base class for custom async polling methods.""" - - def _update_status(self) -> None: - raise NotImplementedError("This method needs to be implemented") - - async def _update_resource(self) -> None: - self._resource = await self._command() - - def initialize(self, client, initial_response, deserialization_callback) -> None: - self._command = client - self._initial_response = initial_response - self._resource = initial_response - - def status(self) -> str: - return self._status - - def finished(self) -> bool: - return self._status in self._termination_statuses - - def resource(self) -> JSON: - return self._resource - - async def run(self) -> None: - try: - while not self.finished(): - await self._update_resource() - self._update_status() - - if not self.finished(): - await asyncio.sleep(self._polling_interval) - except Exception as e: - logger.error(e) - raise e - - -class AsyncValidationCheckPoller(AsyncLoadTestingPollingMethod): - def __init__(self, interval=5) -> None: - self._resource = None - self._command = None - self._initial_response = None - self._polling_interval = interval - self._status = None - self._termination_statuses = [ - "VALIDATION_SUCCESS", - "VALIDATION_FAILURE", - "NOT_VALIDATED", - "VALIDATION_NOT_REQUIRED", - ] - - def _update_status(self) -> None: - self._status = self._resource["validationStatus"] - - -class AsyncTestRunStatusPoller(AsyncLoadTestingPollingMethod): - def __init__(self, interval=5) -> None: - self._resource = None - self._command = None - self._initial_response = None - self._polling_interval = interval - self._status = None - self._termination_statuses = ["DONE", "FAILED", "CANCELLED"] - - def _update_status(self) -> None: - self._status = self._resource["status"] - - -class AsyncTestProfileRunStatusPoller(AsyncLoadTestingPollingMethod): - def __init__(self, interval=5) -> None: - self._resource = None - self._command = None - self._initial_response = None - self._polling_interval = interval - self._status = None - self._termination_statuses = ["DONE", "FAILED", "CANCELLED"] - - def _update_status(self) -> None: - self._status = self._resource["status"] - - -class LoadTestAdministrationClientOperationsMixin(GeneratedAdministrationClientOperations): - - def __init__(self, *args, **kwargs): - super(LoadTestAdministrationClientOperationsMixin, self).__init__(*args, **kwargs) - - @overload - async def begin_upload_test_file( - self, - test_id: str, - file_name: str, - body: IO, - *, - file_type: Optional[Union[str, _models.FileType]] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.TestFileInfo]: - """Upload input file for a given test Id. File size can't be more than 50 MB. - Existing file with same name for the given test will be overwritten. File - should be provided in the request body as application/octet-stream. - - Upload input file for a given test Id. File size can't be more than 50 MB. - Existing file with same name for the given test will be overwritten. File - should be provided in the request body as application/octet-stream. - - :param test_id: Unique name for the load test, must contain only lower-case alphabetic, - numeric, underscore or hyphen characters. Required. - :type test_id: str - :param file_name: Unique name for test file with file extension like : App.jmx. Required. - :type file_name: str - :param body: The file content as application/octet-stream. Required. - :type body: IO - :keyword file_type: File type. Known values are: "JMX_FILE", "USER_PROPERTIES", - "ADDITIONAL_ARTIFACTS", "ZIPPED_ARTIFACTS", "URL_TEST_CONFIG", and "TEST_SCRIPT". Default value - is None. - :paramtype file_type: str or ~azure.developer.loadtesting.models.FileType - :return: An instance of AsyncLROPoller. Call `result()` on the poller object to return a :class:`~azure.developer.loadtesting.models.TestFileInfo`. - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.developer.loadtesting.models.TestFileInfo] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_upload_test_file( - self, - test_id: str, - file_name: str, - body: bytes, - *, - file_type: Optional[Union[str, _models.FileType]] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.TestFileInfo]: - """Upload input file for a given test Id. File size can't be more than 50 MB. - Existing file with same name for the given test will be overwritten. File - should be provided in the request body as application/octet-stream. - - Upload input file for a given test Id. File size can't be more than 50 MB. - Existing file with same name for the given test will be overwritten. File - should be provided in the request body as application/octet-stream. - - :param test_id: Unique name for the load test, must contain only lower-case alphabetic, - numeric, underscore or hyphen characters. Required. - :type test_id: str - :param file_name: Unique name for test file with file extension like : App.jmx. Required. - :type file_name: str - :param body: The file content as application/octet-stream. Required. - :type body: bytes - :keyword file_type: File type. Known values are: "JMX_FILE", "USER_PROPERTIES", - "ADDITIONAL_ARTIFACTS", "ZIPPED_ARTIFACTS", "URL_TEST_CONFIG", and "TEST_SCRIPT". Default value - is None. - :paramtype file_type: str or ~azure.developer.loadtesting.models.FileType - :return: An instance of AsyncLROPoller. Call `result()` on the poller object to return a :class:`~azure.developer.loadtesting.models.TestFileInfo`. - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.developer.loadtesting.models.TestFileInfo] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_upload_test_file( - self, - test_id: str, - file_name: str, - body: Union[IO, bytes], - *, - file_type: Optional[Union[str, _models.FileType]] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.TestFileInfo]: - """Upload input file for a given test Id. File size can't be more than 50 MB. - Existing file with same name for the given test will be overwritten. File - should be provided in the request body as application/octet-stream. - - Upload input file for a given test Id. File size can't be more than 50 MB. - Existing file with same name for the given test will be overwritten. File - should be provided in the request body as application/octet-stream. - - :param test_id: Unique name for the load test, must contain only lower-case alphabetic, - numeric, underscore or hyphen characters. Required. - :type test_id: str - :param file_name: Unique name for test file with file extension like : App.jmx. Required. - :type file_name: str - :param body: The file content as application/octet-stream. Required. - :type body: Is one of the following types: IO, bytes - :keyword file_type: File type. Known values are: "JMX_FILE", "USER_PROPERTIES", - "ADDITIONAL_ARTIFACTS", "ZIPPED_ARTIFACTS", "URL_TEST_CONFIG", and "TEST_SCRIPT". Default value - is None. - :paramtype file_type: str or ~azure.developer.loadtesting.models.FileType - :return: An instance of AsyncLROPoller. Call `result()` on the poller object to return a :class:`~azure.developer.loadtesting.models.TestFileInfo`. - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.developer.loadtesting.models.TestFileInfo] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling_interval = kwargs.pop("_polling_interval", None) - if polling_interval is None: - polling_interval = 5 - upload_test_file_operation = await super()._begin_upload_test_file( - test_id=test_id, file_name=file_name, body=body, file_type=file_type, **kwargs - ) - - command = partial(self.get_test_file, test_id=test_id, file_name=file_name) - - file_validation_status_polling = AsyncValidationCheckPoller(interval=polling_interval) - return AsyncLROPoller( - command, - upload_test_file_operation, - lambda *_: None, - file_validation_status_polling, - ) - - -class LoadTestRunClientOperationsMixin(GeneratedRunClientOperations): - - def __init__(self, *args, **kwargs): - super(LoadTestRunClientOperationsMixin).__init__(*args, **kwargs) - - @overload - async def begin_test_run( - self, - test_run_id: str, - body: _models.TestRun, - *, - content_type: str = "application/merge-patch+json", - old_test_run_id: Optional[str] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.TestRun]: - """Create and start a new test run with the given test run Id. - - Create and start a new test run with the given test run Id. - - :param test_run_id: Unique test run identifier for the load test run, must contain only - lower-case alphabetic, numeric, underscore or hyphen characters. Required. - :type test_run_id: str - :param body: The resource instance. Required. - :type body: ~azure.developer.loadtesting.models.TestRun - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :keyword old_test_run_id: Existing test run identifier that should be rerun, if this is - provided, the - test will run with the JMX file, configuration and app components from the - existing test run. You can override the configuration values for new test run - in the request body. Default value is None. - :paramtype old_test_run_id: str - :return: An instance of AsyncLROPoller. Call `result()` on the poller object to return a :class:`~azure.developer.loadtesting.models.TestRun`. - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.developer.loadtesting.models.TestRun] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_test_run( - self, - test_run_id: str, - body: JSON, - *, - content_type: str = "application/merge-patch+json", - old_test_run_id: Optional[str] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.TestRun]: - """Create and start a new test run with the given test run Id. - - Create and start a new test run with the given test run Id. - - :param test_run_id: Unique test run identifier for the load test run, must contain only - lower-case alphabetic, numeric, underscore or hyphen characters. Required. - :type test_run_id: str - :param body: The resource instance. Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :keyword old_test_run_id: Existing test run identifier that should be rerun, if this is - provided, the - test will run with the JMX file, configuration and app components from the - existing test run. You can override the configuration values for new test run - in the request body. Default value is None. - :paramtype old_test_run_id: str - :return: An instance of AsyncLROPoller. Call `result()` on the poller object to return a :class:`~azure.developer.loadtesting.models.TestRun`. - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.developer.loadtesting.models.TestRun] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_test_run( - self, - test_run_id: str, - body: IO[bytes], - *, - content_type: str = "application/merge-patch+json", - old_test_run_id: Optional[str] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.TestRun]: - """Create and start a new test run with the given test run Id. - - Create and start a new test run with the given test run Id. - - :param test_run_id: Unique test run identifier for the load test run, must contain only - lower-case alphabetic, numeric, underscore or hyphen characters. Required. - :type test_run_id: str - :param body: The resource instance. Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :keyword old_test_run_id: Existing test run identifier that should be rerun, if this is - provided, the - test will run with the JMX file, configuration and app components from the - existing test run. You can override the configuration values for new test run - in the request body. Default value is None. - :paramtype old_test_run_id: str - :return: An instance of AsyncLROPoller. Call `result()` on the poller object to return a :class:`~azure.developer.loadtesting.models.TestRun`. - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.developer.loadtesting.models.TestRun] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_test_run( - self, - test_run_id: str, - body: Union[_models.TestRun, JSON, IO[bytes]], - *, - old_test_run_id: Optional[str] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.TestRun]: - """Create and start a new test run with the given test run Id. - - Create and start a new test run with the given test run Id. - - :param test_run_id: Unique test run identifier for the load test run, must contain only - lower-case alphabetic, numeric, underscore or hyphen characters. Required. - :type test_run_id: str - :param body: The resource instance. Is one of the following types: TestRun, JSON, IO[bytes] - Required. - :type body: ~azure.developer.loadtesting.models.TestRun or JSON or IO[bytes] - :keyword old_test_run_id: Existing test run identifier that should be rerun, if this is - provided, the - test will run with the JMX file, configuration and app components from the - existing test run. You can override the configuration values for new test run - in the request body. Default value is None. - :paramtype old_test_run_id: str - :return: An instance of AsyncLROPoller. Call `result()` on the poller object to return a :class:`~azure.developer.loadtesting.models.TestRun`. - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.developer.loadtesting.models.TestRun] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling_interval = kwargs.pop("_polling_interval", None) - if polling_interval is None: - polling_interval = 5 - - create_or_update_test_run_operation = await super()._begin_test_run( - test_run_id, body, old_test_run_id=old_test_run_id, **kwargs - ) - - command = partial(self.get_test_run, test_run_id=test_run_id) - - test_run_status_polling = AsyncTestRunStatusPoller(interval=polling_interval) - - return AsyncLROPoller( - command, - create_or_update_test_run_operation, - lambda *_: None, - test_run_status_polling, - ) - - @overload - async def begin_test_profile_run( - self, - test_profile_run_id: str, - body: _models.TestProfileRun, - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> AsyncLROPoller[_models.TestProfileRun]: - """Create and start a new test profile run. - - Create and start a new test profile run with the given test profile run Id. - - :param test_profile_run_id: Unique identifier for the test profile run, must contain only - lower-case alphabetic, numeric, underscore or hyphen characters. Required. - :type test_profile_run_id: str - :param body: The resource instance. Required. - :type body: ~azure.developer.loadtesting.models.TestProfileRun - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller. Call `result()` on the poller object to return a :class:`~azure.developer.loadtesting.models.TestProfileRun`. - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.developer.loadtesting.models.TestProfileRun] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_test_profile_run( - self, test_profile_run_id: str, body: JSON, *, content_type: str = "application/merge-patch+json", **kwargs: Any - ) -> AsyncLROPoller[_models.TestProfileRun]: - """Create and start a new test profile run. - - Create and start a new test profile run with the given test profile run Id. - - :param test_profile_run_id: Unique identifier for the test profile run, must contain only - lower-case alphabetic, numeric, underscore or hyphen characters. Required. - :type test_profile_run_id: str - :param body: The resource instance. Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller. Call `result()` on the poller object to return a :class:`~azure.developer.loadtesting.models.TestProfileRun`. - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.developer.loadtesting.models.TestProfileRun] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_test_profile_run( - self, - test_profile_run_id: str, - body: IO[bytes], - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> AsyncLROPoller[_models.TestProfileRun]: - """Create and start a new test profile run. - - Create and start a new test profile run with the given test profile run Id. - - :param test_profile_run_id: Unique identifier for the test profile run, must contain only - lower-case alphabetic, numeric, underscore or hyphen characters. Required. - :type test_profile_run_id: str - :param body: The resource instance. Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller. Call `result()` on the poller object to return a :class:`~azure.developer.loadtesting.models.TestProfileRun`. - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.developer.loadtesting.models.TestProfileRun] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_test_profile_run( - self, test_profile_run_id: str, body: Union[_models.TestProfileRun, JSON, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.TestProfileRun]: - """Create and start a new test profile run. - - Create and start a new test profile run with the given test profile run Id. - - :param test_profile_run_id: Unique identifier for the test profile run, must contain only - lower-case alphabetic, numeric, underscore or hyphen characters. Required. - :type test_profile_run_id: str - :param body: The resource instance. Is one of the following types: TestProfileRun, JSON, - IO[bytes] Required. - :type body: ~azure.developer.loadtesting.models.TestProfileRun or JSON or IO[bytes] - :return: An instance of AsyncLROPoller. Call `result()` on the poller object to return a :class:`~azure.developer.loadtesting.models.TestProfileRun`. - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.developer.loadtesting.models.TestProfileRun] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling_interval = kwargs.pop("_polling_interval", None) - - if polling_interval is None: - polling_interval = 5 - - create_or_update_test_profile_run_operation = await super()._begin_test_profile_run( - test_profile_run_id, body, **kwargs - ) - - command = partial(self.get_test_profile_run, test_profile_run_id=test_profile_run_id) - - test_profile_run_status_polling = AsyncTestProfileRunStatusPoller(interval=polling_interval) - return AsyncLROPoller( - command, - create_or_update_test_profile_run_operation, - lambda *_: None, - test_profile_run_status_polling, - ) - - -# Add all objects you want publicly available to users at this package level -__all__: List[str] = ["LoadTestAdministrationClientOperationsMixin", "LoadTestRunClientOperationsMixin"] +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/aio/_patch.py b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/aio/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/aio/_patch.py +++ b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/aio/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize diff --git a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/aio/_vendor.py b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/aio/_vendor.py deleted file mode 100644 index cc211a4758bb..000000000000 --- a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/aio/_vendor.py +++ /dev/null @@ -1,34 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from abc import ABC -from typing import TYPE_CHECKING - -from ._configuration import LoadTestAdministrationClientConfiguration, LoadTestRunClientConfiguration - -if TYPE_CHECKING: - from azure.core import AsyncPipelineClient - - from .._serialization import Deserializer, Serializer - - -class LoadTestAdministrationClientMixinABC(ABC): - """DO NOT use this class. It is for internal typing use only.""" - - _client: "AsyncPipelineClient" - _config: LoadTestAdministrationClientConfiguration - _serialize: "Serializer" - _deserialize: "Deserializer" - - -class LoadTestRunClientMixinABC(ABC): - """DO NOT use this class. It is for internal typing use only.""" - - _client: "AsyncPipelineClient" - _config: LoadTestRunClientConfiguration - _serialize: "Serializer" - _deserialize: "Deserializer" diff --git a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/models/_models.py b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/models/_models.py index 32acdef7a137..2a08cb204f5b 100644 --- a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/models/_models.py +++ b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/models/_models.py @@ -11,15 +11,14 @@ import datetime from typing import Any, Dict, List, Literal, Mapping, Optional, TYPE_CHECKING, Union, overload -from .. import _model_base -from .._model_base import rest_discriminator, rest_field +from .._utils.model_base import Model as _Model, rest_discriminator, rest_field from ._enums import ResourceKind if TYPE_CHECKING: from .. import models as _models -class AppComponent(_model_base.Model): +class AppComponent(_Model): """An Azure resource object (Refer azure generic resource model :`https://learn.microsoft.com/en-us/rest/api/resources/resources/get-by-id#genericresource `_). @@ -82,7 +81,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class ArtifactsContainerInfo(_model_base.Model): +class ArtifactsContainerInfo(_Model): """Artifacts container info. :ivar url: This is a SAS URI to an Azure Storage Container that contains the test run @@ -118,7 +117,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class AutoStopCriteria(_model_base.Model): +class AutoStopCriteria(_Model): """Auto stop criteria for a test. This will automatically stop a load test if the error percentage is high for a certain time window. @@ -166,7 +165,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class CertificateMetadata(_model_base.Model): +class CertificateMetadata(_Model): """Certificates metadata. :ivar value: The value of the certificate for respective type. @@ -206,7 +205,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class DimensionFilter(_model_base.Model): +class DimensionFilter(_Model): """Dimension name and values to filter. :ivar name: The dimension name. @@ -241,7 +240,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class DimensionValue(_model_base.Model): +class DimensionValue(_Model): """Represents a metric dimension value. :ivar name: The name of the dimension. @@ -274,7 +273,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class ErrorDetails(_model_base.Model): +class ErrorDetails(_Model): """Error details if there is any failure in load test run. :ivar message: Error details in case test run was not successfully run. @@ -285,7 +284,7 @@ class ErrorDetails(_model_base.Model): """Error details in case test run was not successfully run.""" -class FunctionFlexConsumptionResourceConfiguration(_model_base.Model): # pylint: disable=name-too-long +class FunctionFlexConsumptionResourceConfiguration(_Model): # pylint: disable=name-too-long """Resource configuration instance for a Flex Consumption based Azure Function App. :ivar instance_memory_mb: Memory size of the instance. Supported values are 2048, 4096. @@ -323,7 +322,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class TargetResourceConfigurations(_model_base.Model): +class TargetResourceConfigurations(_Model): """Configurations of a target resource. This varies with the kind of resource. You probably want to use the sub-classes and not this class directly. Known sub-classes are: @@ -334,7 +333,7 @@ class TargetResourceConfigurations(_model_base.Model): :vartype kind: str or ~azure.developer.loadtesting.models.ResourceKind """ - __mapping__: Dict[str, _model_base.Model] = {} + __mapping__: Dict[str, _Model] = {} kind: str = rest_discriminator(name="kind", visibility=["read", "create"]) """Kind of the resource for which the configurations apply. Required. \"FunctionsFlexConsumption\"""" @@ -397,7 +396,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, kind=ResourceKind.FUNCTIONS_FLEX_CONSUMPTION, **kwargs) -class LoadTestConfiguration(_model_base.Model): +class LoadTestConfiguration(_Model): """Configurations for the load test. :ivar engine_instances: The number of engine instances to execute load test. Supported values @@ -469,7 +468,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class MetricAvailability(_model_base.Model): +class MetricAvailability(_Model): """Metric availability specifies the time grain (aggregation interval or frequency). :ivar time_grain: The time grain specifies the aggregation interval for the metric. Expressed @@ -503,7 +502,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class MetricDefinition(_model_base.Model): +class MetricDefinition(_Model): """Metric definition. :ivar dimensions: List of dimensions. @@ -587,7 +586,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class MetricDefinitionCollection(_model_base.Model): +class MetricDefinitionCollection(_Model): """Represents collection of metric definitions. :ivar value: the values for the metric definitions. Required. @@ -615,7 +614,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class MetricNamespace(_model_base.Model): +class MetricNamespace(_Model): """Metric namespace class specifies the metadata for a metric namespace. :ivar description: The namespace description. @@ -648,7 +647,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class MetricNamespaceCollection(_model_base.Model): +class MetricNamespaceCollection(_Model): """Represents collection of metric namespaces. :ivar value: The values for the metric namespaces. Required. @@ -676,7 +675,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class MetricRequestPayload(_model_base.Model): +class MetricRequestPayload(_Model): """Filters to fetch the set of metric. :ivar filters: Get metrics for specific dimension values. Example: Metric contains dimension @@ -712,7 +711,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class MetricValue(_model_base.Model): +class MetricValue(_Model): """Represents a metric value. :ivar timestamp: The timestamp for the metric value in RFC 3339 format. @@ -747,7 +746,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class NameAndDescription(_model_base.Model): +class NameAndDescription(_Model): """The name and description. :ivar description: The description. @@ -780,7 +779,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class OptionalLoadTestConfiguration(_model_base.Model): +class OptionalLoadTestConfiguration(_Model): """Configuration for quick load test. :ivar endpoint_url: Test URL. Provide the complete HTTP URL. For example, @@ -847,7 +846,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class PassFailCriteria(_model_base.Model): +class PassFailCriteria(_Model): """Pass fail criteria for a test. :ivar pass_fail_metrics: Map of id and pass fail metrics { id : pass fail metrics }. @@ -886,13 +885,14 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class PassFailMetric(_model_base.Model): +class PassFailMetric(_Model): """Pass fail metric. :ivar client_metric: The client metric on which the criteria should be applied. Known values are: "response_time_ms", "latency", "error", "requests", and "requests_per_sec". :vartype client_metric: str or ~azure.developer.loadtesting.models.PFMetrics :ivar aggregate: The aggregation function to be applied on the client metric. Allowed functions + * ‘percentage’ - for error metric , ‘avg’, percentiles like ‘p50’, ‘p90’, & so on, ‘min’, ‘max’ - for response_time_ms and latency metric, ‘avg’ - for requests_per_sec, ‘count’ - for requests. Known values are: "count", "percentage", "avg", "p50", "p75", "p90", @@ -924,6 +924,7 @@ class PassFailMetric(_model_base.Model): visibility=["read", "create", "update", "delete", "query"] ) """The aggregation function to be applied on the client metric. Allowed functions + * ‘percentage’ - for error metric , ‘avg’, percentiles like ‘p50’, ‘p90’, & so on, ‘min’, ‘max’ - for response_time_ms and latency metric, ‘avg’ - for requests_per_sec, ‘count’ - for requests. Known values are: \"count\", \"percentage\", \"avg\", \"p50\", \"p75\", @@ -971,7 +972,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class PassFailServerMetric(_model_base.Model): +class PassFailServerMetric(_Model): """Pass fail server metric. :ivar resource_id: The resource id of the resource emitting the metric. Required. @@ -1044,7 +1045,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class RegionalConfiguration(_model_base.Model): +class RegionalConfiguration(_Model): """Region distribution configuration for the load test. :ivar engine_instances: The number of engine instances to execute load test in specified @@ -1089,7 +1090,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class ResourceMetric(_model_base.Model): +class ResourceMetric(_Model): """Associated metric definition for particular metrics of the azure resource ( Refer : `https://learn.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition @@ -1158,7 +1159,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class Secret(_model_base.Model): +class Secret(_Model): """Secret. :ivar value: The value of the secret for the respective type. @@ -1193,7 +1194,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class Test(_model_base.Model): +class Test(_Model): """Load test model. :ivar pass_fail_criteria: Pass fail criteria for a test. @@ -1392,7 +1393,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class TestAppComponents(_model_base.Model): +class TestAppComponents(_Model): """Test app components. :ivar components: Azure resource collection { resource id (fully qualified resource Id e.g @@ -1450,7 +1451,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class TestFileInfo(_model_base.Model): +class TestFileInfo(_Model): """Test file info. :ivar file_name: Name of the file. Required. @@ -1507,7 +1508,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class TestInputArtifacts(_model_base.Model): +class TestInputArtifacts(_Model): """The input artifacts for the test. :ivar config_file_info: The load test YAML file that contains the the test configuration. @@ -1571,7 +1572,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class TestProfile(_model_base.Model): +class TestProfile(_Model): """Test Profile Model. :ivar test_profile_id: Unique identifier for the test profile, must contain only lower-case @@ -1655,7 +1656,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class TestProfileRun(_model_base.Model): +class TestProfileRun(_Model): """Test Profile Run model. :ivar test_profile_run_id: Unique identifier for the test profile run, must contain only @@ -1774,7 +1775,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class TestProfileRunRecommendation(_model_base.Model): +class TestProfileRunRecommendation(_Model): """A recommendation object that provides a list of configuration that optimizes its category. :ivar category: Category of the recommendation. Required. Known values are: @@ -1813,7 +1814,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class TestRun(_model_base.Model): +class TestRun(_Model): """Load test run model. :ivar test_run_id: Unique test run identifier for the load test run, must contain only @@ -2053,7 +2054,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class TestRunAppComponents(_model_base.Model): +class TestRunAppComponents(_Model): """Test run app component. :ivar components: Azure resource collection { resource id (fully qualified resource Id e.g @@ -2111,7 +2112,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class TestRunArtifacts(_model_base.Model): +class TestRunArtifacts(_Model): """Collection of test run artifacts. :ivar input_artifacts: The input artifacts for the test run. @@ -2145,7 +2146,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class TestRunDetail(_model_base.Model): +class TestRunDetail(_Model): """Details of a particular test run for a test profile run. :ivar status: Status of the test run. Required. Known values are: "ACCEPTED", "NOTSTARTED", @@ -2191,7 +2192,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class TestRunFileInfo(_model_base.Model): +class TestRunFileInfo(_Model): """Test run file info. :ivar file_name: Name of the file. Required. @@ -2248,7 +2249,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class TestRunInputArtifacts(_model_base.Model): +class TestRunInputArtifacts(_Model): """The input artifacts for the test run. :ivar config_file_info: The load test YAML file that contains the the test configuration. @@ -2312,7 +2313,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class TestRunOutputArtifacts(_model_base.Model): +class TestRunOutputArtifacts(_Model): """The output artifacts for the test run. :ivar result_file_info: The test run results file. @@ -2363,7 +2364,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class TestRunServerMetricsConfiguration(_model_base.Model): +class TestRunServerMetricsConfiguration(_Model): """Test run server metrics configuration. :ivar test_run_id: Test run identifier. @@ -2423,7 +2424,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class TestRunStatistics(_model_base.Model): +class TestRunStatistics(_Model): """Test run statistics. :ivar transaction: Transaction name. @@ -2510,7 +2511,7 @@ class TestRunStatistics(_model_base.Model): """Send network bytes.""" -class TestServerMetricsConfiguration(_model_base.Model): +class TestServerMetricsConfiguration(_Model): """Test server metrics configuration. :ivar test_id: Test identifier. @@ -2570,7 +2571,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class TimeSeriesElement(_model_base.Model): +class TimeSeriesElement(_Model): """The time series returned when a data query is performed. :ivar data: An array of data points representing the metric values. diff --git a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/models/_patch.py b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/models/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/models/_patch.py +++ b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/models/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/create_or_update_test.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/create_or_update_test.py new file mode 100644 index 000000000000..aaa60dd35632 --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/create_or_update_test.py @@ -0,0 +1,86 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestAdministrationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python create_or_update_test.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + response = client.create_or_update_test( + test_id="12345678-1234-1234-1234-123456789012", + body={ + "autoStopCriteria": {"autoStopDisabled": True, "errorRate": 70, "errorRateTimeWindowInSeconds": 60}, + "description": "sample description", + "displayName": "Performance_LoadTest", + "engineBuiltInIdentityIds": [ + "/subscriptions/10000000-0000-0000-0000-000000000000/resourceGroups/samplerg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/sampleresourcename" + ], + "engineBuiltInIdentityType": "UserAssigned", + "environmentVariables": {"envvar1": "sampletext"}, + "keyvaultReferenceIdentityId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/sampleprovider/sampleresourcetype/sampleresourcename", + "keyvaultReferenceIdentityType": "UserAssigned", + "loadTestConfiguration": {"engineInstances": 6, "splitAllCSVs": True}, + "metricsReferenceIdentityId": "/subscriptions/10000000-0000-0000-0000-000000000000/resourceGroups/samplerg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/sampleresourcename", + "metricsReferenceIdentityType": "UserAssigned", + "passFailCriteria": { + "passFailMetrics": { + "fefd759d-7fe8-4f83-8b6d-aeebe0f491fe": { + "action": "continue", + "aggregate": "percentage", + "clientMetric": "response_time_ms", + "condition": ">", + "value": 20, + } + }, + "passFailServerMetrics": { + "fefd759d-7fe8-4f83-8b6d-aeebe0f491fe": { + "action": "continue", + "aggregation": "Average", + "condition": ">", + "metricName": "Percentage CPU", + "metricNamespace": "Microsoft.Compute/virtualMachines", + "resourceId": "/subscriptions/12345678-1234-1234-1234-123456789abc/resourceGroups/MyResourceGroup/providers/Microsoft.Compute/virtualMachines/MyVM", + "value": 20, + } + }, + }, + "secrets": { + "secret1": { + "type": "AKV_SECRET_URI", + "value": "https://samplevault.vault.azure.net/secrets/samplesecret/f113f91fd4c44a368049849c164db827", + } + }, + "subnetId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/Microsoft.Network/virtualNetworks/samplenetworkresource/subnets/AAAAA0A0A0", + }, + ) + print(response) + + +# x-ms-original-file: 2024-12-01-preview/CreateOrUpdateTest.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/create_or_update_test_app_components.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/create_or_update_test_app_components.py new file mode 100644 index 000000000000..364fbf5d4867 --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/create_or_update_test_app_components.py @@ -0,0 +1,52 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestAdministrationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python create_or_update_test_app_components.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + response = client.create_or_update_app_components( + test_id="ee843bd9-a6d4-4364-a45c-427a03c39fa7", + body={ + "components": { + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource": { + "displayName": "Performance_LoadTest_Insights", + "kind": "web", + "resourceName": "appcomponentresource", + "resourceType": "microsoft.insights/components", + } + } + }, + ) + print(response) + + +# x-ms-original-file: 2024-12-01-preview/CreateOrUpdateTestAppComponents.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/create_or_update_test_profile.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/create_or_update_test_profile.py new file mode 100644 index 000000000000..4c352636fa5c --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/create_or_update_test_profile.py @@ -0,0 +1,55 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestAdministrationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python create_or_update_test_profile.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + response = client.create_or_update_test_profile( + test_profile_id="12345678-1234-1234-1234-123456789012", + body={ + "description": "sample description", + "displayName": "Performance_TestProfile", + "targetResourceConfigurations": { + "configurations": { + "config1": {"httpConcurrency": 16, "instanceMemoryMB": 2048}, + "config2": {"httpConcurrency": 16, "instanceMemoryMB": 4096}, + }, + "kind": "FunctionsFlexConsumption", + }, + "targetResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/Microsoft.Web/sites/myfunctionapp", + "testId": "12346-abcd-6789", + }, + ) + print(response) + + +# x-ms-original-file: 2024-12-01-preview/CreateOrUpdateTestProfile.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/create_or_update_test_run_app_components.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/create_or_update_test_run_app_components.py new file mode 100644 index 000000000000..2a5bc389ef73 --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/create_or_update_test_run_app_components.py @@ -0,0 +1,52 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestRunClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python create_or_update_test_run_app_components.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + response = client.create_or_update_app_components( + test_run_id="ee843bd9-a6d4-4364-a45c-427a03c39fa7", + body={ + "components": { + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource": { + "displayName": "Performance_LoadTest_Insights", + "kind": "web", + "resourceName": "appcomponentresource", + "resourceType": "microsoft.insights/components", + } + } + }, + ) + print(response) + + +# x-ms-original-file: 2024-12-01-preview/CreateOrUpdateTestRunAppComponents.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/create_or_update_test_run_server_metrics_config.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/create_or_update_test_run_server_metrics_config.py new file mode 100644 index 000000000000..784e78b3a34e --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/create_or_update_test_run_server_metrics_config.py @@ -0,0 +1,55 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestRunClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python create_or_update_test_run_server_metrics_config.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + response = client.create_or_update_server_metrics_config( + test_run_id="edc6e529-d009-4b99-b763-ca492e3a2823", + body={ + "metrics": { + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource/providers/microsoft.insights/metricdefinitions/requests/duration": { + "aggregation": "Average", + "displayDescription": "sample description", + "metricNamespace": "microsoft.insights/components", + "name": "requests/duration", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource", + "resourceType": "microsoft.insights/components", + "unit": None, + } + } + }, + ) + print(response) + + +# x-ms-original-file: 2024-12-01-preview/CreateOrUpdateTestRunServerMetricsConfig.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/create_or_update_test_server_metrics_config.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/create_or_update_test_server_metrics_config.py new file mode 100644 index 000000000000..5e0f7ee59252 --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/create_or_update_test_server_metrics_config.py @@ -0,0 +1,55 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestAdministrationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python create_or_update_test_server_metrics_config.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + response = client.create_or_update_server_metrics_config( + test_id="edc6e529-d009-4b99-b763-ca492e3a2823", + body={ + "metrics": { + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource/providers/microsoft.insights/metricdefinitions/requests/duration": { + "aggregation": "Average", + "displayDescription": "sample description", + "metricNamespace": "microsoft.insights/components", + "name": "requests/duration", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource", + "resourceType": "microsoft.insights/components", + "unit": None, + } + } + }, + ) + print(response) + + +# x-ms-original-file: 2024-12-01-preview/CreateOrUpdateTestServerMetricsConfig.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/delete_test.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/delete_test.py new file mode 100644 index 000000000000..ea15239252f0 --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/delete_test.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestAdministrationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python delete_test.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + client.delete_test( + test_id="12345678-1234-1234-1234-123456789012", + ) + + +# x-ms-original-file: 2024-12-01-preview/DeleteTest.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/delete_test_file.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/delete_test_file.py new file mode 100644 index 000000000000..c29679a53251 --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/delete_test_file.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestAdministrationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python delete_test_file.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + client.delete_test_file( + test_id="12345678-1234-1234-1234-123456789012", + file_name="app.jmx", + ) + + +# x-ms-original-file: 2024-12-01-preview/DeleteTestFile.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/delete_test_profile.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/delete_test_profile.py new file mode 100644 index 000000000000..0e9b84a0bc65 --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/delete_test_profile.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestAdministrationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python delete_test_profile.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + client.delete_test_profile( + test_profile_id="12345678-1234-1234-1234-123456789012", + ) + + +# x-ms-original-file: 2024-12-01-preview/DeleteTestProfile.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/delete_test_profile_run.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/delete_test_profile_run.py new file mode 100644 index 000000000000..44d81620cbe5 --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/delete_test_profile_run.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestRunClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python delete_test_profile_run.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + client.delete_test_profile_run( + test_profile_run_id="12316678-1234-1234-1234-122451189012", + ) + + +# x-ms-original-file: 2024-12-01-preview/DeleteTestProfileRun.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/delete_test_run.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/delete_test_run.py new file mode 100644 index 000000000000..8c0f0473b328 --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/delete_test_run.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestRunClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python delete_test_run.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + client.delete_test_run( + test_run_id="12316678-1234-1234-1234-122451189012", + ) + + +# x-ms-original-file: 2024-12-01-preview/DeleteTestRun.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/get_test.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/get_test.py new file mode 100644 index 000000000000..b3f96425935c --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/get_test.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestAdministrationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python get_test.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + response = client.get_test( + test_id="12345678-1234-1234-1234-123456789012", + ) + print(response) + + +# x-ms-original-file: 2024-12-01-preview/GetTest.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/get_test_file.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/get_test_file.py new file mode 100644 index 000000000000..915ca32fb4c7 --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/get_test_file.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestAdministrationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python get_test_file.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + response = client.get_test_file( + test_id="12345678-1234-1234-1234-123456789012", + file_name="sample.jmx", + ) + print(response) + + +# x-ms-original-file: 2024-12-01-preview/GetTestFile.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/get_test_profile.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/get_test_profile.py new file mode 100644 index 000000000000..1741693e1dc0 --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/get_test_profile.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestAdministrationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python get_test_profile.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + response = client.get_test_profile( + test_profile_id="12345678-1234-1234-1234-123456789012", + ) + print(response) + + +# x-ms-original-file: 2024-12-01-preview/GetTestProfile.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/get_test_profile_run_executed.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/get_test_profile_run_executed.py new file mode 100644 index 000000000000..c7341aee9c2a --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/get_test_profile_run_executed.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestRunClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python get_test_profile_run_executed.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + response = client.get_test_profile_run( + test_profile_run_id="12316678-1234-1234-1234-122451189012", + ) + print(response) + + +# x-ms-original-file: 2024-12-01-preview/GetTestProfileRun_Executed.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/get_test_profile_run_executing.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/get_test_profile_run_executing.py new file mode 100644 index 000000000000..5fb7d8adfb3a --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/get_test_profile_run_executing.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestRunClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python get_test_profile_run_executing.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + response = client.get_test_profile_run( + test_profile_run_id="12316678-1234-1234-1234-122451189012", + ) + print(response) + + +# x-ms-original-file: 2024-12-01-preview/GetTestProfileRun_Executing.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/get_test_run.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/get_test_run.py new file mode 100644 index 000000000000..6c05c2432ed0 --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/get_test_run.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestRunClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python get_test_run.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + response = client.get_test_run( + test_run_id="12316678-1234-1234-1234-122451189012", + ) + print(response) + + +# x-ms-original-file: 2024-12-01-preview/GetTestRun.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/get_test_run_file.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/get_test_run_file.py new file mode 100644 index 000000000000..cd56d2701fb5 --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/get_test_run_file.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestRunClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python get_test_run_file.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + response = client.get_test_run_file( + test_run_id="12316678-1234-1234-1234-122451189012", + file_name="sample.jmx", + ) + print(response) + + +# x-ms-original-file: 2024-12-01-preview/GetTestRunFile.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_metric_dimension_values.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_metric_dimension_values.py new file mode 100644 index 000000000000..6b3267ca3e9e --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_metric_dimension_values.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestRunClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python list_metric_dimension_values.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + response = client.list_metric_dimension_values( + test_run_id="12316678-1234-1234-1234-122451189012", + name="SamplerName", + metric_name="ActiveThreads", + metric_namespace="LoadTestRunMetrics", + time_interval="2022-09-24T19:00:40Z/2022-09-25T19:28:40Z", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2024-12-01-preview/ListMetricDimensionValues.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_app_components.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_app_components.py new file mode 100644 index 000000000000..0fda7a77e15a --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_app_components.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestAdministrationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python list_test_app_components.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + response = client.get_app_components( + test_id="ee843bd9-a6d4-4364-a45c-427a03c39fa7", + ) + print(response) + + +# x-ms-original-file: 2024-12-01-preview/ListTestAppComponents.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_files.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_files.py new file mode 100644 index 000000000000..773efd436868 --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_files.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestAdministrationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python list_test_files.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + response = client.list_test_files( + test_id="12345678-1234-1234-1234-123456789012", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2024-12-01-preview/ListTestFiles.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_profile_runs.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_profile_runs.py new file mode 100644 index 000000000000..6006e992357e --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_profile_runs.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestRunClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python list_test_profile_runs.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + response = client.list_test_profile_runs() + for item in response: + print(item) + + +# x-ms-original-file: 2024-12-01-preview/ListTestProfileRuns.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_profiles.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_profiles.py new file mode 100644 index 000000000000..499a5d8db6d8 --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_profiles.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestAdministrationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python list_test_profiles.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + response = client.list_test_profiles() + for item in response: + print(item) + + +# x-ms-original-file: 2024-12-01-preview/ListTestProfiles.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_run_app_components.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_run_app_components.py new file mode 100644 index 000000000000..f61e6f46d687 --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_run_app_components.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestRunClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python list_test_run_app_components.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + response = client.get_app_components( + test_run_id="ee843bd9-a6d4-4364-a45c-427a03c39fa7", + ) + print(response) + + +# x-ms-original-file: 2024-12-01-preview/ListTestRunAppComponents.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_run_metrics.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_run_metrics.py new file mode 100644 index 000000000000..dea14de4a132 --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_run_metrics.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestRunClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python list_test_run_metrics.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + response = client.list_metrics( + test_run_id="12316678-1234-1234-1234-122451189012", + metric_name="ActiveThreads", + metric_namespace="LoadTestRunMetrics", + time_interval="2022-09-24T19:00:40Z/2022-09-25T19:28:40Z", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2024-12-01-preview/ListTestRunMetrics.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_run_metrics_definitions.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_run_metrics_definitions.py new file mode 100644 index 000000000000..867ba9495379 --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_run_metrics_definitions.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestRunClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python list_test_run_metrics_definitions.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + response = client.get_metric_definitions( + test_run_id="12316678-1234-1234-1234-122451189012", + metric_namespace="LoadTestRunMetrics", + ) + print(response) + + +# x-ms-original-file: 2024-12-01-preview/ListTestRunMetricsDefinitions.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_run_metrics_namespaces.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_run_metrics_namespaces.py new file mode 100644 index 000000000000..be23840910b3 --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_run_metrics_namespaces.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestRunClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python list_test_run_metrics_namespaces.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + response = client.get_metric_namespaces( + test_run_id="12316678-1234-1234-1234-122451189012", + ) + print(response) + + +# x-ms-original-file: 2024-12-01-preview/ListTestRunMetricsNamespaces.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_run_server_metrics_config.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_run_server_metrics_config.py new file mode 100644 index 000000000000..cff5a8a23a55 --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_run_server_metrics_config.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestRunClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python list_test_run_server_metrics_config.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + response = client.get_server_metrics_config( + test_run_id="12345678-1234-1234-1234-123456789012", + ) + print(response) + + +# x-ms-original-file: 2024-12-01-preview/ListTestRunServerMetricsConfig.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_runs.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_runs.py new file mode 100644 index 000000000000..207a128183d5 --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_runs.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestRunClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python list_test_runs.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + response = client.list_test_runs() + for item in response: + print(item) + + +# x-ms-original-file: 2024-12-01-preview/ListTestRuns.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_server_metrics_config.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_server_metrics_config.py new file mode 100644 index 000000000000..51dff2ec7cca --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_test_server_metrics_config.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestAdministrationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python list_test_server_metrics_config.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + response = client.get_server_metrics_config( + test_id="12345678-1234-1234-1234-123456789012", + ) + print(response) + + +# x-ms-original-file: 2024-12-01-preview/ListTestServerMetricsConfig.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_tests.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_tests.py new file mode 100644 index 000000000000..d97b49bcef68 --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/list_tests.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestAdministrationClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python list_tests.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + response = client.list_tests() + for item in response: + print(item) + + +# x-ms-original-file: 2024-12-01-preview/ListTests.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/stop_test_profile_run.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/stop_test_profile_run.py new file mode 100644 index 000000000000..3a670e9049b5 --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/stop_test_profile_run.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestRunClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python stop_test_profile_run.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + response = client.stop_test_profile_run( + test_profile_run_id="12316678-1234-1234-1234-122451189012", + ) + print(response) + + +# x-ms-original-file: 2024-12-01-preview/StopTestProfileRun.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_samples/stop_test_run.py b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/stop_test_run.py new file mode 100644 index 000000000000..51eff362473e --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_samples/stop_test_run.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.developer.loadtesting import LoadTestRunClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-developer-loadtesting +# USAGE + python stop_test_run.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = LoadTestAdministrationClient( + endpoint="ENDPOINT", + credential=DefaultAzureCredential(), + ) + + response = client.stop_test_run( + test_run_id="12316678-1234-1234-1234-122451189012", + ) + print(response) + + +# x-ms-original-file: 2024-12-01-preview/StopTestRun.json +if __name__ == "__main__": + main() diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_tests/conftest.py b/sdk/loadtesting/azure-developer-loadtesting/generated_tests/conftest.py new file mode 100644 index 000000000000..4350841161b5 --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_tests/conftest.py @@ -0,0 +1,56 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# For security, please avoid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + loadtestadministration_subscription_id = os.environ.get( + "LOADTESTADMINISTRATION_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000" + ) + loadtestadministration_tenant_id = os.environ.get( + "LOADTESTADMINISTRATION_TENANT_ID", "00000000-0000-0000-0000-000000000000" + ) + loadtestadministration_client_id = os.environ.get( + "LOADTESTADMINISTRATION_CLIENT_ID", "00000000-0000-0000-0000-000000000000" + ) + loadtestadministration_client_secret = os.environ.get( + "LOADTESTADMINISTRATION_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=loadtestadministration_subscription_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer(regex=loadtestadministration_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=loadtestadministration_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer( + regex=loadtestadministration_client_secret, value="00000000-0000-0000-0000-000000000000" + ) + + loadtestrun_subscription_id = os.environ.get("LOADTESTRUN_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + loadtestrun_tenant_id = os.environ.get("LOADTESTRUN_TENANT_ID", "00000000-0000-0000-0000-000000000000") + loadtestrun_client_id = os.environ.get("LOADTESTRUN_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + loadtestrun_client_secret = os.environ.get("LOADTESTRUN_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=loadtestrun_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=loadtestrun_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=loadtestrun_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=loadtestrun_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_tests/test_load_test_administration.py b/sdk/loadtesting/azure-developer-loadtesting/generated_tests/test_load_test_administration.py new file mode 100644 index 000000000000..db860d9d5d8c --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_tests/test_load_test_administration.py @@ -0,0 +1,341 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from devtools_testutils import recorded_by_proxy +from testpreparer import LoadTestAdministrationClientTestBase, LoadTestAdministrationPreparer + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestLoadTestAdministration(LoadTestAdministrationClientTestBase): + @LoadTestAdministrationPreparer() + @recorded_by_proxy + def test_create_or_update_test(self, loadtestadministration_endpoint): + client = self.create_client(endpoint=loadtestadministration_endpoint) + response = client.create_or_update_test( + test_id="str", + body={ + "testId": "str", + "autoStopCriteria": {"autoStopDisabled": bool, "errorRate": 0.0, "errorRateTimeWindowInSeconds": 0}, + "baselineTestRunId": "str", + "certificate": {"name": "str", "type": "str", "value": "str"}, + "createdBy": "str", + "createdDateTime": "2020-02-20 00:00:00", + "description": "str", + "displayName": "str", + "engineBuiltInIdentityIds": ["str"], + "engineBuiltInIdentityType": "str", + "environmentVariables": {"str": "str"}, + "inputArtifacts": { + "additionalFileInfo": [ + { + "fileName": "str", + "expireDateTime": "2020-02-20 00:00:00", + "fileType": "str", + "url": "str", + "validationFailureDetails": "str", + "validationStatus": "str", + } + ], + "configFileInfo": { + "fileName": "str", + "expireDateTime": "2020-02-20 00:00:00", + "fileType": "str", + "url": "str", + "validationFailureDetails": "str", + "validationStatus": "str", + }, + "inputArtifactsZipFileInfo": { + "fileName": "str", + "expireDateTime": "2020-02-20 00:00:00", + "fileType": "str", + "url": "str", + "validationFailureDetails": "str", + "validationStatus": "str", + }, + "testScriptFileInfo": { + "fileName": "str", + "expireDateTime": "2020-02-20 00:00:00", + "fileType": "str", + "url": "str", + "validationFailureDetails": "str", + "validationStatus": "str", + }, + "urlTestConfigFileInfo": { + "fileName": "str", + "expireDateTime": "2020-02-20 00:00:00", + "fileType": "str", + "url": "str", + "validationFailureDetails": "str", + "validationStatus": "str", + }, + "userPropFileInfo": { + "fileName": "str", + "expireDateTime": "2020-02-20 00:00:00", + "fileType": "str", + "url": "str", + "validationFailureDetails": "str", + "validationStatus": "str", + }, + }, + "keyvaultReferenceIdentityId": "str", + "keyvaultReferenceIdentityType": "str", + "kind": "str", + "lastModifiedBy": "str", + "lastModifiedDateTime": "2020-02-20 00:00:00", + "loadTestConfiguration": { + "engineInstances": 0, + "optionalLoadTestConfig": { + "duration": 0, + "endpointUrl": "str", + "maxResponseTimeInMs": 0, + "rampUpTime": 0, + "requestsPerSecond": 0, + "virtualUsers": 0, + }, + "quickStartTest": bool, + "regionalLoadTestConfig": [{"engineInstances": 0, "region": "str"}], + "splitAllCSVs": bool, + }, + "metricsReferenceIdentityId": "str", + "metricsReferenceIdentityType": "str", + "passFailCriteria": { + "passFailMetrics": { + "str": { + "action": "str", + "actualValue": 0.0, + "aggregate": "str", + "clientMetric": "str", + "condition": "str", + "requestName": "str", + "result": "str", + "value": 0.0, + } + }, + "passFailServerMetrics": { + "str": { + "aggregation": "str", + "condition": "str", + "metricName": "str", + "metricNamespace": "str", + "resourceId": "str", + "value": 0.0, + "action": "str", + "actualValue": 0.0, + "result": "str", + } + }, + }, + "publicIPDisabled": bool, + "secrets": {"str": {"type": "str", "value": "str"}}, + "subnetId": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @LoadTestAdministrationPreparer() + @recorded_by_proxy + def test_create_or_update_app_components(self, loadtestadministration_endpoint): + client = self.create_client(endpoint=loadtestadministration_endpoint) + response = client.create_or_update_app_components( + test_id="str", + body={ + "components": { + "str": { + "resourceId": "str", + "resourceName": "str", + "resourceType": "str", + "displayName": "str", + "kind": "str", + "resourceGroup": "str", + "subscriptionId": "str", + } + }, + "createdBy": "str", + "createdDateTime": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedDateTime": "2020-02-20 00:00:00", + "testId": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @LoadTestAdministrationPreparer() + @recorded_by_proxy + def test_create_or_update_server_metrics_config(self, loadtestadministration_endpoint): + client = self.create_client(endpoint=loadtestadministration_endpoint) + response = client.create_or_update_server_metrics_config( + test_id="str", + body={ + "metrics": { + "str": { + "aggregation": "str", + "metricNamespace": "str", + "name": "str", + "resourceId": "str", + "resourceType": "str", + "displayDescription": "str", + "id": "str", + "unit": "str", + } + }, + "createdBy": "str", + "createdDateTime": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedDateTime": "2020-02-20 00:00:00", + "testId": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @LoadTestAdministrationPreparer() + @recorded_by_proxy + def test_get_app_components(self, loadtestadministration_endpoint): + client = self.create_client(endpoint=loadtestadministration_endpoint) + response = client.get_app_components( + test_id="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestAdministrationPreparer() + @recorded_by_proxy + def test_get_server_metrics_config(self, loadtestadministration_endpoint): + client = self.create_client(endpoint=loadtestadministration_endpoint) + response = client.get_server_metrics_config( + test_id="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestAdministrationPreparer() + @recorded_by_proxy + def test_get_test(self, loadtestadministration_endpoint): + client = self.create_client(endpoint=loadtestadministration_endpoint) + response = client.get_test( + test_id="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestAdministrationPreparer() + @recorded_by_proxy + def test_get_test_file(self, loadtestadministration_endpoint): + client = self.create_client(endpoint=loadtestadministration_endpoint) + response = client.get_test_file( + test_id="str", + file_name="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestAdministrationPreparer() + @recorded_by_proxy + def test_list_test_files(self, loadtestadministration_endpoint): + client = self.create_client(endpoint=loadtestadministration_endpoint) + response = client.list_test_files( + test_id="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @LoadTestAdministrationPreparer() + @recorded_by_proxy + def test_list_tests(self, loadtestadministration_endpoint): + client = self.create_client(endpoint=loadtestadministration_endpoint) + response = client.list_tests() + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @LoadTestAdministrationPreparer() + @recorded_by_proxy + def test_delete_test_file(self, loadtestadministration_endpoint): + client = self.create_client(endpoint=loadtestadministration_endpoint) + response = client.delete_test_file( + test_id="str", + file_name="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestAdministrationPreparer() + @recorded_by_proxy + def test_delete_test(self, loadtestadministration_endpoint): + client = self.create_client(endpoint=loadtestadministration_endpoint) + response = client.delete_test( + test_id="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestAdministrationPreparer() + @recorded_by_proxy + def test_create_or_update_test_profile(self, loadtestadministration_endpoint): + client = self.create_client(endpoint=loadtestadministration_endpoint) + response = client.create_or_update_test_profile( + test_profile_id="str", + body={ + "testProfileId": "str", + "createdBy": "str", + "createdDateTime": "2020-02-20 00:00:00", + "description": "str", + "displayName": "str", + "lastModifiedBy": "str", + "lastModifiedDateTime": "2020-02-20 00:00:00", + "targetResourceConfigurations": "target_resource_configurations", + "targetResourceId": "str", + "testId": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @LoadTestAdministrationPreparer() + @recorded_by_proxy + def test_delete_test_profile(self, loadtestadministration_endpoint): + client = self.create_client(endpoint=loadtestadministration_endpoint) + response = client.delete_test_profile( + test_profile_id="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestAdministrationPreparer() + @recorded_by_proxy + def test_get_test_profile(self, loadtestadministration_endpoint): + client = self.create_client(endpoint=loadtestadministration_endpoint) + response = client.get_test_profile( + test_profile_id="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestAdministrationPreparer() + @recorded_by_proxy + def test_list_test_profiles(self, loadtestadministration_endpoint): + client = self.create_client(endpoint=loadtestadministration_endpoint) + response = client.list_test_profiles() + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_tests/test_load_test_administration_async.py b/sdk/loadtesting/azure-developer-loadtesting/generated_tests/test_load_test_administration_async.py new file mode 100644 index 000000000000..ee605480da90 --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_tests/test_load_test_administration_async.py @@ -0,0 +1,342 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from devtools_testutils.aio import recorded_by_proxy_async +from testpreparer import LoadTestAdministrationPreparer +from testpreparer_async import LoadTestAdministrationClientTestBaseAsync + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestLoadTestAdministrationAsync(LoadTestAdministrationClientTestBaseAsync): + @LoadTestAdministrationPreparer() + @recorded_by_proxy_async + async def test_create_or_update_test(self, loadtestadministration_endpoint): + client = self.create_async_client(endpoint=loadtestadministration_endpoint) + response = await client.create_or_update_test( + test_id="str", + body={ + "testId": "str", + "autoStopCriteria": {"autoStopDisabled": bool, "errorRate": 0.0, "errorRateTimeWindowInSeconds": 0}, + "baselineTestRunId": "str", + "certificate": {"name": "str", "type": "str", "value": "str"}, + "createdBy": "str", + "createdDateTime": "2020-02-20 00:00:00", + "description": "str", + "displayName": "str", + "engineBuiltInIdentityIds": ["str"], + "engineBuiltInIdentityType": "str", + "environmentVariables": {"str": "str"}, + "inputArtifacts": { + "additionalFileInfo": [ + { + "fileName": "str", + "expireDateTime": "2020-02-20 00:00:00", + "fileType": "str", + "url": "str", + "validationFailureDetails": "str", + "validationStatus": "str", + } + ], + "configFileInfo": { + "fileName": "str", + "expireDateTime": "2020-02-20 00:00:00", + "fileType": "str", + "url": "str", + "validationFailureDetails": "str", + "validationStatus": "str", + }, + "inputArtifactsZipFileInfo": { + "fileName": "str", + "expireDateTime": "2020-02-20 00:00:00", + "fileType": "str", + "url": "str", + "validationFailureDetails": "str", + "validationStatus": "str", + }, + "testScriptFileInfo": { + "fileName": "str", + "expireDateTime": "2020-02-20 00:00:00", + "fileType": "str", + "url": "str", + "validationFailureDetails": "str", + "validationStatus": "str", + }, + "urlTestConfigFileInfo": { + "fileName": "str", + "expireDateTime": "2020-02-20 00:00:00", + "fileType": "str", + "url": "str", + "validationFailureDetails": "str", + "validationStatus": "str", + }, + "userPropFileInfo": { + "fileName": "str", + "expireDateTime": "2020-02-20 00:00:00", + "fileType": "str", + "url": "str", + "validationFailureDetails": "str", + "validationStatus": "str", + }, + }, + "keyvaultReferenceIdentityId": "str", + "keyvaultReferenceIdentityType": "str", + "kind": "str", + "lastModifiedBy": "str", + "lastModifiedDateTime": "2020-02-20 00:00:00", + "loadTestConfiguration": { + "engineInstances": 0, + "optionalLoadTestConfig": { + "duration": 0, + "endpointUrl": "str", + "maxResponseTimeInMs": 0, + "rampUpTime": 0, + "requestsPerSecond": 0, + "virtualUsers": 0, + }, + "quickStartTest": bool, + "regionalLoadTestConfig": [{"engineInstances": 0, "region": "str"}], + "splitAllCSVs": bool, + }, + "metricsReferenceIdentityId": "str", + "metricsReferenceIdentityType": "str", + "passFailCriteria": { + "passFailMetrics": { + "str": { + "action": "str", + "actualValue": 0.0, + "aggregate": "str", + "clientMetric": "str", + "condition": "str", + "requestName": "str", + "result": "str", + "value": 0.0, + } + }, + "passFailServerMetrics": { + "str": { + "aggregation": "str", + "condition": "str", + "metricName": "str", + "metricNamespace": "str", + "resourceId": "str", + "value": 0.0, + "action": "str", + "actualValue": 0.0, + "result": "str", + } + }, + }, + "publicIPDisabled": bool, + "secrets": {"str": {"type": "str", "value": "str"}}, + "subnetId": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @LoadTestAdministrationPreparer() + @recorded_by_proxy_async + async def test_create_or_update_app_components(self, loadtestadministration_endpoint): + client = self.create_async_client(endpoint=loadtestadministration_endpoint) + response = await client.create_or_update_app_components( + test_id="str", + body={ + "components": { + "str": { + "resourceId": "str", + "resourceName": "str", + "resourceType": "str", + "displayName": "str", + "kind": "str", + "resourceGroup": "str", + "subscriptionId": "str", + } + }, + "createdBy": "str", + "createdDateTime": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedDateTime": "2020-02-20 00:00:00", + "testId": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @LoadTestAdministrationPreparer() + @recorded_by_proxy_async + async def test_create_or_update_server_metrics_config(self, loadtestadministration_endpoint): + client = self.create_async_client(endpoint=loadtestadministration_endpoint) + response = await client.create_or_update_server_metrics_config( + test_id="str", + body={ + "metrics": { + "str": { + "aggregation": "str", + "metricNamespace": "str", + "name": "str", + "resourceId": "str", + "resourceType": "str", + "displayDescription": "str", + "id": "str", + "unit": "str", + } + }, + "createdBy": "str", + "createdDateTime": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedDateTime": "2020-02-20 00:00:00", + "testId": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @LoadTestAdministrationPreparer() + @recorded_by_proxy_async + async def test_get_app_components(self, loadtestadministration_endpoint): + client = self.create_async_client(endpoint=loadtestadministration_endpoint) + response = await client.get_app_components( + test_id="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestAdministrationPreparer() + @recorded_by_proxy_async + async def test_get_server_metrics_config(self, loadtestadministration_endpoint): + client = self.create_async_client(endpoint=loadtestadministration_endpoint) + response = await client.get_server_metrics_config( + test_id="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestAdministrationPreparer() + @recorded_by_proxy_async + async def test_get_test(self, loadtestadministration_endpoint): + client = self.create_async_client(endpoint=loadtestadministration_endpoint) + response = await client.get_test( + test_id="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestAdministrationPreparer() + @recorded_by_proxy_async + async def test_get_test_file(self, loadtestadministration_endpoint): + client = self.create_async_client(endpoint=loadtestadministration_endpoint) + response = await client.get_test_file( + test_id="str", + file_name="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestAdministrationPreparer() + @recorded_by_proxy_async + async def test_list_test_files(self, loadtestadministration_endpoint): + client = self.create_async_client(endpoint=loadtestadministration_endpoint) + response = client.list_test_files( + test_id="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @LoadTestAdministrationPreparer() + @recorded_by_proxy_async + async def test_list_tests(self, loadtestadministration_endpoint): + client = self.create_async_client(endpoint=loadtestadministration_endpoint) + response = client.list_tests() + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @LoadTestAdministrationPreparer() + @recorded_by_proxy_async + async def test_delete_test_file(self, loadtestadministration_endpoint): + client = self.create_async_client(endpoint=loadtestadministration_endpoint) + response = await client.delete_test_file( + test_id="str", + file_name="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestAdministrationPreparer() + @recorded_by_proxy_async + async def test_delete_test(self, loadtestadministration_endpoint): + client = self.create_async_client(endpoint=loadtestadministration_endpoint) + response = await client.delete_test( + test_id="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestAdministrationPreparer() + @recorded_by_proxy_async + async def test_create_or_update_test_profile(self, loadtestadministration_endpoint): + client = self.create_async_client(endpoint=loadtestadministration_endpoint) + response = await client.create_or_update_test_profile( + test_profile_id="str", + body={ + "testProfileId": "str", + "createdBy": "str", + "createdDateTime": "2020-02-20 00:00:00", + "description": "str", + "displayName": "str", + "lastModifiedBy": "str", + "lastModifiedDateTime": "2020-02-20 00:00:00", + "targetResourceConfigurations": "target_resource_configurations", + "targetResourceId": "str", + "testId": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @LoadTestAdministrationPreparer() + @recorded_by_proxy_async + async def test_delete_test_profile(self, loadtestadministration_endpoint): + client = self.create_async_client(endpoint=loadtestadministration_endpoint) + response = await client.delete_test_profile( + test_profile_id="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestAdministrationPreparer() + @recorded_by_proxy_async + async def test_get_test_profile(self, loadtestadministration_endpoint): + client = self.create_async_client(endpoint=loadtestadministration_endpoint) + response = await client.get_test_profile( + test_profile_id="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestAdministrationPreparer() + @recorded_by_proxy_async + async def test_list_test_profiles(self, loadtestadministration_endpoint): + client = self.create_async_client(endpoint=loadtestadministration_endpoint) + response = client.list_test_profiles() + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_tests/test_load_test_run.py b/sdk/loadtesting/azure-developer-loadtesting/generated_tests/test_load_test_run.py new file mode 100644 index 000000000000..895274de2057 --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_tests/test_load_test_run.py @@ -0,0 +1,242 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from devtools_testutils import recorded_by_proxy +from testpreparer import LoadTestRunClientTestBase, LoadTestRunPreparer + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestLoadTestRun(LoadTestRunClientTestBase): + @LoadTestRunPreparer() + @recorded_by_proxy + def test_create_or_update_app_components(self, loadtestrun_endpoint): + client = self.create_client(endpoint=loadtestrun_endpoint) + response = client.create_or_update_app_components( + test_run_id="str", + body={ + "components": { + "str": { + "resourceId": "str", + "resourceName": "str", + "resourceType": "str", + "displayName": "str", + "kind": "str", + "resourceGroup": "str", + "subscriptionId": "str", + } + }, + "createdBy": "str", + "createdDateTime": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedDateTime": "2020-02-20 00:00:00", + "testRunId": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy + def test_create_or_update_server_metrics_config(self, loadtestrun_endpoint): + client = self.create_client(endpoint=loadtestrun_endpoint) + response = client.create_or_update_server_metrics_config( + test_run_id="str", + body={ + "createdBy": "str", + "createdDateTime": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedDateTime": "2020-02-20 00:00:00", + "metrics": { + "str": { + "aggregation": "str", + "metricNamespace": "str", + "name": "str", + "resourceId": "str", + "resourceType": "str", + "displayDescription": "str", + "id": "str", + "unit": "str", + } + }, + "testRunId": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy + def test_delete_test_run(self, loadtestrun_endpoint): + client = self.create_client(endpoint=loadtestrun_endpoint) + response = client.delete_test_run( + test_run_id="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy + def test_get_app_components(self, loadtestrun_endpoint): + client = self.create_client(endpoint=loadtestrun_endpoint) + response = client.get_app_components( + test_run_id="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy + def test_get_server_metrics_config(self, loadtestrun_endpoint): + client = self.create_client(endpoint=loadtestrun_endpoint) + response = client.get_server_metrics_config( + test_run_id="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy + def test_get_test_run(self, loadtestrun_endpoint): + client = self.create_client(endpoint=loadtestrun_endpoint) + response = client.get_test_run( + test_run_id="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy + def test_get_test_run_file(self, loadtestrun_endpoint): + client = self.create_client(endpoint=loadtestrun_endpoint) + response = client.get_test_run_file( + test_run_id="str", + file_name="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy + def test_list_metric_dimension_values(self, loadtestrun_endpoint): + client = self.create_client(endpoint=loadtestrun_endpoint) + response = client.list_metric_dimension_values( + test_run_id="str", + name="str", + metric_name="str", + metric_namespace="str", + time_interval="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy + def test_get_metric_definitions(self, loadtestrun_endpoint): + client = self.create_client(endpoint=loadtestrun_endpoint) + response = client.get_metric_definitions( + test_run_id="str", + metric_namespace="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy + def test_get_metric_namespaces(self, loadtestrun_endpoint): + client = self.create_client(endpoint=loadtestrun_endpoint) + response = client.get_metric_namespaces( + test_run_id="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy + def test_list_metrics(self, loadtestrun_endpoint): + client = self.create_client(endpoint=loadtestrun_endpoint) + response = client.list_metrics( + test_run_id="str", + metric_name="str", + metric_namespace="str", + time_interval="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy + def test_list_test_runs(self, loadtestrun_endpoint): + client = self.create_client(endpoint=loadtestrun_endpoint) + response = client.list_test_runs() + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy + def test_stop_test_run(self, loadtestrun_endpoint): + client = self.create_client(endpoint=loadtestrun_endpoint) + response = client.stop_test_run( + test_run_id="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy + def test_delete_test_profile_run(self, loadtestrun_endpoint): + client = self.create_client(endpoint=loadtestrun_endpoint) + response = client.delete_test_profile_run( + test_profile_run_id="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy + def test_get_test_profile_run(self, loadtestrun_endpoint): + client = self.create_client(endpoint=loadtestrun_endpoint) + response = client.get_test_profile_run( + test_profile_run_id="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy + def test_list_test_profile_runs(self, loadtestrun_endpoint): + client = self.create_client(endpoint=loadtestrun_endpoint) + response = client.list_test_profile_runs() + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy + def test_stop_test_profile_run(self, loadtestrun_endpoint): + client = self.create_client(endpoint=loadtestrun_endpoint) + response = client.stop_test_profile_run( + test_profile_run_id="str", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_tests/test_load_test_run_async.py b/sdk/loadtesting/azure-developer-loadtesting/generated_tests/test_load_test_run_async.py new file mode 100644 index 000000000000..963c78291566 --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_tests/test_load_test_run_async.py @@ -0,0 +1,243 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from devtools_testutils.aio import recorded_by_proxy_async +from testpreparer import LoadTestRunPreparer +from testpreparer_async import LoadTestRunClientTestBaseAsync + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestLoadTestRunAsync(LoadTestRunClientTestBaseAsync): + @LoadTestRunPreparer() + @recorded_by_proxy_async + async def test_create_or_update_app_components(self, loadtestrun_endpoint): + client = self.create_async_client(endpoint=loadtestrun_endpoint) + response = await client.create_or_update_app_components( + test_run_id="str", + body={ + "components": { + "str": { + "resourceId": "str", + "resourceName": "str", + "resourceType": "str", + "displayName": "str", + "kind": "str", + "resourceGroup": "str", + "subscriptionId": "str", + } + }, + "createdBy": "str", + "createdDateTime": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedDateTime": "2020-02-20 00:00:00", + "testRunId": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy_async + async def test_create_or_update_server_metrics_config(self, loadtestrun_endpoint): + client = self.create_async_client(endpoint=loadtestrun_endpoint) + response = await client.create_or_update_server_metrics_config( + test_run_id="str", + body={ + "createdBy": "str", + "createdDateTime": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedDateTime": "2020-02-20 00:00:00", + "metrics": { + "str": { + "aggregation": "str", + "metricNamespace": "str", + "name": "str", + "resourceId": "str", + "resourceType": "str", + "displayDescription": "str", + "id": "str", + "unit": "str", + } + }, + "testRunId": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy_async + async def test_delete_test_run(self, loadtestrun_endpoint): + client = self.create_async_client(endpoint=loadtestrun_endpoint) + response = await client.delete_test_run( + test_run_id="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy_async + async def test_get_app_components(self, loadtestrun_endpoint): + client = self.create_async_client(endpoint=loadtestrun_endpoint) + response = await client.get_app_components( + test_run_id="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy_async + async def test_get_server_metrics_config(self, loadtestrun_endpoint): + client = self.create_async_client(endpoint=loadtestrun_endpoint) + response = await client.get_server_metrics_config( + test_run_id="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy_async + async def test_get_test_run(self, loadtestrun_endpoint): + client = self.create_async_client(endpoint=loadtestrun_endpoint) + response = await client.get_test_run( + test_run_id="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy_async + async def test_get_test_run_file(self, loadtestrun_endpoint): + client = self.create_async_client(endpoint=loadtestrun_endpoint) + response = await client.get_test_run_file( + test_run_id="str", + file_name="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy_async + async def test_list_metric_dimension_values(self, loadtestrun_endpoint): + client = self.create_async_client(endpoint=loadtestrun_endpoint) + response = client.list_metric_dimension_values( + test_run_id="str", + name="str", + metric_name="str", + metric_namespace="str", + time_interval="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy_async + async def test_get_metric_definitions(self, loadtestrun_endpoint): + client = self.create_async_client(endpoint=loadtestrun_endpoint) + response = await client.get_metric_definitions( + test_run_id="str", + metric_namespace="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy_async + async def test_get_metric_namespaces(self, loadtestrun_endpoint): + client = self.create_async_client(endpoint=loadtestrun_endpoint) + response = await client.get_metric_namespaces( + test_run_id="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy_async + async def test_list_metrics(self, loadtestrun_endpoint): + client = self.create_async_client(endpoint=loadtestrun_endpoint) + response = client.list_metrics( + test_run_id="str", + metric_name="str", + metric_namespace="str", + time_interval="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy_async + async def test_list_test_runs(self, loadtestrun_endpoint): + client = self.create_async_client(endpoint=loadtestrun_endpoint) + response = client.list_test_runs() + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy_async + async def test_stop_test_run(self, loadtestrun_endpoint): + client = self.create_async_client(endpoint=loadtestrun_endpoint) + response = await client.stop_test_run( + test_run_id="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy_async + async def test_delete_test_profile_run(self, loadtestrun_endpoint): + client = self.create_async_client(endpoint=loadtestrun_endpoint) + response = await client.delete_test_profile_run( + test_profile_run_id="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy_async + async def test_get_test_profile_run(self, loadtestrun_endpoint): + client = self.create_async_client(endpoint=loadtestrun_endpoint) + response = await client.get_test_profile_run( + test_profile_run_id="str", + ) + + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy_async + async def test_list_test_profile_runs(self, loadtestrun_endpoint): + client = self.create_async_client(endpoint=loadtestrun_endpoint) + response = client.list_test_profile_runs() + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @LoadTestRunPreparer() + @recorded_by_proxy_async + async def test_stop_test_profile_run(self, loadtestrun_endpoint): + client = self.create_async_client(endpoint=loadtestrun_endpoint) + response = await client.stop_test_profile_run( + test_profile_run_id="str", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_tests/testpreparer.py b/sdk/loadtesting/azure-developer-loadtesting/generated_tests/testpreparer.py new file mode 100644 index 000000000000..d2a65a724bdf --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_tests/testpreparer.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from azure.developer.loadtesting import LoadTestAdministrationClient, LoadTestRunClient +from devtools_testutils import AzureRecordedTestCase, PowerShellPreparer +import functools + + +class LoadTestAdministrationClientTestBase(AzureRecordedTestCase): + + def create_client(self, endpoint): + credential = self.get_credential(LoadTestAdministrationClient) + return self.create_client_from_credential( + LoadTestAdministrationClient, + credential=credential, + endpoint=endpoint, + ) + + +LoadTestAdministrationPreparer = functools.partial( + PowerShellPreparer, + "loadtestadministration", + loadtestadministration_endpoint="https://fake_loadtestadministration_endpoint.com", +) + + +class LoadTestRunClientTestBase(AzureRecordedTestCase): + + def create_client(self, endpoint): + credential = self.get_credential(LoadTestRunClient) + return self.create_client_from_credential( + LoadTestRunClient, + credential=credential, + endpoint=endpoint, + ) + + +LoadTestRunPreparer = functools.partial( + PowerShellPreparer, "loadtestrun", loadtestrun_endpoint="https://fake_loadtestrun_endpoint.com" +) diff --git a/sdk/loadtesting/azure-developer-loadtesting/generated_tests/testpreparer_async.py b/sdk/loadtesting/azure-developer-loadtesting/generated_tests/testpreparer_async.py new file mode 100644 index 000000000000..a45d09fcf9b4 --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/generated_tests/testpreparer_async.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from azure.developer.loadtesting.aio import LoadTestAdministrationClient, LoadTestRunClient +from devtools_testutils import AzureRecordedTestCase + + +class LoadTestAdministrationClientTestBaseAsync(AzureRecordedTestCase): + + def create_async_client(self, endpoint): + credential = self.get_credential(LoadTestAdministrationClient, is_async=True) + return self.create_client_from_credential( + LoadTestAdministrationClient, + credential=credential, + endpoint=endpoint, + ) + + +class LoadTestRunClientTestBaseAsync(AzureRecordedTestCase): + + def create_async_client(self, endpoint): + credential = self.get_credential(LoadTestRunClient, is_async=True) + return self.create_client_from_credential( + LoadTestRunClient, + credential=credential, + endpoint=endpoint, + ) diff --git a/sdk/loadtesting/azure-developer-loadtesting/samples/create_or_update_app_components_test.py b/sdk/loadtesting/azure-developer-loadtesting/samples/create_or_update_app_components_test.py index 79adb48c202b..8cfc28a1de29 100644 --- a/sdk/loadtesting/azure-developer-loadtesting/samples/create_or_update_app_components_test.py +++ b/sdk/loadtesting/azure-developer-loadtesting/samples/create_or_update_app_components_test.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for diff --git a/sdk/loadtesting/azure-developer-loadtesting/samples/create_or_update_test.py b/sdk/loadtesting/azure-developer-loadtesting/samples/create_or_update_test.py index 36b793be030d..402294d5b89d 100644 --- a/sdk/loadtesting/azure-developer-loadtesting/samples/create_or_update_test.py +++ b/sdk/loadtesting/azure-developer-loadtesting/samples/create_or_update_test.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for diff --git a/sdk/loadtesting/azure-developer-loadtesting/samples/create_or_update_test_profile.py b/sdk/loadtesting/azure-developer-loadtesting/samples/create_or_update_test_profile.py index 6d19b26a3aca..b49976147e7c 100644 --- a/sdk/loadtesting/azure-developer-loadtesting/samples/create_or_update_test_profile.py +++ b/sdk/loadtesting/azure-developer-loadtesting/samples/create_or_update_test_profile.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -59,9 +60,9 @@ "config2": { "instanceMemoryMB": 4096, "httpConcurrency": 100, - } - } - } + }, + }, + }, }, ) diff --git a/sdk/loadtesting/azure-developer-loadtesting/samples/upload_test_file.py b/sdk/loadtesting/azure-developer-loadtesting/samples/upload_test_file.py index ed8380e6ca39..1c8c7fbe5d0e 100644 --- a/sdk/loadtesting/azure-developer-loadtesting/samples/upload_test_file.py +++ b/sdk/loadtesting/azure-developer-loadtesting/samples/upload_test_file.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for diff --git a/sdk/loadtesting/azure-developer-loadtesting/setup.py b/sdk/loadtesting/azure-developer-loadtesting/setup.py index 0d0752f9040b..1297cc5c96fd 100644 --- a/sdk/loadtesting/azure-developer-loadtesting/setup.py +++ b/sdk/loadtesting/azure-developer-loadtesting/setup.py @@ -5,7 +5,7 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -# coding: utf-8 + import os import re @@ -29,7 +29,7 @@ setup( name=PACKAGE_NAME, version=version, - description="Microsoft {} Client Library for Python".format(PACKAGE_PPRINT_NAME), + description="Microsoft Corporation {} Client Library for Python".format(PACKAGE_PPRINT_NAME), long_description=open("README.md", "r").read(), long_description_content_type="text/markdown", license="MIT License", @@ -42,7 +42,6 @@ "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -67,5 +66,5 @@ "azure-core>=1.30.0", "typing-extensions>=4.6.0", ], - python_requires=">=3.8", + python_requires=">=3.9", ) diff --git a/sdk/loadtesting/azure-developer-loadtesting/tests/test_async_load_test_administration_ops.py b/sdk/loadtesting/azure-developer-loadtesting/tests/test_async_load_test_administration_ops.py index 655cfce51f17..69232f7a0183 100644 --- a/sdk/loadtesting/azure-developer-loadtesting/tests/test_async_load_test_administration_ops.py +++ b/sdk/loadtesting/azure-developer-loadtesting/tests/test_async_load_test_administration_ops.py @@ -16,6 +16,7 @@ DISPLAY_NAME = "TestingResourcePyTest" + class TestLoadTestAdministrationOperations(LoadTestingAsyncTest): @LoadTestingPreparer() @@ -36,8 +37,18 @@ async def test_create_or_update_load_test(self, loadtesting_endpoint, loadtestin }, "passFailCriteria": { "passFailMetrics": { - "condition1": {"clientmetric": "response_time_ms", "aggregate": "avg", "condition": ">", "value": 300}, - "condition2": {"clientmetric": "error", "aggregate": "percentage", "condition": ">", "value": 50}, + "condition1": { + "clientmetric": "response_time_ms", + "aggregate": "avg", + "condition": ">", + "value": 300, + }, + "condition2": { + "clientmetric": "error", + "aggregate": "percentage", + "condition": ">", + "value": 50, + }, "condition3": { "clientmetric": "latency", "aggregate": "avg", @@ -49,7 +60,8 @@ async def test_create_or_update_load_test(self, loadtesting_endpoint, loadtestin }, "secrets": {}, "environmentVariables": {"my-variable": "value"}, - }) + }, + ) assert result is not None await self.close_admin_client() @@ -137,7 +149,7 @@ async def test_delete_test_file(self, loadtesting_endpoint, loadtesting_test_id) assert result is None await self.close_admin_client() - + @LoadTestingPreparer() @recorded_by_proxy_async @pytest.mark.asyncio @@ -230,6 +242,7 @@ async def test_delete_load_test(self, loadtesting_endpoint, loadtesting_test_id) await self.close_admin_client() + class TestTestProfileAdministrationOperations(LoadTestingAsyncTest): @LoadTestingPreparer() @@ -250,8 +263,18 @@ async def test_create_or_update_load_test(self, loadtesting_endpoint, loadtestin }, "passFailCriteria": { "passFailMetrics": { - "condition1": {"clientmetric": "response_time_ms", "aggregate": "avg", "condition": ">", "value": 300}, - "condition2": {"clientmetric": "error", "aggregate": "percentage", "condition": ">", "value": 50}, + "condition1": { + "clientmetric": "response_time_ms", + "aggregate": "avg", + "condition": ">", + "value": 300, + }, + "condition2": { + "clientmetric": "error", + "aggregate": "percentage", + "condition": ">", + "value": 50, + }, "condition3": { "clientmetric": "latency", "aggregate": "avg", @@ -263,7 +286,8 @@ async def test_create_or_update_load_test(self, loadtesting_endpoint, loadtestin }, "secrets": {}, "environmentVariables": {"my-variable": "value"}, - }) + }, + ) assert result is not None await self.close_admin_client() @@ -283,7 +307,9 @@ async def test_get_load_test(self, loadtesting_endpoint, loadtesting_test_id): @LoadTestingPreparer() @recorded_by_proxy_async @pytest.mark.asyncio - async def test_create_or_update_test_profile(self, loadtesting_endpoint, loadtesting_test_id, loadtesting_test_profile_id, loadtesting_target_resource_id): + async def test_create_or_update_test_profile( + self, loadtesting_endpoint, loadtesting_test_id, loadtesting_test_profile_id, loadtesting_target_resource_id + ): set_bodiless_matcher() client = self.create_administration_client(loadtesting_endpoint) @@ -297,16 +323,10 @@ async def test_create_or_update_test_profile(self, loadtesting_endpoint, loadtes "targetResourceConfigurations": { "kind": "FunctionsFlexConsumption", "configurations": { - "config1": { - "instanceMemoryMB": 2048, - "httpConcurrency": 20 - }, - "config2": { - "instanceMemoryMB": 4096, - "httpConcurrency": 100 - }, - } - } + "config1": {"instanceMemoryMB": 2048, "httpConcurrency": 20}, + "config2": {"instanceMemoryMB": 4096, "httpConcurrency": 100}, + }, + }, }, ) @@ -318,7 +338,7 @@ async def test_create_or_update_test_profile(self, loadtesting_endpoint, loadtes @pytest.mark.asyncio async def test_get_test_profile(self, loadtesting_endpoint, loadtesting_test_profile_id): set_bodiless_matcher() - + client = self.create_administration_client(loadtesting_endpoint) result = await client.get_test_profile(loadtesting_test_profile_id) assert result is not None @@ -330,7 +350,7 @@ async def test_get_test_profile(self, loadtesting_endpoint, loadtesting_test_pro @pytest.mark.asyncio async def test_list_test_profiles(self, loadtesting_endpoint): set_bodiless_matcher() - + client = self.create_administration_client(loadtesting_endpoint) result = client.list_test_profiles() assert result is not None diff --git a/sdk/loadtesting/azure-developer-loadtesting/tests/test_async_load_test_run_ops.py b/sdk/loadtesting/azure-developer-loadtesting/tests/test_async_load_test_run_ops.py index a35c670296df..c00da04555ee 100644 --- a/sdk/loadtesting/azure-developer-loadtesting/tests/test_async_load_test_run_ops.py +++ b/sdk/loadtesting/azure-developer-loadtesting/tests/test_async_load_test_run_ops.py @@ -17,6 +17,7 @@ DISPLAY_NAME = "TestingResourcePyTest" NON_EXISTING_RESOURCE = "nonexistingresource" + class TestLoadTestRunOperations(LoadTestingAsyncTest): # Pre-requisite: Test creation is needed for test run related tests @@ -37,8 +38,18 @@ async def test_create_or_update_load_test(self, loadtesting_endpoint, loadtestin }, "passFailCriteria": { "passFailMetrics": { - "condition1": {"clientmetric": "response_time_ms", "aggregate": "avg", "condition": ">", "value": 300}, - "condition2": {"clientmetric": "error", "aggregate": "percentage", "condition": ">", "value": 50}, + "condition1": { + "clientmetric": "response_time_ms", + "aggregate": "avg", + "condition": ">", + "value": 300, + }, + "condition2": { + "clientmetric": "error", + "aggregate": "percentage", + "condition": ">", + "value": 50, + }, "condition3": { "clientmetric": "latency", "aggregate": "avg", @@ -50,7 +61,8 @@ async def test_create_or_update_load_test(self, loadtesting_endpoint, loadtestin }, "secrets": {}, "environmentVariables": {"my-variable": "value"}, - }) + }, + ) assert result is not None @@ -66,7 +78,7 @@ async def test_get_load_test(self, loadtesting_endpoint, loadtesting_test_id): assert result is not None await self.close_admin_client() - + @LoadTestingPreparer() @recorded_by_proxy_async async def test_upload_test_file(self, loadtesting_endpoint, loadtesting_test_id): @@ -154,7 +166,7 @@ async def test_list_test_runs(self, loadtesting_endpoint): result = run_client.list_test_runs() assert result is not None items = [item async for item in result] - assert len(items) > 0 # Atleast one item in the page + assert len(items) > 0 # Atleast one item in the page await self.close_run_client() @@ -217,9 +229,7 @@ async def test_create_or_update_app_component( @LoadTestingPreparer() @recorded_by_proxy_async - async def test_get_app_component( - self, loadtesting_endpoint, loadtesting_test_run_id - ): + async def test_get_app_component(self, loadtesting_endpoint, loadtesting_test_run_id): set_bodiless_matcher() run_client = self.create_run_client(loadtesting_endpoint) @@ -260,9 +270,7 @@ async def test_create_or_update_server_metrics_config( @LoadTestingPreparer() @recorded_by_proxy_async - async def test_get_server_metrics_config( - self, loadtesting_endpoint, loadtesting_test_run_id - ): + async def test_get_server_metrics_config(self, loadtesting_endpoint, loadtesting_test_run_id): set_bodiless_matcher() run_client = self.create_run_client(loadtesting_endpoint) @@ -302,7 +310,7 @@ async def test_delete_test_run(self, loadtesting_endpoint, loadtesting_test_run_ assert result is None await self.close_run_client() - + @LoadTestingPreparer() @recorded_by_proxy_async async def test_delete_test(self, loadtesting_endpoint, loadtesting_test_id): @@ -315,6 +323,7 @@ async def test_delete_test(self, loadtesting_endpoint, loadtesting_test_id): await self.close_admin_client() + class TestTestProfileRunOperations(LoadTestingAsyncTest): # Pre-requisite: Test & Test Profile creation is needed for test profile run related tests @@ -335,8 +344,18 @@ async def test_create_or_update_load_test(self, loadtesting_endpoint, loadtestin }, "passFailCriteria": { "passFailMetrics": { - "condition1": {"clientmetric": "response_time_ms", "aggregate": "avg", "condition": ">", "value": 300}, - "condition2": {"clientmetric": "error", "aggregate": "percentage", "condition": ">", "value": 50}, + "condition1": { + "clientmetric": "response_time_ms", + "aggregate": "avg", + "condition": ">", + "value": 300, + }, + "condition2": { + "clientmetric": "error", + "aggregate": "percentage", + "condition": ">", + "value": 50, + }, "condition3": { "clientmetric": "latency", "aggregate": "avg", @@ -398,7 +417,9 @@ async def test_get_test_file(self, loadtesting_endpoint, loadtesting_test_id): @LoadTestingPreparer() @recorded_by_proxy_async - async def test_create_or_update_test_profile(self, loadtesting_endpoint, loadtesting_test_id, loadtesting_test_profile_id, loadtesting_target_resource_id): + async def test_create_or_update_test_profile( + self, loadtesting_endpoint, loadtesting_test_id, loadtesting_test_profile_id, loadtesting_target_resource_id + ): set_bodiless_matcher() client = self.create_administration_client(loadtesting_endpoint) @@ -412,16 +433,10 @@ async def test_create_or_update_test_profile(self, loadtesting_endpoint, loadtes "targetResourceConfigurations": { "kind": "FunctionsFlexConsumption", "configurations": { - "config1": { - "instanceMemoryMB": 2048, - "httpConcurrency": 20 - }, - "config2": { - "instanceMemoryMB": 4096, - "httpConcurrency": 100 - }, - } - } + "config1": {"instanceMemoryMB": 2048, "httpConcurrency": 20}, + "config2": {"instanceMemoryMB": 4096, "httpConcurrency": 100}, + }, + }, }, ) assert result is not None @@ -441,7 +456,9 @@ async def test_get_test_profile(self, loadtesting_endpoint, loadtesting_test_pro @LoadTestingPreparer() @recorded_by_proxy_async - async def test_begin_test_profile_run(self, loadtesting_endpoint, loadtesting_test_profile_id, loadtesting_test_profile_run_id): + async def test_begin_test_profile_run( + self, loadtesting_endpoint, loadtesting_test_profile_id, loadtesting_test_profile_run_id + ): set_bodiless_matcher() run_client = self.create_run_client(loadtesting_endpoint) diff --git a/sdk/loadtesting/azure-developer-loadtesting/tests/test_load_test_administration_ops.py b/sdk/loadtesting/azure-developer-loadtesting/tests/test_load_test_administration_ops.py index 22b217d8200e..25ee309e1019 100644 --- a/sdk/loadtesting/azure-developer-loadtesting/tests/test_load_test_administration_ops.py +++ b/sdk/loadtesting/azure-developer-loadtesting/tests/test_load_test_administration_ops.py @@ -14,6 +14,7 @@ DISPLAY_NAME = "TestingResourcePyTest" + class TestLoadTestAdministrationOperations(LoadTestingTest): @LoadTestingPreparer() @@ -33,8 +34,18 @@ def test_create_or_update_load_test(self, loadtesting_endpoint, loadtesting_test }, "passFailCriteria": { "passFailMetrics": { - "condition1": {"clientmetric": "response_time_ms", "aggregate": "avg", "condition": ">", "value": 300}, - "condition2": {"clientmetric": "error", "aggregate": "percentage", "condition": ">", "value": 50}, + "condition1": { + "clientmetric": "response_time_ms", + "aggregate": "avg", + "condition": ">", + "value": 300, + }, + "condition2": { + "clientmetric": "error", + "aggregate": "percentage", + "condition": ">", + "value": 50, + }, "condition3": { "clientmetric": "latency", "aggregate": "avg", @@ -46,7 +57,8 @@ def test_create_or_update_load_test(self, loadtesting_endpoint, loadtesting_test }, "secrets": {}, "environmentVariables": {"my-variable": "value"}, - }) + }, + ) assert result is not None @@ -110,7 +122,8 @@ def list_test_files(self, loadtesting_endpoint, loadtesting_test_id): @LoadTestingPreparer() @recorded_by_proxy def test_create_or_update_app_components( - self, loadtesting_endpoint, loadtesting_test_id, loadtesting_app_component_id): + self, loadtesting_endpoint, loadtesting_test_id, loadtesting_app_component_id + ): set_bodiless_matcher() client = self.create_administration_client(loadtesting_endpoint) @@ -181,7 +194,7 @@ def test_delete_test_file(self, loadtesting_endpoint, loadtesting_test_id): client = self.create_administration_client(loadtesting_endpoint) result = client.delete_test_file(loadtesting_test_id, "sample.jmx") assert result is None - + @LoadTestingPreparer() @recorded_by_proxy def test_delete_load_test(self, loadtesting_endpoint, loadtesting_test_id): @@ -191,6 +204,7 @@ def test_delete_load_test(self, loadtesting_endpoint, loadtesting_test_id): result = client.delete_test(loadtesting_test_id) assert result is None + class TestTestProfileAdministrationOperations(LoadTestingTest): # Pre-requisite: Test creation is needed for test profile related tests @@ -211,8 +225,18 @@ def test_create_or_update_load_test(self, loadtesting_endpoint, loadtesting_test }, "passFailCriteria": { "passFailMetrics": { - "condition1": {"clientmetric": "response_time_ms", "aggregate": "avg", "condition": ">", "value": 300}, - "condition2": {"clientmetric": "error", "aggregate": "percentage", "condition": ">", "value": 50}, + "condition1": { + "clientmetric": "response_time_ms", + "aggregate": "avg", + "condition": ">", + "value": 300, + }, + "condition2": { + "clientmetric": "error", + "aggregate": "percentage", + "condition": ">", + "value": 50, + }, "condition3": { "clientmetric": "latency", "aggregate": "avg", @@ -224,7 +248,8 @@ def test_create_or_update_load_test(self, loadtesting_endpoint, loadtesting_test }, "secrets": {}, "environmentVariables": {"my-variable": "value"}, - }) + }, + ) assert result is not None @@ -239,7 +264,9 @@ def test_get_load_test(self, loadtesting_endpoint, loadtesting_test_id): @LoadTestingPreparer() @recorded_by_proxy - def test_create_or_update_test_profile(self, loadtesting_endpoint, loadtesting_test_id, loadtesting_test_profile_id, loadtesting_target_resource_id): + def test_create_or_update_test_profile( + self, loadtesting_endpoint, loadtesting_test_id, loadtesting_test_profile_id, loadtesting_target_resource_id + ): set_bodiless_matcher() client = self.create_administration_client(loadtesting_endpoint) @@ -253,20 +280,14 @@ def test_create_or_update_test_profile(self, loadtesting_endpoint, loadtesting_t "targetResourceConfigurations": { "kind": "FunctionsFlexConsumption", "configurations": { - "config1": { - "instanceMemoryMB": 2048, - "httpConcurrency": 20 - }, - "config2": { - "instanceMemoryMB": 4096, - "httpConcurrency": 100 - }, - } - } + "config1": {"instanceMemoryMB": 2048, "httpConcurrency": 20}, + "config2": {"instanceMemoryMB": 4096, "httpConcurrency": 100}, + }, + }, }, ) assert result is not None - + @LoadTestingPreparer() @recorded_by_proxy def test_get_test_profile(self, loadtesting_endpoint, loadtesting_test_profile_id): @@ -286,7 +307,7 @@ def test_list_test_profiles(self, loadtesting_endpoint): assert result is not None items = [r for r in result] assert len(items) > 0 # page has atleast one item - + @LoadTestingPreparer() @recorded_by_proxy def test_delete_test_profile(self, loadtesting_endpoint, loadtesting_test_profile_id): diff --git a/sdk/loadtesting/azure-developer-loadtesting/tests/test_load_test_run_ops.py b/sdk/loadtesting/azure-developer-loadtesting/tests/test_load_test_run_ops.py index be5b5d5efa29..ab60ea9c712b 100644 --- a/sdk/loadtesting/azure-developer-loadtesting/tests/test_load_test_run_ops.py +++ b/sdk/loadtesting/azure-developer-loadtesting/tests/test_load_test_run_ops.py @@ -35,8 +35,18 @@ def test_create_or_update_load_test(self, loadtesting_endpoint, loadtesting_test }, "passFailCriteria": { "passFailMetrics": { - "condition1": {"clientmetric": "response_time_ms", "aggregate": "avg", "condition": ">", "value": 300}, - "condition2": {"clientmetric": "error", "aggregate": "percentage", "condition": ">", "value": 50}, + "condition1": { + "clientmetric": "response_time_ms", + "aggregate": "avg", + "condition": ">", + "value": 300, + }, + "condition2": { + "clientmetric": "error", + "aggregate": "percentage", + "condition": ">", + "value": 50, + }, "condition3": { "clientmetric": "latency", "aggregate": "avg", @@ -48,7 +58,8 @@ def test_create_or_update_load_test(self, loadtesting_endpoint, loadtesting_test }, "secrets": {}, "environmentVariables": {"my-variable": "value"}, - }) + }, + ) assert result is not None @@ -60,7 +71,7 @@ def test_get_load_test(self, loadtesting_endpoint, loadtesting_test_id): client = self.create_administration_client(loadtesting_endpoint) result = client.get_test(loadtesting_test_id) assert result is not None - + @LoadTestingPreparer() @recorded_by_proxy def test_upload_test_file(self, loadtesting_endpoint, loadtesting_test_id): @@ -138,7 +149,7 @@ def test_list_test_runs(self, loadtesting_endpoint, loadtesting_test_id, loadtes result = run_client.list_test_runs() assert result is not None items = [item for item in result] - assert len(items) > 0 # Atleast one item in the page + assert len(items) > 0 # Atleast one item in the page @LoadTestingPreparer() @recorded_by_proxy @@ -195,9 +206,7 @@ def test_create_or_update_app_component( @LoadTestingPreparer() @recorded_by_proxy - def test_get_app_component( - self, loadtesting_endpoint, loadtesting_test_run_id - ): + def test_get_app_component(self, loadtesting_endpoint, loadtesting_test_run_id): set_bodiless_matcher() run_client = self.create_run_client(loadtesting_endpoint) @@ -234,9 +243,7 @@ def test_create_or_update_server_metrics_config( @LoadTestingPreparer() @recorded_by_proxy - def test_get_server_metrics_config( - self, loadtesting_endpoint, loadtesting_test_run_id - ): + def test_get_server_metrics_config(self, loadtesting_endpoint, loadtesting_test_run_id): set_bodiless_matcher() run_client = self.create_run_client(loadtesting_endpoint) @@ -275,7 +282,7 @@ def test_delete_test_run(self, loadtesting_endpoint, loadtesting_test_run_id): result = run_client.delete_test_run(loadtesting_test_run_id) assert result is None - + @LoadTestingPreparer() @recorded_by_proxy def test_delete_test(self, loadtesting_endpoint, loadtesting_test_id): @@ -286,6 +293,7 @@ def test_delete_test(self, loadtesting_endpoint, loadtesting_test_id): result = client.delete_test(loadtesting_test_id) assert result is None + class TestTestProfileRunOperations(LoadTestingTest): # Pre-requisite: Test & Test Profile creation is needed for test profile run related tests @@ -306,8 +314,18 @@ def test_create_or_update_load_test(self, loadtesting_endpoint, loadtesting_test }, "passFailCriteria": { "passFailMetrics": { - "condition1": {"clientmetric": "response_time_ms", "aggregate": "avg", "condition": ">", "value": 300}, - "condition2": {"clientmetric": "error", "aggregate": "percentage", "condition": ">", "value": 50}, + "condition1": { + "clientmetric": "response_time_ms", + "aggregate": "avg", + "condition": ">", + "value": 300, + }, + "condition2": { + "clientmetric": "error", + "aggregate": "percentage", + "condition": ">", + "value": 50, + }, "condition3": { "clientmetric": "latency", "aggregate": "avg", @@ -319,7 +337,8 @@ def test_create_or_update_load_test(self, loadtesting_endpoint, loadtesting_test }, "secrets": {}, "environmentVariables": {"my-variable": "value"}, - }) + }, + ) assert result is not None @@ -331,7 +350,7 @@ def test_get_load_test(self, loadtesting_endpoint, loadtesting_test_id): client = self.create_administration_client(loadtesting_endpoint) result = client.get_test(loadtesting_test_id) assert result is not None - + @LoadTestingPreparer() @recorded_by_proxy def test_upload_test_file(self, loadtesting_endpoint, loadtesting_test_id): @@ -360,7 +379,9 @@ def test_get_test_file(self, loadtesting_endpoint, loadtesting_test_id): @LoadTestingPreparer() @recorded_by_proxy - def test_create_or_update_test_profile(self, loadtesting_endpoint, loadtesting_test_id, loadtesting_test_profile_id, loadtesting_target_resource_id): + def test_create_or_update_test_profile( + self, loadtesting_endpoint, loadtesting_test_id, loadtesting_test_profile_id, loadtesting_target_resource_id + ): set_bodiless_matcher() client = self.create_administration_client(loadtesting_endpoint) @@ -374,20 +395,14 @@ def test_create_or_update_test_profile(self, loadtesting_endpoint, loadtesting_t "targetResourceConfigurations": { "kind": "FunctionsFlexConsumption", "configurations": { - "config1": { - "instanceMemoryMB": 2048, - "httpConcurrency": 20 - }, - "config2": { - "instanceMemoryMB": 4096, - "httpConcurrency": 100 - }, - } - } + "config1": {"instanceMemoryMB": 2048, "httpConcurrency": 20}, + "config2": {"instanceMemoryMB": 4096, "httpConcurrency": 100}, + }, + }, }, ) assert result is not None - + @LoadTestingPreparer() @recorded_by_proxy def test_get_test_profile(self, loadtesting_endpoint, loadtesting_test_profile_id): @@ -399,7 +414,9 @@ def test_get_test_profile(self, loadtesting_endpoint, loadtesting_test_profile_i @LoadTestingPreparer() @recorded_by_proxy - def test_begin_test_profile_run(self, loadtesting_endpoint, loadtesting_test_profile_id, loadtesting_test_profile_run_id): + def test_begin_test_profile_run( + self, loadtesting_endpoint, loadtesting_test_profile_id, loadtesting_test_profile_run_id + ): set_bodiless_matcher() run_client = self.create_run_client(loadtesting_endpoint) @@ -428,7 +445,7 @@ def test_get_test_profile_run(self, loadtesting_endpoint, loadtesting_test_profi result = run_client.get_test_profile_run(loadtesting_test_profile_run_id) assert result is not None assert len(result["recommendations"]) > 0 - + @LoadTestingPreparer() @recorded_by_proxy def test_stop_test_profile_run(self, loadtesting_endpoint, loadtesting_test_profile_id): @@ -460,7 +477,7 @@ def test_delete_test_profile_run(self, loadtesting_endpoint, loadtesting_test_pr result = run_client.delete_test_profile_run(loadtesting_test_profile_run_id) assert result is None - + @LoadTestingPreparer() @recorded_by_proxy def test_delete_test_profile(self, loadtesting_endpoint, loadtesting_test_profile_id): diff --git a/sdk/loadtesting/azure-developer-loadtesting/tests/testcase.py b/sdk/loadtesting/azure-developer-loadtesting/tests/testcase.py index 08c5ecb92644..df4dc143934d 100644 --- a/sdk/loadtesting/azure-developer-loadtesting/tests/testcase.py +++ b/sdk/loadtesting/azure-developer-loadtesting/tests/testcase.py @@ -38,5 +38,5 @@ def create_run_client(self, endpoint) -> LoadTestRunClient: loadtesting_app_component_id="/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRG/providers/Microsoft.Web/sites/contoso-sampleapp", loadtesting_test_profile_id="some-test-profile-id", loadtesting_target_resource_id="/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRG/providers/Microsoft.Web/sites/myFlexFunction", - loadtesting_test_profile_run_id="some-test-profile-run-id" + loadtesting_test_profile_run_id="some-test-profile-run-id", ) diff --git a/sdk/loadtesting/azure-developer-loadtesting/tests/testcase_async.py b/sdk/loadtesting/azure-developer-loadtesting/tests/testcase_async.py index e7ad3bfcd12c..7e256725c64a 100644 --- a/sdk/loadtesting/azure-developer-loadtesting/tests/testcase_async.py +++ b/sdk/loadtesting/azure-developer-loadtesting/tests/testcase_async.py @@ -16,7 +16,7 @@ def create_administration_client(self, endpoint) -> LoadTestAdministrationClient credential=self.admin_credential, endpoint=endpoint, ) - + return self.admin_client def create_run_client(self, endpoint) -> LoadTestRunClient: @@ -28,11 +28,11 @@ def create_run_client(self, endpoint) -> LoadTestRunClient: ) return self.run_client - + async def close_admin_client(self): await self.admin_credential.close() await self.admin_client.close() - + async def close_run_client(self): await self.run_credential.close() await self.run_client.close() diff --git a/sdk/loadtesting/azure-developer-loadtesting/tsp-location.yaml b/sdk/loadtesting/azure-developer-loadtesting/tsp-location.yaml index f862b18befa1..a1b082c49865 100644 --- a/sdk/loadtesting/azure-developer-loadtesting/tsp-location.yaml +++ b/sdk/loadtesting/azure-developer-loadtesting/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/loadtestservice/LoadTestService -commit: 3582fd3aac7f024efda7e439acd84a83fc5ad3df +commit: f0143019cfea40b0257f746a6d512a83774e375e repo: Azure/azure-rest-api-specs additionalDirectories: