@azure-rest/load-testing 1.0.1 → 1.1.0-alpha.20250324.1
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.
- package/LICENSE +4 -4
- package/README.md +91 -107
- package/dist/browser/azureLoadTesting.d.ts +10 -4
- package/dist/browser/azureLoadTesting.d.ts.map +1 -1
- package/dist/browser/azureLoadTesting.js +28 -11
- package/dist/browser/azureLoadTesting.js.map +1 -1
- package/dist/browser/clientDefinitions.d.ts +164 -84
- package/dist/browser/clientDefinitions.d.ts.map +1 -1
- package/dist/browser/clientDefinitions.js.map +1 -1
- package/dist/browser/getFileValidationPoller.d.ts +2 -2
- package/dist/browser/getFileValidationPoller.d.ts.map +1 -1
- package/dist/browser/getFileValidationPoller.js.map +1 -1
- package/dist/browser/getTestProfileRunCompletionPoller.d.ts +11 -0
- package/dist/browser/getTestProfileRunCompletionPoller.d.ts.map +1 -0
- package/dist/browser/getTestProfileRunCompletionPoller.js +127 -0
- package/dist/browser/getTestProfileRunCompletionPoller.js.map +1 -0
- package/dist/browser/getTestRunCompletionPoller.d.ts +2 -2
- package/dist/browser/getTestRunCompletionPoller.d.ts.map +1 -1
- package/dist/browser/getTestRunCompletionPoller.js.map +1 -1
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/isUnexpected.d.ts +44 -27
- package/dist/browser/isUnexpected.d.ts.map +1 -1
- package/dist/browser/isUnexpected.js +52 -32
- package/dist/browser/isUnexpected.js.map +1 -1
- package/dist/browser/logger.d.ts +2 -0
- package/dist/browser/logger.d.ts.map +1 -0
- package/dist/browser/logger.js +5 -0
- package/dist/browser/logger.js.map +1 -0
- package/dist/browser/models.d.ts +545 -220
- package/dist/browser/models.d.ts.map +1 -1
- package/dist/browser/models.js.map +1 -1
- package/dist/browser/outputModels.d.ts +844 -207
- package/dist/browser/outputModels.d.ts.map +1 -1
- package/dist/browser/outputModels.js.map +1 -1
- package/dist/browser/paginateHelper.d.ts +27 -2
- package/dist/browser/paginateHelper.d.ts.map +1 -1
- package/dist/browser/paginateHelper.js +98 -1
- package/dist/browser/paginateHelper.js.map +1 -1
- package/dist/browser/parameters.d.ts +327 -123
- package/dist/browser/parameters.d.ts.map +1 -1
- package/dist/browser/parameters.js.map +1 -1
- package/dist/browser/pollingHelper.d.ts +2 -1
- package/dist/browser/pollingHelper.d.ts.map +1 -1
- package/dist/browser/pollingHelper.js +7 -0
- package/dist/browser/pollingHelper.js.map +1 -1
- package/dist/browser/responses.d.ts +464 -239
- package/dist/browser/responses.d.ts.map +1 -1
- package/dist/browser/responses.js.map +1 -1
- package/dist/browser/util/LROUtil.d.ts +2 -1
- package/dist/browser/util/LROUtil.d.ts.map +1 -1
- package/dist/browser/util/LROUtil.js +13 -0
- package/dist/browser/util/LROUtil.js.map +1 -1
- package/dist/commonjs/azureLoadTesting.d.ts +10 -4
- package/dist/commonjs/azureLoadTesting.d.ts.map +1 -1
- package/dist/commonjs/azureLoadTesting.js +28 -11
- package/dist/commonjs/azureLoadTesting.js.map +1 -1
- package/dist/commonjs/clientDefinitions.d.ts +164 -84
- package/dist/commonjs/clientDefinitions.d.ts.map +1 -1
- package/dist/commonjs/clientDefinitions.js.map +1 -1
- package/dist/commonjs/getFileValidationPoller.d.ts +2 -2
- package/dist/commonjs/getFileValidationPoller.d.ts.map +1 -1
- package/dist/commonjs/getFileValidationPoller.js.map +1 -1
- package/dist/commonjs/getTestProfileRunCompletionPoller.d.ts +11 -0
- package/dist/commonjs/getTestProfileRunCompletionPoller.d.ts.map +1 -0
- package/dist/commonjs/getTestProfileRunCompletionPoller.js +130 -0
- package/dist/commonjs/getTestProfileRunCompletionPoller.js.map +1 -0
- package/dist/commonjs/getTestRunCompletionPoller.d.ts +2 -2
- package/dist/commonjs/getTestRunCompletionPoller.d.ts.map +1 -1
- package/dist/commonjs/getTestRunCompletionPoller.js.map +1 -1
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/isUnexpected.d.ts +44 -27
- package/dist/commonjs/isUnexpected.d.ts.map +1 -1
- package/dist/commonjs/isUnexpected.js +52 -32
- package/dist/commonjs/isUnexpected.js.map +1 -1
- package/dist/commonjs/logger.d.ts +2 -0
- package/dist/commonjs/logger.d.ts.map +1 -0
- package/dist/commonjs/logger.js +8 -0
- package/dist/commonjs/logger.js.map +1 -0
- package/dist/commonjs/models.d.ts +545 -220
- package/dist/commonjs/models.d.ts.map +1 -1
- package/dist/commonjs/models.js.map +1 -1
- package/dist/commonjs/outputModels.d.ts +844 -207
- package/dist/commonjs/outputModels.d.ts.map +1 -1
- package/dist/commonjs/outputModels.js.map +1 -1
- package/dist/commonjs/paginateHelper.d.ts +27 -2
- package/dist/commonjs/paginateHelper.d.ts.map +1 -1
- package/dist/commonjs/paginateHelper.js +99 -2
- package/dist/commonjs/paginateHelper.js.map +1 -1
- package/dist/commonjs/parameters.d.ts +327 -123
- package/dist/commonjs/parameters.d.ts.map +1 -1
- package/dist/commonjs/parameters.js.map +1 -1
- package/dist/commonjs/pollingHelper.d.ts +2 -1
- package/dist/commonjs/pollingHelper.d.ts.map +1 -1
- package/dist/commonjs/pollingHelper.js +7 -0
- package/dist/commonjs/pollingHelper.js.map +1 -1
- package/dist/commonjs/responses.d.ts +464 -239
- package/dist/commonjs/responses.d.ts.map +1 -1
- package/dist/commonjs/responses.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +1 -1
- package/dist/commonjs/util/LROUtil.d.ts +2 -1
- package/dist/commonjs/util/LROUtil.d.ts.map +1 -1
- package/dist/commonjs/util/LROUtil.js +14 -0
- package/dist/commonjs/util/LROUtil.js.map +1 -1
- package/dist/esm/azureLoadTesting.d.ts +10 -4
- package/dist/esm/azureLoadTesting.d.ts.map +1 -1
- package/dist/esm/azureLoadTesting.js +28 -11
- package/dist/esm/azureLoadTesting.js.map +1 -1
- package/dist/esm/clientDefinitions.d.ts +164 -84
- package/dist/esm/clientDefinitions.d.ts.map +1 -1
- package/dist/esm/clientDefinitions.js.map +1 -1
- package/dist/esm/getFileValidationPoller.d.ts +2 -2
- package/dist/esm/getFileValidationPoller.d.ts.map +1 -1
- package/dist/esm/getFileValidationPoller.js.map +1 -1
- package/dist/esm/getTestProfileRunCompletionPoller.d.ts +11 -0
- package/dist/esm/getTestProfileRunCompletionPoller.d.ts.map +1 -0
- package/dist/esm/getTestProfileRunCompletionPoller.js +127 -0
- package/dist/esm/getTestProfileRunCompletionPoller.js.map +1 -0
- package/dist/esm/getTestRunCompletionPoller.d.ts +2 -2
- package/dist/esm/getTestRunCompletionPoller.d.ts.map +1 -1
- package/dist/esm/getTestRunCompletionPoller.js.map +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/isUnexpected.d.ts +44 -27
- package/dist/esm/isUnexpected.d.ts.map +1 -1
- package/dist/esm/isUnexpected.js +52 -32
- package/dist/esm/isUnexpected.js.map +1 -1
- package/dist/esm/logger.d.ts +2 -0
- package/dist/esm/logger.d.ts.map +1 -0
- package/dist/esm/logger.js +5 -0
- package/dist/esm/logger.js.map +1 -0
- package/dist/esm/models.d.ts +545 -220
- package/dist/esm/models.d.ts.map +1 -1
- package/dist/esm/models.js.map +1 -1
- package/dist/esm/outputModels.d.ts +844 -207
- package/dist/esm/outputModels.d.ts.map +1 -1
- package/dist/esm/outputModels.js.map +1 -1
- package/dist/esm/paginateHelper.d.ts +27 -2
- package/dist/esm/paginateHelper.d.ts.map +1 -1
- package/dist/esm/paginateHelper.js +98 -1
- package/dist/esm/paginateHelper.js.map +1 -1
- package/dist/esm/parameters.d.ts +327 -123
- package/dist/esm/parameters.d.ts.map +1 -1
- package/dist/esm/parameters.js.map +1 -1
- package/dist/esm/pollingHelper.d.ts +2 -1
- package/dist/esm/pollingHelper.d.ts.map +1 -1
- package/dist/esm/pollingHelper.js +7 -0
- package/dist/esm/pollingHelper.js.map +1 -1
- package/dist/esm/responses.d.ts +464 -239
- package/dist/esm/responses.d.ts.map +1 -1
- package/dist/esm/responses.js.map +1 -1
- package/dist/esm/util/LROUtil.d.ts +2 -1
- package/dist/esm/util/LROUtil.d.ts.map +1 -1
- package/dist/esm/util/LROUtil.js +13 -0
- package/dist/esm/util/LROUtil.js.map +1 -1
- package/dist/react-native/azureLoadTesting.d.ts +10 -4
- package/dist/react-native/azureLoadTesting.d.ts.map +1 -1
- package/dist/react-native/azureLoadTesting.js +28 -11
- package/dist/react-native/azureLoadTesting.js.map +1 -1
- package/dist/react-native/clientDefinitions.d.ts +164 -84
- package/dist/react-native/clientDefinitions.d.ts.map +1 -1
- package/dist/react-native/clientDefinitions.js.map +1 -1
- package/dist/react-native/getFileValidationPoller.d.ts +2 -2
- package/dist/react-native/getFileValidationPoller.d.ts.map +1 -1
- package/dist/react-native/getFileValidationPoller.js.map +1 -1
- package/dist/react-native/getTestProfileRunCompletionPoller.d.ts +11 -0
- package/dist/react-native/getTestProfileRunCompletionPoller.d.ts.map +1 -0
- package/dist/react-native/getTestProfileRunCompletionPoller.js +127 -0
- package/dist/react-native/getTestProfileRunCompletionPoller.js.map +1 -0
- package/dist/react-native/getTestRunCompletionPoller.d.ts +2 -2
- package/dist/react-native/getTestRunCompletionPoller.d.ts.map +1 -1
- package/dist/react-native/getTestRunCompletionPoller.js.map +1 -1
- package/dist/react-native/index.d.ts.map +1 -1
- package/dist/react-native/index.js.map +1 -1
- package/dist/react-native/isUnexpected.d.ts +44 -27
- package/dist/react-native/isUnexpected.d.ts.map +1 -1
- package/dist/react-native/isUnexpected.js +52 -32
- package/dist/react-native/isUnexpected.js.map +1 -1
- package/dist/react-native/logger.d.ts +2 -0
- package/dist/react-native/logger.d.ts.map +1 -0
- package/dist/react-native/logger.js +5 -0
- package/dist/react-native/logger.js.map +1 -0
- package/dist/react-native/models.d.ts +545 -220
- package/dist/react-native/models.d.ts.map +1 -1
- package/dist/react-native/models.js.map +1 -1
- package/dist/react-native/outputModels.d.ts +844 -207
- package/dist/react-native/outputModels.d.ts.map +1 -1
- package/dist/react-native/outputModels.js.map +1 -1
- package/dist/react-native/paginateHelper.d.ts +27 -2
- package/dist/react-native/paginateHelper.d.ts.map +1 -1
- package/dist/react-native/paginateHelper.js +98 -1
- package/dist/react-native/paginateHelper.js.map +1 -1
- package/dist/react-native/parameters.d.ts +327 -123
- package/dist/react-native/parameters.d.ts.map +1 -1
- package/dist/react-native/parameters.js.map +1 -1
- package/dist/react-native/pollingHelper.d.ts +2 -1
- package/dist/react-native/pollingHelper.d.ts.map +1 -1
- package/dist/react-native/pollingHelper.js +7 -0
- package/dist/react-native/pollingHelper.js.map +1 -1
- package/dist/react-native/responses.d.ts +464 -239
- package/dist/react-native/responses.d.ts.map +1 -1
- package/dist/react-native/responses.js.map +1 -1
- package/dist/react-native/util/LROUtil.d.ts +2 -1
- package/dist/react-native/util/LROUtil.d.ts.map +1 -1
- package/dist/react-native/util/LROUtil.js +13 -0
- package/dist/react-native/util/LROUtil.js.map +1 -1
- package/package.json +23 -21
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
Copyright (c) Microsoft Corporation.
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
MIT License
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -12,10 +12,10 @@ furnished to do so, subject to the following conditions:
|
|
|
12
12
|
The above copyright notice and this permission notice shall be included in all
|
|
13
13
|
copies or substantial portions of the Software.
|
|
14
14
|
|
|
15
|
-
THE SOFTWARE IS PROVIDED
|
|
15
|
+
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
16
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
17
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -17,14 +17,15 @@ Various documentation is available to help you get started
|
|
|
17
17
|
### Currently supported environments
|
|
18
18
|
|
|
19
19
|
- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule)
|
|
20
|
+
- Latest versions of Safari, Chrome, Edge and Firefox
|
|
20
21
|
|
|
21
22
|
### Prerequisites
|
|
22
23
|
|
|
23
|
-
- You must have an [Azure subscription](https://azure.microsoft.com/free/) and [Azure Load Test Service Resource](https://learn.microsoft.com/azure/load-testing/) to use this package.
|
|
24
|
+
- You must have an [Azure subscription](https://azure.microsoft.com/free/) and [Azure Load Test Service Resource](https://learn.microsoft.com/azure/load-testing/) to use this package. You can create the resource via the [Azure Portal](https://portal.azure.com), or the [Azure CLI](https://learn.microsoft.com/cli/azure).
|
|
24
25
|
|
|
25
26
|
### Install the `@azure-rest/load-testing` package
|
|
26
27
|
|
|
27
|
-
Install the
|
|
28
|
+
Install the Azure Load Testing client REST client library for JavaScript with `npm`:
|
|
28
29
|
|
|
29
30
|
```bash
|
|
30
31
|
npm install @azure-rest/load-testing
|
|
@@ -45,11 +46,12 @@ can be used to authenticate the client.
|
|
|
45
46
|
Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables:
|
|
46
47
|
AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET
|
|
47
48
|
|
|
48
|
-
```
|
|
49
|
-
import AzureLoadTesting
|
|
49
|
+
```ts snippet:ReadmeSampleCreateClient_Node
|
|
50
|
+
import AzureLoadTesting from "@azure-rest/load-testing";
|
|
50
51
|
import { DefaultAzureCredential } from "@azure/identity";
|
|
51
52
|
|
|
52
|
-
const
|
|
53
|
+
const endpoint = "https://<endpoint>";
|
|
54
|
+
const client = AzureLoadTesting(endpoint, new DefaultAzureCredential());
|
|
53
55
|
```
|
|
54
56
|
|
|
55
57
|
## Key concepts
|
|
@@ -74,11 +76,11 @@ During a load test, Azure Load Testing collects metrics about the test execution
|
|
|
74
76
|
|
|
75
77
|
### Test Engine
|
|
76
78
|
|
|
77
|
-
A test engine is computing infrastructure that runs the Apache JMeter test script. You can scale out your load test by configuring the number of test engines. The test script runs in parallel across the specified number of test engines.
|
|
79
|
+
A test engine is computing infrastructure that runs the Apache JMeter or Locust test script. You can scale out your load test by configuring the number of test engines. The test script runs in parallel across the specified number of test engines.
|
|
78
80
|
|
|
79
81
|
### Test Run
|
|
80
82
|
|
|
81
|
-
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.
|
|
83
|
+
A test run represents one execution of a load test. It collects the logs associated with running the Apache JMeter or Locust script, the load test YAML configuration, the list of app components to monitor, and the results of the test.
|
|
82
84
|
|
|
83
85
|
### Data-Plane Endpoint
|
|
84
86
|
|
|
@@ -88,7 +90,7 @@ Data-plane of Azure Load Testing resources is addressable using the following UR
|
|
|
88
90
|
|
|
89
91
|
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.
|
|
90
92
|
|
|
91
|
-
The data-plane endpoint is obtained from Control Plane APIs.
|
|
93
|
+
The data-plane endpoint is obtained from Control Plane APIs. To obtain the data-plane endpoint for your resource, follow [this documentation][obtaining_data_plane_uri].
|
|
92
94
|
|
|
93
95
|
**Example:** `1234abcd-12ab-12ab-12ab-123456abcdef.eus.cnt-prod.loadtesting.azure.com`
|
|
94
96
|
|
|
@@ -98,15 +100,15 @@ In the above example, `eus` represents the Azure region `East US`.
|
|
|
98
100
|
|
|
99
101
|
### Creating a load test
|
|
100
102
|
|
|
101
|
-
```
|
|
102
|
-
import { AzureLoadTestingClient } from "@azure-rest/load-testing";
|
|
103
|
+
```ts snippet:ReadmeSampleCreateLoadTest
|
|
103
104
|
import AzureLoadTesting from "@azure-rest/load-testing";
|
|
104
105
|
import { DefaultAzureCredential } from "@azure/identity";
|
|
105
106
|
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
const endpoint = "https://<endpoint>";
|
|
108
|
+
const client = AzureLoadTesting(endpoint, new DefaultAzureCredential());
|
|
108
109
|
|
|
109
|
-
const
|
|
110
|
+
const TEST_ID = "some-test-id";
|
|
111
|
+
const DISPLAY_NAME = "my-load-test";
|
|
110
112
|
|
|
111
113
|
await client.path("/tests/{testId}", TEST_ID).patch({
|
|
112
114
|
contentType: "application/merge-patch+json",
|
|
@@ -124,17 +126,17 @@ await client.path("/tests/{testId}", TEST_ID).patch({
|
|
|
124
126
|
});
|
|
125
127
|
```
|
|
126
128
|
|
|
127
|
-
### Uploading
|
|
129
|
+
### Uploading Test script file to a Test
|
|
128
130
|
|
|
129
|
-
```
|
|
130
|
-
import {
|
|
131
|
-
import AzureLoadTesting from "@azure-rest/load-testing";
|
|
131
|
+
```ts snippet:ReadmeSampleUploadTestScriptFile
|
|
132
|
+
import AzureLoadTesting, { isUnexpected, getLongRunningPoller } from "@azure-rest/load-testing";
|
|
132
133
|
import { DefaultAzureCredential } from "@azure/identity";
|
|
133
|
-
import { createReadStream } from "fs";
|
|
134
|
+
import { createReadStream } from "node:fs";
|
|
134
135
|
|
|
135
|
-
const
|
|
136
|
+
const endpoint = "https://<endpoint>";
|
|
137
|
+
const client = AzureLoadTesting(endpoint, new DefaultAzureCredential());
|
|
136
138
|
|
|
137
|
-
|
|
139
|
+
const TEST_ID = "some-test-id";
|
|
138
140
|
const readStream = createReadStream("./sample.jmx");
|
|
139
141
|
|
|
140
142
|
const fileUploadResult = await client
|
|
@@ -148,34 +150,22 @@ if (isUnexpected(fileUploadResult)) {
|
|
|
148
150
|
throw fileUploadResult.body.error;
|
|
149
151
|
}
|
|
150
152
|
|
|
151
|
-
let fileValidateResult;
|
|
152
153
|
const fileValidatePoller = await getLongRunningPoller(client, fileUploadResult);
|
|
153
|
-
|
|
154
|
-
fileValidateResult = await fileValidatePoller.pollUntilDone({
|
|
155
|
-
abortSignal: AbortSignal.timeout(120*1000), // timeout of 120 seconds
|
|
156
|
-
});} catch (ex: any) {
|
|
157
|
-
new Error("Error in polling file Validation" + ex.message); //polling timed out
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
if (fileValidatePoller.getOperationState().status != "succeeded" && fileValidateResult)
|
|
161
|
-
throw new Error(
|
|
162
|
-
"There is some issue in validation, please make sure uploaded file is a valid JMX." +
|
|
163
|
-
fileValidateResult.body.validationFailureDetails
|
|
164
|
-
);
|
|
154
|
+
const fileValidateResult = await fileValidatePoller.pollUntilDone();
|
|
165
155
|
```
|
|
166
156
|
|
|
167
157
|
### Running a Test and fetching Metrics
|
|
168
158
|
|
|
169
|
-
```
|
|
170
|
-
import {
|
|
171
|
-
import AzureLoadTesting from "@azure-rest/load-testing";
|
|
159
|
+
```ts snippet:ReadmeSampleRunTest
|
|
160
|
+
import AzureLoadTesting, { isUnexpected, getLongRunningPoller } from "@azure-rest/load-testing";
|
|
172
161
|
import { DefaultAzureCredential } from "@azure/identity";
|
|
173
162
|
|
|
174
|
-
const
|
|
163
|
+
const endpoint = "https://<endpoint>";
|
|
164
|
+
const client = AzureLoadTesting(endpoint, new DefaultAzureCredential());
|
|
175
165
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
166
|
+
const TEST_ID = "some-test-id";
|
|
167
|
+
const DISPLAY_NAME = "my-load-test";
|
|
168
|
+
const TEST_RUN_ID = "some-test-run-id";
|
|
179
169
|
|
|
180
170
|
// Creating/Updating the test run
|
|
181
171
|
const testRunCreationResult = await client.path("/test-runs/{testRunId}", TEST_RUN_ID).patch({
|
|
@@ -190,72 +180,61 @@ if (isUnexpected(testRunCreationResult)) {
|
|
|
190
180
|
throw testRunCreationResult.body.error;
|
|
191
181
|
}
|
|
192
182
|
|
|
193
|
-
if (testRunCreationResult.body.testRunId === undefined)
|
|
194
|
-
throw new Error("Test Run ID returned as undefined.");
|
|
195
|
-
|
|
196
183
|
const testRunPoller = await getLongRunningPoller(client, testRunCreationResult);
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
metricname: metricDefinition.name,
|
|
252
|
-
metricNamespace: metricNamespace.name,
|
|
253
|
-
timespan: testRunStarttime + "/" + testRunEndTime,
|
|
254
|
-
},
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
console.log(metricsResult);
|
|
258
|
-
console.log(testRunResult);
|
|
184
|
+
const testRunResult = await testRunPoller.pollUntilDone();
|
|
185
|
+
|
|
186
|
+
const testRunStarttime = testRunResult.body.startDateTime;
|
|
187
|
+
const testRunEndTime = testRunResult.body.endDateTime;
|
|
188
|
+
|
|
189
|
+
// get list of all metric namespaces and pick the first one
|
|
190
|
+
const metricNamespaces = await client
|
|
191
|
+
.path("/test-runs/{testRunId}/metric-namespaces", TEST_RUN_ID)
|
|
192
|
+
.get();
|
|
193
|
+
|
|
194
|
+
if (isUnexpected(metricNamespaces)) {
|
|
195
|
+
throw metricNamespaces.body.error;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const metricNamespace = metricNamespaces.body.value[0];
|
|
199
|
+
|
|
200
|
+
if (metricNamespace.name === undefined) {
|
|
201
|
+
throw "No Metric Namespace name is defined.";
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// get list of all metric definitions and pick the first one
|
|
205
|
+
const metricDefinitions = await client
|
|
206
|
+
.path("/test-runs/{testRunId}/metric-definitions", TEST_RUN_ID)
|
|
207
|
+
.get({
|
|
208
|
+
queryParameters: {
|
|
209
|
+
metricNamespace: metricNamespace.name,
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
if (isUnexpected(metricDefinitions)) {
|
|
214
|
+
throw metricDefinitions.body.error;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const metricDefinition = metricDefinitions.body.value[0];
|
|
218
|
+
|
|
219
|
+
if (metricDefinition.name === undefined) {
|
|
220
|
+
throw "No Metric Namespace name is defined.";
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// fetch client metrics using metric namespace and metric name
|
|
224
|
+
const metricsResult = await client.path("/test-runs/{testRunId}/metrics", TEST_RUN_ID).post({
|
|
225
|
+
queryParameters: {
|
|
226
|
+
metricname: metricDefinition.name,
|
|
227
|
+
metricNamespace: metricNamespace.name,
|
|
228
|
+
timespan: testRunStarttime + "/" + testRunEndTime,
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
if (isUnexpected(metricsResult)) {
|
|
233
|
+
throw metricsResult.body.error;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
for (const timeSeries of metricsResult.body.value) {
|
|
237
|
+
console.log(timeSeries);
|
|
259
238
|
}
|
|
260
239
|
```
|
|
261
240
|
|
|
@@ -265,7 +244,7 @@ const testRunPoller = await getLongRunningPoller(client, testRunCreationResult);
|
|
|
265
244
|
|
|
266
245
|
Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:
|
|
267
246
|
|
|
268
|
-
```
|
|
247
|
+
```ts snippet:SetLogLevel
|
|
269
248
|
import { setLogLevel } from "@azure/logger";
|
|
270
249
|
|
|
271
250
|
setLogLevel("info");
|
|
@@ -281,7 +260,7 @@ See [Azure Load Testing samples][sample_code].
|
|
|
281
260
|
|
|
282
261
|
## Contributing
|
|
283
262
|
|
|
284
|
-
For details on contributing to this repository, see the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md).
|
|
263
|
+
For details on contributing to this repository, see the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more on how to build and test the code.
|
|
285
264
|
|
|
286
265
|
1. Fork it
|
|
287
266
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
@@ -289,10 +268,15 @@ For details on contributing to this repository, see the [contributing guide](htt
|
|
|
289
268
|
4. Push to the branch (`git push origin my-new-feature`)
|
|
290
269
|
5. Create new Pull Request
|
|
291
270
|
|
|
271
|
+
## Related Projects
|
|
272
|
+
|
|
273
|
+
- [Microsoft Azure SDK for JavaScript](https://github.com/Azure/azure-sdk-for-js)
|
|
274
|
+
|
|
292
275
|
<!-- LINKS -->
|
|
293
276
|
|
|
294
277
|
[source_code]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/loadtesting/load-testing-rest/src
|
|
295
278
|
[sample_code]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/loadtesting/load-testing-rest/samples/v1-beta
|
|
296
279
|
[api_reference_doc]: https://learn.microsoft.com/rest/api/loadtesting/
|
|
280
|
+
[obtaining_data_plane_uri]: https://learn.microsoft.com/rest/api/loadtesting/data-plane-uri
|
|
297
281
|
[product_documentation]: https://azure.microsoft.com/services/load-testing/
|
|
298
282
|
[azure_subscription]: https://azure.microsoft.com/free/
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import type { ClientOptions } from "@azure-rest/core-client";
|
|
2
2
|
import type { TokenCredential } from "@azure/core-auth";
|
|
3
3
|
import type { AzureLoadTestingClient } from "./clientDefinitions.js";
|
|
4
|
+
/** The optional parameters for the client */
|
|
5
|
+
export interface AzureLoadTestingClientOptions extends ClientOptions {
|
|
6
|
+
/** The api version option of the client */
|
|
7
|
+
apiVersion?: string;
|
|
8
|
+
}
|
|
4
9
|
/**
|
|
5
|
-
* Initialize a new instance of
|
|
6
|
-
* @param
|
|
7
|
-
* @param credentials -
|
|
10
|
+
* Initialize a new instance of `AzureLoadTestingClient`
|
|
11
|
+
* @param endpointParam - A sequence of textual characters.
|
|
12
|
+
* @param credentials - uniquely identify client credential
|
|
13
|
+
* @param options - the parameter for all optional parameters
|
|
8
14
|
*/
|
|
9
|
-
export default function createClient(
|
|
15
|
+
export default function createClient(endpointParam: string, credentials: TokenCredential, { apiVersion, ...options }?: AzureLoadTestingClientOptions): AzureLoadTestingClient;
|
|
10
16
|
//# sourceMappingURL=azureLoadTesting.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"azureLoadTesting.d.ts","sourceRoot":"","sources":["../../src/azureLoadTesting.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"azureLoadTesting.d.ts","sourceRoot":"","sources":["../../src/azureLoadTesting.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAErE,6CAA6C;AAC7C,MAAM,WAAW,6BAA8B,SAAQ,aAAa;IAClE,2CAA2C;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,eAAe,EAC5B,EAAE,UAAiC,EAAE,GAAG,OAAO,EAAE,GAAE,6BAAkC,GACpF,sBAAsB,CAuCxB"}
|
|
@@ -1,26 +1,43 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
|
+
import { __rest } from "tslib";
|
|
3
4
|
import { getClient } from "@azure-rest/core-client";
|
|
5
|
+
import { logger } from "./logger.js";
|
|
4
6
|
/**
|
|
5
|
-
* Initialize a new instance of
|
|
6
|
-
* @param
|
|
7
|
-
* @param credentials -
|
|
7
|
+
* Initialize a new instance of `AzureLoadTestingClient`
|
|
8
|
+
* @param endpointParam - A sequence of textual characters.
|
|
9
|
+
* @param credentials - uniquely identify client credential
|
|
10
|
+
* @param options - the parameter for all optional parameters
|
|
8
11
|
*/
|
|
9
|
-
export default function createClient(
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
options = Object.assign(Object.assign({}, options), { credentials: {
|
|
14
|
-
scopes: ["https://cnt-prod.loadtesting.azure.com/.default"],
|
|
15
|
-
} });
|
|
12
|
+
export default function createClient(endpointParam, credentials, _a = {}) {
|
|
13
|
+
var _b, _c, _d, _e, _f, _g;
|
|
14
|
+
var { apiVersion = "2024-12-01-preview" } = _a, options = __rest(_a, ["apiVersion"]);
|
|
15
|
+
const endpointUrl = (_c = (_b = options.endpoint) !== null && _b !== void 0 ? _b : options.baseUrl) !== null && _c !== void 0 ? _c : `https://${endpointParam}`;
|
|
16
16
|
const userAgentInfo = `azsdk-js-load-testing-rest/1.0.1`;
|
|
17
17
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
18
18
|
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
|
19
19
|
: `${userAgentInfo}`;
|
|
20
20
|
options = Object.assign(Object.assign({}, options), { userAgentOptions: {
|
|
21
21
|
userAgentPrefix,
|
|
22
|
+
}, loggingOptions: {
|
|
23
|
+
logger: (_e = (_d = options.loggingOptions) === null || _d === void 0 ? void 0 : _d.logger) !== null && _e !== void 0 ? _e : logger.info,
|
|
24
|
+
}, credentials: {
|
|
25
|
+
scopes: (_g = (_f = options.credentials) === null || _f === void 0 ? void 0 : _f.scopes) !== null && _g !== void 0 ? _g : ["https://cnt-prod.loadtesting.azure.com/.default"],
|
|
22
26
|
} });
|
|
23
|
-
const client = getClient(
|
|
27
|
+
const client = getClient(endpointUrl, credentials, options);
|
|
28
|
+
client.pipeline.removePolicy({ name: "ApiVersionPolicy" });
|
|
29
|
+
client.pipeline.addPolicy({
|
|
30
|
+
name: "ClientApiVersionPolicy",
|
|
31
|
+
sendRequest: (req, next) => {
|
|
32
|
+
// Use the apiVersion defined in request url directly
|
|
33
|
+
// Append one if there is no apiVersion and we have one at client options
|
|
34
|
+
const url = new URL(req.url);
|
|
35
|
+
if (!url.searchParams.get("api-version") && apiVersion) {
|
|
36
|
+
req.url = `${req.url}${Array.from(url.searchParams.keys()).length > 0 ? "&" : "?"}api-version=${apiVersion}`;
|
|
37
|
+
}
|
|
38
|
+
return next(req);
|
|
39
|
+
},
|
|
40
|
+
});
|
|
24
41
|
return client;
|
|
25
42
|
}
|
|
26
43
|
//# sourceMappingURL=azureLoadTesting.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"azureLoadTesting.js","sourceRoot":"","sources":["../../src/azureLoadTesting.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC
|
|
1
|
+
{"version":3,"file":"azureLoadTesting.js","sourceRoot":"","sources":["../../src/azureLoadTesting.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAGlC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAUrC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,aAAqB,EACrB,WAA4B,EAC5B,KAAmF,EAAE;;QAArF,EAAE,UAAU,GAAG,oBAAoB,OAAkD,EAA7C,OAAO,cAA/C,cAAiD,CAAF;IAE/C,MAAM,WAAW,GAAG,MAAA,MAAA,OAAO,CAAC,QAAQ,mCAAI,OAAO,CAAC,OAAO,mCAAI,WAAW,aAAa,EAAE,CAAC;IACtF,MAAM,aAAa,GAAG,kCAAkC,CAAC;IACzD,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;QAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,aAAa,EAAE;QAChE,CAAC,CAAC,GAAG,aAAa,EAAE,CAAC;IACzB,OAAO,mCACF,OAAO,KACV,gBAAgB,EAAE;YAChB,eAAe;SAChB,EACD,cAAc,EAAE;YACd,MAAM,EAAE,MAAA,MAAA,OAAO,CAAC,cAAc,0CAAE,MAAM,mCAAI,MAAM,CAAC,IAAI;SACtD,EACD,WAAW,EAAE;YACX,MAAM,EAAE,MAAA,MAAA,OAAO,CAAC,WAAW,0CAAE,MAAM,mCAAI,CAAC,iDAAiD,CAAC;SAC3F,GACF,CAAC;IACF,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAA2B,CAAC;IAEtF,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC,CAAC;IAC3D,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;QACxB,IAAI,EAAE,wBAAwB;QAC9B,WAAW,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YACzB,qDAAqD;YACrD,yEAAyE;YACzE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC7B,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,UAAU,EAAE,CAAC;gBACvD,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,GAAG,GAClB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GACzD,eAAe,UAAU,EAAE,CAAC;YAC9B,CAAC;YAED,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ClientOptions } from \"@azure-rest/core-client\";\nimport { getClient } from \"@azure-rest/core-client\";\nimport { logger } from \"./logger.js\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport type { AzureLoadTestingClient } from \"./clientDefinitions.js\";\n\n/** The optional parameters for the client */\nexport interface AzureLoadTestingClientOptions extends ClientOptions {\n /** The api version option of the client */\n apiVersion?: string;\n}\n\n/**\n * Initialize a new instance of `AzureLoadTestingClient`\n * @param endpointParam - A sequence of textual characters.\n * @param credentials - uniquely identify client credential\n * @param options - the parameter for all optional parameters\n */\nexport default function createClient(\n endpointParam: string,\n credentials: TokenCredential,\n { apiVersion = \"2024-12-01-preview\", ...options }: AzureLoadTestingClientOptions = {},\n): AzureLoadTestingClient {\n const endpointUrl = options.endpoint ?? options.baseUrl ?? `https://${endpointParam}`;\n const userAgentInfo = `azsdk-js-load-testing-rest/1.0.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix,\n },\n loggingOptions: {\n logger: options.loggingOptions?.logger ?? logger.info,\n },\n credentials: {\n scopes: options.credentials?.scopes ?? [\"https://cnt-prod.loadtesting.azure.com/.default\"],\n },\n };\n const client = getClient(endpointUrl, credentials, options) as AzureLoadTestingClient;\n\n client.pipeline.removePolicy({ name: \"ApiVersionPolicy\" });\n client.pipeline.addPolicy({\n name: \"ClientApiVersionPolicy\",\n sendRequest: (req, next) => {\n // Use the apiVersion defined in request url directly\n // Append one if there is no apiVersion and we have one at client options\n const url = new URL(req.url);\n if (!url.searchParams.get(\"api-version\") && apiVersion) {\n req.url = `${req.url}${\n Array.from(url.searchParams.keys()).length > 0 ? \"&\" : \"?\"\n }api-version=${apiVersion}`;\n }\n\n return next(req);\n },\n });\n\n return client;\n}\n"]}
|