Skip to content

Commit 514ee86

Browse files
committed
fix: add back retry logic so that tests can run
1 parent 5ffe5d2 commit 514ee86

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

packages/core/src/shared/clients/codecatalystClient.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { DevSettings } from '../settings'
4040
import { getServiceEnvVarConfig } from '../vscode/env'
4141
import { AwsCommand } from '../awsClientBuilderV3'
4242
import { ClientWrapper } from './clientWrapper'
43+
import { StandardRetryStrategy } from '@smithy/util-retry'
4344

4445
export interface CodeCatalystConfig {
4546
readonly region: string
@@ -137,13 +138,15 @@ function toBranch(
137138
async function createCodeCatalystClient(
138139
connection: SsoConnection,
139140
regionCode: string,
140-
endpoint: string
141+
endpoint: string,
142+
maxRetries: number
141143
): Promise<CodeCatalyst> {
142144
const c = await globals.sdkClientBuilder.createAwsService(CodeCatalyst, {
143145
region: regionCode,
144146
correctClockSkew: true,
145147
endpoint: endpoint,
146148
token: new TokenProvider(connection),
149+
maxRetries,
147150
} as ServiceConfigurationOptions)
148151

149152
return c
@@ -152,14 +155,16 @@ async function createCodeCatalystClient(
152155
function createCodeCatalystClientV3(
153156
connection: SsoConnection,
154157
regionCode: string,
155-
endpoint: string
158+
endpoint: string,
159+
maxRetries: number
156160
): CodeCatalystSDKClient {
157161
return globals.sdkClientBuilderV3.createAwsService({
158162
serviceClient: CodeCatalystSDKClient,
159163
clientOptions: {
160164
region: regionCode,
161165
endpoint: endpoint,
162166
token: new TokenProvider(connection),
167+
retryStrategy: new StandardRetryStrategy(maxRetries),
163168
},
164169
})
165170
}
@@ -192,10 +197,11 @@ export async function createClient(
192197
connection: SsoConnection,
193198
regionCode = getCodeCatalystConfig().region,
194199
endpoint = getCodeCatalystConfig().endpoint,
200+
maxRetries: number = 1,
195201
authOptions: AuthOptions = {}
196202
): Promise<CodeCatalystClient> {
197-
const sdkClient = await createCodeCatalystClient(connection, regionCode, endpoint)
198-
const sdkv3Client = createCodeCatalystClientV3(connection, regionCode, endpoint)
203+
const sdkClient = await createCodeCatalystClient(connection, regionCode, endpoint, maxRetries)
204+
const sdkv3Client = createCodeCatalystClientV3(connection, regionCode, endpoint, maxRetries)
199205
const c = new CodeCatalystClientInternal(connection, sdkClient, sdkv3Client)
200206
try {
201207
await c.verifySession()

packages/core/src/test/shared/awsClientBuilderV3.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ abstract class TestClientBase implements AwsClient {
386386
public middlewareStack: { add: MiddlewareStack<any, MetadataBearer>['add'] } = {
387387
add: (_: any, __: any) => {},
388388
}
389-
public async send(command: AwsCommand, options?: any): Promise<any> {}
389+
public async send(command: AwsCommand<object, object>, options?: any): Promise<any> {}
390390
public destroy(): void {}
391391
}
392392

packages/core/src/testE2E/codecatalyst/client.test.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -425,15 +425,9 @@ describe('Test how this codebase uses the CodeCatalyst API', function () {
425425
*/
426426
async function createTestCodeCatalystClient(auth: Auth): Promise<CodeCatalystClient> {
427427
const conn = await useCodeCatalystSsoConnection(auth)
428-
return await createCodeCatalystClient(conn, undefined, undefined, {
429-
// Add retries for tests since many may be running in parallel in github CI.
430-
// AWS SDK adds jitter automatically.
431-
// https://github.com/aws/aws-sdk-js/blob/3e616251947c73d5239178c167a9d73d985ca581/lib/util.js#L884
432-
retryDelayOptions: {
433-
base: 1200, // ms
434-
},
435-
maxRetries: 5,
436-
})
428+
// Add retries for tests since many may be running in parallel in github CI.
429+
// AWS SDK adds jitter automatically.
430+
return await createCodeCatalystClient(conn, undefined, undefined, 5)
437431
}
438432

439433
/**

0 commit comments

Comments
 (0)