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.
- azure-developer-loadtesting-1.0.0/CHANGELOG.md +72 -0
- azure-developer-loadtesting-1.0.0/LICENSE +21 -0
- azure-developer-loadtesting-1.0.0/MANIFEST.in +7 -0
- azure-developer-loadtesting-1.0.0/PKG-INFO +281 -0
- azure-developer-loadtesting-1.0.0/README.md +258 -0
- azure-developer-loadtesting-1.0.0/azure/__init__.py +1 -0
- azure-developer-loadtesting-1.0.0/azure/developer/__init__.py +1 -0
- azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/__init__.py +10 -0
- azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_client.py +97 -0
- azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/__init__.py +26 -0
- azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/_client.py +88 -0
- azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/_configuration.py +71 -0
- azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/_patch.py +24 -0
- azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/_serialization.py +1996 -0
- azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/_vendor.py +20 -0
- azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/_version.py +9 -0
- azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/aio/__init__.py +23 -0
- azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/aio/_client.py +88 -0
- azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/aio/_configuration.py +71 -0
- azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/aio/_patch.py +23 -0
- azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/aio/_vendor.py +17 -0
- azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/aio/operations/__init__.py +21 -0
- azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/aio/operations/_operations.py +6517 -0
- azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/aio/operations/_patch.py +187 -0
- azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/operations/__init__.py +21 -0
- azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/operations/_operations.py +7242 -0
- azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_generated/operations/_patch.py +195 -0
- azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/_version.py +6 -0
- azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/aio/__init__.py +9 -0
- azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/aio/_client.py +107 -0
- azure-developer-loadtesting-1.0.0/azure/developer/loadtesting/py.typed +1 -0
- azure-developer-loadtesting-1.0.0/azure_developer_loadtesting.egg-info/PKG-INFO +281 -0
- azure-developer-loadtesting-1.0.0/azure_developer_loadtesting.egg-info/SOURCES.txt +52 -0
- azure-developer-loadtesting-1.0.0/azure_developer_loadtesting.egg-info/dependency_links.txt +1 -0
- azure-developer-loadtesting-1.0.0/azure_developer_loadtesting.egg-info/not-zip-safe +1 -0
- azure-developer-loadtesting-1.0.0/azure_developer_loadtesting.egg-info/requires.txt +5 -0
- azure-developer-loadtesting-1.0.0/azure_developer_loadtesting.egg-info/top_level.txt +1 -0
- azure-developer-loadtesting-1.0.0/pyproject.toml +6 -0
- azure-developer-loadtesting-1.0.0/samples/begin_test_run.py +52 -0
- azure-developer-loadtesting-1.0.0/samples/create_or_update_app_components.py +57 -0
- azure-developer-loadtesting-1.0.0/samples/create_or_update_test_function.py +84 -0
- azure-developer-loadtesting-1.0.0/samples/delete_load_test_function.py +46 -0
- azure-developer-loadtesting-1.0.0/samples/delete_load_test_run.py +39 -0
- azure-developer-loadtesting-1.0.0/samples/get_metrics.py +64 -0
- azure-developer-loadtesting-1.0.0/samples/upload_test_file.py +45 -0
- azure-developer-loadtesting-1.0.0/setup.cfg +4 -0
- azure-developer-loadtesting-1.0.0/setup.py +71 -0
- azure-developer-loadtesting-1.0.0/tests/conftest.py +60 -0
- azure-developer-loadtesting-1.0.0/tests/test_admin_ops.py +284 -0
- azure-developer-loadtesting-1.0.0/tests/test_async_admin_ops.py +286 -0
- azure-developer-loadtesting-1.0.0/tests/test_async_run_ops.py +286 -0
- azure-developer-loadtesting-1.0.0/tests/test_run_ops.py +289 -0
- azure-developer-loadtesting-1.0.0/tests/testcase.py +41 -0
- azure-developer-loadtesting-1.0.0/tests/testcase_async.py +26 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
# coding: utf-8
|
|
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
|
+
import os
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
import pytest
|
|
11
|
+
from azure.core.exceptions import HttpResponseError, ResourceNotFoundError
|
|
12
|
+
|
|
13
|
+
from testcase import LoadtestingPowerShellPreparer
|
|
14
|
+
from testcase_async import LoadtestingAsyncTest
|
|
15
|
+
from devtools_testutils import set_bodiless_matcher, set_custom_default_matcher
|
|
16
|
+
from devtools_testutils.aio import recorded_by_proxy_async
|
|
17
|
+
|
|
18
|
+
DISPLAY_NAME = "TestingResourcePyTest"
|
|
19
|
+
NON_EXISTING_RESOURCE = "nonexistingresource"
|
|
20
|
+
class TestRunOps(LoadtestingAsyncTest):
|
|
21
|
+
|
|
22
|
+
async def setup_loadtest(self, endpoint, test_id):
|
|
23
|
+
admin_client = self.create_administration_client(endpoint)
|
|
24
|
+
|
|
25
|
+
await admin_client.create_or_update_test(
|
|
26
|
+
test_id,
|
|
27
|
+
{
|
|
28
|
+
"description": "",
|
|
29
|
+
"displayName": DISPLAY_NAME,
|
|
30
|
+
"loadTestConfig": {
|
|
31
|
+
"engineSize": "m",
|
|
32
|
+
"engineInstances": 1,
|
|
33
|
+
"splitAllCSVs": False,
|
|
34
|
+
},
|
|
35
|
+
"secrets": {},
|
|
36
|
+
"environmentVariables": {},
|
|
37
|
+
"passFailCriteria": {"passFailMetrics": {}},
|
|
38
|
+
"keyvaultReferenceIdentityType": "SystemAssigned",
|
|
39
|
+
"keyvaultReferenceIdentityId": None,
|
|
40
|
+
}
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
validation_poller = await admin_client.begin_upload_test_file(
|
|
44
|
+
test_id, "sample.jmx", open(os.path.join(os.path.dirname(__file__), "sample.jmx"), "rb")
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
await validation_poller.result()
|
|
48
|
+
|
|
49
|
+
async def setup_test_run(self, endpoint, test_id, test_run_id):
|
|
50
|
+
await self.setup_loadtest(endpoint, test_id)
|
|
51
|
+
|
|
52
|
+
run_client = self.create_run_client(endpoint)
|
|
53
|
+
|
|
54
|
+
run_poller = await run_client.begin_test_run(
|
|
55
|
+
test_run_id,
|
|
56
|
+
{
|
|
57
|
+
"testId": test_id,
|
|
58
|
+
"displayName": "My New Load Test Run from PyTest",
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
await run_poller.result()
|
|
62
|
+
|
|
63
|
+
@LoadtestingPowerShellPreparer()
|
|
64
|
+
@recorded_by_proxy_async
|
|
65
|
+
async def test_test_run_poller(self, loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id):
|
|
66
|
+
set_bodiless_matcher()
|
|
67
|
+
|
|
68
|
+
await self.setup_loadtest(loadtesting_endpoint, loadtesting_test_id)
|
|
69
|
+
|
|
70
|
+
run_client = self.create_run_client(loadtesting_endpoint)
|
|
71
|
+
|
|
72
|
+
run_poller = await run_client.begin_test_run(
|
|
73
|
+
loadtesting_test_run_id,
|
|
74
|
+
{
|
|
75
|
+
"testId": loadtesting_test_id,
|
|
76
|
+
"displayName": "My New Load Test Run from PyTest",
|
|
77
|
+
}
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
result = await run_poller.result()
|
|
81
|
+
assert result is not None
|
|
82
|
+
|
|
83
|
+
assert run_poller.status() is not None
|
|
84
|
+
assert run_poller.done() is True
|
|
85
|
+
|
|
86
|
+
@LoadtestingPowerShellPreparer()
|
|
87
|
+
@recorded_by_proxy_async
|
|
88
|
+
async def test_get_test_run(self, loadtesting_endpoint, loadtesting_test_run_id):
|
|
89
|
+
set_bodiless_matcher()
|
|
90
|
+
|
|
91
|
+
run_client = self.create_run_client(loadtesting_endpoint)
|
|
92
|
+
|
|
93
|
+
result = await run_client.get_test_run(loadtesting_test_run_id)
|
|
94
|
+
assert result is not None
|
|
95
|
+
|
|
96
|
+
with pytest.raises(ResourceNotFoundError):
|
|
97
|
+
await run_client.get_test_run(NON_EXISTING_RESOURCE)
|
|
98
|
+
|
|
99
|
+
@LoadtestingPowerShellPreparer()
|
|
100
|
+
@recorded_by_proxy_async
|
|
101
|
+
async def test_delete_test_run(self, loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id):
|
|
102
|
+
set_bodiless_matcher()
|
|
103
|
+
|
|
104
|
+
await self.setup_test_run(loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id)
|
|
105
|
+
|
|
106
|
+
run_client = self.create_run_client(loadtesting_endpoint)
|
|
107
|
+
|
|
108
|
+
result = await run_client.delete_test_run(loadtesting_test_run_id)
|
|
109
|
+
assert result is None
|
|
110
|
+
|
|
111
|
+
with pytest.raises(ResourceNotFoundError):
|
|
112
|
+
await run_client.delete_test_run(NON_EXISTING_RESOURCE)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
@LoadtestingPowerShellPreparer()
|
|
116
|
+
@recorded_by_proxy_async
|
|
117
|
+
async def test_get_test_run_file(self, loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id):
|
|
118
|
+
set_bodiless_matcher()
|
|
119
|
+
|
|
120
|
+
await self.setup_test_run(loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id)
|
|
121
|
+
|
|
122
|
+
run_client = self.create_run_client(loadtesting_endpoint)
|
|
123
|
+
|
|
124
|
+
result = await run_client.get_test_run_file(loadtesting_test_run_id, "sample.jmx")
|
|
125
|
+
assert result is not None
|
|
126
|
+
|
|
127
|
+
with pytest.raises(ResourceNotFoundError):
|
|
128
|
+
await run_client.get_test_run_file(NON_EXISTING_RESOURCE, "sample.jmx")
|
|
129
|
+
|
|
130
|
+
with pytest.raises(HttpResponseError):
|
|
131
|
+
await run_client.get_test_run_file(loadtesting_test_run_id, NON_EXISTING_RESOURCE)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
@LoadtestingPowerShellPreparer()
|
|
135
|
+
@recorded_by_proxy_async
|
|
136
|
+
async def test_list_test_runs(self, loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id):
|
|
137
|
+
set_bodiless_matcher()
|
|
138
|
+
|
|
139
|
+
await self.setup_test_run(loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id)
|
|
140
|
+
|
|
141
|
+
run_client = self.create_run_client(loadtesting_endpoint)
|
|
142
|
+
|
|
143
|
+
result = run_client.list_test_runs()
|
|
144
|
+
assert result is not None
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
@LoadtestingPowerShellPreparer()
|
|
148
|
+
@recorded_by_proxy_async
|
|
149
|
+
async def test_stop_test_run(self, loadtesting_endpoint):
|
|
150
|
+
set_bodiless_matcher()
|
|
151
|
+
|
|
152
|
+
await self.setup_loadtest(loadtesting_endpoint, "new-load-test-from-pytest-aio-abc")
|
|
153
|
+
run_client = self.create_run_client(loadtesting_endpoint)
|
|
154
|
+
|
|
155
|
+
try:
|
|
156
|
+
await run_client.delete_test_run("my-new-test-run-from-pytest-aio-abc")
|
|
157
|
+
except ResourceNotFoundError:
|
|
158
|
+
pass
|
|
159
|
+
|
|
160
|
+
run_poller = await run_client.begin_test_run(
|
|
161
|
+
"my-new-test-run-from-pytest-aio-abc",
|
|
162
|
+
{
|
|
163
|
+
"testId": "new-load-test-from-pytest-aio-abc",
|
|
164
|
+
"displayName": "My New Load Test Run from PyTest",
|
|
165
|
+
}
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
result = await run_client.stop_test_run("my-new-test-run-from-pytest-aio-abc")
|
|
169
|
+
assert result is not None
|
|
170
|
+
|
|
171
|
+
@LoadtestingPowerShellPreparer()
|
|
172
|
+
@recorded_by_proxy_async
|
|
173
|
+
async def test_get_metrics(self, loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id):
|
|
174
|
+
set_bodiless_matcher()
|
|
175
|
+
|
|
176
|
+
await self.setup_test_run(loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id)
|
|
177
|
+
run_client = self.create_run_client(loadtesting_endpoint)
|
|
178
|
+
|
|
179
|
+
test_run_response = await run_client.get_test_run(loadtesting_test_run_id)
|
|
180
|
+
assert test_run_response is not None
|
|
181
|
+
|
|
182
|
+
metric_namespaces = await run_client.get_metric_namespaces(loadtesting_test_run_id)
|
|
183
|
+
assert metric_namespaces is not None
|
|
184
|
+
|
|
185
|
+
metric_definitions = await run_client.get_metric_definitions(loadtesting_test_run_id,
|
|
186
|
+
metric_namespace=metric_namespaces["value"][0]["name"])
|
|
187
|
+
assert metric_definitions is not None
|
|
188
|
+
|
|
189
|
+
metrics = run_client.list_metrics(
|
|
190
|
+
test_run_id=loadtesting_test_run_id,
|
|
191
|
+
metric_name=metric_definitions["value"][0]["name"],
|
|
192
|
+
metric_namespace=metric_namespaces["value"][0]["name"],
|
|
193
|
+
time_interval=test_run_response["startDateTime"] + "/" + test_run_response["endDateTime"]
|
|
194
|
+
)
|
|
195
|
+
assert metrics is not None
|
|
196
|
+
|
|
197
|
+
@LoadtestingPowerShellPreparer()
|
|
198
|
+
@recorded_by_proxy_async
|
|
199
|
+
async def test_create_or_update_app_component(self, loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id, loadtesting_resource_id):
|
|
200
|
+
set_bodiless_matcher()
|
|
201
|
+
|
|
202
|
+
await self.setup_test_run(loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id)
|
|
203
|
+
|
|
204
|
+
run_client = self.create_run_client(loadtesting_endpoint)
|
|
205
|
+
|
|
206
|
+
result = await run_client.create_or_update_app_components(
|
|
207
|
+
loadtesting_test_run_id,
|
|
208
|
+
{
|
|
209
|
+
"components":
|
|
210
|
+
{
|
|
211
|
+
loadtesting_resource_id:
|
|
212
|
+
{
|
|
213
|
+
"resourceId": loadtesting_resource_id,
|
|
214
|
+
"resourceName": "App-Service-Sample-Demo",
|
|
215
|
+
"resourceType": "Microsoft.Web/sites",
|
|
216
|
+
"kind": "web"
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
)
|
|
221
|
+
assert result is not None
|
|
222
|
+
|
|
223
|
+
with pytest.raises(ResourceNotFoundError):
|
|
224
|
+
await run_client.create_or_update_app_components(
|
|
225
|
+
NON_EXISTING_RESOURCE,
|
|
226
|
+
{
|
|
227
|
+
"components":
|
|
228
|
+
{
|
|
229
|
+
loadtesting_resource_id:
|
|
230
|
+
{
|
|
231
|
+
"resourceId": loadtesting_resource_id,
|
|
232
|
+
"resourceName": "App-Service-Sample-Demo",
|
|
233
|
+
"resourceType": "Microsoft.Web/sites",
|
|
234
|
+
"kind": "web"
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
@LoadtestingPowerShellPreparer()
|
|
241
|
+
@recorded_by_proxy_async
|
|
242
|
+
async def test_get_app_component(self, loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id, loadtesting_resource_id):
|
|
243
|
+
set_bodiless_matcher()
|
|
244
|
+
await self.setup_test_run(loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id)
|
|
245
|
+
|
|
246
|
+
run_client = self.create_run_client(loadtesting_endpoint)
|
|
247
|
+
|
|
248
|
+
result = await run_client.get_app_components(loadtesting_test_run_id)
|
|
249
|
+
assert result is not None
|
|
250
|
+
|
|
251
|
+
@LoadtestingPowerShellPreparer()
|
|
252
|
+
@recorded_by_proxy_async
|
|
253
|
+
async def test_create_or_update_server_metrics_config(self, loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id, loadtesting_resource_id):
|
|
254
|
+
set_bodiless_matcher()
|
|
255
|
+
await self.setup_test_run(loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id)
|
|
256
|
+
|
|
257
|
+
run_client = self.create_run_client(loadtesting_endpoint)
|
|
258
|
+
|
|
259
|
+
result = await run_client.create_or_update_server_metrics_config(
|
|
260
|
+
loadtesting_test_run_id,
|
|
261
|
+
{
|
|
262
|
+
"metrics": {
|
|
263
|
+
loadtesting_resource_id: {
|
|
264
|
+
"resourceId": loadtesting_resource_id,
|
|
265
|
+
"metricNamespace": "microsoft.insights/components",
|
|
266
|
+
"displayDescription": "sample description",
|
|
267
|
+
"name": "requests/duration",
|
|
268
|
+
"aggregation": "Average",
|
|
269
|
+
"unit": None,
|
|
270
|
+
"resourceType": "microsoft.insights/components"
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
)
|
|
275
|
+
assert result is not None
|
|
276
|
+
|
|
277
|
+
@LoadtestingPowerShellPreparer()
|
|
278
|
+
@recorded_by_proxy_async
|
|
279
|
+
async def test_get_server_metrics_config(self, loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id, loadtesting_resource_id):
|
|
280
|
+
set_bodiless_matcher()
|
|
281
|
+
await self.setup_test_run(loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id)
|
|
282
|
+
|
|
283
|
+
run_client = self.create_run_client(loadtesting_endpoint)
|
|
284
|
+
|
|
285
|
+
result = await run_client.get_server_metrics_config(loadtesting_test_run_id)
|
|
286
|
+
assert result is not None
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
# coding: utf-8
|
|
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
|
+
import os
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
import pytest
|
|
11
|
+
from azure.core.exceptions import HttpResponseError, ResourceNotFoundError
|
|
12
|
+
|
|
13
|
+
from testcase import LoadtestingPowerShellPreparer, LoadtestingTest
|
|
14
|
+
from devtools_testutils import recorded_by_proxy, set_bodiless_matcher, set_custom_default_matcher
|
|
15
|
+
|
|
16
|
+
DISPLAY_NAME = "TestingResourcePyTest"
|
|
17
|
+
NON_EXISTING_RESOURCE = "nonexistingresource"
|
|
18
|
+
|
|
19
|
+
class TestRunOps(LoadtestingTest):
|
|
20
|
+
|
|
21
|
+
def setup_loadtest(self, endpoint, test_id):
|
|
22
|
+
admin_client = self.create_administration_client(endpoint)
|
|
23
|
+
|
|
24
|
+
admin_client.create_or_update_test(
|
|
25
|
+
test_id,
|
|
26
|
+
{
|
|
27
|
+
"description": "",
|
|
28
|
+
"displayName": DISPLAY_NAME,
|
|
29
|
+
"loadTestConfig": {
|
|
30
|
+
"engineSize": "m",
|
|
31
|
+
"engineInstances": 1,
|
|
32
|
+
"splitAllCSVs": False,
|
|
33
|
+
},
|
|
34
|
+
"secrets": {},
|
|
35
|
+
"environmentVariables": {},
|
|
36
|
+
"passFailCriteria": {"passFailMetrics": {}},
|
|
37
|
+
"keyvaultReferenceIdentityType": "SystemAssigned",
|
|
38
|
+
"keyvaultReferenceIdentityId": None,
|
|
39
|
+
}
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
validation_poller = admin_client.begin_upload_test_file(
|
|
43
|
+
test_id, "sample.jmx", open(os.path.join(os.path.dirname(__file__), "sample.jmx"), "rb")
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
validation_poller.result(6000)
|
|
47
|
+
|
|
48
|
+
def setup_test_run(self, endpoint, test_id, test_run_id):
|
|
49
|
+
self.setup_loadtest(endpoint, test_id)
|
|
50
|
+
|
|
51
|
+
run_client = self.create_run_client(endpoint)
|
|
52
|
+
|
|
53
|
+
run_poller = run_client.begin_test_run(
|
|
54
|
+
test_run_id,
|
|
55
|
+
{
|
|
56
|
+
"testId": test_id,
|
|
57
|
+
"displayName": "My New Load Test Run from PyTest",
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
run_poller.result(10800)
|
|
61
|
+
|
|
62
|
+
@LoadtestingPowerShellPreparer()
|
|
63
|
+
@recorded_by_proxy
|
|
64
|
+
def test_test_run_poller(self, loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id):
|
|
65
|
+
set_bodiless_matcher()
|
|
66
|
+
|
|
67
|
+
self.setup_loadtest(loadtesting_endpoint, loadtesting_test_id)
|
|
68
|
+
|
|
69
|
+
run_client = self.create_run_client(loadtesting_endpoint)
|
|
70
|
+
|
|
71
|
+
run_poller = run_client.begin_test_run(
|
|
72
|
+
loadtesting_test_run_id,
|
|
73
|
+
{
|
|
74
|
+
"testId": loadtesting_test_id,
|
|
75
|
+
"displayName": "My New Load Test Run from PyTest",
|
|
76
|
+
},
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
result = run_poller.result(10800)
|
|
80
|
+
assert result is not None
|
|
81
|
+
|
|
82
|
+
assert run_poller.status() is not None
|
|
83
|
+
assert run_poller.done() is True
|
|
84
|
+
|
|
85
|
+
@LoadtestingPowerShellPreparer()
|
|
86
|
+
@recorded_by_proxy
|
|
87
|
+
def test_get_test_run(self, loadtesting_endpoint, loadtesting_test_run_id):
|
|
88
|
+
set_bodiless_matcher()
|
|
89
|
+
|
|
90
|
+
run_client = self.create_run_client(loadtesting_endpoint)
|
|
91
|
+
|
|
92
|
+
result = run_client.get_test_run(loadtesting_test_run_id)
|
|
93
|
+
assert result is not None
|
|
94
|
+
|
|
95
|
+
with pytest.raises(ResourceNotFoundError):
|
|
96
|
+
run_client.get_test_run(NON_EXISTING_RESOURCE)
|
|
97
|
+
|
|
98
|
+
@LoadtestingPowerShellPreparer()
|
|
99
|
+
@recorded_by_proxy
|
|
100
|
+
def test_delete_test_run(self, loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id):
|
|
101
|
+
set_bodiless_matcher()
|
|
102
|
+
|
|
103
|
+
self.setup_test_run(loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id)
|
|
104
|
+
|
|
105
|
+
run_client = self.create_run_client(loadtesting_endpoint)
|
|
106
|
+
|
|
107
|
+
result = run_client.delete_test_run(loadtesting_test_run_id)
|
|
108
|
+
assert result is None
|
|
109
|
+
|
|
110
|
+
with pytest.raises(ResourceNotFoundError):
|
|
111
|
+
run_client.delete_test_run(NON_EXISTING_RESOURCE)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
@LoadtestingPowerShellPreparer()
|
|
115
|
+
@recorded_by_proxy
|
|
116
|
+
def test_get_test_run_file(self, loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id):
|
|
117
|
+
set_bodiless_matcher()
|
|
118
|
+
|
|
119
|
+
self.setup_test_run(loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id)
|
|
120
|
+
|
|
121
|
+
run_client = self.create_run_client(loadtesting_endpoint)
|
|
122
|
+
|
|
123
|
+
result = run_client.get_test_run_file(loadtesting_test_run_id, "sample.jmx")
|
|
124
|
+
assert result is not None
|
|
125
|
+
|
|
126
|
+
with pytest.raises(ResourceNotFoundError):
|
|
127
|
+
run_client.get_test_run_file(NON_EXISTING_RESOURCE, "sample.jmx")
|
|
128
|
+
|
|
129
|
+
with pytest.raises(HttpResponseError):
|
|
130
|
+
run_client.get_test_run_file(loadtesting_test_run_id, NON_EXISTING_RESOURCE)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
@LoadtestingPowerShellPreparer()
|
|
134
|
+
@recorded_by_proxy
|
|
135
|
+
def test_list_test_runs(self, loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id):
|
|
136
|
+
set_bodiless_matcher()
|
|
137
|
+
|
|
138
|
+
self.setup_test_run(loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id)
|
|
139
|
+
|
|
140
|
+
run_client = self.create_run_client(loadtesting_endpoint)
|
|
141
|
+
|
|
142
|
+
result = run_client.list_test_runs()
|
|
143
|
+
assert result is not None
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
@LoadtestingPowerShellPreparer()
|
|
147
|
+
@recorded_by_proxy
|
|
148
|
+
def test_stop_test_run(self, loadtesting_endpoint):
|
|
149
|
+
set_bodiless_matcher()
|
|
150
|
+
|
|
151
|
+
self.setup_loadtest(loadtesting_endpoint, "new-load-test-from-pytest-abc")
|
|
152
|
+
run_client = self.create_run_client(loadtesting_endpoint)
|
|
153
|
+
|
|
154
|
+
try:
|
|
155
|
+
run_client.delete_test_run("my-new-test-run-from-pytest")
|
|
156
|
+
except ResourceNotFoundError:
|
|
157
|
+
pass
|
|
158
|
+
|
|
159
|
+
run_poller = run_client.begin_test_run(
|
|
160
|
+
"my-new-test-run-from-pytest",
|
|
161
|
+
{
|
|
162
|
+
"testId": "new-load-test-from-pytest-abc",
|
|
163
|
+
"displayName": "My New Load Test Run from PyTest",
|
|
164
|
+
}
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
result = run_client.stop_test_run("my-new-test-run-from-pytest")
|
|
168
|
+
assert result is not None
|
|
169
|
+
|
|
170
|
+
with pytest.raises(ResourceNotFoundError):
|
|
171
|
+
run_client.stop_test_run(NON_EXISTING_RESOURCE)
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
@LoadtestingPowerShellPreparer()
|
|
175
|
+
@recorded_by_proxy
|
|
176
|
+
def test_get_metrics(self, loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id):
|
|
177
|
+
set_bodiless_matcher()
|
|
178
|
+
|
|
179
|
+
self.setup_test_run(loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id)
|
|
180
|
+
run_client = self.create_run_client(loadtesting_endpoint)
|
|
181
|
+
|
|
182
|
+
test_run_response = run_client.get_test_run(loadtesting_test_run_id)
|
|
183
|
+
assert test_run_response is not None
|
|
184
|
+
|
|
185
|
+
metric_namespaces = run_client.get_metric_namespaces(loadtesting_test_run_id)
|
|
186
|
+
assert metric_namespaces is not None
|
|
187
|
+
|
|
188
|
+
metric_definitions = run_client.get_metric_definitions(loadtesting_test_run_id,
|
|
189
|
+
metric_namespace=metric_namespaces["value"][0]["name"])
|
|
190
|
+
assert metric_definitions is not None
|
|
191
|
+
|
|
192
|
+
metrics = run_client.list_metrics(
|
|
193
|
+
test_run_id=loadtesting_test_run_id,
|
|
194
|
+
metric_name=metric_definitions["value"][0]["name"],
|
|
195
|
+
metric_namespace=metric_namespaces["value"][0]["name"],
|
|
196
|
+
time_interval=test_run_response["startDateTime"] + "/" + test_run_response["endDateTime"]
|
|
197
|
+
)
|
|
198
|
+
assert metrics is not None
|
|
199
|
+
|
|
200
|
+
@LoadtestingPowerShellPreparer()
|
|
201
|
+
@recorded_by_proxy
|
|
202
|
+
def test_create_or_update_app_component(self, loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id, loadtesting_resource_id):
|
|
203
|
+
set_bodiless_matcher()
|
|
204
|
+
|
|
205
|
+
self.setup_test_run(loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id)
|
|
206
|
+
|
|
207
|
+
run_client = self.create_run_client(loadtesting_endpoint)
|
|
208
|
+
|
|
209
|
+
result = run_client.create_or_update_app_components(
|
|
210
|
+
loadtesting_test_run_id,
|
|
211
|
+
{
|
|
212
|
+
"components":
|
|
213
|
+
{
|
|
214
|
+
loadtesting_resource_id:
|
|
215
|
+
{
|
|
216
|
+
"resourceId": loadtesting_resource_id,
|
|
217
|
+
"resourceName": "App-Service-Sample-Demo",
|
|
218
|
+
"resourceType": "Microsoft.Web/sites",
|
|
219
|
+
"kind": "web"
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
)
|
|
224
|
+
assert result is not None
|
|
225
|
+
|
|
226
|
+
with pytest.raises(ResourceNotFoundError):
|
|
227
|
+
run_client.create_or_update_app_components(
|
|
228
|
+
NON_EXISTING_RESOURCE,
|
|
229
|
+
{
|
|
230
|
+
"components":
|
|
231
|
+
{
|
|
232
|
+
loadtesting_resource_id:
|
|
233
|
+
{
|
|
234
|
+
"resourceId": loadtesting_resource_id,
|
|
235
|
+
"resourceName": "App-Service-Sample-Demo",
|
|
236
|
+
"resourceType": "Microsoft.Web/sites",
|
|
237
|
+
"kind": "web"
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
@LoadtestingPowerShellPreparer()
|
|
244
|
+
@recorded_by_proxy
|
|
245
|
+
def test_get_app_component(self, loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id, loadtesting_resource_id):
|
|
246
|
+
set_bodiless_matcher()
|
|
247
|
+
self.setup_test_run(loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id)
|
|
248
|
+
|
|
249
|
+
run_client = self.create_run_client(loadtesting_endpoint)
|
|
250
|
+
|
|
251
|
+
result = run_client.get_app_components(loadtesting_test_run_id)
|
|
252
|
+
assert result is not None
|
|
253
|
+
|
|
254
|
+
@LoadtestingPowerShellPreparer()
|
|
255
|
+
@recorded_by_proxy
|
|
256
|
+
def test_create_or_update_server_metrics_config(self, loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id, loadtesting_resource_id):
|
|
257
|
+
set_bodiless_matcher()
|
|
258
|
+
self.setup_test_run(loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id)
|
|
259
|
+
|
|
260
|
+
run_client = self.create_run_client(loadtesting_endpoint)
|
|
261
|
+
|
|
262
|
+
result = run_client.create_or_update_server_metrics_config(
|
|
263
|
+
loadtesting_test_run_id,
|
|
264
|
+
{
|
|
265
|
+
"metrics": {
|
|
266
|
+
loadtesting_resource_id: {
|
|
267
|
+
"resourceId": loadtesting_resource_id,
|
|
268
|
+
"metricNamespace": "microsoft.insights/components",
|
|
269
|
+
"displayDescription": "sample description",
|
|
270
|
+
"name": "requests/duration",
|
|
271
|
+
"aggregation": "Average",
|
|
272
|
+
"unit": None,
|
|
273
|
+
"resourceType": "microsoft.insights/components"
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
)
|
|
278
|
+
assert result is not None
|
|
279
|
+
|
|
280
|
+
@LoadtestingPowerShellPreparer()
|
|
281
|
+
@recorded_by_proxy
|
|
282
|
+
def test_get_server_metrics_config(self, loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id, loadtesting_resource_id):
|
|
283
|
+
set_bodiless_matcher()
|
|
284
|
+
self.setup_test_run(loadtesting_endpoint, loadtesting_test_id, loadtesting_test_run_id)
|
|
285
|
+
|
|
286
|
+
run_client = self.create_run_client(loadtesting_endpoint)
|
|
287
|
+
|
|
288
|
+
result = run_client.get_server_metrics_config(loadtesting_test_run_id)
|
|
289
|
+
assert result is not None
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# coding: utf-8
|
|
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
|
+
import os
|
|
8
|
+
import functools
|
|
9
|
+
from devtools_testutils import AzureRecordedTestCase, PowerShellPreparer
|
|
10
|
+
from azure.developer.loadtesting import LoadTestAdministrationClient, LoadTestRunClient
|
|
11
|
+
|
|
12
|
+
class LoadtestingTest(AzureRecordedTestCase):
|
|
13
|
+
|
|
14
|
+
def create_administration_client(self, endpoint):
|
|
15
|
+
credential = self.get_credential(LoadTestAdministrationClient)
|
|
16
|
+
return self.create_client_from_credential(
|
|
17
|
+
LoadTestAdministrationClient,
|
|
18
|
+
credential=credential,
|
|
19
|
+
endpoint=endpoint,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
def create_run_client(self, endpoint):
|
|
23
|
+
credential = self.get_credential(LoadTestRunClient)
|
|
24
|
+
return self.create_client_from_credential(
|
|
25
|
+
LoadTestRunClient,
|
|
26
|
+
credential=credential,
|
|
27
|
+
endpoint=endpoint,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
LoadtestingPowerShellPreparer = functools.partial(
|
|
32
|
+
PowerShellPreparer,
|
|
33
|
+
"loadtesting",
|
|
34
|
+
loadtesting_endpoint="https://myservice.azure.com",
|
|
35
|
+
loadtesting_test_id="000",
|
|
36
|
+
loadtesting_file_id="000",
|
|
37
|
+
loadtesting_test_run_id="000",
|
|
38
|
+
loadtesting_app_component="000",
|
|
39
|
+
loadtesting_subscription_id="000",
|
|
40
|
+
loadtesting_resource_id="000",
|
|
41
|
+
)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# coding: utf-8
|
|
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 azure.developer.loadtesting.aio import LoadTestRunClient, LoadTestAdministrationClient
|
|
8
|
+
from devtools_testutils import AzureRecordedTestCase
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class LoadtestingAsyncTest(AzureRecordedTestCase):
|
|
12
|
+
def create_administration_client(self, endpoint):
|
|
13
|
+
credential = self.get_credential(LoadTestAdministrationClient, is_async=True)
|
|
14
|
+
return self.create_client_from_credential(
|
|
15
|
+
LoadTestAdministrationClient,
|
|
16
|
+
credential=credential,
|
|
17
|
+
endpoint=endpoint,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
def create_run_client(self, endpoint):
|
|
21
|
+
credential = self.get_credential(LoadTestRunClient, is_async=True)
|
|
22
|
+
return self.create_client_from_credential(
|
|
23
|
+
LoadTestRunClient,
|
|
24
|
+
credential=credential,
|
|
25
|
+
endpoint=endpoint,
|
|
26
|
+
)
|