From 71380571b878a50fe4b754c7dac78da075a98242 Mon Sep 17 00:00:00 2001 From: Cory Hall <43035978+corymhall@users.noreply.github.com> Date: Thu, 26 May 2022 12:37:52 -0400 Subject: [PATCH] fix(integ-runner): always resynth on deploy (#20508) We were trying to save time by re-using a previously synthed cloud assembly if it existed, but we should not be doing this. When we perform the deployment we could be using new settings (or context) that needs to be applied to the synth. ---- ### All Submissions: * [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../@aws-cdk/integ-runner/lib/runner/integ-test-runner.ts | 2 +- packages/@aws-cdk/integ-runner/lib/runner/runner-base.ts | 8 ++------ .../integ-runner/test/runner/integ-test-runner.test.ts | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/@aws-cdk/integ-runner/lib/runner/integ-test-runner.ts b/packages/@aws-cdk/integ-runner/lib/runner/integ-test-runner.ts index 705f9f045e6e9..3c325d34c3700 100644 --- a/packages/@aws-cdk/integ-runner/lib/runner/integ-test-runner.ts +++ b/packages/@aws-cdk/integ-runner/lib/runner/integ-test-runner.ts @@ -259,7 +259,7 @@ export class IntegTestRunner extends IntegRunner { ...actualTestCase?.cdkCommandOptions?.deploy?.args, ...actualTestCase.assertionStack ? { outputsFile: path.join(this.cdkOutDir, 'assertion-results.json') } : undefined, context: this.getContext(actualTestCase?.cdkCommandOptions?.deploy?.args?.context), - app: this.hasTmpActualSnapshot() ? this.cdkOutDir : this.cdkApp, + app: this.cdkApp, }); if (actualTestCase.hooks?.postDeploy) { diff --git a/packages/@aws-cdk/integ-runner/lib/runner/runner-base.ts b/packages/@aws-cdk/integ-runner/lib/runner/runner-base.ts index eff0e68191acb..18b8a3c6e9f64 100644 --- a/packages/@aws-cdk/integ-runner/lib/runner/runner-base.ts +++ b/packages/@aws-cdk/integ-runner/lib/runner/runner-base.ts @@ -146,7 +146,7 @@ export abstract class IntegRunner { this.testName = testName; } else { const relativePath = path.relative(options.directory, parsed.dir); - this.testName = `${relativePath ? relativePath+'/' : ''}${parsed.name}`; + this.testName = `${relativePath ? relativePath + '/' : ''}${parsed.name}`; } this.snapshotDir = path.join(this.directory, `${testName}.integ.snapshot`); this.relativeSnapshotDir = `${testName}.integ.snapshot`; @@ -210,10 +210,6 @@ export abstract class IntegRunner { return fs.existsSync(this.snapshotDir); } - public hasTmpActualSnapshot(): boolean { - return fs.existsSync(path.join(this.directory, this.cdkOutDir)); - } - /** * Load the integ manifest which contains information * on how to execute the tests @@ -371,7 +367,7 @@ export abstract class IntegRunner { } protected getContext(additionalContext?: Record): Record { - const futureFlags: {[key: string]: any} = {}; + const futureFlags: { [key: string]: any } = {}; Object.entries(FUTURE_FLAGS) .filter(([k, _]) => !FUTURE_FLAGS_EXPIRED.includes(k)) .forEach(([k, v]) => futureFlags[k] = v); diff --git a/packages/@aws-cdk/integ-runner/test/runner/integ-test-runner.test.ts b/packages/@aws-cdk/integ-runner/test/runner/integ-test-runner.test.ts index 78f321e81d9aa..db4c4a434554d 100644 --- a/packages/@aws-cdk/integ-runner/test/runner/integ-test-runner.test.ts +++ b/packages/@aws-cdk/integ-runner/test/runner/integ-test-runner.test.ts @@ -78,7 +78,7 @@ describe('IntegTest runIntegTests', () => { stacks: ['test-stack'], }); expect(deployMock).toHaveBeenCalledWith({ - app: 'cdk-integ.out.test-with-snapshot', + app: 'node integ.test-with-snapshot.js', requireApproval: 'never', pathMetadata: false, assetMetadata: false,