azure-developer-loadtesting 1.0.0__zip

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. azure-developer-loadtesting-1.0.0/CHANGELOG.md +72 -0
  2. azure-developer-loadtesting-1.0.0/LICENSE +21 -0
  3. azure-developer-loadtesting-1.0.0/MANIFEST.in +7 -0
  4. azure-developer-loadtesting-1.0.0/PKG-INFO +281 -0
  5. azure-developer-loadtesting-1.0.0/README.md +258 -0
  6. azure-developer-loadtesting-1.0.0/azure/__init__.py +1 -0
  7. azure-developer-loadtesting-1.0.0/azure/developer/__init__.py +1 -0
  8. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/__init__.py +10 -0
  9. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_client.py +97 -0
  10. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/__init__.py +26 -0
  11. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/_client.py +88 -0
  12. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/_configuration.py +71 -0
  13. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/_patch.py +24 -0
  14. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/_serialization.py +1996 -0
  15. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/_vendor.py +20 -0
  16. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/_version.py +9 -0
  17. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/aio/__init__.py +23 -0
  18. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/aio/_client.py +88 -0
  19. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/aio/_configuration.py +71 -0
  20. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/aio/_patch.py +23 -0
  21. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/aio/_vendor.py +17 -0
  22. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/aio/operations/__init__.py +21 -0
  23. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/aio/operations/_operations.py +6517 -0
  24. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/aio/operations/_patch.py +187 -0
  25. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/operations/__init__.py +21 -0
  26. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/operations/_operations.py +7242 -0
  27. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/operations/_patch.py +195 -0
  28. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_version.py +6 -0
  29. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/aio/__init__.py +9 -0
  30. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/aio/_client.py +107 -0
  31. azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/py.typed +1 -0
  32. azure-developer-loadtesting-1.0.0/azure_developer_loadtesting.egg-info/PKG-INFO +281 -0
  33. azure-developer-loadtesting-1.0.0/azure_developer_loadtesting.egg-info/SOURCES.txt +52 -0
  34. azure-developer-loadtesting-1.0.0/azure_developer_loadtesting.egg-info/dependency_links.txt +1 -0
  35. azure-developer-loadtesting-1.0.0/azure_developer_loadtesting.egg-info/not-zip-safe +1 -0
  36. azure-developer-loadtesting-1.0.0/azure_developer_loadtesting.egg-info/requires.txt +5 -0
  37. azure-developer-loadtesting-1.0.0/azure_developer_loadtesting.egg-info/top_level.txt +1 -0
  38. azure-developer-loadtesting-1.0.0/pyproject.toml +6 -0
  39. azure-developer-loadtesting-1.0.0/samples/begin_test_run.py +52 -0
  40. azure-developer-loadtesting-1.0.0/samples/create_or_update_app_components.py +57 -0
  41. azure-developer-loadtesting-1.0.0/samples/create_or_update_test_function.py +84 -0
  42. azure-developer-loadtesting-1.0.0/samples/delete_load_test_function.py +46 -0
  43. azure-developer-loadtesting-1.0.0/samples/delete_load_test_run.py +39 -0
  44. azure-developer-loadtesting-1.0.0/samples/get_metrics.py +64 -0
  45. azure-developer-loadtesting-1.0.0/samples/upload_test_file.py +45 -0
  46. azure-developer-loadtesting-1.0.0/setup.cfg +4 -0
  47. azure-developer-loadtesting-1.0.0/setup.py +71 -0
  48. azure-developer-loadtesting-1.0.0/tests/conftest.py +60 -0
  49. azure-developer-loadtesting-1.0.0/tests/test_admin_ops.py +284 -0
  50. azure-developer-loadtesting-1.0.0/tests/test_async_admin_ops.py +286 -0
  51. azure-developer-loadtesting-1.0.0/tests/test_async_run_ops.py +286 -0
  52. azure-developer-loadtesting-1.0.0/tests/test_run_ops.py +289 -0
  53. azure-developer-loadtesting-1.0.0/tests/testcase.py +41 -0
  54. azure-developer-loadtesting-1.0.0/tests/testcase_async.py +26 -0
@@ -0,0 +1,195 @@
1
+ # ------------------------------------
2
+ # Copyright (c) Microsoft Corporation.
3
+ # Licensed under the MIT License.
4
+ # ------------------------------------
5
+ """Customize generated code here.
6
+
7
+ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize
8
+ """
9
+ import logging
10
+ import time
11
+ from functools import partial
12
+ from typing import List, IO, Optional, Any, Union, overload, Generic, TypeVar
13
+
14
+ from azure.core.polling import PollingMethod
15
+ from azure.core.tracing.decorator import distributed_trace
16
+ from azure.core.polling import LROPoller
17
+
18
+ from ._operations import AdministrationOperations as AdministrationOperationsGenerated, JSON
19
+ from ._operations import TestRunOperations as TestRunOperationsGenerated
20
+ from .._serialization import Serializer
21
+
22
+ _SERIALIZER = Serializer()
23
+ _SERIALIZER.client_side_validation = False
24
+
25
+ PollingReturnType = TypeVar("PollingReturnType")
26
+
27
+ logger = logging.getLogger(__name__)
28
+
29
+
30
+ class LoadTestingPollingMethod(PollingMethod):
31
+ """Base class for custom sync polling methods."""
32
+
33
+ def _update_status(self) -> None:
34
+ raise NotImplementedError("This method needs to be implemented")
35
+
36
+ def _update_resource(self) -> None:
37
+ self._resource = self._command()
38
+
39
+ def initialize(self, client, initial_response, deserialization_callback) -> None:
40
+ self._command = client
41
+ self._initial_response = initial_response
42
+ self._resource = initial_response
43
+
44
+ def status(self) -> str:
45
+ return self._status
46
+
47
+ def finished(self) -> bool:
48
+ return self._status in self._termination_statuses
49
+
50
+ def resource(self) -> JSON:
51
+ return self._resource
52
+
53
+ def run(self) -> None:
54
+ try:
55
+ while not self.finished():
56
+ self._update_resource()
57
+ self._update_status()
58
+
59
+ if not self.finished():
60
+ time.sleep(self._polling_interval)
61
+ except Exception as e:
62
+ logger.error(e)
63
+ raise e
64
+
65
+
66
+ class ValidationCheckPoller(LoadTestingPollingMethod):
67
+ """polling method for long-running validation check operation."""
68
+
69
+ def __init__(self, interval=5) -> None:
70
+ self._resource = None
71
+ self._command = None
72
+ self._initial_response = None
73
+ self._polling_interval = interval
74
+ self._status = None
75
+ self._termination_statuses = ["VALIDATION_SUCCESS", "VALIDATION_FAILED", "VALIDATION_NOT_REQUIRED"]
76
+
77
+ def _update_status(self) -> None:
78
+ self._status = self._resource["validationStatus"]
79
+
80
+
81
+ class TestRunStatusPoller(LoadTestingPollingMethod):
82
+ def __init__(self, interval=5) -> None:
83
+ self._resource = None
84
+ self._command = None
85
+ self._initial_response = None
86
+ self._polling_interval = interval
87
+ self._status = None
88
+ self._termination_statuses = ["DONE", "FAILED", "CANCELLED"]
89
+
90
+ def _update_status(self) -> None:
91
+ self._status = self._resource["status"]
92
+
93
+
94
+ class AdministrationOperations(AdministrationOperationsGenerated):
95
+ """
96
+ for performing the operations on the Administration Subclient
97
+ """
98
+
99
+ def __init__(self, *args, **kwargs):
100
+ super(AdministrationOperations, self).__init__(*args, **kwargs)
101
+
102
+ @distributed_trace
103
+ def begin_upload_test_file(
104
+ self, test_id: str, file_name: str, body: IO, *, file_type: Optional[str] = None, **kwargs: Any
105
+ ) -> LROPoller[JSON]:
106
+ """Upload file to the test
107
+
108
+ :param test_id: Unique id for the test
109
+ :type test_id: str
110
+ :param file_name: Name of the file to be uploaded
111
+ :type file_name: str
112
+ :param body: File content to be uploaded
113
+ :type body: IO
114
+ :param file_type: Type of the file to be uploaded
115
+ :type file_type: str
116
+ :return: An instance of LROPoller object to check the validation status of file
117
+ :rtype: ~azure.developer.loadtesting._polling.LoadTestingLROPoller
118
+ :raises ~azure.core.exceptions.HttpResponseError:
119
+ :raises ~azure.core.exceptions.ResourceNotFoundError:
120
+ """
121
+
122
+ polling_interval = kwargs.pop("_polling_interval", None)
123
+ if polling_interval is None:
124
+ polling_interval = 5
125
+ upload_test_file_operation = super().begin_upload_test_file(
126
+ test_id=test_id, file_name=file_name, body=body, file_type=file_type, **kwargs
127
+ )
128
+
129
+ command = partial(self.get_test_file, test_id=test_id, file_name=file_name)
130
+
131
+ create_validation_status_polling = ValidationCheckPoller(interval=polling_interval)
132
+ return LROPoller(command, upload_test_file_operation, lambda *_: None, create_validation_status_polling)
133
+
134
+
135
+ class TestRunOperations(TestRunOperationsGenerated):
136
+ """
137
+ class to perform operations on TestRun
138
+ """
139
+
140
+ def __init__(self, *args, **kwargs):
141
+ super(TestRunOperations, self).__init__(*args, **kwargs)
142
+
143
+ @distributed_trace
144
+ def begin_test_run(
145
+ self, test_run_id: str, body: Union[JSON, IO], *, old_test_run_id: Optional[str] = None, **kwargs: Any
146
+ ) -> LROPoller[JSON]:
147
+ """Create and start a new test run with the given name.
148
+
149
+ Create and start a new test run with the given name.
150
+
151
+ :param test_run_id: Unique name for the load test run, must contain only lower-case alphabetic,
152
+ numeric, underscore or hyphen characters. Required.
153
+ :type test_run_id: str
154
+ :param body: Load test run model. Is either a model type or a IO type. Required.
155
+ :type body: JSON or IO
156
+ :keyword old_test_run_id: Existing test run identifier that should be rerun, if this is
157
+ provided, the test will run with the JMX file, configuration and app components from the
158
+ existing test run. You can override the configuration values for new test run in the request
159
+ body. Default value is None.
160
+ :paramtype old_test_run_id: str
161
+ :keyword content_type: Body Parameter content-type. Known values are:
162
+ 'application/merge-patch+json'. Default value is None.
163
+ :paramtype content_type: str
164
+
165
+ :rtype: ~azure.developer.loadtesting._polling.LoadTestingLROPoller
166
+ :raises ~azure.core.exceptions.HttpResponseError:
167
+ :raises ~azure.core.exceptions.ResourceNotFoundError:
168
+ """
169
+
170
+ polling_interval = kwargs.pop("_polling_interval", None)
171
+ if polling_interval is None:
172
+ polling_interval = 5
173
+ create_or_update_test_run_operation = super()._test_run_initial(
174
+ test_run_id, body, old_test_run_id=old_test_run_id, **kwargs
175
+ )
176
+
177
+ command = partial(self.get_test_run, test_run_id=test_run_id)
178
+
179
+ create_test_run_polling = TestRunStatusPoller(interval=polling_interval)
180
+ return LROPoller(command, create_or_update_test_run_operation, lambda *_: None, create_test_run_polling)
181
+
182
+
183
+ __all__: List[str] = ["AdministrationOperations", "TestRunOperations"]
184
+
185
+
186
+ # Add all objects you want publicly available to users at this package level
187
+
188
+
189
+ def patch_sdk():
190
+ """Do not remove from this file.
191
+
192
+ `patch_sdk` is a last resort escape hatch that allows you to do customizations
193
+ you can't accomplish using the techniques described in
194
+ https://aka.ms/azsdk/python/dpcodegen/python/customize
195
+ """
@@ -0,0 +1,6 @@
1
+ # ------------------------------------
2
+ # Copyright (c) Microsoft Corporation.
3
+ # Licensed under the MIT License.
4
+ # ------------------------------------
5
+
6
+ VERSION = "1.0.0"
@@ -0,0 +1,9 @@
1
+
2
+ # -------------------------------------------------------------------------
3
+ # Copyright (c) Microsoft Corporation. All rights reserved.
4
+ # Licensed under the MIT License. See License.txt in the project root for
5
+ # license information.
6
+ # --------------------------------------------------------------------------
7
+ from ._client import LoadTestRunClient, LoadTestAdministrationClient
8
+
9
+ __all__ = ["LoadTestAdministrationClient", "LoadTestRunClient"]
@@ -0,0 +1,107 @@
1
+ # -------------------------------------------------------------------------
2
+ # Copyright (c) Microsoft Corporation. All rights reserved.
3
+ # Licensed under the MIT License. See License.txt in the project root for
4
+ # license information.
5
+ # --------------------------------------------------------------------------
6
+
7
+ from copy import deepcopy
8
+ from typing import Any, Awaitable
9
+
10
+ from azure.core.credentials_async import AsyncTokenCredential
11
+ from azure.core import AsyncPipelineClient
12
+ from azure.core.rest import HttpRequest, AsyncHttpResponse
13
+
14
+ from .._generated.aio._configuration import LoadTestingClientConfiguration
15
+ from .._generated._serialization import Deserializer, Serializer
16
+ from .._generated.aio.operations import AdministrationOperations, TestRunOperations
17
+
18
+ class _BaseClient: # pylint: disable=client-accepts-api-version-keyword
19
+ """These APIs allow end users to create, view and run load tests using Azure Load Test Service.
20
+
21
+ :ivar administration: AdministrationOperations operations
22
+ :vartype administration: azure.developer.loadtesting.aio.operations.AdministrationOperations
23
+ :ivar test_run: TestRunOperations operations
24
+ :vartype test_run: azure.developer.loadtesting.aio.operations.TestRunOperations
25
+ :param endpoint: URL to perform data plane API operations on the resource. Required.
26
+ :type endpoint: str
27
+ :param credential: Credential needed for the client to connect to Azure. Required.
28
+ :type credential: ~azure.core.credentials_async.AsyncTokenCredential
29
+ :keyword api_version: Api Version. Default value is "2022-11-01". Note that overriding this
30
+ default value may result in unsupported behavior.
31
+ :paramtype api_version: str
32
+ """
33
+
34
+ def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs: Any) -> None:
35
+ _endpoint = "https://{Endpoint}"
36
+ self._config = LoadTestingClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
37
+ self._client = AsyncPipelineClient(base_url=_endpoint, config=self._config, **kwargs)
38
+
39
+ self._serialize = Serializer()
40
+ self._deserialize = Deserializer()
41
+ self._serialize.client_side_validation = False
42
+ super().__init__(self._client, self._config, self._serialize, self._deserialize)
43
+
44
+ def send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]:
45
+ """Runs the network request through the client's chained policies.
46
+
47
+ >>> from azure.core.rest import HttpRequest
48
+ >>> request = HttpRequest("GET", "https://www.example.org/")
49
+ <HttpRequest [GET], url: 'https://www.example.org/'>
50
+ >>> response = await client.send_request(request)
51
+ <AsyncHttpResponse: 200 OK>
52
+
53
+ For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
54
+
55
+ :param request: The network request you want to make. Required.
56
+ :type request: ~azure.core.rest.HttpRequest
57
+ :keyword bool stream: Whether the response payload will be streamed. Defaults to False.
58
+ :return: The response of your network call. Does not do error handling on your response.
59
+ :rtype: ~azure.core.rest.AsyncHttpResponse
60
+ """
61
+
62
+ request_copy = deepcopy(request)
63
+ path_format_arguments = {
64
+ "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
65
+ }
66
+
67
+ request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
68
+ return self._client.send_request(request_copy, **kwargs)
69
+
70
+ async def close(self) -> None:
71
+ await self._client.close()
72
+
73
+ async def __aexit__(self, *exc_details) -> None:
74
+ await self._client.__aexit__(*exc_details)
75
+
76
+
77
+ class LoadTestAdministrationClient(_BaseClient, AdministrationOperations): # pylint: disable=client-accepts-api-version-keyword
78
+ """These APIs allow end users to create, view and run load tests using Azure Load Test Service.
79
+
80
+ :param endpoint: URL to perform data plane API operations on the resource. Required.
81
+ :type endpoint: str
82
+ :param credential: Credential needed for the client to connect to Azure. Required.
83
+ :type credential: ~azure.core.credentials_async.AsyncTokenCredential
84
+ :keyword api_version: Api Version. Default value is "2022-11-01". Note that overriding this
85
+ default value may result in unsupported behavior.
86
+ :paramtype api_version: str
87
+ """
88
+
89
+ async def __aenter__(self) -> "LoadTestAdministrationClient":
90
+ await self._client.__aenter__()
91
+ return self
92
+
93
+ class LoadTestRunClient(_BaseClient, TestRunOperations): # pylint: disable=client-accepts-api-version-keyword
94
+ """These APIs allow end users to create, view and run load tests using Azure Load Test Service.
95
+
96
+ :param endpoint: URL to perform data plane API operations on the resource. Required.
97
+ :type endpoint: str
98
+ :param credential: Credential needed for the client to connect to Azure. Required.
99
+ :type credential: ~azure.core.credentials_async.AsyncTokenCredential
100
+ :keyword api_version: Api Version. Default value is "2022-11-01". Note that overriding this
101
+ default value may result in unsupported behavior.
102
+ :paramtype api_version: str
103
+ """
104
+
105
+ async def __aenter__(self) -> "LoadTestRunClient":
106
+ await self._client.__aenter__()
107
+ return self
@@ -0,0 +1 @@
1
+ # Marker file for PEP 561.
@@ -0,0 +1,281 @@
1
+ Metadata-Version: 2.1
2
+ Name: azure-developer-loadtesting
3
+ Version: 1.0.0
4
+ Summary: Microsoft Azure Developer LoadTesting Client Library for Python
5
+ Home-page: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk
6
+ Author: Microsoft Corporation
7
+ Author-email: azpysdkhelp@microsoft.com
8
+ License: MIT License
9
+ Keywords: azure,azure sdk
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Programming Language :: Python
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.7
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: License :: OSI Approved :: MIT License
20
+ Requires-Python: >=3.7
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+
24
+ # Azure Load Testing client library for Python
25
+ Azure Load Testing provides client library in python to the user by which they can interact natively with Azure Load Testing service. Azure Load Testing is a fully managed load-testing service that enables you to generate high-scale load. The service simulates traffic for your applications, regardless of where they're hosted. Developers, testers, and quality assurance (QA) engineers can use it to optimize application performance, scalability, or capacity.
26
+
27
+ ## Documentation
28
+ Various documentation is available to help you get started
29
+
30
+ <!-- - [Source code][source_code] -->
31
+ - [API reference documentation][api_reference_doc]
32
+ - [Product Documentation][product_documentation]
33
+
34
+ ## Getting started
35
+
36
+ ### Installing the package
37
+
38
+ ```bash
39
+ python -m pip install azure-developer-loadtesting
40
+ ```
41
+
42
+ #### Prequisites
43
+
44
+ - Python 3.7 or later is required to use this package.
45
+ - You need an [Azure subscription][azure_sub] to use this package.
46
+ - An existing Azure Developer LoadTesting instance.
47
+
48
+ #### Create with an Azure Active Directory Credential
49
+
50
+ To use an [Azure Active Directory (AAD) token credential][authenticate_with_token],
51
+ provide an instance of the desired credential type obtained from the
52
+ [azure-identity][azure_identity_credentials] library.
53
+
54
+ To authenticate with AAD, you must first [pip][pip] install [`azure-identity`][azure_identity_pip]
55
+
56
+ After setup, you can choose which type of [credential][azure_identity_credentials] from azure.identity to use.
57
+
58
+ As an example, sign in via the Azure CLI `az login` command and [DefaultAzureCredential](https://learn.microsoft.com/python/api/azure-identity/azure.identity.defaultazurecredential?view=azure-python) will authenticate as that user.
59
+
60
+ Use the returned token credential to authenticate the client.
61
+
62
+ #### Create the client
63
+
64
+ Azure Developer LoadTesting SDK has 2 sub-clients of the main client (`LoadTestingClient`) to interact with the service, 'administration' and 'test_run'.
65
+
66
+ ```python
67
+ from azure.developer.loadtesting import LoadTestAdministrationClient
68
+
69
+ # for managing authentication and authorization
70
+ # can be installed from pypi, follow: https://pypi.org/project/azure-identity/
71
+ # using DefaultAzureCredentials, read more at: https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity.defaultazurecredential?view=azure-python
72
+ from azure.identity import DefaultAzureCredential
73
+
74
+ client = LoadTestAdministrationClient(endpoint='<endpoint>', credential=DefaultAzureCredential())
75
+ ```
76
+
77
+ `<endpoint>` refers to the data-plane endpoint/URL of the resource.
78
+
79
+ ## Key concepts
80
+
81
+ The Azure Load Test client library for python allows you to interact with each of these components through the use of clients. There are two top-level clients which are the main entry points for the library
82
+
83
+ - `LoadTestAdministrationClient` (`azure.developer.loadtesting.LoadTestAdministrationClient`)
84
+ - `LoadTestRunClient` (`azure.developer.loadtesting.LoadTestRunClient`)
85
+
86
+ These two clients also have there asynchronous counterparts, which are
87
+ - `LoadTestAdministrationClient` (`azure.developer.loadtesting.aio.LoadTestAdministrationClient`)
88
+ - `LoadTestRunClient` (`azure.developer.loadtesting.aio.LoadTestRunClient`)
89
+
90
+ ### Load Test Administration Client
91
+
92
+ The `LoadTestAdministrationClient` is used to administer and configure the load tests, app components and metrics.
93
+
94
+ #### Test
95
+
96
+ A test specifies the test script, and configuration settings for running a load test. You can create one or more tests in an Azure Load Testing resource.
97
+
98
+ #### App Component
99
+
100
+ When you run a load test for an Azure-hosted application, you can monitor resource metrics for the different Azure application components (server-side metrics). While the load test runs, and after completion of the test, you can monitor and analyze the resource metrics in the Azure Load Testing dashboard.
101
+
102
+ #### Metrics
103
+
104
+ During a load test, Azure Load Testing collects metrics about the test execution. There are two types of metrics:
105
+
106
+ 1. Client-side metrics give you details reported by the test engine. These metrics include the number of virtual users, the request response time, the number of failed requests, or the number of requests per second.
107
+
108
+ 2. Server-side metrics are available for Azure-hosted applications and provide information about your Azure application components. Metrics can be for the number of database reads, the type of HTTP responses, or container resource consumption.
109
+
110
+ ### Test Run Client
111
+
112
+ The `LoadTestRunClient` is used to start and stop test runs corresponding to a load test. A test run represents one execution of a load test. It collects the logs associated with running the Apache JMeter script, the load test YAML configuration, the list of app components to monitor, and the results of the test.
113
+
114
+ ### Data-Plane Endpoint
115
+
116
+ Data-plane of Azure Load Testing resources is addressable using the following URL format:
117
+
118
+ `00000000-0000-0000-0000-000000000000.aaa.cnt-prod.loadtesting.azure.com`
119
+
120
+ The first GUID `00000000-0000-0000-0000-000000000000` is the unique identifier used for accessing the Azure Load Testing resource. This is followed by `aaa` which is the Azure region of the resource.
121
+
122
+ The data-plane endpoint is obtained from Control Plane APIs.
123
+
124
+ **Example:** `1234abcd-12ab-12ab-12ab-123456abcdef.eus.cnt-prod.loadtesting.azure.com`
125
+
126
+ In the above example, `eus` represents the Azure region `East US`.
127
+
128
+ ## Examples
129
+
130
+ ### Creating a load test
131
+ ```python
132
+ from azure.developer.loadtesting import LoadTestAdministrationClient
133
+ from azure.identity import DefaultAzureCredential
134
+ from azure.core.exceptions import HttpResponseError
135
+ import os
136
+
137
+ TEST_ID = "some-test-id"
138
+ DISPLAY_NAME = "my-load-test"
139
+
140
+ # set SUBSCRIPTION_ID as an environment variable
141
+ SUBSCRIPTION_ID = os.environ["SUBSCRIPTION_ID"]
142
+
143
+ client = LoadTestAdministrationClient(endpoint='<endpoint>', credential=DefaultAzureCredential())
144
+
145
+ try:
146
+ result = client.create_or_update_test(
147
+ TEST_ID,
148
+ {
149
+ "description": "",
150
+ "displayName": "My New Load Test",
151
+ "loadTestConfig": {
152
+ "engineInstances": 1,
153
+ "splitAllCSVs": False,
154
+ },
155
+ "passFailCriteria": {
156
+ "passFailMetrics": {
157
+ "condition1": {
158
+ "clientmetric": "response_time_ms",
159
+ "aggregate": "avg",
160
+ "condition": ">",
161
+ "value": 300
162
+ },
163
+ "condition2": {
164
+ "clientmetric": "error",
165
+ "aggregate": "percentage",
166
+ "condition": ">",
167
+ "value": 50
168
+ },
169
+ "condition3": {
170
+ "clientmetric": "latency",
171
+ "aggregate": "avg",
172
+ "condition": ">",
173
+ "value": 200,
174
+ "requestName": "GetCustomerDetails"
175
+ }
176
+ }
177
+ },
178
+ "secrets": {
179
+ "secret1": {
180
+ "value": "https://sdk-testing-keyvault.vault.azure.net/secrets/sdk-secret",
181
+ "type": "AKV_SECRET_URI"
182
+ }
183
+ },
184
+ "environmentVariables": {
185
+ "my-variable": "value"
186
+ }
187
+ }
188
+ )
189
+ print(result)
190
+ except HttpResponseError as e:
191
+ print('Service responded with error: {}'.format(e.response.json()))
192
+
193
+ ```
194
+
195
+ ### Uploading .jmx file to a Test
196
+ ```python
197
+ from azure.developer.loadtesting import LoadTestAdministrationClient
198
+ from azure.identity import DefaultAzureCredential
199
+ from azure.core.exceptions import HttpResponseError
200
+
201
+ TEST_ID = "some-test-id"
202
+ FILE_NAME = "some-file-name.jmx"
203
+
204
+ client = LoadTestAdministrationClient(endpoint='<endpoint>', credential=DefaultAzureCredential())
205
+
206
+ try:
207
+
208
+ # uploading .jmx file to a test
209
+ resultPoller = client.begin_upload_test_file(TEST_ID, FILE_NAME, open("sample.jmx", "rb"))
210
+
211
+ # getting result of LRO poller with timeout of 600 secs
212
+ validationResponse = resultPoller.result(600)
213
+ print(validationResponse)
214
+
215
+ except HttpResponseError as e:
216
+ print("Failed with error: {}".format(e.response.json()))
217
+ ```
218
+
219
+ ### Running a Test
220
+ ```python
221
+ from azure.developer.loadtesting import LoadTestRunClient
222
+ from azure.identity import DefaultAzureCredential
223
+ from azure.core.exceptions import HttpResponseError
224
+
225
+ TEST_ID = "some-test-id"
226
+ TEST_RUN_ID = "some-testrun-id"
227
+ DISPLAY_NAME = "my-load-test-run"
228
+
229
+ client = LoadTestRunClient(endpoint='<endpoint>', credential=DefaultAzureCredential())
230
+
231
+ try:
232
+ testRunPoller = client.begin_test_run(
233
+ TEST_RUN_ID,
234
+ {
235
+ "testId": TEST_ID,
236
+ "displayName": "My New Load Test Run",
237
+ }
238
+ )
239
+
240
+ #waiting for test run status to be completed with timeout = 3600 seconds
241
+ result = testRunPoller.result(3600)
242
+
243
+ print(result)
244
+ except HttpResponseError as e:
245
+ print("Failed with error: {}".format(e.response.json()))
246
+ ```
247
+
248
+ ## Next steps
249
+
250
+ More samples can be found [here](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/loadtesting/azure-developer-loadtesting/samples).
251
+
252
+ ## Contributing
253
+
254
+ This project welcomes contributions and suggestions. Most contributions require
255
+ you to agree to a Contributor License Agreement (CLA) declaring that you have
256
+ the right to, and actually do, grant us the rights to use your contribution.
257
+ For details, visit https://cla.microsoft.com.
258
+
259
+ When you submit a pull request, a CLA-bot will automatically determine whether
260
+ you need to provide a CLA and decorate the PR appropriately (e.g., label,
261
+ comment). Simply follow the instructions provided by the bot. You will only
262
+ need to do this once across all repos using our CLA.
263
+
264
+ This project has adopted the
265
+ [Microsoft Open Source Code of Conduct][code_of_conduct]. For more information,
266
+ see the Code of Conduct FAQ or contact opencode@microsoft.com with any
267
+ additional questions or comments.
268
+
269
+ ## Troubleshooting
270
+ More about it is coming soon...
271
+
272
+ <!-- LINKS -->
273
+ [code_of_conduct]: https://opensource.microsoft.com/codeofconduct/
274
+ [authenticate_with_token]: https://docs.microsoft.com/azure/cognitive-services/authentication?tabs=powershell#authenticate-with-an-authentication-token
275
+ [azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#credentials
276
+ [azure_identity_pip]: https://pypi.org/project/azure-identity/
277
+ [default_azure_credential]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#defaultazurecredential
278
+ [pip]: https://pypi.org/project/pip/
279
+ [azure_sub]: https://azure.microsoft.com/free/
280
+ [api_reference_doc]: https://docs.microsoft.com/rest/api/loadtesting/
281
+ [product_documentation]: https://azure.microsoft.com/services/load-testing/
@@ -0,0 +1,52 @@
1
+ CHANGELOG.md
2
+ LICENSE
3
+ MANIFEST.in
4
+ README.md
5
+ pyproject.toml
6
+ setup.py
7
+ azure/__init__.py
8
+ azure/developer/__init__.py
9
+ azure/developer/loadtesting/__init__.py
10
+ azure/developer/loadtesting/_client.py
11
+ azure/developer/loadtesting/_version.py
12
+ azure/developer/loadtesting/py.typed
13
+ azure/developer/loadtesting/_generated/__init__.py
14
+ azure/developer/loadtesting/_generated/_client.py
15
+ azure/developer/loadtesting/_generated/_configuration.py
16
+ azure/developer/loadtesting/_generated/_patch.py
17
+ azure/developer/loadtesting/_generated/_serialization.py
18
+ azure/developer/loadtesting/_generated/_vendor.py
19
+ azure/developer/loadtesting/_generated/_version.py
20
+ azure/developer/loadtesting/_generated/aio/__init__.py
21
+ azure/developer/loadtesting/_generated/aio/_client.py
22
+ azure/developer/loadtesting/_generated/aio/_configuration.py
23
+ azure/developer/loadtesting/_generated/aio/_patch.py
24
+ azure/developer/loadtesting/_generated/aio/_vendor.py
25
+ azure/developer/loadtesting/_generated/aio/operations/__init__.py
26
+ azure/developer/loadtesting/_generated/aio/operations/_operations.py
27
+ azure/developer/loadtesting/_generated/aio/operations/_patch.py
28
+ azure/developer/loadtesting/_generated/operations/__init__.py
29
+ azure/developer/loadtesting/_generated/operations/_operations.py
30
+ azure/developer/loadtesting/_generated/operations/_patch.py
31
+ azure/developer/loadtesting/aio/__init__.py
32
+ azure/developer/loadtesting/aio/_client.py
33
+ azure_developer_loadtesting.egg-info/PKG-INFO
34
+ azure_developer_loadtesting.egg-info/SOURCES.txt
35
+ azure_developer_loadtesting.egg-info/dependency_links.txt
36
+ azure_developer_loadtesting.egg-info/not-zip-safe
37
+ azure_developer_loadtesting.egg-info/requires.txt
38
+ azure_developer_loadtesting.egg-info/top_level.txt
39
+ samples/begin_test_run.py
40
+ samples/create_or_update_app_components.py
41
+ samples/create_or_update_test_function.py
42
+ samples/delete_load_test_function.py
43
+ samples/delete_load_test_run.py
44
+ samples/get_metrics.py
45
+ samples/upload_test_file.py
46
+ tests/conftest.py
47
+ tests/test_admin_ops.py
48
+ tests/test_async_admin_ops.py
49
+ tests/test_async_run_ops.py
50
+ tests/test_run_ops.py
51
+ tests/testcase.py
52
+ tests/testcase_async.py
@@ -0,0 +1,5 @@
1
+ isodate<1.0.0,>=0.6.1
2
+ azure-core<2.0.0,>=1.24.0
3
+
4
+ [:python_version < "3.8.0"]
5
+ typing-extensions>=4.3.0
@@ -0,0 +1,6 @@
1
+ [tool.azure-sdk-build]
2
+ mypy = false
3
+ pylint = false
4
+ pyright = false
5
+ type_check_samples = false
6
+ verifytypes = false