@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.
Files changed (208) hide show
  1. package/LICENSE +4 -4
  2. package/README.md +91 -107
  3. package/dist/browser/azureLoadTesting.d.ts +10 -4
  4. package/dist/browser/azureLoadTesting.d.ts.map +1 -1
  5. package/dist/browser/azureLoadTesting.js +28 -11
  6. package/dist/browser/azureLoadTesting.js.map +1 -1
  7. package/dist/browser/clientDefinitions.d.ts +164 -84
  8. package/dist/browser/clientDefinitions.d.ts.map +1 -1
  9. package/dist/browser/clientDefinitions.js.map +1 -1
  10. package/dist/browser/getFileValidationPoller.d.ts +2 -2
  11. package/dist/browser/getFileValidationPoller.d.ts.map +1 -1
  12. package/dist/browser/getFileValidationPoller.js.map +1 -1
  13. package/dist/browser/getTestProfileRunCompletionPoller.d.ts +11 -0
  14. package/dist/browser/getTestProfileRunCompletionPoller.d.ts.map +1 -0
  15. package/dist/browser/getTestProfileRunCompletionPoller.js +127 -0
  16. package/dist/browser/getTestProfileRunCompletionPoller.js.map +1 -0
  17. package/dist/browser/getTestRunCompletionPoller.d.ts +2 -2
  18. package/dist/browser/getTestRunCompletionPoller.d.ts.map +1 -1
  19. package/dist/browser/getTestRunCompletionPoller.js.map +1 -1
  20. package/dist/browser/index.d.ts.map +1 -1
  21. package/dist/browser/index.js.map +1 -1
  22. package/dist/browser/isUnexpected.d.ts +44 -27
  23. package/dist/browser/isUnexpected.d.ts.map +1 -1
  24. package/dist/browser/isUnexpected.js +52 -32
  25. package/dist/browser/isUnexpected.js.map +1 -1
  26. package/dist/browser/logger.d.ts +2 -0
  27. package/dist/browser/logger.d.ts.map +1 -0
  28. package/dist/browser/logger.js +5 -0
  29. package/dist/browser/logger.js.map +1 -0
  30. package/dist/browser/models.d.ts +545 -220
  31. package/dist/browser/models.d.ts.map +1 -1
  32. package/dist/browser/models.js.map +1 -1
  33. package/dist/browser/outputModels.d.ts +844 -207
  34. package/dist/browser/outputModels.d.ts.map +1 -1
  35. package/dist/browser/outputModels.js.map +1 -1
  36. package/dist/browser/paginateHelper.d.ts +27 -2
  37. package/dist/browser/paginateHelper.d.ts.map +1 -1
  38. package/dist/browser/paginateHelper.js +98 -1
  39. package/dist/browser/paginateHelper.js.map +1 -1
  40. package/dist/browser/parameters.d.ts +327 -123
  41. package/dist/browser/parameters.d.ts.map +1 -1
  42. package/dist/browser/parameters.js.map +1 -1
  43. package/dist/browser/pollingHelper.d.ts +2 -1
  44. package/dist/browser/pollingHelper.d.ts.map +1 -1
  45. package/dist/browser/pollingHelper.js +7 -0
  46. package/dist/browser/pollingHelper.js.map +1 -1
  47. package/dist/browser/responses.d.ts +464 -239
  48. package/dist/browser/responses.d.ts.map +1 -1
  49. package/dist/browser/responses.js.map +1 -1
  50. package/dist/browser/util/LROUtil.d.ts +2 -1
  51. package/dist/browser/util/LROUtil.d.ts.map +1 -1
  52. package/dist/browser/util/LROUtil.js +13 -0
  53. package/dist/browser/util/LROUtil.js.map +1 -1
  54. package/dist/commonjs/azureLoadTesting.d.ts +10 -4
  55. package/dist/commonjs/azureLoadTesting.d.ts.map +1 -1
  56. package/dist/commonjs/azureLoadTesting.js +28 -11
  57. package/dist/commonjs/azureLoadTesting.js.map +1 -1
  58. package/dist/commonjs/clientDefinitions.d.ts +164 -84
  59. package/dist/commonjs/clientDefinitions.d.ts.map +1 -1
  60. package/dist/commonjs/clientDefinitions.js.map +1 -1
  61. package/dist/commonjs/getFileValidationPoller.d.ts +2 -2
  62. package/dist/commonjs/getFileValidationPoller.d.ts.map +1 -1
  63. package/dist/commonjs/getFileValidationPoller.js.map +1 -1
  64. package/dist/commonjs/getTestProfileRunCompletionPoller.d.ts +11 -0
  65. package/dist/commonjs/getTestProfileRunCompletionPoller.d.ts.map +1 -0
  66. package/dist/commonjs/getTestProfileRunCompletionPoller.js +130 -0
  67. package/dist/commonjs/getTestProfileRunCompletionPoller.js.map +1 -0
  68. package/dist/commonjs/getTestRunCompletionPoller.d.ts +2 -2
  69. package/dist/commonjs/getTestRunCompletionPoller.d.ts.map +1 -1
  70. package/dist/commonjs/getTestRunCompletionPoller.js.map +1 -1
  71. package/dist/commonjs/index.d.ts.map +1 -1
  72. package/dist/commonjs/index.js.map +1 -1
  73. package/dist/commonjs/isUnexpected.d.ts +44 -27
  74. package/dist/commonjs/isUnexpected.d.ts.map +1 -1
  75. package/dist/commonjs/isUnexpected.js +52 -32
  76. package/dist/commonjs/isUnexpected.js.map +1 -1
  77. package/dist/commonjs/logger.d.ts +2 -0
  78. package/dist/commonjs/logger.d.ts.map +1 -0
  79. package/dist/commonjs/logger.js +8 -0
  80. package/dist/commonjs/logger.js.map +1 -0
  81. package/dist/commonjs/models.d.ts +545 -220
  82. package/dist/commonjs/models.d.ts.map +1 -1
  83. package/dist/commonjs/models.js.map +1 -1
  84. package/dist/commonjs/outputModels.d.ts +844 -207
  85. package/dist/commonjs/outputModels.d.ts.map +1 -1
  86. package/dist/commonjs/outputModels.js.map +1 -1
  87. package/dist/commonjs/paginateHelper.d.ts +27 -2
  88. package/dist/commonjs/paginateHelper.d.ts.map +1 -1
  89. package/dist/commonjs/paginateHelper.js +99 -2
  90. package/dist/commonjs/paginateHelper.js.map +1 -1
  91. package/dist/commonjs/parameters.d.ts +327 -123
  92. package/dist/commonjs/parameters.d.ts.map +1 -1
  93. package/dist/commonjs/parameters.js.map +1 -1
  94. package/dist/commonjs/pollingHelper.d.ts +2 -1
  95. package/dist/commonjs/pollingHelper.d.ts.map +1 -1
  96. package/dist/commonjs/pollingHelper.js +7 -0
  97. package/dist/commonjs/pollingHelper.js.map +1 -1
  98. package/dist/commonjs/responses.d.ts +464 -239
  99. package/dist/commonjs/responses.d.ts.map +1 -1
  100. package/dist/commonjs/responses.js.map +1 -1
  101. package/dist/commonjs/tsdoc-metadata.json +1 -1
  102. package/dist/commonjs/util/LROUtil.d.ts +2 -1
  103. package/dist/commonjs/util/LROUtil.d.ts.map +1 -1
  104. package/dist/commonjs/util/LROUtil.js +14 -0
  105. package/dist/commonjs/util/LROUtil.js.map +1 -1
  106. package/dist/esm/azureLoadTesting.d.ts +10 -4
  107. package/dist/esm/azureLoadTesting.d.ts.map +1 -1
  108. package/dist/esm/azureLoadTesting.js +28 -11
  109. package/dist/esm/azureLoadTesting.js.map +1 -1
  110. package/dist/esm/clientDefinitions.d.ts +164 -84
  111. package/dist/esm/clientDefinitions.d.ts.map +1 -1
  112. package/dist/esm/clientDefinitions.js.map +1 -1
  113. package/dist/esm/getFileValidationPoller.d.ts +2 -2
  114. package/dist/esm/getFileValidationPoller.d.ts.map +1 -1
  115. package/dist/esm/getFileValidationPoller.js.map +1 -1
  116. package/dist/esm/getTestProfileRunCompletionPoller.d.ts +11 -0
  117. package/dist/esm/getTestProfileRunCompletionPoller.d.ts.map +1 -0
  118. package/dist/esm/getTestProfileRunCompletionPoller.js +127 -0
  119. package/dist/esm/getTestProfileRunCompletionPoller.js.map +1 -0
  120. package/dist/esm/getTestRunCompletionPoller.d.ts +2 -2
  121. package/dist/esm/getTestRunCompletionPoller.d.ts.map +1 -1
  122. package/dist/esm/getTestRunCompletionPoller.js.map +1 -1
  123. package/dist/esm/index.d.ts.map +1 -1
  124. package/dist/esm/index.js.map +1 -1
  125. package/dist/esm/isUnexpected.d.ts +44 -27
  126. package/dist/esm/isUnexpected.d.ts.map +1 -1
  127. package/dist/esm/isUnexpected.js +52 -32
  128. package/dist/esm/isUnexpected.js.map +1 -1
  129. package/dist/esm/logger.d.ts +2 -0
  130. package/dist/esm/logger.d.ts.map +1 -0
  131. package/dist/esm/logger.js +5 -0
  132. package/dist/esm/logger.js.map +1 -0
  133. package/dist/esm/models.d.ts +545 -220
  134. package/dist/esm/models.d.ts.map +1 -1
  135. package/dist/esm/models.js.map +1 -1
  136. package/dist/esm/outputModels.d.ts +844 -207
  137. package/dist/esm/outputModels.d.ts.map +1 -1
  138. package/dist/esm/outputModels.js.map +1 -1
  139. package/dist/esm/paginateHelper.d.ts +27 -2
  140. package/dist/esm/paginateHelper.d.ts.map +1 -1
  141. package/dist/esm/paginateHelper.js +98 -1
  142. package/dist/esm/paginateHelper.js.map +1 -1
  143. package/dist/esm/parameters.d.ts +327 -123
  144. package/dist/esm/parameters.d.ts.map +1 -1
  145. package/dist/esm/parameters.js.map +1 -1
  146. package/dist/esm/pollingHelper.d.ts +2 -1
  147. package/dist/esm/pollingHelper.d.ts.map +1 -1
  148. package/dist/esm/pollingHelper.js +7 -0
  149. package/dist/esm/pollingHelper.js.map +1 -1
  150. package/dist/esm/responses.d.ts +464 -239
  151. package/dist/esm/responses.d.ts.map +1 -1
  152. package/dist/esm/responses.js.map +1 -1
  153. package/dist/esm/util/LROUtil.d.ts +2 -1
  154. package/dist/esm/util/LROUtil.d.ts.map +1 -1
  155. package/dist/esm/util/LROUtil.js +13 -0
  156. package/dist/esm/util/LROUtil.js.map +1 -1
  157. package/dist/react-native/azureLoadTesting.d.ts +10 -4
  158. package/dist/react-native/azureLoadTesting.d.ts.map +1 -1
  159. package/dist/react-native/azureLoadTesting.js +28 -11
  160. package/dist/react-native/azureLoadTesting.js.map +1 -1
  161. package/dist/react-native/clientDefinitions.d.ts +164 -84
  162. package/dist/react-native/clientDefinitions.d.ts.map +1 -1
  163. package/dist/react-native/clientDefinitions.js.map +1 -1
  164. package/dist/react-native/getFileValidationPoller.d.ts +2 -2
  165. package/dist/react-native/getFileValidationPoller.d.ts.map +1 -1
  166. package/dist/react-native/getFileValidationPoller.js.map +1 -1
  167. package/dist/react-native/getTestProfileRunCompletionPoller.d.ts +11 -0
  168. package/dist/react-native/getTestProfileRunCompletionPoller.d.ts.map +1 -0
  169. package/dist/react-native/getTestProfileRunCompletionPoller.js +127 -0
  170. package/dist/react-native/getTestProfileRunCompletionPoller.js.map +1 -0
  171. package/dist/react-native/getTestRunCompletionPoller.d.ts +2 -2
  172. package/dist/react-native/getTestRunCompletionPoller.d.ts.map +1 -1
  173. package/dist/react-native/getTestRunCompletionPoller.js.map +1 -1
  174. package/dist/react-native/index.d.ts.map +1 -1
  175. package/dist/react-native/index.js.map +1 -1
  176. package/dist/react-native/isUnexpected.d.ts +44 -27
  177. package/dist/react-native/isUnexpected.d.ts.map +1 -1
  178. package/dist/react-native/isUnexpected.js +52 -32
  179. package/dist/react-native/isUnexpected.js.map +1 -1
  180. package/dist/react-native/logger.d.ts +2 -0
  181. package/dist/react-native/logger.d.ts.map +1 -0
  182. package/dist/react-native/logger.js +5 -0
  183. package/dist/react-native/logger.js.map +1 -0
  184. package/dist/react-native/models.d.ts +545 -220
  185. package/dist/react-native/models.d.ts.map +1 -1
  186. package/dist/react-native/models.js.map +1 -1
  187. package/dist/react-native/outputModels.d.ts +844 -207
  188. package/dist/react-native/outputModels.d.ts.map +1 -1
  189. package/dist/react-native/outputModels.js.map +1 -1
  190. package/dist/react-native/paginateHelper.d.ts +27 -2
  191. package/dist/react-native/paginateHelper.d.ts.map +1 -1
  192. package/dist/react-native/paginateHelper.js +98 -1
  193. package/dist/react-native/paginateHelper.js.map +1 -1
  194. package/dist/react-native/parameters.d.ts +327 -123
  195. package/dist/react-native/parameters.d.ts.map +1 -1
  196. package/dist/react-native/parameters.js.map +1 -1
  197. package/dist/react-native/pollingHelper.d.ts +2 -1
  198. package/dist/react-native/pollingHelper.d.ts.map +1 -1
  199. package/dist/react-native/pollingHelper.js +7 -0
  200. package/dist/react-native/pollingHelper.js.map +1 -1
  201. package/dist/react-native/responses.d.ts +464 -239
  202. package/dist/react-native/responses.d.ts.map +1 -1
  203. package/dist/react-native/responses.js.map +1 -1
  204. package/dist/react-native/util/LROUtil.d.ts +2 -1
  205. package/dist/react-native/util/LROUtil.d.ts.map +1 -1
  206. package/dist/react-native/util/LROUtil.js +13 -0
  207. package/dist/react-native/util/LROUtil.js.map +1 -1
  208. package/package.json +23 -21
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
- The MIT License (MIT)
1
+ Copyright (c) Microsoft Corporation.
2
2
 
3
- Copyright (c) 2022 Microsoft
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 "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
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 AzureLoadTesting client REST client library for JavaScript with `npm`:
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
- ```javascript
49
- import AzureLoadTesting, { AzureLoadTestingClient } from "@azure-rest/load-testing";
49
+ ```ts snippet:ReadmeSampleCreateClient_Node
50
+ import AzureLoadTesting from "@azure-rest/load-testing";
50
51
  import { DefaultAzureCredential } from "@azure/identity";
51
52
 
52
- const Client: AzureLoadTestingClient = AzureLoadTesting(Endpoint, new DefaultAzureCredential());
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
- ```javascript
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
- var TEST_ID = "some-test-id";
107
- var DISPLAY_NAME = "my-load-test";
107
+ const endpoint = "https://<endpoint>";
108
+ const client = AzureLoadTesting(endpoint, new DefaultAzureCredential());
108
109
 
109
- const client: AzureLoadTestingClient = AzureLoadTesting("<Endpoint>", new DefaultAzureCredential());
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 .jmx file to a Test
129
+ ### Uploading Test script file to a Test
128
130
 
129
- ```javascript
130
- import { AzureLoadTestingClient, getLongRunningPoller, isUnexpected } from "@azure-rest/load-testing";
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 client: AzureLoadTestingClient = AzureLoadTesting("<Endpoint>", new DefaultAzureCredential());
136
+ const endpoint = "https://<endpoint>";
137
+ const client = AzureLoadTesting(endpoint, new DefaultAzureCredential());
136
138
 
137
- var TEST_ID = "some-test-id";
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
- try{
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
- ```javascript
170
- import { AzureLoadTestingClient, getLongRunningPoller, isUnexpected } from "@azure-rest/load-testing";
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 client: AzureLoadTestingClient = AzureLoadTesting("<Endpoint>", new DefaultAzureCredential());
163
+ const endpoint = "https://<endpoint>";
164
+ const client = AzureLoadTesting(endpoint, new DefaultAzureCredential());
175
165
 
176
- var TEST_ID = "some-test-id";
177
- var DISPLAY_NAME = "my-load-test";
178
- var TEST_RUN_ID = "some-test-run-id";
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
- let testRunResult;
198
-
199
- try {
200
- testRunResult = await testRunPoller.pollUntilDone({
201
- abortSignal: AbortSignal.timeout(60000), // timeout of 60 seconds
202
- });
203
- } catch (ex: any) {
204
- new Error("Error in polling test run completion" + ex.message); //polling timed out
205
- }
206
-
207
- if (testRunPoller.getOperationState().status != "succeeded")
208
- throw new Error("There is some issue in running the test, Error Response : " + testRunResult);
209
-
210
- if (testRunResult) {
211
- let testRunStarttime = testRunResult.body.startDateTime;
212
- let testRunEndTime = testRunResult.body.endDateTime;
213
-
214
- // get list of all metric namespaces and pick the first one
215
- const metricNamespaces = await client
216
- .path("/test-runs/{testRunId}/metric-namespaces", TEST_RUN_ID)
217
- .get();
218
-
219
- if (isUnexpected(metricNamespaces)) {
220
- throw metricNamespaces.body.error;
221
- }
222
-
223
- const metricNamespace = metricNamespaces.body.value[0];
224
-
225
- if (metricNamespace.name === undefined) {
226
- throw "No Metric Namespace name is defined.";
227
- }
228
-
229
- // get list of all metric definitions and pick the first one
230
- const metricDefinitions = await client
231
- .path("/test-runs/{testRunId}/metric-definitions", TEST_RUN_ID)
232
- .get({
233
- queryParameters: {
234
- metricNamespace: metricNamespace.name,
235
- },
236
- });
237
-
238
- if (isUnexpected(metricDefinitions)) {
239
- throw metricDefinitions.body.error;
240
- }
241
-
242
- const metricDefinition = metricDefinitions.body.value[0];
243
-
244
- if (metricDefinition.name === undefined) {
245
- throw "No Metric Namespace name is defined.";
246
- }
247
-
248
- // fetch client metrics using metric namespace and metric name
249
- const metricsResult = await client.path("/test-runs/{testRunId}/metrics", TEST_RUN_ID).post({
250
- queryParameters: {
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
- ```javascript
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 the class AzureLoadTestingClient class.
6
- * @param Endpoint - type: string URL to perform data plane API operations on the resource.
7
- * @param credentials - type: TokenCredential
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(Endpoint: string, credentials: TokenCredential, options?: ClientOptions): AzureLoadTestingClient;
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;AAE7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAErE;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,eAAe,EAC5B,OAAO,GAAE,aAAkB,GAC1B,sBAAsB,CAyBxB"}
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 the class AzureLoadTestingClient class.
6
- * @param Endpoint - type: string URL to perform data plane API operations on the resource.
7
- * @param credentials - type: TokenCredential
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(Endpoint, credentials, options = {}) {
10
- var _a, _b;
11
- const baseUrl = (_a = options.baseUrl) !== null && _a !== void 0 ? _a : `https://${Endpoint}`;
12
- options.apiVersion = (_b = options.apiVersion) !== null && _b !== void 0 ? _b : "2022-11-01";
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(baseUrl, credentials, options);
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;AAGlC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAIpD;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,QAAgB,EAChB,WAA4B,EAC5B,UAAyB,EAAE;;IAE3B,MAAM,OAAO,GAAG,MAAA,OAAO,CAAC,OAAO,mCAAI,WAAW,QAAQ,EAAE,CAAC;IACzD,OAAO,CAAC,UAAU,GAAG,MAAA,OAAO,CAAC,UAAU,mCAAI,YAAY,CAAC;IACxD,OAAO,mCACF,OAAO,KACV,WAAW,EAAE;YACX,MAAM,EAAE,CAAC,iDAAiD,CAAC;SAC5D,GACF,CAAC;IAEF,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,GACF,CAAC;IAEF,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAA2B,CAAC;IAElF,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 type { TokenCredential } from \"@azure/core-auth\";\nimport type { AzureLoadTestingClient } from \"./clientDefinitions.js\";\n\n/**\n * Initialize a new instance of the class AzureLoadTestingClient class.\n * @param Endpoint - type: string URL to perform data plane API operations on the resource.\n * @param credentials - type: TokenCredential\n */\nexport default function createClient(\n Endpoint: string,\n credentials: TokenCredential,\n options: ClientOptions = {},\n): AzureLoadTestingClient {\n const baseUrl = options.baseUrl ?? `https://${Endpoint}`;\n options.apiVersion = options.apiVersion ?? \"2022-11-01\";\n options = {\n ...options,\n credentials: {\n scopes: [\"https://cnt-prod.loadtesting.azure.com/.default\"],\n },\n };\n\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 };\n\n const client = getClient(baseUrl, credentials, options) as AzureLoadTestingClient;\n\n return client;\n}\n"]}
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"]}