Skip to content

Commit

Permalink
fix(aws-client-retry-test): correct retry delay assertion (#4274)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe committed Dec 12, 2022
1 parent 2ebe2e5 commit 5bfcda6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions private/aws-client-retry-test/src/ClientRetryTest.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { GetInsightCommand, ThrottledException, XRayClient } from "@aws-sdk/client-xray";
import { HttpResponse } from "@aws-sdk/protocol-http";
import { RequestHandlerOutput } from "@aws-sdk/types";
import { StandardRetryStrategy } from "@aws-sdk/util-retry";
import { Readable } from "stream";

describe("Middleware-retry integration tests", () => {
Expand All @@ -26,6 +27,7 @@ describe("Middleware-retry integration tests", () => {
handle: () => Promise.resolve(mockSuccess),
},
});
expect(await client.config.retryStrategy()).toBeInstanceOf(StandardRetryStrategy);
const response = await client.send(getInsightCommand);
expect(response.$metadata.httpStatusCode).toBe(200);
expect(response.$metadata.attempts).toBe(1);
Expand All @@ -42,11 +44,12 @@ describe("Middleware-retry integration tests", () => {
handle: mockHandle,
},
});
expect(await client.config.retryStrategy()).toBeInstanceOf(StandardRetryStrategy);
const response = await client.send(getInsightCommand);
expect(response.$metadata.httpStatusCode).toBe(200);
expect(mockHandle).toBeCalledTimes(3);
expect(response.$metadata.attempts).toBe(3);
expect(response.$metadata.totalRetryDelay).toBeGreaterThan(300);
expect(response.$metadata.totalRetryDelay).toBeGreaterThan(0);
});
it("should retry until attemps are exhausted", async () => {
const expectedException = new ThrottledException({
Expand All @@ -60,13 +63,14 @@ describe("Middleware-retry integration tests", () => {
handle: () => Promise.resolve(mockThrottled),
},
});
expect(await client.config.retryStrategy()).toBeInstanceOf(StandardRetryStrategy);
try {
await client.send(getInsightCommand);
} catch (error) {
expect(error).toStrictEqual(expectedException);
expect(error.$metadata.httpStatusCode).toBe(429);
expect(error.$metadata.attempts).toBe(4);
expect(error.$metadata.totalRetryDelay).toBeGreaterThan(300);
expect(error.$metadata.totalRetryDelay).toBeGreaterThan(0);
}
});
});

0 comments on commit 5bfcda6

Please sign in to comment.