Files
Himanshu BishtandGitHub 9de86dafb0 [Azure Load Testing] Updating JavaScript SDK to new data plane api version 2025-11-01-preview (#37055)
Generated new sdk for data plane api version 2025-11-01-preview
SDK is generated with the help of typespec
API spec change PR -
https://github.com/Azure/azure-rest-api-specs/pull/39372

### Packages impacted by this PR
@azure-rest/load-testing

### Issues associated with this PR


### Describe the problem that is addressed by this PR
SDK for new data plane api version

### What are the possible designs available to address the problem? If
there are more than one possible design, why was the one in this PR
chosen?


### Are there test cases added in this PR? _(If not, why?)_


### Provide a list of related PRs _(if any)_
API spec change PR -
https://github.com/Azure/azure-rest-api-specs/pull/39372

### Command used to generate this PR:**_(Applicable only to SDK release
request PRs)_
Referred this doc for sdk generation -
https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/RLC-quickstart.md
Updated tsp-location.yaml and ran tsp-client update 

### Checklists
- [x] Added impacted package name to the issue description
- [ ] Does this PR needs any fixes in the SDK Generator?** _(If so,
create an Issue in the
[Autorest/typescript](https://github.com/Azure/autorest.typescript)
repository and link it here)_
- [x] Added a changelog (if necessary)
2026-03-18 11:10:35 +05:30

64 lines
2.2 KiB
JavaScript

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
/**
* This sample demonstrates how to upload a JMX test script file
*
* @summary Demonstrates how to upload a test script file.
*/
const AzureLoadTesting = require("@azure-rest/load-testing").default,
{ isUnexpected, getLongRunningPoller } = require("@azure-rest/load-testing");
const { DefaultAzureCredential } = require("@azure/identity");
const { createReadStream } = require("node:fs");
const readStream = createReadStream("./sample.jmx");
async function main() {
/**
* The dataplane endpoint for the Azure Load Testing resource.
* Refer to https://learn.microsoft.com/rest/api/apptesting/loadtest/data-plane-uri to understand how to obtain the data-plane endpoint.
*/
const endpoint = process.env["LOADTESTSERVICE_ENDPOINT"] || "";
/** Microsoft Entra ID authentication */
/**
* In this sample you can populate the three AZURE_CLIENT_ID, AZURE_CLIENT_SECRET & AZURE_TENANT_ID variables for Microsoft Entra ID auth
*/
const credential = new DefaultAzureCredential();
const testId = process.env["LOADTESTSERVICE_TESTID"] || ""; // TestId of a test already created.
// Build a client through AAD
const client = AzureLoadTesting(endpoint, credential);
// Uploading .jmx test script file for 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 fileValidationResult;
const fileValidationPoller = await getLongRunningPoller(client, fileUploadResult);
try {
fileValidationResult = await fileValidationPoller.pollUntilDone({
abortSignal: AbortSignal.timeout(120 * 1000), // Time out polling in 120 seconds
});
} catch (ex) {
throw new Error("Error in polling file validation status: " + ex.message); // Validation might have timed out.
}
if (fileValidationPoller.getOperationState().status !== "succeeded" && fileValidationResult) {
throw new Error(
"There is some issue in validation, please make sure the upload file is a valid JMX file.",
);
}
}
main().catch(console.error);