azure-developer-loadtesting 1.0.1__tar.gz

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 (55) hide show
  1. azure_developer_loadtesting-1.0.1/CHANGELOG.md +82 -0
  2. azure_developer_loadtesting-1.0.1/LICENSE +21 -0
  3. azure_developer_loadtesting-1.0.1/MANIFEST.in +7 -0
  4. azure_developer_loadtesting-1.0.1/PKG-INFO +284 -0
  5. azure_developer_loadtesting-1.0.1/README.md +258 -0
  6. azure_developer_loadtesting-1.0.1/azure/__init__.py +1 -0
  7. azure_developer_loadtesting-1.0.1/azure/developer/__init__.py +1 -0
  8. azure_developer_loadtesting-1.0.1/azure/developer/loadtesting/__init__.py +10 -0
  9. azure_developer_loadtesting-1.0.1/azure/developer/loadtesting/_client.py +97 -0
  10. azure_developer_loadtesting-1.0.1/azure/developer/loadtesting/_generated/__init__.py +26 -0
  11. azure_developer_loadtesting-1.0.1/azure/developer/loadtesting/_generated/_client.py +88 -0
  12. azure_developer_loadtesting-1.0.1/azure/developer/loadtesting/_generated/_configuration.py +71 -0
  13. azure_developer_loadtesting-1.0.1/azure/developer/loadtesting/_generated/_patch.py +24 -0
  14. azure_developer_loadtesting-1.0.1/azure/developer/loadtesting/_generated/_serialization.py +1996 -0
  15. azure_developer_loadtesting-1.0.1/azure/developer/loadtesting/_generated/_vendor.py +20 -0
  16. azure_developer_loadtesting-1.0.1/azure/developer/loadtesting/_generated/_version.py +9 -0
  17. azure_developer_loadtesting-1.0.1/azure/developer/loadtesting/_generated/aio/__init__.py +23 -0
  18. azure_developer_loadtesting-1.0.1/azure/developer/loadtesting/_generated/aio/_client.py +88 -0
  19. azure_developer_loadtesting-1.0.1/azure/developer/loadtesting/_generated/aio/_configuration.py +71 -0
  20. azure_developer_loadtesting-1.0.1/azure/developer/loadtesting/_generated/aio/_patch.py +23 -0
  21. azure_developer_loadtesting-1.0.1/azure/developer/loadtesting/_generated/aio/_vendor.py +17 -0
  22. azure_developer_loadtesting-1.0.1/azure/developer/loadtesting/_generated/aio/operations/__init__.py +21 -0
  23. azure_developer_loadtesting-1.0.1/azure/developer/loadtesting/_generated/aio/operations/_operations.py +6517 -0
  24. azure_developer_loadtesting-1.0.1/azure/developer/loadtesting/_generated/aio/operations/_patch.py +186 -0
  25. azure_developer_loadtesting-1.0.1/azure/developer/loadtesting/_generated/operations/__init__.py +21 -0
  26. azure_developer_loadtesting-1.0.1/azure/developer/loadtesting/_generated/operations/_operations.py +7242 -0
  27. azure_developer_loadtesting-1.0.1/azure/developer/loadtesting/_generated/operations/_patch.py +193 -0
  28. azure_developer_loadtesting-1.0.1/azure/developer/loadtesting/_generated/py.typed +1 -0
  29. azure_developer_loadtesting-1.0.1/azure/developer/loadtesting/_version.py +6 -0
  30. azure_developer_loadtesting-1.0.1/azure/developer/loadtesting/aio/__init__.py +9 -0
  31. azure_developer_loadtesting-1.0.1/azure/developer/loadtesting/aio/_client.py +107 -0
  32. azure_developer_loadtesting-1.0.1/azure/developer/loadtesting/py.typed +1 -0
  33. azure_developer_loadtesting-1.0.1/azure_developer_loadtesting.egg-info/PKG-INFO +284 -0
  34. azure_developer_loadtesting-1.0.1/azure_developer_loadtesting.egg-info/SOURCES.txt +53 -0
  35. azure_developer_loadtesting-1.0.1/azure_developer_loadtesting.egg-info/dependency_links.txt +1 -0
  36. azure_developer_loadtesting-1.0.1/azure_developer_loadtesting.egg-info/not-zip-safe +1 -0
  37. azure_developer_loadtesting-1.0.1/azure_developer_loadtesting.egg-info/requires.txt +5 -0
  38. azure_developer_loadtesting-1.0.1/azure_developer_loadtesting.egg-info/top_level.txt +1 -0
  39. azure_developer_loadtesting-1.0.1/pyproject.toml +5 -0
  40. azure_developer_loadtesting-1.0.1/samples/begin_test_run.py +52 -0
  41. azure_developer_loadtesting-1.0.1/samples/create_or_update_app_components.py +57 -0
  42. azure_developer_loadtesting-1.0.1/samples/create_or_update_test_function.py +84 -0
  43. azure_developer_loadtesting-1.0.1/samples/delete_load_test_function.py +46 -0
  44. azure_developer_loadtesting-1.0.1/samples/delete_load_test_run.py +39 -0
  45. azure_developer_loadtesting-1.0.1/samples/get_metrics.py +64 -0
  46. azure_developer_loadtesting-1.0.1/samples/upload_test_file.py +45 -0
  47. azure_developer_loadtesting-1.0.1/setup.cfg +4 -0
  48. azure_developer_loadtesting-1.0.1/setup.py +71 -0
  49. azure_developer_loadtesting-1.0.1/tests/conftest.py +60 -0
  50. azure_developer_loadtesting-1.0.1/tests/test_admin_ops.py +284 -0
  51. azure_developer_loadtesting-1.0.1/tests/test_async_admin_ops.py +286 -0
  52. azure_developer_loadtesting-1.0.1/tests/test_async_run_ops.py +286 -0
  53. azure_developer_loadtesting-1.0.1/tests/test_run_ops.py +289 -0
  54. azure_developer_loadtesting-1.0.1/tests/testcase.py +41 -0
  55. azure_developer_loadtesting-1.0.1/tests/testcase_async.py +26 -0
@@ -0,0 +1,82 @@
1
+ # Release History
2
+
3
+ ## 1.0.1 (2025-01-20)
4
+
5
+ ### Bugs Fixed
6
+
7
+ - Update API response enum typo for VALIDATION_FAILURE
8
+
9
+ ### Other Changes
10
+
11
+ - Add NOT_VALIDATED to the list of terminal states for the file validation poller
12
+
13
+ ## 1.0.0 (2023-03-07)
14
+
15
+ ### Breaking Changes
16
+ - moved all operations under `azure.developer.loadtesting.LoadTestingClient.test_run` to `azure.developer.loadtesting.LoadTestRunClient`
17
+ - moved all operations under `azure.developer.loadtesting.LoadTestingClient.administration` to `azure.developer.loadtesting.LoadTestAdministrationClient`
18
+ - moved all operations under `azure.developer.loadtesting.aio.LoadTestingClient.test_run` to `azure.developer.loadtesting.aio.LoadTestRunClient`
19
+ - moved all operations under `azure.developer.loadtesting.aio.LoadTestingClient.administration` to `azure.developer.loadtesting.aio.LoadTestAdministrationClient`
20
+ - removed `azure.developer.loadtesting.LoadTestingClient.administration.upload_test_file` as it moved all functionality to `azure.developer.loadtesting.LoadTestAdministrationClient.begin_upload_test_file`
21
+ - removed `azure.developer.loadtesting.aio.LoadTestingClient.administration.upload_test_file` as it moved all functionality to `azure.developer.loadtesting.aio.LoadTestAdministrationClient.begin_upload_test_file`
22
+ - removed `azure.developer.loadtesting.LoadTestingClient.test_run.create_or_update_test_run` as it moved all functionality to `azure.developer.loadtesting.LoadTestRunClient.begin_test_run`
23
+ - removed `azure.developer.loadtesting.aio.LoadTestingClient.test_run.create_or_update_test_run` as it moved all functionality to `azure.developer.loadtesting.aio.LoadTestRunClient.begin_test_run`
24
+ - removed `azure.developer.loadtesting.aio.LoadTestingClient.test_run.list_metric_definitions` as it moved all functionality to `azure.developer.loadtesting.aio.LoadTestRunClient.get_metric_definitions`
25
+ - removed `azure.developer.loadtesting.LoadTestingClient.test_run.list_metric_definitions` as it moved all functionality to `azure.developer.loadtesting.LoadTestRunClient.get_metric_definitions`
26
+ - removed `azure.developer.loadtesting.aio.LoadTestingClient.test_run.list_metric_definitions` as it moved all functionality to `azure.developer.loadtesting.aio.LoadTestRunClient.get_metric_definitions`
27
+ - removed `azure.developer.loadtesting.LoadTestingClient.test_run.list_metric_namespaces` as it moved all functionality to `azure.developer.loadtesting.LoadTestRunClient.get_metric_namespaces`
28
+
29
+ ### Other Changes
30
+ - bumped version to stable `1.0.0`
31
+ - updated README.md
32
+
33
+ ## 1.0.0b3 (2023-01-01)
34
+
35
+ ### Features Added
36
+ - Method added `azure.developer.loadtesting.LoadTestingClient.test_run.list_metric_namespaces`
37
+ - Method added `azure.developer.loadtesting.LoadTestingClient.test_run.list_metric_definitions`
38
+ - Method added `azure.developer.loadtesting.LoadTestingClient.test_run.list_metrics`
39
+ - Method added `azure.developer.loadtesting.LoadTestingClient.test_run.create_or_update_app_components`
40
+ - Method added `azure.developer.loadtesting.LoadTestingClient.test_run.get_app_components`
41
+ - Method added `azure.developer.loadtesting.LoadTestingClient.test_run.create_or_update_server_metrics_config`
42
+ - Method added `azure.developer.loadtesting.LoadTestingClient.test_run.get_server_metrics_config`
43
+ - Method added `azure.developer.loadtesting.LoadTestingClient.administration.begin_upload_test_file`
44
+ - Method added `azure.developer.loadtesting.LoadTestingClient.test_run.begin_test_run`
45
+ - Method added `azure.developer.loadtesting.LoadTestingClient.test_run.begin_test_run_status`
46
+ - Method added `azure.developer.loadtesting.aio.LoadTestingClient.test_run.list_metric_namespaces`
47
+ - Method added `azure.developer.loadtesting.aio.LoadTestingClient.test_run.list_metric_definitions`
48
+ - Method added `azure.developer.loadtesting.aio.LoadTestingClient.test_run.list_metrics`
49
+ - Method added `azure.developer.loadtesting.aio.LoadTestingClient.test_run.create_or_update_app_components`
50
+ - Method added `azure.developer.loadtesting.aio.LoadTestingClient.test_run.get_app_components`
51
+ - Method added `azure.developer.loadtesting.aio.LoadTestingClient.test_run.create_or_update_server_metrics_config`
52
+ - Method added `azure.developer.loadtesting.aio.LoadTestingClient.test_run.get_server_metrics_config`
53
+ - Method added `azure.developer.loadtesting.aio.LoadTestingClient.administration.begin_upload_test_file`
54
+ - Method added `azure.developer.loadtesting.aio.LoadTestingClient.test_run.begin_test_run_status`
55
+ - Method added `azure.developer.loadtesting.aio.LoadTestingClient.test_run.get_metric_dimension_values`
56
+ - Method added `azure.developer.loadtesting.aio.LoadTestingClient.test_run.begin_test_run`
57
+
58
+
59
+ ### Breaking Changes
60
+ - Changed subclients `load_test_runs` and `load_test_adminsitration` to `test_run` and `adminsitrative` respectively
61
+ - Removed `continuation_token` as a parameter for method `azure.developer.loadtesting.aio.LoadTestingClient.test_run.list_test_runs`
62
+ - Removed `continuation_token` as a parameter for method `azure.developer.loadtesting.LoadTestingClient.test_run.list_test_runs`,
63
+ - Removed `continuation_token` as a parameter for method `azure.developer.loadtesting.aio.LoadTestingClient.administration.list_test_files`
64
+ - Removed `continuation_token` as a parameter for method `azure.developer.loadtesting.LoadTestingClient.administration.list_test_files`
65
+ - Removed `continuation_token` as a parameter for method `azure.developer.loadtesting.aio.LoadTestingClient.administration.list_tests`
66
+ - Removed `continuation_token` as a parameter for method `azure.developer.loadtesting.LoadTestingClient.administration.list_tests`
67
+
68
+ ### Other Changes
69
+ - Updated README
70
+
71
+ ## 1.0.0b2 (2022-10-17)
72
+
73
+ ### Bug Fixed
74
+ - `delete_app_components` method from `azure.developer.loadtesting.LoadTestingClient.load_test_administration.delete_app_components` was not discoverable in expected location, fixed discoverability.
75
+
76
+ ### Other Changes
77
+ - Updated README
78
+
79
+ ## 1.0.0b1 (2022-07-28)
80
+
81
+ ### Features Added
82
+ - Initial version
@@ -0,0 +1,21 @@
1
+ Copyright (c) Microsoft Corporation.
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,7 @@
1
+ include *.md
2
+ include LICENSE
3
+ include azure/developer/loadtesting/py.typed
4
+ recursive-include tests *.py
5
+ recursive-include samples *.py *.md
6
+ include azure/__init__.py
7
+ include azure/developer/__init__.py
@@ -0,0 +1,284 @@
1
+ Metadata-Version: 2.1
2
+ Name: azure-developer-loadtesting
3
+ Version: 1.0.1
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
+ Requires-Dist: isodate<1.0.0,>=0.6.1
24
+ Requires-Dist: azure-core<2.0.0,>=1.26.2
25
+ Requires-Dist: typing-extensions>=4.3.0; python_version < "3.8.0"
26
+
27
+ # Azure Load Testing client library for Python
28
+ 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.
29
+
30
+ ## Documentation
31
+ Various documentation is available to help you get started
32
+
33
+ <!-- - [Source code][source_code] -->
34
+ - [API reference documentation][api_reference_doc]
35
+ - [Product Documentation][product_documentation]
36
+
37
+ ## Getting started
38
+
39
+ ### Installing the package
40
+
41
+ ```bash
42
+ python -m pip install azure-developer-loadtesting
43
+ ```
44
+
45
+ #### Prequisites
46
+
47
+ - Python 3.7 or later is required to use this package.
48
+ - You need an [Azure subscription][azure_sub] to use this package.
49
+ - An existing Azure Developer LoadTesting instance.
50
+
51
+ #### Create with an Azure Active Directory Credential
52
+
53
+ To use an [Azure Active Directory (AAD) token credential][authenticate_with_token],
54
+ provide an instance of the desired credential type obtained from the
55
+ [azure-identity][azure_identity_credentials] library.
56
+
57
+ To authenticate with AAD, you must first [pip][pip] install [`azure-identity`][azure_identity_pip]
58
+
59
+ After setup, you can choose which type of [credential][azure_identity_credentials] from azure.identity to use.
60
+
61
+ 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.
62
+
63
+ Use the returned token credential to authenticate the client.
64
+
65
+ #### Create the client
66
+
67
+ Azure Developer LoadTesting SDK has 2 sub-clients of the main client (`LoadTestingClient`) to interact with the service, 'administration' and 'test_run'.
68
+
69
+ ```python
70
+ from azure.developer.loadtesting import LoadTestAdministrationClient
71
+
72
+ # for managing authentication and authorization
73
+ # can be installed from pypi, follow: https://pypi.org/project/azure-identity/
74
+ # using DefaultAzureCredentials, read more at: https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity.defaultazurecredential?view=azure-python
75
+ from azure.identity import DefaultAzureCredential
76
+
77
+ client = LoadTestAdministrationClient(endpoint='<endpoint>', credential=DefaultAzureCredential())
78
+ ```
79
+
80
+ `<endpoint>` refers to the data-plane endpoint/URL of the resource.
81
+
82
+ ## Key concepts
83
+
84
+ 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
85
+
86
+ - `LoadTestAdministrationClient` (`azure.developer.loadtesting.LoadTestAdministrationClient`)
87
+ - `LoadTestRunClient` (`azure.developer.loadtesting.LoadTestRunClient`)
88
+
89
+ These two clients also have there asynchronous counterparts, which are
90
+ - `LoadTestAdministrationClient` (`azure.developer.loadtesting.aio.LoadTestAdministrationClient`)
91
+ - `LoadTestRunClient` (`azure.developer.loadtesting.aio.LoadTestRunClient`)
92
+
93
+ ### Load Test Administration Client
94
+
95
+ The `LoadTestAdministrationClient` is used to administer and configure the load tests, app components and metrics.
96
+
97
+ #### Test
98
+
99
+ 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.
100
+
101
+ #### App Component
102
+
103
+ 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.
104
+
105
+ #### Metrics
106
+
107
+ During a load test, Azure Load Testing collects metrics about the test execution. There are two types of metrics:
108
+
109
+ 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.
110
+
111
+ 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.
112
+
113
+ ### Test Run Client
114
+
115
+ 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.
116
+
117
+ ### Data-Plane Endpoint
118
+
119
+ Data-plane of Azure Load Testing resources is addressable using the following URL format:
120
+
121
+ `00000000-0000-0000-0000-000000000000.aaa.cnt-prod.loadtesting.azure.com`
122
+
123
+ 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.
124
+
125
+ The data-plane endpoint is obtained from Control Plane APIs.
126
+
127
+ **Example:** `1234abcd-12ab-12ab-12ab-123456abcdef.eus.cnt-prod.loadtesting.azure.com`
128
+
129
+ In the above example, `eus` represents the Azure region `East US`.
130
+
131
+ ## Examples
132
+
133
+ ### Creating a load test
134
+ ```python
135
+ from azure.developer.loadtesting import LoadTestAdministrationClient
136
+ from azure.identity import DefaultAzureCredential
137
+ from azure.core.exceptions import HttpResponseError
138
+ import os
139
+
140
+ TEST_ID = "some-test-id"
141
+ DISPLAY_NAME = "my-load-test"
142
+
143
+ # set SUBSCRIPTION_ID as an environment variable
144
+ SUBSCRIPTION_ID = os.environ["SUBSCRIPTION_ID"]
145
+
146
+ client = LoadTestAdministrationClient(endpoint='<endpoint>', credential=DefaultAzureCredential())
147
+
148
+ try:
149
+ result = client.create_or_update_test(
150
+ TEST_ID,
151
+ {
152
+ "description": "",
153
+ "displayName": "My New Load Test",
154
+ "loadTestConfig": {
155
+ "engineInstances": 1,
156
+ "splitAllCSVs": False,
157
+ },
158
+ "passFailCriteria": {
159
+ "passFailMetrics": {
160
+ "condition1": {
161
+ "clientmetric": "response_time_ms",
162
+ "aggregate": "avg",
163
+ "condition": ">",
164
+ "value": 300
165
+ },
166
+ "condition2": {
167
+ "clientmetric": "error",
168
+ "aggregate": "percentage",
169
+ "condition": ">",
170
+ "value": 50
171
+ },
172
+ "condition3": {
173
+ "clientmetric": "latency",
174
+ "aggregate": "avg",
175
+ "condition": ">",
176
+ "value": 200,
177
+ "requestName": "GetCustomerDetails"
178
+ }
179
+ }
180
+ },
181
+ "secrets": {
182
+ "secret1": {
183
+ "value": "https://sdk-testing-keyvault.vault.azure.net/secrets/sdk-secret",
184
+ "type": "AKV_SECRET_URI"
185
+ }
186
+ },
187
+ "environmentVariables": {
188
+ "my-variable": "value"
189
+ }
190
+ }
191
+ )
192
+ print(result)
193
+ except HttpResponseError as e:
194
+ print('Service responded with error: {}'.format(e.response.json()))
195
+
196
+ ```
197
+
198
+ ### Uploading .jmx file to a Test
199
+ ```python
200
+ from azure.developer.loadtesting import LoadTestAdministrationClient
201
+ from azure.identity import DefaultAzureCredential
202
+ from azure.core.exceptions import HttpResponseError
203
+
204
+ TEST_ID = "some-test-id"
205
+ FILE_NAME = "some-file-name.jmx"
206
+
207
+ client = LoadTestAdministrationClient(endpoint='<endpoint>', credential=DefaultAzureCredential())
208
+
209
+ try:
210
+
211
+ # uploading .jmx file to a test
212
+ resultPoller = client.begin_upload_test_file(TEST_ID, FILE_NAME, open("sample.jmx", "rb"))
213
+
214
+ # getting result of LRO poller with timeout of 600 secs
215
+ validationResponse = resultPoller.result(600)
216
+ print(validationResponse)
217
+
218
+ except HttpResponseError as e:
219
+ print("Failed with error: {}".format(e.response.json()))
220
+ ```
221
+
222
+ ### Running a Test
223
+ ```python
224
+ from azure.developer.loadtesting import LoadTestRunClient
225
+ from azure.identity import DefaultAzureCredential
226
+ from azure.core.exceptions import HttpResponseError
227
+
228
+ TEST_ID = "some-test-id"
229
+ TEST_RUN_ID = "some-testrun-id"
230
+ DISPLAY_NAME = "my-load-test-run"
231
+
232
+ client = LoadTestRunClient(endpoint='<endpoint>', credential=DefaultAzureCredential())
233
+
234
+ try:
235
+ testRunPoller = client.begin_test_run(
236
+ TEST_RUN_ID,
237
+ {
238
+ "testId": TEST_ID,
239
+ "displayName": "My New Load Test Run",
240
+ }
241
+ )
242
+
243
+ #waiting for test run status to be completed with timeout = 3600 seconds
244
+ result = testRunPoller.result(3600)
245
+
246
+ print(result)
247
+ except HttpResponseError as e:
248
+ print("Failed with error: {}".format(e.response.json()))
249
+ ```
250
+
251
+ ## Next steps
252
+
253
+ More samples can be found [here](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/loadtesting/azure-developer-loadtesting/samples).
254
+
255
+ ## Contributing
256
+
257
+ This project welcomes contributions and suggestions. Most contributions require
258
+ you to agree to a Contributor License Agreement (CLA) declaring that you have
259
+ the right to, and actually do, grant us the rights to use your contribution.
260
+ For details, visit https://cla.microsoft.com.
261
+
262
+ When you submit a pull request, a CLA-bot will automatically determine whether
263
+ you need to provide a CLA and decorate the PR appropriately (e.g., label,
264
+ comment). Simply follow the instructions provided by the bot. You will only
265
+ need to do this once across all repos using our CLA.
266
+
267
+ This project has adopted the
268
+ [Microsoft Open Source Code of Conduct][code_of_conduct]. For more information,
269
+ see the Code of Conduct FAQ or contact opencode@microsoft.com with any
270
+ additional questions or comments.
271
+
272
+ ## Troubleshooting
273
+ More about it is coming soon...
274
+
275
+ <!-- LINKS -->
276
+ [code_of_conduct]: https://opensource.microsoft.com/codeofconduct/
277
+ [authenticate_with_token]: https://docs.microsoft.com/azure/cognitive-services/authentication?tabs=powershell#authenticate-with-an-authentication-token
278
+ [azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#credentials
279
+ [azure_identity_pip]: https://pypi.org/project/azure-identity/
280
+ [default_azure_credential]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#defaultazurecredential
281
+ [pip]: https://pypi.org/project/pip/
282
+ [azure_sub]: https://azure.microsoft.com/free/
283
+ [api_reference_doc]: https://docs.microsoft.com/rest/api/loadtesting/
284
+ [product_documentation]: https://azure.microsoft.com/services/load-testing/
@@ -0,0 +1,258 @@
1
+ # Azure Load Testing client library for Python
2
+ 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.
3
+
4
+ ## Documentation
5
+ Various documentation is available to help you get started
6
+
7
+ <!-- - [Source code][source_code] -->
8
+ - [API reference documentation][api_reference_doc]
9
+ - [Product Documentation][product_documentation]
10
+
11
+ ## Getting started
12
+
13
+ ### Installing the package
14
+
15
+ ```bash
16
+ python -m pip install azure-developer-loadtesting
17
+ ```
18
+
19
+ #### Prequisites
20
+
21
+ - Python 3.7 or later is required to use this package.
22
+ - You need an [Azure subscription][azure_sub] to use this package.
23
+ - An existing Azure Developer LoadTesting instance.
24
+
25
+ #### Create with an Azure Active Directory Credential
26
+
27
+ To use an [Azure Active Directory (AAD) token credential][authenticate_with_token],
28
+ provide an instance of the desired credential type obtained from the
29
+ [azure-identity][azure_identity_credentials] library.
30
+
31
+ To authenticate with AAD, you must first [pip][pip] install [`azure-identity`][azure_identity_pip]
32
+
33
+ After setup, you can choose which type of [credential][azure_identity_credentials] from azure.identity to use.
34
+
35
+ 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.
36
+
37
+ Use the returned token credential to authenticate the client.
38
+
39
+ #### Create the client
40
+
41
+ Azure Developer LoadTesting SDK has 2 sub-clients of the main client (`LoadTestingClient`) to interact with the service, 'administration' and 'test_run'.
42
+
43
+ ```python
44
+ from azure.developer.loadtesting import LoadTestAdministrationClient
45
+
46
+ # for managing authentication and authorization
47
+ # can be installed from pypi, follow: https://pypi.org/project/azure-identity/
48
+ # using DefaultAzureCredentials, read more at: https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity.defaultazurecredential?view=azure-python
49
+ from azure.identity import DefaultAzureCredential
50
+
51
+ client = LoadTestAdministrationClient(endpoint='<endpoint>', credential=DefaultAzureCredential())
52
+ ```
53
+
54
+ `<endpoint>` refers to the data-plane endpoint/URL of the resource.
55
+
56
+ ## Key concepts
57
+
58
+ 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
59
+
60
+ - `LoadTestAdministrationClient` (`azure.developer.loadtesting.LoadTestAdministrationClient`)
61
+ - `LoadTestRunClient` (`azure.developer.loadtesting.LoadTestRunClient`)
62
+
63
+ These two clients also have there asynchronous counterparts, which are
64
+ - `LoadTestAdministrationClient` (`azure.developer.loadtesting.aio.LoadTestAdministrationClient`)
65
+ - `LoadTestRunClient` (`azure.developer.loadtesting.aio.LoadTestRunClient`)
66
+
67
+ ### Load Test Administration Client
68
+
69
+ The `LoadTestAdministrationClient` is used to administer and configure the load tests, app components and metrics.
70
+
71
+ #### Test
72
+
73
+ 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.
74
+
75
+ #### App Component
76
+
77
+ 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.
78
+
79
+ #### Metrics
80
+
81
+ During a load test, Azure Load Testing collects metrics about the test execution. There are two types of metrics:
82
+
83
+ 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.
84
+
85
+ 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.
86
+
87
+ ### Test Run Client
88
+
89
+ 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.
90
+
91
+ ### Data-Plane Endpoint
92
+
93
+ Data-plane of Azure Load Testing resources is addressable using the following URL format:
94
+
95
+ `00000000-0000-0000-0000-000000000000.aaa.cnt-prod.loadtesting.azure.com`
96
+
97
+ 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.
98
+
99
+ The data-plane endpoint is obtained from Control Plane APIs.
100
+
101
+ **Example:** `1234abcd-12ab-12ab-12ab-123456abcdef.eus.cnt-prod.loadtesting.azure.com`
102
+
103
+ In the above example, `eus` represents the Azure region `East US`.
104
+
105
+ ## Examples
106
+
107
+ ### Creating a load test
108
+ ```python
109
+ from azure.developer.loadtesting import LoadTestAdministrationClient
110
+ from azure.identity import DefaultAzureCredential
111
+ from azure.core.exceptions import HttpResponseError
112
+ import os
113
+
114
+ TEST_ID = "some-test-id"
115
+ DISPLAY_NAME = "my-load-test"
116
+
117
+ # set SUBSCRIPTION_ID as an environment variable
118
+ SUBSCRIPTION_ID = os.environ["SUBSCRIPTION_ID"]
119
+
120
+ client = LoadTestAdministrationClient(endpoint='<endpoint>', credential=DefaultAzureCredential())
121
+
122
+ try:
123
+ result = client.create_or_update_test(
124
+ TEST_ID,
125
+ {
126
+ "description": "",
127
+ "displayName": "My New Load Test",
128
+ "loadTestConfig": {
129
+ "engineInstances": 1,
130
+ "splitAllCSVs": False,
131
+ },
132
+ "passFailCriteria": {
133
+ "passFailMetrics": {
134
+ "condition1": {
135
+ "clientmetric": "response_time_ms",
136
+ "aggregate": "avg",
137
+ "condition": ">",
138
+ "value": 300
139
+ },
140
+ "condition2": {
141
+ "clientmetric": "error",
142
+ "aggregate": "percentage",
143
+ "condition": ">",
144
+ "value": 50
145
+ },
146
+ "condition3": {
147
+ "clientmetric": "latency",
148
+ "aggregate": "avg",
149
+ "condition": ">",
150
+ "value": 200,
151
+ "requestName": "GetCustomerDetails"
152
+ }
153
+ }
154
+ },
155
+ "secrets": {
156
+ "secret1": {
157
+ "value": "https://sdk-testing-keyvault.vault.azure.net/secrets/sdk-secret",
158
+ "type": "AKV_SECRET_URI"
159
+ }
160
+ },
161
+ "environmentVariables": {
162
+ "my-variable": "value"
163
+ }
164
+ }
165
+ )
166
+ print(result)
167
+ except HttpResponseError as e:
168
+ print('Service responded with error: {}'.format(e.response.json()))
169
+
170
+ ```
171
+
172
+ ### Uploading .jmx file to a Test
173
+ ```python
174
+ from azure.developer.loadtesting import LoadTestAdministrationClient
175
+ from azure.identity import DefaultAzureCredential
176
+ from azure.core.exceptions import HttpResponseError
177
+
178
+ TEST_ID = "some-test-id"
179
+ FILE_NAME = "some-file-name.jmx"
180
+
181
+ client = LoadTestAdministrationClient(endpoint='<endpoint>', credential=DefaultAzureCredential())
182
+
183
+ try:
184
+
185
+ # uploading .jmx file to a test
186
+ resultPoller = client.begin_upload_test_file(TEST_ID, FILE_NAME, open("sample.jmx", "rb"))
187
+
188
+ # getting result of LRO poller with timeout of 600 secs
189
+ validationResponse = resultPoller.result(600)
190
+ print(validationResponse)
191
+
192
+ except HttpResponseError as e:
193
+ print("Failed with error: {}".format(e.response.json()))
194
+ ```
195
+
196
+ ### Running a Test
197
+ ```python
198
+ from azure.developer.loadtesting import LoadTestRunClient
199
+ from azure.identity import DefaultAzureCredential
200
+ from azure.core.exceptions import HttpResponseError
201
+
202
+ TEST_ID = "some-test-id"
203
+ TEST_RUN_ID = "some-testrun-id"
204
+ DISPLAY_NAME = "my-load-test-run"
205
+
206
+ client = LoadTestRunClient(endpoint='<endpoint>', credential=DefaultAzureCredential())
207
+
208
+ try:
209
+ testRunPoller = client.begin_test_run(
210
+ TEST_RUN_ID,
211
+ {
212
+ "testId": TEST_ID,
213
+ "displayName": "My New Load Test Run",
214
+ }
215
+ )
216
+
217
+ #waiting for test run status to be completed with timeout = 3600 seconds
218
+ result = testRunPoller.result(3600)
219
+
220
+ print(result)
221
+ except HttpResponseError as e:
222
+ print("Failed with error: {}".format(e.response.json()))
223
+ ```
224
+
225
+ ## Next steps
226
+
227
+ More samples can be found [here](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/loadtesting/azure-developer-loadtesting/samples).
228
+
229
+ ## Contributing
230
+
231
+ This project welcomes contributions and suggestions. Most contributions require
232
+ you to agree to a Contributor License Agreement (CLA) declaring that you have
233
+ the right to, and actually do, grant us the rights to use your contribution.
234
+ For details, visit https://cla.microsoft.com.
235
+
236
+ When you submit a pull request, a CLA-bot will automatically determine whether
237
+ you need to provide a CLA and decorate the PR appropriately (e.g., label,
238
+ comment). Simply follow the instructions provided by the bot. You will only
239
+ need to do this once across all repos using our CLA.
240
+
241
+ This project has adopted the
242
+ [Microsoft Open Source Code of Conduct][code_of_conduct]. For more information,
243
+ see the Code of Conduct FAQ or contact opencode@microsoft.com with any
244
+ additional questions or comments.
245
+
246
+ ## Troubleshooting
247
+ More about it is coming soon...
248
+
249
+ <!-- LINKS -->
250
+ [code_of_conduct]: https://opensource.microsoft.com/codeofconduct/
251
+ [authenticate_with_token]: https://docs.microsoft.com/azure/cognitive-services/authentication?tabs=powershell#authenticate-with-an-authentication-token
252
+ [azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#credentials
253
+ [azure_identity_pip]: https://pypi.org/project/azure-identity/
254
+ [default_azure_credential]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#defaultazurecredential
255
+ [pip]: https://pypi.org/project/pip/
256
+ [azure_sub]: https://azure.microsoft.com/free/
257
+ [api_reference_doc]: https://docs.microsoft.com/rest/api/loadtesting/
258
+ [product_documentation]: https://azure.microsoft.com/services/load-testing/
@@ -0,0 +1 @@
1
+ __path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
@@ -0,0 +1 @@
1
+ __path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
@@ -0,0 +1,10 @@
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
+ from ._client import LoadTestAdministrationClient, LoadTestRunClient
7
+ from ._version import VERSION
8
+
9
+ __version__ = VERSION
10
+ __all__ = ["LoadTestAdministrationClient", "LoadTestRunClient"]