Skip to content

feat(cli-integ): bootstrap test environments with a random qualifier - #1789

Merged
aws-cdk-automation merged 1 commit into
mainfrom
mrgrain/feat/cli-integ/random-bootstrap-qualifier
Jul 31, 2026
Merged

feat(cli-integ): bootstrap test environments with a random qualifier#1789
aws-cdk-automation merged 1 commit into
mainfrom
mrgrain/feat/cli-integ/random-bootstrap-qualifier

Conversation

@mrgrain

@mrgrain mrgrain commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Fixes #

The integ tests bootstrap every environment with the fixed default qualifier, so the bootstrap bucket always gets the same deterministic name. With recycled test environments this regularly makes the bucket name unavailable — S3's eventual consistency lets CloudFormation believe the previous bucket still exists and the bootstrap fails. We currently paper over this with a retry loop.

This change bootstraps each test fixture with its own random qualifier and toolkit stack name, making bucket names unique so the collision can't occur (the retry stays as a safety net). As a bonus, every test now exercises the custom bootstrap qualifier feature instead of always running on the default.

Apps automatically receive the qualifier: TestFixture keeps an app context dict (seeded with the qualifier) that the app fixtures write into the app's cdk.json. This also covers invocations bypassing fixture.cdk(), and command-line --context still wins. Tests can add their own context via addAppContext() or the nestable withAppContext() block. Tests that hardcoded default-qualifier resource names now derive them from the fixture.

Checklist

  • This change contains a major version upgrade for a dependency and I confirm all breaking changes are addressed
    • Release notes for the new version:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@aws-cdk-automation
aws-cdk-automation requested a review from a team July 31, 2026 10:22
* `toolkitStackName: fixture.bootstrapStackName` (or via `ensureBootstrapped`,
* which uses that stack name by default).
*/
public async bootstrapRepoName(): Promise<string> {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the ensureBootstrapped() call that used to be here. It was vestigial: it bootstrapped the default CDKToolkit stack, which never matched the fixture.bootstrapStackName lookup below — the assertion only ever passed because all callers (the gc ECR tests) explicitly bootstrap that stack first. With the new per-fixture bootstrap it would have become harmful, re-bootstrapping the caller's stack with --bootstrap-kms-key-id AWS_MANAGED_KEY and triggering a CloudFormation update (bucket encryption change) mid-test.

@mrgrain
mrgrain changed the base branch from main to mrgrain/fix/toolkit-lib/refactor-custom-toolkit-stack-name July 31, 2026 13:25
auto-merge was automatically disabled July 31, 2026 13:26

Merge commits are not allowed on this repository

@mrgrain
mrgrain marked this pull request as draft July 31, 2026 13:46
Instead of bootstrapping every test environment with the fixed default
qualifier, each test fixture now bootstraps with its own random qualifier
and a per-fixture toolkit stack name. This makes bootstrap bucket names
unique across (potentially recycled) test environments, avoiding S3
eventual-consistency collisions on the fixed default bucket name.

Apps automatically receive the qualifier: TestFixture keeps an app
context dict (seeded with the qualifier) that the app fixtures write
into the app's cdk.json. Tests can add more context via addAppContext()
or the new nestable withAppContext() block.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants