feat(cli-integ): bootstrap test environments with a random qualifier - #1789
Merged
aws-cdk-automation merged 1 commit intoJul 31, 2026
Merged
Conversation
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
aws-cdk-automation
enabled auto-merge
July 31, 2026 10:22
mrgrain
commented
Jul 31, 2026
| * `toolkitStackName: fixture.bootstrapStackName` (or via `ensureBootstrapped`, | ||
| * which uses that stack name by default). | ||
| */ | ||
| public async bootstrapRepoName(): Promise<string> { |
Contributor
Author
There was a problem hiding this comment.
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.
2 tasks
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
marked this pull request as draft
July 31, 2026 13:46
iliapolo
approved these changes
Jul 31, 2026
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
TestFixturekeeps an app context dict (seeded with the qualifier) that the app fixtures write into the app'scdk.json. This also covers invocations bypassingfixture.cdk(), and command-line--contextstill wins. Tests can add their own context viaaddAppContext()or the nestablewithAppContext()block. Tests that hardcoded default-qualifier resource names now derive them from the fixture.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license