Skip to content

Commit eb233b4

Browse files
authored
[AppConfig] allow setting updateIntervalInMs in LRO options (#27200)
also add a `testPollingOptions` in recorder to help testing in playback mode.
1 parent 45d9f36 commit eb233b4

File tree

9 files changed

+32
-14
lines changed

9 files changed

+32
-14
lines changed

sdk/appconfiguration/app-configuration/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
### Features Added
77

8+
- Allow setting `updateIntervalInMs` in `CreateSnapshotOptions`
9+
810
### Bugs Fixed
911

1012
### Other Changes

sdk/appconfiguration/app-configuration/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
"@azure/identity": "^2.0.1",
100100
"@azure/keyvault-secrets": "^4.2.0",
101101
"@azure-tools/test-credential": "^1.0.0",
102-
"@azure-tools/test-recorder": "^3.0.0",
102+
"@azure-tools/test-recorder": "^3.1.0",
103103
"@azure/test-utils": "^1.0.0",
104104
"@microsoft/api-extractor": "^7.31.1",
105105
"@types/chai": "^4.1.6",

sdk/appconfiguration/app-configuration/review/app-configuration.api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export interface ConfigurationSettingsFilter {
9999

100100
// @public
101101
export interface CreateSnapshotOptions extends OperationOptions {
102+
updateIntervalInMs?: number;
102103
}
103104

104105
// @public

sdk/appconfiguration/app-configuration/src/models.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,12 @@ export interface RetryOptions {
461461
/**
462462
* Options used when creating a Snapshot.
463463
*/
464-
export interface CreateSnapshotOptions extends OperationOptions {}
464+
export interface CreateSnapshotOptions extends OperationOptions {
465+
/**
466+
* The amount of time to wait (in milliseconds) between subsequent requests relating to the same operation.
467+
*/
468+
updateIntervalInMs?: number;
469+
}
465470

466471
/**
467472
* Response from adding a Snapshot.

sdk/appconfiguration/app-configuration/test/public/snapshot.spec.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
3-
import { Recorder, isPlaybackMode } from "@azure-tools/test-recorder";
3+
import { Recorder, isPlaybackMode, testPollingOptions } from "@azure-tools/test-recorder";
44
import { assert } from "chai";
55
import { Context } from "mocha";
66
import { AppConfigurationClient } from "../../src/appConfigurationClient";
@@ -59,7 +59,7 @@ describe("AppConfigurationClient snapshot", () => {
5959
describe("createSnapshot", () => {
6060
it("create a snapshot", async () => {
6161
// creating a new snapshot
62-
const poller = await client.beginCreateSnapshot(snapshot1);
62+
const poller = await client.beginCreateSnapshot(snapshot1, testPollingOptions);
6363
newSnapshot = await poller.pollUntilDone();
6464
assertEqualSnapshot(newSnapshot, snapshot1);
6565

@@ -68,7 +68,7 @@ describe("AppConfigurationClient snapshot", () => {
6868

6969
it("service throws error when tried to create a snapshot with same name", async () => {
7070
// creating a new snapshot
71-
newSnapshot = await client.beginCreateSnapshotAndWait(snapshot1);
71+
newSnapshot = await client.beginCreateSnapshotAndWait(snapshot1, testPollingOptions);
7272
assertEqualSnapshot(newSnapshot, snapshot1);
7373

7474
const errorExpected = {
@@ -80,7 +80,7 @@ describe("AppConfigurationClient snapshot", () => {
8080

8181
// attempt to add the same snapshot
8282
try {
83-
await client.beginCreateSnapshotAndWait(snapshot1);
83+
await client.beginCreateSnapshotAndWait(snapshot1, testPollingOptions);
8484
throw new Error("Test failure");
8585
} catch (err: any) {
8686
assert.equal(err.message, JSON.stringify(errorExpected));
@@ -98,6 +98,7 @@ describe("AppConfigurationClient snapshot", () => {
9898
requestOptions: {
9999
timeout: 1,
100100
},
101+
updateIntervalInMs: testPollingOptions.updateIntervalInMs,
101102
});
102103
});
103104
});
@@ -106,7 +107,7 @@ describe("AppConfigurationClient snapshot", () => {
106107
describe("listConfigurationSettings of a Snapshot", () => {
107108
it("list configuration settings", async () => {
108109
// creating a new snapshot
109-
newSnapshot = await client.beginCreateSnapshotAndWait(snapshot1);
110+
newSnapshot = await client.beginCreateSnapshotAndWait(snapshot1, testPollingOptions);
110111

111112
// change the value of the setting
112113
await client.setConfigurationSetting({ ...filter1, value: "value2" });
@@ -129,7 +130,7 @@ describe("AppConfigurationClient snapshot", () => {
129130
describe("archiveSnapshot", () => {
130131
it("archive a snapshot", async () => {
131132
// creating a new snapshot
132-
newSnapshot = await client.beginCreateSnapshotAndWait(snapshot1);
133+
newSnapshot = await client.beginCreateSnapshotAndWait(snapshot1, testPollingOptions);
133134
const archivedSnapshot = await client.archiveSnapshot(newSnapshot);
134135

135136
assert.equal(
@@ -154,7 +155,7 @@ describe("AppConfigurationClient snapshot", () => {
154155
describe("getSnapshot", () => {
155156
it("get a snapshot", async () => {
156157
// creating a new snapshot
157-
newSnapshot = await client.beginCreateSnapshotAndWait(snapshot1);
158+
newSnapshot = await client.beginCreateSnapshotAndWait(snapshot1, testPollingOptions);
158159

159160
const snapshot = await client.getSnapshot(newSnapshot.name);
160161
assertEqualSnapshot(snapshot, newSnapshot);
@@ -165,7 +166,7 @@ describe("AppConfigurationClient snapshot", () => {
165166
it.skip("accepts operation options", async function () {
166167
if (isPlaybackMode()) this.skip();
167168
// creating a new snapshot
168-
newSnapshot = await client.beginCreateSnapshotAndWait(snapshot1);
169+
newSnapshot = await client.beginCreateSnapshotAndWait(snapshot1, testPollingOptions);
169170
await assertThrowsAbortError(async () => {
170171
await client.getSnapshot(newSnapshot.name, {
171172
requestOptions: {
@@ -194,14 +195,14 @@ describe("AppConfigurationClient snapshot", () => {
194195
assert.equal(num, 0, "There should be no snapshot in ready status");
195196

196197
// creating a new snapshot 1
197-
await client.beginCreateSnapshotAndWait(snapshot1);
198+
await client.beginCreateSnapshotAndWait(snapshot1, testPollingOptions);
198199

199200
// create a new snapshot 2
200201
const snapshot2 = {
201202
name: recorder.variable("snapshot2", `snapshot-${new Date().getTime()}`),
202203
filters: [filter1, filter2],
203204
};
204-
await client.beginCreateSnapshotAndWait(snapshot2);
205+
await client.beginCreateSnapshotAndWait(snapshot2, testPollingOptions);
205206

206207
// new snapshot lists
207208
const listAfter = await client.listSnapshots({ statusFilter: ["ready"] });

sdk/test-utils/recorder/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# Release History
22

3-
## 3.0.1 (Unreleased)
3+
## 3.1.0 (Unreleased)
44

55
### Features Added
66

77
- Add support for setting `TLSValidationCert` in the Test Proxy Transport.
8+
- Add a `testPollingOptions` that allow skip polling wait in playback mode.
89

910
### Breaking Changes
1011

sdk/test-utils/recorder/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@azure-tools/test-recorder",
3-
"version": "3.0.1",
3+
"version": "3.1.0",
44
"sdk-type": "utility",
55
"description": "This library provides interfaces and helper methods to provide recording and playback capabilities for the tests in Azure JS/TS SDKs",
66
"main": "dist/index.js",

sdk/test-utils/recorder/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export {
1010
isPlaybackMode,
1111
isRecordMode,
1212
assertEnvironmentVariable,
13+
testPollingOptions,
1314
} from "./utils/utils";
1415
export { env } from "./utils/env";
1516
export { delay } from "./utils/delay";

sdk/test-utils/recorder/src/utils/utils.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,3 +363,10 @@ export function assertEnvironmentVariable(variable: string): string {
363363
if (!value) throw new Error(`${variable} is not defined`);
364364
return value;
365365
}
366+
367+
/**
368+
* Polling options that don't wait in playback mode.
369+
*/
370+
export const testPollingOptions = {
371+
updateIntervalInMs: isPlaybackMode() ? 0 : undefined,
372+
};

0 commit comments

Comments
 (0)