Skip to content

Commit a5c2da9

Browse files
authored
fix(e2e): limit PR tests to Bedrock-only and improve credential cleanup (#728)
1 parent 60b5946 commit a5c2da9

2 files changed

Lines changed: 17 additions & 19 deletions

File tree

.github/workflows/e2e-tests.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,6 @@ jobs:
106106
OPENAI_API_KEY: ${{ env.E2E_OPENAI_API_KEY }}
107107
GEMINI_API_KEY: ${{ env.E2E_GEMINI_API_KEY }}
108108
CDK_TARBALL: ${{ env.CDK_TARBALL }}
109-
run: npx vitest run --project e2e strands-bedrock strands-openai langgraph-bedrock googleadk-gemini
109+
# Only run Bedrock tests on PRs to avoid creating ApiKeyCredentialProviders,
110+
# which have a 50-resource account limit and accumulate from interrupted runs.
111+
run: npx vitest run --project e2e strands-bedrock langgraph-bedrock

e2e-tests/e2e-helper.ts

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -332,12 +332,22 @@ export function installCdkTarball(projectPath: string): void {
332332
}
333333
}
334334

335+
async function deleteCredentialProvider(client: BedrockAgentCoreControlClient, name: string): Promise<void> {
336+
try {
337+
await client.send(new DeleteApiKeyCredentialProviderCommand({ name }));
338+
console.log(`Deleted credential provider: ${name}`);
339+
} catch (error) {
340+
const code = (error as { name?: string }).name ?? 'Unknown';
341+
console.warn(`Failed to delete credential provider ${name}: [${code}]`);
342+
}
343+
}
344+
335345
/**
336346
* Delete stale E2e* credential providers older than the given max age.
337347
* Runs in beforeAll to prevent accumulation from previous runs that
338348
* crashed or timed out before their afterAll teardown could execute.
339349
*/
340-
export async function cleanupStaleCredentialProviders(maxAgeMs: number = 60 * 60 * 1000): Promise<void> {
350+
export async function cleanupStaleCredentialProviders(maxAgeMs: number = 30 * 60 * 1000): Promise<void> {
341351
const region = process.env.AWS_REGION ?? 'us-east-1';
342352
const client = new BedrockAgentCoreControlClient({ region });
343353
const cutoff = new Date(Date.now() - maxAgeMs);
@@ -348,16 +358,7 @@ export async function cleanupStaleCredentialProviders(maxAgeMs: number = 60 * 60
348358
const providers = response.credentialProviders ?? [];
349359
const stale = providers.filter(p => p.name?.startsWith('E2e') && p.createdTime && p.createdTime < cutoff);
350360

351-
await Promise.all(
352-
stale.map(async p => {
353-
try {
354-
await client.send(new DeleteApiKeyCredentialProviderCommand({ name: p.name! }));
355-
console.log(`Cleaned up stale credential provider: ${p.name}`);
356-
} catch {
357-
console.warn(`Failed to clean up stale credential provider: ${p.name}`);
358-
}
359-
})
360-
);
361+
await Promise.all(stale.map(p => deleteCredentialProvider(client, p.name!)));
361362

362363
nextToken = response.nextToken;
363364
} while (nextToken);
@@ -371,13 +372,8 @@ export async function teardownE2EProject(projectPath: string, agentName: string,
371372
console.log('Teardown stderr:', result.stderr);
372373
}
373374
if (modelProvider !== 'Bedrock' && agentName) {
374-
const providerName = `${agentName}${modelProvider}`;
375375
const region = process.env.AWS_REGION ?? 'us-east-1';
376-
try {
377-
const client = new BedrockAgentCoreControlClient({ region });
378-
await client.send(new DeleteApiKeyCredentialProviderCommand({ name: providerName }));
379-
} catch {
380-
// Best-effort cleanup
381-
}
376+
const client = new BedrockAgentCoreControlClient({ region });
377+
await deleteCredentialProvider(client, `${agentName}${modelProvider}`);
382378
}
383379
}

0 commit comments

Comments
 (0)