From 382e6d126c47e09724ca6147e39e8eedd4ce159a Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 25 Sep 2024 21:25:13 +0000 Subject: [PATCH] CodeGen from PR 30738 in Azure/azure-rest-api-specs Merge d211e17fb9391173470717311d645620954f5840 into 93837eec52045805de3df1346c2abb8afe21325a --- .../load-testing-rest/CHANGELOG.md | 35 - sdk/loadtesting/load-testing-rest/LICENSE | 21 - sdk/loadtesting/load-testing-rest/README.md | 298 --- .../load-testing-rest/api-extractor.json | 18 - sdk/loadtesting/load-testing-rest/assets.json | 6 - .../load-testing-rest/eslint.config.mjs | 14 - .../load-testing-rest/karma.conf.js | 135 -- .../load-testing-rest/package.json | 134 -- .../review/load-testing.api.md | 1729 ----------------- sdk/loadtesting/load-testing-rest/sample.env | 8 - .../load-testing-rest/samples-dev/sample.jmx | 89 - .../load-testing-rest/samples-dev/sample.ts | 196 -- .../load-testing-rest/samples-dev/stopTest.ts | 68 - .../samples/v1-beta/javascript/README.md | 64 - .../samples/v1-beta/javascript/package.json | 35 - .../samples/v1-beta/javascript/sample.env | 8 - .../samples/v1-beta/javascript/sample.js | 197 -- .../samples/v1-beta/javascript/stopTest.js | 68 - .../samples/v1-beta/typescript/README.md | 77 - .../samples/v1-beta/typescript/package.json | 45 - .../samples/v1-beta/typescript/sample.env | 8 - .../samples/v1-beta/typescript/src/sample.ts | 195 -- .../v1-beta/typescript/src/stopTest.ts | 67 - .../samples/v1-beta/typescript/tsconfig.json | 17 - .../samples/v1/javascript/README.md | 68 - .../v1/javascript/createAppComponent.js | 67 - .../v1/javascript/createOrUpdateTest.js | 35 - .../javascript/createTestRunAndGetMetrics.js | 62 - .../samples/v1/javascript/fileUpload.js | 59 - .../samples/v1/javascript/package.json | 34 - .../samples/v1/javascript/sample.env | 4 - .../samples/v1/typescript/README.md | 81 - .../samples/v1/typescript/package.json | 44 - .../samples/v1/typescript/sample.env | 4 - .../v1/typescript/src/createAppComponent.ts | 65 - .../v1/typescript/src/createOrUpdateTest.ts | 35 - .../src/createTestRunAndGetMetrics.ts | 61 - .../samples/v1/typescript/src/fileUpload.ts | 58 - .../samples/v1/typescript/tsconfig.json | 17 - .../load-testing-rest/src/azureLoadTesting.ts | 64 +- .../src/clientDefinitions.ts | 605 ++++-- .../src/getFileValidationPoller.ts | 172 -- .../src/getTestRunCompletionPoller.ts | 155 -- .../load-testing-rest/src/index.ts | 20 +- .../load-testing-rest/src/isUnexpected.ts | 678 ++++--- .../load-testing-rest/src/logger.ts | 5 + .../load-testing-rest/src/models.ts | 551 +++--- .../load-testing-rest/src/outputModels.ts | 796 +++++--- .../load-testing-rest/src/paginateHelper.ts | 33 +- .../load-testing-rest/src/parameters.ts | 419 ++-- .../load-testing-rest/src/pollingHelper.ts | 40 - .../load-testing-rest/src/responses.ts | 698 ++++--- .../load-testing-rest/src/util/LROUtil.ts | 52 - .../load-testing-rest/swagger/README.md | 25 - .../test/public/additional-data.csv | 2 - .../load-testing-rest/test/public/sample.jmx | 89 - .../test/public/testAdministration.spec.ts | 163 -- .../test/public/testRun.spec.ts | 190 -- .../test/public/utils/env.browser.ts | 2 - .../test/public/utils/env.ts | 6 - .../test/public/utils/recordedClient.ts | 45 - .../load-testing-rest/tsconfig.json | 11 - .../load-testing-rest/tsp-location.yaml | 4 + 63 files changed, 2510 insertions(+), 6541 deletions(-) delete mode 100644 sdk/loadtesting/load-testing-rest/CHANGELOG.md delete mode 100644 sdk/loadtesting/load-testing-rest/LICENSE delete mode 100644 sdk/loadtesting/load-testing-rest/README.md delete mode 100644 sdk/loadtesting/load-testing-rest/api-extractor.json delete mode 100644 sdk/loadtesting/load-testing-rest/assets.json delete mode 100644 sdk/loadtesting/load-testing-rest/eslint.config.mjs delete mode 100644 sdk/loadtesting/load-testing-rest/karma.conf.js delete mode 100644 sdk/loadtesting/load-testing-rest/package.json delete mode 100644 sdk/loadtesting/load-testing-rest/review/load-testing.api.md delete mode 100644 sdk/loadtesting/load-testing-rest/sample.env delete mode 100644 sdk/loadtesting/load-testing-rest/samples-dev/sample.jmx delete mode 100644 sdk/loadtesting/load-testing-rest/samples-dev/sample.ts delete mode 100644 sdk/loadtesting/load-testing-rest/samples-dev/stopTest.ts delete mode 100644 sdk/loadtesting/load-testing-rest/samples/v1-beta/javascript/README.md delete mode 100644 sdk/loadtesting/load-testing-rest/samples/v1-beta/javascript/package.json delete mode 100644 sdk/loadtesting/load-testing-rest/samples/v1-beta/javascript/sample.env delete mode 100644 sdk/loadtesting/load-testing-rest/samples/v1-beta/javascript/sample.js delete mode 100644 sdk/loadtesting/load-testing-rest/samples/v1-beta/javascript/stopTest.js delete mode 100644 sdk/loadtesting/load-testing-rest/samples/v1-beta/typescript/README.md delete mode 100644 sdk/loadtesting/load-testing-rest/samples/v1-beta/typescript/package.json delete mode 100644 sdk/loadtesting/load-testing-rest/samples/v1-beta/typescript/sample.env delete mode 100644 sdk/loadtesting/load-testing-rest/samples/v1-beta/typescript/src/sample.ts delete mode 100644 sdk/loadtesting/load-testing-rest/samples/v1-beta/typescript/src/stopTest.ts delete mode 100644 sdk/loadtesting/load-testing-rest/samples/v1-beta/typescript/tsconfig.json delete mode 100644 sdk/loadtesting/load-testing-rest/samples/v1/javascript/README.md delete mode 100644 sdk/loadtesting/load-testing-rest/samples/v1/javascript/createAppComponent.js delete mode 100644 sdk/loadtesting/load-testing-rest/samples/v1/javascript/createOrUpdateTest.js delete mode 100644 sdk/loadtesting/load-testing-rest/samples/v1/javascript/createTestRunAndGetMetrics.js delete mode 100644 sdk/loadtesting/load-testing-rest/samples/v1/javascript/fileUpload.js delete mode 100644 sdk/loadtesting/load-testing-rest/samples/v1/javascript/package.json delete mode 100644 sdk/loadtesting/load-testing-rest/samples/v1/javascript/sample.env delete mode 100644 sdk/loadtesting/load-testing-rest/samples/v1/typescript/README.md delete mode 100644 sdk/loadtesting/load-testing-rest/samples/v1/typescript/package.json delete mode 100644 sdk/loadtesting/load-testing-rest/samples/v1/typescript/sample.env delete mode 100644 sdk/loadtesting/load-testing-rest/samples/v1/typescript/src/createAppComponent.ts delete mode 100644 sdk/loadtesting/load-testing-rest/samples/v1/typescript/src/createOrUpdateTest.ts delete mode 100644 sdk/loadtesting/load-testing-rest/samples/v1/typescript/src/createTestRunAndGetMetrics.ts delete mode 100644 sdk/loadtesting/load-testing-rest/samples/v1/typescript/src/fileUpload.ts delete mode 100644 sdk/loadtesting/load-testing-rest/samples/v1/typescript/tsconfig.json delete mode 100644 sdk/loadtesting/load-testing-rest/src/getFileValidationPoller.ts delete mode 100644 sdk/loadtesting/load-testing-rest/src/getTestRunCompletionPoller.ts create mode 100644 sdk/loadtesting/load-testing-rest/src/logger.ts delete mode 100644 sdk/loadtesting/load-testing-rest/src/pollingHelper.ts delete mode 100644 sdk/loadtesting/load-testing-rest/src/util/LROUtil.ts delete mode 100644 sdk/loadtesting/load-testing-rest/swagger/README.md delete mode 100644 sdk/loadtesting/load-testing-rest/test/public/additional-data.csv delete mode 100644 sdk/loadtesting/load-testing-rest/test/public/sample.jmx delete mode 100644 sdk/loadtesting/load-testing-rest/test/public/testAdministration.spec.ts delete mode 100644 sdk/loadtesting/load-testing-rest/test/public/testRun.spec.ts delete mode 100644 sdk/loadtesting/load-testing-rest/test/public/utils/env.browser.ts delete mode 100644 sdk/loadtesting/load-testing-rest/test/public/utils/env.ts delete mode 100644 sdk/loadtesting/load-testing-rest/test/public/utils/recordedClient.ts delete mode 100644 sdk/loadtesting/load-testing-rest/tsconfig.json create mode 100644 sdk/loadtesting/load-testing-rest/tsp-location.yaml diff --git a/sdk/loadtesting/load-testing-rest/CHANGELOG.md b/sdk/loadtesting/load-testing-rest/CHANGELOG.md deleted file mode 100644 index 5c0c1e2a2b41..000000000000 --- a/sdk/loadtesting/load-testing-rest/CHANGELOG.md +++ /dev/null @@ -1,35 +0,0 @@ -# Release History - -## 1.0.1 (Unreleased) - -### Features Added - -### Breaking Changes - -### Bugs Fixed - -### Other Changes - -## 1.0.0 (2023-03-07) - -First stable release of Azure Load Testing client library for Javascript. - -## 1.0.0-beta.2 (2023-01-26) - -Second preview release of Azure Load Testing client library for Javascript. - -### Features Added - -- Added `LoadTestClient.getLongRunningPoller` Long-Running operation helper - -### Breaking Changes - -- Added metric namespaces and metric dimensions -- File upload now uses `application/octet-stream` instead of `multipart/form-data` -- File upload now uses file name as primary identifier instead of `fileId` - -## 1.0.0-beta.1 (2022-10-19) - -### Features Added - -Initial release of the Azure LoadTesting package diff --git a/sdk/loadtesting/load-testing-rest/LICENSE b/sdk/loadtesting/load-testing-rest/LICENSE deleted file mode 100644 index 5d1d36e0af80..000000000000 --- a/sdk/loadtesting/load-testing-rest/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2022 Microsoft - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/sdk/loadtesting/load-testing-rest/README.md b/sdk/loadtesting/load-testing-rest/README.md deleted file mode 100644 index 355b4095a451..000000000000 --- a/sdk/loadtesting/load-testing-rest/README.md +++ /dev/null @@ -1,298 +0,0 @@ -# Azure Load Testing client library for JavaScript - -Azure Load Testing provides client library in JavaScript to the user by which they can interact natively with Azure Load Testing service. Azure Load Testing is a fully managed load-testing service that enables you to generate high-scale load. The service simulates traffic for your applications, regardless of where they're hosted. Developers, testers, and quality assurance (QA) engineers can use it to optimize application performance, scalability, or capacity. - -**Please rely heavily on our [REST client docs](https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/rest-clients.md) to use this library** - -## Documentation - -Various documentation is available to help you get started - -- [Source code][source_code] -- [API reference documentation][api_reference_doc] -- [Product Documentation][product_documentation] - -## Getting started - -### Currently supported environments - -- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule) - -### Prerequisites - -- 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. - -### Install the `@azure-rest/load-testing` package - -Install the AzureLoadTesting client REST client library for JavaScript with `npm`: - -```bash -npm install @azure-rest/load-testing -``` - -### Create and authenticate a `AzureLoadTesting` client - -To use an [Azure Active Directory (AAD) token credential](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token), -provide an instance of the desired credential type obtained from the -[@azure/identity](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) library. - -To authenticate with AAD, you must first `npm` install [`@azure/identity`](https://www.npmjs.com/package/@azure/identity) - -After setup, you can choose which type of [credential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) from `@azure/identity` to use. -As an example, [DefaultAzureCredential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential) -can be used to authenticate the client. - -Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: -AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET - -```javascript -import AzureLoadTesting, { AzureLoadTestingClient } from "@azure-rest/load-testing"; -import { DefaultAzureCredential } from "@azure/identity"; - -const Client: AzureLoadTestingClient = AzureLoadTesting(Endpoint, new DefaultAzureCredential()); -``` - -## Key concepts - -The following components make up the Azure Load Testing Service. The Azure Load Test client library for JavaScript allows you to interact with each of these components through the use of a dedicated client object. - -#### Test - -A test specifies the test script, and configuration settings for running a load test. You can create one or more tests in an Azure Load Testing resource. - -#### App Component - -When you run a load test for an Azure-hosted application, you can monitor resource metrics for the different Azure application components (server-side metrics). While the load test runs, and after completion of the test, you can monitor and analyze the resource metrics in the Azure Load Testing dashboard. - -#### Metrics - -During a load test, Azure Load Testing collects metrics about the test execution. There are two types of metrics: - -1. Client-side metrics give you details reported by the test engine. These metrics include the number of virtual users, the request response time, the number of failed requests, or the number of requests per second. - -2. Server-side metrics are available for Azure-hosted applications and provide information about your Azure application components. Metrics can be for the number of database reads, the type of HTTP responses, or container resource consumption. - -### Test Engine - -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. - -### Test Run - -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. - -### Data-Plane Endpoint - -Data-plane of Azure Load Testing resources is addressable using the following URL format: - -`00000000-0000-0000-0000-000000000000.aaa.cnt-prod.loadtesting.azure.com` - -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. - -The data-plane endpoint is obtained from Control Plane APIs. - -**Example:** `1234abcd-12ab-12ab-12ab-123456abcdef.eus.cnt-prod.loadtesting.azure.com` - -In the above example, `eus` represents the Azure region `East US`. - -## Examples - -### Creating a load test - -```javascript -import { AzureLoadTestingClient } from "@azure-rest/load-testing"; -import AzureLoadTesting from "@azure-rest/load-testing"; -import { DefaultAzureCredential } from "@azure/identity"; - -var TEST_ID = "some-test-id"; -var DISPLAY_NAME = "my-load-test"; - -const client: AzureLoadTestingClient = AzureLoadTesting("", new DefaultAzureCredential()); - -await client.path("/tests/{testId}", TEST_ID).patch({ - contentType: "application/merge-patch+json", - body: { - displayName: DISPLAY_NAME, - description: "", - loadTestConfiguration: { - engineInstances: 1, - splitAllCSVs: false, - }, - secrets: {}, - environmentVariables: {}, - passFailCriteria: { passFailMetrics: {} }, - }, -}); -``` - -### Uploading .jmx file to a Test - -```javascript -import { AzureLoadTestingClient, getLongRunningPoller, isUnexpected } from "@azure-rest/load-testing"; -import AzureLoadTesting from "@azure-rest/load-testing"; -import { DefaultAzureCredential } from "@azure/identity"; -import { createReadStream } from "fs"; - -const client: AzureLoadTestingClient = AzureLoadTesting("", new DefaultAzureCredential()); - -var TEST_ID = "some-test-id"; -const readStream = createReadStream("./sample.jmx"); - -const fileUploadResult = await client - .path("/tests/{testId}/files/{fileName}", TEST_ID, "sample.jmx") - .put({ - contentType: "application/octet-stream", - body: readStream, - }); - -if (isUnexpected(fileUploadResult)) { - throw fileUploadResult.body.error; -} - -let fileValidateResult; -const fileValidatePoller = await getLongRunningPoller(client, fileUploadResult); -try{ -fileValidateResult = await fileValidatePoller.pollUntilDone({ - abortSignal: AbortSignal.timeout(120*1000), // timeout of 120 seconds -});} catch (ex: any) { -new Error("Error in polling file Validation" + ex.message); //polling timed out -} - -if (fileValidatePoller.getOperationState().status != "succeeded" && fileValidateResult) - throw new Error( - "There is some issue in validation, please make sure uploaded file is a valid JMX." + - fileValidateResult.body.validationFailureDetails - ); -``` - -### Running a Test and fetching Metrics - -```javascript -import { AzureLoadTestingClient, getLongRunningPoller, isUnexpected } from "@azure-rest/load-testing"; -import AzureLoadTesting from "@azure-rest/load-testing"; -import { DefaultAzureCredential } from "@azure/identity"; - -const client: AzureLoadTestingClient = AzureLoadTesting("", new DefaultAzureCredential()); - -var TEST_ID = "some-test-id"; -var DISPLAY_NAME = "my-load-test"; -var TEST_RUN_ID = "some-test-run-id"; - -// Creating/Updating the test run -const testRunCreationResult = await client.path("/test-runs/{testRunId}", TEST_RUN_ID).patch({ - contentType: "application/merge-patch+json", - body: { - testId: TEST_ID, - displayName: DISPLAY_NAME, - }, -}); - -if (isUnexpected(testRunCreationResult)) { - throw testRunCreationResult.body.error; -} - -if (testRunCreationResult.body.testRunId === undefined) - throw new Error("Test Run ID returned as undefined."); - -const testRunPoller = await getLongRunningPoller(client, testRunCreationResult); - let testRunResult; - - try { - testRunResult = await testRunPoller.pollUntilDone({ - abortSignal: AbortSignal.timeout(60000), // timeout of 60 seconds - }); - } catch (ex: any) { - new Error("Error in polling test run completion" + ex.message); //polling timed out - } - - if (testRunPoller.getOperationState().status != "succeeded") - throw new Error("There is some issue in running the test, Error Response : " + testRunResult); - - if (testRunResult) { - let testRunStarttime = testRunResult.body.startDateTime; - let testRunEndTime = testRunResult.body.endDateTime; - - // get list of all metric namespaces and pick the first one - const metricNamespaces = await client - .path("/test-runs/{testRunId}/metric-namespaces", TEST_RUN_ID) - .get(); - - if (isUnexpected(metricNamespaces)) { - throw metricNamespaces.body.error; - } - - const metricNamespace = metricNamespaces.body.value[0]; - - if (metricNamespace.name === undefined) { - throw "No Metric Namespace name is defined."; - } - - // get list of all metric definitions and pick the first one - const metricDefinitions = await client - .path("/test-runs/{testRunId}/metric-definitions", TEST_RUN_ID) - .get({ - queryParameters: { - metricNamespace: metricNamespace.name, - }, - }); - - if (isUnexpected(metricDefinitions)) { - throw metricDefinitions.body.error; - } - - const metricDefinition = metricDefinitions.body.value[0]; - - if (metricDefinition.name === undefined) { - throw "No Metric Namespace name is defined."; - } - - // fetch client metrics using metric namespace and metric name - const metricsResult = await client.path("/test-runs/{testRunId}/metrics", TEST_RUN_ID).post({ - queryParameters: { - metricname: metricDefinition.name, - metricNamespace: metricNamespace.name, - timespan: testRunStarttime + "/" + testRunEndTime, - }, - }); - - console.log(metricsResult); - console.log(testRunResult); -} -``` - -## Troubleshooting - -### Logging - -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`: - -```javascript -import { setLogLevel } from "@azure/logger"; - -setLogLevel("info"); -``` - -For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger). - -## Next steps - -Azure Loading Testing JavaScript SDK samples are available to you in the SDK's GitHub repository. These samples provide example code for additional scenarios commonly encountered. - -See [Azure Load Testing samples][sample_code]. - -## Contributing - -For details on contributing to this repository, see the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md). - -1. Fork it -2. Create your feature branch (`git checkout -b my-new-feature`) -3. Commit your changes (`git commit -am 'Add some feature'`) -4. Push to the branch (`git push origin my-new-feature`) -5. Create new Pull Request - - - -[source_code]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/loadtesting/load-testing-rest/src -[sample_code]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/loadtesting/load-testing-rest/samples/v1-beta -[api_reference_doc]: https://docs.microsoft.com/rest/api/loadtesting/ -[product_documentation]: https://azure.microsoft.com/services/load-testing/ -[azure_subscription]: https://azure.microsoft.com/free/ diff --git a/sdk/loadtesting/load-testing-rest/api-extractor.json b/sdk/loadtesting/load-testing-rest/api-extractor.json deleted file mode 100644 index 2f752668f341..000000000000 --- a/sdk/loadtesting/load-testing-rest/api-extractor.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", - "mainEntryPointFilePath": "./types/src/index.d.ts", - "docModel": { "enabled": true }, - "apiReport": { "enabled": true, "reportFolder": "./review" }, - "dtsRollup": { - "enabled": true, - "untrimmedFilePath": "", - "publicTrimmedFilePath": "./types/load-testing.d.ts" - }, - "messages": { - "tsdocMessageReporting": { "default": { "logLevel": "none" } }, - "extractorMessageReporting": { - "ae-missing-release-tag": { "logLevel": "none" }, - "ae-unresolved-link": { "logLevel": "none" } - } - } -} diff --git a/sdk/loadtesting/load-testing-rest/assets.json b/sdk/loadtesting/load-testing-rest/assets.json deleted file mode 100644 index a86676a4caf0..000000000000 --- a/sdk/loadtesting/load-testing-rest/assets.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "AssetsRepo": "Azure/azure-sdk-assets", - "AssetsRepoPrefixPath": "js", - "TagPrefix": "js/loadtesting/load-testing-rest", - "Tag": "js/loadtesting/load-testing-rest_06f27b7b92" -} diff --git a/sdk/loadtesting/load-testing-rest/eslint.config.mjs b/sdk/loadtesting/load-testing-rest/eslint.config.mjs deleted file mode 100644 index e559ed8cb5bd..000000000000 --- a/sdk/loadtesting/load-testing-rest/eslint.config.mjs +++ /dev/null @@ -1,14 +0,0 @@ -import azsdkEslint from "@azure/eslint-plugin-azure-sdk"; - -export default [ - ...azsdkEslint.configs.recommended, - { - rules: { - "@azure/azure-sdk/ts-modules-only-named": "warn", - "@azure/azure-sdk/ts-apiextractor-json-types": "warn", - "@azure/azure-sdk/ts-package-json-types": "warn", - "@azure/azure-sdk/ts-package-json-engine-is-present": "warn", - "tsdoc/syntax": "warn", - }, - }, -]; diff --git a/sdk/loadtesting/load-testing-rest/karma.conf.js b/sdk/loadtesting/load-testing-rest/karma.conf.js deleted file mode 100644 index 5f468354314d..000000000000 --- a/sdk/loadtesting/load-testing-rest/karma.conf.js +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -// https://github.com/karma-runner/karma-chrome-launcher -process.env.CHROME_BIN = require("puppeteer").executablePath(); -require("dotenv").config(); -const { relativeRecordingsPath } = require("@azure-tools/test-recorder"); -process.env.RECORDINGS_RELATIVE_PATH = relativeRecordingsPath(); - -module.exports = function (config) { - config.set({ - // base path that will be used to resolve all patterns (eg. files, exclude) - basePath: "./", - - // frameworks to use - // available frameworks: https://npmjs.org/browse/keyword/karma-adapter - frameworks: ["source-map-support", "mocha"], - - failOnEmptyTestSuite: false, - - plugins: [ - "karma-mocha", - "karma-mocha-reporter", - "karma-chrome-launcher", - "karma-firefox-launcher", - "karma-env-preprocessor", - "karma-coverage", - "karma-sourcemap-loader", - "karma-junit-reporter", - "karma-source-map-support", - ], - - // list of files / patterns to load in the browser - files: [ - "dist-test/index.browser.js", - { - pattern: "dist-test/index.browser.js.map", - type: "html", - included: false, - served: true, - }, - ], - - // list of files / patterns to exclude - exclude: [], - - // preprocess matching files before serving them to the browser - // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor - preprocessors: { - "**/*.js": ["sourcemap", "env"], - // IMPORTANT: COMMENT following line if you want to debug in your browsers!! - // Preprocess source file to calculate code coverage, however this will make source file unreadable - // "dist-test/index.js": ["coverage"] - }, - - envPreprocessor: [ - "TEST_MODE", - "LOADTESTSERVICE_ENDPOINT", - "AZURE_CLIENT_SECRET", - "AZURE_CLIENT_ID", - "AZURE_TENANT_ID", - "SUBSCRIPTION_ID", - "RECORDINGS_RELATIVE_PATH", - ], - - // test results reporter to use - // possible values: 'dots', 'progress' - // available reporters: https://npmjs.org/browse/keyword/karma-reporter - reporters: ["mocha", "coverage", "junit"], - - coverageReporter: { - // specify a common output directory - dir: "coverage-browser/", - reporters: [ - { type: "json", subdir: ".", file: "coverage.json" }, - { type: "lcovonly", subdir: ".", file: "lcov.info" }, - { type: "html", subdir: "html" }, - { type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" }, - ], - }, - - junitReporter: { - outputDir: "", // results will be saved as $outputDir/$browserName.xml - outputFile: "test-results.browser.xml", // if included, results will be saved as $outputDir/$browserName/$outputFile - suite: "", // suite will become the package name attribute in xml testsuite element - useBrowserName: false, // add browser name to report and classes names - nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element - classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element - properties: {}, // key value pair of properties to add to the section of the report - }, - - // web server port - port: 9876, - - // enable / disable colors in the output (reporters and logs) - colors: true, - - // level of logging - // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG - logLevel: config.LOG_INFO, - - // enable / disable watching file and executing tests whenever any file changes - autoWatch: false, - - // --no-sandbox allows our tests to run in Linux without having to change the system. - // --disable-web-security allows us to authenticate from the browser without having to write tests using interactive auth, which would be far more complex. - browsers: ["ChromeHeadlessNoSandbox"], - customLaunchers: { - ChromeHeadlessNoSandbox: { - base: "ChromeHeadless", - flags: ["--no-sandbox", "--disable-web-security", "--lang=en-US"], - }, - }, - - // Continuous Integration mode - // if true, Karma captures browsers, runs the tests and exits - singleRun: false, - - // Concurrency level - // how many browser should be started simultaneous - concurrency: 1, - - browserNoActivityTimeout: 60000000, - browserDisconnectTimeout: 10000, - browserDisconnectTolerance: 3, - - client: { - mocha: { - // change Karma's debug.html to the mocha web reporter - reporter: "html", - timeout: "600000", - }, - }, - }); -}; diff --git a/sdk/loadtesting/load-testing-rest/package.json b/sdk/loadtesting/load-testing-rest/package.json deleted file mode 100644 index 2753c51cb52c..000000000000 --- a/sdk/loadtesting/load-testing-rest/package.json +++ /dev/null @@ -1,134 +0,0 @@ -{ - "name": "@azure-rest/load-testing", - "sdk-type": "client", - "author": "Microsoft Corporation", - "version": "1.0.1", - "description": "This package contains Microsoft Azure LoadTestingClient client library.", - "keywords": [ - "node", - "azure", - "cloud", - "typescript", - "browser", - "isomorphic" - ], - "license": "MIT", - "main": "dist/index.js", - "module": "./dist-esm/src/index.js", - "types": "./types/load-testing.d.ts", - "repository": "github:Azure/azure-sdk-for-js", - "bugs": { - "url": "https://github.com/Azure/azure-sdk-for-js/issues" - }, - "files": [ - "dist/", - "dist-esm/src/", - "types/load-testing.d.ts", - "README.md", - "LICENSE", - "review/*" - ], - "//sampleConfiguration": { - "productName": "Azure Load Testing rest", - "productSlugs": [ - "azure" - ], - "requiredResources": { - "Azure LoadTesting Service instance": "https://learn.microsoft.com/azure/load-testing/" - } - }, - "engines": { - "node": ">=18.0.0" - }, - "scripts": { - "audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit", - "build:browser": "tsc -p . && dev-tool run bundle", - "build:node": "tsc -p . && dev-tool run bundle --browser-test false", - "build:samples": "echo skipped.", - "build:test": "tsc -p . && dev-tool run bundle", - "build:debug": "tsc -p . && dev-tool run bundle && dev-tool run extract-api", - "check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"", - "clean": "rimraf --glob dist dist-browser dist-esm test-dist temp types *.tgz *.log", - "execute:samples": "echo skipped", - "extract-api": "rimraf review && mkdirp ./review && dev-tool run extract-api", - "format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"", - "generate:client": "autorest --typescript swagger/README.md && npm run format", - "integration-test:browser": "dev-tool run test:browser", - "integration-test:node": "dev-tool run test:node-js-input -- --timeout 5000000 'dist-esm/test/**/*.spec.js'", - "integration-test": "npm run integration-test:node && npm run integration-test:browser", - "lint:fix": "eslint package.json api-extractor.json src test --fix --fix-type [problem,suggestion]", - "lint": "eslint package.json api-extractor.json src test", - "pack": "npm pack 2>&1", - "test:browser": "npm run clean && npm run build:test && npm run unit-test:browser", - "test:node": "npm run clean && npm run build:test && npm run unit-test:node", - "test": "npm run clean && npm run build:test && npm run unit-test", - "unit-test": "npm run unit-test:node && npm run unit-test:browser", - "unit-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 --exclude 'test/**/browser/*.spec.ts' 'test/**/*.spec.ts'", - "unit-test:browser": "dev-tool run test:browser", - "build": "npm run clean && tsc -p . && dev-tool run bundle && mkdirp ./review && dev-tool run extract-api" - }, - "sideEffects": false, - "autoPublish": false, - "dependencies": { - "@azure-rest/core-client": "^1.0.0", - "@azure/core-auth": "^1.3.0", - "@azure/core-paging": "^1.2.0", - "@azure/core-rest-pipeline": "^1.8.0", - "@azure/logger": "^1.0.0", - "tslib": "^2.2.0", - "@azure/core-lro": "^2.4.1", - "@azure/core-util": "^1.1.1", - "@azure/abort-controller": "^2.1.2" - }, - "devDependencies": { - "@azure-tools/test-credential": "^1.0.4", - "@azure-tools/test-recorder": "^3.0.0", - "@azure/identity": "^4.0.1", - "@microsoft/api-extractor": "^7.31.1", - "@azure/dev-tool": "^1.0.0", - "@azure/eslint-plugin-azure-sdk": "^3.0.0", - "@types/chai": "^4.2.8", - "@types/mocha": "^10.0.0", - "@types/node": "^18.0.0", - "@types/uuid": "^8.3.4", - "autorest": "latest", - "chai": "^4.2.0", - "cross-env": "^7.0.2", - "dotenv": "^16.0.0", - "eslint": "^9.9.0", - "karma": "^6.2.0", - "karma-chrome-launcher": "^3.0.0", - "karma-coverage": "^2.0.0", - "karma-env-preprocessor": "^0.1.1", - "karma-firefox-launcher": "^1.1.0", - "karma-junit-reporter": "^2.0.1", - "karma-mocha": "^2.0.1", - "karma-mocha-reporter": "^2.2.5", - "karma-source-map-support": "~1.4.0", - "karma-sourcemap-loader": "^0.3.8", - "mkdirp": "^3.0.1", - "mocha": "^10.0.0", - "nyc": "^17.0.0", - "rimraf": "^5.0.5", - "source-map-support": "^0.5.9", - "uuid": "^9.0.0", - "typescript": "~5.6.2", - "ts-node": "^10.0.0" - }, - "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/loadtesting/load-testing-rest/README.md", - "//metadata": { - "constantPaths": [ - { - "path": "swagger/README.md", - "prefix": "package-version" - }, - { - "path": "src/azureLoadTesting.ts", - "prefix": "userAgentInfo" - } - ] - }, - "browser": { - "./dist-esm/test/public/utils/env.js": "./dist-esm/test/public/utils/env.browser.js" - } -} diff --git a/sdk/loadtesting/load-testing-rest/review/load-testing.api.md b/sdk/loadtesting/load-testing-rest/review/load-testing.api.md deleted file mode 100644 index 00269c36727b..000000000000 --- a/sdk/loadtesting/load-testing-rest/review/load-testing.api.md +++ /dev/null @@ -1,1729 +0,0 @@ -## API Report File for "@azure-rest/load-testing" - -> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). - -```ts - -import { Client } from '@azure-rest/core-client'; -import { ClientOptions } from '@azure-rest/core-client'; -import { HttpResponse } from '@azure-rest/core-client'; -import { OperationState } from '@azure/core-lro'; -import { PagedAsyncIterableIterator } from '@azure/core-paging'; -import { PathUncheckedResponse } from '@azure-rest/core-client'; -import { RawHttpHeaders } from '@azure/core-rest-pipeline'; -import { RequestParameters } from '@azure-rest/core-client'; -import { SimplePollerLike } from '@azure/core-lro'; -import { StreamableMethod } from '@azure-rest/core-client'; -import { TokenCredential } from '@azure/core-auth'; - -// @public -export interface AppComponent { - displayName?: string; - kind?: string; - resourceGroup?: string; - resourceId?: string; - resourceName?: string; - resourceType?: string; - subscriptionId?: string; -} - -// @public -export interface AppComponentOutput { - displayName?: string; - kind?: string; - resourceGroup?: string; - resourceId?: string; - resourceName?: string; - resourceType?: string; - subscriptionId?: string; -} - -// @public (undocumented) -export type AzureLoadTestingClient = Client & { - path: Routes; -}; - -// @public -export interface CertificateMetadata { - name?: string; - type?: "AKV_CERT_URI"; - value?: string; -} - -// @public -export interface CertificateMetadataOutput { - name?: string; - type?: "AKV_CERT_URI"; - value?: string; -} - -// @public -function createClient(Endpoint: string, credentials: TokenCredential, options?: ClientOptions): AzureLoadTestingClient; -export default createClient; - -// @public -export interface DimensionFilter { - name?: string; - values?: Array; -} - -// @public -export interface DimensionValueListOutput { - nextLink?: string; - value?: Array; -} - -// @public -export interface DimensionValueOutput { - name?: string; - value?: string; -} - -// @public -export interface ErrorDetails { - message?: string; -} - -// @public -export interface ErrorDetailsOutput { - message?: string; -} - -// @public -export interface ErrorModelOutput { - code: string; - details?: Array; - message: string; - target?: string; -} - -// @public -export interface ErrorResponseBodyOutput { - error: ErrorModelOutput; -} - -// @public -export interface FileInfo { - expireDateTime?: Date | string; - fileName?: string; - fileType?: "JMX_FILE" | "USER_PROPERTIES" | "ADDITIONAL_ARTIFACTS"; - url?: string; - validationFailureDetails?: string; - validationStatus?: "NOT_VALIDATED" | "VALIDATION_SUCCESS" | "VALIDATION_FAILURE" | "VALIDATION_INITIATED" | "VALIDATION_NOT_REQUIRED"; -} - -// @public -export interface FileInfoListOutput { - nextLink?: string; - value: Array; -} - -// @public -export interface FileInfoOutput { - expireDateTime?: string; - fileName?: string; - fileType?: "JMX_FILE" | "USER_PROPERTIES" | "ADDITIONAL_ARTIFACTS"; - url?: string; - validationFailureDetails?: string; - validationStatus?: "NOT_VALIDATED" | "VALIDATION_SUCCESS" | "VALIDATION_FAILURE" | "VALIDATION_INITIATED" | "VALIDATION_NOT_REQUIRED"; -} - -// @public -export type FileUploadAndValidatePoller = SimplePollerLike, TestGetFile200Response>; - -// @public -export type GetArrayType = T extends Array ? TData : never; - -// @public (undocumented) -export function getLongRunningPoller(client: AzureLoadTestingClient, initialResponse: TestUploadFileSuccessResponse): Promise; - -// @public (undocumented) -export function getLongRunningPoller(client: AzureLoadTestingClient, initialResponse: TestRunCreateOrUpdateSuccessResponse): Promise; - -// @public -export type GetPage = (pageLink: string, maxPageSize?: number) => Promise<{ - page: TPage; - nextPageLink?: string; -}>; - -// @public (undocumented) -export function isUnexpected(response: TestCreateOrUpdate200Response | TestCreateOrUpdate201Response | TestCreateOrUpdateDefaultResponse): response is TestCreateOrUpdateDefaultResponse; - -// @public (undocumented) -export function isUnexpected(response: TestDelete204Response | TestDeleteDefaultResponse): response is TestDeleteDefaultResponse; - -// @public (undocumented) -export function isUnexpected(response: TestGet200Response | TestGetDefaultResponse): response is TestGetDefaultResponse; - -// @public (undocumented) -export function isUnexpected(response: TestList200Response | TestListDefaultResponse): response is TestListDefaultResponse; - -// @public (undocumented) -export function isUnexpected(response: TestUploadFile201Response | TestUploadFileDefaultResponse): response is TestUploadFileDefaultResponse; - -// @public (undocumented) -export function isUnexpected(response: TestGetFile200Response | TestGetFileDefaultResponse): response is TestGetFileDefaultResponse; - -// @public (undocumented) -export function isUnexpected(response: TestDeleteFile204Response | TestDeleteFileDefaultResponse): response is TestDeleteFileDefaultResponse; - -// @public (undocumented) -export function isUnexpected(response: TestListFiles200Response | TestListFilesDefaultResponse): response is TestListFilesDefaultResponse; - -// @public (undocumented) -export function isUnexpected(response: TestCreateOrUpdateAppComponents200Response | TestCreateOrUpdateAppComponents201Response | TestCreateOrUpdateAppComponentsDefaultResponse): response is TestCreateOrUpdateAppComponentsDefaultResponse; - -// @public (undocumented) -export function isUnexpected(response: TestListAppComponents200Response | TestListAppComponentsDefaultResponse): response is TestListAppComponentsDefaultResponse; - -// @public (undocumented) -export function isUnexpected(response: TestCreateOrUpdateServerMetricsConfig200Response | TestCreateOrUpdateServerMetricsConfig201Response | TestCreateOrUpdateServerMetricsConfigDefaultResponse): response is TestCreateOrUpdateServerMetricsConfigDefaultResponse; - -// @public (undocumented) -export function isUnexpected(response: TestListServerMetricsConfig200Response | TestListServerMetricsConfigDefaultResponse): response is TestListServerMetricsConfigDefaultResponse; - -// @public (undocumented) -export function isUnexpected(response: TestRunDelete204Response | TestRunDeleteDefaultResponse): response is TestRunDeleteDefaultResponse; - -// @public (undocumented) -export function isUnexpected(response: TestRunCreateOrUpdate200Response | TestRunCreateOrUpdate201Response | TestRunCreateOrUpdateDefaultResponse): response is TestRunCreateOrUpdateDefaultResponse; - -// @public (undocumented) -export function isUnexpected(response: TestRunGet200Response | TestRunGetDefaultResponse): response is TestRunGetDefaultResponse; - -// @public (undocumented) -export function isUnexpected(response: TestRunGetFile200Response | TestRunGetFileDefaultResponse): response is TestRunGetFileDefaultResponse; - -// @public (undocumented) -export function isUnexpected(response: TestRunList200Response | TestRunListDefaultResponse): response is TestRunListDefaultResponse; - -// @public (undocumented) -export function isUnexpected(response: TestRunStop200Response | TestRunStopDefaultResponse): response is TestRunStopDefaultResponse; - -// @public (undocumented) -export function isUnexpected(response: TestRunListMetricNamespaces200Response | TestRunListMetricNamespacesDefaultResponse): response is TestRunListMetricNamespacesDefaultResponse; - -// @public (undocumented) -export function isUnexpected(response: TestRunListMetricDefinitions200Response | TestRunListMetricDefinitionsDefaultResponse): response is TestRunListMetricDefinitionsDefaultResponse; - -// @public (undocumented) -export function isUnexpected(response: TestRunListMetrics200Response | TestRunListMetricsDefaultResponse): response is TestRunListMetricsDefaultResponse; - -// @public (undocumented) -export function isUnexpected(response: TestRunListMetricDimensionValues200Response | TestRunListMetricDimensionValuesDefaultResponse): response is TestRunListMetricDimensionValuesDefaultResponse; - -// @public (undocumented) -export function isUnexpected(response: TestRunCreateOrUpdateAppComponents200Response | TestRunCreateOrUpdateAppComponents201Response | TestRunCreateOrUpdateAppComponentsDefaultResponse): response is TestRunCreateOrUpdateAppComponentsDefaultResponse; - -// @public (undocumented) -export function isUnexpected(response: TestRunListAppComponents200Response | TestRunListAppComponentsDefaultResponse): response is TestRunListAppComponentsDefaultResponse; - -// @public (undocumented) -export function isUnexpected(response: TestRunCreateOrUpdateServerMetricsConfig200Response | TestRunCreateOrUpdateServerMetricsConfig201Response | TestRunCreateOrUpdateServerMetricsConfigDefaultResponse): response is TestRunCreateOrUpdateServerMetricsConfigDefaultResponse; - -// @public (undocumented) -export function isUnexpected(response: TestRunListServerMetricsConfig200Response | TestRunListServerMetricsConfigDefaultResponse): response is TestRunListServerMetricsConfigDefaultResponse; - -// @public -export interface LoadTestConfiguration { - engineInstances?: number; - optionalLoadTestConfig?: OptionalLoadTestConfig; - quickStartTest?: boolean; - splitAllCSVs?: boolean; -} - -// @public -export interface LoadTestConfigurationOutput { - engineInstances?: number; - optionalLoadTestConfig?: OptionalLoadTestConfigOutput; - quickStartTest?: boolean; - splitAllCSVs?: boolean; -} - -// @public -export interface MetricAvailabilityOutput { - timeGrain?: "PT5S" | "PT10S" | "PT1M" | "PT5M" | "PT1H"; -} - -// @public -export interface MetricDefinitionCollectionOutput { - value: Array; -} - -// @public -export interface MetricDefinitionOutput { - description?: string; - dimensions?: Array; - metricAvailabilities?: Array; - name?: string; - namespace?: string; - primaryAggregationType?: "Average" | "Count" | "None" | "Total" | "Percentile90" | "Percentile95" | "Percentile99"; - supportedAggregationTypes?: Array; - unit?: "NotSpecified" | "Percent" | "Count" | "Seconds" | "Milliseconds" | "Bytes" | "BytesPerSecond" | "CountPerSecond"; -} - -// @public -export interface MetricNamespaceCollectionOutput { - value: Array; -} - -// @public -export interface MetricNamespaceOutput { - description?: string; - name?: string; -} - -// @public -export interface MetricRequestPayload { - filters?: Array; -} - -// @public -export interface MetricsOutput { - nextLink?: string; - timeseries?: Array; -} - -// @public -export interface MetricValueOutput { - timestamp?: string; - value?: number; -} - -// @public -export interface NameAndDescOutput { - description?: string; - name?: string; -} - -// @public -export interface OptionalLoadTestConfig { - duration?: number; - endpointUrl?: string; - rampUpTime?: number; - virtualUsers?: number; -} - -// @public -export interface OptionalLoadTestConfigOutput { - duration?: number; - endpointUrl?: string; - rampUpTime?: number; - virtualUsers?: number; -} - -// @public -export function paginate(client: Client, initialResponse: TResponse, options?: PagingOptions): PagedAsyncIterableIterator>; - -// @public -export type PaginateReturn = TResult extends { - body: { - value?: infer TPage; - }; -} ? GetArrayType : Array; - -// @public -export interface PagingOptions { - customGetPage?: GetPage[]>; -} - -// @public -export interface PassFailCriteria { - passFailMetrics?: Record; -} - -// @public -export interface PassFailCriteriaOutput { - passFailMetrics?: Record; -} - -// @public -export interface PassFailMetric { - action?: "stop" | "continue"; - actualValue?: number; - aggregate?: "count" | "percentage" | "avg" | "p50" | "p90" | "p95" | "p99" | "min" | "max"; - clientMetric?: "response_time_ms" | "latency" | "error" | "requests" | "requests_per_sec"; - condition?: string; - requestName?: string; - result?: "passed" | "undetermined" | "failed"; - value?: number; -} - -// @public -export interface PassFailMetricOutput { - action?: "stop" | "continue"; - actualValue?: number; - aggregate?: "count" | "percentage" | "avg" | "p50" | "p90" | "p95" | "p99" | "min" | "max"; - clientMetric?: "response_time_ms" | "latency" | "error" | "requests" | "requests_per_sec"; - condition?: string; - requestName?: string; - result?: "passed" | "undetermined" | "failed"; - value?: number; -} - -// @public (undocumented) -export interface PolledOperationOptions { - updateIntervalInMs?: number; -} - -// @public -export interface ResourceMetric { - aggregation: string; - displayDescription?: string; - id?: string; - metricNamespace: string; - name: string; - resourceId: string; - resourceType: string; - unit?: string; -} - -// @public -export interface ResourceMetricOutput { - aggregation: string; - displayDescription?: string; - id?: string; - metricNamespace: string; - name: string; - resourceId: string; - resourceType: string; - unit?: string; -} - -// @public (undocumented) -export interface Routes { - (path: "/tests/{testId}", testId: string): TestCreateOrUpdate; - (path: "/tests"): TestList; - (path: "/tests/{testId}/files/{fileName}", testId: string, fileName: string): TestUploadFile; - (path: "/tests/{testId}/files", testId: string): TestListFiles; - (path: "/tests/{testId}/app-components", testId: string): TestCreateOrUpdateAppComponents; - (path: "/tests/{testId}/server-metrics-config", testId: string): TestCreateOrUpdateServerMetricsConfig; - (path: "/test-runs/{testRunId}", testRunId: string): TestRunDelete; - (path: "/test-runs/{testRunId}/files/{fileName}", testRunId: string, fileName: string): TestRunGetFile; - (path: "/test-runs"): TestRunList; - (path: "/test-runs/{testRunId}:stop", testRunId: string): TestRunStop; - (path: "/test-runs/{testRunId}/metric-namespaces", testRunId: string): TestRunListMetricNamespaces; - (path: "/test-runs/{testRunId}/metric-definitions", testRunId: string): TestRunListMetricDefinitions; - (path: "/test-runs/{testRunId}/metrics", testRunId: string): TestRunListMetrics; - (path: "/test-runs/{testRunId}/metric-dimensions/{name}/values", testRunId: string, name: string): TestRunListMetricDimensionValues; - (path: "/test-runs/{testRunId}/app-components", testRunId: string): TestRunCreateOrUpdateAppComponents; - (path: "/test-runs/{testRunId}/server-metrics-config", testRunId: string): TestRunCreateOrUpdateServerMetricsConfig; -} - -// @public -export interface Secret { - type?: "AKV_SECRET_URI" | "SECRET_VALUE"; - value?: string; -} - -// @public -export interface SecretOutput { - type?: "AKV_SECRET_URI" | "SECRET_VALUE"; - value?: string; -} - -// @public -export interface Test { - certificate?: CertificateMetadata; - createdBy?: string; - createdDateTime?: Date | string; - description?: string; - displayName?: string; - environmentVariables?: Record; - inputArtifacts?: TestInputArtifacts; - keyvaultReferenceIdentityId?: string; - keyvaultReferenceIdentityType?: string; - lastModifiedBy?: string; - lastModifiedDateTime?: Date | string; - loadTestConfiguration?: LoadTestConfiguration; - passFailCriteria?: PassFailCriteria; - secrets?: Record; - subnetId?: string; - testId?: string; -} - -// @public -export interface TestAppComponents { - components: Record; - createdBy?: string; - createdDateTime?: Date | string; - lastModifiedBy?: string; - lastModifiedDateTime?: Date | string; - testId?: string; -} - -// @public -export interface TestAppComponentsOutput { - components: Record; - createdBy?: string; - createdDateTime?: string; - lastModifiedBy?: string; - lastModifiedDateTime?: string; - testId?: string; -} - -// @public (undocumented) -export interface TestCreateOrUpdate { - delete(options?: TestDeleteParameters): StreamableMethod; - get(options?: TestGetParameters): StreamableMethod; - patch(options: TestCreateOrUpdateParameters): StreamableMethod; -} - -// @public -export interface TestCreateOrUpdate200Response extends HttpResponse { - // (undocumented) - body: TestOutput; - // (undocumented) - status: "200"; -} - -// @public -export interface TestCreateOrUpdate201Response extends HttpResponse { - // (undocumented) - body: TestOutput; - // (undocumented) - status: "201"; -} - -// @public (undocumented) -export interface TestCreateOrUpdateAppComponents { - get(options?: TestListAppComponentsParameters): StreamableMethod; - patch(options: TestCreateOrUpdateAppComponentsParameters): StreamableMethod; -} - -// @public -export interface TestCreateOrUpdateAppComponents200Response extends HttpResponse { - // (undocumented) - body: TestAppComponentsOutput; - // (undocumented) - status: "200"; -} - -// @public -export interface TestCreateOrUpdateAppComponents201Response extends HttpResponse { - // (undocumented) - body: TestAppComponentsOutput; - // (undocumented) - status: "201"; -} - -// @public (undocumented) -export interface TestCreateOrUpdateAppComponentsBodyParam { - body: TestAppComponents; -} - -// @public (undocumented) -export interface TestCreateOrUpdateAppComponentsDefaultHeaders { - "x-ms-error-code"?: string; -} - -// @public -export interface TestCreateOrUpdateAppComponentsDefaultResponse extends HttpResponse { - // (undocumented) - body: ErrorResponseBodyOutput; - // (undocumented) - headers: RawHttpHeaders & TestCreateOrUpdateAppComponentsDefaultHeaders; - // (undocumented) - status: string; -} - -// @public (undocumented) -export interface TestCreateOrUpdateAppComponentsMediaTypesParam { - contentType?: "application/merge-patch+json"; -} - -// @public (undocumented) -export type TestCreateOrUpdateAppComponentsParameters = TestCreateOrUpdateAppComponentsMediaTypesParam & TestCreateOrUpdateAppComponentsBodyParam & RequestParameters; - -// @public (undocumented) -export interface TestCreateOrUpdateBodyParam { - body: Test; -} - -// @public (undocumented) -export interface TestCreateOrUpdateDefaultHeaders { - "x-ms-error-code"?: string; -} - -// @public -export interface TestCreateOrUpdateDefaultResponse extends HttpResponse { - // (undocumented) - body: ErrorResponseBodyOutput; - // (undocumented) - headers: RawHttpHeaders & TestCreateOrUpdateDefaultHeaders; - // (undocumented) - status: string; -} - -// @public (undocumented) -export interface TestCreateOrUpdateMediaTypesParam { - contentType?: "application/merge-patch+json"; -} - -// @public (undocumented) -export type TestCreateOrUpdateParameters = TestCreateOrUpdateMediaTypesParam & TestCreateOrUpdateBodyParam & RequestParameters; - -// @public (undocumented) -export interface TestCreateOrUpdateServerMetricsConfig { - get(options?: TestListServerMetricsConfigParameters): StreamableMethod; - patch(options: TestCreateOrUpdateServerMetricsConfigParameters): StreamableMethod; -} - -// @public -export interface TestCreateOrUpdateServerMetricsConfig200Response extends HttpResponse { - // (undocumented) - body: TestServerMetricConfigOutput; - // (undocumented) - status: "200"; -} - -// @public -export interface TestCreateOrUpdateServerMetricsConfig201Response extends HttpResponse { - // (undocumented) - body: TestServerMetricConfigOutput; - // (undocumented) - status: "201"; -} - -// @public (undocumented) -export interface TestCreateOrUpdateServerMetricsConfigBodyParam { - body: TestServerMetricConfig; -} - -// @public (undocumented) -export interface TestCreateOrUpdateServerMetricsConfigDefaultHeaders { - "x-ms-error-code"?: string; -} - -// @public -export interface TestCreateOrUpdateServerMetricsConfigDefaultResponse extends HttpResponse { - // (undocumented) - body: ErrorResponseBodyOutput; - // (undocumented) - headers: RawHttpHeaders & TestCreateOrUpdateServerMetricsConfigDefaultHeaders; - // (undocumented) - status: string; -} - -// @public (undocumented) -export interface TestCreateOrUpdateServerMetricsConfigMediaTypesParam { - contentType?: "application/merge-patch+json"; -} - -// @public (undocumented) -export type TestCreateOrUpdateServerMetricsConfigParameters = TestCreateOrUpdateServerMetricsConfigMediaTypesParam & TestCreateOrUpdateServerMetricsConfigBodyParam & RequestParameters; - -// @public -export interface TestDelete204Response extends HttpResponse { - // (undocumented) - body: Record; - // (undocumented) - status: "204"; -} - -// @public (undocumented) -export interface TestDeleteDefaultHeaders { - "x-ms-error-code"?: string; -} - -// @public -export interface TestDeleteDefaultResponse extends HttpResponse { - // (undocumented) - body: ErrorResponseBodyOutput; - // (undocumented) - headers: RawHttpHeaders & TestDeleteDefaultHeaders; - // (undocumented) - status: string; -} - -// @public -export interface TestDeleteFile204Response extends HttpResponse { - // (undocumented) - body: Record; - // (undocumented) - status: "204"; -} - -// @public (undocumented) -export interface TestDeleteFileDefaultHeaders { - "x-ms-error-code"?: string; -} - -// @public -export interface TestDeleteFileDefaultResponse extends HttpResponse { - // (undocumented) - body: ErrorResponseBodyOutput; - // (undocumented) - headers: RawHttpHeaders & TestDeleteFileDefaultHeaders; - // (undocumented) - status: string; -} - -// @public (undocumented) -export type TestDeleteFileParameters = RequestParameters; - -// @public (undocumented) -export type TestDeleteParameters = RequestParameters; - -// @public -export interface TestGet200Response extends HttpResponse { - // (undocumented) - body: TestOutput; - // (undocumented) - status: "200"; -} - -// @public (undocumented) -export interface TestGetDefaultHeaders { - "x-ms-error-code"?: string; -} - -// @public -export interface TestGetDefaultResponse extends HttpResponse { - // (undocumented) - body: ErrorResponseBodyOutput; - // (undocumented) - headers: RawHttpHeaders & TestGetDefaultHeaders; - // (undocumented) - status: string; -} - -// @public -export interface TestGetFile200Response extends HttpResponse { - // (undocumented) - body: FileInfoOutput; - // (undocumented) - status: "200"; -} - -// @public (undocumented) -export interface TestGetFileDefaultHeaders { - "x-ms-error-code"?: string; -} - -// @public -export interface TestGetFileDefaultResponse extends HttpResponse { - // (undocumented) - body: ErrorResponseBodyOutput; - // (undocumented) - headers: RawHttpHeaders & TestGetFileDefaultHeaders; - // (undocumented) - status: string; -} - -// @public (undocumented) -export type TestGetFileParameters = RequestParameters; - -// @public (undocumented) -export type TestGetParameters = RequestParameters; - -// @public -export interface TestInputArtifacts { - additionalFileInfo?: Array; - configFileInfo?: FileInfo; - inputArtifactsZipFileInfo?: FileInfo; - testScriptFileInfo?: FileInfo; - userPropFileInfo?: FileInfo; -} - -// @public -export interface TestInputArtifactsOutput { - additionalFileInfo?: Array; - configFileInfo?: FileInfoOutput; - inputArtifactsZipFileInfo?: FileInfoOutput; - testScriptFileInfo?: FileInfoOutput; - userPropFileInfo?: FileInfoOutput; -} - -// @public (undocumented) -export interface TestList { - get(options?: TestListParameters): StreamableMethod; -} - -// @public -export interface TestList200Response extends HttpResponse { - // (undocumented) - body: TestsListOutput; - // (undocumented) - status: "200"; -} - -// @public -export interface TestListAppComponents200Response extends HttpResponse { - // (undocumented) - body: TestAppComponentsOutput; - // (undocumented) - status: "200"; -} - -// @public (undocumented) -export interface TestListAppComponentsDefaultHeaders { - "x-ms-error-code"?: string; -} - -// @public -export interface TestListAppComponentsDefaultResponse extends HttpResponse { - // (undocumented) - body: ErrorResponseBodyOutput; - // (undocumented) - headers: RawHttpHeaders & TestListAppComponentsDefaultHeaders; - // (undocumented) - status: string; -} - -// @public (undocumented) -export type TestListAppComponentsParameters = RequestParameters; - -// @public (undocumented) -export interface TestListDefaultHeaders { - "x-ms-error-code"?: string; -} - -// @public -export interface TestListDefaultResponse extends HttpResponse { - // (undocumented) - body: ErrorResponseBodyOutput; - // (undocumented) - headers: RawHttpHeaders & TestListDefaultHeaders; - // (undocumented) - status: string; -} - -// @public (undocumented) -export interface TestListFiles { - get(options?: TestListFilesParameters): StreamableMethod; -} - -// @public -export interface TestListFiles200Response extends HttpResponse { - // (undocumented) - body: FileInfoListOutput; - // (undocumented) - status: "200"; -} - -// @public (undocumented) -export interface TestListFilesDefaultHeaders { - "x-ms-error-code"?: string; -} - -// @public -export interface TestListFilesDefaultResponse extends HttpResponse { - // (undocumented) - body: ErrorResponseBodyOutput; - // (undocumented) - headers: RawHttpHeaders & TestListFilesDefaultHeaders; - // (undocumented) - status: string; -} - -// @public (undocumented) -export type TestListFilesParameters = TestListFilesQueryParam & RequestParameters; - -// @public (undocumented) -export interface TestListFilesQueryParam { - // (undocumented) - queryParameters?: TestListFilesQueryParamProperties; -} - -// @public (undocumented) -export interface TestListFilesQueryParamProperties { - continuationToken?: string; -} - -// @public (undocumented) -export type TestListParameters = TestListQueryParam & RequestParameters; - -// @public (undocumented) -export interface TestListQueryParam { - // (undocumented) - queryParameters?: TestListQueryParamProperties; -} - -// @public (undocumented) -export interface TestListQueryParamProperties { - continuationToken?: string; - lastModifiedEndTime?: Date | string; - lastModifiedStartTime?: Date | string; - maxpagesize?: number; - orderby?: string; - search?: string; -} - -// @public -export interface TestListServerMetricsConfig200Response extends HttpResponse { - // (undocumented) - body: TestServerMetricConfigOutput; - // (undocumented) - status: "200"; -} - -// @public (undocumented) -export interface TestListServerMetricsConfigDefaultHeaders { - "x-ms-error-code"?: string; -} - -// @public -export interface TestListServerMetricsConfigDefaultResponse extends HttpResponse { - // (undocumented) - body: ErrorResponseBodyOutput; - // (undocumented) - headers: RawHttpHeaders & TestListServerMetricsConfigDefaultHeaders; - // (undocumented) - status: string; -} - -// @public (undocumented) -export type TestListServerMetricsConfigParameters = RequestParameters; - -// @public -export interface TestOutput { - certificate?: CertificateMetadataOutput; - createdBy?: string; - createdDateTime?: string; - description?: string; - displayName?: string; - environmentVariables?: Record; - inputArtifacts?: TestInputArtifactsOutput; - keyvaultReferenceIdentityId?: string; - keyvaultReferenceIdentityType?: string; - lastModifiedBy?: string; - lastModifiedDateTime?: string; - loadTestConfiguration?: LoadTestConfigurationOutput; - passFailCriteria?: PassFailCriteriaOutput; - secrets?: Record; - subnetId?: string; - testId?: string; -} - -// @public -export interface TestRun { - certificate?: CertificateMetadata; - createdBy?: string; - createdDateTime?: Date | string; - description?: string; - displayName?: string; - duration?: number; - endDateTime?: Date | string; - environmentVariables?: Record; - errorDetails?: Array; - executedDateTime?: Date | string; - lastModifiedBy?: string; - lastModifiedDateTime?: Date | string; - loadTestConfiguration?: LoadTestConfiguration; - passFailCriteria?: PassFailCriteria; - portalUrl?: string; - secrets?: Record; - startDateTime?: Date | string; - status?: "ACCEPTED" | "NOTSTARTED" | "PROVISIONING" | "PROVISIONED" | "CONFIGURING" | "CONFIGURED" | "EXECUTING" | "EXECUTED" | "DEPROVISIONING" | "DEPROVISIONED" | "DONE" | "CANCELLING" | "CANCELLED" | "FAILED" | "VALIDATION_SUCCESS" | "VALIDATION_FAILURE"; - subnetId?: string; - testArtifacts?: TestRunArtifacts; - testId?: string; - testResult?: "PASSED" | "NOT_APPLICABLE" | "FAILED"; - testRunId?: string; - testRunStatistics?: Record; - virtualUsers?: number; -} - -// @public -export interface TestRunAppComponents { - components: Record; - createdBy?: string; - createdDateTime?: Date | string; - lastModifiedBy?: string; - lastModifiedDateTime?: Date | string; - testRunId?: string; -} - -// @public -export interface TestRunAppComponentsOutput { - components: Record; - createdBy?: string; - createdDateTime?: string; - lastModifiedBy?: string; - lastModifiedDateTime?: string; - testRunId?: string; -} - -// @public -export interface TestRunArtifacts { - inputArtifacts?: TestRunInputArtifacts; - outputArtifacts?: TestRunOutputArtifacts; -} - -// @public -export interface TestRunArtifactsOutput { - inputArtifacts?: TestRunInputArtifactsOutput; - outputArtifacts?: TestRunOutputArtifactsOutput; -} - -// @public (undocumented) -export type TestRunCompletionPoller = SimplePollerLike, TestRunGet200Response>; - -// @public -export interface TestRunCreateOrUpdate200Response extends HttpResponse { - // (undocumented) - body: TestRunOutput; - // (undocumented) - status: "200"; -} - -// @public -export interface TestRunCreateOrUpdate201Response extends HttpResponse { - // (undocumented) - body: TestRunOutput; - // (undocumented) - status: "201"; -} - -// @public (undocumented) -export interface TestRunCreateOrUpdateAppComponents { - get(options?: TestRunListAppComponentsParameters): StreamableMethod; - patch(options: TestRunCreateOrUpdateAppComponentsParameters): StreamableMethod; -} - -// @public -export interface TestRunCreateOrUpdateAppComponents200Response extends HttpResponse { - // (undocumented) - body: TestRunAppComponentsOutput; - // (undocumented) - status: "200"; -} - -// @public -export interface TestRunCreateOrUpdateAppComponents201Response extends HttpResponse { - // (undocumented) - body: TestRunAppComponentsOutput; - // (undocumented) - status: "201"; -} - -// @public (undocumented) -export interface TestRunCreateOrUpdateAppComponentsBodyParam { - body: TestRunAppComponents; -} - -// @public (undocumented) -export interface TestRunCreateOrUpdateAppComponentsDefaultHeaders { - "x-ms-error-code"?: string; -} - -// @public -export interface TestRunCreateOrUpdateAppComponentsDefaultResponse extends HttpResponse { - // (undocumented) - body: ErrorResponseBodyOutput; - // (undocumented) - headers: RawHttpHeaders & TestRunCreateOrUpdateAppComponentsDefaultHeaders; - // (undocumented) - status: string; -} - -// @public (undocumented) -export interface TestRunCreateOrUpdateAppComponentsMediaTypesParam { - contentType?: "application/merge-patch+json"; -} - -// @public (undocumented) -export type TestRunCreateOrUpdateAppComponentsParameters = TestRunCreateOrUpdateAppComponentsMediaTypesParam & TestRunCreateOrUpdateAppComponentsBodyParam & RequestParameters; - -// @public (undocumented) -export interface TestRunCreateOrUpdateBodyParam { - body: TestRun; -} - -// @public (undocumented) -export interface TestRunCreateOrUpdateDefaultHeaders { - "x-ms-error-code"?: string; -} - -// @public -export interface TestRunCreateOrUpdateDefaultResponse extends HttpResponse { - // (undocumented) - body: ErrorResponseBodyOutput; - // (undocumented) - headers: RawHttpHeaders & TestRunCreateOrUpdateDefaultHeaders; - // (undocumented) - status: string; -} - -// @public (undocumented) -export interface TestRunCreateOrUpdateMediaTypesParam { - contentType?: "application/merge-patch+json"; -} - -// @public (undocumented) -export type TestRunCreateOrUpdateParameters = TestRunCreateOrUpdateQueryParam & TestRunCreateOrUpdateMediaTypesParam & TestRunCreateOrUpdateBodyParam & RequestParameters; - -// @public (undocumented) -export interface TestRunCreateOrUpdateQueryParam { - // (undocumented) - queryParameters?: TestRunCreateOrUpdateQueryParamProperties; -} - -// @public (undocumented) -export interface TestRunCreateOrUpdateQueryParamProperties { - oldTestRunId?: string; -} - -// @public (undocumented) -export interface TestRunCreateOrUpdateServerMetricsConfig { - get(options?: TestRunListServerMetricsConfigParameters): StreamableMethod; - patch(options: TestRunCreateOrUpdateServerMetricsConfigParameters): StreamableMethod; -} - -// @public -export interface TestRunCreateOrUpdateServerMetricsConfig200Response extends HttpResponse { - // (undocumented) - body: TestRunServerMetricConfigOutput; - // (undocumented) - status: "200"; -} - -// @public -export interface TestRunCreateOrUpdateServerMetricsConfig201Response extends HttpResponse { - // (undocumented) - body: TestRunServerMetricConfigOutput; - // (undocumented) - status: "201"; -} - -// @public (undocumented) -export interface TestRunCreateOrUpdateServerMetricsConfigBodyParam { - body: TestRunServerMetricConfig; -} - -// @public (undocumented) -export interface TestRunCreateOrUpdateServerMetricsConfigDefaultHeaders { - "x-ms-error-code"?: string; -} - -// @public -export interface TestRunCreateOrUpdateServerMetricsConfigDefaultResponse extends HttpResponse { - // (undocumented) - body: ErrorResponseBodyOutput; - // (undocumented) - headers: RawHttpHeaders & TestRunCreateOrUpdateServerMetricsConfigDefaultHeaders; - // (undocumented) - status: string; -} - -// @public (undocumented) -export interface TestRunCreateOrUpdateServerMetricsConfigMediaTypesParam { - contentType?: "application/merge-patch+json"; -} - -// @public (undocumented) -export type TestRunCreateOrUpdateServerMetricsConfigParameters = TestRunCreateOrUpdateServerMetricsConfigMediaTypesParam & TestRunCreateOrUpdateServerMetricsConfigBodyParam & RequestParameters; - -// @public (undocumented) -export type TestRunCreateOrUpdateSuccessResponse = TestRunCreateOrUpdate200Response | TestRunCreateOrUpdate201Response; - -// @public (undocumented) -export interface TestRunDelete { - delete(options?: TestRunDeleteParameters): StreamableMethod; - get(options?: TestRunGetParameters): StreamableMethod; - patch(options: TestRunCreateOrUpdateParameters): StreamableMethod; -} - -// @public -export interface TestRunDelete204Response extends HttpResponse { - // (undocumented) - body: Record; - // (undocumented) - status: "204"; -} - -// @public (undocumented) -export interface TestRunDeleteDefaultHeaders { - "x-ms-error-code"?: string; -} - -// @public -export interface TestRunDeleteDefaultResponse extends HttpResponse { - // (undocumented) - body: ErrorResponseBodyOutput; - // (undocumented) - headers: RawHttpHeaders & TestRunDeleteDefaultHeaders; - // (undocumented) - status: string; -} - -// @public (undocumented) -export type TestRunDeleteParameters = RequestParameters; - -// @public -export interface TestRunGet200Response extends HttpResponse { - // (undocumented) - body: TestRunOutput; - // (undocumented) - status: "200"; -} - -// @public (undocumented) -export interface TestRunGetDefaultHeaders { - "x-ms-error-code"?: string; -} - -// @public -export interface TestRunGetDefaultResponse extends HttpResponse { - // (undocumented) - body: ErrorResponseBodyOutput; - // (undocumented) - headers: RawHttpHeaders & TestRunGetDefaultHeaders; - // (undocumented) - status: string; -} - -// @public (undocumented) -export interface TestRunGetFile { - get(options?: TestRunGetFileParameters): StreamableMethod; -} - -// @public -export interface TestRunGetFile200Response extends HttpResponse { - // (undocumented) - body: FileInfoOutput; - // (undocumented) - status: "200"; -} - -// @public (undocumented) -export interface TestRunGetFileDefaultHeaders { - "x-ms-error-code"?: string; -} - -// @public -export interface TestRunGetFileDefaultResponse extends HttpResponse { - // (undocumented) - body: ErrorResponseBodyOutput; - // (undocumented) - headers: RawHttpHeaders & TestRunGetFileDefaultHeaders; - // (undocumented) - status: string; -} - -// @public (undocumented) -export type TestRunGetFileParameters = RequestParameters; - -// @public (undocumented) -export type TestRunGetParameters = RequestParameters; - -// @public -export interface TestRunInputArtifacts { - additionalFileInfo?: Array; - configFileInfo?: FileInfo; - inputArtifactsZipFileInfo?: FileInfo; - testScriptFileInfo?: FileInfo; - userPropFileInfo?: FileInfo; -} - -// @public -export interface TestRunInputArtifactsOutput { - additionalFileInfo?: Array; - configFileInfo?: FileInfoOutput; - inputArtifactsZipFileInfo?: FileInfoOutput; - testScriptFileInfo?: FileInfoOutput; - userPropFileInfo?: FileInfoOutput; -} - -// @public (undocumented) -export interface TestRunList { - get(options?: TestRunListParameters): StreamableMethod; -} - -// @public -export interface TestRunList200Response extends HttpResponse { - // (undocumented) - body: TestRunsListOutput; - // (undocumented) - status: "200"; -} - -// @public -export interface TestRunListAppComponents200Response extends HttpResponse { - // (undocumented) - body: TestRunAppComponentsOutput; - // (undocumented) - status: "200"; -} - -// @public (undocumented) -export interface TestRunListAppComponentsDefaultHeaders { - "x-ms-error-code"?: string; -} - -// @public -export interface TestRunListAppComponentsDefaultResponse extends HttpResponse { - // (undocumented) - body: ErrorResponseBodyOutput; - // (undocumented) - headers: RawHttpHeaders & TestRunListAppComponentsDefaultHeaders; - // (undocumented) - status: string; -} - -// @public (undocumented) -export type TestRunListAppComponentsParameters = RequestParameters; - -// @public (undocumented) -export interface TestRunListDefaultHeaders { - "x-ms-error-code"?: string; -} - -// @public -export interface TestRunListDefaultResponse extends HttpResponse { - // (undocumented) - body: ErrorResponseBodyOutput; - // (undocumented) - headers: RawHttpHeaders & TestRunListDefaultHeaders; - // (undocumented) - status: string; -} - -// @public (undocumented) -export interface TestRunListMetricDefinitions { - get(options: TestRunListMetricDefinitionsParameters): StreamableMethod; -} - -// @public -export interface TestRunListMetricDefinitions200Response extends HttpResponse { - // (undocumented) - body: MetricDefinitionCollectionOutput; - // (undocumented) - status: "200"; -} - -// @public (undocumented) -export interface TestRunListMetricDefinitionsDefaultHeaders { - "x-ms-error-code"?: string; -} - -// @public -export interface TestRunListMetricDefinitionsDefaultResponse extends HttpResponse { - // (undocumented) - body: ErrorResponseBodyOutput; - // (undocumented) - headers: RawHttpHeaders & TestRunListMetricDefinitionsDefaultHeaders; - // (undocumented) - status: string; -} - -// @public (undocumented) -export type TestRunListMetricDefinitionsParameters = TestRunListMetricDefinitionsQueryParam & RequestParameters; - -// @public (undocumented) -export interface TestRunListMetricDefinitionsQueryParam { - // (undocumented) - queryParameters: TestRunListMetricDefinitionsQueryParamProperties; -} - -// @public (undocumented) -export interface TestRunListMetricDefinitionsQueryParamProperties { - metricNamespace: string; -} - -// @public (undocumented) -export interface TestRunListMetricDimensionValues { - get(options: TestRunListMetricDimensionValuesParameters): StreamableMethod; -} - -// @public -export interface TestRunListMetricDimensionValues200Response extends HttpResponse { - // (undocumented) - body: DimensionValueListOutput; - // (undocumented) - status: "200"; -} - -// @public (undocumented) -export interface TestRunListMetricDimensionValuesDefaultHeaders { - "x-ms-error-code"?: string; -} - -// @public -export interface TestRunListMetricDimensionValuesDefaultResponse extends HttpResponse { - // (undocumented) - body: ErrorResponseBodyOutput; - // (undocumented) - headers: RawHttpHeaders & TestRunListMetricDimensionValuesDefaultHeaders; - // (undocumented) - status: string; -} - -// @public (undocumented) -export type TestRunListMetricDimensionValuesParameters = TestRunListMetricDimensionValuesQueryParam & RequestParameters; - -// @public (undocumented) -export interface TestRunListMetricDimensionValuesQueryParam { - // (undocumented) - queryParameters: TestRunListMetricDimensionValuesQueryParamProperties; -} - -// @public (undocumented) -export interface TestRunListMetricDimensionValuesQueryParamProperties { - interval?: "PT5S" | "PT10S" | "PT1M" | "PT5M" | "PT1H"; - metricname: string; - metricNamespace: string; - timespan: string; -} - -// @public (undocumented) -export interface TestRunListMetricNamespaces { - get(options?: TestRunListMetricNamespacesParameters): StreamableMethod; -} - -// @public -export interface TestRunListMetricNamespaces200Response extends HttpResponse { - // (undocumented) - body: MetricNamespaceCollectionOutput; - // (undocumented) - status: "200"; -} - -// @public (undocumented) -export interface TestRunListMetricNamespacesDefaultHeaders { - "x-ms-error-code"?: string; -} - -// @public -export interface TestRunListMetricNamespacesDefaultResponse extends HttpResponse { - // (undocumented) - body: ErrorResponseBodyOutput; - // (undocumented) - headers: RawHttpHeaders & TestRunListMetricNamespacesDefaultHeaders; - // (undocumented) - status: string; -} - -// @public (undocumented) -export type TestRunListMetricNamespacesParameters = RequestParameters; - -// @public (undocumented) -export interface TestRunListMetrics { - post(options: TestRunListMetricsParameters): StreamableMethod; -} - -// @public -export interface TestRunListMetrics200Response extends HttpResponse { - // (undocumented) - body: MetricsOutput; - // (undocumented) - status: "200"; -} - -// @public (undocumented) -export interface TestRunListMetricsBodyParam { - body?: MetricRequestPayload; -} - -// @public (undocumented) -export interface TestRunListMetricsDefaultHeaders { - "x-ms-error-code"?: string; -} - -// @public -export interface TestRunListMetricsDefaultResponse extends HttpResponse { - // (undocumented) - body: ErrorResponseBodyOutput; - // (undocumented) - headers: RawHttpHeaders & TestRunListMetricsDefaultHeaders; - // (undocumented) - status: string; -} - -// @public (undocumented) -export interface TestRunListMetricsMediaTypesParam { - contentType?: "application/json"; -} - -// @public (undocumented) -export type TestRunListMetricsParameters = TestRunListMetricsQueryParam & TestRunListMetricsMediaTypesParam & TestRunListMetricsBodyParam & RequestParameters; - -// @public (undocumented) -export interface TestRunListMetricsQueryParam { - // (undocumented) - queryParameters: TestRunListMetricsQueryParamProperties; -} - -// @public (undocumented) -export interface TestRunListMetricsQueryParamProperties { - aggregation?: string; - interval?: "PT5S" | "PT10S" | "PT1M" | "PT5M" | "PT1H"; - metricname: string; - metricNamespace: string; - timespan: string; -} - -// @public (undocumented) -export type TestRunListParameters = TestRunListQueryParam & RequestParameters; - -// @public (undocumented) -export interface TestRunListQueryParam { - // (undocumented) - queryParameters?: TestRunListQueryParamProperties; -} - -// @public (undocumented) -export interface TestRunListQueryParamProperties { - continuationToken?: string; - executionFrom?: Date | string; - executionTo?: Date | string; - maxpagesize?: number; - orderby?: string; - search?: string; - status?: string; - testId?: string; -} - -// @public -export interface TestRunListServerMetricsConfig200Response extends HttpResponse { - // (undocumented) - body: TestRunServerMetricConfigOutput; - // (undocumented) - status: "200"; -} - -// @public (undocumented) -export interface TestRunListServerMetricsConfigDefaultHeaders { - "x-ms-error-code"?: string; -} - -// @public -export interface TestRunListServerMetricsConfigDefaultResponse extends HttpResponse { - // (undocumented) - body: ErrorResponseBodyOutput; - // (undocumented) - headers: RawHttpHeaders & TestRunListServerMetricsConfigDefaultHeaders; - // (undocumented) - status: string; -} - -// @public (undocumented) -export type TestRunListServerMetricsConfigParameters = RequestParameters; - -// @public -export interface TestRunOutput { - certificate?: CertificateMetadataOutput; - createdBy?: string; - createdDateTime?: string; - description?: string; - displayName?: string; - duration?: number; - endDateTime?: string; - environmentVariables?: Record; - errorDetails?: Array; - executedDateTime?: string; - lastModifiedBy?: string; - lastModifiedDateTime?: string; - loadTestConfiguration?: LoadTestConfigurationOutput; - passFailCriteria?: PassFailCriteriaOutput; - portalUrl?: string; - secrets?: Record; - startDateTime?: string; - status?: "ACCEPTED" | "NOTSTARTED" | "PROVISIONING" | "PROVISIONED" | "CONFIGURING" | "CONFIGURED" | "EXECUTING" | "EXECUTED" | "DEPROVISIONING" | "DEPROVISIONED" | "DONE" | "CANCELLING" | "CANCELLED" | "FAILED" | "VALIDATION_SUCCESS" | "VALIDATION_FAILURE"; - subnetId?: string; - testArtifacts?: TestRunArtifactsOutput; - testId?: string; - testResult?: "PASSED" | "NOT_APPLICABLE" | "FAILED"; - testRunId?: string; - testRunStatistics?: Record; - virtualUsers?: number; -} - -// @public -export interface TestRunOutputArtifacts { - logsFileInfo?: FileInfo; - resultFileInfo?: FileInfo; -} - -// @public -export interface TestRunOutputArtifactsOutput { - logsFileInfo?: FileInfoOutput; - resultFileInfo?: FileInfoOutput; -} - -// @public -export interface TestRunServerMetricConfig { - createdBy?: string; - createdDateTime?: Date | string; - lastModifiedBy?: string; - lastModifiedDateTime?: Date | string; - metrics?: Record; - testRunId?: string; -} - -// @public -export interface TestRunServerMetricConfigOutput { - createdBy?: string; - createdDateTime?: string; - lastModifiedBy?: string; - lastModifiedDateTime?: string; - metrics?: Record; - testRunId?: string; -} - -// @public -export interface TestRunsListOutput { - nextLink?: string; - value: Array; -} - -// @public -export interface TestRunStatistics { - errorCount?: number; - errorPct?: number; - maxResTime?: number; - meanResTime?: number; - medianResTime?: number; - minResTime?: number; - pct1ResTime?: number; - pct2ResTime?: number; - pct3ResTime?: number; - receivedKBytesPerSec?: number; - sampleCount?: number; - sentKBytesPerSec?: number; - throughput?: number; - transaction?: string; -} - -// @public -export interface TestRunStatisticsOutput { - errorCount?: number; - errorPct?: number; - maxResTime?: number; - meanResTime?: number; - medianResTime?: number; - minResTime?: number; - pct1ResTime?: number; - pct2ResTime?: number; - pct3ResTime?: number; - receivedKBytesPerSec?: number; - sampleCount?: number; - sentKBytesPerSec?: number; - throughput?: number; - transaction?: string; -} - -// @public (undocumented) -export interface TestRunStop { - post(options?: TestRunStopParameters): StreamableMethod; -} - -// @public -export interface TestRunStop200Response extends HttpResponse { - // (undocumented) - body: TestRunOutput; - // (undocumented) - status: "200"; -} - -// @public (undocumented) -export interface TestRunStopDefaultHeaders { - "x-ms-error-code"?: string; -} - -// @public -export interface TestRunStopDefaultResponse extends HttpResponse { - // (undocumented) - body: ErrorResponseBodyOutput; - // (undocumented) - headers: RawHttpHeaders & TestRunStopDefaultHeaders; - // (undocumented) - status: string; -} - -// @public (undocumented) -export type TestRunStopParameters = RequestParameters; - -// @public -export interface TestServerMetricConfig { - createdBy?: string; - createdDateTime?: Date | string; - lastModifiedBy?: string; - lastModifiedDateTime?: Date | string; - metrics?: Record; - testId?: string; -} - -// @public -export interface TestServerMetricConfigOutput { - createdBy?: string; - createdDateTime?: string; - lastModifiedBy?: string; - lastModifiedDateTime?: string; - metrics?: Record; - testId?: string; -} - -// @public -export interface TestsListOutput { - nextLink?: string; - value: Array; -} - -// @public (undocumented) -export interface TestUploadFile { - delete(options?: TestDeleteFileParameters): StreamableMethod; - get(options?: TestGetFileParameters): StreamableMethod; - put(options: TestUploadFileParameters): StreamableMethod; -} - -// @public -export interface TestUploadFile201Response extends HttpResponse { - // (undocumented) - body: FileInfoOutput; - // (undocumented) - status: "201"; -} - -// @public (undocumented) -export interface TestUploadFileBodyParam { - body: string | Uint8Array | ReadableStream | NodeJS.ReadableStream; -} - -// @public (undocumented) -export interface TestUploadFileDefaultHeaders { - "x-ms-error-code"?: string; -} - -// @public -export interface TestUploadFileDefaultResponse extends HttpResponse { - // (undocumented) - body: ErrorResponseBodyOutput; - // (undocumented) - headers: RawHttpHeaders & TestUploadFileDefaultHeaders; - // (undocumented) - status: string; -} - -// @public (undocumented) -export interface TestUploadFileMediaTypesParam { - contentType?: "application/octet-stream"; -} - -// @public (undocumented) -export type TestUploadFileParameters = TestUploadFileQueryParam & TestUploadFileMediaTypesParam & TestUploadFileBodyParam & RequestParameters; - -// @public (undocumented) -export interface TestUploadFileQueryParam { - // (undocumented) - queryParameters?: TestUploadFileQueryParamProperties; -} - -// @public (undocumented) -export interface TestUploadFileQueryParamProperties { - fileType?: "JMX_FILE" | "USER_PROPERTIES" | "ADDITIONAL_ARTIFACTS"; -} - -// @public (undocumented) -export type TestUploadFileSuccessResponse = TestUploadFile201Response; - -// @public -export interface TimeSeriesElementOutput { - data?: Array; - dimensionValues?: Array; -} - -// (No @packageDocumentation comment for this package) - -``` diff --git a/sdk/loadtesting/load-testing-rest/sample.env b/sdk/loadtesting/load-testing-rest/sample.env deleted file mode 100644 index d01f16f14dd8..000000000000 --- a/sdk/loadtesting/load-testing-rest/sample.env +++ /dev/null @@ -1,8 +0,0 @@ -# App registration secret for AAD authentication -AZURE_CLIENT_SECRET= -AZURE_CLIENT_ID= -AZURE_TENANT_ID= - -LOADTESTSERVICE_ENDPOINT= -SUBSCRIPTION_ID= -RESOURCE_GROUP= diff --git a/sdk/loadtesting/load-testing-rest/samples-dev/sample.jmx b/sdk/loadtesting/load-testing-rest/samples-dev/sample.jmx deleted file mode 100644 index a8d909ef60fa..000000000000 --- a/sdk/loadtesting/load-testing-rest/samples-dev/sample.jmx +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - false - false - - - - - - - - continue - - false - 10 - - 50 - 2 - 1515063650000 - 1515063650000 - false - 60 - - true - - - - - - - microsoft.com - - - - / - GET - true - false - true - false - - - - - - - - false - - saveConfig - - - true - true - true - - true - true - true - true - false - true - true - false - false - false - true - false - false - false - true - 0 - true - true - true - true - true - true - - - - - - - - diff --git a/sdk/loadtesting/load-testing-rest/samples-dev/sample.ts b/sdk/loadtesting/load-testing-rest/samples-dev/sample.ts deleted file mode 100644 index 4467375d0718..000000000000 --- a/sdk/loadtesting/load-testing-rest/samples-dev/sample.ts +++ /dev/null @@ -1,196 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to a) create a loadtest, b) upload a jmx file, c) create appcomponent, d) run test and e) get test status, and f) get test metrics - * - * @summary creates and run a loadtest - * @azsdk-weight 10 - */ - -import AzureLoadTesting, { isUnexpected, getLongRunningPoller } from "@azure-rest/load-testing"; -import { DefaultAzureCredential } from "@azure/identity"; -import { createReadStream } from "fs"; -import { v4 as uuidv4 } from "uuid"; - -const readStream = createReadStream("./sample.jmx"); - -async function main() { - const endpoint = process.env["LOADTESTSERVICE_ENDPOINT"] || ""; - const displayName = "some-load-test"; - const SUBSCRIPTION_ID = process.env["SUBSCRIPTION_ID"] || ""; - const testId = uuidv4(); // ID to be assigned to a test - const testRunId = uuidv4(); // ID to be assigned to a testRun - - // Build a client through AAD - const client = AzureLoadTesting(endpoint, new DefaultAzureCredential()); - - // Creating/Updating a load test - const testCreationResult = await client.path("/tests/{testId}", testId).patch({ - contentType: "application/merge-patch+json", - body: { - displayName: displayName, - description: "", - loadTestConfiguration: { - engineInstances: 1, // number of engine instances to run test - }, - }, - }); - // Checking for error response - if (isUnexpected(testCreationResult)) { - throw testCreationResult.body.error; - } - - if (testCreationResult.body.testId === undefined) - throw new Error("Test ID returned as undefined."); - - // Uploading .jmx file to a test - const fileUploadResult = await client - .path("/tests/{testId}/files/{fileName}", testId, "sample.jmx") - .put({ - contentType: "application/octet-stream", - body: readStream, - }); - - if (isUnexpected(fileUploadResult)) { - throw fileUploadResult.body.error; - } - - let fileValidateResult; - const fileValidatePoller = await getLongRunningPoller(client, fileUploadResult); - try { - fileValidateResult = await fileValidatePoller.pollUntilDone({ - abortSignal: AbortSignal.timeout(120 * 1000), // timeout of 120 seconds - }); - } catch (ex: any) { - new Error("Error in polling file Validation" + ex.message); //polling timed out - } - - if (fileValidatePoller.getOperationState().status != "succeeded" && fileValidateResult) - throw new Error( - "There is some issue in validation, please make sure uploaded file is a valid JMX." + - fileValidateResult.body.validationFailureDetails, - ); - - // Creating/Updating app component - const appComponentCreationResult = await client - .path("/tests/{testId}/app-components", testId) - .patch({ - contentType: "application/merge-patch+json", - body: { - testId: testCreationResult.body.testId, - components: { - "/subscriptions/{SUBSCRIPTION_ID}/resourceGroups/App-Service-Sample-Demo-rg/providers/Microsoft.Web/sites/App-Service-Sample-Demo": - { - resourceId: - "/subscriptions/{SUBSCRIPTION_ID}/resourceGroups/App-Service-Sample-Demo-rg/providers/Microsoft.Web/sites/App-Service-Sample-Demo", - resourceName: "App-Service-Sample-Demo", - resourceType: "Microsoft.Web/sites", - subscriptionId: SUBSCRIPTION_ID, - }, - }, - }, - }); - - if (isUnexpected(appComponentCreationResult)) { - throw appComponentCreationResult.body.error; - } - - // Creating/Updating the test run - const testRunCreationResult = await client.path("/test-runs/{testRunId}", testRunId).patch({ - contentType: "application/merge-patch+json", - body: { - testId: testId, - displayName: displayName, - virtualUsers: 10, - }, - }); - - if (isUnexpected(testRunCreationResult)) { - throw testRunCreationResult.body.error; - } - - if (testRunCreationResult.body.testRunId === undefined) - throw new Error("Test Run ID returned as undefined."); - - let testRunResult; - const testRunPoller = await getLongRunningPoller(client, testRunCreationResult); - - try { - testRunResult = await testRunPoller.pollUntilDone({ - abortSignal: AbortSignal.timeout(300 * 1000), // timeout of 5 minutes - }); - } catch (ex: any) { - new Error("Error in polling test run completion" + ex.message); //polling timed out - } - - if (testRunPoller.getOperationState().status != "succeeded") - throw new Error("There is some issue in running the test, Error Response : " + testRunResult); - - if (testRunResult) { - let testRunStarttime = testRunResult.body.startDateTime; - let testRunEndTime = testRunResult.body.endDateTime; - - // get list of all metric namespaces and pick the first one - const metricNamespaces = await client - .path("/test-runs/{testRunId}/metric-namespaces", testRunId) - .get(); - - if (isUnexpected(metricNamespaces)) { - throw metricNamespaces.body.error; - } - - const metricNamespace = metricNamespaces.body.value[0]; - - if (metricNamespace.name === undefined) { - throw "No Metric Namespace name is defined."; - } - - // get list of all metric definitions and pick the first one - const metricDefinitions = await client - .path("/test-runs/{testRunId}/metric-definitions", testRunId) - .get({ - queryParameters: { - metricNamespace: metricNamespace.name, - }, - }); - - if (isUnexpected(metricDefinitions)) { - throw metricDefinitions.body.error; - } - - const metricDefinition = metricDefinitions.body.value[0]; - - if (metricDefinition.name === undefined) { - throw "No Metric Namespace name is defined."; - } - - // fetch client metrics using metric namespace and metric name - const metricsResult = await client.path("/test-runs/{testRunId}/metrics", testRunId).post({ - queryParameters: { - metricname: metricDefinition.name, - metricNamespace: metricNamespace.name, - timespan: testRunStarttime + "/" + testRunEndTime, - }, - }); - - console.log(metricsResult); - console.log(testRunResult); - - // Deleting test run - const deleteTestRunResult = await client.path("/test-runs/{testRunId}", testRunId).delete(); - - if (isUnexpected(deleteTestRunResult)) { - throw deleteTestRunResult.body.error; - } - - // Deleting test - const deleteTestResult = await client.path("/tests/{testId}", testId).delete(); - - if (isUnexpected(deleteTestResult)) { - throw deleteTestResult.body.error; - } - } -} - -main().catch(console.error); diff --git a/sdk/loadtesting/load-testing-rest/samples-dev/stopTest.ts b/sdk/loadtesting/load-testing-rest/samples-dev/stopTest.ts deleted file mode 100644 index daa145545c5b..000000000000 --- a/sdk/loadtesting/load-testing-rest/samples-dev/stopTest.ts +++ /dev/null @@ -1,68 +0,0 @@ -/** - * This sample demonstrates how to run a test and stop execution - * - * @summary creates, run and stop a loadtest - * @azsdk-weight 10 - */ - -import AzureLoadTesting, { isUnexpected } from "@azure-rest/load-testing"; -import { DefaultAzureCredential } from "@azure/identity"; -import { v4 as uuidv4 } from "uuid"; - -async function main() { - const endpoint = process.env["LOADTESTSERVICE_ENDPOINT"] || ""; - const displayName = "some-load-test"; - const testId = uuidv4(); // ID to be assigned to a test - const testRunId = uuidv4(); // ID to be assigned to a testRun - - // Build a client through AAD - const client = AzureLoadTesting(endpoint, new DefaultAzureCredential()); - - // Patching a load test - const testCreationResult = await client.path("/tests/{testId}", testId).patch({ - contentType: "application/merge-patch+json", - body: { - displayName: displayName, - description: "", - loadTestConfiguration: { - engineInstances: 1, // number of engine instances to run test - }, - }, - }); - // Checking for error response - if (isUnexpected(testCreationResult)) { - throw testCreationResult.body.error; - } - - if (testCreationResult.body.testId === undefined) - throw new Error("Test ID returned as undefined."); - - // Patching the test run - const testRunCreationResult = await client.path("/test-runs/{testRunId}", testRunId).patch({ - contentType: "application/merge-patch+json", - body: { - testId: testId, - displayName: displayName, - virtualUsers: 10, - }, - }); - - if (isUnexpected(testRunCreationResult)) { - throw testRunCreationResult.body.error; - } - - if (testRunCreationResult.body.testRunId === undefined) - throw new Error("Test Run ID returned as undefined."); - - // Checking the test run status - const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms)); - - sleep(30000); - - let stopTestRunResult = await client.path("/test-runs/{testRunId}:stop", testRunId).post(); - - if (isUnexpected(stopTestRunResult)) { - throw stopTestRunResult.body.error; - } -} -main().catch(console.error); diff --git a/sdk/loadtesting/load-testing-rest/samples/v1-beta/javascript/README.md b/sdk/loadtesting/load-testing-rest/samples/v1-beta/javascript/README.md deleted file mode 100644 index d1644381770e..000000000000 --- a/sdk/loadtesting/load-testing-rest/samples/v1-beta/javascript/README.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -page_type: sample -languages: - - javascript -products: - - azure -urlFragment: load-testing-javascript-beta ---- - -# Azure Load Testing rest client library samples for JavaScript (Beta) - -These sample programs show how to use the JavaScript client libraries for Azure Load Testing rest in some common scenarios. - -| **File Name** | **Description** | -| ----------------------- | -------------------------------- | -| [sample.js][sample] | creates and run a loadtest | -| [stopTest.js][stoptest] | creates, run and stop a loadtest | - -## Prerequisites - -The sample programs are compatible with [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule). - -You need [an Azure subscription][freesub] and the following Azure resources to run these sample programs: - -- [Azure LoadTesting Service instance][createinstance_azureloadtestingserviceinstance] - -Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. - -Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. - -## Setup - -To run the samples using the published version of the package: - -1. Install the dependencies using `npm`: - -```bash -npm install -``` - -2. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. - -3. Run whichever samples you like (note that some samples may require additional setup, see the table above): - -```bash -node sample.js -``` - -Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): - -```bash -npx cross-env LOADTESTSERVICE_ENDPOINT="" SUBSCRIPTION_ID="" node sample.js -``` - -## Next Steps - -Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. - -[sample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/load-testing-rest/samples/v1-beta/javascript/sample.js -[stoptest]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/load-testing-rest/samples/v1-beta/javascript/stopTest.js -[apiref]: https://docs.microsoft.com/javascript/api/@azure-rest/load-testing -[freesub]: https://azure.microsoft.com/free/ -[createinstance_azureloadtestingserviceinstance]: https://learn.microsoft.com/azure/load-testing/ -[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/loadtesting/load-testing-rest/README.md diff --git a/sdk/loadtesting/load-testing-rest/samples/v1-beta/javascript/package.json b/sdk/loadtesting/load-testing-rest/samples/v1-beta/javascript/package.json deleted file mode 100644 index 51d06337cb76..000000000000 --- a/sdk/loadtesting/load-testing-rest/samples/v1-beta/javascript/package.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "@azure-samples/load-testing-js-beta", - "private": true, - "version": "1.0.0", - "description": "Azure Load Testing rest client library samples for JavaScript (Beta)", - "engines": { - "node": ">=18.0.0" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/Azure/azure-sdk-for-js.git", - "directory": "sdk/loadtesting/load-testing-rest" - }, - "keywords": [ - "node", - "azure", - "cloud", - "typescript", - "browser", - "isomorphic" - ], - "author": "Microsoft Corporation", - "license": "MIT", - "bugs": { - "url": "https://github.com/Azure/azure-sdk-for-js/issues" - }, - "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/loadtesting/load-testing-rest", - "dependencies": { - "@azure-rest/load-testing": "1.0.0-beta.2", - "dotenv": "latest", - "@azure/abort-controller": "^1.1.1", - "@azure/identity": "^4.2.1", - "uuid": "^9.0.0" - } -} diff --git a/sdk/loadtesting/load-testing-rest/samples/v1-beta/javascript/sample.env b/sdk/loadtesting/load-testing-rest/samples/v1-beta/javascript/sample.env deleted file mode 100644 index d01f16f14dd8..000000000000 --- a/sdk/loadtesting/load-testing-rest/samples/v1-beta/javascript/sample.env +++ /dev/null @@ -1,8 +0,0 @@ -# App registration secret for AAD authentication -AZURE_CLIENT_SECRET= -AZURE_CLIENT_ID= -AZURE_TENANT_ID= - -LOADTESTSERVICE_ENDPOINT= -SUBSCRIPTION_ID= -RESOURCE_GROUP= diff --git a/sdk/loadtesting/load-testing-rest/samples/v1-beta/javascript/sample.js b/sdk/loadtesting/load-testing-rest/samples/v1-beta/javascript/sample.js deleted file mode 100644 index d305db386a22..000000000000 --- a/sdk/loadtesting/load-testing-rest/samples/v1-beta/javascript/sample.js +++ /dev/null @@ -1,197 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to a) create a loadtest, b) upload a jmx file, c) create appcomponent, d) run test and e) get test status, and f) get test metrics - * - * @summary creates and run a loadtest - */ - -const AzureLoadTesting = require("@azure-rest/load-testing").default, - { isUnexpected, getLongRunningPoller } = require("@azure-rest/load-testing"); -const { AbortController } = require("@azure/abort-controller"); -const { DefaultAzureCredential } = require("@azure/identity"); -const { createReadStream } = require("fs"); -const { v4: uuidv4 } = require("uuid"); - -const readStream = createReadStream("./sample.jmx"); - -async function main() { - const endpoint = process.env["LOADTESTSERVICE_ENDPOINT"] || ""; - const displayName = "some-load-test"; - const SUBSCRIPTION_ID = process.env["SUBSCRIPTION_ID"] || ""; - const testId = uuidv4(); // ID to be assigned to a test - const testRunId = uuidv4(); // ID to be assigned to a testRun - - // Build a client through AAD - const client = AzureLoadTesting(endpoint, new DefaultAzureCredential()); - - // Creating/Updating a load test - const testCreationResult = await client.path("/tests/{testId}", testId).patch({ - contentType: "application/merge-patch+json", - body: { - displayName: displayName, - description: "", - loadTestConfiguration: { - engineInstances: 1, // number of engine instances to run test - }, - }, - }); - // Checking for error response - if (isUnexpected(testCreationResult)) { - throw testCreationResult.body.error; - } - - if (testCreationResult.body.testId === undefined) - throw new Error("Test ID returned as undefined."); - - // Uploading .jmx file to a test - const fileUploadResult = await client - .path("/tests/{testId}/files/{fileName}", testId, "sample.jmx") - .put({ - contentType: "application/octet-stream", - body: readStream, - }); - - if (isUnexpected(fileUploadResult)) { - throw fileUploadResult.body.error; - } - - let fileValidateResult; - const fileValidatePoller = await getLongRunningPoller(client, fileUploadResult); - try { - fileValidateResult = await fileValidatePoller.pollUntilDone({ - abortSignal: AbortSignal.timeout(120 * 1000), // timeout of 120 seconds - }); - } catch (ex) { - new Error("Error in polling file Validation" + ex.message); //polling timed out - } - - if (fileValidatePoller.getOperationState().status != "succeeded" && fileValidateResult) - throw new Error( - "There is some issue in validation, please make sure uploaded file is a valid JMX." + - fileValidateResult.body.validationFailureDetails - ); - - // Creating/Updating app component - const appComponentCreationResult = await client - .path("/tests/{testId}/app-components", testId) - .patch({ - contentType: "application/merge-patch+json", - body: { - testId: testCreationResult.body.testId, - components: { - "/subscriptions/{SUBSCRIPTION_ID}/resourceGroups/App-Service-Sample-Demo-rg/providers/Microsoft.Web/sites/App-Service-Sample-Demo": - { - resourceId: - "/subscriptions/{SUBSCRIPTION_ID}/resourceGroups/App-Service-Sample-Demo-rg/providers/Microsoft.Web/sites/App-Service-Sample-Demo", - resourceName: "App-Service-Sample-Demo", - resourceType: "Microsoft.Web/sites", - subscriptionId: SUBSCRIPTION_ID, - }, - }, - }, - }); - - if (isUnexpected(appComponentCreationResult)) { - throw appComponentCreationResult.body.error; - } - - // Creating/Updating the test run - const testRunCreationResult = await client.path("/test-runs/{testRunId}", testRunId).patch({ - contentType: "application/merge-patch+json", - body: { - testId: testId, - displayName: displayName, - virtualUsers: 10, - }, - }); - - if (isUnexpected(testRunCreationResult)) { - throw testRunCreationResult.body.error; - } - - if (testRunCreationResult.body.testRunId === undefined) - throw new Error("Test Run ID returned as undefined."); - - let testRunResult; - const testRunPoller = await getLongRunningPoller(client, testRunCreationResult); - - try { - testRunResult = await testRunPoller.pollUntilDone({ - abortSignal: AbortSignal.timeout(300 * 1000), // timeout of 5 minutes - }); - } catch (ex) { - new Error("Error in polling test run completion" + ex.message); //polling timed out - } - - if (testRunPoller.getOperationState().status != "succeeded") - throw new Error("There is some issue in running the test, Error Response : " + testRunResult); - - if (testRunResult) { - let testRunStarttime = testRunResult.body.startDateTime; - let testRunEndTime = testRunResult.body.endDateTime; - - // get list of all metric namespaces and pick the first one - const metricNamespaces = await client - .path("/test-runs/{testRunId}/metric-namespaces", testRunId) - .get(); - - if (isUnexpected(metricNamespaces)) { - throw metricNamespaces.body.error; - } - - const metricNamespace = metricNamespaces.body.value[0]; - - if (metricNamespace.name === undefined) { - throw "No Metric Namespace name is defined."; - } - - // get list of all metric definitions and pick the first one - const metricDefinitions = await client - .path("/test-runs/{testRunId}/metric-definitions", testRunId) - .get({ - queryParameters: { - metricNamespace: metricNamespace.name, - }, - }); - - if (isUnexpected(metricDefinitions)) { - throw metricDefinitions.body.error; - } - - const metricDefinition = metricDefinitions.body.value[0]; - - if (metricDefinition.name === undefined) { - throw "No Metric Namespace name is defined."; - } - - // fetch client metrics using metric namespace and metric name - const metricsResult = await client.path("/test-runs/{testRunId}/metrics", testRunId).post({ - queryParameters: { - metricname: metricDefinition.name, - metricNamespace: metricNamespace.name, - timespan: testRunStarttime + "/" + testRunEndTime, - }, - }); - - console.log(metricsResult); - console.log(testRunResult); - - // Deleting test run - const deleteTestRunResult = await client.path("/test-runs/{testRunId}", testRunId).delete(); - - if (isUnexpected(deleteTestRunResult)) { - throw deleteTestRunResult.body.error; - } - - // Deleting test - const deleteTestResult = await client.path("/tests/{testId}", testId).delete(); - - if (isUnexpected(deleteTestResult)) { - throw deleteTestResult.body.error; - } - } -} - -main().catch(console.error); diff --git a/sdk/loadtesting/load-testing-rest/samples/v1-beta/javascript/stopTest.js b/sdk/loadtesting/load-testing-rest/samples/v1-beta/javascript/stopTest.js deleted file mode 100644 index cfed7ceb0ed5..000000000000 --- a/sdk/loadtesting/load-testing-rest/samples/v1-beta/javascript/stopTest.js +++ /dev/null @@ -1,68 +0,0 @@ -/** - * This sample demonstrates how to run a test and stop execution - * - * @summary creates, run and stop a loadtest - */ - -const AzureLoadTesting = require("@azure-rest/load-testing").default, - { isUnexpected } = require("@azure-rest/load-testing"); -const { DefaultAzureCredential } = require("@azure/identity"); -const { v4: uuidv4 } = require("uuid"); - -async function main() { - const endpoint = process.env["LOADTESTSERVICE_ENDPOINT"] || ""; - const displayName = "some-load-test"; - const testId = uuidv4(); // ID to be assigned to a test - const testRunId = uuidv4(); // ID to be assigned to a testRun - - // Build a client through AAD - const client = AzureLoadTesting(endpoint, new DefaultAzureCredential()); - - // Patching a load test - const testCreationResult = await client.path("/tests/{testId}", testId).patch({ - contentType: "application/merge-patch+json", - body: { - displayName: displayName, - description: "", - loadTestConfiguration: { - engineInstances: 1, // number of engine instances to run test - }, - }, - }); - // Checking for error response - if (isUnexpected(testCreationResult)) { - throw testCreationResult.body.error; - } - - if (testCreationResult.body.testId === undefined) - throw new Error("Test ID returned as undefined."); - - // Patching the test run - const testRunCreationResult = await client.path("/test-runs/{testRunId}", testRunId).patch({ - contentType: "application/merge-patch+json", - body: { - testId: testId, - displayName: displayName, - virtualUsers: 10, - }, - }); - - if (isUnexpected(testRunCreationResult)) { - throw testRunCreationResult.body.error; - } - - if (testRunCreationResult.body.testRunId === undefined) - throw new Error("Test Run ID returned as undefined."); - - // Checking the test run status - const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); - - sleep(30000); - - let stopTestRunResult = await client.path("/test-runs/{testRunId}:stop", testRunId).post(); - - if (isUnexpected(stopTestRunResult)) { - throw stopTestRunResult.body.error; - } -} -main().catch(console.error); diff --git a/sdk/loadtesting/load-testing-rest/samples/v1-beta/typescript/README.md b/sdk/loadtesting/load-testing-rest/samples/v1-beta/typescript/README.md deleted file mode 100644 index 49fe27e08c49..000000000000 --- a/sdk/loadtesting/load-testing-rest/samples/v1-beta/typescript/README.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -page_type: sample -languages: - - typescript -products: - - azure -urlFragment: load-testing-typescript-beta ---- - -# Azure Load Testing rest client library samples for TypeScript (Beta) - -These sample programs show how to use the TypeScript client libraries for Azure Load Testing rest in some common scenarios. - -| **File Name** | **Description** | -| ----------------------- | -------------------------------- | -| [sample.ts][sample] | creates and run a loadtest | -| [stopTest.ts][stoptest] | creates, run and stop a loadtest | - -## Prerequisites - -The sample programs are compatible with [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule). - -Before running the samples in Node, they must be compiled to JavaScript using the TypeScript compiler. For more information on TypeScript, see the [TypeScript documentation][typescript]. Install the TypeScript compiler using: - -```bash -npm install -g typescript -``` - -You need [an Azure subscription][freesub] and the following Azure resources to run these sample programs: - -- [Azure LoadTesting Service instance][createinstance_azureloadtestingserviceinstance] - -Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. - -Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. - -## Setup - -To run the samples using the published version of the package: - -1. Install the dependencies using `npm`: - -```bash -npm install -``` - -2. Compile the samples: - -```bash -npm run build -``` - -3. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. - -4. Run whichever samples you like (note that some samples may require additional setup, see the table above): - -```bash -node dist/sample.js -``` - -Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): - -```bash -npx cross-env LOADTESTSERVICE_ENDPOINT="" SUBSCRIPTION_ID="" node dist/sample.js -``` - -## Next Steps - -Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. - -[sample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/load-testing-rest/samples/v1-beta/typescript/src/sample.ts -[stoptest]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/load-testing-rest/samples/v1-beta/typescript/src/stopTest.ts -[apiref]: https://docs.microsoft.com/javascript/api/@azure-rest/load-testing -[freesub]: https://azure.microsoft.com/free/ -[createinstance_azureloadtestingserviceinstance]: https://learn.microsoft.com/azure/load-testing/ -[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/loadtesting/load-testing-rest/README.md -[typescript]: https://www.typescriptlang.org/docs/home.html diff --git a/sdk/loadtesting/load-testing-rest/samples/v1-beta/typescript/package.json b/sdk/loadtesting/load-testing-rest/samples/v1-beta/typescript/package.json deleted file mode 100644 index 84781fc5b445..000000000000 --- a/sdk/loadtesting/load-testing-rest/samples/v1-beta/typescript/package.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "name": "@azure-samples/load-testing-ts-beta", - "private": true, - "version": "1.0.0", - "description": "Azure Load Testing rest client library samples for TypeScript (Beta)", - "engines": { - "node": ">=18.0.0" - }, - "scripts": { - "build": "tsc", - "prebuild": "rimraf dist/" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/Azure/azure-sdk-for-js.git", - "directory": "sdk/loadtesting/load-testing-rest" - }, - "keywords": [ - "node", - "azure", - "cloud", - "typescript", - "browser", - "isomorphic" - ], - "author": "Microsoft Corporation", - "license": "MIT", - "bugs": { - "url": "https://github.com/Azure/azure-sdk-for-js/issues" - }, - "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/loadtesting/load-testing-rest", - "dependencies": { - "@azure-rest/load-testing": "1.0.0-beta.2", - "dotenv": "latest", - "@azure/abort-controller": "^1.1.1", - "@azure/identity": "^4.2.1", - "uuid": "^9.0.0" - }, - "devDependencies": { - "@types/uuid": "^8.3.4", - "@types/node": "^18.0.0", - "typescript": "~5.6.2", - "rimraf": "latest" - } -} diff --git a/sdk/loadtesting/load-testing-rest/samples/v1-beta/typescript/sample.env b/sdk/loadtesting/load-testing-rest/samples/v1-beta/typescript/sample.env deleted file mode 100644 index d01f16f14dd8..000000000000 --- a/sdk/loadtesting/load-testing-rest/samples/v1-beta/typescript/sample.env +++ /dev/null @@ -1,8 +0,0 @@ -# App registration secret for AAD authentication -AZURE_CLIENT_SECRET= -AZURE_CLIENT_ID= -AZURE_TENANT_ID= - -LOADTESTSERVICE_ENDPOINT= -SUBSCRIPTION_ID= -RESOURCE_GROUP= diff --git a/sdk/loadtesting/load-testing-rest/samples/v1-beta/typescript/src/sample.ts b/sdk/loadtesting/load-testing-rest/samples/v1-beta/typescript/src/sample.ts deleted file mode 100644 index 42ed0df94114..000000000000 --- a/sdk/loadtesting/load-testing-rest/samples/v1-beta/typescript/src/sample.ts +++ /dev/null @@ -1,195 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to a) create a loadtest, b) upload a jmx file, c) create appcomponent, d) run test and e) get test status, and f) get test metrics - * - * @summary creates and run a loadtest - */ - -import AzureLoadTesting, { isUnexpected, getLongRunningPoller } from "@azure-rest/load-testing"; -import { AbortController } from "@azure/abort-controller"; -import { DefaultAzureCredential } from "@azure/identity"; -import { createReadStream } from "fs"; -import { v4 as uuidv4 } from "uuid"; - -const readStream = createReadStream("./sample.jmx"); - -async function main() { - const endpoint = process.env["LOADTESTSERVICE_ENDPOINT"] || ""; - const displayName = "some-load-test"; - const SUBSCRIPTION_ID = process.env["SUBSCRIPTION_ID"] || ""; - const testId = uuidv4(); // ID to be assigned to a test - const testRunId = uuidv4(); // ID to be assigned to a testRun - - // Build a client through AAD - const client = AzureLoadTesting(endpoint, new DefaultAzureCredential()); - - // Creating/Updating a load test - const testCreationResult = await client.path("/tests/{testId}", testId).patch({ - contentType: "application/merge-patch+json", - body: { - displayName: displayName, - description: "", - loadTestConfiguration: { - engineInstances: 1, // number of engine instances to run test - }, - }, - }); - // Checking for error response - if (isUnexpected(testCreationResult)) { - throw testCreationResult.body.error; - } - - if (testCreationResult.body.testId === undefined) - throw new Error("Test ID returned as undefined."); - - // Uploading .jmx file to a test - const fileUploadResult = await client - .path("/tests/{testId}/files/{fileName}", testId, "sample.jmx") - .put({ - contentType: "application/octet-stream", - body: readStream, - }); - - if (isUnexpected(fileUploadResult)) { - throw fileUploadResult.body.error; - } - - let fileValidateResult; - const fileValidatePoller = await getLongRunningPoller(client, fileUploadResult); - try { - fileValidateResult = await fileValidatePoller.pollUntilDone({ - abortSignal: AbortSignal.timeout(120 * 1000), // timeout of 120 seconds - }); - } catch (ex: any) { - new Error("Error in polling file Validation" + ex.message); //polling timed out - } - - if (fileValidatePoller.getOperationState().status != "succeeded" && fileValidateResult) - throw new Error( - "There is some issue in validation, please make sure uploaded file is a valid JMX." + - fileValidateResult.body.validationFailureDetails - ); - - // Creating/Updating app component - const appComponentCreationResult = await client - .path("/tests/{testId}/app-components", testId) - .patch({ - contentType: "application/merge-patch+json", - body: { - testId: testCreationResult.body.testId, - components: { - "/subscriptions/{SUBSCRIPTION_ID}/resourceGroups/App-Service-Sample-Demo-rg/providers/Microsoft.Web/sites/App-Service-Sample-Demo": { - resourceId: - "/subscriptions/{SUBSCRIPTION_ID}/resourceGroups/App-Service-Sample-Demo-rg/providers/Microsoft.Web/sites/App-Service-Sample-Demo", - resourceName: "App-Service-Sample-Demo", - resourceType: "Microsoft.Web/sites", - subscriptionId: SUBSCRIPTION_ID, - }, - }, - }, - }); - - if (isUnexpected(appComponentCreationResult)) { - throw appComponentCreationResult.body.error; - } - - // Creating/Updating the test run - const testRunCreationResult = await client.path("/test-runs/{testRunId}", testRunId).patch({ - contentType: "application/merge-patch+json", - body: { - testId: testId, - displayName: displayName, - virtualUsers: 10, - }, - }); - - if (isUnexpected(testRunCreationResult)) { - throw testRunCreationResult.body.error; - } - - if (testRunCreationResult.body.testRunId === undefined) - throw new Error("Test Run ID returned as undefined."); - - let testRunResult; - const testRunPoller = await getLongRunningPoller(client, testRunCreationResult); - - try { - testRunResult = await testRunPoller.pollUntilDone({ - abortSignal: AbortSignal.timeout(300 * 1000), // timeout of 5 minutes - }); - } catch (ex: any) { - new Error("Error in polling test run completion" + ex.message); //polling timed out - } - - if (testRunPoller.getOperationState().status != "succeeded") - throw new Error("There is some issue in running the test, Error Response : " + testRunResult); - - if (testRunResult) { - let testRunStarttime = testRunResult.body.startDateTime; - let testRunEndTime = testRunResult.body.endDateTime; - - // get list of all metric namespaces and pick the first one - const metricNamespaces = await client - .path("/test-runs/{testRunId}/metric-namespaces", testRunId) - .get(); - - if (isUnexpected(metricNamespaces)) { - throw metricNamespaces.body.error; - } - - const metricNamespace = metricNamespaces.body.value[0]; - - if (metricNamespace.name === undefined) { - throw "No Metric Namespace name is defined."; - } - - // get list of all metric definitions and pick the first one - const metricDefinitions = await client - .path("/test-runs/{testRunId}/metric-definitions", testRunId) - .get({ - queryParameters: { - metricNamespace: metricNamespace.name, - }, - }); - - if (isUnexpected(metricDefinitions)) { - throw metricDefinitions.body.error; - } - - const metricDefinition = metricDefinitions.body.value[0]; - - if (metricDefinition.name === undefined) { - throw "No Metric Namespace name is defined."; - } - - // fetch client metrics using metric namespace and metric name - const metricsResult = await client.path("/test-runs/{testRunId}/metrics", testRunId).post({ - queryParameters: { - metricname: metricDefinition.name, - metricNamespace: metricNamespace.name, - timespan: testRunStarttime + "/" + testRunEndTime, - }, - }); - - console.log(metricsResult); - console.log(testRunResult); - - // Deleting test run - const deleteTestRunResult = await client.path("/test-runs/{testRunId}", testRunId).delete(); - - if (isUnexpected(deleteTestRunResult)) { - throw deleteTestRunResult.body.error; - } - - // Deleting test - const deleteTestResult = await client.path("/tests/{testId}", testId).delete(); - - if (isUnexpected(deleteTestResult)) { - throw deleteTestResult.body.error; - } - } -} - -main().catch(console.error); diff --git a/sdk/loadtesting/load-testing-rest/samples/v1-beta/typescript/src/stopTest.ts b/sdk/loadtesting/load-testing-rest/samples/v1-beta/typescript/src/stopTest.ts deleted file mode 100644 index 4ad09a35d6c8..000000000000 --- a/sdk/loadtesting/load-testing-rest/samples/v1-beta/typescript/src/stopTest.ts +++ /dev/null @@ -1,67 +0,0 @@ -/** - * This sample demonstrates how to run a test and stop execution - * - * @summary creates, run and stop a loadtest - */ - -import AzureLoadTesting, { isUnexpected } from "@azure-rest/load-testing"; -import { DefaultAzureCredential } from "@azure/identity"; -import { v4 as uuidv4 } from "uuid"; - -async function main() { - const endpoint = process.env["LOADTESTSERVICE_ENDPOINT"] || ""; - const displayName = "some-load-test"; - const testId = uuidv4(); // ID to be assigned to a test - const testRunId = uuidv4(); // ID to be assigned to a testRun - - // Build a client through AAD - const client = AzureLoadTesting(endpoint, new DefaultAzureCredential()); - - // Patching a load test - const testCreationResult = await client.path("/tests/{testId}", testId).patch({ - contentType: "application/merge-patch+json", - body: { - displayName: displayName, - description: "", - loadTestConfiguration: { - engineInstances: 1, // number of engine instances to run test - }, - }, - }); - // Checking for error response - if (isUnexpected(testCreationResult)) { - throw testCreationResult.body.error; - } - - if (testCreationResult.body.testId === undefined) - throw new Error("Test ID returned as undefined."); - - // Patching the test run - const testRunCreationResult = await client.path("/test-runs/{testRunId}", testRunId).patch({ - contentType: "application/merge-patch+json", - body: { - testId: testId, - displayName: displayName, - virtualUsers: 10, - }, - }); - - if (isUnexpected(testRunCreationResult)) { - throw testRunCreationResult.body.error; - } - - if (testRunCreationResult.body.testRunId === undefined) - throw new Error("Test Run ID returned as undefined."); - - // Checking the test run status - const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms)); - - sleep(30000); - - let stopTestRunResult = await client.path("/test-runs/{testRunId}:stop", testRunId).post(); - - if (isUnexpected(stopTestRunResult)) { - throw stopTestRunResult.body.error; - } -} -main().catch(console.error); diff --git a/sdk/loadtesting/load-testing-rest/samples/v1-beta/typescript/tsconfig.json b/sdk/loadtesting/load-testing-rest/samples/v1-beta/typescript/tsconfig.json deleted file mode 100644 index 984eed535aa8..000000000000 --- a/sdk/loadtesting/load-testing-rest/samples/v1-beta/typescript/tsconfig.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2020", - "module": "commonjs", - "moduleResolution": "node", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "strict": true, - "alwaysStrict": true, - "outDir": "dist", - "rootDir": "src" - }, - "include": [ - "src/**/*.ts" - ] -} diff --git a/sdk/loadtesting/load-testing-rest/samples/v1/javascript/README.md b/sdk/loadtesting/load-testing-rest/samples/v1/javascript/README.md deleted file mode 100644 index e318e04f9e32..000000000000 --- a/sdk/loadtesting/load-testing-rest/samples/v1/javascript/README.md +++ /dev/null @@ -1,68 +0,0 @@ ---- -page_type: sample -languages: - - javascript -products: - - azure -urlFragment: load-testing-javascript ---- - -# Azure Load Testing rest client library samples for JavaScript - -These sample programs show how to use the JavaScript client libraries for Azure Load Testing rest in some common scenarios. - -| **File Name** | **Description** | -| ----------------------------------------------------------- | -------------------------- | -| [createAppComponent.js][createappcomponent] | creates and run a loadtest | -| [createOrUpdateTest.js][createorupdatetest] | creates and run a loadtest | -| [createTestRunAndGetMetrics.js][createtestrunandgetmetrics] | creates and run a loadtest | -| [fileUpload.js][fileupload] | creates and run a loadtest | - -## Prerequisites - -The sample programs are compatible with [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule). - -You need [an Azure subscription][freesub] and the following Azure resources to run these sample programs: - -- [Azure LoadTesting Service instance][createinstance_azureloadtestingserviceinstance] - -Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. - -Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. - -## Setup - -To run the samples using the published version of the package: - -1. Install the dependencies using `npm`: - -```bash -npm install -``` - -2. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. - -3. Run whichever samples you like (note that some samples may require additional setup, see the table above): - -```bash -node createAppComponent.js -``` - -Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): - -```bash -npx cross-env LOADTESTSERVICE_ENDPOINT="" SUBSCRIPTION_ID="" node createAppComponent.js -``` - -## Next Steps - -Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. - -[createappcomponent]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/load-testing-rest/samples/v1/javascript/createAppComponent.js -[createorupdatetest]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/load-testing-rest/samples/v1/javascript/createOrUpdateTest.js -[createtestrunandgetmetrics]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/load-testing-rest/samples/v1/javascript/createTestRunAndGetMetrics.js -[fileupload]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/load-testing-rest/samples/v1/javascript/fileUpload.js -[apiref]: https://docs.microsoft.com/javascript/api/@azure-rest/load-testing -[freesub]: https://azure.microsoft.com/free/ -[createinstance_azureloadtestingserviceinstance]: https://learn.microsoft.com/azure/load-testing/ -[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/loadtesting/load-testing-rest/README.md diff --git a/sdk/loadtesting/load-testing-rest/samples/v1/javascript/createAppComponent.js b/sdk/loadtesting/load-testing-rest/samples/v1/javascript/createAppComponent.js deleted file mode 100644 index 2467377d9210..000000000000 --- a/sdk/loadtesting/load-testing-rest/samples/v1/javascript/createAppComponent.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to a) create a loadtest, b) upload a jmx file, c) create appcomponent, d) run test and e) get test status - * - * @summary creates and run a loadtest - */ - -const AzureLoadTesting = require("@azure-rest/load-testing").default, - { isUnexpected } = require("@azure-rest/load-testing"); -const { DefaultAzureCredential } = require("@azure/identity"); -const { v4: uuidv4 } = require("uuid"); - -async function main() { - const endpoint = process.env["LOADTESTSERVICE_ENDPOINT"] || ""; - const displayName = "some-load-test"; - const testId = uuidv4(); // ID to be assigned to a test - const SUBSCRIPTION_ID = process.env["SUBSCRIPTION_ID"] || ""; - - // Build a client through AAD - const client = AzureLoadTesting(endpoint, new DefaultAzureCredential()); - - // Creating a load test - const testCreationResult = await client.path("/tests/{testId}", testId).patch({ - contentType: "application/merge-patch+json", - body: { - displayName: displayName, - description: "", - loadTestConfiguration: { - engineInstances: 1, // number of engine instances to run test - }, - }, - }); - // Checking for error response - if (isUnexpected(testCreationResult)) { - throw testCreationResult.body.error; - } - - if (testCreationResult.body.testId === undefined) - throw new Error("Test ID returned as undefined."); - - const appComponentCreationResult = await client - .path("/tests/{testId}/app-components", testId) - .patch({ - contentType: "application/merge-patch+json", - body: { - testId: testCreationResult.body.testId, - components: { - "/subscriptions/{SUBSCRIPTION_ID}/resourceGroups/App-Service-Sample-Demo-rg/providers/Microsoft.Web/sites/App-Service-Sample-Demo": - { - resourceId: - "/subscriptions/{SUBSCRIPTION_ID}/resourceGroups/App-Service-Sample-Demo-rg/providers/Microsoft.Web/sites/App-Service-Sample-Demo", - resourceName: "App-Service-Sample-Demo", - resourceType: "Microsoft.Web/sites", - subscriptionId: SUBSCRIPTION_ID, - }, - }, - }, - }); - - if (isUnexpected(appComponentCreationResult)) { - throw appComponentCreationResult.body.error; - } -} - -main().catch(console.error); diff --git a/sdk/loadtesting/load-testing-rest/samples/v1/javascript/createOrUpdateTest.js b/sdk/loadtesting/load-testing-rest/samples/v1/javascript/createOrUpdateTest.js deleted file mode 100644 index db99089bffa0..000000000000 --- a/sdk/loadtesting/load-testing-rest/samples/v1/javascript/createOrUpdateTest.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to a) create a loadtest, b) upload a jmx file, c) create appcomponent, d) run test and e) get test status - * - * @summary creates and run a loadtest - */ - -const AzureLoadTesting /*, { isUnexpected }*/ = require("@azure-rest/load-testing").default; -const { DefaultAzureCredential } = require("@azure/identity"); -const { v4: uuidv4 } = require("uuid"); - -async function main() { - const endpoint = process.env["LOADTESTSERVICE_ENDPOINT"] || ""; - const displayName = "some-load-test"; - const testId = uuidv4(); // ID to be assigned to a test - - // Build a client through AAD - const client = AzureLoadTesting(endpoint, new DefaultAzureCredential()); - - // Creating the Load test - await client.path("/tests/{testId}", testId).patch({ - contentType: "application/merge-patch+json", - body: { - displayName: displayName, - description: "", - loadTestConfiguration: { - engineInstances: 1, // number of engine instances to run test - }, - }, - }); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/load-testing-rest/samples/v1/javascript/createTestRunAndGetMetrics.js b/sdk/loadtesting/load-testing-rest/samples/v1/javascript/createTestRunAndGetMetrics.js deleted file mode 100644 index 1539a1481460..000000000000 --- a/sdk/loadtesting/load-testing-rest/samples/v1/javascript/createTestRunAndGetMetrics.js +++ /dev/null @@ -1,62 +0,0 @@ -/** - * This sample demonstrates how to run a test and get test status - * - * @summary creates and run a loadtest - */ - -const AzureLoadTesting = require("@azure-rest/load-testing").default, - { isUnexpected } = require("@azure-rest/load-testing"); -const { DefaultAzureCredential } = require("@azure/identity"); -const { v4: uuidv4 } = require("uuid"); - -async function main() { - const endpoint = process.env["LOADTESTSERVICE_ENDPOINT"] || ""; - const displayName = "some-load-test"; - const testId = uuidv4(); // ID to be assigned to a test - const testRunId = uuidv4(); // ID to be assigned to a testRun - - // Build a client through AAD - const client = AzureLoadTesting(endpoint, new DefaultAzureCredential()); - - // Creating the test run - const testRunCreationResult = await client.path("/test-runs/{testRunId}", testRunId).patch({ - contentType: "application/merge-patch+json", - body: { - testId: testId, - displayName: displayName, - virtualUsers: 10, - }, - }); - - if (isUnexpected(testRunCreationResult)) { - throw testRunCreationResult.body.error; - } - - if (testRunCreationResult.body.testRunId === undefined) - throw new Error("Test Run ID returned as undefined."); - - // Checking the test run status and printing metrics - var testStatus = null; - var getTestRunResult = null; - const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); - - //wait for terminal state - while ( - testStatus == null || - (testStatus != "DONE" && testStatus != "CANCELLED" && testStatus != "FAILED") - ) { - getTestRunResult = await client - .path("/test-runs/{testRunId}", testRunCreationResult.body.testRunId) - .get(); - if (isUnexpected(getTestRunResult)) { - throw getTestRunResult.body.error; - } - testStatus = getTestRunResult.body.status; - - //Check test status after every 5 seconds - sleep(5000); - } - - console.log(getTestRunResult); -} -main().catch(console.error); diff --git a/sdk/loadtesting/load-testing-rest/samples/v1/javascript/fileUpload.js b/sdk/loadtesting/load-testing-rest/samples/v1/javascript/fileUpload.js deleted file mode 100644 index b7b61697beb6..000000000000 --- a/sdk/loadtesting/load-testing-rest/samples/v1/javascript/fileUpload.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to a) create a loadtest, b) upload a jmx file, c) create appcomponent, d) run test and e) get test status - * - * @summary creates and run a loadtest - */ - -const AzureLoadTesting = require("@azure-rest/load-testing").default, - { isUnexpected } = require("@azure-rest/load-testing"); -const { DefaultAzureCredential } = require("@azure/identity"); -const { createReadStream } = require("fs"); -const { v4: uuidv4 } = require("uuid"); - -const readStream = createReadStream("./sample.jmx"); - -async function main() { - const endpoint = process.env["LOADTESTSERVICE_ENDPOINT"] || ""; - const displayName = "some-load-test"; - const testId = uuidv4(); // ID to be assigned to a test - const fileId = uuidv4(); // ID to be assigned to the file being uploaded - - // Build a client through AAD - const client = AzureLoadTesting(endpoint, new DefaultAzureCredential()); - - // Creating a load test - const testCreationResult = await client.path("/tests/{testId}", testId).patch({ - contentType: "application/merge-patch+json", - body: { - displayName: displayName, - description: "", - loadTestConfiguration: { - engineInstances: 1, // number of engine instances to run test - }, - }, - }); - // Checking for error response - if (isUnexpected(testCreationResult)) { - throw testCreationResult.body.error; - } - - if (testCreationResult.body.testId === undefined) - throw new Error("Test ID returned as undefined."); - - // Uploading .jmx file to a test - const fileUploadResult = await client - .path("/tests/{testId}/files/{fileName}", testCreationResult.body.testId, fileId) - .put({ - contentType: "application/octet-stream", - body: readStream, - }); - - if (isUnexpected(fileUploadResult)) { - throw fileUploadResult.body.error; - } -} - -main().catch(console.error); diff --git a/sdk/loadtesting/load-testing-rest/samples/v1/javascript/package.json b/sdk/loadtesting/load-testing-rest/samples/v1/javascript/package.json deleted file mode 100644 index cd7a01bd653a..000000000000 --- a/sdk/loadtesting/load-testing-rest/samples/v1/javascript/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "@azure-samples/load-testing-js", - "private": true, - "version": "1.0.0", - "description": "Azure Load Testing rest client library samples for JavaScript", - "engines": { - "node": ">=18.0.0" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/Azure/azure-sdk-for-js.git", - "directory": "sdk/loadtesting/load-testing-rest" - }, - "keywords": [ - "node", - "azure", - "cloud", - "typescript", - "browser", - "isomorphic" - ], - "author": "Microsoft Corporation", - "license": "MIT", - "bugs": { - "url": "https://github.com/Azure/azure-sdk-for-js/issues" - }, - "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/loadtesting/load-testing-rest", - "dependencies": { - "@azure-rest/load-testing": "latest", - "dotenv": "latest", - "@azure/identity": "^4.2.1", - "uuid": "^9.0.0" - } -} diff --git a/sdk/loadtesting/load-testing-rest/samples/v1/javascript/sample.env b/sdk/loadtesting/load-testing-rest/samples/v1/javascript/sample.env deleted file mode 100644 index 672847a3fea0..000000000000 --- a/sdk/loadtesting/load-testing-rest/samples/v1/javascript/sample.env +++ /dev/null @@ -1,4 +0,0 @@ -# App registration secret for AAD authentication -AZURE_CLIENT_SECRET= -AZURE_CLIENT_ID= -AZURE_TENANT_ID= \ No newline at end of file diff --git a/sdk/loadtesting/load-testing-rest/samples/v1/typescript/README.md b/sdk/loadtesting/load-testing-rest/samples/v1/typescript/README.md deleted file mode 100644 index 0c7fb723950f..000000000000 --- a/sdk/loadtesting/load-testing-rest/samples/v1/typescript/README.md +++ /dev/null @@ -1,81 +0,0 @@ ---- -page_type: sample -languages: - - typescript -products: - - azure -urlFragment: load-testing-typescript ---- - -# Azure Load Testing rest client library samples for TypeScript - -These sample programs show how to use the TypeScript client libraries for Azure Load Testing rest in some common scenarios. - -| **File Name** | **Description** | -| ----------------------------------------------------------- | -------------------------- | -| [createAppComponent.ts][createappcomponent] | creates and run a loadtest | -| [createOrUpdateTest.ts][createorupdatetest] | creates and run a loadtest | -| [createTestRunAndGetMetrics.ts][createtestrunandgetmetrics] | creates and run a loadtest | -| [fileUpload.ts][fileupload] | creates and run a loadtest | - -## Prerequisites - -The sample programs are compatible with [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule). - -Before running the samples in Node, they must be compiled to JavaScript using the TypeScript compiler. For more information on TypeScript, see the [TypeScript documentation][typescript]. Install the TypeScript compiler using: - -```bash -npm install -g typescript -``` - -You need [an Azure subscription][freesub] and the following Azure resources to run these sample programs: - -- [Azure LoadTesting Service instance][createinstance_azureloadtestingserviceinstance] - -Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. - -Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. - -## Setup - -To run the samples using the published version of the package: - -1. Install the dependencies using `npm`: - -```bash -npm install -``` - -2. Compile the samples: - -```bash -npm run build -``` - -3. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. - -4. Run whichever samples you like (note that some samples may require additional setup, see the table above): - -```bash -node dist/createAppComponent.js -``` - -Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): - -```bash -npx cross-env LOADTESTSERVICE_ENDPOINT="" SUBSCRIPTION_ID="" node dist/createAppComponent.js -``` - -## Next Steps - -Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. - -[createappcomponent]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/load-testing-rest/samples/v1/typescript/src/createAppComponent.ts -[createorupdatetest]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/load-testing-rest/samples/v1/typescript/src/createOrUpdateTest.ts -[createtestrunandgetmetrics]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/load-testing-rest/samples/v1/typescript/src/createTestRunAndGetMetrics.ts -[fileupload]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/loadtesting/load-testing-rest/samples/v1/typescript/src/fileUpload.ts -[apiref]: https://docs.microsoft.com/javascript/api/@azure-rest/load-testing -[freesub]: https://azure.microsoft.com/free/ -[createinstance_azureloadtestingserviceinstance]: https://learn.microsoft.com/azure/load-testing/ -[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/loadtesting/load-testing-rest/README.md -[typescript]: https://www.typescriptlang.org/docs/home.html diff --git a/sdk/loadtesting/load-testing-rest/samples/v1/typescript/package.json b/sdk/loadtesting/load-testing-rest/samples/v1/typescript/package.json deleted file mode 100644 index 8fe4eaa2e944..000000000000 --- a/sdk/loadtesting/load-testing-rest/samples/v1/typescript/package.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "name": "@azure-samples/load-testing-ts", - "private": true, - "version": "1.0.0", - "description": "Azure Load Testing rest client library samples for TypeScript", - "engines": { - "node": ">=18.0.0" - }, - "scripts": { - "build": "tsc", - "prebuild": "rimraf dist/" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/Azure/azure-sdk-for-js.git", - "directory": "sdk/loadtesting/load-testing-rest" - }, - "keywords": [ - "node", - "azure", - "cloud", - "typescript", - "browser", - "isomorphic" - ], - "author": "Microsoft Corporation", - "license": "MIT", - "bugs": { - "url": "https://github.com/Azure/azure-sdk-for-js/issues" - }, - "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/loadtesting/load-testing-rest", - "dependencies": { - "@azure-rest/load-testing": "latest", - "dotenv": "latest", - "@azure/identity": "^4.2.1", - "uuid": "^9.0.0" - }, - "devDependencies": { - "@types/uuid": "^8.3.4", - "@types/node": "^18.0.0", - "typescript": "~5.6.2", - "rimraf": "latest" - } -} diff --git a/sdk/loadtesting/load-testing-rest/samples/v1/typescript/sample.env b/sdk/loadtesting/load-testing-rest/samples/v1/typescript/sample.env deleted file mode 100644 index 672847a3fea0..000000000000 --- a/sdk/loadtesting/load-testing-rest/samples/v1/typescript/sample.env +++ /dev/null @@ -1,4 +0,0 @@ -# App registration secret for AAD authentication -AZURE_CLIENT_SECRET= -AZURE_CLIENT_ID= -AZURE_TENANT_ID= \ No newline at end of file diff --git a/sdk/loadtesting/load-testing-rest/samples/v1/typescript/src/createAppComponent.ts b/sdk/loadtesting/load-testing-rest/samples/v1/typescript/src/createAppComponent.ts deleted file mode 100644 index 6cea36d3d224..000000000000 --- a/sdk/loadtesting/load-testing-rest/samples/v1/typescript/src/createAppComponent.ts +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to a) create a loadtest, b) upload a jmx file, c) create appcomponent, d) run test and e) get test status - * - * @summary creates and run a loadtest - */ - -import AzureLoadTesting, { isUnexpected } from "@azure-rest/load-testing"; -import { DefaultAzureCredential } from "@azure/identity"; -import { v4 as uuidv4 } from "uuid"; - -async function main() { - const endpoint = process.env["LOADTESTSERVICE_ENDPOINT"] || ""; - const displayName = "some-load-test"; - const testId = uuidv4(); // ID to be assigned to a test - const SUBSCRIPTION_ID = process.env["SUBSCRIPTION_ID"] || ""; - - // Build a client through AAD - const client = AzureLoadTesting(endpoint, new DefaultAzureCredential()); - - // Creating a load test - const testCreationResult = await client.path("/tests/{testId}", testId).patch({ - contentType: "application/merge-patch+json", - body: { - displayName: displayName, - description: "", - loadTestConfiguration: { - engineInstances: 1, // number of engine instances to run test - }, - }, - }); - // Checking for error response - if (isUnexpected(testCreationResult)) { - throw testCreationResult.body.error; - } - - if (testCreationResult.body.testId === undefined) - throw new Error("Test ID returned as undefined."); - - const appComponentCreationResult = await client - .path("/tests/{testId}/app-components", testId) - .patch({ - contentType: "application/merge-patch+json", - body: { - testId: testCreationResult.body.testId, - components: { - "/subscriptions/{SUBSCRIPTION_ID}/resourceGroups/App-Service-Sample-Demo-rg/providers/Microsoft.Web/sites/App-Service-Sample-Demo": { - resourceId: - "/subscriptions/{SUBSCRIPTION_ID}/resourceGroups/App-Service-Sample-Demo-rg/providers/Microsoft.Web/sites/App-Service-Sample-Demo", - resourceName: "App-Service-Sample-Demo", - resourceType: "Microsoft.Web/sites", - subscriptionId: SUBSCRIPTION_ID, - }, - }, - }, - }); - - if (isUnexpected(appComponentCreationResult)) { - throw appComponentCreationResult.body.error; - } -} - -main().catch(console.error); diff --git a/sdk/loadtesting/load-testing-rest/samples/v1/typescript/src/createOrUpdateTest.ts b/sdk/loadtesting/load-testing-rest/samples/v1/typescript/src/createOrUpdateTest.ts deleted file mode 100644 index 62f47df27e77..000000000000 --- a/sdk/loadtesting/load-testing-rest/samples/v1/typescript/src/createOrUpdateTest.ts +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to a) create a loadtest, b) upload a jmx file, c) create appcomponent, d) run test and e) get test status - * - * @summary creates and run a loadtest - */ - -import AzureLoadTesting /*, { isUnexpected }*/ from "@azure-rest/load-testing"; -import { DefaultAzureCredential } from "@azure/identity"; -import { v4 as uuidv4 } from "uuid"; - -async function main() { - const endpoint = process.env["LOADTESTSERVICE_ENDPOINT"] || ""; - const displayName = "some-load-test"; - const testId = uuidv4(); // ID to be assigned to a test - - // Build a client through AAD - const client = AzureLoadTesting(endpoint, new DefaultAzureCredential()); - - // Creating the Load test - await client.path("/tests/{testId}", testId).patch({ - contentType: "application/merge-patch+json", - body: { - displayName: displayName, - description: "", - loadTestConfiguration: { - engineInstances: 1, // number of engine instances to run test - }, - }, - }); -} - -main().catch(console.error); diff --git a/sdk/loadtesting/load-testing-rest/samples/v1/typescript/src/createTestRunAndGetMetrics.ts b/sdk/loadtesting/load-testing-rest/samples/v1/typescript/src/createTestRunAndGetMetrics.ts deleted file mode 100644 index 23592802ebb5..000000000000 --- a/sdk/loadtesting/load-testing-rest/samples/v1/typescript/src/createTestRunAndGetMetrics.ts +++ /dev/null @@ -1,61 +0,0 @@ -/** - * This sample demonstrates how to run a test and get test status - * - * @summary creates and run a loadtest - */ - -import AzureLoadTesting, { isUnexpected } from "@azure-rest/load-testing"; -import { DefaultAzureCredential } from "@azure/identity"; -import { v4 as uuidv4 } from "uuid"; - -async function main() { - const endpoint = process.env["LOADTESTSERVICE_ENDPOINT"] || ""; - const displayName = "some-load-test"; - const testId = uuidv4(); // ID to be assigned to a test - const testRunId = uuidv4(); // ID to be assigned to a testRun - - // Build a client through AAD - const client = AzureLoadTesting(endpoint, new DefaultAzureCredential()); - - // Creating the test run - const testRunCreationResult = await client.path("/test-runs/{testRunId}", testRunId).patch({ - contentType: "application/merge-patch+json", - body: { - testId: testId, - displayName: displayName, - virtualUsers: 10, - }, - }); - - if (isUnexpected(testRunCreationResult)) { - throw testRunCreationResult.body.error; - } - - if (testRunCreationResult.body.testRunId === undefined) - throw new Error("Test Run ID returned as undefined."); - - // Checking the test run status and printing metrics - var testStatus = null; - var getTestRunResult = null; - const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms)); - - //wait for terminal state - while ( - testStatus == null || - (testStatus != "DONE" && testStatus != "CANCELLED" && testStatus != "FAILED") - ) { - getTestRunResult = await client - .path("/test-runs/{testRunId}", testRunCreationResult.body.testRunId) - .get(); - if (isUnexpected(getTestRunResult)) { - throw getTestRunResult.body.error; - } - testStatus = getTestRunResult.body.status; - - //Check test status after every 5 seconds - sleep(5000); - } - - console.log(getTestRunResult); -} -main().catch(console.error); diff --git a/sdk/loadtesting/load-testing-rest/samples/v1/typescript/src/fileUpload.ts b/sdk/loadtesting/load-testing-rest/samples/v1/typescript/src/fileUpload.ts deleted file mode 100644 index dafe8f132612..000000000000 --- a/sdk/loadtesting/load-testing-rest/samples/v1/typescript/src/fileUpload.ts +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to a) create a loadtest, b) upload a jmx file, c) create appcomponent, d) run test and e) get test status - * - * @summary creates and run a loadtest - */ - -import AzureLoadTesting, { isUnexpected } from "@azure-rest/load-testing"; -import { DefaultAzureCredential } from "@azure/identity"; -import { createReadStream } from "fs"; -import { v4 as uuidv4 } from "uuid"; - -const readStream = createReadStream("./sample.jmx"); - -async function main() { - const endpoint = process.env["LOADTESTSERVICE_ENDPOINT"] || ""; - const displayName = "some-load-test"; - const testId = uuidv4(); // ID to be assigned to a test - const fileId = uuidv4(); // ID to be assigned to the file being uploaded - - // Build a client through AAD - const client = AzureLoadTesting(endpoint, new DefaultAzureCredential()); - - // Creating a load test - const testCreationResult = await client.path("/tests/{testId}", testId).patch({ - contentType: "application/merge-patch+json", - body: { - displayName: displayName, - description: "", - loadTestConfiguration: { - engineInstances: 1, // number of engine instances to run test - }, - }, - }); - // Checking for error response - if (isUnexpected(testCreationResult)) { - throw testCreationResult.body.error; - } - - if (testCreationResult.body.testId === undefined) - throw new Error("Test ID returned as undefined."); - - // Uploading .jmx file to a test - const fileUploadResult = await client - .path("/tests/{testId}/files/{fileName}", testCreationResult.body.testId, fileId) - .put({ - contentType: "application/octet-stream", - body: readStream, - }); - - if (isUnexpected(fileUploadResult)) { - throw fileUploadResult.body.error; - } -} - -main().catch(console.error); diff --git a/sdk/loadtesting/load-testing-rest/samples/v1/typescript/tsconfig.json b/sdk/loadtesting/load-testing-rest/samples/v1/typescript/tsconfig.json deleted file mode 100644 index ad5ff9a19d36..000000000000 --- a/sdk/loadtesting/load-testing-rest/samples/v1/typescript/tsconfig.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2018", - "module": "commonjs", - "moduleResolution": "node", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "strict": true, - "alwaysStrict": true, - "outDir": "dist", - "rootDir": "src" - }, - "include": [ - "src/**/*.ts" - ] -} diff --git a/sdk/loadtesting/load-testing-rest/src/azureLoadTesting.ts b/sdk/loadtesting/load-testing-rest/src/azureLoadTesting.ts index 7fddb3e997fe..4afa60a2d340 100644 --- a/sdk/loadtesting/load-testing-rest/src/azureLoadTesting.ts +++ b/sdk/loadtesting/load-testing-rest/src/azureLoadTesting.ts @@ -2,28 +2,32 @@ // Licensed under the MIT License. import { getClient, ClientOptions } from "@azure-rest/core-client"; +import { logger } from "./logger.js"; import { TokenCredential } from "@azure/core-auth"; -import { AzureLoadTestingClient } from "./clientDefinitions"; +import { AzureLoadTestingClient } from "./clientDefinitions.js"; + +/** The optional parameters for the client */ +export interface AzureLoadTestingClientOptions extends ClientOptions { + /** The api version option of the client */ + apiVersion?: string; +} /** - * Initialize a new instance of the class AzureLoadTestingClient class. - * @param Endpoint type: string URL to perform data plane API operations on the resource. - * @param credentials type: TokenCredential + * Initialize a new instance of `AzureLoadTestingClient` + * @param endpointParam - A sequence of textual characters. + * @param credentials - uniquely identify client credential + * @param options - the parameter for all optional parameters */ export default function createClient( - Endpoint: string, + endpointParam: string, credentials: TokenCredential, - options: ClientOptions = {}, + { + apiVersion = "2024-05-01-preview", + ...options + }: AzureLoadTestingClientOptions = {}, ): AzureLoadTestingClient { - const baseUrl = options.baseUrl ?? `https://${Endpoint}`; - options.apiVersion = options.apiVersion ?? "2022-11-01"; - options = { - ...options, - credentials: { - scopes: ["https://cnt-prod.loadtesting.azure.com/.default"], - }, - }; - + const endpointUrl = + options.endpoint ?? options.baseUrl ?? `https://${endpointParam}`; const userAgentInfo = `azsdk-js-load-testing-rest/1.0.1`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix @@ -34,9 +38,37 @@ export default function createClient( userAgentOptions: { userAgentPrefix, }, + loggingOptions: { + logger: options.loggingOptions?.logger ?? logger.info, + }, + credentials: { + scopes: options.credentials?.scopes ?? [ + "https://cnt-prod.loadtesting.azure.com/.default", + ], + }, }; + const client = getClient( + endpointUrl, + credentials, + options, + ) as AzureLoadTestingClient; + + client.pipeline.removePolicy({ name: "ApiVersionPolicy" }); + client.pipeline.addPolicy({ + name: "ClientApiVersionPolicy", + sendRequest: (req, next) => { + // Use the apiVersion defined in request url directly + // Append one if there is no apiVersion and we have one at client options + const url = new URL(req.url); + if (!url.searchParams.get("api-version") && apiVersion) { + req.url = `${req.url}${ + Array.from(url.searchParams.keys()).length > 0 ? "&" : "?" + }api-version=${apiVersion}`; + } - const client = getClient(baseUrl, credentials, options) as AzureLoadTestingClient; + return next(req); + }, + }); return client; } diff --git a/sdk/loadtesting/load-testing-rest/src/clientDefinitions.ts b/sdk/loadtesting/load-testing-rest/src/clientDefinitions.ts index 512e9b092b49..999985456127 100644 --- a/sdk/loadtesting/load-testing-rest/src/clientDefinitions.ts +++ b/sdk/loadtesting/load-testing-rest/src/clientDefinitions.ts @@ -2,337 +2,540 @@ // Licensed under the MIT License. import { - TestCreateOrUpdateParameters, - TestDeleteParameters, - TestGetParameters, - TestListParameters, - TestUploadFileParameters, - TestGetFileParameters, - TestDeleteFileParameters, - TestListFilesParameters, - TestCreateOrUpdateAppComponentsParameters, - TestListAppComponentsParameters, - TestCreateOrUpdateServerMetricsConfigParameters, - TestListServerMetricsConfigParameters, - TestRunDeleteParameters, - TestRunCreateOrUpdateParameters, - TestRunGetParameters, - TestRunGetFileParameters, - TestRunListParameters, - TestRunStopParameters, - TestRunListMetricNamespacesParameters, - TestRunListMetricDefinitionsParameters, - TestRunListMetricsParameters, - TestRunListMetricDimensionValuesParameters, - TestRunCreateOrUpdateAppComponentsParameters, - TestRunListAppComponentsParameters, - TestRunCreateOrUpdateServerMetricsConfigParameters, - TestRunListServerMetricsConfigParameters, -} from "./parameters"; + LoadTestAdministrationCreateOrUpdateTestParameters, + LoadTestAdministrationDeleteTestParameters, + LoadTestAdministrationGetTestParameters, + LoadTestAdministrationListTestsParameters, + LoadTestAdministrationUploadTestFileParameters, + LoadTestAdministrationGetTestFileParameters, + LoadTestAdministrationDeleteTestFileParameters, + LoadTestAdministrationListTestFilesParameters, + LoadTestAdministrationCreateOrUpdateAppComponentsParameters, + LoadTestAdministrationGetAppComponentsParameters, + LoadTestAdministrationCreateOrUpdateServerMetricsConfigParameters, + LoadTestAdministrationGetServerMetricsConfigParameters, + LoadTestRunGetTestRunParameters, + LoadTestRunCreateOrUpdateTestRunParameters, + LoadTestRunDeleteTestRunParameters, + LoadTestRunListTestRunsParameters, + LoadTestRunGetTestRunFileParameters, + LoadTestRunStopTestRunParameters, + LoadTestRunListMetricNamespacesParameters, + LoadTestRunListMetricDefinitionsParameters, + LoadTestRunListMetricsParameters, + LoadTestRunListMetricDimensionValuesParameters, + LoadTestRunCreateOrUpdateAppComponentsParameters, + LoadTestRunGetAppComponentsParameters, + LoadTestRunCreateOrUpdateServerMetricsConfigParameters, + LoadTestRunGetServerMetricsConfigParameters, + TestProfileAdministrationCreateOrUpdateTestProfileParameters, + TestProfileAdministrationDeleteTestProfileParameters, + TestProfileAdministrationGetTestProfileParameters, + TestProfileAdministrationListTestProfilesParameters, + TestProfileRunAdministrationGetTestProfileRunParameters, + TestProfileRunAdministrationCreateOrUpdateTestProfileRunParameters, + TestProfileRunAdministrationDeleteTestProfileRunParameters, + TestProfileRunAdministrationStopTestProfileRunParameters, + TestProfileRunAdministrationListTestProfileRunsParameters, +} from "./parameters.js"; import { - TestCreateOrUpdate200Response, - TestCreateOrUpdate201Response, - TestCreateOrUpdateDefaultResponse, - TestDelete204Response, - TestDeleteDefaultResponse, - TestGet200Response, - TestGetDefaultResponse, - TestList200Response, - TestListDefaultResponse, - TestUploadFile201Response, - TestUploadFileDefaultResponse, - TestGetFile200Response, - TestGetFileDefaultResponse, - TestDeleteFile204Response, - TestDeleteFileDefaultResponse, - TestListFiles200Response, - TestListFilesDefaultResponse, - TestCreateOrUpdateAppComponents200Response, - TestCreateOrUpdateAppComponents201Response, - TestCreateOrUpdateAppComponentsDefaultResponse, - TestListAppComponents200Response, - TestListAppComponentsDefaultResponse, - TestCreateOrUpdateServerMetricsConfig200Response, - TestCreateOrUpdateServerMetricsConfig201Response, - TestCreateOrUpdateServerMetricsConfigDefaultResponse, - TestListServerMetricsConfig200Response, - TestListServerMetricsConfigDefaultResponse, - TestRunDelete204Response, - TestRunDeleteDefaultResponse, - TestRunCreateOrUpdate200Response, - TestRunCreateOrUpdate201Response, - TestRunCreateOrUpdateDefaultResponse, - TestRunGet200Response, - TestRunGetDefaultResponse, - TestRunGetFile200Response, - TestRunGetFileDefaultResponse, - TestRunList200Response, - TestRunListDefaultResponse, - TestRunStop200Response, - TestRunStopDefaultResponse, - TestRunListMetricNamespaces200Response, - TestRunListMetricNamespacesDefaultResponse, - TestRunListMetricDefinitions200Response, - TestRunListMetricDefinitionsDefaultResponse, - TestRunListMetrics200Response, - TestRunListMetricsDefaultResponse, - TestRunListMetricDimensionValues200Response, - TestRunListMetricDimensionValuesDefaultResponse, - TestRunCreateOrUpdateAppComponents200Response, - TestRunCreateOrUpdateAppComponents201Response, - TestRunCreateOrUpdateAppComponentsDefaultResponse, - TestRunListAppComponents200Response, - TestRunListAppComponentsDefaultResponse, - TestRunCreateOrUpdateServerMetricsConfig200Response, - TestRunCreateOrUpdateServerMetricsConfig201Response, - TestRunCreateOrUpdateServerMetricsConfigDefaultResponse, - TestRunListServerMetricsConfig200Response, - TestRunListServerMetricsConfigDefaultResponse, -} from "./responses"; + LoadTestAdministrationCreateOrUpdateTest200Response, + LoadTestAdministrationCreateOrUpdateTest201Response, + LoadTestAdministrationCreateOrUpdateTestDefaultResponse, + LoadTestAdministrationDeleteTest204Response, + LoadTestAdministrationDeleteTestDefaultResponse, + LoadTestAdministrationGetTest200Response, + LoadTestAdministrationGetTestDefaultResponse, + LoadTestAdministrationListTests200Response, + LoadTestAdministrationListTestsDefaultResponse, + LoadTestAdministrationUploadTestFile201Response, + LoadTestAdministrationUploadTestFileDefaultResponse, + LoadTestAdministrationGetTestFile200Response, + LoadTestAdministrationGetTestFileDefaultResponse, + LoadTestAdministrationDeleteTestFile204Response, + LoadTestAdministrationDeleteTestFileDefaultResponse, + LoadTestAdministrationListTestFiles200Response, + LoadTestAdministrationListTestFilesDefaultResponse, + LoadTestAdministrationCreateOrUpdateAppComponents200Response, + LoadTestAdministrationCreateOrUpdateAppComponents201Response, + LoadTestAdministrationCreateOrUpdateAppComponentsDefaultResponse, + LoadTestAdministrationGetAppComponents200Response, + LoadTestAdministrationGetAppComponentsDefaultResponse, + LoadTestAdministrationCreateOrUpdateServerMetricsConfig200Response, + LoadTestAdministrationCreateOrUpdateServerMetricsConfig201Response, + LoadTestAdministrationCreateOrUpdateServerMetricsConfigDefaultResponse, + LoadTestAdministrationGetServerMetricsConfig200Response, + LoadTestAdministrationGetServerMetricsConfigDefaultResponse, + LoadTestRunGetTestRun200Response, + LoadTestRunGetTestRunDefaultResponse, + LoadTestRunCreateOrUpdateTestRun200Response, + LoadTestRunCreateOrUpdateTestRun201Response, + LoadTestRunCreateOrUpdateTestRunDefaultResponse, + LoadTestRunDeleteTestRun204Response, + LoadTestRunDeleteTestRunDefaultResponse, + LoadTestRunListTestRuns200Response, + LoadTestRunListTestRunsDefaultResponse, + LoadTestRunGetTestRunFile200Response, + LoadTestRunGetTestRunFileDefaultResponse, + LoadTestRunStopTestRun200Response, + LoadTestRunStopTestRunDefaultResponse, + LoadTestRunListMetricNamespaces200Response, + LoadTestRunListMetricNamespacesDefaultResponse, + LoadTestRunListMetricDefinitions200Response, + LoadTestRunListMetricDefinitionsDefaultResponse, + LoadTestRunListMetrics200Response, + LoadTestRunListMetricsDefaultResponse, + LoadTestRunListMetricDimensionValues200Response, + LoadTestRunListMetricDimensionValuesDefaultResponse, + LoadTestRunCreateOrUpdateAppComponents200Response, + LoadTestRunCreateOrUpdateAppComponents201Response, + LoadTestRunCreateOrUpdateAppComponentsDefaultResponse, + LoadTestRunGetAppComponents200Response, + LoadTestRunGetAppComponentsDefaultResponse, + LoadTestRunCreateOrUpdateServerMetricsConfig200Response, + LoadTestRunCreateOrUpdateServerMetricsConfig201Response, + LoadTestRunCreateOrUpdateServerMetricsConfigDefaultResponse, + LoadTestRunGetServerMetricsConfig200Response, + LoadTestRunGetServerMetricsConfigDefaultResponse, + TestProfileAdministrationCreateOrUpdateTestProfile200Response, + TestProfileAdministrationCreateOrUpdateTestProfile201Response, + TestProfileAdministrationCreateOrUpdateTestProfileDefaultResponse, + TestProfileAdministrationDeleteTestProfile204Response, + TestProfileAdministrationDeleteTestProfileDefaultResponse, + TestProfileAdministrationGetTestProfile200Response, + TestProfileAdministrationGetTestProfileDefaultResponse, + TestProfileAdministrationListTestProfiles200Response, + TestProfileAdministrationListTestProfilesDefaultResponse, + TestProfileRunAdministrationGetTestProfileRun200Response, + TestProfileRunAdministrationGetTestProfileRunDefaultResponse, + TestProfileRunAdministrationCreateOrUpdateTestProfileRun200Response, + TestProfileRunAdministrationCreateOrUpdateTestProfileRun201Response, + TestProfileRunAdministrationCreateOrUpdateTestProfileRunDefaultResponse, + TestProfileRunAdministrationDeleteTestProfileRun204Response, + TestProfileRunAdministrationDeleteTestProfileRunDefaultResponse, + TestProfileRunAdministrationStopTestProfileRun200Response, + TestProfileRunAdministrationStopTestProfileRunDefaultResponse, + TestProfileRunAdministrationListTestProfileRuns200Response, + TestProfileRunAdministrationListTestProfileRunsDefaultResponse, +} from "./responses.js"; import { Client, StreamableMethod } from "@azure-rest/core-client"; -export interface TestCreateOrUpdate { - /** Create a new test or update an existing test. */ +export interface LoadTestAdministrationCreateOrUpdateTest { + /** Create a new test or update an existing test by providing the test Id. */ patch( - options: TestCreateOrUpdateParameters, + options: LoadTestAdministrationCreateOrUpdateTestParameters, ): StreamableMethod< - | TestCreateOrUpdate200Response - | TestCreateOrUpdate201Response - | TestCreateOrUpdateDefaultResponse + | LoadTestAdministrationCreateOrUpdateTest200Response + | LoadTestAdministrationCreateOrUpdateTest201Response + | LoadTestAdministrationCreateOrUpdateTestDefaultResponse >; - /** Delete a test by its name. */ + /** Delete a test by its test Id. */ delete( - options?: TestDeleteParameters, - ): StreamableMethod; - /** Get load test details by test name */ - get(options?: TestGetParameters): StreamableMethod; + options?: LoadTestAdministrationDeleteTestParameters, + ): StreamableMethod< + | LoadTestAdministrationDeleteTest204Response + | LoadTestAdministrationDeleteTestDefaultResponse + >; + /** Get load test details by test Id */ + get( + options?: LoadTestAdministrationGetTestParameters, + ): StreamableMethod< + | LoadTestAdministrationGetTest200Response + | LoadTestAdministrationGetTestDefaultResponse + >; } -export interface TestList { - /** Get all load tests by the fully qualified resource Id e.g subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. */ +export interface LoadTestAdministrationListTests { + /** + * Get all load tests by the fully qualified resource Id e.g + * subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + */ get( - options?: TestListParameters, - ): StreamableMethod; + options?: LoadTestAdministrationListTestsParameters, + ): StreamableMethod< + | LoadTestAdministrationListTests200Response + | LoadTestAdministrationListTestsDefaultResponse + >; } -export interface TestUploadFile { - /** Upload input file for a given test name. File size can't be more than 50 MB. Existing file with same name for the given test will be overwritten. File should be provided in the request body as application/octet-stream. */ +export interface LoadTestAdministrationUploadTestFile { + /** + * Upload input file for a given test Id. File size can't be more than 50 MB. + * Existing file with same name for the given test will be overwritten. File + * should be provided in the request body as application/octet-stream. + */ put( - options: TestUploadFileParameters, - ): StreamableMethod; - /** Get test file by the file name. */ + options: LoadTestAdministrationUploadTestFileParameters, + ): StreamableMethod< + | LoadTestAdministrationUploadTestFile201Response + | LoadTestAdministrationUploadTestFileDefaultResponse + >; + /** Get all the files that are associated with a test. */ get( - options?: TestGetFileParameters, - ): StreamableMethod; + options?: LoadTestAdministrationGetTestFileParameters, + ): StreamableMethod< + | LoadTestAdministrationGetTestFile200Response + | LoadTestAdministrationGetTestFileDefaultResponse + >; /** Delete file by the file name for a test */ delete( - options?: TestDeleteFileParameters, - ): StreamableMethod; + options?: LoadTestAdministrationDeleteTestFileParameters, + ): StreamableMethod< + | LoadTestAdministrationDeleteTestFile204Response + | LoadTestAdministrationDeleteTestFileDefaultResponse + >; } -export interface TestListFiles { +export interface LoadTestAdministrationListTestFiles { /** Get all test files. */ get( - options?: TestListFilesParameters, - ): StreamableMethod; + options?: LoadTestAdministrationListTestFilesParameters, + ): StreamableMethod< + | LoadTestAdministrationListTestFiles200Response + | LoadTestAdministrationListTestFilesDefaultResponse + >; } -export interface TestCreateOrUpdateAppComponents { - /** Associate an app component (collection of azure resources) to a test */ +export interface LoadTestAdministrationCreateOrUpdateAppComponents { + /** Add an app component to a test by providing the resource Id, name and type. */ patch( - options: TestCreateOrUpdateAppComponentsParameters, + options: LoadTestAdministrationCreateOrUpdateAppComponentsParameters, ): StreamableMethod< - | TestCreateOrUpdateAppComponents200Response - | TestCreateOrUpdateAppComponents201Response - | TestCreateOrUpdateAppComponentsDefaultResponse + | LoadTestAdministrationCreateOrUpdateAppComponents200Response + | LoadTestAdministrationCreateOrUpdateAppComponents201Response + | LoadTestAdministrationCreateOrUpdateAppComponentsDefaultResponse >; /** Get associated app component (collection of azure resources) for the given test. */ get( - options?: TestListAppComponentsParameters, - ): StreamableMethod; + options?: LoadTestAdministrationGetAppComponentsParameters, + ): StreamableMethod< + | LoadTestAdministrationGetAppComponents200Response + | LoadTestAdministrationGetAppComponentsDefaultResponse + >; } -export interface TestCreateOrUpdateServerMetricsConfig { +export interface LoadTestAdministrationCreateOrUpdateServerMetricsConfig { /** Configure server metrics for a test */ patch( - options: TestCreateOrUpdateServerMetricsConfigParameters, + options: LoadTestAdministrationCreateOrUpdateServerMetricsConfigParameters, ): StreamableMethod< - | TestCreateOrUpdateServerMetricsConfig200Response - | TestCreateOrUpdateServerMetricsConfig201Response - | TestCreateOrUpdateServerMetricsConfigDefaultResponse + | LoadTestAdministrationCreateOrUpdateServerMetricsConfig200Response + | LoadTestAdministrationCreateOrUpdateServerMetricsConfig201Response + | LoadTestAdministrationCreateOrUpdateServerMetricsConfigDefaultResponse >; /** List server metrics configuration for the given test. */ get( - options?: TestListServerMetricsConfigParameters, + options?: LoadTestAdministrationGetServerMetricsConfigParameters, ): StreamableMethod< - TestListServerMetricsConfig200Response | TestListServerMetricsConfigDefaultResponse + | LoadTestAdministrationGetServerMetricsConfig200Response + | LoadTestAdministrationGetServerMetricsConfigDefaultResponse >; } -export interface TestRunDelete { - /** Delete a test run by its name. */ - delete( - options?: TestRunDeleteParameters, - ): StreamableMethod; - /** Create and start a new test run with the given name. */ +export interface LoadTestRunGetTestRun { + /** Get test run details by test run Id. */ + get( + options?: LoadTestRunGetTestRunParameters, + ): StreamableMethod< + LoadTestRunGetTestRun200Response | LoadTestRunGetTestRunDefaultResponse + >; + /** Create and start a new test run with the given test run Id. */ patch( - options: TestRunCreateOrUpdateParameters, + options: LoadTestRunCreateOrUpdateTestRunParameters, ): StreamableMethod< - | TestRunCreateOrUpdate200Response - | TestRunCreateOrUpdate201Response - | TestRunCreateOrUpdateDefaultResponse + | LoadTestRunCreateOrUpdateTestRun200Response + | LoadTestRunCreateOrUpdateTestRun201Response + | LoadTestRunCreateOrUpdateTestRunDefaultResponse + >; + /** Delete an existing load test run by providing the testRunId. */ + delete( + options?: LoadTestRunDeleteTestRunParameters, + ): StreamableMethod< + | LoadTestRunDeleteTestRun204Response + | LoadTestRunDeleteTestRunDefaultResponse >; - /** Get test run details by name. */ - get( - options?: TestRunGetParameters, - ): StreamableMethod; } -export interface TestRunGetFile { - /** Get test run file by file name. */ +export interface LoadTestRunListTestRuns { + /** Get all test runs for the given filters. */ get( - options?: TestRunGetFileParameters, - ): StreamableMethod; + options?: LoadTestRunListTestRunsParameters, + ): StreamableMethod< + LoadTestRunListTestRuns200Response | LoadTestRunListTestRunsDefaultResponse + >; } -export interface TestRunList { - /** Get all test runs with given filters */ +export interface LoadTestRunGetTestRunFile { + /** Get test run file by file name. */ get( - options?: TestRunListParameters, - ): StreamableMethod; + options?: LoadTestRunGetTestRunFileParameters, + ): StreamableMethod< + | LoadTestRunGetTestRunFile200Response + | LoadTestRunGetTestRunFileDefaultResponse + >; } -export interface TestRunStop { - /** Stop test run by name. */ +export interface LoadTestRunStopTestRun { + /** Stop test run by test run Id. */ post( - options?: TestRunStopParameters, - ): StreamableMethod; + options?: LoadTestRunStopTestRunParameters, + ): StreamableMethod< + LoadTestRunStopTestRun200Response | LoadTestRunStopTestRunDefaultResponse + >; } -export interface TestRunListMetricNamespaces { +export interface LoadTestRunListMetricNamespaces { /** List the metric namespaces for a load test run. */ get( - options?: TestRunListMetricNamespacesParameters, + options?: LoadTestRunListMetricNamespacesParameters, ): StreamableMethod< - TestRunListMetricNamespaces200Response | TestRunListMetricNamespacesDefaultResponse + | LoadTestRunListMetricNamespaces200Response + | LoadTestRunListMetricNamespacesDefaultResponse >; } -export interface TestRunListMetricDefinitions { +export interface LoadTestRunListMetricDefinitions { /** List the metric definitions for a load test run. */ get( - options: TestRunListMetricDefinitionsParameters, + options: LoadTestRunListMetricDefinitionsParameters, ): StreamableMethod< - TestRunListMetricDefinitions200Response | TestRunListMetricDefinitionsDefaultResponse + | LoadTestRunListMetricDefinitions200Response + | LoadTestRunListMetricDefinitionsDefaultResponse >; } -export interface TestRunListMetrics { +export interface LoadTestRunListMetrics { /** List the metric values for a load test run. */ post( - options: TestRunListMetricsParameters, - ): StreamableMethod; + options: LoadTestRunListMetricsParameters, + ): StreamableMethod< + LoadTestRunListMetrics200Response | LoadTestRunListMetricsDefaultResponse + >; } -export interface TestRunListMetricDimensionValues { +export interface LoadTestRunListMetricDimensionValues { /** List the dimension values for the given metric dimension name. */ get( - options: TestRunListMetricDimensionValuesParameters, + options: LoadTestRunListMetricDimensionValuesParameters, ): StreamableMethod< - TestRunListMetricDimensionValues200Response | TestRunListMetricDimensionValuesDefaultResponse + | LoadTestRunListMetricDimensionValues200Response + | LoadTestRunListMetricDimensionValuesDefaultResponse >; } -export interface TestRunCreateOrUpdateAppComponents { - /** Associate an app component (collection of azure resources) to a test run */ +export interface LoadTestRunCreateOrUpdateAppComponents { + /** Add an app component to a test run by providing the resource Id, name and type. */ patch( - options: TestRunCreateOrUpdateAppComponentsParameters, + options: LoadTestRunCreateOrUpdateAppComponentsParameters, ): StreamableMethod< - | TestRunCreateOrUpdateAppComponents200Response - | TestRunCreateOrUpdateAppComponents201Response - | TestRunCreateOrUpdateAppComponentsDefaultResponse + | LoadTestRunCreateOrUpdateAppComponents200Response + | LoadTestRunCreateOrUpdateAppComponents201Response + | LoadTestRunCreateOrUpdateAppComponentsDefaultResponse >; - /** Get associated app component (collection of azure resources) for the given test run. */ + /** + * Get associated app component (collection of azure resources) for the given test + * run. + */ get( - options?: TestRunListAppComponentsParameters, + options?: LoadTestRunGetAppComponentsParameters, ): StreamableMethod< - TestRunListAppComponents200Response | TestRunListAppComponentsDefaultResponse + | LoadTestRunGetAppComponents200Response + | LoadTestRunGetAppComponentsDefaultResponse >; } -export interface TestRunCreateOrUpdateServerMetricsConfig { +export interface LoadTestRunCreateOrUpdateServerMetricsConfig { /** Configure server metrics for a test run */ patch( - options: TestRunCreateOrUpdateServerMetricsConfigParameters, + options: LoadTestRunCreateOrUpdateServerMetricsConfigParameters, + ): StreamableMethod< + | LoadTestRunCreateOrUpdateServerMetricsConfig200Response + | LoadTestRunCreateOrUpdateServerMetricsConfig201Response + | LoadTestRunCreateOrUpdateServerMetricsConfigDefaultResponse + >; + /** Get associated server metrics configuration for the given test run. */ + get( + options?: LoadTestRunGetServerMetricsConfigParameters, + ): StreamableMethod< + | LoadTestRunGetServerMetricsConfig200Response + | LoadTestRunGetServerMetricsConfigDefaultResponse + >; +} + +export interface TestProfileAdministrationCreateOrUpdateTestProfile { + /** Create a new test profile or update an existing test profile by providing the test profile Id. */ + patch( + options: TestProfileAdministrationCreateOrUpdateTestProfileParameters, + ): StreamableMethod< + | TestProfileAdministrationCreateOrUpdateTestProfile200Response + | TestProfileAdministrationCreateOrUpdateTestProfile201Response + | TestProfileAdministrationCreateOrUpdateTestProfileDefaultResponse + >; + /** Delete a test profile by its test profile Id. */ + delete( + options?: TestProfileAdministrationDeleteTestProfileParameters, + ): StreamableMethod< + | TestProfileAdministrationDeleteTestProfile204Response + | TestProfileAdministrationDeleteTestProfileDefaultResponse + >; + /** Get load test profile details by test profile Id. */ + get( + options?: TestProfileAdministrationGetTestProfileParameters, + ): StreamableMethod< + | TestProfileAdministrationGetTestProfile200Response + | TestProfileAdministrationGetTestProfileDefaultResponse + >; +} + +export interface TestProfileAdministrationListTestProfiles { + /** Get all test profiles for the given filters. */ + get( + options?: TestProfileAdministrationListTestProfilesParameters, + ): StreamableMethod< + | TestProfileAdministrationListTestProfiles200Response + | TestProfileAdministrationListTestProfilesDefaultResponse + >; +} + +export interface TestProfileRunAdministrationGetTestProfileRun { + /** Get test profile run details by test profile run Id. */ + get( + options?: TestProfileRunAdministrationGetTestProfileRunParameters, + ): StreamableMethod< + | TestProfileRunAdministrationGetTestProfileRun200Response + | TestProfileRunAdministrationGetTestProfileRunDefaultResponse + >; + /** Create and start a new test profile run with the given test profile run Id. */ + patch( + options: TestProfileRunAdministrationCreateOrUpdateTestProfileRunParameters, ): StreamableMethod< - | TestRunCreateOrUpdateServerMetricsConfig200Response - | TestRunCreateOrUpdateServerMetricsConfig201Response - | TestRunCreateOrUpdateServerMetricsConfigDefaultResponse + | TestProfileRunAdministrationCreateOrUpdateTestProfileRun200Response + | TestProfileRunAdministrationCreateOrUpdateTestProfileRun201Response + | TestProfileRunAdministrationCreateOrUpdateTestProfileRunDefaultResponse >; - /** List server metrics configuration for the given test run. */ + /** Delete an existing load test profile run by providing the test profile run Id. */ + delete( + options?: TestProfileRunAdministrationDeleteTestProfileRunParameters, + ): StreamableMethod< + | TestProfileRunAdministrationDeleteTestProfileRun204Response + | TestProfileRunAdministrationDeleteTestProfileRunDefaultResponse + >; +} + +export interface TestProfileRunAdministrationStopTestProfileRun { + /** Stop test profile run for the given test profile run Id. */ + post( + options?: TestProfileRunAdministrationStopTestProfileRunParameters, + ): StreamableMethod< + | TestProfileRunAdministrationStopTestProfileRun200Response + | TestProfileRunAdministrationStopTestProfileRunDefaultResponse + >; +} + +export interface TestProfileRunAdministrationListTestProfileRuns { + /** Get all test profile runs for the given filters. */ get( - options?: TestRunListServerMetricsConfigParameters, + options?: TestProfileRunAdministrationListTestProfileRunsParameters, ): StreamableMethod< - TestRunListServerMetricsConfig200Response | TestRunListServerMetricsConfigDefaultResponse + | TestProfileRunAdministrationListTestProfileRuns200Response + | TestProfileRunAdministrationListTestProfileRunsDefaultResponse >; } export interface Routes { /** Resource for '/tests/\{testId\}' has methods for the following verbs: patch, delete, get */ - (path: "/tests/{testId}", testId: string): TestCreateOrUpdate; + ( + path: "/tests/{testId}", + testId: string, + ): LoadTestAdministrationCreateOrUpdateTest; /** Resource for '/tests' has methods for the following verbs: get */ - (path: "/tests"): TestList; + (path: "/tests"): LoadTestAdministrationListTests; /** Resource for '/tests/\{testId\}/files/\{fileName\}' has methods for the following verbs: put, get, delete */ - (path: "/tests/{testId}/files/{fileName}", testId: string, fileName: string): TestUploadFile; + ( + path: "/tests/{testId}/files/{fileName}", + testId: string, + fileName: string, + ): LoadTestAdministrationUploadTestFile; /** Resource for '/tests/\{testId\}/files' has methods for the following verbs: get */ - (path: "/tests/{testId}/files", testId: string): TestListFiles; + ( + path: "/tests/{testId}/files", + testId: string, + ): LoadTestAdministrationListTestFiles; /** Resource for '/tests/\{testId\}/app-components' has methods for the following verbs: patch, get */ - (path: "/tests/{testId}/app-components", testId: string): TestCreateOrUpdateAppComponents; + ( + path: "/tests/{testId}/app-components", + testId: string, + ): LoadTestAdministrationCreateOrUpdateAppComponents; /** Resource for '/tests/\{testId\}/server-metrics-config' has methods for the following verbs: patch, get */ ( path: "/tests/{testId}/server-metrics-config", testId: string, - ): TestCreateOrUpdateServerMetricsConfig; - /** Resource for '/test-runs/\{testRunId\}' has methods for the following verbs: delete, patch, get */ - (path: "/test-runs/{testRunId}", testRunId: string): TestRunDelete; + ): LoadTestAdministrationCreateOrUpdateServerMetricsConfig; + /** Resource for '/test-runs/\{testRunId\}' has methods for the following verbs: get, patch, delete */ + (path: "/test-runs/{testRunId}", testRunId: string): LoadTestRunGetTestRun; + /** Resource for '/test-runs' has methods for the following verbs: get */ + (path: "/test-runs"): LoadTestRunListTestRuns; /** Resource for '/test-runs/\{testRunId\}/files/\{fileName\}' has methods for the following verbs: get */ ( path: "/test-runs/{testRunId}/files/{fileName}", testRunId: string, fileName: string, - ): TestRunGetFile; - /** Resource for '/test-runs' has methods for the following verbs: get */ - (path: "/test-runs"): TestRunList; + ): LoadTestRunGetTestRunFile; /** Resource for '/test-runs/\{testRunId\}:stop' has methods for the following verbs: post */ - (path: "/test-runs/{testRunId}:stop", testRunId: string): TestRunStop; + ( + path: "/test-runs/{testRunId}:stop", + testRunId: string, + ): LoadTestRunStopTestRun; /** Resource for '/test-runs/\{testRunId\}/metric-namespaces' has methods for the following verbs: get */ ( path: "/test-runs/{testRunId}/metric-namespaces", testRunId: string, - ): TestRunListMetricNamespaces; + ): LoadTestRunListMetricNamespaces; /** Resource for '/test-runs/\{testRunId\}/metric-definitions' has methods for the following verbs: get */ ( path: "/test-runs/{testRunId}/metric-definitions", testRunId: string, - ): TestRunListMetricDefinitions; + ): LoadTestRunListMetricDefinitions; /** Resource for '/test-runs/\{testRunId\}/metrics' has methods for the following verbs: post */ - (path: "/test-runs/{testRunId}/metrics", testRunId: string): TestRunListMetrics; + ( + path: "/test-runs/{testRunId}/metrics", + testRunId: string, + ): LoadTestRunListMetrics; /** Resource for '/test-runs/\{testRunId\}/metric-dimensions/\{name\}/values' has methods for the following verbs: get */ ( path: "/test-runs/{testRunId}/metric-dimensions/{name}/values", testRunId: string, name: string, - ): TestRunListMetricDimensionValues; + ): LoadTestRunListMetricDimensionValues; /** Resource for '/test-runs/\{testRunId\}/app-components' has methods for the following verbs: patch, get */ ( path: "/test-runs/{testRunId}/app-components", testRunId: string, - ): TestRunCreateOrUpdateAppComponents; + ): LoadTestRunCreateOrUpdateAppComponents; /** Resource for '/test-runs/\{testRunId\}/server-metrics-config' has methods for the following verbs: patch, get */ ( path: "/test-runs/{testRunId}/server-metrics-config", testRunId: string, - ): TestRunCreateOrUpdateServerMetricsConfig; + ): LoadTestRunCreateOrUpdateServerMetricsConfig; + /** Resource for '/test-profiles/\{testProfileId\}' has methods for the following verbs: patch, delete, get */ + ( + path: "/test-profiles/{testProfileId}", + testProfileId: string, + ): TestProfileAdministrationCreateOrUpdateTestProfile; + /** Resource for '/test-profiles' has methods for the following verbs: get */ + (path: "/test-profiles"): TestProfileAdministrationListTestProfiles; + /** Resource for '/test-profile-runs/\{testProfileRunId\}' has methods for the following verbs: get, patch, delete */ + ( + path: "/test-profile-runs/{testProfileRunId}", + testProfileRunId: string, + ): TestProfileRunAdministrationGetTestProfileRun; + /** Resource for '/test-profile-runs/\{testProfileRunId\}:stop' has methods for the following verbs: post */ + ( + path: "/test-profile-runs/{testProfileRunId}:stop", + testProfileRunId: string, + ): TestProfileRunAdministrationStopTestProfileRun; + /** Resource for '/test-profile-runs' has methods for the following verbs: get */ + (path: "/test-profile-runs"): TestProfileRunAdministrationListTestProfileRuns; } export type AzureLoadTestingClient = Client & { diff --git a/sdk/loadtesting/load-testing-rest/src/getFileValidationPoller.ts b/sdk/loadtesting/load-testing-rest/src/getFileValidationPoller.ts deleted file mode 100644 index 58f85c1f7f59..000000000000 --- a/sdk/loadtesting/load-testing-rest/src/getFileValidationPoller.ts +++ /dev/null @@ -1,172 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import { AbortError, AbortSignalLike } from "@azure/abort-controller"; -import { CancelOnProgress, OperationState, SimplePollerLike } from "@azure/core-lro"; -import { FileUploadAndValidatePoller, PolledOperationOptions } from "./models"; -import { AzureLoadTestingClient } from "./clientDefinitions"; -import { TestGetFile200Response, TestUploadFile201Response } from "./responses"; -import { isUnexpected } from "./isUnexpected"; -import { sleep } from "./util/LROUtil"; - -/** - * Uploads a file and creates a poller to poll for validation. - * @param client - The Load Testing client. - * @param options - The operation options. - * @returns A poller which can be called to poll until completion of the job. - */ -export async function getFileValidationPoller( - client: AzureLoadTestingClient, - fileUploadResult: TestUploadFile201Response, - polledOperationOptions: PolledOperationOptions = {}, -): Promise { - // get filename and testid from initial response - const fileName = fileUploadResult.body.fileName; - const requestUrl = fileUploadResult.request.url; - const testId = requestUrl.substring( - requestUrl.indexOf("tests/") + 6, - requestUrl.lastIndexOf("/files"), - ); - type Handler = (state: OperationState) => void; - - const state: OperationState = { - status: "notStarted", - }; - - const progressCallbacks = new Map(); - const processProgressCallbacks = async (): Promise => - progressCallbacks.forEach((h) => h(state)); - let resultPromise: Promise | undefined; - let cancelJob: (() => void) | undefined; - const abortController = new AbortController(); - const currentPollIntervalInMs = polledOperationOptions.updateIntervalInMs ?? 2000; - - const poller: SimplePollerLike, TestGetFile200Response> = { - async poll(options?: { abortSignal?: AbortSignalLike }): Promise { - if (options?.abortSignal?.aborted) { - throw new AbortError("The polling was aborted."); - } - - if (fileName) { - const fileValidationResponse = await client - .path("/tests/{testId}/files/{fileName}", testId, fileName) - .get(); - if (isUnexpected(fileValidationResponse)) { - state.status = "failed"; - state.error = new Error(fileValidationResponse.body.error.message); - return; - } - - switch (fileValidationResponse.body.validationStatus) { - case "NOT_VALIDATED": { - if (fileValidationResponse.body.fileType === "JMX_FILE") { - state.status = "running"; - } else { - state.status = "succeeded"; - } - break; - } - case "VALIDATION_INITIATED": { - state.status = "running"; - break; - } - case "VALIDATION_SUCCESS": - case "VALIDATION_NOT_REQUIRED": { - state.status = "succeeded"; - break; - } - case "VALIDATION_FAILURE": { - state.status = "failed"; - state.error = new Error(fileValidationResponse.body.validationFailureDetails); - break; - } - } - state.result = fileValidationResponse; - - await processProgressCallbacks(); - } - }, - - pollUntilDone(pollOptions?: { - abortSignal?: AbortSignalLike; - }): Promise { - return (resultPromise ??= (async () => { - const { abortSignal: inputAbortSignal } = pollOptions || {}; - // In the future we can use AbortSignal.any() instead - function abortListener(): void { - abortController.abort(); - } - const abortSignal = abortController.signal; - if (inputAbortSignal?.aborted) { - abortController.abort(); - } else if (!abortSignal.aborted) { - inputAbortSignal?.addEventListener("abort", abortListener, { once: true }); - } - - try { - if (!poller.isDone()) { - await poller.poll({ abortSignal }); - while (!poller.isDone()) { - const delay = sleep(currentPollIntervalInMs, abortSignal); - cancelJob = () => abortController.abort(); - await delay; - await poller.poll({ abortSignal }); - } - } - } finally { - inputAbortSignal?.removeEventListener("abort", abortListener); - } - switch (state.status) { - case "succeeded": - case "failed": - case "canceled": { - return poller.getResult() as TestGetFile200Response; - } - case "notStarted": - case "running": { - // Unreachable - throw new Error(`polling completed without succeeding or failing`); - } - } - })().finally(() => { - resultPromise = undefined; - })); - }, - - onProgress( - callback: (state: OperationState) => void, - ): CancelOnProgress { - const s = Symbol(); - progressCallbacks.set(s, callback); - - return () => progressCallbacks.delete(s); - }, - - isDone(): boolean { - return ["succeeded", "failed", "canceled"].includes(state.status); - }, - - stopPolling(): void { - abortController.abort(); - cancelJob?.(); - }, - - isStopped(): boolean { - return resultPromise === undefined; - }, - - getOperationState(): OperationState { - return state; - }, - - getResult(): TestGetFile200Response | undefined { - return state.result; - }, - - toString() { - return JSON.stringify({ state }); - }, - }; - - return poller; -} diff --git a/sdk/loadtesting/load-testing-rest/src/getTestRunCompletionPoller.ts b/sdk/loadtesting/load-testing-rest/src/getTestRunCompletionPoller.ts deleted file mode 100644 index 910d3cee0ad0..000000000000 --- a/sdk/loadtesting/load-testing-rest/src/getTestRunCompletionPoller.ts +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import { AbortError, AbortSignalLike } from "@azure/abort-controller"; -import { CancelOnProgress, OperationState, SimplePollerLike } from "@azure/core-lro"; -import { TestRunCompletionPoller, PolledOperationOptions } from "./models"; -import { AzureLoadTestingClient } from "./clientDefinitions"; -import { - TestRunCreateOrUpdate200Response, - TestRunCreateOrUpdate201Response, - TestRunGet200Response, -} from "./responses"; -import { isUnexpected } from "./isUnexpected"; -import { sleep, isTestRunInProgress } from "./util/LROUtil"; - -/** - * Creates a poller to poll for test run status. - * @param client - The Load Testing client. - * @param options - The operation options. - * @returns A poller which can be called to poll until completion of the job. - */ -export async function getTestRunCompletionPoller( - client: AzureLoadTestingClient, - createTestRunResponse: TestRunCreateOrUpdate200Response | TestRunCreateOrUpdate201Response, - polledOperationOptions: PolledOperationOptions = {}, -): Promise { - type Handler = (state: OperationState) => void; - - const state: OperationState = { - status: "notStarted", - }; - - const progressCallbacks = new Map(); - const processProgressCallbacks = async (): Promise => - progressCallbacks.forEach((h) => h(state)); - let resultPromise: Promise | undefined; - let cancelJob: (() => void) | undefined; - const abortController = new AbortController(); - const currentPollIntervalInMs = polledOperationOptions.updateIntervalInMs ?? 2000; - const testRunId = createTestRunResponse.body.testRunId; - - const poller: SimplePollerLike, TestRunGet200Response> = { - async poll(options?: { abortSignal?: AbortSignalLike }): Promise { - if (options?.abortSignal?.aborted) { - throw new AbortError("The polling was aborted."); - } - - if (testRunId) { - const getTestRunResult = await client.path("/test-runs/{testRunId}", testRunId).get(); - if (isUnexpected(getTestRunResult)) { - state.status = "failed"; - state.error = new Error(getTestRunResult.body.error.message); - return; - } - - if (getTestRunResult.body.status === "FAILED") { - state.status = "failed"; - state.error = new Error(getTestRunResult.body.status); - } - - if (getTestRunResult.body.status === "CANCELLED") { - state.status = "canceled"; - } - - if (getTestRunResult.body.status === "DONE") { - state.status = "succeeded"; - } - - if (isTestRunInProgress(getTestRunResult.body)) { - state.status = "running"; - } - state.result = getTestRunResult; - await processProgressCallbacks(); - } - }, - - pollUntilDone(pollOptions?: { abortSignal?: AbortSignalLike }): Promise { - return (resultPromise ??= (async () => { - const { abortSignal: inputAbortSignal } = pollOptions || {}; - // In the future we can use AbortSignal.any() instead - function abortListener(): void { - abortController.abort(); - } - const abortSignal = abortController.signal; - if (inputAbortSignal?.aborted) { - abortController.abort(); - } else if (!abortSignal.aborted) { - inputAbortSignal?.addEventListener("abort", abortListener, { once: true }); - } - - try { - if (!poller.isDone()) { - await poller.poll({ abortSignal }); - while (!poller.isDone()) { - const delay = sleep(currentPollIntervalInMs, abortSignal); - cancelJob = () => abortController.abort(); - await delay; - await poller.poll({ abortSignal }); - } - } - } finally { - inputAbortSignal?.removeEventListener("abort", abortListener); - } - switch (state.status) { - case "succeeded": - case "failed": - case "canceled": { - return poller.getResult() as TestRunGet200Response; - } - case "notStarted": - case "running": { - // Unreachable - throw new Error(`polling completed without succeeding or failing`); - } - } - })().finally(() => { - resultPromise = undefined; - })); - }, - - onProgress(callback: (state: OperationState) => void): CancelOnProgress { - const s = Symbol(); - progressCallbacks.set(s, callback); - - return () => progressCallbacks.delete(s); - }, - - isDone(): boolean { - return ["succeeded", "failed", "canceled"].includes(state.status); - }, - - stopPolling(): void { - abortController.abort(); - cancelJob?.(); - }, - - isStopped(): boolean { - return resultPromise === undefined; - }, - - getOperationState(): OperationState { - return state; - }, - - getResult(): TestRunGet200Response | undefined { - return state.result; - }, - - toString() { - return JSON.stringify({ state }); - }, - }; - - return poller; -} diff --git a/sdk/loadtesting/load-testing-rest/src/index.ts b/sdk/loadtesting/load-testing-rest/src/index.ts index e5f7eab868f6..242e15696d72 100644 --- a/sdk/loadtesting/load-testing-rest/src/index.ts +++ b/sdk/loadtesting/load-testing-rest/src/index.ts @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import AzureLoadTesting from "./azureLoadTesting"; +import AzureLoadTesting from "./azureLoadTesting.js"; + +export * from "./azureLoadTesting.js"; +export * from "./parameters.js"; +export * from "./responses.js"; +export * from "./clientDefinitions.js"; +export * from "./isUnexpected.js"; +export * from "./models.js"; +export * from "./outputModels.js"; +export * from "./paginateHelper.js"; -export * from "./azureLoadTesting"; -export * from "./parameters"; -export * from "./responses"; -export * from "./clientDefinitions"; -export * from "./isUnexpected"; -export * from "./models"; -export * from "./outputModels"; -export * from "./paginateHelper"; -export { getLongRunningPoller } from "./pollingHelper"; export default AzureLoadTesting; diff --git a/sdk/loadtesting/load-testing-rest/src/isUnexpected.ts b/sdk/loadtesting/load-testing-rest/src/isUnexpected.ts index 0a8a404ea398..c07c8891a968 100644 --- a/sdk/loadtesting/load-testing-rest/src/isUnexpected.ts +++ b/sdk/loadtesting/load-testing-rest/src/isUnexpected.ts @@ -2,65 +2,85 @@ // Licensed under the MIT License. import { - TestCreateOrUpdate200Response, - TestCreateOrUpdate201Response, - TestCreateOrUpdateDefaultResponse, - TestDelete204Response, - TestDeleteDefaultResponse, - TestGet200Response, - TestGetDefaultResponse, - TestList200Response, - TestListDefaultResponse, - TestUploadFile201Response, - TestUploadFileDefaultResponse, - TestGetFile200Response, - TestGetFileDefaultResponse, - TestDeleteFile204Response, - TestDeleteFileDefaultResponse, - TestListFiles200Response, - TestListFilesDefaultResponse, - TestCreateOrUpdateAppComponents200Response, - TestCreateOrUpdateAppComponents201Response, - TestCreateOrUpdateAppComponentsDefaultResponse, - TestListAppComponents200Response, - TestListAppComponentsDefaultResponse, - TestCreateOrUpdateServerMetricsConfig200Response, - TestCreateOrUpdateServerMetricsConfig201Response, - TestCreateOrUpdateServerMetricsConfigDefaultResponse, - TestListServerMetricsConfig200Response, - TestListServerMetricsConfigDefaultResponse, - TestRunDelete204Response, - TestRunDeleteDefaultResponse, - TestRunCreateOrUpdate200Response, - TestRunCreateOrUpdate201Response, - TestRunCreateOrUpdateDefaultResponse, - TestRunGet200Response, - TestRunGetDefaultResponse, - TestRunGetFile200Response, - TestRunGetFileDefaultResponse, - TestRunList200Response, - TestRunListDefaultResponse, - TestRunStop200Response, - TestRunStopDefaultResponse, - TestRunListMetricNamespaces200Response, - TestRunListMetricNamespacesDefaultResponse, - TestRunListMetricDefinitions200Response, - TestRunListMetricDefinitionsDefaultResponse, - TestRunListMetrics200Response, - TestRunListMetricsDefaultResponse, - TestRunListMetricDimensionValues200Response, - TestRunListMetricDimensionValuesDefaultResponse, - TestRunCreateOrUpdateAppComponents200Response, - TestRunCreateOrUpdateAppComponents201Response, - TestRunCreateOrUpdateAppComponentsDefaultResponse, - TestRunListAppComponents200Response, - TestRunListAppComponentsDefaultResponse, - TestRunCreateOrUpdateServerMetricsConfig200Response, - TestRunCreateOrUpdateServerMetricsConfig201Response, - TestRunCreateOrUpdateServerMetricsConfigDefaultResponse, - TestRunListServerMetricsConfig200Response, - TestRunListServerMetricsConfigDefaultResponse, -} from "./responses"; + LoadTestAdministrationCreateOrUpdateTest200Response, + LoadTestAdministrationCreateOrUpdateTest201Response, + LoadTestAdministrationCreateOrUpdateTestDefaultResponse, + LoadTestAdministrationDeleteTest204Response, + LoadTestAdministrationDeleteTestDefaultResponse, + LoadTestAdministrationGetTest200Response, + LoadTestAdministrationGetTestDefaultResponse, + LoadTestAdministrationListTests200Response, + LoadTestAdministrationListTestsDefaultResponse, + LoadTestAdministrationUploadTestFile201Response, + LoadTestAdministrationUploadTestFileDefaultResponse, + LoadTestAdministrationGetTestFile200Response, + LoadTestAdministrationGetTestFileDefaultResponse, + LoadTestAdministrationDeleteTestFile204Response, + LoadTestAdministrationDeleteTestFileDefaultResponse, + LoadTestAdministrationListTestFiles200Response, + LoadTestAdministrationListTestFilesDefaultResponse, + LoadTestAdministrationCreateOrUpdateAppComponents200Response, + LoadTestAdministrationCreateOrUpdateAppComponents201Response, + LoadTestAdministrationCreateOrUpdateAppComponentsDefaultResponse, + LoadTestAdministrationGetAppComponents200Response, + LoadTestAdministrationGetAppComponentsDefaultResponse, + LoadTestAdministrationCreateOrUpdateServerMetricsConfig200Response, + LoadTestAdministrationCreateOrUpdateServerMetricsConfig201Response, + LoadTestAdministrationCreateOrUpdateServerMetricsConfigDefaultResponse, + LoadTestAdministrationGetServerMetricsConfig200Response, + LoadTestAdministrationGetServerMetricsConfigDefaultResponse, + LoadTestRunGetTestRun200Response, + LoadTestRunGetTestRunDefaultResponse, + LoadTestRunCreateOrUpdateTestRun200Response, + LoadTestRunCreateOrUpdateTestRun201Response, + LoadTestRunCreateOrUpdateTestRunDefaultResponse, + LoadTestRunDeleteTestRun204Response, + LoadTestRunDeleteTestRunDefaultResponse, + LoadTestRunListTestRuns200Response, + LoadTestRunListTestRunsDefaultResponse, + LoadTestRunGetTestRunFile200Response, + LoadTestRunGetTestRunFileDefaultResponse, + LoadTestRunStopTestRun200Response, + LoadTestRunStopTestRunDefaultResponse, + LoadTestRunListMetricNamespaces200Response, + LoadTestRunListMetricNamespacesDefaultResponse, + LoadTestRunListMetricDefinitions200Response, + LoadTestRunListMetricDefinitionsDefaultResponse, + LoadTestRunListMetrics200Response, + LoadTestRunListMetricsDefaultResponse, + LoadTestRunListMetricDimensionValues200Response, + LoadTestRunListMetricDimensionValuesDefaultResponse, + LoadTestRunCreateOrUpdateAppComponents200Response, + LoadTestRunCreateOrUpdateAppComponents201Response, + LoadTestRunCreateOrUpdateAppComponentsDefaultResponse, + LoadTestRunGetAppComponents200Response, + LoadTestRunGetAppComponentsDefaultResponse, + LoadTestRunCreateOrUpdateServerMetricsConfig200Response, + LoadTestRunCreateOrUpdateServerMetricsConfig201Response, + LoadTestRunCreateOrUpdateServerMetricsConfigDefaultResponse, + LoadTestRunGetServerMetricsConfig200Response, + LoadTestRunGetServerMetricsConfigDefaultResponse, + TestProfileAdministrationCreateOrUpdateTestProfile200Response, + TestProfileAdministrationCreateOrUpdateTestProfile201Response, + TestProfileAdministrationCreateOrUpdateTestProfileDefaultResponse, + TestProfileAdministrationDeleteTestProfile204Response, + TestProfileAdministrationDeleteTestProfileDefaultResponse, + TestProfileAdministrationGetTestProfile200Response, + TestProfileAdministrationGetTestProfileDefaultResponse, + TestProfileAdministrationListTestProfiles200Response, + TestProfileAdministrationListTestProfilesDefaultResponse, + TestProfileRunAdministrationGetTestProfileRun200Response, + TestProfileRunAdministrationGetTestProfileRunDefaultResponse, + TestProfileRunAdministrationCreateOrUpdateTestProfileRun200Response, + TestProfileRunAdministrationCreateOrUpdateTestProfileRun201Response, + TestProfileRunAdministrationCreateOrUpdateTestProfileRunDefaultResponse, + TestProfileRunAdministrationDeleteTestProfileRun204Response, + TestProfileRunAdministrationDeleteTestProfileRunDefaultResponse, + TestProfileRunAdministrationStopTestProfileRun200Response, + TestProfileRunAdministrationStopTestProfileRunDefaultResponse, + TestProfileRunAdministrationListTestProfileRuns200Response, + TestProfileRunAdministrationListTestProfileRunsDefaultResponse, +} from "./responses.js"; const responseMap: Record = { "PATCH /tests/{testId}": ["200", "201"], @@ -75,11 +95,11 @@ const responseMap: Record = { "GET /tests/{testId}/app-components": ["200"], "PATCH /tests/{testId}/server-metrics-config": ["200", "201"], "GET /tests/{testId}/server-metrics-config": ["200"], - "DELETE /test-runs/{testRunId}": ["204"], - "PATCH /test-runs/{testRunId}": ["200", "201"], "GET /test-runs/{testRunId}": ["200"], - "GET /test-runs/{testRunId}/files/{fileName}": ["200"], + "PATCH /test-runs/{testRunId}": ["200", "201"], + "DELETE /test-runs/{testRunId}": ["204"], "GET /test-runs": ["200"], + "GET /test-runs/{testRunId}/files/{fileName}": ["200"], "POST /test-runs/{testRunId}:stop": ["200"], "GET /test-runs/{testRunId}/metric-namespaces": ["200"], "GET /test-runs/{testRunId}/metric-definitions": ["200"], @@ -89,208 +109,335 @@ const responseMap: Record = { "GET /test-runs/{testRunId}/app-components": ["200"], "PATCH /test-runs/{testRunId}/server-metrics-config": ["200", "201"], "GET /test-runs/{testRunId}/server-metrics-config": ["200"], + "PATCH /test-profiles/{testProfileId}": ["200", "201"], + "DELETE /test-profiles/{testProfileId}": ["204"], + "GET /test-profiles/{testProfileId}": ["200"], + "GET /test-profiles": ["200"], + "GET /test-profile-runs/{testProfileRunId}": ["200"], + "PATCH /test-profile-runs/{testProfileRunId}": ["200", "201"], + "DELETE /test-profile-runs/{testProfileRunId}": ["204"], + "POST /test-profile-runs/{testProfileRunId}:stop": ["200"], + "GET /test-profile-runs": ["200"], }; export function isUnexpected( response: - | TestCreateOrUpdate200Response - | TestCreateOrUpdate201Response - | TestCreateOrUpdateDefaultResponse, -): response is TestCreateOrUpdateDefaultResponse; + | LoadTestAdministrationCreateOrUpdateTest200Response + | LoadTestAdministrationCreateOrUpdateTest201Response + | LoadTestAdministrationCreateOrUpdateTestDefaultResponse, +): response is LoadTestAdministrationCreateOrUpdateTestDefaultResponse; +export function isUnexpected( + response: + | LoadTestAdministrationDeleteTest204Response + | LoadTestAdministrationDeleteTestDefaultResponse, +): response is LoadTestAdministrationDeleteTestDefaultResponse; +export function isUnexpected( + response: + | LoadTestAdministrationGetTest200Response + | LoadTestAdministrationGetTestDefaultResponse, +): response is LoadTestAdministrationGetTestDefaultResponse; +export function isUnexpected( + response: + | LoadTestAdministrationListTests200Response + | LoadTestAdministrationListTestsDefaultResponse, +): response is LoadTestAdministrationListTestsDefaultResponse; +export function isUnexpected( + response: + | LoadTestAdministrationUploadTestFile201Response + | LoadTestAdministrationUploadTestFileDefaultResponse, +): response is LoadTestAdministrationUploadTestFileDefaultResponse; +export function isUnexpected( + response: + | LoadTestAdministrationGetTestFile200Response + | LoadTestAdministrationGetTestFileDefaultResponse, +): response is LoadTestAdministrationGetTestFileDefaultResponse; +export function isUnexpected( + response: + | LoadTestAdministrationDeleteTestFile204Response + | LoadTestAdministrationDeleteTestFileDefaultResponse, +): response is LoadTestAdministrationDeleteTestFileDefaultResponse; +export function isUnexpected( + response: + | LoadTestAdministrationListTestFiles200Response + | LoadTestAdministrationListTestFilesDefaultResponse, +): response is LoadTestAdministrationListTestFilesDefaultResponse; +export function isUnexpected( + response: + | LoadTestAdministrationCreateOrUpdateAppComponents200Response + | LoadTestAdministrationCreateOrUpdateAppComponents201Response + | LoadTestAdministrationCreateOrUpdateAppComponentsDefaultResponse, +): response is LoadTestAdministrationCreateOrUpdateAppComponentsDefaultResponse; +export function isUnexpected( + response: + | LoadTestAdministrationGetAppComponents200Response + | LoadTestAdministrationGetAppComponentsDefaultResponse, +): response is LoadTestAdministrationGetAppComponentsDefaultResponse; +export function isUnexpected( + response: + | LoadTestAdministrationCreateOrUpdateServerMetricsConfig200Response + | LoadTestAdministrationCreateOrUpdateServerMetricsConfig201Response + | LoadTestAdministrationCreateOrUpdateServerMetricsConfigDefaultResponse, +): response is LoadTestAdministrationCreateOrUpdateServerMetricsConfigDefaultResponse; +export function isUnexpected( + response: + | LoadTestAdministrationGetServerMetricsConfig200Response + | LoadTestAdministrationGetServerMetricsConfigDefaultResponse, +): response is LoadTestAdministrationGetServerMetricsConfigDefaultResponse; +export function isUnexpected( + response: + | LoadTestRunGetTestRun200Response + | LoadTestRunGetTestRunDefaultResponse, +): response is LoadTestRunGetTestRunDefaultResponse; +export function isUnexpected( + response: + | LoadTestRunCreateOrUpdateTestRun200Response + | LoadTestRunCreateOrUpdateTestRun201Response + | LoadTestRunCreateOrUpdateTestRunDefaultResponse, +): response is LoadTestRunCreateOrUpdateTestRunDefaultResponse; +export function isUnexpected( + response: + | LoadTestRunDeleteTestRun204Response + | LoadTestRunDeleteTestRunDefaultResponse, +): response is LoadTestRunDeleteTestRunDefaultResponse; export function isUnexpected( - response: TestDelete204Response | TestDeleteDefaultResponse, -): response is TestDeleteDefaultResponse; + response: + | LoadTestRunListTestRuns200Response + | LoadTestRunListTestRunsDefaultResponse, +): response is LoadTestRunListTestRunsDefaultResponse; +export function isUnexpected( + response: + | LoadTestRunGetTestRunFile200Response + | LoadTestRunGetTestRunFileDefaultResponse, +): response is LoadTestRunGetTestRunFileDefaultResponse; +export function isUnexpected( + response: + | LoadTestRunStopTestRun200Response + | LoadTestRunStopTestRunDefaultResponse, +): response is LoadTestRunStopTestRunDefaultResponse; +export function isUnexpected( + response: + | LoadTestRunListMetricNamespaces200Response + | LoadTestRunListMetricNamespacesDefaultResponse, +): response is LoadTestRunListMetricNamespacesDefaultResponse; +export function isUnexpected( + response: + | LoadTestRunListMetricDefinitions200Response + | LoadTestRunListMetricDefinitionsDefaultResponse, +): response is LoadTestRunListMetricDefinitionsDefaultResponse; +export function isUnexpected( + response: + | LoadTestRunListMetrics200Response + | LoadTestRunListMetricsDefaultResponse, +): response is LoadTestRunListMetricsDefaultResponse; +export function isUnexpected( + response: + | LoadTestRunListMetricDimensionValues200Response + | LoadTestRunListMetricDimensionValuesDefaultResponse, +): response is LoadTestRunListMetricDimensionValuesDefaultResponse; +export function isUnexpected( + response: + | LoadTestRunCreateOrUpdateAppComponents200Response + | LoadTestRunCreateOrUpdateAppComponents201Response + | LoadTestRunCreateOrUpdateAppComponentsDefaultResponse, +): response is LoadTestRunCreateOrUpdateAppComponentsDefaultResponse; +export function isUnexpected( + response: + | LoadTestRunGetAppComponents200Response + | LoadTestRunGetAppComponentsDefaultResponse, +): response is LoadTestRunGetAppComponentsDefaultResponse; export function isUnexpected( - response: TestGet200Response | TestGetDefaultResponse, -): response is TestGetDefaultResponse; + response: + | LoadTestRunCreateOrUpdateServerMetricsConfig200Response + | LoadTestRunCreateOrUpdateServerMetricsConfig201Response + | LoadTestRunCreateOrUpdateServerMetricsConfigDefaultResponse, +): response is LoadTestRunCreateOrUpdateServerMetricsConfigDefaultResponse; export function isUnexpected( - response: TestList200Response | TestListDefaultResponse, -): response is TestListDefaultResponse; + response: + | LoadTestRunGetServerMetricsConfig200Response + | LoadTestRunGetServerMetricsConfigDefaultResponse, +): response is LoadTestRunGetServerMetricsConfigDefaultResponse; export function isUnexpected( - response: TestUploadFile201Response | TestUploadFileDefaultResponse, -): response is TestUploadFileDefaultResponse; + response: + | TestProfileAdministrationCreateOrUpdateTestProfile200Response + | TestProfileAdministrationCreateOrUpdateTestProfile201Response + | TestProfileAdministrationCreateOrUpdateTestProfileDefaultResponse, +): response is TestProfileAdministrationCreateOrUpdateTestProfileDefaultResponse; export function isUnexpected( - response: TestGetFile200Response | TestGetFileDefaultResponse, -): response is TestGetFileDefaultResponse; + response: + | TestProfileAdministrationDeleteTestProfile204Response + | TestProfileAdministrationDeleteTestProfileDefaultResponse, +): response is TestProfileAdministrationDeleteTestProfileDefaultResponse; export function isUnexpected( - response: TestDeleteFile204Response | TestDeleteFileDefaultResponse, -): response is TestDeleteFileDefaultResponse; + response: + | TestProfileAdministrationGetTestProfile200Response + | TestProfileAdministrationGetTestProfileDefaultResponse, +): response is TestProfileAdministrationGetTestProfileDefaultResponse; export function isUnexpected( - response: TestListFiles200Response | TestListFilesDefaultResponse, -): response is TestListFilesDefaultResponse; + response: + | TestProfileAdministrationListTestProfiles200Response + | TestProfileAdministrationListTestProfilesDefaultResponse, +): response is TestProfileAdministrationListTestProfilesDefaultResponse; export function isUnexpected( response: - | TestCreateOrUpdateAppComponents200Response - | TestCreateOrUpdateAppComponents201Response - | TestCreateOrUpdateAppComponentsDefaultResponse, -): response is TestCreateOrUpdateAppComponentsDefaultResponse; + | TestProfileRunAdministrationGetTestProfileRun200Response + | TestProfileRunAdministrationGetTestProfileRunDefaultResponse, +): response is TestProfileRunAdministrationGetTestProfileRunDefaultResponse; export function isUnexpected( - response: TestListAppComponents200Response | TestListAppComponentsDefaultResponse, -): response is TestListAppComponentsDefaultResponse; + response: + | TestProfileRunAdministrationCreateOrUpdateTestProfileRun200Response + | TestProfileRunAdministrationCreateOrUpdateTestProfileRun201Response + | TestProfileRunAdministrationCreateOrUpdateTestProfileRunDefaultResponse, +): response is TestProfileRunAdministrationCreateOrUpdateTestProfileRunDefaultResponse; export function isUnexpected( response: - | TestCreateOrUpdateServerMetricsConfig200Response - | TestCreateOrUpdateServerMetricsConfig201Response - | TestCreateOrUpdateServerMetricsConfigDefaultResponse, -): response is TestCreateOrUpdateServerMetricsConfigDefaultResponse; + | TestProfileRunAdministrationDeleteTestProfileRun204Response + | TestProfileRunAdministrationDeleteTestProfileRunDefaultResponse, +): response is TestProfileRunAdministrationDeleteTestProfileRunDefaultResponse; export function isUnexpected( - response: TestListServerMetricsConfig200Response | TestListServerMetricsConfigDefaultResponse, -): response is TestListServerMetricsConfigDefaultResponse; + response: + | TestProfileRunAdministrationStopTestProfileRun200Response + | TestProfileRunAdministrationStopTestProfileRunDefaultResponse, +): response is TestProfileRunAdministrationStopTestProfileRunDefaultResponse; export function isUnexpected( - response: TestRunDelete204Response | TestRunDeleteDefaultResponse, -): response is TestRunDeleteDefaultResponse; -export function isUnexpected( - response: - | TestRunCreateOrUpdate200Response - | TestRunCreateOrUpdate201Response - | TestRunCreateOrUpdateDefaultResponse, -): response is TestRunCreateOrUpdateDefaultResponse; -export function isUnexpected( - response: TestRunGet200Response | TestRunGetDefaultResponse, -): response is TestRunGetDefaultResponse; -export function isUnexpected( - response: TestRunGetFile200Response | TestRunGetFileDefaultResponse, -): response is TestRunGetFileDefaultResponse; -export function isUnexpected( - response: TestRunList200Response | TestRunListDefaultResponse, -): response is TestRunListDefaultResponse; -export function isUnexpected( - response: TestRunStop200Response | TestRunStopDefaultResponse, -): response is TestRunStopDefaultResponse; -export function isUnexpected( - response: TestRunListMetricNamespaces200Response | TestRunListMetricNamespacesDefaultResponse, -): response is TestRunListMetricNamespacesDefaultResponse; -export function isUnexpected( - response: TestRunListMetricDefinitions200Response | TestRunListMetricDefinitionsDefaultResponse, -): response is TestRunListMetricDefinitionsDefaultResponse; -export function isUnexpected( - response: TestRunListMetrics200Response | TestRunListMetricsDefaultResponse, -): response is TestRunListMetricsDefaultResponse; -export function isUnexpected( - response: - | TestRunListMetricDimensionValues200Response - | TestRunListMetricDimensionValuesDefaultResponse, -): response is TestRunListMetricDimensionValuesDefaultResponse; -export function isUnexpected( - response: - | TestRunCreateOrUpdateAppComponents200Response - | TestRunCreateOrUpdateAppComponents201Response - | TestRunCreateOrUpdateAppComponentsDefaultResponse, -): response is TestRunCreateOrUpdateAppComponentsDefaultResponse; -export function isUnexpected( - response: TestRunListAppComponents200Response | TestRunListAppComponentsDefaultResponse, -): response is TestRunListAppComponentsDefaultResponse; -export function isUnexpected( - response: - | TestRunCreateOrUpdateServerMetricsConfig200Response - | TestRunCreateOrUpdateServerMetricsConfig201Response - | TestRunCreateOrUpdateServerMetricsConfigDefaultResponse, -): response is TestRunCreateOrUpdateServerMetricsConfigDefaultResponse; -export function isUnexpected( - response: - | TestRunListServerMetricsConfig200Response - | TestRunListServerMetricsConfigDefaultResponse, -): response is TestRunListServerMetricsConfigDefaultResponse; -export function isUnexpected( - response: - | TestCreateOrUpdate200Response - | TestCreateOrUpdate201Response - | TestCreateOrUpdateDefaultResponse - | TestDelete204Response - | TestDeleteDefaultResponse - | TestGet200Response - | TestGetDefaultResponse - | TestList200Response - | TestListDefaultResponse - | TestUploadFile201Response - | TestUploadFileDefaultResponse - | TestGetFile200Response - | TestGetFileDefaultResponse - | TestDeleteFile204Response - | TestDeleteFileDefaultResponse - | TestListFiles200Response - | TestListFilesDefaultResponse - | TestCreateOrUpdateAppComponents200Response - | TestCreateOrUpdateAppComponents201Response - | TestCreateOrUpdateAppComponentsDefaultResponse - | TestListAppComponents200Response - | TestListAppComponentsDefaultResponse - | TestCreateOrUpdateServerMetricsConfig200Response - | TestCreateOrUpdateServerMetricsConfig201Response - | TestCreateOrUpdateServerMetricsConfigDefaultResponse - | TestListServerMetricsConfig200Response - | TestListServerMetricsConfigDefaultResponse - | TestRunDelete204Response - | TestRunDeleteDefaultResponse - | TestRunCreateOrUpdate200Response - | TestRunCreateOrUpdate201Response - | TestRunCreateOrUpdateDefaultResponse - | TestRunGet200Response - | TestRunGetDefaultResponse - | TestRunGetFile200Response - | TestRunGetFileDefaultResponse - | TestRunList200Response - | TestRunListDefaultResponse - | TestRunStop200Response - | TestRunStopDefaultResponse - | TestRunListMetricNamespaces200Response - | TestRunListMetricNamespacesDefaultResponse - | TestRunListMetricDefinitions200Response - | TestRunListMetricDefinitionsDefaultResponse - | TestRunListMetrics200Response - | TestRunListMetricsDefaultResponse - | TestRunListMetricDimensionValues200Response - | TestRunListMetricDimensionValuesDefaultResponse - | TestRunCreateOrUpdateAppComponents200Response - | TestRunCreateOrUpdateAppComponents201Response - | TestRunCreateOrUpdateAppComponentsDefaultResponse - | TestRunListAppComponents200Response - | TestRunListAppComponentsDefaultResponse - | TestRunCreateOrUpdateServerMetricsConfig200Response - | TestRunCreateOrUpdateServerMetricsConfig201Response - | TestRunCreateOrUpdateServerMetricsConfigDefaultResponse - | TestRunListServerMetricsConfig200Response - | TestRunListServerMetricsConfigDefaultResponse, + response: + | TestProfileRunAdministrationListTestProfileRuns200Response + | TestProfileRunAdministrationListTestProfileRunsDefaultResponse, +): response is TestProfileRunAdministrationListTestProfileRunsDefaultResponse; +export function isUnexpected( + response: + | LoadTestAdministrationCreateOrUpdateTest200Response + | LoadTestAdministrationCreateOrUpdateTest201Response + | LoadTestAdministrationCreateOrUpdateTestDefaultResponse + | LoadTestAdministrationDeleteTest204Response + | LoadTestAdministrationDeleteTestDefaultResponse + | LoadTestAdministrationGetTest200Response + | LoadTestAdministrationGetTestDefaultResponse + | LoadTestAdministrationListTests200Response + | LoadTestAdministrationListTestsDefaultResponse + | LoadTestAdministrationUploadTestFile201Response + | LoadTestAdministrationUploadTestFileDefaultResponse + | LoadTestAdministrationGetTestFile200Response + | LoadTestAdministrationGetTestFileDefaultResponse + | LoadTestAdministrationDeleteTestFile204Response + | LoadTestAdministrationDeleteTestFileDefaultResponse + | LoadTestAdministrationListTestFiles200Response + | LoadTestAdministrationListTestFilesDefaultResponse + | LoadTestAdministrationCreateOrUpdateAppComponents200Response + | LoadTestAdministrationCreateOrUpdateAppComponents201Response + | LoadTestAdministrationCreateOrUpdateAppComponentsDefaultResponse + | LoadTestAdministrationGetAppComponents200Response + | LoadTestAdministrationGetAppComponentsDefaultResponse + | LoadTestAdministrationCreateOrUpdateServerMetricsConfig200Response + | LoadTestAdministrationCreateOrUpdateServerMetricsConfig201Response + | LoadTestAdministrationCreateOrUpdateServerMetricsConfigDefaultResponse + | LoadTestAdministrationGetServerMetricsConfig200Response + | LoadTestAdministrationGetServerMetricsConfigDefaultResponse + | LoadTestRunGetTestRun200Response + | LoadTestRunGetTestRunDefaultResponse + | LoadTestRunCreateOrUpdateTestRun200Response + | LoadTestRunCreateOrUpdateTestRun201Response + | LoadTestRunCreateOrUpdateTestRunDefaultResponse + | LoadTestRunDeleteTestRun204Response + | LoadTestRunDeleteTestRunDefaultResponse + | LoadTestRunListTestRuns200Response + | LoadTestRunListTestRunsDefaultResponse + | LoadTestRunGetTestRunFile200Response + | LoadTestRunGetTestRunFileDefaultResponse + | LoadTestRunStopTestRun200Response + | LoadTestRunStopTestRunDefaultResponse + | LoadTestRunListMetricNamespaces200Response + | LoadTestRunListMetricNamespacesDefaultResponse + | LoadTestRunListMetricDefinitions200Response + | LoadTestRunListMetricDefinitionsDefaultResponse + | LoadTestRunListMetrics200Response + | LoadTestRunListMetricsDefaultResponse + | LoadTestRunListMetricDimensionValues200Response + | LoadTestRunListMetricDimensionValuesDefaultResponse + | LoadTestRunCreateOrUpdateAppComponents200Response + | LoadTestRunCreateOrUpdateAppComponents201Response + | LoadTestRunCreateOrUpdateAppComponentsDefaultResponse + | LoadTestRunGetAppComponents200Response + | LoadTestRunGetAppComponentsDefaultResponse + | LoadTestRunCreateOrUpdateServerMetricsConfig200Response + | LoadTestRunCreateOrUpdateServerMetricsConfig201Response + | LoadTestRunCreateOrUpdateServerMetricsConfigDefaultResponse + | LoadTestRunGetServerMetricsConfig200Response + | LoadTestRunGetServerMetricsConfigDefaultResponse + | TestProfileAdministrationCreateOrUpdateTestProfile200Response + | TestProfileAdministrationCreateOrUpdateTestProfile201Response + | TestProfileAdministrationCreateOrUpdateTestProfileDefaultResponse + | TestProfileAdministrationDeleteTestProfile204Response + | TestProfileAdministrationDeleteTestProfileDefaultResponse + | TestProfileAdministrationGetTestProfile200Response + | TestProfileAdministrationGetTestProfileDefaultResponse + | TestProfileAdministrationListTestProfiles200Response + | TestProfileAdministrationListTestProfilesDefaultResponse + | TestProfileRunAdministrationGetTestProfileRun200Response + | TestProfileRunAdministrationGetTestProfileRunDefaultResponse + | TestProfileRunAdministrationCreateOrUpdateTestProfileRun200Response + | TestProfileRunAdministrationCreateOrUpdateTestProfileRun201Response + | TestProfileRunAdministrationCreateOrUpdateTestProfileRunDefaultResponse + | TestProfileRunAdministrationDeleteTestProfileRun204Response + | TestProfileRunAdministrationDeleteTestProfileRunDefaultResponse + | TestProfileRunAdministrationStopTestProfileRun200Response + | TestProfileRunAdministrationStopTestProfileRunDefaultResponse + | TestProfileRunAdministrationListTestProfileRuns200Response + | TestProfileRunAdministrationListTestProfileRunsDefaultResponse, ): response is - | TestCreateOrUpdateDefaultResponse - | TestDeleteDefaultResponse - | TestGetDefaultResponse - | TestListDefaultResponse - | TestUploadFileDefaultResponse - | TestGetFileDefaultResponse - | TestDeleteFileDefaultResponse - | TestListFilesDefaultResponse - | TestCreateOrUpdateAppComponentsDefaultResponse - | TestListAppComponentsDefaultResponse - | TestCreateOrUpdateServerMetricsConfigDefaultResponse - | TestListServerMetricsConfigDefaultResponse - | TestRunDeleteDefaultResponse - | TestRunCreateOrUpdateDefaultResponse - | TestRunGetDefaultResponse - | TestRunGetFileDefaultResponse - | TestRunListDefaultResponse - | TestRunStopDefaultResponse - | TestRunListMetricNamespacesDefaultResponse - | TestRunListMetricDefinitionsDefaultResponse - | TestRunListMetricsDefaultResponse - | TestRunListMetricDimensionValuesDefaultResponse - | TestRunCreateOrUpdateAppComponentsDefaultResponse - | TestRunListAppComponentsDefaultResponse - | TestRunCreateOrUpdateServerMetricsConfigDefaultResponse - | TestRunListServerMetricsConfigDefaultResponse { + | LoadTestAdministrationCreateOrUpdateTestDefaultResponse + | LoadTestAdministrationDeleteTestDefaultResponse + | LoadTestAdministrationGetTestDefaultResponse + | LoadTestAdministrationListTestsDefaultResponse + | LoadTestAdministrationUploadTestFileDefaultResponse + | LoadTestAdministrationGetTestFileDefaultResponse + | LoadTestAdministrationDeleteTestFileDefaultResponse + | LoadTestAdministrationListTestFilesDefaultResponse + | LoadTestAdministrationCreateOrUpdateAppComponentsDefaultResponse + | LoadTestAdministrationGetAppComponentsDefaultResponse + | LoadTestAdministrationCreateOrUpdateServerMetricsConfigDefaultResponse + | LoadTestAdministrationGetServerMetricsConfigDefaultResponse + | LoadTestRunGetTestRunDefaultResponse + | LoadTestRunCreateOrUpdateTestRunDefaultResponse + | LoadTestRunDeleteTestRunDefaultResponse + | LoadTestRunListTestRunsDefaultResponse + | LoadTestRunGetTestRunFileDefaultResponse + | LoadTestRunStopTestRunDefaultResponse + | LoadTestRunListMetricNamespacesDefaultResponse + | LoadTestRunListMetricDefinitionsDefaultResponse + | LoadTestRunListMetricsDefaultResponse + | LoadTestRunListMetricDimensionValuesDefaultResponse + | LoadTestRunCreateOrUpdateAppComponentsDefaultResponse + | LoadTestRunGetAppComponentsDefaultResponse + | LoadTestRunCreateOrUpdateServerMetricsConfigDefaultResponse + | LoadTestRunGetServerMetricsConfigDefaultResponse + | TestProfileAdministrationCreateOrUpdateTestProfileDefaultResponse + | TestProfileAdministrationDeleteTestProfileDefaultResponse + | TestProfileAdministrationGetTestProfileDefaultResponse + | TestProfileAdministrationListTestProfilesDefaultResponse + | TestProfileRunAdministrationGetTestProfileRunDefaultResponse + | TestProfileRunAdministrationCreateOrUpdateTestProfileRunDefaultResponse + | TestProfileRunAdministrationDeleteTestProfileRunDefaultResponse + | TestProfileRunAdministrationStopTestProfileRunDefaultResponse + | TestProfileRunAdministrationListTestProfileRunsDefaultResponse { const lroOriginal = response.headers["x-ms-original-url"]; const url = new URL(lroOriginal ?? response.request.url); const method = response.request.method; let pathDetails = responseMap[`${method} ${url.pathname}`]; if (!pathDetails) { - pathDetails = geParametrizedPathSuccess(method, url.pathname); + pathDetails = getParametrizedPathSuccess(method, url.pathname); } return !pathDetails.includes(response.status); } -function geParametrizedPathSuccess(method: string, path: string): string[] { +function getParametrizedPathSuccess(method: string, path: string): string[] { const pathParts = path.split("/"); + // Traverse list to match the longest candidate + // matchedLen: the length of candidate path + // matchedValue: the matched status code array + let matchedLen = -1, + matchedValue: string[] = []; + // Iterate the responseMap to find a match for (const [key, value] of Object.entries(responseMap)) { // Extracting the path from the map key which is in format @@ -302,43 +449,52 @@ function geParametrizedPathSuccess(method: string, path: string): string[] { // Get each part of the url path const candidateParts = candidatePath.split("/"); - // If the candidate and actual paths don't match in size - // we move on to the next candidate path - if (candidateParts.length === pathParts.length && hasParametrizedPath(key)) { - // track if we have found a match to return the values found. - let found = true; - for (let i = 0; i < candidateParts.length; i++) { - if (candidateParts[i]?.startsWith("{") && candidateParts[i]?.endsWith("}")) { - // If the current part of the candidate is a "template" part - // it is a match with the actual path part on hand - // skip as the parameterized part can match anything - continue; - } + // track if we have found a match to return the values found. + let found = true; + for ( + let i = candidateParts.length - 1, j = pathParts.length - 1; + i >= 1 && j >= 1; + i--, j-- + ) { + if ( + candidateParts[i]?.startsWith("{") && + candidateParts[i]?.indexOf("}") !== -1 + ) { + const start = candidateParts[i]!.indexOf("}") + 1, + end = candidateParts[i]?.length; + // If the current part of the candidate is a "template" part + // Try to use the suffix of pattern to match the path + // {guid} ==> $ + // {guid}:export ==> :export$ + const isMatched = new RegExp( + `${candidateParts[i]?.slice(start, end)}`, + ).test(pathParts[j] || ""); - // If the candidate part is not a template and - // the parts don't match mark the candidate as not found - // to move on with the next candidate path. - if (candidateParts[i] !== pathParts[i]) { + if (!isMatched) { found = false; break; } + continue; } - // We finished evaluating the current candidate parts - // if all parts matched we return the success values form - // the path mapping. - if (found) { - return value; + // If the candidate part is not a template and + // the parts don't match mark the candidate as not found + // to move on with the next candidate path. + if (candidateParts[i] !== pathParts[j]) { + found = false; + break; } } - } - // No match was found, return an empty array. - return []; -} + // We finished evaluating the current candidate parts + // Update the matched value if and only if we found the longer pattern + if (found && candidatePath.length > matchedLen) { + matchedLen = candidatePath.length; + matchedValue = value; + } + } -function hasParametrizedPath(path: string): boolean { - return path.includes("/{"); + return matchedValue; } function getPathFromMapKey(mapKey: string): string { diff --git a/sdk/loadtesting/load-testing-rest/src/logger.ts b/sdk/loadtesting/load-testing-rest/src/logger.ts new file mode 100644 index 000000000000..31a2389c94d0 --- /dev/null +++ b/sdk/loadtesting/load-testing-rest/src/logger.ts @@ -0,0 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { createClientLogger } from "@azure/logger"; +export const logger = createClientLogger("load-testing"); diff --git a/sdk/loadtesting/load-testing-rest/src/models.ts b/sdk/loadtesting/load-testing-rest/src/models.ts index a892154e0bee..1810c2692588 100644 --- a/sdk/loadtesting/load-testing-rest/src/models.ts +++ b/sdk/loadtesting/load-testing-rest/src/models.ts @@ -1,49 +1,46 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { OperationState, SimplePollerLike } from "@azure/core-lro"; -import { - TestGetFile200Response, - TestRunCreateOrUpdate200Response, - TestRunCreateOrUpdate201Response, - TestRunGet200Response, - TestUploadFile201Response, -} from "./responses"; - -/** Load test model */ +/** Load test model. */ export interface Test { /** Pass fail criteria for a test. */ passFailCriteria?: PassFailCriteria; - /** Secrets can be stored in an Azure Key Vault or any other secret store. If the secret is stored in an Azure Key Vault, the value should be the secret identifier and the type should be AKV_SECRET_URI. If the secret is stored elsewhere, the secret value should be provided directly and the type should be SECRET_VALUE. */ + /** Auto stop criteria for a test. This will automatically stop a load test if the error percentage is high for a certain time window. */ + autoStopCriteria?: AutoStopCriteria; + /** + * Secrets can be stored in an Azure Key Vault or any other secret store. If the + * secret is stored in an Azure Key Vault, the value should be the secret + * identifier and the type should be AKV_SECRET_URI. If the secret is stored + * elsewhere, the secret value should be provided directly and the type should be + * SECRET_VALUE. + */ secrets?: Record; - /** Certificates metadata */ + /** Certificates metadata. */ certificate?: CertificateMetadata; /** Environment variables which are defined as a set of pairs. */ environmentVariables?: Record; /** The load test configuration. */ loadTestConfiguration?: LoadTestConfiguration; - /** The input artifacts for the test. */ - inputArtifacts?: TestInputArtifacts; - /** Unique test name as identifier. */ - testId?: string; + /** Id of the test run to be marked as baseline to view trends of client-side metrics from recent test runs */ + baselineTestRunId?: string; /** The test description. */ description?: string; /** Display name of a test. */ displayName?: string; /** Subnet ID on which the load test instances should run. */ subnetId?: string; + /** + * Kind of test. + * + * Possible values: "URL", "JMX", "Locust" + */ + kind?: TestKind; + /** Inject load test engines without deploying public IP for outbound access */ + publicIPDisabled?: boolean; /** Type of the managed identity referencing the Key vault. */ keyvaultReferenceIdentityType?: string; /** Resource Id of the managed identity referencing the Key vault. */ keyvaultReferenceIdentityId?: string; - /** The creation datetime(ISO 8601 literal format). */ - createdDateTime?: Date | string; - /** The user that created. */ - createdBy?: string; - /** The last Modified datetime(ISO 8601 literal format). */ - lastModifiedDateTime?: Date | string; - /** The user that last modified. */ - lastModifiedBy?: string; } /** Pass fail criteria for a test. */ @@ -54,155 +51,182 @@ export interface PassFailCriteria { /** Pass fail metric */ export interface PassFailMetric { - /** The client metric on which the criteria should be applied. */ - clientMetric?: "response_time_ms" | "latency" | "error" | "requests" | "requests_per_sec"; - /** The aggregation function to be applied on the client metric. Allowed functions - ‘percentage’ - for error metric , ‘avg’, ‘p50’, ‘p90’, ‘p95’, ‘p99’, ‘min’, ‘max’ - for response_time_ms and latency metric, ‘avg’ - for requests_per_sec, ‘count’ - for requests */ - aggregate?: "count" | "percentage" | "avg" | "p50" | "p90" | "p95" | "p99" | "min" | "max"; + /** + * The client metric on which the criteria should be applied. + * + * Possible values: "response_time_ms", "latency", "error", "requests", "requests_per_sec" + */ + clientMetric?: PFMetrics; + /** + * The aggregation function to be applied on the client metric. Allowed functions + * - ‘percentage’ - for error metric , ‘avg’, percentiles like ‘p50’, ‘p90’, & so on, ‘min’, + * ‘max’ - for response_time_ms and latency metric, ‘avg’ - for requests_per_sec, + * ‘count’ - for requests + * + * Possible values: "count", "percentage", "avg", "p50", "p75", "p90", "p95", "p96", "p97", "p98", "p99", "p99.9", "p99.99", "min", "max" + */ + aggregate?: PFAgFunc; /** The comparison operator. Supported types ‘>’, ‘<’ */ condition?: string; /** Request name for which the Pass fail criteria has to be applied */ requestName?: string; - /** The value to compare with the client metric. Allowed values - ‘error : [0.0 , 100.0] unit- % ’, response_time_ms and latency : any integer value unit- ms. */ + /** + * The value to compare with the client metric. Allowed values - ‘error : [0.0 , + * 100.0] unit- % ’, response_time_ms and latency : any integer value unit- ms. + */ value?: number; - /** Action taken after the threshold is met. Default is ‘continue’. */ - action?: "stop" | "continue"; - /** The actual value of the client metric for the test run. */ - actualValue?: number; - /** Outcome of the test run. */ - result?: "passed" | "undetermined" | "failed"; + /** + * Action taken after the threshold is met. Default is ‘continue’. + * + * Possible values: "continue", "stop" + */ + action?: PFAction; +} + +/** Auto stop criteria for a test. This will automatically stop a load test if the error percentage is high for a certain time window. */ +export interface AutoStopCriteria { + /** Whether auto-stop should be disabled. The default value is false. */ + autoStopDisabled?: boolean; + /** Threshold percentage of errors on which test run should be automatically stopped. Allowed values are in range of 0.0-100.0 */ + errorRate?: number; + /** Time window during which the error percentage should be evaluated in seconds. */ + errorRateTimeWindowInSeconds?: number; } /** Secret */ export interface Secret { /** The value of the secret for the respective type */ value?: string; - /** Type of secret */ - type?: "AKV_SECRET_URI" | "SECRET_VALUE"; + /** + * Type of secret + * + * Possible values: "AKV_SECRET_URI", "SECRET_VALUE" + */ + type?: SecretType; } /** Certificates metadata */ export interface CertificateMetadata { /** The value of the certificate for respective type */ value?: string; - /** Type of certificate */ - type?: "AKV_CERT_URI"; + /** + * Type of certificate + * + * Possible values: "AKV_CERT_URI" + */ + type?: CertificateType; /** Name of the certificate. */ name?: string; } -/** The load test configuration. */ +/** Configurations for the load test. */ export interface LoadTestConfiguration { - /** The number of engine instances to execute load test. Supported values are in range of 1-45. Required for creating a new test. */ + /** The number of engine instances to execute load test. Supported values are in range of 1-400. Required for creating a new test. */ engineInstances?: number; - /** If false, Azure Load Testing copies and processes your input files unmodified across all test engine instances. If true, Azure Load Testing splits the CSV input data evenly across all engine instances. If you provide multiple CSV files, each file will be split evenly. */ + /** + * If false, Azure Load Testing copies and processes your input files unmodified + * across all test engine instances. If true, Azure Load Testing splits the CSV + * input data evenly across all engine instances. If you provide multiple CSV + * files, each file will be split evenly. + */ splitAllCSVs?: boolean; - /** If true, optionalLoadTestConfig is required and JMX script for the load test is not required to upload. */ + /** + * If true, optionalLoadTestConfig is required and JMX script for the load test is + * not required to upload. + */ quickStartTest?: boolean; - /** Optional load test config */ + /** Configuration for quick load test */ optionalLoadTestConfig?: OptionalLoadTestConfig; + /** Region distribution configuration for the load test. */ + regionalLoadTestConfig?: Array; } -/** Optional load test config */ +/** Configuration for quick load test */ export interface OptionalLoadTestConfig { - /** Test URL. Provide the complete HTTP URL. For example, http://contoso-app.azurewebsites.net/login */ + /** Test URL. Provide the complete HTTP URL. For example, https://contoso-app.azurewebsites.net/login */ endpointUrl?: string; - /** No of concurrent virtual users */ + /** Target throughput (requests per second). This may not be necessarily achieved. The actual throughput will be lower if the application is not capable of handling it. */ + requestsPerSecond?: number; + /** Maximum response time in milliseconds of the API/endpoint. */ + maxResponseTimeInMs?: number; + /** No of concurrent virtual users. */ virtualUsers?: number; - /** Ramp up time */ + /** Ramp up time in seconds. */ rampUpTime?: number; - /** Test run duration */ + /** Test run duration in seconds. */ duration?: number; } +/** Region distribution configuration for the load test. */ +export interface RegionalConfiguration { + /** The number of engine instances to execute load test in specified region. Supported values are in range of 1-400. */ + engineInstances: number; + /** + * Azure region name. + * The region name should of format accepted by ARM, and should be a region supported by Azure Load Testing. For example, East US should be passed as "eastus". + * The region name must match one of the strings in the "Name" column returned from running the "az account list-locations -o table" Azure CLI command. + */ + region: string; +} + /** The input artifacts for the test. */ export interface TestInputArtifacts { /** File info */ - configFileInfo?: FileInfo; + configFileInfo?: TestFileInfo; /** File info */ - testScriptFileInfo?: FileInfo; + testScriptFileInfo?: TestFileInfo; /** File info */ - userPropFileInfo?: FileInfo; + userPropFileInfo?: TestFileInfo; /** File info */ - inputArtifactsZipFileInfo?: FileInfo; - /** Additional supported files for the test run */ - additionalFileInfo?: Array; + inputArtifactsZipFileInfo?: TestFileInfo; + /** The config json file for url based test */ + urlTestConfigFileInfo?: TestFileInfo; } -/** File info */ -export interface FileInfo { - /** File URL. */ - url?: string; +/** Test file info. */ +export interface TestFileInfo { /** Name of the file. */ - fileName?: string; - /** File type */ - fileType?: "JMX_FILE" | "USER_PROPERTIES" | "ADDITIONAL_ARTIFACTS"; - /** Expiry time of the file (ISO 8601 literal format) */ - expireDateTime?: Date | string; - /** Validation status of the file */ - validationStatus?: - | "NOT_VALIDATED" - | "VALIDATION_SUCCESS" - | "VALIDATION_FAILURE" - | "VALIDATION_INITIATED" - | "VALIDATION_NOT_REQUIRED"; - /** Validation failure error details */ - validationFailureDetails?: string; -} - -/** Test app component */ + fileName: string; +} + +/** Test app components */ export interface TestAppComponents { - /** Azure resource collection { resource id (fully qualified resource Id e.g subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) : resource object } */ + /** + * Azure resource collection { resource id (fully qualified resource Id e.g + * subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) + * : resource object } + */ components: Record; - /** Test identifier */ - testId?: string; - /** The creation datetime(ISO 8601 literal format). */ - createdDateTime?: Date | string; - /** The user that created. */ - createdBy?: string; - /** The last Modified datetime(ISO 8601 literal format). */ - lastModifiedDateTime?: Date | string; - /** The user that last modified. */ - lastModifiedBy?: string; } -/** An Azure resource object (Refer azure generic resource model : https://docs.microsoft.com/en-us/rest/api/resources/resources/get-by-id#genericresource) */ +/** An Azure resource object (Refer azure generic resource model :https://docs.microsoft.com/en-us/rest/api/resources/resources/get-by-id#genericresource) */ export interface AppComponent { - /** fully qualified resource Id e.g subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName} */ - resourceId?: string; /** Azure resource name, required while creating the app component. */ - resourceName?: string; + resourceName: string; /** Azure resource type, required while creating the app component. */ - resourceType?: string; + resourceType: string; /** Azure resource display name */ displayName?: string; - /** Resource group name of the Azure resource */ - resourceGroup?: string; - /** Subscription Id of the Azure resource */ - subscriptionId?: string; /** Kind of Azure resource type */ kind?: string; } /** Test server metrics configuration */ export interface TestServerMetricConfig { - /** Test identifier */ - testId?: string; - /** Azure resource metrics collection {metric id : metrics object} (Refer : https://docs.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition for metric id). */ - metrics?: Record; - /** The creation datetime(ISO 8601 literal format). */ - createdDateTime?: Date | string; - /** The user that created. */ - createdBy?: string; - /** The last Modified datetime(ISO 8601 literal format). */ - lastModifiedDateTime?: Date | string; - /** The user that last modified. */ - lastModifiedBy?: string; + /** + * Azure resource metrics collection {metric id : metrics object} (Refer : + * https://docs.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition + * for metric id). + */ + metrics: Record; } -/** Associated metric definition for particular metrics of the azure resource ( Refer : https://docs.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition). */ +/** + * Associated metric definition for particular metrics of the azure resource ( + * Refer : + * https://docs.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition). + */ export interface ResourceMetric { - /** Unique name for metric. */ - id?: string; /** Azure resource id. */ resourceId: string; /** Metric name space. */ @@ -223,114 +247,46 @@ export interface ResourceMetric { export interface TestRun { /** Pass fail criteria for a test. */ passFailCriteria?: PassFailCriteria; - /** Secrets can be stored in an Azure Key Vault or any other secret store. If the secret is stored in an Azure Key Vault, the value should be the secret identifier and the type should be AKV_SECRET_URI. If the secret is stored elsewhere, the secret value should be provided directly and the type should be SECRET_VALUE. */ + /** Auto stop criteria for a test. This will automatically stop a load test if the error percentage is high for a certain time window. */ + autoStopCriteria?: AutoStopCriteria; + /** + * Secrets can be stored in an Azure Key Vault or any other secret store. If the + * secret is stored in an Azure Key Vault, the value should be the secret + * identifier and the type should be AKV_SECRET_URI. If the secret is stored + * elsewhere, the secret value should be provided directly and the type should be + * SECRET_VALUE. + */ secrets?: Record; /** Certificates metadata */ certificate?: CertificateMetadata; /** Environment variables which are defined as a set of pairs. */ environmentVariables?: Record; - /** Error details if there is any failure in load test run */ - errorDetails?: Array; - /** Test run statistics. */ - testRunStatistics?: Record; /** The load test configuration. */ loadTestConfiguration?: LoadTestConfiguration; - /** Collection of test run artifacts */ - testArtifacts?: TestRunArtifacts; - /** Test result for pass/Fail criteria used during the test run. */ - testResult?: "PASSED" | "NOT_APPLICABLE" | "FAILED"; - /** Number of virtual users, for which test has been run. */ - virtualUsers?: number; - /** Unique test run name as identifier */ - testRunId?: string; /** Display name of a testRun. */ displayName?: string; /** Associated test Id. */ testId?: string; /** The test run description. */ description?: string; - /** The test run status. */ - status?: - | "ACCEPTED" - | "NOTSTARTED" - | "PROVISIONING" - | "PROVISIONED" - | "CONFIGURING" - | "CONFIGURED" - | "EXECUTING" - | "EXECUTED" - | "DEPROVISIONING" - | "DEPROVISIONED" - | "DONE" - | "CANCELLING" - | "CANCELLED" - | "FAILED" - | "VALIDATION_SUCCESS" - | "VALIDATION_FAILURE"; - /** The test run start DateTime(ISO 8601 literal format). */ - startDateTime?: Date | string; - /** The test run end DateTime(ISO 8601 literal format). */ - endDateTime?: Date | string; - /** Test run initiated time. */ - executedDateTime?: Date | string; - /** Portal url. */ - portalUrl?: string; - /** Test run duration in milliseconds. */ - duration?: number; - /** Subnet ID on which the load test instances should run. */ - subnetId?: string; - /** The creation datetime(ISO 8601 literal format). */ - createdDateTime?: Date | string; - /** The user that created. */ - createdBy?: string; - /** The last Modified datetime(ISO 8601 literal format). */ - lastModifiedDateTime?: Date | string; - /** The user that last modified. */ - lastModifiedBy?: string; + /** + * Request data collection level for test run + * + * Possible values: "NONE", "ERRORS" + */ + requestDataLevel?: RequestDataLevel; + /** Enable or disable debug level logging. True if debug logs are enabled for the test run. False otherwise */ + debugLogsEnabled?: boolean; } /** Error details if there is any failure in load test run */ -export interface ErrorDetails { - /** Error details in case test run was not successfully run. */ - message?: string; -} +export interface ErrorDetails {} /** Test run statistics. */ -export interface TestRunStatistics { - /** Transaction name. */ - transaction?: string; - /** Sampler count. */ - sampleCount?: number; - /** Error count. */ - errorCount?: number; - /** Error percentage. */ - errorPct?: number; - /** Mean response time. */ - meanResTime?: number; - /** Median response time. */ - medianResTime?: number; - /** Max response time. */ - maxResTime?: number; - /** Minimum response time. */ - minResTime?: number; - /** 90 percentile response time. */ - pct1ResTime?: number; - /** 95 percentile response time. */ - pct2ResTime?: number; - /** 99 percentile response time. */ - pct3ResTime?: number; - /** Throughput. */ - throughput?: number; - /** Received network bytes. */ - receivedKBytesPerSec?: number; - /** Send network bytes. */ - sentKBytesPerSec?: number; -} +export interface TestRunStatistics {} /** Collection of test run artifacts */ export interface TestRunArtifacts { - /** The input artifacts for the test run. */ - inputArtifacts?: TestRunInputArtifacts; /** The output artifacts for the test run. */ outputArtifacts?: TestRunOutputArtifacts; } @@ -338,28 +294,51 @@ export interface TestRunArtifacts { /** The input artifacts for the test run. */ export interface TestRunInputArtifacts { /** File info */ - configFileInfo?: FileInfo; + configFileInfo?: TestRunFileInfo; /** File info */ - testScriptFileInfo?: FileInfo; + testScriptFileInfo?: TestRunFileInfo; /** File info */ - userPropFileInfo?: FileInfo; + userPropFileInfo?: TestRunFileInfo; /** File info */ - inputArtifactsZipFileInfo?: FileInfo; - /** Additional supported files for the test run */ - additionalFileInfo?: Array; + inputArtifactsZipFileInfo?: TestRunFileInfo; + /** The config json file for url based test */ + urlTestConfigFileInfo?: TestRunFileInfo; +} + +/** Test run file info. */ +export interface TestRunFileInfo { + /** Name of the file. */ + fileName: string; } /** The output artifacts for the test run. */ export interface TestRunOutputArtifacts { /** File info */ - resultFileInfo?: FileInfo; + resultFileInfo?: TestRunFileInfo; /** File info */ - logsFileInfo?: FileInfo; + logsFileInfo?: TestRunFileInfo; + /** The container for test run artifacts. */ + artifactsContainerInfo?: ArtifactsContainerInfo; + /** The report file for the test run. */ + reportFileInfo?: TestRunFileInfo; +} + +/** Artifacts container info. */ +export interface ArtifactsContainerInfo { + /** This is a SAS URI to an Azure Storage Container that contains the test run artifacts. */ + url?: string; + /** Expiry time of the container (RFC 3339 literal format) */ + expireDateTime?: Date | string; } -/** Filters to fetch the set of metric */ +/** Filters to fetch the set of metric. */ export interface MetricRequestPayload { - /** Get metrics for specific dimension values. Example: Metric contains dimension like SamplerName, Error. To retrieve all the time series data where SamplerName is equals to HTTPRequest1 or HTTPRequest2, the DimensionFilter value will be {"SamplerName", ["HTTPRequest1", "HTTPRequest2"} */ + /** + * Get metrics for specific dimension values. Example: Metric contains dimension + * like SamplerName, Error. To retrieve all the time series data where SamplerName + * is equals to HTTPRequest1 or HTTPRequest2, the DimensionFilter value will be + * {"SamplerName", ["HTTPRequest1", "HTTPRequest2"} + */ filters?: Array; } @@ -368,63 +347,137 @@ export interface DimensionFilter { /** The dimension name */ name?: string; /** The dimension values. Maximum values can be 20. */ - values?: Array; + values?: string[]; } /** Test run app component */ export interface TestRunAppComponents { - /** Azure resource collection { resource id (fully qualified resource Id e.g subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) : resource object } */ + /** + * Azure resource collection { resource id (fully qualified resource Id e.g + * subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) + * : resource object } + */ components: Record; - /** Test run identifier */ - testRunId?: string; - /** The creation datetime(ISO 8601 literal format). */ - createdDateTime?: Date | string; - /** The user that created. */ - createdBy?: string; - /** The last Modified datetime(ISO 8601 literal format). */ - lastModifiedDateTime?: Date | string; - /** The user that last modified. */ - lastModifiedBy?: string; } /** Test run server metrics configuration */ export interface TestRunServerMetricConfig { - /** Test run identifier */ - testRunId?: string; - /** Azure resource metrics collection {metric id : metrics object} (Refer : https://docs.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition for metric id). */ + /** + * Azure resource metrics collection {metric id : metrics object} (Refer : + * https://docs.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition + * for metric id). + */ metrics?: Record; - /** The creation datetime(ISO 8601 literal format). */ - createdDateTime?: Date | string; - /** The user that created. */ - createdBy?: string; - /** The last Modified datetime(ISO 8601 literal format). */ - lastModifiedDateTime?: Date | string; - /** The user that last modified. */ - lastModifiedBy?: string; } -/** - * Describes a poller for NotificationHubJob types. - */ -export type FileUploadAndValidatePoller = SimplePollerLike< - OperationState, - TestGetFile200Response ->; +/** The Test Profile Model. A Test Profile resource enables you to set up a test profile which contains various configurations for a supported resource type and a load test to execute on that resource. */ +export interface TestProfile { + /** Display name of the test profile. */ + displayName?: string; + /** Description for the test profile. */ + description?: string; + /** Associated test ID for the test profile. This property is required for creating a Test Profile and it's not allowed to be updated. */ + testId?: string; + /** Target resource ID on which the test profile is created. This property is required for creating a Test Profile and it's not allowed to be updated. */ + targetResourceId?: string; + /** Configurations of the target resource on which testing would be done. */ + targetResourceConfigurations?: TargetResourceConfigurations; +} -export type TestRunCompletionPoller = SimplePollerLike< - OperationState, - TestRunGet200Response ->; +/** Configurations of a target resource. This varies with the kind of resource. */ +export interface TargetResourceConfigurationsParent { + kind: ResourceKind; +} -export type TestRunCreateOrUpdateSuccessResponse = - | TestRunCreateOrUpdate200Response - | TestRunCreateOrUpdate201Response; +/** Configurations for a Function App using Flex Consumption Plan. */ +export interface FunctionFlexConsumptionTargetResourceConfigurations + extends TargetResourceConfigurationsParent { + /** + * The kind value to use when providing configuration. + * This should typically be not changed from its value. + */ + kind: "FunctionsFlexConsumption"; + /** A map of configurations for a Function app using Flex Consumption Plan. */ + configurations?: Record; +} -export type TestUploadFileSuccessResponse = TestUploadFile201Response; +/** Resource configuration instance for a Flex Consumption based Azure Function App. */ +export interface FunctionFlexConsumptionResourceConfiguration { + /** Memory size of the instance. Supported values are 2048, 4096. */ + instanceMemoryMB: number; + /** HTTP Concurrency for the function app. */ + httpConcurrency: number; +} + +/** The Test Profile Run Model. Test Profile Run resource enables you to instantiate an already created test profile and run load tests to get recommendations on the optimal configuration for the target resource. */ +export interface TestProfileRun { + /** Display name for the test profile run. */ + displayName?: string; + /** The test profile run description */ + description?: string; + /** Associated test profile ID for the test profile run. This is required to create a test profile run and can't be updated. */ + testProfileId?: string; +} -export interface PolledOperationOptions { +/** Details of a particular test run for a test profile run. */ +export interface TestRunDetail { /** - * Time delay between poll requests, in milliseconds. + * Status of the test run. + * + * Possible values: "ACCEPTED", "NOTSTARTED", "PROVISIONING", "PROVISIONED", "CONFIGURING", "CONFIGURED", "EXECUTING", "EXECUTED", "DEPROVISIONING", "DEPROVISIONED", "DONE", "CANCELLING", "CANCELLED", "FAILED", "VALIDATION_SUCCESS", "VALIDATION_FAILURE" */ - updateIntervalInMs?: number; + status: Status; + /** ID of the configuration on which the test ran. */ + configurationId: string; + /** Key value pair of extra properties associated with the test run. */ + properties: Record; } + +/** A recommendation object that provides a list of configuration that optimizes its category. */ +export interface TestProfileRunRecommendation { + /** + * Category of the recommendation. + * + * Possible values: "ThroughputOptimized", "CostOptimized" + */ + category: RecommendationCategory; + /** List of configurations IDs for which the recommendation is applicable. These are a subset of the provided target resource configurations. */ + configurations?: string[]; +} + +/** Configurations of a target resource. This varies with the kind of resource. */ +export type TargetResourceConfigurations = + | TargetResourceConfigurationsParent + | FunctionFlexConsumptionTargetResourceConfigurations; +/** Alias for PFMetrics */ +export type PFMetrics = string; +/** Alias for PFAgFunc */ +export type PFAgFunc = string; +/** Alias for PFAction */ +export type PFAction = string; +/** Alias for PFResult */ +export type PFResult = string; +/** Alias for SecretType */ +export type SecretType = string; +/** Alias for CertificateType */ +export type CertificateType = string; +/** Alias for FileType */ +export type FileType = string; +/** Alias for FileStatus */ +export type FileStatus = string; +/** Alias for TestKind */ +export type TestKind = string; +/** Alias for PFTestResult */ +export type PFTestResult = string; +/** Alias for Status */ +export type Status = string; +/** Alias for RequestDataLevel */ +export type RequestDataLevel = string; +/** Alias for TimeGrain */ +export type TimeGrain = string; +/** Alias for ResourceKind */ +export type ResourceKind = string; +/** Alias for TestProfileRunStatus */ +export type TestProfileRunStatus = string; +/** Alias for RecommendationCategory */ +export type RecommendationCategory = string; diff --git a/sdk/loadtesting/load-testing-rest/src/outputModels.ts b/sdk/loadtesting/load-testing-rest/src/outputModels.ts index 3dbe80add481..cc2400534a0b 100644 --- a/sdk/loadtesting/load-testing-rest/src/outputModels.ts +++ b/sdk/loadtesting/load-testing-rest/src/outputModels.ts @@ -1,40 +1,60 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/** Load test model */ +import { Paged } from "@azure/core-paging"; + +/** Load test model. */ export interface TestOutput { /** Pass fail criteria for a test. */ passFailCriteria?: PassFailCriteriaOutput; - /** Secrets can be stored in an Azure Key Vault or any other secret store. If the secret is stored in an Azure Key Vault, the value should be the secret identifier and the type should be AKV_SECRET_URI. If the secret is stored elsewhere, the secret value should be provided directly and the type should be SECRET_VALUE. */ + /** Auto stop criteria for a test. This will automatically stop a load test if the error percentage is high for a certain time window. */ + autoStopCriteria?: AutoStopCriteriaOutput; + /** + * Secrets can be stored in an Azure Key Vault or any other secret store. If the + * secret is stored in an Azure Key Vault, the value should be the secret + * identifier and the type should be AKV_SECRET_URI. If the secret is stored + * elsewhere, the secret value should be provided directly and the type should be + * SECRET_VALUE. + */ secrets?: Record; - /** Certificates metadata */ + /** Certificates metadata. */ certificate?: CertificateMetadataOutput; /** Environment variables which are defined as a set of pairs. */ environmentVariables?: Record; /** The load test configuration. */ loadTestConfiguration?: LoadTestConfigurationOutput; + /** Id of the test run to be marked as baseline to view trends of client-side metrics from recent test runs */ + baselineTestRunId?: string; /** The input artifacts for the test. */ - inputArtifacts?: TestInputArtifactsOutput; - /** Unique test name as identifier. */ - testId?: string; + readonly inputArtifacts?: TestInputArtifactsOutput; + /** Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. */ + readonly testId: string; /** The test description. */ description?: string; /** Display name of a test. */ displayName?: string; /** Subnet ID on which the load test instances should run. */ subnetId?: string; + /** + * Kind of test. + * + * Possible values: "URL", "JMX", "Locust" + */ + kind?: TestKindOutput; + /** Inject load test engines without deploying public IP for outbound access */ + publicIPDisabled?: boolean; /** Type of the managed identity referencing the Key vault. */ keyvaultReferenceIdentityType?: string; /** Resource Id of the managed identity referencing the Key vault. */ keyvaultReferenceIdentityId?: string; - /** The creation datetime(ISO 8601 literal format). */ - createdDateTime?: string; + /** The creation datetime(RFC 3339 literal format). */ + readonly createdDateTime?: string; /** The user that created. */ - createdBy?: string; - /** The last Modified datetime(ISO 8601 literal format). */ - lastModifiedDateTime?: string; + readonly createdBy?: string; + /** The last Modified datetime(RFC 3339 literal format). */ + readonly lastModifiedDateTime?: string; /** The user that last modified. */ - lastModifiedBy?: string; + readonly lastModifiedBy?: string; } /** Pass fail criteria for a test. */ @@ -45,165 +65,206 @@ export interface PassFailCriteriaOutput { /** Pass fail metric */ export interface PassFailMetricOutput { - /** The client metric on which the criteria should be applied. */ - clientMetric?: "response_time_ms" | "latency" | "error" | "requests" | "requests_per_sec"; - /** The aggregation function to be applied on the client metric. Allowed functions - ‘percentage’ - for error metric , ‘avg’, ‘p50’, ‘p90’, ‘p95’, ‘p99’, ‘min’, ‘max’ - for response_time_ms and latency metric, ‘avg’ - for requests_per_sec, ‘count’ - for requests */ - aggregate?: "count" | "percentage" | "avg" | "p50" | "p90" | "p95" | "p99" | "min" | "max"; + /** + * The client metric on which the criteria should be applied. + * + * Possible values: "response_time_ms", "latency", "error", "requests", "requests_per_sec" + */ + clientMetric?: PFMetricsOutput; + /** + * The aggregation function to be applied on the client metric. Allowed functions + * - ‘percentage’ - for error metric , ‘avg’, percentiles like ‘p50’, ‘p90’, & so on, ‘min’, + * ‘max’ - for response_time_ms and latency metric, ‘avg’ - for requests_per_sec, + * ‘count’ - for requests + * + * Possible values: "count", "percentage", "avg", "p50", "p75", "p90", "p95", "p96", "p97", "p98", "p99", "p99.9", "p99.99", "min", "max" + */ + aggregate?: PFAgFuncOutput; /** The comparison operator. Supported types ‘>’, ‘<’ */ condition?: string; /** Request name for which the Pass fail criteria has to be applied */ requestName?: string; - /** The value to compare with the client metric. Allowed values - ‘error : [0.0 , 100.0] unit- % ’, response_time_ms and latency : any integer value unit- ms. */ + /** + * The value to compare with the client metric. Allowed values - ‘error : [0.0 , + * 100.0] unit- % ’, response_time_ms and latency : any integer value unit- ms. + */ value?: number; - /** Action taken after the threshold is met. Default is ‘continue’. */ - action?: "stop" | "continue"; + /** + * Action taken after the threshold is met. Default is ‘continue’. + * + * Possible values: "continue", "stop" + */ + action?: PFActionOutput; /** The actual value of the client metric for the test run. */ - actualValue?: number; - /** Outcome of the test run. */ - result?: "passed" | "undetermined" | "failed"; + readonly actualValue?: number; + /** + * Outcome of the test run. + * + * Possible values: "passed", "undetermined", "failed" + */ + readonly result?: PFResultOutput; +} + +/** Auto stop criteria for a test. This will automatically stop a load test if the error percentage is high for a certain time window. */ +export interface AutoStopCriteriaOutput { + /** Whether auto-stop should be disabled. The default value is false. */ + autoStopDisabled?: boolean; + /** Threshold percentage of errors on which test run should be automatically stopped. Allowed values are in range of 0.0-100.0 */ + errorRate?: number; + /** Time window during which the error percentage should be evaluated in seconds. */ + errorRateTimeWindowInSeconds?: number; } /** Secret */ export interface SecretOutput { /** The value of the secret for the respective type */ value?: string; - /** Type of secret */ - type?: "AKV_SECRET_URI" | "SECRET_VALUE"; + /** + * Type of secret + * + * Possible values: "AKV_SECRET_URI", "SECRET_VALUE" + */ + type?: SecretTypeOutput; } /** Certificates metadata */ export interface CertificateMetadataOutput { /** The value of the certificate for respective type */ value?: string; - /** Type of certificate */ - type?: "AKV_CERT_URI"; + /** + * Type of certificate + * + * Possible values: "AKV_CERT_URI" + */ + type?: CertificateTypeOutput; /** Name of the certificate. */ name?: string; } -/** The load test configuration. */ +/** Configurations for the load test. */ export interface LoadTestConfigurationOutput { - /** The number of engine instances to execute load test. Supported values are in range of 1-45. Required for creating a new test. */ + /** The number of engine instances to execute load test. Supported values are in range of 1-400. Required for creating a new test. */ engineInstances?: number; - /** If false, Azure Load Testing copies and processes your input files unmodified across all test engine instances. If true, Azure Load Testing splits the CSV input data evenly across all engine instances. If you provide multiple CSV files, each file will be split evenly. */ + /** + * If false, Azure Load Testing copies and processes your input files unmodified + * across all test engine instances. If true, Azure Load Testing splits the CSV + * input data evenly across all engine instances. If you provide multiple CSV + * files, each file will be split evenly. + */ splitAllCSVs?: boolean; - /** If true, optionalLoadTestConfig is required and JMX script for the load test is not required to upload. */ + /** + * If true, optionalLoadTestConfig is required and JMX script for the load test is + * not required to upload. + */ quickStartTest?: boolean; - /** Optional load test config */ + /** Configuration for quick load test */ optionalLoadTestConfig?: OptionalLoadTestConfigOutput; + /** Region distribution configuration for the load test. */ + regionalLoadTestConfig?: Array; } -/** Optional load test config */ +/** Configuration for quick load test */ export interface OptionalLoadTestConfigOutput { - /** Test URL. Provide the complete HTTP URL. For example, http://contoso-app.azurewebsites.net/login */ + /** Test URL. Provide the complete HTTP URL. For example, https://contoso-app.azurewebsites.net/login */ endpointUrl?: string; - /** No of concurrent virtual users */ + /** Target throughput (requests per second). This may not be necessarily achieved. The actual throughput will be lower if the application is not capable of handling it. */ + requestsPerSecond?: number; + /** Maximum response time in milliseconds of the API/endpoint. */ + maxResponseTimeInMs?: number; + /** No of concurrent virtual users. */ virtualUsers?: number; - /** Ramp up time */ + /** Ramp up time in seconds. */ rampUpTime?: number; - /** Test run duration */ + /** Test run duration in seconds. */ duration?: number; } +/** Region distribution configuration for the load test. */ +export interface RegionalConfigurationOutput { + /** The number of engine instances to execute load test in specified region. Supported values are in range of 1-400. */ + engineInstances: number; + /** + * Azure region name. + * The region name should of format accepted by ARM, and should be a region supported by Azure Load Testing. For example, East US should be passed as "eastus". + * The region name must match one of the strings in the "Name" column returned from running the "az account list-locations -o table" Azure CLI command. + */ + region: string; +} + /** The input artifacts for the test. */ export interface TestInputArtifactsOutput { /** File info */ - configFileInfo?: FileInfoOutput; + configFileInfo?: TestFileInfoOutput; /** File info */ - testScriptFileInfo?: FileInfoOutput; + testScriptFileInfo?: TestFileInfoOutput; /** File info */ - userPropFileInfo?: FileInfoOutput; + userPropFileInfo?: TestFileInfoOutput; /** File info */ - inputArtifactsZipFileInfo?: FileInfoOutput; + inputArtifactsZipFileInfo?: TestFileInfoOutput; + /** The config json file for url based test */ + urlTestConfigFileInfo?: TestFileInfoOutput; /** Additional supported files for the test run */ - additionalFileInfo?: Array; + readonly additionalFileInfo?: Array; } -/** File info */ -export interface FileInfoOutput { - /** File URL. */ - url?: string; +/** Test file info. */ +export interface TestFileInfoOutput { /** Name of the file. */ - fileName?: string; - /** File type */ - fileType?: "JMX_FILE" | "USER_PROPERTIES" | "ADDITIONAL_ARTIFACTS"; - /** Expiry time of the file (ISO 8601 literal format) */ - expireDateTime?: string; - /** Validation status of the file */ - validationStatus?: - | "NOT_VALIDATED" - | "VALIDATION_SUCCESS" - | "VALIDATION_FAILURE" - | "VALIDATION_INITIATED" - | "VALIDATION_NOT_REQUIRED"; + fileName: string; + /** File URL. */ + readonly url?: string; + /** + * File type + * + * Possible values: "JMX_FILE", "USER_PROPERTIES", "ADDITIONAL_ARTIFACTS", "ZIPPED_ARTIFACTS", "URL_TEST_CONFIG", "TEST_SCRIPT" + */ + readonly fileType?: FileTypeOutput; + /** Expiry time of the file (RFC 3339 literal format) */ + readonly expireDateTime?: string; + /** + * Validation status of the file + * + * Possible values: "NOT_VALIDATED", "VALIDATION_SUCCESS", "VALIDATION_FAILURE", "VALIDATION_INITIATED", "VALIDATION_NOT_REQUIRED" + */ + readonly validationStatus?: FileStatusOutput; /** Validation failure error details */ - validationFailureDetails?: string; -} - -/** The definition of an error object. */ -export interface ErrorResponseBodyOutput { - /** Error from a REST request. */ - error: ErrorModelOutput; + readonly validationFailureDetails?: string; } -/** Error from a REST request. */ -export interface ErrorModelOutput { - /** The error code. */ - code: string; - /** The error message. */ - message: string; - /** The error target. */ - target?: string; - /** Additional details and inner errors. */ - details?: Array; -} - -/** Collection of tests */ -export interface TestsListOutput { - /** List of tests */ - value: Array; - /** Link for the next list of tests in case of paginated results, if applicable */ - nextLink?: string; -} - -/** Collection of files. */ -export interface FileInfoListOutput { - /** List of file info. */ - value: Array; - /** Link for the next list of file URLs, if applicable */ - nextLink?: string; -} - -/** Test app component */ +/** Test app components */ export interface TestAppComponentsOutput { - /** Azure resource collection { resource id (fully qualified resource Id e.g subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) : resource object } */ + /** + * Azure resource collection { resource id (fully qualified resource Id e.g + * subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) + * : resource object } + */ components: Record; /** Test identifier */ - testId?: string; - /** The creation datetime(ISO 8601 literal format). */ - createdDateTime?: string; + readonly testId?: string; + /** The creation datetime(RFC 3339 literal format). */ + readonly createdDateTime?: string; /** The user that created. */ - createdBy?: string; - /** The last Modified datetime(ISO 8601 literal format). */ - lastModifiedDateTime?: string; + readonly createdBy?: string; + /** The last Modified datetime(RFC 3339 literal format). */ + readonly lastModifiedDateTime?: string; /** The user that last modified. */ - lastModifiedBy?: string; + readonly lastModifiedBy?: string; } -/** An Azure resource object (Refer azure generic resource model : https://docs.microsoft.com/en-us/rest/api/resources/resources/get-by-id#genericresource) */ +/** An Azure resource object (Refer azure generic resource model :https://docs.microsoft.com/en-us/rest/api/resources/resources/get-by-id#genericresource) */ export interface AppComponentOutput { /** fully qualified resource Id e.g subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName} */ - resourceId?: string; + readonly resourceId: string; /** Azure resource name, required while creating the app component. */ - resourceName?: string; + resourceName: string; /** Azure resource type, required while creating the app component. */ - resourceType?: string; + resourceType: string; /** Azure resource display name */ displayName?: string; /** Resource group name of the Azure resource */ - resourceGroup?: string; + readonly resourceGroup?: string; /** Subscription Id of the Azure resource */ - subscriptionId?: string; + readonly subscriptionId?: string; /** Kind of Azure resource type */ kind?: string; } @@ -211,23 +272,31 @@ export interface AppComponentOutput { /** Test server metrics configuration */ export interface TestServerMetricConfigOutput { /** Test identifier */ - testId?: string; - /** Azure resource metrics collection {metric id : metrics object} (Refer : https://docs.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition for metric id). */ - metrics?: Record; - /** The creation datetime(ISO 8601 literal format). */ - createdDateTime?: string; + readonly testId?: string; + /** + * Azure resource metrics collection {metric id : metrics object} (Refer : + * https://docs.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition + * for metric id). + */ + metrics: Record; + /** The creation datetime(RFC 3339 literal format). */ + readonly createdDateTime?: string; /** The user that created. */ - createdBy?: string; - /** The last Modified datetime(ISO 8601 literal format). */ - lastModifiedDateTime?: string; + readonly createdBy?: string; + /** The last Modified datetime(RFC 3339 literal format). */ + readonly lastModifiedDateTime?: string; /** The user that last modified. */ - lastModifiedBy?: string; + readonly lastModifiedBy?: string; } -/** Associated metric definition for particular metrics of the azure resource ( Refer : https://docs.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition). */ +/** + * Associated metric definition for particular metrics of the azure resource ( + * Refer : + * https://docs.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition). + */ export interface ResourceMetricOutput { /** Unique name for metric. */ - id?: string; + readonly id?: string; /** Azure resource id. */ resourceId: string; /** Metric name space. */ @@ -246,116 +315,154 @@ export interface ResourceMetricOutput { /** Load test run model */ export interface TestRunOutput { + /** Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. */ + readonly testRunId: string; /** Pass fail criteria for a test. */ passFailCriteria?: PassFailCriteriaOutput; - /** Secrets can be stored in an Azure Key Vault or any other secret store. If the secret is stored in an Azure Key Vault, the value should be the secret identifier and the type should be AKV_SECRET_URI. If the secret is stored elsewhere, the secret value should be provided directly and the type should be SECRET_VALUE. */ + /** Auto stop criteria for a test. This will automatically stop a load test if the error percentage is high for a certain time window. */ + autoStopCriteria?: AutoStopCriteriaOutput; + /** + * Secrets can be stored in an Azure Key Vault or any other secret store. If the + * secret is stored in an Azure Key Vault, the value should be the secret + * identifier and the type should be AKV_SECRET_URI. If the secret is stored + * elsewhere, the secret value should be provided directly and the type should be + * SECRET_VALUE. + */ secrets?: Record; /** Certificates metadata */ certificate?: CertificateMetadataOutput; /** Environment variables which are defined as a set of pairs. */ environmentVariables?: Record; /** Error details if there is any failure in load test run */ - errorDetails?: Array; - /** Test run statistics. */ - testRunStatistics?: Record; + readonly errorDetails?: Array; + /** + * Test run statistics. Key is the sampler name and value is the set of statistics for performance metrics like response time, throughput, etc. from the load test run. + * The sampler name is the same as the name mentioned in the test script. + * Sampler name "Total" represents the aggregated statistics of all the samplers. + */ + readonly testRunStatistics?: Record; + /** + * Regional statistics. Key is the Azure region name and value is the test run statistics. + * The region name should of format accepted by ARM, and should be a region supported by Azure Load Testing. For example, East US should be passed as "eastus". + * The region name must match one of the strings in the "Name" column returned from running the "az account list-locations -o table" Azure CLI command. + */ + readonly regionalStatistics?: Record; /** The load test configuration. */ loadTestConfiguration?: LoadTestConfigurationOutput; /** Collection of test run artifacts */ - testArtifacts?: TestRunArtifactsOutput; - /** Test result for pass/Fail criteria used during the test run. */ - testResult?: "PASSED" | "NOT_APPLICABLE" | "FAILED"; + readonly testArtifacts?: TestRunArtifactsOutput; + /** + * Test result for pass/Fail criteria used during the test run. + * + * Possible values: "PASSED", "NOT_APPLICABLE", "FAILED" + */ + readonly testResult?: PFTestResultOutput; /** Number of virtual users, for which test has been run. */ - virtualUsers?: number; - /** Unique test run name as identifier */ - testRunId?: string; + readonly virtualUsers?: number; /** Display name of a testRun. */ displayName?: string; /** Associated test Id. */ testId?: string; /** The test run description. */ description?: string; - /** The test run status. */ - status?: - | "ACCEPTED" - | "NOTSTARTED" - | "PROVISIONING" - | "PROVISIONED" - | "CONFIGURING" - | "CONFIGURED" - | "EXECUTING" - | "EXECUTED" - | "DEPROVISIONING" - | "DEPROVISIONED" - | "DONE" - | "CANCELLING" - | "CANCELLED" - | "FAILED" - | "VALIDATION_SUCCESS" - | "VALIDATION_FAILURE"; - /** The test run start DateTime(ISO 8601 literal format). */ - startDateTime?: string; - /** The test run end DateTime(ISO 8601 literal format). */ - endDateTime?: string; + /** + * The test run status. + * + * Possible values: "ACCEPTED", "NOTSTARTED", "PROVISIONING", "PROVISIONED", "CONFIGURING", "CONFIGURED", "EXECUTING", "EXECUTED", "DEPROVISIONING", "DEPROVISIONED", "DONE", "CANCELLING", "CANCELLED", "FAILED", "VALIDATION_SUCCESS", "VALIDATION_FAILURE" + */ + readonly status?: StatusOutput; + /** The test run start DateTime(RFC 3339 literal format). */ + readonly startDateTime?: string; + /** The test run end DateTime(RFC 3339 literal format). */ + readonly endDateTime?: string; /** Test run initiated time. */ - executedDateTime?: string; + readonly executedDateTime?: string; /** Portal url. */ - portalUrl?: string; + readonly portalUrl?: string; /** Test run duration in milliseconds. */ - duration?: number; + readonly duration?: number; /** Subnet ID on which the load test instances should run. */ - subnetId?: string; - /** The creation datetime(ISO 8601 literal format). */ - createdDateTime?: string; + readonly subnetId?: string; + /** + * Type of test. + * + * Possible values: "URL", "JMX", "Locust" + */ + readonly kind?: TestKindOutput; + /** + * Request data collection level for test run + * + * Possible values: "NONE", "ERRORS" + */ + requestDataLevel?: RequestDataLevelOutput; + /** Enable or disable debug level logging. True if debug logs are enabled for the test run. False otherwise */ + debugLogsEnabled?: boolean; + /** Inject load test engines without deploying public IP for outbound access */ + readonly publicIPDisabled?: boolean; + /** The creation datetime(RFC 3339 literal format). */ + readonly createdDateTime?: string; /** The user that created. */ - createdBy?: string; - /** The last Modified datetime(ISO 8601 literal format). */ - lastModifiedDateTime?: string; + readonly createdBy?: string; + /** The last Modified datetime(RFC 3339 literal format). */ + readonly lastModifiedDateTime?: string; /** The user that last modified. */ - lastModifiedBy?: string; + readonly lastModifiedBy?: string; } /** Error details if there is any failure in load test run */ export interface ErrorDetailsOutput { /** Error details in case test run was not successfully run. */ - message?: string; + readonly message?: string; } /** Test run statistics. */ export interface TestRunStatisticsOutput { /** Transaction name. */ - transaction?: string; + readonly transaction?: string; /** Sampler count. */ - sampleCount?: number; + readonly sampleCount?: number; /** Error count. */ - errorCount?: number; + readonly errorCount?: number; /** Error percentage. */ - errorPct?: number; + readonly errorPct?: number; /** Mean response time. */ - meanResTime?: number; + readonly meanResTime?: number; /** Median response time. */ - medianResTime?: number; + readonly medianResTime?: number; /** Max response time. */ - maxResTime?: number; + readonly maxResTime?: number; /** Minimum response time. */ - minResTime?: number; + readonly minResTime?: number; /** 90 percentile response time. */ - pct1ResTime?: number; + readonly pct1ResTime?: number; /** 95 percentile response time. */ - pct2ResTime?: number; + readonly pct2ResTime?: number; /** 99 percentile response time. */ - pct3ResTime?: number; + readonly pct3ResTime?: number; + /** 75 percentile response time. */ + readonly pct75ResTime?: number; + /** 96 percentile response time. */ + readonly pct96ResTime?: number; + /** 97 percentile response time. */ + readonly pct97ResTime?: number; + /** 98 percentile response time. */ + readonly pct98ResTime?: number; + /** 99.9 percentile response time. */ + readonly pct999ResTime?: number; + /** 99.99 percentile response time. */ + readonly pct9999ResTime?: number; /** Throughput. */ - throughput?: number; + readonly throughput?: number; /** Received network bytes. */ - receivedKBytesPerSec?: number; + readonly receivedKBytesPerSec?: number; /** Send network bytes. */ - sentKBytesPerSec?: number; + readonly sentKBytesPerSec?: number; } /** Collection of test run artifacts */ export interface TestRunArtifactsOutput { /** The input artifacts for the test run. */ - inputArtifacts?: TestRunInputArtifactsOutput; + readonly inputArtifacts?: TestRunInputArtifactsOutput; /** The output artifacts for the test run. */ outputArtifacts?: TestRunOutputArtifactsOutput; } @@ -363,31 +470,61 @@ export interface TestRunArtifactsOutput { /** The input artifacts for the test run. */ export interface TestRunInputArtifactsOutput { /** File info */ - configFileInfo?: FileInfoOutput; + configFileInfo?: TestRunFileInfoOutput; /** File info */ - testScriptFileInfo?: FileInfoOutput; + testScriptFileInfo?: TestRunFileInfoOutput; /** File info */ - userPropFileInfo?: FileInfoOutput; + userPropFileInfo?: TestRunFileInfoOutput; /** File info */ - inputArtifactsZipFileInfo?: FileInfoOutput; + inputArtifactsZipFileInfo?: TestRunFileInfoOutput; + /** The config json file for url based test */ + urlTestConfigFileInfo?: TestRunFileInfoOutput; /** Additional supported files for the test run */ - additionalFileInfo?: Array; + readonly additionalFileInfo?: Array; +} + +/** Test run file info. */ +export interface TestRunFileInfoOutput { + /** Name of the file. */ + fileName: string; + /** File URL. */ + readonly url?: string; + /** + * File type + * + * Possible values: "JMX_FILE", "USER_PROPERTIES", "ADDITIONAL_ARTIFACTS", "ZIPPED_ARTIFACTS", "URL_TEST_CONFIG", "TEST_SCRIPT" + */ + readonly fileType?: FileTypeOutput; + /** Expiry time of the file (RFC 3339 literal format) */ + readonly expireDateTime?: string; + /** + * Validation status of the file + * + * Possible values: "NOT_VALIDATED", "VALIDATION_SUCCESS", "VALIDATION_FAILURE", "VALIDATION_INITIATED", "VALIDATION_NOT_REQUIRED" + */ + readonly validationStatus?: FileStatusOutput; + /** Validation failure error details */ + readonly validationFailureDetails?: string; } /** The output artifacts for the test run. */ export interface TestRunOutputArtifactsOutput { /** File info */ - resultFileInfo?: FileInfoOutput; + resultFileInfo?: TestRunFileInfoOutput; /** File info */ - logsFileInfo?: FileInfoOutput; + logsFileInfo?: TestRunFileInfoOutput; + /** The container for test run artifacts. */ + artifactsContainerInfo?: ArtifactsContainerInfoOutput; + /** The report file for the test run. */ + reportFileInfo?: TestRunFileInfoOutput; } -/** Collection of test runs */ -export interface TestRunsListOutput { - /** List of test runs */ - value: Array; - /** Link for the next list of test runs in case of paginated results, if applicable */ - nextLink?: string; +/** Artifacts container info. */ +export interface ArtifactsContainerInfoOutput { + /** This is a SAS URI to an Azure Storage Container that contains the test run artifacts. */ + url?: string; + /** Expiry time of the container (RFC 3339 literal format) */ + expireDateTime?: string; } /** Represents collection of metric namespaces. */ @@ -420,28 +557,24 @@ export interface MetricDefinitionOutput { name?: string; /** The namespace the metric belongs to. */ namespace?: string; - /** The primary aggregation type value defining how to use the values for display. */ - primaryAggregationType?: - | "Average" - | "Count" - | "None" - | "Total" - | "Percentile90" - | "Percentile95" - | "Percentile99"; + /** + * The primary aggregation type value defining how to use the values for display. + * + * Possible values: "Average", "Count", "None", "Total", "Percentile75", "Percentile90", "Percentile95", "Percentile96", "Percentile97", "Percentile98", "Percentile99", "Percentile999", "Percentile9999" + */ + primaryAggregationType?: AggregationTypeOutput; /** The collection of what all aggregation types are supported. */ - supportedAggregationTypes?: Array; - /** The unit of the metric. */ - unit?: - | "NotSpecified" - | "Percent" - | "Count" - | "Seconds" - | "Milliseconds" - | "Bytes" - | "BytesPerSecond" - | "CountPerSecond"; - /** Metric availability specifies the time grain (aggregation interval or frequency). */ + supportedAggregationTypes?: string[]; + /** + * The unit of the metric. + * + * Possible values: "NotSpecified", "Percent", "Count", "Seconds", "Milliseconds", "Bytes", "BytesPerSecond", "CountPerSecond" + */ + unit?: MetricUnitOutput; + /** + * Metric availability specifies the time grain (aggregation interval or + * frequency). + */ metricAvailabilities?: Array; } @@ -455,16 +588,13 @@ export interface NameAndDescOutput { /** Metric availability specifies the time grain (aggregation interval or frequency) */ export interface MetricAvailabilityOutput { - /** The time grain specifies the aggregation interval for the metric. Expressed as a duration 'PT1M', 'PT1H', etc. */ - timeGrain?: "PT5S" | "PT10S" | "PT1M" | "PT5M" | "PT1H"; -} - -/** The response to a metrics query. */ -export interface MetricsOutput { - /** Timeseries data for metric query. */ - timeseries?: Array; - /** Link for the next set of timeseries in case of paginated results, if applicable */ - nextLink?: string; + /** + * The time grain specifies the aggregation interval for the metric. Expressed as + * a duration 'PT1M', 'PT1H', etc. + * + * Possible values: "PT5S", "PT10S", "PT1M", "PT5M", "PT1H" + */ + timeGrain?: TimeGrainOutput; } /** The time series returned when a data query is performed. */ @@ -477,7 +607,7 @@ export interface TimeSeriesElementOutput { /** Represents a metric value. */ export interface MetricValueOutput { - /** The timestamp for the metric value in ISO 8601 format. */ + /** The timestamp for the metric value in RFC 3339 format. */ timestamp?: string; /** The metric value. */ value?: number; @@ -493,40 +623,226 @@ export interface DimensionValueOutput { /** Metrics dimension values. */ export interface DimensionValueListOutput { - /** The dimension values */ - value?: Array; - /** Link for the next set of values in case of paginated results, if applicable */ + /** The dimension name */ + readonly name?: string; + /** The dimension value */ + value?: string[]; + /** Link for the next set of values in case of paginated results, if applicable. */ nextLink?: string; } /** Test run app component */ export interface TestRunAppComponentsOutput { - /** Azure resource collection { resource id (fully qualified resource Id e.g subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) : resource object } */ + /** + * Azure resource collection { resource id (fully qualified resource Id e.g + * subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) + * : resource object } + */ components: Record; /** Test run identifier */ - testRunId?: string; - /** The creation datetime(ISO 8601 literal format). */ - createdDateTime?: string; + readonly testRunId?: string; + /** The creation datetime(RFC 3339 literal format). */ + readonly createdDateTime?: string; /** The user that created. */ - createdBy?: string; - /** The last Modified datetime(ISO 8601 literal format). */ - lastModifiedDateTime?: string; + readonly createdBy?: string; + /** The last Modified datetime(RFC 3339 literal format). */ + readonly lastModifiedDateTime?: string; /** The user that last modified. */ - lastModifiedBy?: string; + readonly lastModifiedBy?: string; } /** Test run server metrics configuration */ export interface TestRunServerMetricConfigOutput { /** Test run identifier */ - testRunId?: string; - /** Azure resource metrics collection {metric id : metrics object} (Refer : https://docs.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition for metric id). */ + readonly testRunId?: string; + /** + * Azure resource metrics collection {metric id : metrics object} (Refer : + * https://docs.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition + * for metric id). + */ metrics?: Record; - /** The creation datetime(ISO 8601 literal format). */ - createdDateTime?: string; + /** The creation datetime(RFC 3339 literal format). */ + readonly createdDateTime?: string; /** The user that created. */ - createdBy?: string; - /** The last Modified datetime(ISO 8601 literal format). */ - lastModifiedDateTime?: string; + readonly createdBy?: string; + /** The last Modified datetime(RFC 3339 literal format). */ + readonly lastModifiedDateTime?: string; /** The user that last modified. */ - lastModifiedBy?: string; + readonly lastModifiedBy?: string; } + +/** The Test Profile Model. A Test Profile resource enables you to set up a test profile which contains various configurations for a supported resource type and a load test to execute on that resource. */ +export interface TestProfileOutput { + /** Unique identifier for the test profile, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. */ + readonly testProfileId: string; + /** Display name of the test profile. */ + displayName?: string; + /** Description for the test profile. */ + description?: string; + /** Associated test ID for the test profile. This property is required for creating a Test Profile and it's not allowed to be updated. */ + testId?: string; + /** Target resource ID on which the test profile is created. This property is required for creating a Test Profile and it's not allowed to be updated. */ + targetResourceId?: string; + /** Configurations of the target resource on which testing would be done. */ + targetResourceConfigurations?: TargetResourceConfigurationsOutput; + /** The creation datetime(RFC 3339 literal format). */ + readonly createdDateTime?: string; + /** The user that created. */ + readonly createdBy?: string; + /** The last Modified datetime(RFC 3339 literal format). */ + readonly lastModifiedDateTime?: string; + /** The user that last modified. */ + readonly lastModifiedBy?: string; +} + +/** Configurations of a target resource. This varies with the kind of resource. */ +export interface TargetResourceConfigurationsOutputParent { + kind: ResourceKindOutput; +} + +/** Configurations for a Function App using Flex Consumption Plan. */ +export interface FunctionFlexConsumptionTargetResourceConfigurationsOutput + extends TargetResourceConfigurationsOutputParent { + /** + * The kind value to use when providing configuration. + * This should typically be not changed from its value. + */ + kind: "FunctionsFlexConsumption"; + /** A map of configurations for a Function app using Flex Consumption Plan. */ + configurations?: Record< + string, + FunctionFlexConsumptionResourceConfigurationOutput + >; +} + +/** Resource configuration instance for a Flex Consumption based Azure Function App. */ +export interface FunctionFlexConsumptionResourceConfigurationOutput { + /** Memory size of the instance. Supported values are 2048, 4096. */ + instanceMemoryMB: number; + /** HTTP Concurrency for the function app. */ + httpConcurrency: number; +} + +/** The Test Profile Run Model. Test Profile Run resource enables you to instantiate an already created test profile and run load tests to get recommendations on the optimal configuration for the target resource. */ +export interface TestProfileRunOutput { + /** Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. */ + readonly testProfileRunId: string; + /** Display name for the test profile run. */ + displayName?: string; + /** The test profile run description */ + description?: string; + /** Associated test profile ID for the test profile run. This is required to create a test profile run and can't be updated. */ + testProfileId?: string; + /** Target resource ID on which the test profile run is created */ + readonly targetResourceId?: string; + /** Configurations of the target resource on which the test profile ran. */ + readonly targetResourceConfigurations?: TargetResourceConfigurationsOutput; + /** + * The test profile run status. + * + * Possible values: "ACCEPTED", "NOTSTARTED", "EXECUTING", "DONE", "CANCELLING", "CANCELLED", "FAILED" + */ + readonly status?: TestProfileRunStatusOutput; + /** Error details if there is any failure in test profile run. These errors are specific to the Test Profile Run. */ + readonly errorDetails?: Array; + /** The test profile run start DateTime(RFC 3339 literal format). */ + readonly startDateTime?: string; + /** The test profile run end DateTime(RFC 3339 literal format). */ + readonly endDateTime?: string; + /** Test profile run duration in seconds. */ + readonly durationInSeconds?: number; + /** + * Details of the test runs ran as part of the test profile run. + * Key is the testRunId of the corresponding testRun. + */ + readonly testRunDetails?: Record; + /** Recommendations provided based on a successful test profile run. */ + readonly recommendations?: Array; + /** The creation datetime(RFC 3339 literal format). */ + readonly createdDateTime?: string; + /** The user that created. */ + readonly createdBy?: string; + /** The last Modified datetime(RFC 3339 literal format). */ + readonly lastModifiedDateTime?: string; + /** The user that last modified. */ + readonly lastModifiedBy?: string; +} + +/** Details of a particular test run for a test profile run. */ +export interface TestRunDetailOutput { + /** + * Status of the test run. + * + * Possible values: "ACCEPTED", "NOTSTARTED", "PROVISIONING", "PROVISIONED", "CONFIGURING", "CONFIGURED", "EXECUTING", "EXECUTED", "DEPROVISIONING", "DEPROVISIONED", "DONE", "CANCELLING", "CANCELLED", "FAILED", "VALIDATION_SUCCESS", "VALIDATION_FAILURE" + */ + status: StatusOutput; + /** ID of the configuration on which the test ran. */ + configurationId: string; + /** Key value pair of extra properties associated with the test run. */ + properties: Record; +} + +/** A recommendation object that provides a list of configuration that optimizes its category. */ +export interface TestProfileRunRecommendationOutput { + /** + * Category of the recommendation. + * + * Possible values: "ThroughputOptimized", "CostOptimized" + */ + category: RecommendationCategoryOutput; + /** List of configurations IDs for which the recommendation is applicable. These are a subset of the provided target resource configurations. */ + configurations?: string[]; +} + +/** Configurations of a target resource. This varies with the kind of resource. */ +export type TargetResourceConfigurationsOutput = + | TargetResourceConfigurationsOutputParent + | FunctionFlexConsumptionTargetResourceConfigurationsOutput; +/** Alias for PFMetricsOutput */ +export type PFMetricsOutput = string; +/** Alias for PFAgFuncOutput */ +export type PFAgFuncOutput = string; +/** Alias for PFActionOutput */ +export type PFActionOutput = string; +/** Alias for PFResultOutput */ +export type PFResultOutput = string; +/** Alias for SecretTypeOutput */ +export type SecretTypeOutput = string; +/** Alias for CertificateTypeOutput */ +export type CertificateTypeOutput = string; +/** Alias for FileTypeOutput */ +export type FileTypeOutput = string; +/** Alias for FileStatusOutput */ +export type FileStatusOutput = string; +/** Alias for TestKindOutput */ +export type TestKindOutput = string; +/** Paged collection of Test items */ +export type PagedTestOutput = Paged; +/** Paged collection of TestFileInfo items */ +export type PagedTestFileInfoOutput = Paged; +/** Alias for PFTestResultOutput */ +export type PFTestResultOutput = string; +/** Alias for StatusOutput */ +export type StatusOutput = string; +/** Alias for RequestDataLevelOutput */ +export type RequestDataLevelOutput = string; +/** Paged collection of TestRun items */ +export type PagedTestRunOutput = Paged; +/** Alias for AggregationTypeOutput */ +export type AggregationTypeOutput = string; +/** Alias for MetricUnitOutput */ +export type MetricUnitOutput = string; +/** Alias for TimeGrainOutput */ +export type TimeGrainOutput = string; +/** The response to a metrics query. */ +export type MetricsOutput = Paged; +/** Alias for ResourceKindOutput */ +export type ResourceKindOutput = string; +/** Paged collection of TestProfile items */ +export type PagedTestProfileOutput = Paged; +/** Alias for TestProfileRunStatusOutput */ +export type TestProfileRunStatusOutput = string; +/** Alias for RecommendationCategoryOutput */ +export type RecommendationCategoryOutput = string; +/** Paged collection of TestProfileRun items */ +export type PagedTestProfileRunOutput = Paged; diff --git a/sdk/loadtesting/load-testing-rest/src/paginateHelper.ts b/sdk/loadtesting/load-testing-rest/src/paginateHelper.ts index e27846d32a90..94d5220235d9 100644 --- a/sdk/loadtesting/load-testing-rest/src/paginateHelper.ts +++ b/sdk/loadtesting/load-testing-rest/src/paginateHelper.ts @@ -1,8 +1,16 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { getPagedAsyncIterator, PagedAsyncIterableIterator, PagedResult } from "@azure/core-paging"; -import { Client, createRestError, PathUncheckedResponse } from "@azure-rest/core-client"; +import { + getPagedAsyncIterator, + PagedAsyncIterableIterator, + PagedResult, +} from "@azure/core-paging"; +import { + Client, + createRestError, + PathUncheckedResponse, +} from "@azure-rest/core-client"; /** * Helper type to extract the type of an array @@ -67,7 +75,9 @@ export function paginate( typeof customGetPage === "function" ? customGetPage : async (pageLink: string) => { - const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get(); + const result = firstRun + ? initialResponse + : await client.pathUnchecked(pageLink).get(); firstRun = false; checkPagingRequest(result); const nextLink = getNextLink(result.body, nextLinkName); @@ -93,7 +103,9 @@ function getNextLink(body: unknown, nextLinkName?: string): string | undefined { const nextLink = (body as Record)[nextLinkName]; if (typeof nextLink !== "string" && typeof nextLink !== "undefined") { - throw new Error(`Body Property ${nextLinkName} should be a string or undefined`); + throw new Error( + `Body Property ${nextLinkName} should be a string or undefined`, + ); } return nextLink; @@ -121,7 +133,18 @@ function getElements(body: unknown, itemName: string): T[] { * Checks if a request failed */ function checkPagingRequest(response: PathUncheckedResponse): void { - const Http2xxStatusCodes = ["200", "201", "202", "203", "204", "205", "206", "207", "208", "226"]; + const Http2xxStatusCodes = [ + "200", + "201", + "202", + "203", + "204", + "205", + "206", + "207", + "208", + "226", + ]; if (!Http2xxStatusCodes.includes(response.status)) { throw createRestError( `Pagination failed with unexpected statusCode ${response.status}`, diff --git a/sdk/loadtesting/load-testing-rest/src/parameters.ts b/sdk/loadtesting/load-testing-rest/src/parameters.ts index 506bc4093798..cb5409127b66 100644 --- a/sdk/loadtesting/load-testing-rest/src/parameters.ts +++ b/sdk/loadtesting/load-testing-rest/src/parameters.ts @@ -4,163 +4,195 @@ import { RequestParameters } from "@azure-rest/core-client"; import { Test, + FileType, TestAppComponents, TestServerMetricConfig, TestRun, + TimeGrain, MetricRequestPayload, TestRunAppComponents, TestRunServerMetricConfig, -} from "./models"; + TestProfile, + TestProfileRun, +} from "./models.js"; -export interface TestCreateOrUpdateBodyParam { - /** Load test model */ - body: Test; +/** The resource instance. */ +export type TestResourceMergeAndPatch = Partial; + +export interface LoadTestAdministrationCreateOrUpdateTestBodyParam { + /** The resource instance. */ + body: TestResourceMergeAndPatch; } -export interface TestCreateOrUpdateMediaTypesParam { - /** Request content type */ - contentType?: "application/merge-patch+json"; +export interface LoadTestAdministrationCreateOrUpdateTestMediaTypesParam { + /** This request has a JSON Merge Patch body. */ + contentType: "application/merge-patch+json"; } -export type TestCreateOrUpdateParameters = TestCreateOrUpdateMediaTypesParam & - TestCreateOrUpdateBodyParam & - RequestParameters; -export type TestDeleteParameters = RequestParameters; -export type TestGetParameters = RequestParameters; +export type LoadTestAdministrationCreateOrUpdateTestParameters = + LoadTestAdministrationCreateOrUpdateTestMediaTypesParam & + LoadTestAdministrationCreateOrUpdateTestBodyParam & + RequestParameters; +export type LoadTestAdministrationDeleteTestParameters = RequestParameters; +export type LoadTestAdministrationGetTestParameters = RequestParameters; -export interface TestListQueryParamProperties { - /** Sort on the supported fields in (field asc/desc) format. eg: lastModifiedDateTime asc. Supported fields - lastModifiedDateTime */ +export interface LoadTestAdministrationListTestsQueryParamProperties { + /** + * Sort on the supported fields in (field asc/desc) format. eg: + * lastModifiedDateTime asc. Supported fields - lastModifiedDateTime + */ orderby?: string; - /** Prefix based, case sensitive search on searchable fields - displayName, createdBy. For example, to search for a test, with display name is Login Test, the search parameter can be Login. */ + /** + * Prefix based, case sensitive search on searchable fields - displayName, + * createdBy. For example, to search for a test, with display name is Login Test, + * the search parameter can be Login. + */ search?: string; - /** Start DateTime(ISO 8601 literal format) of the last updated time range to filter tests. */ + /** Start DateTime(RFC 3339 literal format) of the last updated time range to filter tests. */ lastModifiedStartTime?: Date | string; - /** End DateTime(ISO 8601 literal format) of the last updated time range to filter tests. */ + /** End DateTime(RFC 3339 literal format) of the last updated time range to filter tests. */ lastModifiedEndTime?: Date | string; - /** Continuation token to get the next page of response */ - continuationToken?: string; /** Number of results in response. */ maxpagesize?: number; } -export interface TestListQueryParam { - queryParameters?: TestListQueryParamProperties; +export interface LoadTestAdministrationListTestsQueryParam { + queryParameters?: LoadTestAdministrationListTestsQueryParamProperties; } -export type TestListParameters = TestListQueryParam & RequestParameters; +export type LoadTestAdministrationListTestsParameters = + LoadTestAdministrationListTestsQueryParam & RequestParameters; -export interface TestUploadFileBodyParam { +export interface LoadTestAdministrationUploadTestFileBodyParam { /** * The file content as application/octet-stream. * * Value may contain any sequence of octets */ - body: string | Uint8Array | ReadableStream | NodeJS.ReadableStream; -} - -export interface TestUploadFileQueryParamProperties { - /** File type */ - fileType?: "JMX_FILE" | "USER_PROPERTIES" | "ADDITIONAL_ARTIFACTS"; + body: + | string + | Uint8Array + | ReadableStream + | NodeJS.ReadableStream; } -export interface TestUploadFileQueryParam { - queryParameters?: TestUploadFileQueryParamProperties; -} - -export interface TestUploadFileMediaTypesParam { - /** Request content type */ - contentType?: "application/octet-stream"; +export interface LoadTestAdministrationUploadTestFileQueryParamProperties { + /** + * File type + * + * Possible values: "JMX_FILE", "USER_PROPERTIES", "ADDITIONAL_ARTIFACTS", "ZIPPED_ARTIFACTS", "URL_TEST_CONFIG", "TEST_SCRIPT" + */ + fileType?: FileType; } -export type TestUploadFileParameters = TestUploadFileQueryParam & - TestUploadFileMediaTypesParam & - TestUploadFileBodyParam & - RequestParameters; -export type TestGetFileParameters = RequestParameters; -export type TestDeleteFileParameters = RequestParameters; - -export interface TestListFilesQueryParamProperties { - /** Continuation token to get the next page of response */ - continuationToken?: string; +export interface LoadTestAdministrationUploadTestFileQueryParam { + queryParameters?: LoadTestAdministrationUploadTestFileQueryParamProperties; } -export interface TestListFilesQueryParam { - queryParameters?: TestListFilesQueryParamProperties; +export interface LoadTestAdministrationUploadTestFileMediaTypesParam { + /** Content type. */ + contentType: "application/octet-stream"; } -export type TestListFilesParameters = TestListFilesQueryParam & RequestParameters; +export type LoadTestAdministrationUploadTestFileParameters = + LoadTestAdministrationUploadTestFileQueryParam & + LoadTestAdministrationUploadTestFileMediaTypesParam & + LoadTestAdministrationUploadTestFileBodyParam & + RequestParameters; +export type LoadTestAdministrationGetTestFileParameters = RequestParameters; +export type LoadTestAdministrationDeleteTestFileParameters = RequestParameters; +export type LoadTestAdministrationListTestFilesParameters = RequestParameters; +/** App Component model. */ +export type TestAppComponentsResourceMergeAndPatch = Partial; -export interface TestCreateOrUpdateAppComponentsBodyParam { +export interface LoadTestAdministrationCreateOrUpdateAppComponentsBodyParam { /** App Component model. */ - body: TestAppComponents; + body: TestAppComponentsResourceMergeAndPatch; } -export interface TestCreateOrUpdateAppComponentsMediaTypesParam { - /** Request content type */ - contentType?: "application/merge-patch+json"; +export interface LoadTestAdministrationCreateOrUpdateAppComponentsMediaTypesParam { + /** Content type. */ + contentType: "application/merge-patch+json"; } -export type TestCreateOrUpdateAppComponentsParameters = - TestCreateOrUpdateAppComponentsMediaTypesParam & - TestCreateOrUpdateAppComponentsBodyParam & +export type LoadTestAdministrationCreateOrUpdateAppComponentsParameters = + LoadTestAdministrationCreateOrUpdateAppComponentsMediaTypesParam & + LoadTestAdministrationCreateOrUpdateAppComponentsBodyParam & RequestParameters; -export type TestListAppComponentsParameters = RequestParameters; +export type LoadTestAdministrationGetAppComponentsParameters = + RequestParameters; +/** Server metric configuration model. */ +export type TestServerMetricConfigResourceMergeAndPatch = + Partial; -export interface TestCreateOrUpdateServerMetricsConfigBodyParam { +export interface LoadTestAdministrationCreateOrUpdateServerMetricsConfigBodyParam { /** Server metric configuration model. */ - body: TestServerMetricConfig; + body: TestServerMetricConfigResourceMergeAndPatch; } -export interface TestCreateOrUpdateServerMetricsConfigMediaTypesParam { - /** Request content type */ - contentType?: "application/merge-patch+json"; +export interface LoadTestAdministrationCreateOrUpdateServerMetricsConfigMediaTypesParam { + /** Content type. */ + contentType: "application/merge-patch+json"; } -export type TestCreateOrUpdateServerMetricsConfigParameters = - TestCreateOrUpdateServerMetricsConfigMediaTypesParam & - TestCreateOrUpdateServerMetricsConfigBodyParam & +export type LoadTestAdministrationCreateOrUpdateServerMetricsConfigParameters = + LoadTestAdministrationCreateOrUpdateServerMetricsConfigMediaTypesParam & + LoadTestAdministrationCreateOrUpdateServerMetricsConfigBodyParam & RequestParameters; -export type TestListServerMetricsConfigParameters = RequestParameters; -export type TestRunDeleteParameters = RequestParameters; +export type LoadTestAdministrationGetServerMetricsConfigParameters = + RequestParameters; +export type LoadTestRunGetTestRunParameters = RequestParameters; +/** The resource instance. */ +export type TestRunResourceMergeAndPatch = Partial; -export interface TestRunCreateOrUpdateBodyParam { - /** Load test run model */ - body: TestRun; +export interface LoadTestRunCreateOrUpdateTestRunBodyParam { + /** The resource instance. */ + body: TestRunResourceMergeAndPatch; } -export interface TestRunCreateOrUpdateQueryParamProperties { - /** Existing test run identifier that should be rerun, if this is provided, the test will run with the JMX file, configuration and app components from the existing test run. You can override the configuration values for new test run in the request body. */ +export interface LoadTestRunCreateOrUpdateTestRunQueryParamProperties { + /** + * Existing test run identifier that should be rerun, if this is provided, the + * test will run with the JMX file, configuration and app components from the + * existing test run. You can override the configuration values for new test run + * in the request body. + */ oldTestRunId?: string; } -export interface TestRunCreateOrUpdateQueryParam { - queryParameters?: TestRunCreateOrUpdateQueryParamProperties; +export interface LoadTestRunCreateOrUpdateTestRunQueryParam { + queryParameters?: LoadTestRunCreateOrUpdateTestRunQueryParamProperties; } -export interface TestRunCreateOrUpdateMediaTypesParam { - /** Request content type */ - contentType?: "application/merge-patch+json"; +export interface LoadTestRunCreateOrUpdateTestRunMediaTypesParam { + /** This request has a JSON Merge Patch body. */ + contentType: "application/merge-patch+json"; } -export type TestRunCreateOrUpdateParameters = TestRunCreateOrUpdateQueryParam & - TestRunCreateOrUpdateMediaTypesParam & - TestRunCreateOrUpdateBodyParam & - RequestParameters; -export type TestRunGetParameters = RequestParameters; -export type TestRunGetFileParameters = RequestParameters; +export type LoadTestRunCreateOrUpdateTestRunParameters = + LoadTestRunCreateOrUpdateTestRunQueryParam & + LoadTestRunCreateOrUpdateTestRunMediaTypesParam & + LoadTestRunCreateOrUpdateTestRunBodyParam & + RequestParameters; +export type LoadTestRunDeleteTestRunParameters = RequestParameters; -export interface TestRunListQueryParamProperties { - /** Sort on the supported fields in (field asc/desc) format. eg: executedDateTime asc. Supported fields - executedDateTime */ +export interface LoadTestRunListTestRunsQueryParamProperties { + /** + * Sort on the supported fields in (field asc/desc) format. eg: executedDateTime + * asc. Supported fields - executedDateTime + */ orderby?: string; - /** Continuation token to get the next page of response */ - continuationToken?: string; - /** Prefix based, case sensitive search on searchable fields - description, executedUser. For example, to search for a test run, with description 500 VUs, the search parameter can be 500. */ + /** + * Prefix based, case sensitive search on searchable fields - description, + * executedUser. For example, to search for a test run, with description 500 VUs, + * the search parameter can be 500. + */ search?: string; /** Unique name of an existing load test. */ testId?: string; - /** Start DateTime(ISO 8601 literal format) of test-run execution time filter range. */ + /** Start DateTime(RFC 3339 literal format) of test-run execution time filter range. */ executionFrom?: Date | string; - /** End DateTime(ISO 8601 literal format) of test-run execution time filter range. */ + /** End DateTime(RFC 3339 literal format) of test-run execution time filter range. */ executionTo?: Date | string; /** Comma separated list of test run status. */ status?: string; @@ -168,104 +200,209 @@ export interface TestRunListQueryParamProperties { maxpagesize?: number; } -export interface TestRunListQueryParam { - queryParameters?: TestRunListQueryParamProperties; +export interface LoadTestRunListTestRunsQueryParam { + queryParameters?: LoadTestRunListTestRunsQueryParamProperties; } -export type TestRunListParameters = TestRunListQueryParam & RequestParameters; -export type TestRunStopParameters = RequestParameters; -export type TestRunListMetricNamespacesParameters = RequestParameters; +export type LoadTestRunListTestRunsParameters = + LoadTestRunListTestRunsQueryParam & RequestParameters; +export type LoadTestRunGetTestRunFileParameters = RequestParameters; +export type LoadTestRunStopTestRunParameters = RequestParameters; +export type LoadTestRunListMetricNamespacesParameters = RequestParameters; -export interface TestRunListMetricDefinitionsQueryParamProperties { +export interface LoadTestRunListMetricDefinitionsQueryParamProperties { /** Metric namespace to query metric definitions for. */ metricNamespace: string; } -export interface TestRunListMetricDefinitionsQueryParam { - queryParameters: TestRunListMetricDefinitionsQueryParamProperties; +export interface LoadTestRunListMetricDefinitionsQueryParam { + queryParameters: LoadTestRunListMetricDefinitionsQueryParamProperties; } -export type TestRunListMetricDefinitionsParameters = TestRunListMetricDefinitionsQueryParam & - RequestParameters; +export type LoadTestRunListMetricDefinitionsParameters = + LoadTestRunListMetricDefinitionsQueryParam & RequestParameters; -export interface TestRunListMetricsBodyParam { +export interface LoadTestRunListMetricsBodyParam { /** Metric dimension filter */ body?: MetricRequestPayload; } -export interface TestRunListMetricsQueryParamProperties { +export interface LoadTestRunListMetricsQueryParamProperties { /** The aggregation */ aggregation?: string; - /** The interval (i.e. timegrain) of the query. */ - interval?: "PT5S" | "PT10S" | "PT1M" | "PT5M" | "PT1H"; /** Metric name */ metricname: string; + /** + * The interval (i.e. timegrain) of the query. + * + * Possible values: "PT5S", "PT10S", "PT1M", "PT5M", "PT1H" + */ + interval?: TimeGrain; /** Metric namespace to query metric definitions for. */ metricNamespace: string; /** The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. */ timespan: string; } -export interface TestRunListMetricsQueryParam { - queryParameters: TestRunListMetricsQueryParamProperties; -} - -export interface TestRunListMetricsMediaTypesParam { - /** Request content type */ - contentType?: "application/json"; +export interface LoadTestRunListMetricsQueryParam { + queryParameters: LoadTestRunListMetricsQueryParamProperties; } -export type TestRunListMetricsParameters = TestRunListMetricsQueryParam & - TestRunListMetricsMediaTypesParam & - TestRunListMetricsBodyParam & - RequestParameters; +export type LoadTestRunListMetricsParameters = + LoadTestRunListMetricsQueryParam & + LoadTestRunListMetricsBodyParam & + RequestParameters; -export interface TestRunListMetricDimensionValuesQueryParamProperties { - /** The interval (i.e. timegrain) of the query. */ - interval?: "PT5S" | "PT10S" | "PT1M" | "PT5M" | "PT1H"; +export interface LoadTestRunListMetricDimensionValuesQueryParamProperties { /** Metric name */ metricname: string; + /** + * The interval (i.e. timegrain) of the query. + * + * Possible values: "PT5S", "PT10S", "PT1M", "PT5M", "PT1H" + */ + interval?: TimeGrain; /** Metric namespace to query metric definitions for. */ metricNamespace: string; /** The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. */ timespan: string; } -export interface TestRunListMetricDimensionValuesQueryParam { - queryParameters: TestRunListMetricDimensionValuesQueryParamProperties; +export interface LoadTestRunListMetricDimensionValuesQueryParam { + queryParameters: LoadTestRunListMetricDimensionValuesQueryParamProperties; } -export type TestRunListMetricDimensionValuesParameters = - TestRunListMetricDimensionValuesQueryParam & RequestParameters; +export type LoadTestRunListMetricDimensionValuesParameters = + LoadTestRunListMetricDimensionValuesQueryParam & RequestParameters; +/** App Component model. */ +export type TestRunAppComponentsResourceMergeAndPatch = + Partial; -export interface TestRunCreateOrUpdateAppComponentsBodyParam { +export interface LoadTestRunCreateOrUpdateAppComponentsBodyParam { /** App Component model. */ - body: TestRunAppComponents; + body: TestRunAppComponentsResourceMergeAndPatch; } -export interface TestRunCreateOrUpdateAppComponentsMediaTypesParam { - /** Request content type */ - contentType?: "application/merge-patch+json"; +export interface LoadTestRunCreateOrUpdateAppComponentsMediaTypesParam { + /** Content type. */ + contentType: "application/merge-patch+json"; } -export type TestRunCreateOrUpdateAppComponentsParameters = - TestRunCreateOrUpdateAppComponentsMediaTypesParam & - TestRunCreateOrUpdateAppComponentsBodyParam & +export type LoadTestRunCreateOrUpdateAppComponentsParameters = + LoadTestRunCreateOrUpdateAppComponentsMediaTypesParam & + LoadTestRunCreateOrUpdateAppComponentsBodyParam & RequestParameters; -export type TestRunListAppComponentsParameters = RequestParameters; +export type LoadTestRunGetAppComponentsParameters = RequestParameters; +/** Server metric configuration model. */ +export type TestRunServerMetricConfigResourceMergeAndPatch = + Partial; -export interface TestRunCreateOrUpdateServerMetricsConfigBodyParam { +export interface LoadTestRunCreateOrUpdateServerMetricsConfigBodyParam { /** Server metric configuration model. */ - body: TestRunServerMetricConfig; + body: TestRunServerMetricConfigResourceMergeAndPatch; +} + +export interface LoadTestRunCreateOrUpdateServerMetricsConfigMediaTypesParam { + /** Content type. */ + contentType: "application/merge-patch+json"; +} + +export type LoadTestRunCreateOrUpdateServerMetricsConfigParameters = + LoadTestRunCreateOrUpdateServerMetricsConfigMediaTypesParam & + LoadTestRunCreateOrUpdateServerMetricsConfigBodyParam & + RequestParameters; +export type LoadTestRunGetServerMetricsConfigParameters = RequestParameters; +/** The resource instance. */ +export type TestProfileResourceMergeAndPatch = Partial; + +export interface TestProfileAdministrationCreateOrUpdateTestProfileBodyParam { + /** The resource instance. */ + body: TestProfileResourceMergeAndPatch; +} + +export interface TestProfileAdministrationCreateOrUpdateTestProfileMediaTypesParam { + /** This request has a JSON Merge Patch body. */ + contentType: "application/merge-patch+json"; +} + +export type TestProfileAdministrationCreateOrUpdateTestProfileParameters = + TestProfileAdministrationCreateOrUpdateTestProfileMediaTypesParam & + TestProfileAdministrationCreateOrUpdateTestProfileBodyParam & + RequestParameters; +export type TestProfileAdministrationDeleteTestProfileParameters = + RequestParameters; +export type TestProfileAdministrationGetTestProfileParameters = + RequestParameters; + +export interface TestProfileAdministrationListTestProfilesQueryParamProperties { + /** Maximum number of results to include in a single response. */ + maxpagesize?: number; + /** Start DateTime(RFC 3339 literal format) of the last updated time range to filter test profiles. */ + lastModifiedStartTime?: Date | string; + /** End DateTime(RFC 3339 literal format) of the last updated time range to filter test profiles. */ + lastModifiedEndTime?: Date | string; + /** Comma separated list of IDs of the test profiles to filter. */ + testProfileIds?: string; + /** Comma separated list IDs of the tests which should be associated with the test profiles to fetch. */ + testIds?: string; +} + +export interface TestProfileAdministrationListTestProfilesQueryParam { + queryParameters?: TestProfileAdministrationListTestProfilesQueryParamProperties; } -export interface TestRunCreateOrUpdateServerMetricsConfigMediaTypesParam { - /** Request content type */ - contentType?: "application/merge-patch+json"; +export type TestProfileAdministrationListTestProfilesParameters = + TestProfileAdministrationListTestProfilesQueryParam & RequestParameters; +export type TestProfileRunAdministrationGetTestProfileRunParameters = + RequestParameters; +/** The resource instance. */ +export type TestProfileRunResourceMergeAndPatch = Partial; + +export interface TestProfileRunAdministrationCreateOrUpdateTestProfileRunBodyParam { + /** The resource instance. */ + body: TestProfileRunResourceMergeAndPatch; +} + +export interface TestProfileRunAdministrationCreateOrUpdateTestProfileRunMediaTypesParam { + /** This request has a JSON Merge Patch body. */ + contentType: "application/merge-patch+json"; } -export type TestRunCreateOrUpdateServerMetricsConfigParameters = - TestRunCreateOrUpdateServerMetricsConfigMediaTypesParam & - TestRunCreateOrUpdateServerMetricsConfigBodyParam & +export type TestProfileRunAdministrationCreateOrUpdateTestProfileRunParameters = + TestProfileRunAdministrationCreateOrUpdateTestProfileRunMediaTypesParam & + TestProfileRunAdministrationCreateOrUpdateTestProfileRunBodyParam & RequestParameters; -export type TestRunListServerMetricsConfigParameters = RequestParameters; +export type TestProfileRunAdministrationDeleteTestProfileRunParameters = + RequestParameters; +export type TestProfileRunAdministrationStopTestProfileRunParameters = + RequestParameters; + +export interface TestProfileRunAdministrationListTestProfileRunsQueryParamProperties { + /** Maximum number of results to include in a single response. */ + maxpagesize?: number; + /** Minimum Start DateTime(RFC 3339 literal format) of the test profile runs to filter on. */ + minStartDateTime?: Date | string; + /** Maximum Start DateTime(RFC 3339 literal format) of the test profile runs to filter on. */ + maxStartDateTime?: Date | string; + /** Minimum End DateTime(RFC 3339 literal format) of the test profile runs to filter on. */ + minEndDateTime?: Date | string; + /** Maximum End DateTime(RFC 3339 literal format) of the test profile runs to filter on. */ + maxEndDateTime?: Date | string; + /** Start DateTime(RFC 3339 literal format) of the created time range to filter test profile runs. */ + createdDateStartTime?: Date | string; + /** End DateTime(RFC 3339 literal format) of the created time range to filter test profile runs. */ + createdDateEndTime?: Date | string; + /** Comma separated list of IDs of the test profile runs to filter. */ + testProfileRunIds?: string; + /** Comma separated IDs of the test profiles which should be associated with the test profile runs to fetch. */ + testProfileIds?: string; + /** Comma separated list of Statuses of the test profile runs to filter. */ + statuses?: string; +} + +export interface TestProfileRunAdministrationListTestProfileRunsQueryParam { + queryParameters?: TestProfileRunAdministrationListTestProfileRunsQueryParamProperties; +} + +export type TestProfileRunAdministrationListTestProfileRunsParameters = + TestProfileRunAdministrationListTestProfileRunsQueryParam & RequestParameters; diff --git a/sdk/loadtesting/load-testing-rest/src/pollingHelper.ts b/sdk/loadtesting/load-testing-rest/src/pollingHelper.ts deleted file mode 100644 index a9a2dd93bd25..000000000000 --- a/sdk/loadtesting/load-testing-rest/src/pollingHelper.ts +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import { AzureLoadTestingClient } from "./clientDefinitions"; -import { getFileValidationPoller } from "./getFileValidationPoller"; -import { getTestRunCompletionPoller } from "./getTestRunCompletionPoller"; -import { - FileUploadAndValidatePoller, - TestUploadFileSuccessResponse, - TestRunCompletionPoller, - TestRunCreateOrUpdateSuccessResponse, -} from "./models"; - -export async function getLongRunningPoller( - client: AzureLoadTestingClient, - initialResponse: TestUploadFileSuccessResponse, -): Promise; -export async function getLongRunningPoller( - client: AzureLoadTestingClient, - initialResponse: TestRunCreateOrUpdateSuccessResponse, -): Promise; -export async function getLongRunningPoller( - client: AzureLoadTestingClient, - initialResponse: TestRunCreateOrUpdateSuccessResponse | TestUploadFileSuccessResponse, -): Promise { - if (isFileUpload(initialResponse)) { - return getFileValidationPoller(client, initialResponse); - } else if (isTestRunCreation(initialResponse)) { - return getTestRunCompletionPoller(client, initialResponse); - } - throw new Error("The Operation is not a long running operation."); -} - -function isFileUpload(response: any): response is TestUploadFileSuccessResponse { - return response.request.url.includes("/files/"); -} - -function isTestRunCreation(response: any): response is TestRunCreateOrUpdateSuccessResponse { - return response.request.url.includes("/test-runs/"); -} diff --git a/sdk/loadtesting/load-testing-rest/src/responses.ts b/sdk/loadtesting/load-testing-rest/src/responses.ts index d76ff1ceb9b0..ddc054b75336 100644 --- a/sdk/loadtesting/load-testing-rest/src/responses.ts +++ b/sdk/loadtesting/load-testing-rest/src/responses.ts @@ -2,525 +2,743 @@ // Licensed under the MIT License. import { RawHttpHeaders } from "@azure/core-rest-pipeline"; -import { HttpResponse } from "@azure-rest/core-client"; +import { HttpResponse, ErrorResponse } from "@azure-rest/core-client"; import { TestOutput, - ErrorResponseBodyOutput, - TestsListOutput, - FileInfoOutput, - FileInfoListOutput, + PagedTestOutput, + TestFileInfoOutput, + PagedTestFileInfoOutput, TestAppComponentsOutput, TestServerMetricConfigOutput, TestRunOutput, - TestRunsListOutput, + PagedTestRunOutput, + TestRunFileInfoOutput, MetricNamespaceCollectionOutput, MetricDefinitionCollectionOutput, MetricsOutput, DimensionValueListOutput, TestRunAppComponentsOutput, TestRunServerMetricConfigOutput, -} from "./outputModels"; - -/** Create a new test or update an existing test. */ -export interface TestCreateOrUpdate200Response extends HttpResponse { + TestProfileOutput, + PagedTestProfileOutput, + TestProfileRunOutput, + PagedTestProfileRunOutput, +} from "./outputModels.js"; + +/** The request has succeeded. */ +export interface LoadTestAdministrationCreateOrUpdateTest200Response + extends HttpResponse { status: "200"; body: TestOutput; } -/** Create a new test or update an existing test. */ -export interface TestCreateOrUpdate201Response extends HttpResponse { +/** The request has succeeded and a new resource has been created as a result. */ +export interface LoadTestAdministrationCreateOrUpdateTest201Response + extends HttpResponse { status: "201"; body: TestOutput; } -export interface TestCreateOrUpdateDefaultHeaders { - /** The error code for specific error that occurred. */ +export interface LoadTestAdministrationCreateOrUpdateTestDefaultHeaders { + /** String error code indicating what went wrong. */ "x-ms-error-code"?: string; } -/** Create a new test or update an existing test. */ -export interface TestCreateOrUpdateDefaultResponse extends HttpResponse { +export interface LoadTestAdministrationCreateOrUpdateTestDefaultResponse + extends HttpResponse { status: string; - body: ErrorResponseBodyOutput; - headers: RawHttpHeaders & TestCreateOrUpdateDefaultHeaders; + body: ErrorResponse; + headers: RawHttpHeaders & + LoadTestAdministrationCreateOrUpdateTestDefaultHeaders; } -/** Delete a test by its name. */ -export interface TestDelete204Response extends HttpResponse { +/** There is no content to send for this request, but the headers may be useful. */ +export interface LoadTestAdministrationDeleteTest204Response + extends HttpResponse { status: "204"; - body: Record; } -export interface TestDeleteDefaultHeaders { - /** The error code for specific error that occurred. */ +export interface LoadTestAdministrationDeleteTestDefaultHeaders { + /** String error code indicating what went wrong. */ "x-ms-error-code"?: string; } -/** Delete a test by its name. */ -export interface TestDeleteDefaultResponse extends HttpResponse { +export interface LoadTestAdministrationDeleteTestDefaultResponse + extends HttpResponse { status: string; - body: ErrorResponseBodyOutput; - headers: RawHttpHeaders & TestDeleteDefaultHeaders; + body: ErrorResponse; + headers: RawHttpHeaders & LoadTestAdministrationDeleteTestDefaultHeaders; } -/** Get load test details by test name */ -export interface TestGet200Response extends HttpResponse { +/** The request has succeeded. */ +export interface LoadTestAdministrationGetTest200Response extends HttpResponse { status: "200"; body: TestOutput; } -export interface TestGetDefaultHeaders { - /** The error code for specific error that occurred. */ +export interface LoadTestAdministrationGetTestDefaultHeaders { + /** String error code indicating what went wrong. */ "x-ms-error-code"?: string; } -/** Get load test details by test name */ -export interface TestGetDefaultResponse extends HttpResponse { +export interface LoadTestAdministrationGetTestDefaultResponse + extends HttpResponse { status: string; - body: ErrorResponseBodyOutput; - headers: RawHttpHeaders & TestGetDefaultHeaders; + body: ErrorResponse; + headers: RawHttpHeaders & LoadTestAdministrationGetTestDefaultHeaders; } -/** Get all load tests by the fully qualified resource Id e.g subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. */ -export interface TestList200Response extends HttpResponse { +/** The request has succeeded. */ +export interface LoadTestAdministrationListTests200Response + extends HttpResponse { status: "200"; - body: TestsListOutput; + body: PagedTestOutput; } -export interface TestListDefaultHeaders { - /** The error code for specific error that occurred. */ +export interface LoadTestAdministrationListTestsDefaultHeaders { + /** String error code indicating what went wrong. */ "x-ms-error-code"?: string; } -/** Get all load tests by the fully qualified resource Id e.g subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. */ -export interface TestListDefaultResponse extends HttpResponse { +export interface LoadTestAdministrationListTestsDefaultResponse + extends HttpResponse { status: string; - body: ErrorResponseBodyOutput; - headers: RawHttpHeaders & TestListDefaultHeaders; + body: ErrorResponse; + headers: RawHttpHeaders & LoadTestAdministrationListTestsDefaultHeaders; } -/** Upload input file for a given test name. File size can't be more than 50 MB. Existing file with same name for the given test will be overwritten. File should be provided in the request body as application/octet-stream. */ -export interface TestUploadFile201Response extends HttpResponse { +/** The request has succeeded and a new resource has been created as a result. */ +export interface LoadTestAdministrationUploadTestFile201Response + extends HttpResponse { status: "201"; - body: FileInfoOutput; + body: TestFileInfoOutput; } -export interface TestUploadFileDefaultHeaders { - /** The error code for specific error that occurred. */ +export interface LoadTestAdministrationUploadTestFileDefaultHeaders { + /** String error code indicating what went wrong. */ "x-ms-error-code"?: string; } -/** Upload input file for a given test name. File size can't be more than 50 MB. Existing file with same name for the given test will be overwritten. File should be provided in the request body as application/octet-stream. */ -export interface TestUploadFileDefaultResponse extends HttpResponse { +export interface LoadTestAdministrationUploadTestFileDefaultResponse + extends HttpResponse { status: string; - body: ErrorResponseBodyOutput; - headers: RawHttpHeaders & TestUploadFileDefaultHeaders; + body: ErrorResponse; + headers: RawHttpHeaders & LoadTestAdministrationUploadTestFileDefaultHeaders; } -/** Get test file by the file name. */ -export interface TestGetFile200Response extends HttpResponse { +/** The request has succeeded. */ +export interface LoadTestAdministrationGetTestFile200Response + extends HttpResponse { status: "200"; - body: FileInfoOutput; + body: TestFileInfoOutput; } -export interface TestGetFileDefaultHeaders { - /** The error code for specific error that occurred. */ +export interface LoadTestAdministrationGetTestFileDefaultHeaders { + /** String error code indicating what went wrong. */ "x-ms-error-code"?: string; } -/** Get test file by the file name. */ -export interface TestGetFileDefaultResponse extends HttpResponse { +export interface LoadTestAdministrationGetTestFileDefaultResponse + extends HttpResponse { status: string; - body: ErrorResponseBodyOutput; - headers: RawHttpHeaders & TestGetFileDefaultHeaders; + body: ErrorResponse; + headers: RawHttpHeaders & LoadTestAdministrationGetTestFileDefaultHeaders; } -/** Delete file by the file name for a test */ -export interface TestDeleteFile204Response extends HttpResponse { +/** There is no content to send for this request, but the headers may be useful. */ +export interface LoadTestAdministrationDeleteTestFile204Response + extends HttpResponse { status: "204"; - body: Record; } -export interface TestDeleteFileDefaultHeaders { - /** The error code for specific error that occurred. */ +export interface LoadTestAdministrationDeleteTestFileDefaultHeaders { + /** String error code indicating what went wrong. */ "x-ms-error-code"?: string; } -/** Delete file by the file name for a test */ -export interface TestDeleteFileDefaultResponse extends HttpResponse { +export interface LoadTestAdministrationDeleteTestFileDefaultResponse + extends HttpResponse { status: string; - body: ErrorResponseBodyOutput; - headers: RawHttpHeaders & TestDeleteFileDefaultHeaders; + body: ErrorResponse; + headers: RawHttpHeaders & LoadTestAdministrationDeleteTestFileDefaultHeaders; } -/** Get all test files. */ -export interface TestListFiles200Response extends HttpResponse { +/** The request has succeeded. */ +export interface LoadTestAdministrationListTestFiles200Response + extends HttpResponse { status: "200"; - body: FileInfoListOutput; + body: PagedTestFileInfoOutput; } -export interface TestListFilesDefaultHeaders { - /** The error code for specific error that occurred. */ +export interface LoadTestAdministrationListTestFilesDefaultHeaders { + /** String error code indicating what went wrong. */ "x-ms-error-code"?: string; } -/** Get all test files. */ -export interface TestListFilesDefaultResponse extends HttpResponse { +export interface LoadTestAdministrationListTestFilesDefaultResponse + extends HttpResponse { status: string; - body: ErrorResponseBodyOutput; - headers: RawHttpHeaders & TestListFilesDefaultHeaders; + body: ErrorResponse; + headers: RawHttpHeaders & LoadTestAdministrationListTestFilesDefaultHeaders; } -/** Associate an app component (collection of azure resources) to a test */ -export interface TestCreateOrUpdateAppComponents200Response extends HttpResponse { +/** The request has succeeded. */ +export interface LoadTestAdministrationCreateOrUpdateAppComponents200Response + extends HttpResponse { status: "200"; body: TestAppComponentsOutput; } -/** Associate an app component (collection of azure resources) to a test */ -export interface TestCreateOrUpdateAppComponents201Response extends HttpResponse { +/** The request has succeeded and a new resource has been created as a result. */ +export interface LoadTestAdministrationCreateOrUpdateAppComponents201Response + extends HttpResponse { status: "201"; body: TestAppComponentsOutput; } -export interface TestCreateOrUpdateAppComponentsDefaultHeaders { - /** The error code for specific error that occurred. */ +export interface LoadTestAdministrationCreateOrUpdateAppComponentsDefaultHeaders { + /** String error code indicating what went wrong. */ "x-ms-error-code"?: string; } -/** Associate an app component (collection of azure resources) to a test */ -export interface TestCreateOrUpdateAppComponentsDefaultResponse extends HttpResponse { +export interface LoadTestAdministrationCreateOrUpdateAppComponentsDefaultResponse + extends HttpResponse { status: string; - body: ErrorResponseBodyOutput; - headers: RawHttpHeaders & TestCreateOrUpdateAppComponentsDefaultHeaders; + body: ErrorResponse; + headers: RawHttpHeaders & + LoadTestAdministrationCreateOrUpdateAppComponentsDefaultHeaders; } -/** Get associated app component (collection of azure resources) for the given test. */ -export interface TestListAppComponents200Response extends HttpResponse { +/** The request has succeeded. */ +export interface LoadTestAdministrationGetAppComponents200Response + extends HttpResponse { status: "200"; body: TestAppComponentsOutput; } -export interface TestListAppComponentsDefaultHeaders { - /** The error code for specific error that occurred. */ +export interface LoadTestAdministrationGetAppComponentsDefaultHeaders { + /** String error code indicating what went wrong. */ "x-ms-error-code"?: string; } -/** Get associated app component (collection of azure resources) for the given test. */ -export interface TestListAppComponentsDefaultResponse extends HttpResponse { +export interface LoadTestAdministrationGetAppComponentsDefaultResponse + extends HttpResponse { status: string; - body: ErrorResponseBodyOutput; - headers: RawHttpHeaders & TestListAppComponentsDefaultHeaders; + body: ErrorResponse; + headers: RawHttpHeaders & + LoadTestAdministrationGetAppComponentsDefaultHeaders; } -/** Configure server metrics for a test */ -export interface TestCreateOrUpdateServerMetricsConfig200Response extends HttpResponse { +/** The request has succeeded. */ +export interface LoadTestAdministrationCreateOrUpdateServerMetricsConfig200Response + extends HttpResponse { status: "200"; body: TestServerMetricConfigOutput; } -/** Configure server metrics for a test */ -export interface TestCreateOrUpdateServerMetricsConfig201Response extends HttpResponse { +/** The request has succeeded and a new resource has been created as a result. */ +export interface LoadTestAdministrationCreateOrUpdateServerMetricsConfig201Response + extends HttpResponse { status: "201"; body: TestServerMetricConfigOutput; } -export interface TestCreateOrUpdateServerMetricsConfigDefaultHeaders { - /** The error code for specific error that occurred. */ +export interface LoadTestAdministrationCreateOrUpdateServerMetricsConfigDefaultHeaders { + /** String error code indicating what went wrong. */ "x-ms-error-code"?: string; } -/** Configure server metrics for a test */ -export interface TestCreateOrUpdateServerMetricsConfigDefaultResponse extends HttpResponse { +export interface LoadTestAdministrationCreateOrUpdateServerMetricsConfigDefaultResponse + extends HttpResponse { status: string; - body: ErrorResponseBodyOutput; - headers: RawHttpHeaders & TestCreateOrUpdateServerMetricsConfigDefaultHeaders; + body: ErrorResponse; + headers: RawHttpHeaders & + LoadTestAdministrationCreateOrUpdateServerMetricsConfigDefaultHeaders; } -/** List server metrics configuration for the given test. */ -export interface TestListServerMetricsConfig200Response extends HttpResponse { +/** The request has succeeded. */ +export interface LoadTestAdministrationGetServerMetricsConfig200Response + extends HttpResponse { status: "200"; body: TestServerMetricConfigOutput; } -export interface TestListServerMetricsConfigDefaultHeaders { - /** The error code for specific error that occurred. */ +export interface LoadTestAdministrationGetServerMetricsConfigDefaultHeaders { + /** String error code indicating what went wrong. */ "x-ms-error-code"?: string; } -/** List server metrics configuration for the given test. */ -export interface TestListServerMetricsConfigDefaultResponse extends HttpResponse { +export interface LoadTestAdministrationGetServerMetricsConfigDefaultResponse + extends HttpResponse { status: string; - body: ErrorResponseBodyOutput; - headers: RawHttpHeaders & TestListServerMetricsConfigDefaultHeaders; + body: ErrorResponse; + headers: RawHttpHeaders & + LoadTestAdministrationGetServerMetricsConfigDefaultHeaders; } -/** Delete a test run by its name. */ -export interface TestRunDelete204Response extends HttpResponse { - status: "204"; - body: Record; +/** The request has succeeded. */ +export interface LoadTestRunGetTestRun200Response extends HttpResponse { + status: "200"; + body: TestRunOutput; } -export interface TestRunDeleteDefaultHeaders { - /** The error code for specific error that occurred. */ +export interface LoadTestRunGetTestRunDefaultHeaders { + /** String error code indicating what went wrong. */ "x-ms-error-code"?: string; } -/** Delete a test run by its name. */ -export interface TestRunDeleteDefaultResponse extends HttpResponse { +export interface LoadTestRunGetTestRunDefaultResponse extends HttpResponse { status: string; - body: ErrorResponseBodyOutput; - headers: RawHttpHeaders & TestRunDeleteDefaultHeaders; + body: ErrorResponse; + headers: RawHttpHeaders & LoadTestRunGetTestRunDefaultHeaders; } -/** Create and start a new test run with the given name. */ -export interface TestRunCreateOrUpdate200Response extends HttpResponse { +/** The request has succeeded. */ +export interface LoadTestRunCreateOrUpdateTestRun200Response + extends HttpResponse { status: "200"; body: TestRunOutput; } -/** Create and start a new test run with the given name. */ -export interface TestRunCreateOrUpdate201Response extends HttpResponse { +/** The request has succeeded and a new resource has been created as a result. */ +export interface LoadTestRunCreateOrUpdateTestRun201Response + extends HttpResponse { status: "201"; body: TestRunOutput; } -export interface TestRunCreateOrUpdateDefaultHeaders { - /** The error code for specific error that occurred. */ +export interface LoadTestRunCreateOrUpdateTestRunDefaultHeaders { + /** String error code indicating what went wrong. */ "x-ms-error-code"?: string; } -/** Create and start a new test run with the given name. */ -export interface TestRunCreateOrUpdateDefaultResponse extends HttpResponse { +export interface LoadTestRunCreateOrUpdateTestRunDefaultResponse + extends HttpResponse { status: string; - body: ErrorResponseBodyOutput; - headers: RawHttpHeaders & TestRunCreateOrUpdateDefaultHeaders; + body: ErrorResponse; + headers: RawHttpHeaders & LoadTestRunCreateOrUpdateTestRunDefaultHeaders; } -/** Get test run details by name. */ -export interface TestRunGet200Response extends HttpResponse { - status: "200"; - body: TestRunOutput; +/** There is no content to send for this request, but the headers may be useful. */ +export interface LoadTestRunDeleteTestRun204Response extends HttpResponse { + status: "204"; } -export interface TestRunGetDefaultHeaders { - /** The error code for specific error that occurred. */ +export interface LoadTestRunDeleteTestRunDefaultHeaders { + /** String error code indicating what went wrong. */ "x-ms-error-code"?: string; } -/** Get test run details by name. */ -export interface TestRunGetDefaultResponse extends HttpResponse { +export interface LoadTestRunDeleteTestRunDefaultResponse extends HttpResponse { status: string; - body: ErrorResponseBodyOutput; - headers: RawHttpHeaders & TestRunGetDefaultHeaders; + body: ErrorResponse; + headers: RawHttpHeaders & LoadTestRunDeleteTestRunDefaultHeaders; } -/** Get test run file by file name. */ -export interface TestRunGetFile200Response extends HttpResponse { +/** The request has succeeded. */ +export interface LoadTestRunListTestRuns200Response extends HttpResponse { status: "200"; - body: FileInfoOutput; + body: PagedTestRunOutput; } -export interface TestRunGetFileDefaultHeaders { - /** The error code for specific error that occurred. */ +export interface LoadTestRunListTestRunsDefaultHeaders { + /** String error code indicating what went wrong. */ "x-ms-error-code"?: string; } -/** Get test run file by file name. */ -export interface TestRunGetFileDefaultResponse extends HttpResponse { +export interface LoadTestRunListTestRunsDefaultResponse extends HttpResponse { status: string; - body: ErrorResponseBodyOutput; - headers: RawHttpHeaders & TestRunGetFileDefaultHeaders; + body: ErrorResponse; + headers: RawHttpHeaders & LoadTestRunListTestRunsDefaultHeaders; } -/** Get all test runs with given filters */ -export interface TestRunList200Response extends HttpResponse { +/** The request has succeeded. */ +export interface LoadTestRunGetTestRunFile200Response extends HttpResponse { status: "200"; - body: TestRunsListOutput; + body: TestRunFileInfoOutput; } -export interface TestRunListDefaultHeaders { - /** The error code for specific error that occurred. */ +export interface LoadTestRunGetTestRunFileDefaultHeaders { + /** String error code indicating what went wrong. */ "x-ms-error-code"?: string; } -/** Get all test runs with given filters */ -export interface TestRunListDefaultResponse extends HttpResponse { +export interface LoadTestRunGetTestRunFileDefaultResponse extends HttpResponse { status: string; - body: ErrorResponseBodyOutput; - headers: RawHttpHeaders & TestRunListDefaultHeaders; + body: ErrorResponse; + headers: RawHttpHeaders & LoadTestRunGetTestRunFileDefaultHeaders; } -/** Stop test run by name. */ -export interface TestRunStop200Response extends HttpResponse { +/** The request has succeeded. */ +export interface LoadTestRunStopTestRun200Response extends HttpResponse { status: "200"; body: TestRunOutput; } -export interface TestRunStopDefaultHeaders { - /** The error code for specific error that occurred. */ +export interface LoadTestRunStopTestRunDefaultHeaders { + /** String error code indicating what went wrong. */ "x-ms-error-code"?: string; } -/** Stop test run by name. */ -export interface TestRunStopDefaultResponse extends HttpResponse { +export interface LoadTestRunStopTestRunDefaultResponse extends HttpResponse { status: string; - body: ErrorResponseBodyOutput; - headers: RawHttpHeaders & TestRunStopDefaultHeaders; + body: ErrorResponse; + headers: RawHttpHeaders & LoadTestRunStopTestRunDefaultHeaders; } -/** List the metric namespaces for a load test run. */ -export interface TestRunListMetricNamespaces200Response extends HttpResponse { +/** The request has succeeded. */ +export interface LoadTestRunListMetricNamespaces200Response + extends HttpResponse { status: "200"; body: MetricNamespaceCollectionOutput; } -export interface TestRunListMetricNamespacesDefaultHeaders { - /** The error code for specific error that occurred. */ +export interface LoadTestRunListMetricNamespacesDefaultHeaders { + /** String error code indicating what went wrong. */ "x-ms-error-code"?: string; } -/** List the metric namespaces for a load test run. */ -export interface TestRunListMetricNamespacesDefaultResponse extends HttpResponse { +export interface LoadTestRunListMetricNamespacesDefaultResponse + extends HttpResponse { status: string; - body: ErrorResponseBodyOutput; - headers: RawHttpHeaders & TestRunListMetricNamespacesDefaultHeaders; + body: ErrorResponse; + headers: RawHttpHeaders & LoadTestRunListMetricNamespacesDefaultHeaders; } -/** List the metric definitions for a load test run. */ -export interface TestRunListMetricDefinitions200Response extends HttpResponse { +/** The request has succeeded. */ +export interface LoadTestRunListMetricDefinitions200Response + extends HttpResponse { status: "200"; body: MetricDefinitionCollectionOutput; } -export interface TestRunListMetricDefinitionsDefaultHeaders { - /** The error code for specific error that occurred. */ +export interface LoadTestRunListMetricDefinitionsDefaultHeaders { + /** String error code indicating what went wrong. */ "x-ms-error-code"?: string; } -/** List the metric definitions for a load test run. */ -export interface TestRunListMetricDefinitionsDefaultResponse extends HttpResponse { +export interface LoadTestRunListMetricDefinitionsDefaultResponse + extends HttpResponse { status: string; - body: ErrorResponseBodyOutput; - headers: RawHttpHeaders & TestRunListMetricDefinitionsDefaultHeaders; + body: ErrorResponse; + headers: RawHttpHeaders & LoadTestRunListMetricDefinitionsDefaultHeaders; } -/** List the metric values for a load test run. */ -export interface TestRunListMetrics200Response extends HttpResponse { +/** The request has succeeded. */ +export interface LoadTestRunListMetrics200Response extends HttpResponse { status: "200"; body: MetricsOutput; } -export interface TestRunListMetricsDefaultHeaders { - /** The error code for specific error that occurred. */ +export interface LoadTestRunListMetricsDefaultHeaders { + /** String error code indicating what went wrong. */ "x-ms-error-code"?: string; } -/** List the metric values for a load test run. */ -export interface TestRunListMetricsDefaultResponse extends HttpResponse { +export interface LoadTestRunListMetricsDefaultResponse extends HttpResponse { status: string; - body: ErrorResponseBodyOutput; - headers: RawHttpHeaders & TestRunListMetricsDefaultHeaders; + body: ErrorResponse; + headers: RawHttpHeaders & LoadTestRunListMetricsDefaultHeaders; } -/** List the dimension values for the given metric dimension name. */ -export interface TestRunListMetricDimensionValues200Response extends HttpResponse { +/** The request has succeeded. */ +export interface LoadTestRunListMetricDimensionValues200Response + extends HttpResponse { status: "200"; body: DimensionValueListOutput; } -export interface TestRunListMetricDimensionValuesDefaultHeaders { - /** The error code for specific error that occurred. */ +export interface LoadTestRunListMetricDimensionValuesDefaultHeaders { + /** String error code indicating what went wrong. */ "x-ms-error-code"?: string; } -/** List the dimension values for the given metric dimension name. */ -export interface TestRunListMetricDimensionValuesDefaultResponse extends HttpResponse { +export interface LoadTestRunListMetricDimensionValuesDefaultResponse + extends HttpResponse { status: string; - body: ErrorResponseBodyOutput; - headers: RawHttpHeaders & TestRunListMetricDimensionValuesDefaultHeaders; + body: ErrorResponse; + headers: RawHttpHeaders & LoadTestRunListMetricDimensionValuesDefaultHeaders; } -/** Associate an app component (collection of azure resources) to a test run */ -export interface TestRunCreateOrUpdateAppComponents200Response extends HttpResponse { +/** The request has succeeded. */ +export interface LoadTestRunCreateOrUpdateAppComponents200Response + extends HttpResponse { status: "200"; body: TestRunAppComponentsOutput; } -/** Associate an app component (collection of azure resources) to a test run */ -export interface TestRunCreateOrUpdateAppComponents201Response extends HttpResponse { +/** The request has succeeded and a new resource has been created as a result. */ +export interface LoadTestRunCreateOrUpdateAppComponents201Response + extends HttpResponse { status: "201"; body: TestRunAppComponentsOutput; } -export interface TestRunCreateOrUpdateAppComponentsDefaultHeaders { - /** The error code for specific error that occurred. */ +export interface LoadTestRunCreateOrUpdateAppComponentsDefaultHeaders { + /** String error code indicating what went wrong. */ "x-ms-error-code"?: string; } -/** Associate an app component (collection of azure resources) to a test run */ -export interface TestRunCreateOrUpdateAppComponentsDefaultResponse extends HttpResponse { +export interface LoadTestRunCreateOrUpdateAppComponentsDefaultResponse + extends HttpResponse { status: string; - body: ErrorResponseBodyOutput; - headers: RawHttpHeaders & TestRunCreateOrUpdateAppComponentsDefaultHeaders; + body: ErrorResponse; + headers: RawHttpHeaders & + LoadTestRunCreateOrUpdateAppComponentsDefaultHeaders; } -/** Get associated app component (collection of azure resources) for the given test run. */ -export interface TestRunListAppComponents200Response extends HttpResponse { +/** The request has succeeded. */ +export interface LoadTestRunGetAppComponents200Response extends HttpResponse { status: "200"; body: TestRunAppComponentsOutput; } -export interface TestRunListAppComponentsDefaultHeaders { - /** The error code for specific error that occurred. */ +export interface LoadTestRunGetAppComponentsDefaultHeaders { + /** String error code indicating what went wrong. */ "x-ms-error-code"?: string; } -/** Get associated app component (collection of azure resources) for the given test run. */ -export interface TestRunListAppComponentsDefaultResponse extends HttpResponse { +export interface LoadTestRunGetAppComponentsDefaultResponse + extends HttpResponse { status: string; - body: ErrorResponseBodyOutput; - headers: RawHttpHeaders & TestRunListAppComponentsDefaultHeaders; + body: ErrorResponse; + headers: RawHttpHeaders & LoadTestRunGetAppComponentsDefaultHeaders; } -/** Configure server metrics for a test run */ -export interface TestRunCreateOrUpdateServerMetricsConfig200Response extends HttpResponse { +/** The request has succeeded. */ +export interface LoadTestRunCreateOrUpdateServerMetricsConfig200Response + extends HttpResponse { status: "200"; body: TestRunServerMetricConfigOutput; } -/** Configure server metrics for a test run */ -export interface TestRunCreateOrUpdateServerMetricsConfig201Response extends HttpResponse { +/** The request has succeeded and a new resource has been created as a result. */ +export interface LoadTestRunCreateOrUpdateServerMetricsConfig201Response + extends HttpResponse { status: "201"; body: TestRunServerMetricConfigOutput; } -export interface TestRunCreateOrUpdateServerMetricsConfigDefaultHeaders { - /** The error code for specific error that occurred. */ +export interface LoadTestRunCreateOrUpdateServerMetricsConfigDefaultHeaders { + /** String error code indicating what went wrong. */ "x-ms-error-code"?: string; } -/** Configure server metrics for a test run */ -export interface TestRunCreateOrUpdateServerMetricsConfigDefaultResponse extends HttpResponse { +export interface LoadTestRunCreateOrUpdateServerMetricsConfigDefaultResponse + extends HttpResponse { status: string; - body: ErrorResponseBodyOutput; - headers: RawHttpHeaders & TestRunCreateOrUpdateServerMetricsConfigDefaultHeaders; + body: ErrorResponse; + headers: RawHttpHeaders & + LoadTestRunCreateOrUpdateServerMetricsConfigDefaultHeaders; } -/** List server metrics configuration for the given test run. */ -export interface TestRunListServerMetricsConfig200Response extends HttpResponse { +/** The request has succeeded. */ +export interface LoadTestRunGetServerMetricsConfig200Response + extends HttpResponse { status: "200"; body: TestRunServerMetricConfigOutput; } -export interface TestRunListServerMetricsConfigDefaultHeaders { - /** The error code for specific error that occurred. */ +export interface LoadTestRunGetServerMetricsConfigDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface LoadTestRunGetServerMetricsConfigDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & LoadTestRunGetServerMetricsConfigDefaultHeaders; +} + +/** The request has succeeded. */ +export interface TestProfileAdministrationCreateOrUpdateTestProfile200Response + extends HttpResponse { + status: "200"; + body: TestProfileOutput; +} + +/** The request has succeeded and a new resource has been created as a result. */ +export interface TestProfileAdministrationCreateOrUpdateTestProfile201Response + extends HttpResponse { + status: "201"; + body: TestProfileOutput; +} + +export interface TestProfileAdministrationCreateOrUpdateTestProfileDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface TestProfileAdministrationCreateOrUpdateTestProfileDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & + TestProfileAdministrationCreateOrUpdateTestProfileDefaultHeaders; +} + +/** There is no content to send for this request, but the headers may be useful. */ +export interface TestProfileAdministrationDeleteTestProfile204Response + extends HttpResponse { + status: "204"; +} + +export interface TestProfileAdministrationDeleteTestProfileDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface TestProfileAdministrationDeleteTestProfileDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & + TestProfileAdministrationDeleteTestProfileDefaultHeaders; +} + +/** The request has succeeded. */ +export interface TestProfileAdministrationGetTestProfile200Response + extends HttpResponse { + status: "200"; + body: TestProfileOutput; +} + +export interface TestProfileAdministrationGetTestProfileDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface TestProfileAdministrationGetTestProfileDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & + TestProfileAdministrationGetTestProfileDefaultHeaders; +} + +/** The request has succeeded. */ +export interface TestProfileAdministrationListTestProfiles200Response + extends HttpResponse { + status: "200"; + body: PagedTestProfileOutput; +} + +export interface TestProfileAdministrationListTestProfilesDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface TestProfileAdministrationListTestProfilesDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & + TestProfileAdministrationListTestProfilesDefaultHeaders; +} + +/** The request has succeeded. */ +export interface TestProfileRunAdministrationGetTestProfileRun200Response + extends HttpResponse { + status: "200"; + body: TestProfileRunOutput; +} + +export interface TestProfileRunAdministrationGetTestProfileRunDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface TestProfileRunAdministrationGetTestProfileRunDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & + TestProfileRunAdministrationGetTestProfileRunDefaultHeaders; +} + +/** The request has succeeded. */ +export interface TestProfileRunAdministrationCreateOrUpdateTestProfileRun200Response + extends HttpResponse { + status: "200"; + body: TestProfileRunOutput; +} + +/** The request has succeeded and a new resource has been created as a result. */ +export interface TestProfileRunAdministrationCreateOrUpdateTestProfileRun201Response + extends HttpResponse { + status: "201"; + body: TestProfileRunOutput; +} + +export interface TestProfileRunAdministrationCreateOrUpdateTestProfileRunDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface TestProfileRunAdministrationCreateOrUpdateTestProfileRunDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & + TestProfileRunAdministrationCreateOrUpdateTestProfileRunDefaultHeaders; +} + +/** There is no content to send for this request, but the headers may be useful. */ +export interface TestProfileRunAdministrationDeleteTestProfileRun204Response + extends HttpResponse { + status: "204"; +} + +export interface TestProfileRunAdministrationDeleteTestProfileRunDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface TestProfileRunAdministrationDeleteTestProfileRunDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & + TestProfileRunAdministrationDeleteTestProfileRunDefaultHeaders; +} + +/** The request has succeeded. */ +export interface TestProfileRunAdministrationStopTestProfileRun200Response + extends HttpResponse { + status: "200"; + body: TestProfileRunOutput; +} + +export interface TestProfileRunAdministrationStopTestProfileRunDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface TestProfileRunAdministrationStopTestProfileRunDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & + TestProfileRunAdministrationStopTestProfileRunDefaultHeaders; +} + +/** The request has succeeded. */ +export interface TestProfileRunAdministrationListTestProfileRuns200Response + extends HttpResponse { + status: "200"; + body: PagedTestProfileRunOutput; +} + +export interface TestProfileRunAdministrationListTestProfileRunsDefaultHeaders { + /** String error code indicating what went wrong. */ "x-ms-error-code"?: string; } -/** List server metrics configuration for the given test run. */ -export interface TestRunListServerMetricsConfigDefaultResponse extends HttpResponse { +export interface TestProfileRunAdministrationListTestProfileRunsDefaultResponse + extends HttpResponse { status: string; - body: ErrorResponseBodyOutput; - headers: RawHttpHeaders & TestRunListServerMetricsConfigDefaultHeaders; + body: ErrorResponse; + headers: RawHttpHeaders & + TestProfileRunAdministrationListTestProfileRunsDefaultHeaders; } diff --git a/sdk/loadtesting/load-testing-rest/src/util/LROUtil.ts b/sdk/loadtesting/load-testing-rest/src/util/LROUtil.ts deleted file mode 100644 index 728d110327ad..000000000000 --- a/sdk/loadtesting/load-testing-rest/src/util/LROUtil.ts +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -import { AbortError, AbortSignalLike } from "@azure/abort-controller"; -import { TestRunOutput } from "../outputModels"; - -const REJECTED_ERR = new AbortError("The polling was aborted."); - -export function sleep(ms: number, signal: AbortSignalLike): Promise { - return new Promise((resolve, reject) => { - if (signal.aborted) { - reject(REJECTED_ERR); - return; - } - - const id = setTimeout(() => { - signal.removeEventListener("abort", onAbort); - - if (signal.aborted) { - reject(REJECTED_ERR); - return; - } - - resolve(); - }, ms); - - signal.addEventListener("abort", onAbort, { once: true }); - - function onAbort(): void { - clearTimeout(id); - reject(REJECTED_ERR); - } - }); -} - -export function isTestRunInProgress(testRunOutput: TestRunOutput): boolean { - switch (testRunOutput.status) { - case "ACCEPTED": - case "NOTSTARTED": - case "PROVISIONING": - case "PROVISIONED": - case "CONFIGURING": - case "CONFIGURED": - case "EXECUTING": - case "EXECUTED": - case "DEPROVISIONING": - case "DEPROVISIONED": - case "CANCELLING": - return true; - default: - return false; - } -} diff --git a/sdk/loadtesting/load-testing-rest/swagger/README.md b/sdk/loadtesting/load-testing-rest/swagger/README.md deleted file mode 100644 index 0e01ea5538b9..000000000000 --- a/sdk/loadtesting/load-testing-rest/swagger/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# Azure Load Testing Typescript Protocol Layer - -> see https://aka.ms/autorest - -## Configuration - -```yaml -package-name: "@azure-rest/load-testing" -title: Azure Load Testing -description: Azure Load Testing Client -generate-metadata: true -generate-test: true -license-header: MICROSOFT_MIT_NO_VERSION -output-folder: ../ -source-code-folder-path: ./src -input-file: https://github.com/Azure/azure-rest-api-specs/blob/main/specification/loadtestservice/data-plane/Microsoft.LoadTestService/stable/2022-11-01/loadtestservice.json -package-version: 1.0.1 -rest-level-client: true -security: AADToken -security-scopes: "https://cnt-prod.loadtesting.azure.com/.default" -use-extension: - "@autorest/typescript": "6.0.0-rc.3" -service-versions: -- '2022-11-01' -``` diff --git a/sdk/loadtesting/load-testing-rest/test/public/additional-data.csv b/sdk/loadtesting/load-testing-rest/test/public/additional-data.csv deleted file mode 100644 index 96dbf5b98a39..000000000000 --- a/sdk/loadtesting/load-testing-rest/test/public/additional-data.csv +++ /dev/null @@ -1,2 +0,0 @@ -a,b,c,d -1,2,3,4 diff --git a/sdk/loadtesting/load-testing-rest/test/public/sample.jmx b/sdk/loadtesting/load-testing-rest/test/public/sample.jmx deleted file mode 100644 index 66cb722cab9c..000000000000 --- a/sdk/loadtesting/load-testing-rest/test/public/sample.jmx +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - false - false - - - - - - - - continue - - false - 10 - - 1 - 2 - 1515063650000 - 1515063650000 - false - 10 - - true - - - - - - - microsoft.com - - - - / - GET - true - false - true - false - - - - - - - - false - - saveConfig - - - true - true - true - - true - true - true - true - false - true - true - false - false - false - true - false - false - false - true - 0 - true - true - true - true - true - true - - - - - - - - diff --git a/sdk/loadtesting/load-testing-rest/test/public/testAdministration.spec.ts b/sdk/loadtesting/load-testing-rest/test/public/testAdministration.spec.ts deleted file mode 100644 index 91c0c02eac59..000000000000 --- a/sdk/loadtesting/load-testing-rest/test/public/testAdministration.spec.ts +++ /dev/null @@ -1,163 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import { assert } from "chai"; -import { createClient, createRecorder } from "./utils/recordedClient"; -import { Context } from "mocha"; -import { AzureLoadTestingClient, isUnexpected } from "../../src"; -import { env, isPlaybackMode, Recorder } from "@azure-tools/test-recorder"; -import * as fs from "fs"; -import { isNodeLike } from "@azure/core-util"; -import { getLongRunningPoller } from "../../src/pollingHelper"; - -describe("Test Creation", () => { - let recorder: Recorder; - let client: AzureLoadTestingClient; - let readStreamTestFile: fs.ReadStream; - let readStreamAdditionalFile: fs.ReadStream; - - beforeEach(async function (this: Context) { - recorder = await createRecorder(this); - if (!isNodeLike || isPlaybackMode()) { - this.skip(); - } - client = createClient(recorder); - readStreamTestFile = fs.createReadStream("./test/public/sample.jmx"); - readStreamAdditionalFile = fs.createReadStream("./test/public/additional-data.csv"); - }); - - afterEach(async function () { - await recorder.stop(); - }); - - // patch/put - it("should create a loadtest", async () => { - const result = await client.path("/tests/{testId}", "abc").patch({ - contentType: "application/merge-patch+json", - body: { - displayName: "sample_test", - description: "", - loadTestConfiguration: { - engineInstances: 1, - splitAllCSVs: false, - }, - }, - }); - - assert.include(["200", "201"], result.status); - }); - - it("should upload the additional file without LRO", async () => { - const result = await client - .path("/tests/{testId}/files/{fileName}", "abc", "additional-data.csv") - .put({ - contentType: "application/octet-stream", - body: readStreamAdditionalFile, - queryParameters: { - fileType: "ADDITIONAL_ARTIFACTS", - }, - }); - - assert.include(["201"], result.status); - }); - - it("should not upload the test file with LRO(timeout)", async () => { - const fileUploadResult = await client - .path("/tests/{testId}/files/{fileName}", "abc", "sample.jmx") - .put({ - contentType: "application/octet-stream", - body: readStreamTestFile, - }); - - if (isUnexpected(fileUploadResult)) { - throw fileUploadResult.body.error; - } - - const fileValidatePoller = await getLongRunningPoller(client, fileUploadResult); - try { - await fileValidatePoller.pollUntilDone({ - abortSignal: AbortSignal.timeout(10), // timeout of 10 milliseconds - }); - } catch (ex: any) { - assert.equal(ex.message, "The polling was aborted."); - return; - } - - assert.fail(); - }); - - it("should upload the test file with LRO", async () => { - const fileUploadResult = await client - .path("/tests/{testId}/files/{fileName}", "abc", "sample.jmx") - .put({ - contentType: "application/octet-stream", - body: readStreamTestFile, - }); - - if (isUnexpected(fileUploadResult)) { - throw fileUploadResult.body.error; - } - - const fileValidatePoller = await getLongRunningPoller(client, fileUploadResult); - await fileValidatePoller.pollUntilDone({ - abortSignal: AbortSignal.timeout(60000), // timeout of 60 seconds - }); - assert.equal(fileValidatePoller.getOperationState().status, "succeeded"); - }); - - it("should create the app components", async () => { - const SUBSCRIPTION_ID = env["SUBSCRIPTION_ID"] || ""; - const result = await client.path("/tests/{testId}/app-components", "abc").patch({ - contentType: "application/merge-patch+json", - body: { - testId: "abc", - components: { - "/subscriptions/{SUBSCRIPTION_ID}/resourceGroups/App-Service-Sample-Demo-rg/providers/Microsoft.Web/sites/App-Service-Sample-Demo": - { - resourceId: - "/subscriptions/{SUBSCRIPTION_ID}/resourceGroups/App-Service-Sample-Demo-rg/providers/Microsoft.Web/sites/App-Service-Sample-Demo", - resourceName: "App-Service-Sample-Demo", - resourceType: "Microsoft.Web/sites", - subscriptionId: SUBSCRIPTION_ID, - }, - }, - }, - }); - - assert.include(["200", "201"], result.status); - }); - - // get - it("should get the test file", async () => { - const result = await client.path("/tests/{testId}/files/{fileName}", "abc", "sample.jmx").get(); - - assert.include(["200"], result.status); - }); - - it("should get the test", async () => { - const result = await client.path("/tests/{testId}", "abc").get(); - - assert.include(["200"], result.status); - }); - - it("should get the test app components", async () => { - const result = await client.path("/tests/{testId}/app-components", "abc").get(); - - assert.include(["200"], result.status); - }); - - // delete - it("should delete the test file", async () => { - const result = await client - .path("/tests/{testId}/files/{fileName}", "abc", "sample.jmx") - .delete(); - - assert.include(["204"], result.status); - }); - - it("should delete the test", async () => { - const result = await client.path("/tests/{testId}", "abc").delete(); - - assert.include(["204"], result.status); - }); -}); diff --git a/sdk/loadtesting/load-testing-rest/test/public/testRun.spec.ts b/sdk/loadtesting/load-testing-rest/test/public/testRun.spec.ts deleted file mode 100644 index af5bd3020d7e..000000000000 --- a/sdk/loadtesting/load-testing-rest/test/public/testRun.spec.ts +++ /dev/null @@ -1,190 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import { env, isPlaybackMode, Recorder } from "@azure-tools/test-recorder"; -import { assert } from "chai"; -import { createRecorder, createClient } from "./utils/recordedClient"; -import { Context } from "mocha"; -import * as fs from "fs"; -import { AzureLoadTestingClient, isUnexpected } from "../../src"; -import { isNodeLike } from "@azure/core-util"; -import { getLongRunningPoller } from "../../src/pollingHelper"; - -describe("Test Run Creation", () => { - let recorder: Recorder; - let client: AzureLoadTestingClient; - const SUBSCRIPTION_ID = env["SUBSCRIPTION_ID"] || ""; - let readStreamTestFile: fs.ReadStream; - - beforeEach(async function (this: Context) { - recorder = await createRecorder(this); - if (!isNodeLike || isPlaybackMode()) { - this.skip(); - } - client = createClient(recorder); - readStreamTestFile = fs.createReadStream("./test/public/sample.jmx"); - }); - - afterEach(async function () { - await recorder.stop(); - }); - - it("should create a loadtest", async () => { - const result = await client.path("/tests/{testId}", "abc").patch({ - contentType: "application/merge-patch+json", - body: { - displayName: "sample_test", - description: "", - loadTestConfiguration: { - engineInstances: 1, - splitAllCSVs: false, - }, - }, - }); - - assert.include(["200", "201"], result.status); - }); - - it("should upload the test file with LRO", async () => { - const fileUploadResult = await client - .path("/tests/{testId}/files/{fileName}", "abc", "sample.jmx") - .put({ - contentType: "application/octet-stream", - body: readStreamTestFile, - }); - - if (isUnexpected(fileUploadResult)) { - throw fileUploadResult.body.error; - } - - const fileValidatePoller = await getLongRunningPoller(client, fileUploadResult); - await fileValidatePoller.pollUntilDone({ - abortSignal: AbortSignal.timeout(60000), // timeout of 60 seconds - }); - assert.equal(fileValidatePoller.getOperationState().status, "succeeded"); - }); - - it("should not be able to create a test run(404)", async () => { - const testRunCreationResult = await client.path("/test-runs/{testRunId}", "abcjad").patch({ - contentType: "application/merge-patch+json", - body: { - testId: "abc", - displayName: "sample123", - virtualUsers: 10, - }, - }); - - if (isUnexpected(testRunCreationResult)) { - throw testRunCreationResult.body.error; - } - - testRunCreationResult.body.testRunId = "adjwfjsdmf"; - const testRunPoller = await getLongRunningPoller(client, testRunCreationResult); - await testRunPoller.pollUntilDone({ - abortSignal: AbortSignal.timeout(60000), // timeout of 60 seconds - }); - - assert.equal(testRunPoller.getOperationState().status, "failed"); - }); - - it("should timeout the test run", async () => { - const testRunCreationResult = await client - .path("/test-runs/{testRunId}", "randomtestrun4") - .patch({ - contentType: "application/merge-patch+json", - body: { - testId: "abc", - displayName: "sample123", - virtualUsers: 10, - }, - }); - - if (isUnexpected(testRunCreationResult)) { - throw testRunCreationResult.body.error; - } - - const testRunPoller = await getLongRunningPoller(client, testRunCreationResult); - try { - await testRunPoller.pollUntilDone({ - abortSignal: AbortSignal.timeout(10), // timeout of 10 millieconds - }); - } catch (ex: any) { - assert.equal(ex.name, "AbortError"); - return; - } - - assert.fail(); - }); - - it("should be able to create a test run", async () => { - const testRunCreationResult = await client.path("/test-runs/{testRunId}", "abcde").patch({ - contentType: "application/merge-patch+json", - body: { - testId: "abc", - displayName: "sample123", - virtualUsers: 10, - }, - }); - - if (isUnexpected(testRunCreationResult)) { - throw testRunCreationResult.body.error; - } - - const testRunPoller = await getLongRunningPoller(client, testRunCreationResult); - await testRunPoller.pollUntilDone({ - abortSignal: AbortSignal.timeout(60000), // timeout of 60 seconds - }); - - assert.equal(testRunPoller.getOperationState().status, "succeeded"); - }); - - it("should get a test run", async () => { - const result = await client.path("/test-runs/{testRunId}", "abcde").get(); - - assert.include(["200"], result.status); - }); - - it("should create a app component for test run", async () => { - const result = await client.path("/test-runs/{testRunId}/app-components", "abcde").patch({ - contentType: "application/merge-patch+json", - body: { - components: { - "/subscriptions/{SUBSCRIPTION_ID}/resourceGroups/App-Service-Sample-Demo-rg/providers/Microsoft.Web/sites/App-Service-Sample-Demo": - { - resourceId: - "/subscriptions/{SUBSCRIPTION_ID}/resourceGroups/App-Service-Sample-Demo-rg/providers/Microsoft.Web/sites/App-Service-Sample-Demo", - resourceName: "App-Service-Sample-Demo", - resourceType: "Microsoft.Web/sites", - subscriptionId: SUBSCRIPTION_ID, - }, - }, - }, - }); - - assert.include(["200", "201"], result.status); - }); - - it("should get a test run app components", async () => { - const result = await client.path("/test-runs/{testRunId}/app-components", "abcde").get(); - - assert.include(["200"], result.status); - }); - - it("should get a test run server metrics config", async () => { - const result = await client.path("/test-runs/{testRunId}/server-metrics-config", "abcde").get(); - - assert.include(["200"], result.status); - }); - - it("should delete a test run", async () => { - const result = await client.path("/test-runs/{testRunId}", "abcde").delete(); - - assert.include(["204"], result.status); - }); - - it("should delete the test", async () => { - const result = await client.path("/tests/{testId}", "abc").delete(); - - assert.include(["204"], result.status); - }); -}); diff --git a/sdk/loadtesting/load-testing-rest/test/public/utils/env.browser.ts b/sdk/loadtesting/load-testing-rest/test/public/utils/env.browser.ts deleted file mode 100644 index fc36ab244fad..000000000000 --- a/sdk/loadtesting/load-testing-rest/test/public/utils/env.browser.ts +++ /dev/null @@ -1,2 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. diff --git a/sdk/loadtesting/load-testing-rest/test/public/utils/env.ts b/sdk/loadtesting/load-testing-rest/test/public/utils/env.ts deleted file mode 100644 index 866412f4082d..000000000000 --- a/sdk/loadtesting/load-testing-rest/test/public/utils/env.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import * as dotenv from "dotenv"; - -dotenv.config(); diff --git a/sdk/loadtesting/load-testing-rest/test/public/utils/recordedClient.ts b/sdk/loadtesting/load-testing-rest/test/public/utils/recordedClient.ts deleted file mode 100644 index af3981f05fa3..000000000000 --- a/sdk/loadtesting/load-testing-rest/test/public/utils/recordedClient.ts +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -import AzureLoadTesting, { AzureLoadTestingClient } from "../../../src"; -import { Context } from "mocha"; -import { Recorder, env, RecorderStartOptions } from "@azure-tools/test-recorder"; -import "./env"; - -import { ClientOptions } from "@azure-rest/core-client"; -import { createTestCredential } from "@azure-tools/test-credential"; - -const credential = createTestCredential(); - -const envSetupForPlayback: Record = { - LOADTESTSERVICE_ENDPOINT: "endpoint", - SUBSCRIPTION_ID: "azure_subscription_id", -}; - -const recorderEnvSetup: RecorderStartOptions = { - envSetupForPlayback, - removeCentralSanitizers: [ - "AZSDK3493", // .name in the body is not a secret and is listed below in the beforeEach section - ], -}; - -export function createClient( - recorder: Recorder, - options: ClientOptions = {}, -): AzureLoadTestingClient { - return AzureLoadTesting( - env.LOADTESTSERVICE_ENDPOINT || "", - credential, - recorder.configureClientOptions(options), - ); -} - -/** - * creates the recorder and reads the environment variables from the `.env` file. - * Should be called first in the test suite to make sure environment variables are - * read before they are being used. - */ -export async function createRecorder(context: Context): Promise { - const recorder = new Recorder(context.currentTest); - await recorder.start(recorderEnvSetup); - return recorder; -} diff --git a/sdk/loadtesting/load-testing-rest/tsconfig.json b/sdk/loadtesting/load-testing-rest/tsconfig.json deleted file mode 100644 index 513b0a33f593..000000000000 --- a/sdk/loadtesting/load-testing-rest/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "../../../tsconfig", - "compilerOptions": { - "outDir": "./dist-esm", - "declarationDir": "./types", - "paths": { - "@azure-rest/load-testing": ["./src/index"] - } - }, - "include": ["src/**/*.ts", "./test/**/*.ts", "samples-dev/**/*.ts"] -} diff --git a/sdk/loadtesting/load-testing-rest/tsp-location.yaml b/sdk/loadtesting/load-testing-rest/tsp-location.yaml new file mode 100644 index 000000000000..0a587dee6eb6 --- /dev/null +++ b/sdk/loadtesting/load-testing-rest/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/loadtestservice/LoadTestService +commit: 79970e07d1956a072e69c5edc2df82e839e4d04c +repo: /mnt/vss/_work/1/s/azure-rest-api-specs +additionalDirectories: