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,52 @@
|
|
|
1
|
+
# -------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
# Licensed under the MIT License. See License.txt in the project root for
|
|
4
|
+
# license information.
|
|
5
|
+
# --------------------------------------------------------------------------
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
FILE: create_or_update_test_run.py
|
|
9
|
+
|
|
10
|
+
DESCRIPTION:
|
|
11
|
+
This sample shows how to create or update a test run
|
|
12
|
+
|
|
13
|
+
USAGE:
|
|
14
|
+
python create_or_update_test_run.py
|
|
15
|
+
|
|
16
|
+
Set the environment variables with your own values before running the sample:
|
|
17
|
+
1) AZURE_CLIENT_ID - client id
|
|
18
|
+
2) AZURE_CLIENT_SECRET - client secret
|
|
19
|
+
3) AZURE_TENANT_ID - tenant id for your Azure
|
|
20
|
+
4) LOADTESTSERVICE_ENDPOINT - Data Plane endpoint for Loadtestservice
|
|
21
|
+
"""
|
|
22
|
+
from azure.developer.loadtesting import LoadTestRunClient
|
|
23
|
+
|
|
24
|
+
# for details refer: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/loadtestservice/azure-developer
|
|
25
|
+
# -loadtesting/README.md
|
|
26
|
+
from azure.identity import DefaultAzureCredential
|
|
27
|
+
|
|
28
|
+
import os
|
|
29
|
+
from dotenv import load_dotenv
|
|
30
|
+
|
|
31
|
+
load_dotenv()
|
|
32
|
+
LOADTESTSERVICE_ENDPOINT = os.environ["LOADTESTSERVICE_ENDPOINT"]
|
|
33
|
+
|
|
34
|
+
TEST_RUN_ID = "some-test-run-id"
|
|
35
|
+
TEST_ID = "my-sdk-test-id"
|
|
36
|
+
|
|
37
|
+
# Build a client through AAD and resource endpoint
|
|
38
|
+
client = LoadTestRunClient(credential=DefaultAzureCredential(), endpoint=LOADTESTSERVICE_ENDPOINT)
|
|
39
|
+
|
|
40
|
+
testRunPoller = client.begin_test_run(
|
|
41
|
+
TEST_RUN_ID,
|
|
42
|
+
{
|
|
43
|
+
"testId": TEST_ID,
|
|
44
|
+
"displayName": "My New Load Test Run",
|
|
45
|
+
}
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
#waiting for test run status to be completed with timeout = 3600 seconds
|
|
49
|
+
result = testRunPoller.result(3600)
|
|
50
|
+
|
|
51
|
+
print(result["status"])
|
|
52
|
+
print(result)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# -------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
# Licensed under the MIT License. See License.txt in the project root for
|
|
4
|
+
# license information.
|
|
5
|
+
# --------------------------------------------------------------------------
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
FILE: create_or_update_app_components.py
|
|
9
|
+
|
|
10
|
+
DESCRIPTION:
|
|
11
|
+
This sample shows how to create or update app component
|
|
12
|
+
|
|
13
|
+
USAGE:
|
|
14
|
+
python create_or_update_app_components.py
|
|
15
|
+
|
|
16
|
+
Set the environment variables with your own values before running the sample:
|
|
17
|
+
1) AZURE_CLIENT_ID - client id
|
|
18
|
+
2) AZURE_CLIENT_SECRET - client secret
|
|
19
|
+
3) AZURE_TENANT_ID - tenant id for your Azure
|
|
20
|
+
4) RESOURCE_ID - resource id of resource to connect
|
|
21
|
+
5) LOADTESTSERVICE_ENDPOINT - Data Plane endpoint for Loadtestservice
|
|
22
|
+
"""
|
|
23
|
+
from azure.developer.loadtesting import LoadTestAdministrationClient
|
|
24
|
+
|
|
25
|
+
# for details refer: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/loadtestservice/azure-developer
|
|
26
|
+
# -loadtesting/README.md
|
|
27
|
+
from azure.identity import DefaultAzureCredential
|
|
28
|
+
|
|
29
|
+
import os
|
|
30
|
+
from dotenv import load_dotenv
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
load_dotenv()
|
|
34
|
+
LOADTESTSERVICE_ENDPOINT = os.environ["LOADTESTSERVICE_ENDPOINT"]
|
|
35
|
+
RESOURCE_ID = os.environ["RESOURCE_ID"]
|
|
36
|
+
|
|
37
|
+
# Build a client through AAD and resource endpoint
|
|
38
|
+
client = LoadTestAdministrationClient(credential=DefaultAzureCredential(), endpoint=LOADTESTSERVICE_ENDPOINT)
|
|
39
|
+
|
|
40
|
+
TEST_ID = "my-sdk-test-id"
|
|
41
|
+
APP_COMPONENT = "my-new-app-component"
|
|
42
|
+
|
|
43
|
+
result = client.create_or_update_app_components(
|
|
44
|
+
TEST_ID,
|
|
45
|
+
{
|
|
46
|
+
"components": {
|
|
47
|
+
RESOURCE_ID: {
|
|
48
|
+
"resourceId": RESOURCE_ID,
|
|
49
|
+
"resourceName": "App-Service-Sample-Demo",
|
|
50
|
+
"resourceType": "Microsoft.Web/sites",
|
|
51
|
+
"kind": "web",
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
print(result)
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# -------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
# Licensed under the MIT License. See License.txt in the project root for
|
|
4
|
+
# license information.
|
|
5
|
+
# --------------------------------------------------------------------------
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
FILE: create_or_update_test_function.py
|
|
9
|
+
|
|
10
|
+
DESCRIPTION:
|
|
11
|
+
This sample shows how to create or update a load test
|
|
12
|
+
|
|
13
|
+
USAGE:
|
|
14
|
+
python create_or_update_test_function.py
|
|
15
|
+
|
|
16
|
+
Set the environment variables with your own values before running the sample:
|
|
17
|
+
1) AZURE_CLIENT_ID - client id
|
|
18
|
+
2) AZURE_CLIENT_SECRET - client secret
|
|
19
|
+
3) AZURE_TENANT_ID - tenant id for your Azure
|
|
20
|
+
4) LOADTESTSERVICE_ENDPOINT - Data Plane endpoint for Loadtestservice
|
|
21
|
+
"""
|
|
22
|
+
from azure.developer.loadtesting import LoadTestAdministrationClient
|
|
23
|
+
|
|
24
|
+
# for details refer: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/loadtestservice/azure-developer
|
|
25
|
+
# -loadtesting/README.md
|
|
26
|
+
from azure.identity import DefaultAzureCredential
|
|
27
|
+
|
|
28
|
+
import os
|
|
29
|
+
from dotenv import load_dotenv
|
|
30
|
+
|
|
31
|
+
load_dotenv()
|
|
32
|
+
LOADTESTSERVICE_ENDPOINT = os.environ["LOADTESTSERVICE_ENDPOINT"]
|
|
33
|
+
|
|
34
|
+
# Build a client through AAD and resource endpoint
|
|
35
|
+
client = LoadTestAdministrationClient(credential=DefaultAzureCredential(), endpoint=LOADTESTSERVICE_ENDPOINT)
|
|
36
|
+
|
|
37
|
+
# ID to be assigned to test
|
|
38
|
+
TEST_ID = "my-sdk-test-id"
|
|
39
|
+
|
|
40
|
+
result = client.create_or_update_test(
|
|
41
|
+
TEST_ID,
|
|
42
|
+
{
|
|
43
|
+
"description": "",
|
|
44
|
+
"displayName": "My New Load Test",
|
|
45
|
+
"loadTestConfig": {
|
|
46
|
+
"engineInstances": 1,
|
|
47
|
+
"splitAllCSVs": False,
|
|
48
|
+
},
|
|
49
|
+
"passFailCriteria": {
|
|
50
|
+
"passFailMetrics": {
|
|
51
|
+
"condition1": {
|
|
52
|
+
"clientmetric": "response_time_ms",
|
|
53
|
+
"aggregate": "avg",
|
|
54
|
+
"condition": ">",
|
|
55
|
+
"value": 300
|
|
56
|
+
},
|
|
57
|
+
"condition2": {
|
|
58
|
+
"clientmetric": "error",
|
|
59
|
+
"aggregate": "percentage",
|
|
60
|
+
"condition": ">",
|
|
61
|
+
"value": 50
|
|
62
|
+
},
|
|
63
|
+
"condition3": {
|
|
64
|
+
"clientmetric": "latency",
|
|
65
|
+
"aggregate": "avg",
|
|
66
|
+
"condition": ">",
|
|
67
|
+
"value": 200,
|
|
68
|
+
"requestName": "GetCustomerDetails"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"secrets": {
|
|
73
|
+
"secret1": {
|
|
74
|
+
"value": "https://sdk-testing-keyvault.vault.azure.net/secrets/sdk-secret",
|
|
75
|
+
"type": "AKV_SECRET_URI"
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"environmentVariables": {
|
|
79
|
+
"my-varaible": "value"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
print(result)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# -------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
# Licensed under the MIT License. See License.txt in the project root for
|
|
4
|
+
# license information.
|
|
5
|
+
# --------------------------------------------------------------------------
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
FILE: delete_load_test_function.py
|
|
9
|
+
|
|
10
|
+
DESCRIPTION:
|
|
11
|
+
This sample shows how to delete a load test
|
|
12
|
+
|
|
13
|
+
USAGE:
|
|
14
|
+
python delete_load_test_function.py
|
|
15
|
+
|
|
16
|
+
Set the environment variables with your own values before running the sample:
|
|
17
|
+
1) AZURE_CLIENT_ID - client id
|
|
18
|
+
2) AZURE_CLIENT_SECRET - client secret
|
|
19
|
+
3) AZURE_TENANT_ID - tenant id for your Azure
|
|
20
|
+
4) LOADTESTSERVICE_ENDPOINT - Data Plane endpoint for Loadtestservice
|
|
21
|
+
"""
|
|
22
|
+
# main library import
|
|
23
|
+
from azure.developer.loadtesting import LoadTestAdministrationClient
|
|
24
|
+
|
|
25
|
+
# for managing authentication and authorization can be installed from pypi, follow:
|
|
26
|
+
# https://pypi.org/project/azure-identity/ using DefaultAzureCredentials, read more at:
|
|
27
|
+
# https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity.defaultazurecredential?view=azure-python
|
|
28
|
+
from azure.identity import DefaultAzureCredential
|
|
29
|
+
|
|
30
|
+
# importing os and dotenv for managing and loading environment variables
|
|
31
|
+
import os
|
|
32
|
+
from dotenv import load_dotenv
|
|
33
|
+
|
|
34
|
+
# Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables:
|
|
35
|
+
# AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET, SUBSCRIPTION_ID, RESOURCE_GROUP
|
|
36
|
+
|
|
37
|
+
# loading dotenv file
|
|
38
|
+
load_dotenv()
|
|
39
|
+
LOADTESTSERVICE_ENDPOINT = os.environ["LOADTESTSERVICE_ENDPOINT"]
|
|
40
|
+
|
|
41
|
+
TEST_ID = "my-sdk-test-id"
|
|
42
|
+
|
|
43
|
+
# Build a client through AAD and resource endpoint
|
|
44
|
+
client = LoadTestAdministrationClient(credential=DefaultAzureCredential(), endpoint=LOADTESTSERVICE_ENDPOINT)
|
|
45
|
+
|
|
46
|
+
client.delete_test(TEST_ID)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# -------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
# Licensed under the MIT License. See License.txt in the project root for
|
|
4
|
+
# license information.
|
|
5
|
+
# --------------------------------------------------------------------------
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
FILE: delete_load_test_run.py
|
|
9
|
+
|
|
10
|
+
DESCRIPTION:
|
|
11
|
+
This sample shows how to delete a load test run
|
|
12
|
+
|
|
13
|
+
USAGE:
|
|
14
|
+
python delete_load_test_run.py
|
|
15
|
+
|
|
16
|
+
Set the environment variables with your own values before running the sample:
|
|
17
|
+
1) AZURE_CLIENT_ID - client id
|
|
18
|
+
2) AZURE_CLIENT_SECRET - client secret
|
|
19
|
+
3) AZURE_TENANT_ID - tenant id for your Azure
|
|
20
|
+
4) LOADTESTSERVICE_ENDPOINT - Data Plane endpoint for Loadtestservice
|
|
21
|
+
"""
|
|
22
|
+
from azure.developer.loadtesting import LoadTestRunClient
|
|
23
|
+
|
|
24
|
+
# for details refer: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/loadtestservice/azure-developer
|
|
25
|
+
# -loadtesting/README.md
|
|
26
|
+
from azure.identity import DefaultAzureCredential
|
|
27
|
+
|
|
28
|
+
import os
|
|
29
|
+
from dotenv import load_dotenv
|
|
30
|
+
|
|
31
|
+
load_dotenv()
|
|
32
|
+
LOADTESTSERVICE_ENDPOINT = os.environ["LOADTESTSERVICE_ENDPOINT"]
|
|
33
|
+
|
|
34
|
+
TEST_RUN_ID = "some-test-run-id"
|
|
35
|
+
|
|
36
|
+
# Build a client through AAD and resource endpoint
|
|
37
|
+
client = LoadTestRunClient(credential=DefaultAzureCredential(), endpoint=LOADTESTSERVICE_ENDPOINT)
|
|
38
|
+
|
|
39
|
+
client.delete_test_run(TEST_RUN_ID)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# -------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
# Licensed under the MIT License. See License.txt in the project root for
|
|
4
|
+
# license information.
|
|
5
|
+
# --------------------------------------------------------------------------
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
FILE: get_metics.py
|
|
9
|
+
|
|
10
|
+
DESCRIPTION:
|
|
11
|
+
This sample shows how to get metrics for a test run
|
|
12
|
+
|
|
13
|
+
USAGE:
|
|
14
|
+
python get_metrics.py
|
|
15
|
+
|
|
16
|
+
Set the environment variables with your own values before running the sample:
|
|
17
|
+
1) AZURE_CLIENT_ID - client id
|
|
18
|
+
2) AZURE_CLIENT_SECRET - client secret
|
|
19
|
+
3) AZURE_TENANT_ID - tenant id for your Azure
|
|
20
|
+
4) LOADTESTSERVICE_ENDPOINT - Data Plane endpoint for Loadtestservice
|
|
21
|
+
"""
|
|
22
|
+
from azure.developer.loadtesting import LoadTestRunClient
|
|
23
|
+
|
|
24
|
+
# for details refer: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/loadtestservice/azure-developer
|
|
25
|
+
# -loadtesting/README.md
|
|
26
|
+
from azure.identity import DefaultAzureCredential
|
|
27
|
+
|
|
28
|
+
# importing os and dotenv for managing and loading environment variables
|
|
29
|
+
import os
|
|
30
|
+
from dotenv import load_dotenv
|
|
31
|
+
|
|
32
|
+
# for various
|
|
33
|
+
import time
|
|
34
|
+
|
|
35
|
+
load_dotenv()
|
|
36
|
+
LOADTESTSERVICE_ENDPOINT = os.environ["LOADTESTSERVICE_ENDPOINT"]
|
|
37
|
+
|
|
38
|
+
# Build a client through AAD and resource endpoint
|
|
39
|
+
client = LoadTestRunClient(credential=DefaultAzureCredential(), endpoint=LOADTESTSERVICE_ENDPOINT)
|
|
40
|
+
|
|
41
|
+
TEST_ID = "my-sdk-test-id"
|
|
42
|
+
TEST_RUN_ID = "some-test-run-id"
|
|
43
|
+
|
|
44
|
+
test_run_response = client.get_test_run(TEST_RUN_ID)
|
|
45
|
+
|
|
46
|
+
# get a list of metric namespaces for a given test run
|
|
47
|
+
metric_namespaces = client.get_metric_namespaces(TEST_RUN_ID)
|
|
48
|
+
print(metric_namespaces)
|
|
49
|
+
|
|
50
|
+
# get a list of metric definitions for a given test run and metric namespace
|
|
51
|
+
metric_definitions = client.get_metric_definitions(TEST_RUN_ID, metric_namespace=metric_namespaces["value"][0]["name"])
|
|
52
|
+
print(metric_definitions)
|
|
53
|
+
|
|
54
|
+
# fetch metrics for a test run using metric definition and namespace
|
|
55
|
+
metrics = client.list_metrics(
|
|
56
|
+
TEST_RUN_ID,
|
|
57
|
+
metric_name=metric_definitions["value"][0]["name"],
|
|
58
|
+
metric_namespace=metric_namespaces["value"][0]["name"],
|
|
59
|
+
time_interval=test_run_response["startDateTime"]+"/"+test_run_response["endDateTime"]
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
for page in metrics.by_page():
|
|
63
|
+
for data in page:
|
|
64
|
+
print(data)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# -------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
# Licensed under the MIT License. See License.txt in the project root for
|
|
4
|
+
# license information.
|
|
5
|
+
# --------------------------------------------------------------------------
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
FILE: upload_test_file.py
|
|
9
|
+
|
|
10
|
+
DESCRIPTION:
|
|
11
|
+
This sample shows how to upload a file to your loadtest
|
|
12
|
+
USAGE:
|
|
13
|
+
python upload_test_file.py
|
|
14
|
+
|
|
15
|
+
Set the environment variables with your own values before running the sample:
|
|
16
|
+
1) AZURE_CLIENT_ID - client id
|
|
17
|
+
2) AZURE_CLIENT_SECRET - client secret
|
|
18
|
+
3) AZURE_TENANT_ID - tenant id for your Azure
|
|
19
|
+
4) LOADTESTSERVICE_ENDPOINT - Data Plane endpoint for Loadtestservice
|
|
20
|
+
|
|
21
|
+
Please ensure that correct jmx file and path is used
|
|
22
|
+
"""
|
|
23
|
+
from azure.developer.loadtesting import LoadTestAdministrationClient
|
|
24
|
+
|
|
25
|
+
# for details refer: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/loadtestservice/azure-developer
|
|
26
|
+
# -loadtesting/README.md
|
|
27
|
+
from azure.identity import DefaultAzureCredential
|
|
28
|
+
|
|
29
|
+
import os
|
|
30
|
+
from dotenv import load_dotenv
|
|
31
|
+
|
|
32
|
+
load_dotenv()
|
|
33
|
+
LOADTESTSERVICE_ENDPOINT = os.environ["LOADTESTSERVICE_ENDPOINT"]
|
|
34
|
+
|
|
35
|
+
client = LoadTestAdministrationClient(credential=DefaultAzureCredential(), endpoint=LOADTESTSERVICE_ENDPOINT)
|
|
36
|
+
|
|
37
|
+
TEST_ID = "my-sdk-test-id"
|
|
38
|
+
FILE_NAME = "my-file-id.jmx"
|
|
39
|
+
|
|
40
|
+
# uploading .jmx file to a test
|
|
41
|
+
resultPoller = client.begin_upload_test_file(TEST_ID, FILE_NAME, open("sample.jmx", "rb"))
|
|
42
|
+
|
|
43
|
+
# getting result of LRO poller with timeout of 600 secs
|
|
44
|
+
validationResponse = resultPoller.result(600)
|
|
45
|
+
print(validationResponse)
|
|
@@ -0,0 +1,71 @@
|
|
|
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 license information.
|
|
5
|
+
# Code generated by Microsoft (R) AutoRest Code Generator.
|
|
6
|
+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
|
7
|
+
# --------------------------------------------------------------------------
|
|
8
|
+
# coding: utf-8
|
|
9
|
+
|
|
10
|
+
import os
|
|
11
|
+
import re
|
|
12
|
+
from setuptools import setup, find_packages
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
PACKAGE_NAME = "azure-developer-loadtesting"
|
|
16
|
+
PACKAGE_PPRINT_NAME = "Azure Developer LoadTesting"
|
|
17
|
+
|
|
18
|
+
# a-b-c => a/b/c
|
|
19
|
+
package_folder_path = PACKAGE_NAME.replace("-", "/")
|
|
20
|
+
|
|
21
|
+
# Version extraction inspired from 'requests'
|
|
22
|
+
with open(os.path.join(package_folder_path, "_version.py"), "r") as fd:
|
|
23
|
+
version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1)
|
|
24
|
+
|
|
25
|
+
if not version:
|
|
26
|
+
raise RuntimeError("Cannot find version information")
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
setup(
|
|
30
|
+
name=PACKAGE_NAME,
|
|
31
|
+
version=version,
|
|
32
|
+
description="Microsoft Azure Developer LoadTesting Client Library for Python",
|
|
33
|
+
long_description=open("README.md", "r").read(),
|
|
34
|
+
long_description_content_type="text/markdown",
|
|
35
|
+
license="MIT License",
|
|
36
|
+
author="Microsoft Corporation",
|
|
37
|
+
author_email="azpysdkhelp@microsoft.com",
|
|
38
|
+
url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk",
|
|
39
|
+
keywords="azure, azure sdk",
|
|
40
|
+
classifiers=[
|
|
41
|
+
"Development Status :: 5 - Production/Stable",
|
|
42
|
+
"Programming Language :: Python",
|
|
43
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
44
|
+
"Programming Language :: Python :: 3",
|
|
45
|
+
"Programming Language :: Python :: 3.7",
|
|
46
|
+
"Programming Language :: Python :: 3.8",
|
|
47
|
+
"Programming Language :: Python :: 3.9",
|
|
48
|
+
"Programming Language :: Python :: 3.10",
|
|
49
|
+
"Programming Language :: Python :: 3.11",
|
|
50
|
+
"License :: OSI Approved :: MIT License",
|
|
51
|
+
],
|
|
52
|
+
zip_safe=False,
|
|
53
|
+
packages=find_packages(
|
|
54
|
+
exclude=[
|
|
55
|
+
"tests",
|
|
56
|
+
# Exclude packages that will be covered by PEP420 or nspkg
|
|
57
|
+
"azure",
|
|
58
|
+
"azure.developer",
|
|
59
|
+
]
|
|
60
|
+
),
|
|
61
|
+
include_package_data=True,
|
|
62
|
+
package_data={
|
|
63
|
+
"pytyped": ["py.typed"],
|
|
64
|
+
},
|
|
65
|
+
install_requires=[
|
|
66
|
+
"isodate<1.0.0,>=0.6.1",
|
|
67
|
+
"azure-core<2.0.0,>=1.24.0",
|
|
68
|
+
"typing-extensions>=4.3.0; python_version<'3.8.0'",
|
|
69
|
+
],
|
|
70
|
+
python_requires=">=3.7",
|
|
71
|
+
)
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# --------------------------------------------------------------------------
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
#
|
|
5
|
+
# The MIT License (MIT)
|
|
6
|
+
#
|
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
# of this software and associated documentation files (the ""Software""), to
|
|
9
|
+
# deal in the Software without restriction, including without limitation the
|
|
10
|
+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
11
|
+
# sell copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
# furnished to do so, subject to the following conditions:
|
|
13
|
+
#
|
|
14
|
+
# The above copyright notice and this permission notice shall be included in
|
|
15
|
+
# all copies or substantial portions of the Software.
|
|
16
|
+
#
|
|
17
|
+
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
22
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
23
|
+
# IN THE SOFTWARE.
|
|
24
|
+
#
|
|
25
|
+
# --------------------------------------------------------------------------
|
|
26
|
+
import os
|
|
27
|
+
import platform
|
|
28
|
+
import pytest
|
|
29
|
+
import sys
|
|
30
|
+
|
|
31
|
+
from dotenv import load_dotenv
|
|
32
|
+
|
|
33
|
+
from devtools_testutils import test_proxy, add_general_regex_sanitizer, add_body_key_sanitizer, add_header_regex_sanitizer
|
|
34
|
+
|
|
35
|
+
load_dotenv()
|
|
36
|
+
|
|
37
|
+
@pytest.fixture(scope="session", autouse=True)
|
|
38
|
+
def add_sanitizers(test_proxy):
|
|
39
|
+
subscription_id = os.environ.get("LOADTESTING_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000")
|
|
40
|
+
tenant_id = os.environ.get("LOADTESTING_TENANT_ID", "00000000-0000-0000-0000-000000000000")
|
|
41
|
+
client_id = os.environ.get("LOADTESTING_CLIENT_ID", "00000000-0000-0000-0000-000000000000")
|
|
42
|
+
client_secret = os.environ.get("LOADTESTING_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000")
|
|
43
|
+
test_id = os.environ.get("TEST_ID", "000")
|
|
44
|
+
file_id = os.environ.get("FILE_ID", "000")
|
|
45
|
+
test_run_id = os.environ.get("TEST_RUN_ID", "000")
|
|
46
|
+
resource_id = os.environ.get("RESOURCE_ID", "000")
|
|
47
|
+
app_component = os.environ.get("APP_COMPONENT", "000")
|
|
48
|
+
add_general_regex_sanitizer(regex=subscription_id, value="00000000-0000-0000-0000-000000000000")
|
|
49
|
+
add_general_regex_sanitizer(regex=tenant_id, value="00000000-0000-0000-0000-000000000000")
|
|
50
|
+
add_general_regex_sanitizer(regex=client_id, value="00000000-0000-0000-0000-000000000000")
|
|
51
|
+
add_general_regex_sanitizer(regex=client_secret, value="00000000-0000-0000-0000-000000000000")
|
|
52
|
+
add_general_regex_sanitizer(regex=test_id, value="000")
|
|
53
|
+
add_general_regex_sanitizer(regex=file_id, value="000")
|
|
54
|
+
add_general_regex_sanitizer(regex=test_run_id, value="000")
|
|
55
|
+
add_general_regex_sanitizer(regex=app_component, value="000")
|
|
56
|
+
add_general_regex_sanitizer(regex=resource_id, value="000")
|
|
57
|
+
add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]")
|
|
58
|
+
add_header_regex_sanitizer(key="Cookie", value="cookie;")
|
|
59
|
+
add_body_key_sanitizer(json_path="$..access_token", value="access_token")
|
|
60
|
+
add_body_key_sanitizer(json_path="$..url", value="url")
|