Skip to content

Commit 6ac80a8

Browse files
authored
[load-testing-rest] pass PolledOperationOptions to getLongRunningPoller (#35164)
This PR passes PolledOperationOptions to getLongRunningPoller, allowing customers to change the interval between polls.
1 parent e92d51a commit 6ac80a8

File tree

4 files changed

+51
-14
lines changed

4 files changed

+51
-14
lines changed

sdk/loadtesting/load-testing-rest/review/load-testing-node.api.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,13 @@ export interface FunctionFlexConsumptionTargetResourceConfigurationsOutput exten
193193
export type GetArrayType<T> = T extends Array<infer TData> ? TData : never;
194194

195195
// @public (undocumented)
196-
export function getLongRunningPoller(client: AzureLoadTestingClient, initialResponse: TestUploadFileSuccessResponse): Promise<FileUploadAndValidatePoller>;
196+
export function getLongRunningPoller(client: AzureLoadTestingClient, initialResponse: TestUploadFileSuccessResponse, polledOperationOptions?: PolledOperationOptions): Promise<FileUploadAndValidatePoller>;
197197

198198
// @public (undocumented)
199-
export function getLongRunningPoller(client: AzureLoadTestingClient, initialResponse: TestRunCreateOrUpdateSuccessResponse): Promise<TestRunCompletionPoller>;
199+
export function getLongRunningPoller(client: AzureLoadTestingClient, initialResponse: TestRunCreateOrUpdateSuccessResponse, polledOperationOptions?: PolledOperationOptions): Promise<TestRunCompletionPoller>;
200200

201201
// @public (undocumented)
202-
export function getLongRunningPoller(client: AzureLoadTestingClient, initialResponse: TestProfileRunCreateOrUpdateSuccessResponse): Promise<TestProfileRunCompletionPoller>;
202+
export function getLongRunningPoller(client: AzureLoadTestingClient, initialResponse: TestProfileRunCreateOrUpdateSuccessResponse, polledOperationOptions?: PolledOperationOptions): Promise<TestProfileRunCompletionPoller>;
203203

204204
// @public
205205
export type GetPage<TPage> = (pageLink: string) => Promise<{

sdk/loadtesting/load-testing-rest/src/pollingHelper.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,38 @@ import type {
1212
TestRunCreateOrUpdateSuccessResponse,
1313
TestProfileRunCreateOrUpdateSuccessResponse,
1414
TestProfileRunCompletionPoller,
15+
PolledOperationOptions,
1516
} from "./models.js";
1617

1718
export async function getLongRunningPoller(
1819
client: AzureLoadTestingClient,
1920
initialResponse: TestUploadFileSuccessResponse,
21+
polledOperationOptions?: PolledOperationOptions,
2022
): Promise<FileUploadAndValidatePoller>;
2123
export async function getLongRunningPoller(
2224
client: AzureLoadTestingClient,
2325
initialResponse: TestRunCreateOrUpdateSuccessResponse,
26+
polledOperationOptions?: PolledOperationOptions,
2427
): Promise<TestRunCompletionPoller>;
2528
export async function getLongRunningPoller(
2629
client: AzureLoadTestingClient,
2730
initialResponse: TestProfileRunCreateOrUpdateSuccessResponse,
31+
polledOperationOptions?: PolledOperationOptions,
2832
): Promise<TestProfileRunCompletionPoller>;
2933
export async function getLongRunningPoller(
3034
client: AzureLoadTestingClient,
3135
initialResponse:
3236
| TestRunCreateOrUpdateSuccessResponse
3337
| TestUploadFileSuccessResponse
3438
| TestProfileRunCreateOrUpdateSuccessResponse,
39+
polledOperationOptions: PolledOperationOptions = {},
3540
): Promise<TestRunCompletionPoller | FileUploadAndValidatePoller | TestProfileRunCompletionPoller> {
3641
if (isFileUpload(initialResponse)) {
37-
return getFileValidationPoller(client, initialResponse);
42+
return getFileValidationPoller(client, initialResponse, polledOperationOptions);
3843
} else if (isTestRunCreation(initialResponse)) {
39-
return getTestRunCompletionPoller(client, initialResponse);
44+
return getTestRunCompletionPoller(client, initialResponse, polledOperationOptions);
4045
} else if (isTestProfileRunCreation(initialResponse)) {
41-
return getTestProfileRunCompletionPoller(client, initialResponse);
46+
return getTestProfileRunCompletionPoller(client, initialResponse, polledOperationOptions);
4247
}
4348

4449
throw new Error("The Operation is not a long running operation.");

sdk/loadtesting/load-testing-rest/test/public/node/testAdministration.spec.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@ import type {
99
} from "../../../src/index.js";
1010
import { isUnexpected } from "../../../src/index.js";
1111
import type { Recorder } from "@azure-tools/test-recorder";
12-
import { env } from "@azure-tools/test-recorder";
12+
import { env, isPlaybackMode } from "@azure-tools/test-recorder";
1313
import fs from "node:fs";
1414
import { getLongRunningPoller } from "../../../src/pollingHelper.js";
1515
import { describe, it, assert, beforeEach, afterEach } from "vitest";
1616

17+
const testPollingOptions = {
18+
updateIntervalInMs: isPlaybackMode() ? 0 : undefined,
19+
};
20+
1721
describe("Test Administration Operations", () => {
1822
let recorder: Recorder;
1923
let client: AzureLoadTestingClient;
@@ -100,7 +104,11 @@ describe("Test Administration Operations", () => {
100104
throw fileUploadResult.body.error;
101105
}
102106

103-
const fileValidatePoller = await getLongRunningPoller(client, fileUploadResult);
107+
const fileValidatePoller = await getLongRunningPoller(
108+
client,
109+
fileUploadResult,
110+
testPollingOptions,
111+
);
104112
await fileValidatePoller.pollUntilDone({
105113
abortSignal: AbortSignal.timeout(60000), // timeout of 60 seconds
106114
});
@@ -209,7 +217,11 @@ describe("Test Profile Administration Operations", () => {
209217
throw fileUploadResult.body.error;
210218
}
211219

212-
const fileValidatePoller = await getLongRunningPoller(client, fileUploadResult);
220+
const fileValidatePoller = await getLongRunningPoller(
221+
client,
222+
fileUploadResult,
223+
testPollingOptions,
224+
);
213225
await fileValidatePoller.pollUntilDone({
214226
abortSignal: AbortSignal.timeout(60000), // timeout of 60 seconds
215227
});

sdk/loadtesting/load-testing-rest/test/public/node/testRun.spec.ts

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the MIT License.
33

44
import type { Recorder } from "@azure-tools/test-recorder";
5-
import { env } from "@azure-tools/test-recorder";
5+
import { env, isPlaybackMode } from "@azure-tools/test-recorder";
66
import { createRecorder, createClient } from "../utils/recordedClient.js";
77
import type {
88
AppComponent,
@@ -15,6 +15,10 @@ import fs from "node:fs";
1515
import { getLongRunningPoller } from "../../../src/pollingHelper.js";
1616
import { describe, it, assert, beforeEach, afterEach } from "vitest";
1717

18+
const testPollingOptions = {
19+
updateIntervalInMs: isPlaybackMode() ? 0 : undefined,
20+
};
21+
1822
describe("Test Run Operations", () => {
1923
let recorder: Recorder;
2024
let client: AzureLoadTestingClient;
@@ -61,7 +65,11 @@ describe("Test Run Operations", () => {
6165
throw fileUploadResult.body.error;
6266
}
6367

64-
const fileValidatePoller = await getLongRunningPoller(client, fileUploadResult);
68+
const fileValidatePoller = await getLongRunningPoller(
69+
client,
70+
fileUploadResult,
71+
testPollingOptions,
72+
);
6573
await fileValidatePoller.pollUntilDone({
6674
abortSignal: AbortSignal.timeout(60000), // timeout of 60 seconds
6775
});
@@ -121,7 +129,11 @@ describe("Test Run Operations", () => {
121129
throw testRunCreationResult.body.error;
122130
}
123131

124-
const testRunPoller = await getLongRunningPoller(client, testRunCreationResult);
132+
const testRunPoller = await getLongRunningPoller(
133+
client,
134+
testRunCreationResult,
135+
testPollingOptions,
136+
);
125137
await testRunPoller.pollUntilDone({
126138
abortSignal: AbortSignal.timeout(600000),
127139
});
@@ -234,7 +246,11 @@ describe("Test Profile Run Operations", () => {
234246
throw fileUploadResult.body.error;
235247
}
236248

237-
const fileValidatePoller = await getLongRunningPoller(client, fileUploadResult);
249+
const fileValidatePoller = await getLongRunningPoller(
250+
client,
251+
fileUploadResult,
252+
testPollingOptions,
253+
);
238254
await fileValidatePoller.pollUntilDone({
239255
abortSignal: AbortSignal.timeout(60000), // timeout of 60 seconds
240256
});
@@ -293,7 +309,11 @@ describe("Test Profile Run Operations", () => {
293309
throw testProfileRunCreationResult.body.error;
294310
}
295311

296-
const testProfileRunPoller = await getLongRunningPoller(client, testProfileRunCreationResult);
312+
const testProfileRunPoller = await getLongRunningPoller(
313+
client,
314+
testProfileRunCreationResult,
315+
testPollingOptions,
316+
);
297317
const polledResult = await testProfileRunPoller.pollUntilDone({
298318
abortSignal: AbortSignal.timeout(1200000),
299319
});

0 commit comments

Comments
 (0)