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,72 @@
1
+ # Release History
2
+
3
+ ## 1.0.0 (2023-03-07)
4
+
5
+ ### Breaking Changes
6
+ - moved all operations under `azure.developer.loadtesting.LoadTestingClient.test_run` to `azure.developer.loadtesting.LoadTestRunClient`
7
+ - moved all operations under `azure.developer.loadtesting.LoadTestingClient.administration` to `azure.developer.loadtesting.LoadTestAdministrationClient`
8
+ - moved all operations under `azure.developer.loadtesting.aio.LoadTestingClient.test_run` to `azure.developer.loadtesting.aio.LoadTestRunClient`
9
+ - moved all operations under `azure.developer.loadtesting.aio.LoadTestingClient.administration` to `azure.developer.loadtesting.aio.LoadTestAdministrationClient`
10
+ - removed `azure.developer.loadtesting.LoadTestingClient.administration.upload_test_file` as it moved all functionality to `azure.developer.loadtesting.LoadTestAdministrationClient.begin_upload_test_file`
11
+ - 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`
12
+ - 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`
13
+ - 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`
14
+ - 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`
15
+ - removed `azure.developer.loadtesting.LoadTestingClient.test_run.list_metric_definitions` as it moved all functionality to `azure.developer.loadtesting.LoadTestRunClient.get_metric_definitions`
16
+ - 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`
17
+ - removed `azure.developer.loadtesting.LoadTestingClient.test_run.list_metric_namespaces` as it moved all functionality to `azure.developer.loadtesting.LoadTestRunClient.get_metric_namespaces`
18
+
19
+ ### Other Changes
20
+ - bumped version to stable `1.0.0`
21
+ - updated README.md
22
+
23
+ ## 1.0.0b3 (2023-01-01)
24
+
25
+ ### Features Added
26
+ - Method added `azure.developer.loadtesting.LoadTestingClient.test_run.list_metric_namespaces`
27
+ - Method added `azure.developer.loadtesting.LoadTestingClient.test_run.list_metric_definitions`
28
+ - Method added `azure.developer.loadtesting.LoadTestingClient.test_run.list_metrics`
29
+ - Method added `azure.developer.loadtesting.LoadTestingClient.test_run.create_or_update_app_components`
30
+ - Method added `azure.developer.loadtesting.LoadTestingClient.test_run.get_app_components`
31
+ - Method added `azure.developer.loadtesting.LoadTestingClient.test_run.create_or_update_server_metrics_config`
32
+ - Method added `azure.developer.loadtesting.LoadTestingClient.test_run.get_server_metrics_config`
33
+ - Method added `azure.developer.loadtesting.LoadTestingClient.administration.begin_upload_test_file`
34
+ - Method added `azure.developer.loadtesting.LoadTestingClient.test_run.begin_test_run`
35
+ - Method added `azure.developer.loadtesting.LoadTestingClient.test_run.begin_test_run_status`
36
+ - Method added `azure.developer.loadtesting.aio.LoadTestingClient.test_run.list_metric_namespaces`
37
+ - Method added `azure.developer.loadtesting.aio.LoadTestingClient.test_run.list_metric_definitions`
38
+ - Method added `azure.developer.loadtesting.aio.LoadTestingClient.test_run.list_metrics`
39
+ - Method added `azure.developer.loadtesting.aio.LoadTestingClient.test_run.create_or_update_app_components`
40
+ - Method added `azure.developer.loadtesting.aio.LoadTestingClient.test_run.get_app_components`
41
+ - Method added `azure.developer.loadtesting.aio.LoadTestingClient.test_run.create_or_update_server_metrics_config`
42
+ - Method added `azure.developer.loadtesting.aio.LoadTestingClient.test_run.get_server_metrics_config`
43
+ - Method added `azure.developer.loadtesting.aio.LoadTestingClient.administration.begin_upload_test_file`
44
+ - Method added `azure.developer.loadtesting.aio.LoadTestingClient.test_run.begin_test_run_status`
45
+ - Method added `azure.developer.loadtesting.aio.LoadTestingClient.test_run.get_metric_dimension_values`
46
+ - Method added `azure.developer.loadtesting.aio.LoadTestingClient.test_run.begin_test_run`
47
+
48
+
49
+ ### Breaking Changes
50
+ - Changed subclients `load_test_runs` and `load_test_adminsitration` to `test_run` and `adminsitrative` respectively
51
+ - Removed `continuation_token` as a parameter for method `azure.developer.loadtesting.aio.LoadTestingClient.test_run.list_test_runs`
52
+ - Removed `continuation_token` as a parameter for method `azure.developer.loadtesting.LoadTestingClient.test_run.list_test_runs`,
53
+ - Removed `continuation_token` as a parameter for method `azure.developer.loadtesting.aio.LoadTestingClient.administration.list_test_files`
54
+ - Removed `continuation_token` as a parameter for method `azure.developer.loadtesting.LoadTestingClient.administration.list_test_files`
55
+ - Removed `continuation_token` as a parameter for method `azure.developer.loadtesting.aio.LoadTestingClient.administration.list_tests`
56
+ - Removed `continuation_token` as a parameter for method `azure.developer.loadtesting.LoadTestingClient.administration.list_tests`
57
+
58
+ ### Other Changes
59
+ - Updated README
60
+
61
+ ## 1.0.0b2 (2022-10-17)
62
+
63
+ ### Bug Fixed
64
+ - `delete_app_components` method from `azure.developer.loadtesting.LoadTestingClient.load_test_administration.delete_app_components` was not discoverable in expected location, fixed discoverability.
65
+
66
+ ### Other Changes
67
+ - Updated README
68
+
69
+ ## 1.0.0b1 (2022-07-28)
70
+
71
+ ### Features Added
72
+ - 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,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,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"]