From 8cd80a10edae01c0c61393759bdd2d5f184ac0dd Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 22 Apr 2025 16:38:23 +0000 Subject: [PATCH] CodeGen from PR 34130 in Azure/azure-rest-api-specs Merge 9d6c37392421ceb30ec967dacc2f75cb6cc7ae2c into 7a6eb294ffc666ec4f68c2e78d48a6d9f79dbc51 --- .../azure-developer-loadtesting/MANIFEST.in | 2 +- .../azure-developer-loadtesting/_meta.json | 6 + .../apiview-properties.json | 101 ++++ .../azure/developer/loadtesting/_client.py | 2 + .../developer/loadtesting/_model_base.py | 27 +- .../loadtesting/_operations/_operations.py | 22 +- .../loadtesting/_operations/_patch.py | 494 +---------------- .../azure/developer/loadtesting/_patch.py | 9 +- .../developer/loadtesting/_serialization.py | 26 +- .../azure/developer/loadtesting/_version.py | 2 +- .../developer/loadtesting/aio/_client.py | 2 + .../aio/_operations/_operations.py | 22 +- .../loadtesting/aio/_operations/_patch.py | 498 +----------------- .../azure/developer/loadtesting/aio/_patch.py | 9 +- .../developer/loadtesting/models/_models.py | 2 + .../developer/loadtesting/models/_patch.py | 9 +- .../create_or_update_app_components_test.py | 1 + .../samples/create_or_update_test.py | 1 + .../samples/create_or_update_test_profile.py | 7 +- .../samples/upload_test_file.py | 1 + .../azure-developer-loadtesting/setup.py | 7 +- ...test_async_load_test_administration_ops.py | 60 ++- .../tests/test_async_load_test_run_ops.py | 69 ++- .../test_load_test_administration_ops.py | 63 ++- .../tests/test_load_test_run_ops.py | 79 +-- .../tests/testcase.py | 2 +- .../tests/testcase_async.py | 6 +- .../tsp-location.yaml | 2 +- 28 files changed, 366 insertions(+), 1165 deletions(-) create mode 100644 sdk/loadtesting/azure-developer-loadtesting/_meta.json create mode 100644 sdk/loadtesting/azure-developer-loadtesting/apiview-properties.json 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..43970329080d --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/_meta.json @@ -0,0 +1,6 @@ +{ + "commit": "89202a3ec68b588a14bda647fee7cd34fca46977", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "typespec_src": "specification/loadtestservice/LoadTestService", + "@azure-tools/typespec-python": "0.43.0" +} \ 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..a3541fc179a4 --- /dev/null +++ b/sdk/loadtesting/azure-developer-loadtesting/apiview-properties.json @@ -0,0 +1,101 @@ +{ + "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.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.LoadTestAdministrationClient.get_app_components": "Customizations.AdministrationOperations.getAppComponents", + "azure.developer.loadtesting.LoadTestAdministrationClient.get_server_metrics_config": "Customizations.AdministrationOperations.getServerMetricsConfig", + "azure.developer.loadtesting.LoadTestAdministrationClient.get_test": "Customizations.AdministrationOperations.getTest", + "azure.developer.loadtesting.LoadTestAdministrationClient.get_test_file": "Customizations.AdministrationOperations.getTestFile", + "azure.developer.loadtesting.LoadTestAdministrationClient.list_test_files": "Customizations.AdministrationOperations.listTestFiles", + "azure.developer.loadtesting.LoadTestAdministrationClient.list_tests": "Customizations.AdministrationOperations.listTests", + "azure.developer.loadtesting.LoadTestAdministrationClient.delete_test_file": "Customizations.AdministrationOperations.deleteTestFile", + "azure.developer.loadtesting.LoadTestAdministrationClient.delete_test": "Customizations.AdministrationOperations.deleteTest", + "azure.developer.loadtesting.LoadTestAdministrationClient.create_or_update_test_profile": "Customizations.AdministrationOperations.createOrUpdateTestProfile", + "azure.developer.loadtesting.LoadTestAdministrationClient.delete_test_profile": "Customizations.AdministrationOperations.deleteTestProfile", + "azure.developer.loadtesting.LoadTestAdministrationClient.get_test_profile": "Customizations.AdministrationOperations.getTestProfile", + "azure.developer.loadtesting.LoadTestAdministrationClient.list_test_profiles": "Customizations.AdministrationOperations.listTestProfiles", + "azure.developer.loadtesting.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.LoadTestRunClient.delete_test_run": "Customizations.TestRunOperations.deleteTestRun", + "azure.developer.loadtesting.LoadTestRunClient.get_app_components": "Customizations.TestRunOperations.getAppComponents", + "azure.developer.loadtesting.LoadTestRunClient.get_server_metrics_config": "Customizations.TestRunOperations.getServerMetricsConfig", + "azure.developer.loadtesting.LoadTestRunClient.get_test_run": "Customizations.TestRunOperations.getTestRun", + "azure.developer.loadtesting.LoadTestRunClient.get_test_run_file": "Customizations.TestRunOperations.getTestRunFile", + "azure.developer.loadtesting.LoadTestRunClient.list_metric_dimension_values": "Customizations.TestRunOperations.listMetricDimensionValues", + "azure.developer.loadtesting.LoadTestRunClient.get_metric_definitions": "Customizations.TestRunOperations.listMetricDefinitions", + "azure.developer.loadtesting.LoadTestRunClient.get_metric_namespaces": "Customizations.TestRunOperations.listMetricNamespaces", + "azure.developer.loadtesting.LoadTestRunClient.list_metrics": "Customizations.TestRunOperations.listMetrics", + "azure.developer.loadtesting.LoadTestRunClient.list_test_runs": "Customizations.TestRunOperations.listTestRuns", + "azure.developer.loadtesting.LoadTestRunClient.stop_test_run": "Customizations.TestRunOperations.stop", + "azure.developer.loadtesting.LoadTestRunClient.delete_test_profile_run": "Customizations.TestRunOperations.deleteTestProfileRun", + "azure.developer.loadtesting.LoadTestRunClient.get_test_profile_run": "Customizations.TestRunOperations.getTestProfileRun", + "azure.developer.loadtesting.LoadTestRunClient.list_test_profile_runs": "Customizations.TestRunOperations.listTestProfileRuns", + "azure.developer.loadtesting.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..fd8d32564d0d 100644 --- a/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_client.py +++ b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_client.py @@ -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/_model_base.py b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_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/_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/_operations/_operations.py b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_operations/_operations.py index 2e86f4dbdb46..15d8d335bfc5 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,10 +6,10 @@ # 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 @@ -35,11 +35,7 @@ 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]] @@ -1851,7 +1847,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 +1956,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 +2552,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) @@ -3399,7 +3395,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 +3784,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) @@ -3903,7 +3899,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 +4341,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/_serialization.py b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/_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/_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/_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..7d6eb0e8db07 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 @@ -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..5ec21f5846f0 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,10 +6,10 @@ # 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 @@ -72,11 +72,7 @@ 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, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -842,7 +838,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 +947,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 +1540,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) @@ -2387,7 +2383,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 +2776,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) @@ -2895,7 +2891,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 +3332,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/models/_models.py b/sdk/loadtesting/azure-developer-loadtesting/azure/developer/loadtesting/models/_models.py index 32acdef7a137..9f35f29b0c8e 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 @@ -893,6 +893,7 @@ class PassFailMetric(_model_base.Model): 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 +925,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\", 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/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..73dec75de8e1 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: 89202a3ec68b588a14bda647fee7cd34fca46977 repo: Azure/azure-rest-api-specs additionalDirectories: