Skip to content

Commit

Permalink
chore: bootstrap stack too old for integ tests (#17277)
Browse files Browse the repository at this point in the history
The integ tests try to be clever to save time, and rebootstrap an
account and region pair only if the bootstrap stack does not exist
yet.

This is not good enough if the **version** of the bootstrap stack
changes though (no rebootstrapping will happen), and the following
error will occur:

```
❌  cdktest-0n94n0po827f-test-2 failed: Error: cdktest-0n94n0po827f-test-2: This CDK deployment requires bootstrap stack version '6', found '4'. Please run 'cdk bootstrap'.
```

Instead, always bootstrap every account/region pair at least once
per run. It will take some time, but in most cases we'll be able to
short-circuit the CFN deployment, so it will take ~2s instead of
~20 per case.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
rix0rrr authored Nov 2, 2021
1 parent a7c869e commit ca9320b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/aws-cdk/test/integ/helpers/cdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,11 +541,12 @@ let sanityChecked: boolean | undefined;
* by hand so let's just mass-automate it.
*/
async function ensureBootstrapped(fixture: TestFixture) {
// Use the default name for the bootstrap stack
if (await fixture.aws.stackStatus('CDKToolkit') === undefined) {
// use whatever version of bootstrap is the default for this particular version of the CLI
await fixture.cdk(['bootstrap', `aws://${await fixture.aws.account()}/${fixture.aws.region}`]);
}
// use whatever version of bootstrap is the default for this particular version of the CLI
const envSpecifier = `aws://${await fixture.aws.account()}/${fixture.aws.region}`;
if (ALREADY_BOOTSTRAPPED_IN_THIS_RUN.has(envSpecifier)) { return; }

await fixture.cdk(['bootstrap', envSpecifier]);
ALREADY_BOOTSTRAPPED_IN_THIS_RUN.add(envSpecifier);
}

/**
Expand Down Expand Up @@ -689,3 +690,5 @@ const installNpm7 = memoize0(async (): Promise<string> => {

return path.join(installDir, 'node_modules', '.bin', 'npm');
});

const ALREADY_BOOTSTRAPPED_IN_THIS_RUN = new Set();

0 comments on commit ca9320b

Please sign in to comment.