From deadb015c69ae7043c1c19102177f3c257aea2cd Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Tue, 2 Nov 2021 17:02:05 +0100 Subject: [PATCH] chore: integ tests don't always rebootstrap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- packages/aws-cdk/test/integ/helpers/cdk.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/aws-cdk/test/integ/helpers/cdk.ts b/packages/aws-cdk/test/integ/helpers/cdk.ts index edf996ba36ed6..340aae771f275 100644 --- a/packages/aws-cdk/test/integ/helpers/cdk.ts +++ b/packages/aws-cdk/test/integ/helpers/cdk.ts @@ -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); } /** @@ -689,3 +690,5 @@ const installNpm7 = memoize0(async (): Promise => { return path.join(installDir, 'node_modules', '.bin', 'npm'); }); + +const ALREADY_BOOTSTRAPPED_IN_THIS_RUN = new Set(); \ No newline at end of file