11import { GetInsightCommand , ThrottledException , XRayClient } from "@aws-sdk/client-xray" ;
22import { HttpResponse } from "@aws-sdk/protocol-http" ;
33import { RequestHandlerOutput } from "@aws-sdk/types" ;
4+ import { StandardRetryStrategy } from "@aws-sdk/util-retry" ;
45import { Readable } from "stream" ;
56
67describe ( "Middleware-retry integration tests" , ( ) => {
@@ -26,6 +27,7 @@ describe("Middleware-retry integration tests", () => {
2627 handle : ( ) => Promise . resolve ( mockSuccess ) ,
2728 } ,
2829 } ) ;
30+ expect ( await client . config . retryStrategy ( ) ) . toBeInstanceOf ( StandardRetryStrategy ) ;
2931 const response = await client . send ( getInsightCommand ) ;
3032 expect ( response . $metadata . httpStatusCode ) . toBe ( 200 ) ;
3133 expect ( response . $metadata . attempts ) . toBe ( 1 ) ;
@@ -42,11 +44,12 @@ describe("Middleware-retry integration tests", () => {
4244 handle : mockHandle ,
4345 } ,
4446 } ) ;
47+ expect ( await client . config . retryStrategy ( ) ) . toBeInstanceOf ( StandardRetryStrategy ) ;
4548 const response = await client . send ( getInsightCommand ) ;
4649 expect ( response . $metadata . httpStatusCode ) . toBe ( 200 ) ;
4750 expect ( mockHandle ) . toBeCalledTimes ( 3 ) ;
4851 expect ( response . $metadata . attempts ) . toBe ( 3 ) ;
49- expect ( response . $metadata . totalRetryDelay ) . toBeGreaterThan ( 300 ) ;
52+ expect ( response . $metadata . totalRetryDelay ) . toBeGreaterThan ( 0 ) ;
5053 } ) ;
5154 it ( "should retry until attemps are exhausted" , async ( ) => {
5255 const expectedException = new ThrottledException ( {
@@ -60,13 +63,14 @@ describe("Middleware-retry integration tests", () => {
6063 handle : ( ) => Promise . resolve ( mockThrottled ) ,
6164 } ,
6265 } ) ;
66+ expect ( await client . config . retryStrategy ( ) ) . toBeInstanceOf ( StandardRetryStrategy ) ;
6367 try {
6468 await client . send ( getInsightCommand ) ;
6569 } catch ( error ) {
6670 expect ( error ) . toStrictEqual ( expectedException ) ;
6771 expect ( error . $metadata . httpStatusCode ) . toBe ( 429 ) ;
6872 expect ( error . $metadata . attempts ) . toBe ( 4 ) ;
69- expect ( error . $metadata . totalRetryDelay ) . toBeGreaterThan ( 300 ) ;
73+ expect ( error . $metadata . totalRetryDelay ) . toBeGreaterThan ( 0 ) ;
7074 }
7175 } ) ;
7276} ) ;
0 commit comments