From 3f90eb41a15730886f32d72c7636b7c34d6da891 Mon Sep 17 00:00:00 2001 From: corymhall <43035978+corymhall@users.noreply.github.com> Date: Fri, 3 Jun 2022 14:54:57 +0000 Subject: [PATCH] fix(integ-runner): don't allow new legacy tests All new integration tests that are created should use the new `IntegTest` construct in the [@aws-cdk/integ-tests](https://github.com/aws/aws-cdk/tree/main/packages/%40aws-cdk/integ-tests) module. We will eventually be migrating all of our tests to the new construct and removing the "legacy" mode, so this PR will fail any new test that is added that doesn't use the `IntegTest` construct. I've also renamed some of the `test-data` files so that they will not be picked up by the `integ-runner` if you execute it on the entire repo. --- CONTRIBUTING.md | 24 ++-- INTEGRATION_TESTS.md | 52 +++++++- .../lib/runner/integ-test-runner.ts | 10 ++ .../integ-runner/lib/runner/runner-base.ts | 2 + .../test/runner/integ-test-runner.test.ts | 121 +++++------------ .../test/runner/snapshot-test-runner.test.ts | 72 ++++++++-- .../cdk-integ.out.integ-test1/integ.json | 8 ++ .../integ.json | 2 +- .../integ.json | 2 +- .../integ.json | 2 +- .../manifest.json | 2 +- .../integ.json | 2 +- .../manifest.json | 2 +- .../integ.json | 2 +- .../integ.json | 2 +- .../manifest.json | 2 +- ...eg.integ-test1.ts => xxxxx.integ-test1.ts} | 0 ...eg.integ-test2.ts => xxxxx.integ-test2.ts} | 0 ...> xxxxx.test-with-snapshot-assets-diff.ts} | 0 ....ts => xxxxx.test-with-snapshot-assets.ts} | 0 ...napshot.ts => xxxxx.test-with-snapshot.ts} | 0 .../test/workers/integ-worker.test.ts | 126 +++++++++--------- .../test/workers/snapshot-worker.test.ts | 6 +- 23 files changed, 252 insertions(+), 187 deletions(-) create mode 100644 packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.integ-test1/integ.json rename packages/@aws-cdk/integ-runner/test/test-data/{integ.integ-test1.ts => xxxxx.integ-test1.ts} (100%) rename packages/@aws-cdk/integ-runner/test/test-data/{integ.integ-test2.ts => xxxxx.integ-test2.ts} (100%) rename packages/@aws-cdk/integ-runner/test/test-data/{integ.test-with-snapshot-assets-diff.ts => xxxxx.test-with-snapshot-assets-diff.ts} (100%) rename packages/@aws-cdk/integ-runner/test/test-data/{integ.test-with-snapshot-assets.ts => xxxxx.test-with-snapshot-assets.ts} (100%) rename packages/@aws-cdk/integ-runner/test/test-data/{integ.test-with-snapshot.ts => xxxxx.test-with-snapshot.ts} (100%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 465138d34cc63..e08a10b9a0a6e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -256,7 +256,7 @@ Work your magic. Here are some guidelines: Integration tests perform a few functions in the CDK code base - 1. Acts as a regression detector. It does this by running `cdk synth` on the integration test and comparing it against - the `*.expected.json` file. This highlights how a change affects the synthesized stacks. + the `*.integ.snapshot` directory. This highlights how a change affects the synthesized stacks. 2. Allows for a way to verify if the stacks are still valid CloudFormation templates, as part of an intrusive change. This is done by running `yarn integ` which will run `cdk deploy` across all of the integration tests in that package. If you are developing a new integration test or for some other reason want to work on a single integration test over and over again without running through all the integration tests you can do so using `yarn integ integ.test-name.js` Remember to set up AWS credentials before doing this. @@ -275,9 +275,10 @@ new features unless there is a good reason why one is not needed. 4. Adding a new supported version (e.g. a new [AuroraMysqlEngineVersion](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_rds.AuroraMysqlEngineVersion.html)) 5. Adding any functionality via a [Custom Resource](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.custom_resources-readme.html) -To the extent possible, include a section (like below) in the integration test file that specifies how the successfully -deployed stack can be verified for correctness. Correctness here implies that the resources have been set up correctly. -The steps here are usually AWS CLI commands but they need not be. +All integration tests going forward should use the [IntegTest](https://github.com/aws/aws-cdk/tree/main/packages/%40aws-cdk/integ-tests) +construct. Over time we will be updating all of our existing tests to use this construct. It +allows for more control over configuring each tests as well as the ability to perform +assertions against the deployed infrastructure. ```ts /* @@ -288,8 +289,8 @@ The steps here are usually AWS CLI commands but they need not be. ``` Examples: -* [integ.destinations.ts](https://github.com/aws/aws-cdk/blob/main/packages/%40aws-cdk/aws-lambda-destinations/test/integ.destinations.ts#L7) -* [integ.token-authorizer.lit.ts](https://github.com/aws/aws-cdk/blob/main/packages/%40aws-cdk/aws-apigateway/test/authorizers/integ.token-authorizer.lit.ts#L7-L12) +* [integ.destinations.ts](https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/aws-lambda-destinations/test/integ.destinations.ts#L7) +* [integ.put-events.ts](https://github.com/aws/aws-cdk/blob/main/packages/%40aws-cdk/aws-stepfunctions-tasks/test/eventbridge/integ.put-events.ts) **What do do if you cannot run integration tests** @@ -827,16 +828,7 @@ $ /link-all.sh ### Running integration tests in parallel -Integration tests may take a long time to complete. We can speed this up by running them in parallel -in different regions. - -```shell -# Install GNU parallel (may require uninstall 'moreutils' if you have it) -$ apt-get install parallel -$ brew install parallel - -$ scripts/run-integ-parallel @aws-cdk/aws-ec2 @aws-cdk/aws-autoscaling ... -``` +See the [Integration testing guide](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md#running-large-numbers-of-tests) ### Visualizing dependencies in a CloudFormation Template diff --git a/INTEGRATION_TESTS.md b/INTEGRATION_TESTS.md index f6c95623d1093..3414ebdcc5bb7 100644 --- a/INTEGRATION_TESTS.md +++ b/INTEGRATION_TESTS.md @@ -85,6 +85,7 @@ _integ.lambda.ts_ import * as iam from '@aws-cdk/aws-iam'; import * as cdk from '@aws-cdk/core'; import * as lambda from '../lib'; +import * as integ from '@aws-cdk/integ-tests'; const app = new cdk.App(); @@ -96,6 +97,10 @@ const fn = new lambda.Function(stack, 'MyLambda', { runtime: lambda.Runtime.NODEJS_10_X, }); +new integ.IntegTest(app, 'LambdaTest', { + testCases: [stack], +}); + app.synth(); ``` @@ -223,7 +228,52 @@ but it will not validate that the Lambda function can be invoked. Because of thi to deploy the Lambda Function _and_ then rerun the assertions to ensure that the function can still be invoked. ### Assertions -...Coming soon... + +Sometimes it is necessary to perform some form of _assertion_ against the deployed infrastructure to validate that the +test succeeds. A good example of this is the `@aws-cdk/aws-stepfunctions-tasks` module which creates integrations between +AWS StepFunctions and other AWS services. + +If we look at the [integ.put-events.ts](https://github.com/aws/aws-cdk/blob/main/packages/%40aws-cdk/aws-stepfunctions-tasks/test/eventbridge/integ.put-events.ts) +integration test we can see that we are creating an `@aws-cdk/aws-events.EventBus` along with a `@aws-cdk/aws-stepfunctions.StateMachine` +which will send an event to the `EventBus`. In a typical integration test we would just deploy the test and the fact that the +infrastructure deployed successfully would be enough of a validation that the test succeeded. In this case though, we ideally +want to validate that the _integration_ connecting `StepFunctions` to the `EventBus` has been setup correctly, and the only +way to do that is to actually trigger the `StateMachine` and validate that it was successful. + +```ts +declare const app: App; +declare const sm: sfn.StateMachine; +declare const stack: Stack; + +const testCase = new IntegTest(app, 'PutEvents', { + testCases: [stack], +}); + +// Start an execution +const start = testCase.assertions.awsApiCall('StepFunctions', 'startExecution', { + stateMachineArn: sm.stateMachineArn, +}); + +// describe the results of the execution +const describe = testCase.assertions.awsApiCall('StepFunctions', 'describeExecution', { + executionArn: start.getAttString('executionArn'), +}); + +// assert the results +describe.expect(ExpectedResult.objectLike({ + status: 'SUCCEEDED', +})); +``` + +Not every test requires an assertion. We typically do not need to assert CloudFormation behavior. For example, if we create an S3 Bucket +with Encryption, we do not need to assert that Encryption is set on the bucket. We can trust that the CloudFormation behavior works. +Some things you should look for in deciding if the test needs an assertion: + +- Integrations between services (i.e. integration libraries like `@aws-cdk/aws-lambda-destinations`, `@aws-cdk/aws-stepfunctions-tasks`, etc) +- Anything that bundles or deploys custom code (i.e. does a Lambda function bundled with `@aws-cdk/aws-lambda-nodejs` still invoke or did we break bundling behavior) +- IAM/Networking connections. + - This one is a bit of a judgement call. Most things do not need assertions, but sometimes we handle complicated configurations involving IAM permissions or + Networking access. ## Running Integration Tests 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 fe1e6cadf1e61..3cb2ab4d3eb8a 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 @@ -58,6 +58,16 @@ export class IntegTestRunner extends IntegRunner { constructor(options: IntegRunnerOptions, destructiveChanges?: DestructiveChange[]) { super(options); this._destructiveChanges = destructiveChanges; + + // We don't want new tests written in the legacy mode. + // If there is no existing snapshot _and_ this is a legacy + // test then point the user to the new `IntegTest` construct + if (!this.hasSnapshot() && this.isLegacyTest) { + throw new Error(`${this.testName} is a new test. Please use the IntegTest construct ` + + 'to configure the test\n' + + 'https://github.com/aws/aws-cdk/tree/main/packages/%40aws-cdk/integ-tests', + ); + } } /** 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 1a74184078769..76b70db09eed5 100644 --- a/packages/@aws-cdk/integ-runner/lib/runner/runner-base.ts +++ b/packages/@aws-cdk/integ-runner/lib/runner/runner-base.ts @@ -123,6 +123,7 @@ export abstract class IntegRunner { protected _destructiveChanges?: DestructiveChange[]; private legacyContext?: Record; + protected isLegacyTest?: boolean; constructor(options: IntegRunnerOptions) { this.test = options.test; @@ -211,6 +212,7 @@ export abstract class IntegRunner { }, }); this.legacyContext = LegacyIntegTestSuite.getPragmaContext(this.test.fileName); + this.isLegacyTest = true; return testCases; } } 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 c2b0987c3ba2b..dd077dd929952 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 @@ -37,8 +37,6 @@ beforeEach(() => { output: ['stdout', 'stderr'], signal: null, }); - // jest.spyOn(process.stderr, 'write').mockImplementation(() => { return true; }); - // jest.spyOn(process.stdout, 'write').mockImplementation(() => { return true; }); jest.spyOn(fs, 'moveSync').mockImplementation(() => { return true; }); removeSyncMock = jest.spyOn(fs, 'removeSync').mockImplementation(() => { return true; }); jest.spyOn(fs, 'writeFileSync').mockImplementation(() => { return true; }); @@ -56,12 +54,12 @@ describe('IntegTest runIntegTests', () => { const integTest = new IntegTestRunner({ cdk: cdkMock.cdk, test: new IntegTest({ - fileName: 'test/test-data/integ.test-with-snapshot.js', + fileName: 'test/test-data/xxxxx.test-with-snapshot.js', discoveryRoot: 'test/test-data', }), }); integTest.runIntegTestCase({ - testCaseName: 'integ.test-with-snapshot', + testCaseName: 'xxxxx.test-with-snapshot', }); // THEN @@ -80,7 +78,7 @@ describe('IntegTest runIntegTests', () => { stacks: ['test-stack'], }); expect(deployMock).toHaveBeenCalledWith({ - app: 'node integ.test-with-snapshot.js', + app: 'node xxxxx.test-with-snapshot.js', requireApproval: 'never', pathMetadata: false, assetMetadata: false, @@ -93,7 +91,7 @@ describe('IntegTest runIntegTests', () => { stacks: ['test-stack', 'new-test-stack'], }); expect(destroyMock).toHaveBeenCalledWith({ - app: 'node integ.test-with-snapshot.js', + app: 'node xxxxx.test-with-snapshot.js', pathMetadata: false, assetMetadata: false, context: expect.any(Object), @@ -110,12 +108,12 @@ describe('IntegTest runIntegTests', () => { const integTest = new IntegTestRunner({ cdk: cdkMock.cdk, test: new IntegTest({ - fileName: 'test/test-data/integ.integ-test1.js', + fileName: 'test/test-data/xxxxx.integ-test1.js', discoveryRoot: 'test/test-data', }), }); integTest.runIntegTestCase({ - testCaseName: 'integ.integ-test1', + testCaseName: 'xxxxx.integ-test1', }); // THEN @@ -123,7 +121,7 @@ describe('IntegTest runIntegTests', () => { expect(destroyMock).toHaveBeenCalledTimes(1); expect(synthFastMock).toHaveBeenCalledTimes(1); expect(deployMock).toHaveBeenCalledWith({ - app: 'node integ.integ-test1.js', + app: 'node xxxxx.integ-test1.js', requireApproval: 'never', pathMetadata: false, assetMetadata: false, @@ -138,7 +136,7 @@ describe('IntegTest runIntegTests', () => { output: 'cdk-integ.out.integ-test1', }); expect(destroyMock).toHaveBeenCalledWith({ - app: 'node integ.integ-test1.js', + app: 'node xxxxx.integ-test1.js', pathMetadata: false, assetMetadata: false, versionReporting: false, @@ -154,12 +152,12 @@ describe('IntegTest runIntegTests', () => { const integTest = new IntegTestRunner({ cdk: cdkMock.cdk, test: new IntegTest({ - fileName: 'test/test-data/integ.test-with-snapshot-assets-diff.js', + fileName: 'test/test-data/xxxxx.test-with-snapshot-assets-diff.js', discoveryRoot: 'test/test-data', }), }); integTest.runIntegTestCase({ - testCaseName: 'integ.test-with-snapshot-assets-diff', + testCaseName: 'xxxxx.test-with-snapshot-assets-diff', }); // THEN @@ -167,7 +165,7 @@ describe('IntegTest runIntegTests', () => { expect(destroyMock).toHaveBeenCalledTimes(1); expect(synthFastMock).toHaveBeenCalledTimes(2); expect(deployMock).toHaveBeenCalledWith({ - app: 'node integ.test-with-snapshot-assets-diff.js', + app: 'node xxxxx.test-with-snapshot-assets-diff.js', requireApproval: 'never', pathMetadata: false, assetMetadata: false, @@ -184,7 +182,7 @@ describe('IntegTest runIntegTests', () => { profile: undefined, }); expect(synthFastMock).toHaveBeenCalledWith({ - execCmd: ['node', 'integ.test-with-snapshot-assets-diff.js'], + execCmd: ['node', 'xxxxx.test-with-snapshot-assets-diff.js'], env: expect.objectContaining({ CDK_INTEG_ACCOUNT: '12345678', CDK_INTEG_REGION: 'test-region', @@ -193,7 +191,7 @@ describe('IntegTest runIntegTests', () => { output: 'test-with-snapshot-assets-diff.integ.snapshot', }); expect(destroyMock).toHaveBeenCalledWith({ - app: 'node integ.test-with-snapshot-assets-diff.js', + app: 'node xxxxx.test-with-snapshot-assets-diff.js', pathMetadata: false, assetMetadata: false, context: expect.objectContaining({ @@ -213,12 +211,12 @@ describe('IntegTest runIntegTests', () => { const integTest = new IntegTestRunner({ cdk: cdkMock.cdk, test: new IntegTest({ - fileName: 'test/test-data/integ.integ-test1.js', + fileName: 'test/test-data/xxxxx.integ-test1.js', discoveryRoot: 'test/test-data', }), }); integTest.runIntegTestCase({ - testCaseName: 'integ.integ-test1', + testCaseName: 'xxxxx.integ-test1', clean: false, }); @@ -233,12 +231,12 @@ describe('IntegTest runIntegTests', () => { const integTest = new IntegTestRunner({ cdk: cdkMock.cdk, test: new IntegTest({ - fileName: 'test/test-data/integ.integ-test1.js', + fileName: 'test/test-data/xxxxx.integ-test1.js', discoveryRoot: 'test/test-data', }), }); integTest.runIntegTestCase({ - testCaseName: 'integ.integ-test1', + testCaseName: 'xxxxx.integ-test1', dryRun: true, }); @@ -248,33 +246,12 @@ describe('IntegTest runIntegTests', () => { expect(synthFastMock).toHaveBeenCalledTimes(2); }); - test('determine test stack via pragma', () => { - // WHEN - const integTest = new IntegTestRunner({ - cdk: cdkMock.cdk, - test: new IntegTest({ - fileName: 'test/test-data/integ.integ-test1.js', - discoveryRoot: 'test', - }), - }); - - // THEN - expect(integTest.actualTests()).toEqual(expect.objectContaining({ - 'test-data/integ.integ-test1': { - diffAssets: false, - stackUpdateWorkflow: true, - stacks: ['stack1'], - }, - })); - expect(listMock).toHaveBeenCalledTimes(0); - }); - test('generate snapshot', () => { // WHEN new IntegTestRunner({ cdk: cdkMock.cdk, test: new IntegTest({ - fileName: 'test/test-data/integ.integ-test1.js', + fileName: 'test/test-data/xxxxx.integ-test1.js', discoveryRoot: 'test/test-data', }), }); @@ -282,7 +259,7 @@ describe('IntegTest runIntegTests', () => { // THEN expect(synthFastMock).toHaveBeenCalledTimes(1); expect(synthFastMock).toHaveBeenCalledWith({ - execCmd: ['node', 'integ.integ-test1.js'], + execCmd: ['node', 'xxxxx.integ-test1.js'], output: 'cdk-integ.out.integ-test1', env: expect.objectContaining({ CDK_INTEG_ACCOUNT: '12345678', @@ -290,47 +267,19 @@ describe('IntegTest runIntegTests', () => { }), }); }); - test('get stacks from list, no pragma', async () => { - // WHEN - const integTest = new IntegTestRunner({ - cdk: cdkMock.cdk, - test: new IntegTest({ - fileName: 'test/test-data/integ.integ-test2.js', - discoveryRoot: 'test', - }), - }); - - // THEN - expect(integTest.actualTests()).toEqual(expect.objectContaining({ - 'test-data/integ.integ-test2': { - diffAssets: false, - stackUpdateWorkflow: true, - stacks: ['stackabc'], - }, - })); - expect(synthFastMock).toHaveBeenCalledTimes(1); - expect(synthFastMock).toHaveBeenCalledWith({ - execCmd: ['node', 'integ.integ-test2.js'], - env: expect.objectContaining({ - CDK_INTEG_ACCOUNT: '12345678', - CDK_INTEG_REGION: 'test-region', - }), - output: 'cdk-integ.out.integ-test2', - }); - }); test('with profile', () => { // WHEN const integTest = new IntegTestRunner({ cdk: cdkMock.cdk, test: new IntegTest({ - fileName: 'test/test-data/integ.integ-test1.js', + fileName: 'test/test-data/xxxxx.integ-test1.js', discoveryRoot: 'test/test-data', }), profile: 'test-profile', }); integTest.runIntegTestCase({ - testCaseName: 'integ.integ-test1', + testCaseName: 'xxxxx.integ-test1', }); // THEN @@ -338,7 +287,7 @@ describe('IntegTest runIntegTests', () => { expect(destroyMock).toHaveBeenCalledTimes(1); expect(synthFastMock).toHaveBeenCalledTimes(1); expect(deployMock).toHaveBeenCalledWith({ - app: 'node integ.integ-test1.js', + app: 'node xxxxx.integ-test1.js', requireApproval: 'never', pathMetadata: false, assetMetadata: false, @@ -351,7 +300,7 @@ describe('IntegTest runIntegTests', () => { output: 'cdk-integ.out.integ-test1', }); expect(destroyMock).toHaveBeenCalledWith({ - app: 'node integ.integ-test1.js', + app: 'node xxxxx.integ-test1.js', pathMetadata: false, assetMetadata: false, versionReporting: false, @@ -367,12 +316,12 @@ describe('IntegTest runIntegTests', () => { const integTest = new IntegTestRunner({ cdk: cdkMock.cdk, test: new IntegTest({ - fileName: 'test/test-data/integ.test-with-snapshot-assets.js', + fileName: 'test/test-data/xxxxx.test-with-snapshot-assets.js', discoveryRoot: 'test/test-data', }), }); integTest.runIntegTestCase({ - testCaseName: 'integ.test-with-snapshot-assets', + testCaseName: 'xxxxx.test-with-snapshot-assets', }); // THEN @@ -414,12 +363,12 @@ describe('IntegTest runIntegTests', () => { const integTest = new IntegTestRunner({ cdk: cdkMock.cdk, test: new IntegTest({ - fileName: 'test/test-data/integ.test-with-snapshot.js', + fileName: 'test/test-data/xxxxx.test-with-snapshot.js', discoveryRoot: 'test/test-data', }), }); integTest.runIntegTestCase({ - testCaseName: 'integ.test-with-snapshot', + testCaseName: 'xxxxx.test-with-snapshot', }); // THEN @@ -452,12 +401,12 @@ describe('IntegTest runIntegTests', () => { const integTest = new IntegTestRunner({ cdk: cdkMock.cdk, test: new IntegTest({ - fileName: 'test/test-data/integ.test-with-snapshot.js', + fileName: 'test/test-data/xxxxx.test-with-snapshot.js', discoveryRoot: 'test/test-data', }), }); integTest.runIntegTestCase({ - testCaseName: 'integ.test-with-snapshot', + testCaseName: 'xxxxx.test-with-snapshot', }); // THEN @@ -491,12 +440,12 @@ describe('IntegTest runIntegTests', () => { const integTest = new IntegTestRunner({ cdk: cdkMock.cdk, test: new IntegTest({ - fileName: 'test/test-data/integ.test-with-snapshot.js', + fileName: 'test/test-data/xxxxx.test-with-snapshot.js', discoveryRoot: 'test/test-data', }), }); integTest.runIntegTestCase({ - testCaseName: 'integ.test-with-snapshot', + testCaseName: 'xxxxx.test-with-snapshot', }); // THEN @@ -511,12 +460,12 @@ describe('IntegTest runIntegTests', () => { const integTest = new IntegTestRunner({ cdk: cdkMock.cdk, test: new IntegTest({ - fileName: 'test/test-data/integ.test-with-snapshot-assets.js', + fileName: 'test/test-data/xxxxx.test-with-snapshot-assets.js', discoveryRoot: 'test/test-data', }), }); integTest.runIntegTestCase({ - testCaseName: 'integ.test-with-snapshot-assets', + testCaseName: 'xxxxx.test-with-snapshot-assets', }); expect(removeSyncMock.mock.calls).toEqual([ @@ -532,12 +481,12 @@ describe('IntegTest runIntegTests', () => { const integTest = new IntegTestRunner({ cdk: cdkMock.cdk, test: new IntegTest({ - fileName: 'test/test-data/integ.test-with-snapshot-assets-diff.js', + fileName: 'test/test-data/xxxxx.test-with-snapshot-assets-diff.js', discoveryRoot: 'test/test-data', }), }); integTest.runIntegTestCase({ - testCaseName: 'integ.test-with-snapshot-assets-diff', + testCaseName: 'xxxxx.test-with-snapshot-assets-diff', }); expect(removeSyncMock.mock.calls).toEqual([ diff --git a/packages/@aws-cdk/integ-runner/test/runner/snapshot-test-runner.test.ts b/packages/@aws-cdk/integ-runner/test/runner/snapshot-test-runner.test.ts index 1370589d36252..f51116d5272d7 100644 --- a/packages/@aws-cdk/integ-runner/test/runner/snapshot-test-runner.test.ts +++ b/packages/@aws-cdk/integ-runner/test/runner/snapshot-test-runner.test.ts @@ -47,7 +47,7 @@ describe('IntegTest runSnapshotTests', () => { const integTest = new IntegSnapshotRunner({ cdk: cdkMock.cdk, test: new IntegTest({ - fileName: 'test/test-data/integ.test-with-snapshot.js', + fileName: 'test/test-data/xxxxx.test-with-snapshot.js', discoveryRoot: 'test/test-data', }), integOutDir: 'test/test-data/test-with-snapshot.integ.snapshot', @@ -61,7 +61,7 @@ describe('IntegTest runSnapshotTests', () => { CDK_INTEG_ACCOUNT: '12345678', CDK_INTEG_REGION: 'test-region', }), - execCmd: ['node', 'integ.test-with-snapshot.js'], + execCmd: ['node', 'xxxxx.test-with-snapshot.js'], output: 'test-with-snapshot.integ.snapshot', }); expect(results.diagnostics).toEqual([]); @@ -72,7 +72,7 @@ describe('IntegTest runSnapshotTests', () => { const integTest = new IntegSnapshotRunner({ cdk: cdkMock.cdk, test: new IntegTest({ - fileName: 'test/test-data/integ.test-with-snapshot.js', + fileName: 'test/test-data/xxxxx.test-with-snapshot.js', discoveryRoot: 'test/test-data', }), }); @@ -85,7 +85,7 @@ describe('IntegTest runSnapshotTests', () => { CDK_INTEG_ACCOUNT: '12345678', CDK_INTEG_REGION: 'test-region', }), - execCmd: ['node', 'integ.test-with-snapshot.js'], + execCmd: ['node', 'xxxxx.test-with-snapshot.js'], output: 'cdk-integ.out.test-with-snapshot', }); expect(results.diagnostics).toEqual(expect.arrayContaining([expect.objectContaining({ @@ -100,7 +100,7 @@ describe('IntegTest runSnapshotTests', () => { const integTest = new IntegSnapshotRunner({ cdk: cdkMock.cdk, test: new IntegTest({ - fileName: 'test/test-data/integ.test-with-snapshot.js', + fileName: 'test/test-data/xxxxx.test-with-snapshot.js', discoveryRoot: 'test/test-data', }), integOutDir: 'test/test-data/test-with-snapshot-diff.integ.snapshot', @@ -110,7 +110,7 @@ describe('IntegTest runSnapshotTests', () => { // THEN expect(synthFastMock).toHaveBeenCalledTimes(2); expect(synthFastMock).toHaveBeenCalledWith({ - execCmd: ['node', 'integ.test-with-snapshot.js'], + execCmd: ['node', 'xxxxx.test-with-snapshot.js'], env: expect.objectContaining({ CDK_INTEG_ACCOUNT: '12345678', CDK_INTEG_REGION: 'test-region', @@ -141,7 +141,7 @@ describe('IntegTest runSnapshotTests', () => { const integTest = new IntegSnapshotRunner({ cdk: cdkMock.cdk, test: new IntegTest({ - fileName: path.join(__dirname, '../test-data/integ.test-with-snapshot-assets-diff.js'), + fileName: path.join(__dirname, '../test-data/xxxxx.test-with-snapshot-assets-diff.js'), discoveryRoot: 'test/test-data', }), integOutDir: 'test/test-data/test-with-snapshot-assets.integ.snapshot', @@ -153,7 +153,7 @@ describe('IntegTest runSnapshotTests', () => { // THEN expect(synthFastMock).toHaveBeenCalledTimes(2); expect(synthFastMock).toHaveBeenCalledWith({ - execCmd: ['node', 'integ.test-with-snapshot-assets-diff.js'], + execCmd: ['node', 'xxxxx.test-with-snapshot-assets-diff.js'], env: expect.objectContaining({ CDK_INTEG_ACCOUNT: '12345678', CDK_INTEG_REGION: 'test-region', @@ -162,12 +162,64 @@ describe('IntegTest runSnapshotTests', () => { }); }); + test('determine test stack via pragma', () => { + // WHEN + const integTest = new IntegSnapshotRunner({ + cdk: cdkMock.cdk, + test: new IntegTest({ + fileName: 'test/test-data/xxxxx.integ-test1.js', + discoveryRoot: 'test', + }), + integOutDir: 'does/not/exist', + }); + + // THEN + expect(integTest.actualTests()).toEqual(expect.objectContaining({ + 'test-data/xxxxx.integ-test1': { + diffAssets: false, + stackUpdateWorkflow: true, + stacks: ['stack1'], + }, + })); + expect(listMock).toHaveBeenCalledTimes(0); + }); + + test('get stacks from list, no pragma', async () => { + // WHEN + const integTest = new IntegSnapshotRunner({ + cdk: cdkMock.cdk, + test: new IntegTest({ + fileName: 'test/test-data/xxxxx.integ-test2.js', + discoveryRoot: 'test', + }), + integOutDir: 'does/not/exist', + }); + + // THEN + expect(integTest.actualTests()).toEqual(expect.objectContaining({ + 'test-data/xxxxx.integ-test2': { + diffAssets: false, + stackUpdateWorkflow: true, + stacks: ['stackabc'], + }, + })); + expect(synthFastMock).toHaveBeenCalledTimes(1); + expect(synthFastMock).toHaveBeenCalledWith({ + execCmd: ['node', 'xxxxx.integ-test2.js'], + env: expect.objectContaining({ + CDK_INTEG_ACCOUNT: '12345678', + CDK_INTEG_REGION: 'test-region', + }), + output: '../../does/not/exist', + }); + }); + test('diff asset hashes', () => { // WHEN const integTest = new IntegSnapshotRunner({ cdk: cdkMock.cdk, test: new IntegTest({ - fileName: path.join(__dirname, '../test-data/integ.test-with-snapshot-assets.js'), + fileName: path.join(__dirname, '../test-data/xxxxx.test-with-snapshot-assets.js'), discoveryRoot: 'test/test-data', }), integOutDir: 'test/test-data/test-with-snapshot-assets-diff.integ.snapshot', @@ -177,7 +229,7 @@ describe('IntegTest runSnapshotTests', () => { // THEN expect(synthFastMock).toHaveBeenCalledTimes(2); expect(synthFastMock).toHaveBeenCalledWith({ - execCmd: ['node', 'integ.test-with-snapshot-assets.js'], + execCmd: ['node', 'xxxxx.test-with-snapshot-assets.js'], env: expect.objectContaining({ CDK_INTEG_ACCOUNT: '12345678', CDK_INTEG_REGION: 'test-region', diff --git a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.integ-test1/integ.json b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.integ-test1/integ.json new file mode 100644 index 0000000000000..c07eabcac5353 --- /dev/null +++ b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.integ-test1/integ.json @@ -0,0 +1,8 @@ +{ + "version": "v19.0.0", + "testCases": { + "xxxxx.integ-test1": { + "stacks": ["stack1"] + } + } +} diff --git a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets/integ.json b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets/integ.json index 00ba7f5c62258..a2f390b4d7453 100644 --- a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets/integ.json +++ b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot-assets/integ.json @@ -1,7 +1,7 @@ { "version": "v1.0.0", "testCases": { - "integ.test-with-snapshot-assets": { + "xxxxx.test-with-snapshot-assets": { "stacks": ["test-stack"], "stackUpdateWorkflow": false, "diffAssets": true, diff --git a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot/integ.json b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot/integ.json index 86b02855c4265..aefc17a9ec3b7 100644 --- a/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot/integ.json +++ b/packages/@aws-cdk/integ-runner/test/test-data/cdk-integ.out.test-with-snapshot/integ.json @@ -1,7 +1,7 @@ { "version": "v1.0.0", "testCases": { - "integ.test-with-snapshot": { + "xxxxx.test-with-snapshot": { "stacks": ["test-stack", "new-test-stack"], "diffAssets": true, "allowDestroy": [ diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets-diff.integ.snapshot/integ.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets-diff.integ.snapshot/integ.json index b5cb56ccc0b61..08782d8bed7d2 100644 --- a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets-diff.integ.snapshot/integ.json +++ b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets-diff.integ.snapshot/integ.json @@ -2,7 +2,7 @@ "version": "v1.0.0", "testCases": { "enableLookups": true, - "integ.test-with-snapshot-assets-diff": { + "xxxxx.test-with-snapshot-assets-diff": { "stacks": ["test-stack"], "diffAssets": true, "allowDestroy": [ diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets-diff.integ.snapshot/manifest.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets-diff.integ.snapshot/manifest.json index d1c7a0ea225c1..d5518ce4bd0e1 100644 --- a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets-diff.integ.snapshot/manifest.json +++ b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets-diff.integ.snapshot/manifest.json @@ -1,5 +1,5 @@ { - "version": "19.0.0", + "version": "20.0.0", "artifacts": { "Tree": { "type": "cdk:tree", diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets.integ.snapshot/integ.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets.integ.snapshot/integ.json index 44aa43749d9d7..dd229432f16b2 100644 --- a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets.integ.snapshot/integ.json +++ b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets.integ.snapshot/integ.json @@ -1,7 +1,7 @@ { "version": "v1.0.0", "testCases": { - "integ.test-with-snapshot-assets": { + "xxxxx.test-with-snapshot-assets": { "stacks": ["test-stack"], "stackUpdateWorkflow": false, "diffAssets": true, diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets.integ.snapshot/manifest.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets.integ.snapshot/manifest.json index 8ef72f9af40ea..7c2c6d4d8cdce 100644 --- a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets.integ.snapshot/manifest.json +++ b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-assets.integ.snapshot/manifest.json @@ -1,5 +1,5 @@ { - "version": "19.0.0", + "version": "20.0.0", "artifacts": { "Tree": { "type": "cdk:tree", diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-diff.integ.snapshot/integ.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-diff.integ.snapshot/integ.json index 6938103ade87e..25baeac5899fd 100644 --- a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-diff.integ.snapshot/integ.json +++ b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot-diff.integ.snapshot/integ.json @@ -1,7 +1,7 @@ { "version": "v1.0.0", "testCases": { - "integ.test-with-snapshot": { + "xxxxx.test-with-snapshot": { "stacks": ["test-stack"], "diffAssets": true, "allowDestroy": [ diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot.integ.snapshot/integ.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot.integ.snapshot/integ.json index 6938103ade87e..25baeac5899fd 100644 --- a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot.integ.snapshot/integ.json +++ b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot.integ.snapshot/integ.json @@ -1,7 +1,7 @@ { "version": "v1.0.0", "testCases": { - "integ.test-with-snapshot": { + "xxxxx.test-with-snapshot": { "stacks": ["test-stack"], "diffAssets": true, "allowDestroy": [ diff --git a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot.integ.snapshot/manifest.json b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot.integ.snapshot/manifest.json index bc0e09d1ce230..7b8ed0311e8f0 100644 --- a/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot.integ.snapshot/manifest.json +++ b/packages/@aws-cdk/integ-runner/test/test-data/test-with-snapshot.integ.snapshot/manifest.json @@ -1,5 +1,5 @@ { - "version": "19.0.0", + "version": "20.0.0", "artifacts": { "Tree": { "type": "cdk:tree", diff --git a/packages/@aws-cdk/integ-runner/test/test-data/integ.integ-test1.ts b/packages/@aws-cdk/integ-runner/test/test-data/xxxxx.integ-test1.ts similarity index 100% rename from packages/@aws-cdk/integ-runner/test/test-data/integ.integ-test1.ts rename to packages/@aws-cdk/integ-runner/test/test-data/xxxxx.integ-test1.ts diff --git a/packages/@aws-cdk/integ-runner/test/test-data/integ.integ-test2.ts b/packages/@aws-cdk/integ-runner/test/test-data/xxxxx.integ-test2.ts similarity index 100% rename from packages/@aws-cdk/integ-runner/test/test-data/integ.integ-test2.ts rename to packages/@aws-cdk/integ-runner/test/test-data/xxxxx.integ-test2.ts diff --git a/packages/@aws-cdk/integ-runner/test/test-data/integ.test-with-snapshot-assets-diff.ts b/packages/@aws-cdk/integ-runner/test/test-data/xxxxx.test-with-snapshot-assets-diff.ts similarity index 100% rename from packages/@aws-cdk/integ-runner/test/test-data/integ.test-with-snapshot-assets-diff.ts rename to packages/@aws-cdk/integ-runner/test/test-data/xxxxx.test-with-snapshot-assets-diff.ts diff --git a/packages/@aws-cdk/integ-runner/test/test-data/integ.test-with-snapshot-assets.ts b/packages/@aws-cdk/integ-runner/test/test-data/xxxxx.test-with-snapshot-assets.ts similarity index 100% rename from packages/@aws-cdk/integ-runner/test/test-data/integ.test-with-snapshot-assets.ts rename to packages/@aws-cdk/integ-runner/test/test-data/xxxxx.test-with-snapshot-assets.ts diff --git a/packages/@aws-cdk/integ-runner/test/test-data/integ.test-with-snapshot.ts b/packages/@aws-cdk/integ-runner/test/test-data/xxxxx.test-with-snapshot.ts similarity index 100% rename from packages/@aws-cdk/integ-runner/test/test-data/integ.test-with-snapshot.ts rename to packages/@aws-cdk/integ-runner/test/test-data/xxxxx.test-with-snapshot.ts diff --git a/packages/@aws-cdk/integ-runner/test/workers/integ-worker.test.ts b/packages/@aws-cdk/integ-runner/test/workers/integ-worker.test.ts index 0c1634faf759e..8f2e332a639b2 100644 --- a/packages/@aws-cdk/integ-runner/test/workers/integ-worker.test.ts +++ b/packages/@aws-cdk/integ-runner/test/workers/integ-worker.test.ts @@ -64,7 +64,7 @@ describe('test runner', () => { test('no snapshot', () => { // WHEN const test = { - fileName: 'test/test-data/integ.integ-test1.js', + fileName: 'test/test-data/xxxxx.integ-test1.js', discoveryRoot: 'test/test-data', }; integTestWorker({ @@ -74,7 +74,7 @@ describe('test runner', () => { expect(spawnSyncMock).toHaveBeenCalledWith( expect.stringMatching(/node/), - ['integ.integ-test1.js'], + ['xxxxx.integ-test1.js'], expect.objectContaining({ env: expect.objectContaining({ CDK_INTEG_ACCOUNT: '12345678', @@ -84,11 +84,11 @@ describe('test runner', () => { ); }); - test('no tests', () => { + test('legacy test throws', () => { // WHEN const test = { - fileName: 'test/test-data/integ.integ-test2.js', + fileName: 'test/test-data/xxxxx.integ-test2.js', discoveryRoot: 'test/test-data', }; spawnSyncMock.mockReset(); @@ -100,22 +100,24 @@ describe('test runner', () => { output: ['stdout', 'stderr'], signal: null, }); + + // GIVEN const results = integTestWorker({ tests: [test], region: 'us-east-1', }); // THEN - expect(results[0]).toEqual({ - fileName: expect.stringMatching(/integ.integ-test2.js$/), + expect(results).toEqual([{ discoveryRoot: 'test/test-data', - }); + fileName: 'test/test-data/xxxxx.integ-test2.js', + }]); }); test('has snapshot', () => { // WHEN const test = { - fileName: 'test/test-data/integ.test-with-snapshot.js', + fileName: 'test/test-data/xxxxx.test-with-snapshot.js', discoveryRoot: 'test/test-data', }; const results = integTestWorker({ @@ -153,7 +155,7 @@ describe('test runner', () => { test('deploy failed', () => { // WHEN const test = { - fileName: 'test/test-data/integ.test-with-snapshot.js', + fileName: 'test/test-data/xxxxx.test-with-snapshot.js', discoveryRoot: 'test/test-data', }; jest.spyOn(child_process, 'spawnSync').mockReturnValue({ @@ -170,7 +172,7 @@ describe('test runner', () => { }); expect(results[0]).toEqual({ - fileName: 'test/test-data/integ.test-with-snapshot.js', + fileName: 'test/test-data/xxxxx.test-with-snapshot.js', discoveryRoot: 'test/test-data', }); }); @@ -180,11 +182,11 @@ describe('parallel worker', () => { test('run all integration tests', async () => { const tests = [ { - fileName: 'integ.test-with-snapshot.js', + fileName: 'xxxxx.test-with-snapshot.js', discoveryRoot: 'test/test-data', }, { - fileName: 'integ.another-test-with-snapshot.js', + fileName: 'xxxxx.another-test-with-snapshot.js', discoveryRoot: 'test/test-data', }, ]; @@ -201,16 +203,16 @@ describe('parallel worker', () => { 'Running in parallel across regions: us-east-1, us-east-2', ); expect(stderrMock.mock.calls[2][0]).toContain( - 'Running test integ.another-test-with-snapshot.js in us-east-1', + 'Running test xxxxx.another-test-with-snapshot.js in us-east-1', ); expect(stderrMock.mock.calls[3][0]).toContain( - 'Running test integ.test-with-snapshot.js in us-east-2', + 'Running test xxxxx.test-with-snapshot.js in us-east-2', ); }); test('run tests', async () => { const tests = [{ - fileName: 'integ.test-with-snapshot.js', + fileName: 'xxxxx.test-with-snapshot.js', discoveryRoot: 'test/test-data', }]; const results = await runIntegrationTestsInParallel({ @@ -220,12 +222,12 @@ describe('parallel worker', () => { }); expect(stderrMock.mock.calls[0][0]).toContain( - 'Running test integ.test-with-snapshot.js in us-east-1', + 'Running test xxxxx.test-with-snapshot.js in us-east-1', ); expect(results).toEqual({ failedTests: expect.arrayContaining([ { - fileName: 'integ.test-with-snapshot.js', + fileName: 'xxxxx.test-with-snapshot.js', discoveryRoot: 'test/test-data', }, ]), @@ -234,7 +236,7 @@ describe('parallel worker', () => { duration: expect.anything(), region: 'us-east-1', tests: { - 'integ.test-with-snapshot.js': expect.anything(), + 'xxxxx.test-with-snapshot.js': expect.anything(), }, }, ]), @@ -244,19 +246,19 @@ describe('parallel worker', () => { test('run multiple tests with profiles', async () => { const tests = [ { - fileName: 'integ.test-with-snapshot.js', + fileName: 'xxxxx.another-test-with-snapshot3.js', discoveryRoot: 'test/test-data', }, { - fileName: 'integ.another-test-with-snapshot.js', + fileName: 'xxxxx.another-test-with-snapshot2.js', discoveryRoot: 'test/test-data', }, { - fileName: 'integ.another-test-with-snapshot2.js', + fileName: 'xxxxx.another-test-with-snapshot.js', discoveryRoot: 'test/test-data', }, { - fileName: 'integ.another-test-with-snapshot3.js', + fileName: 'xxxxx.test-with-snapshot.js', discoveryRoot: 'test/test-data', }, ]; @@ -267,34 +269,34 @@ describe('parallel worker', () => { regions: ['us-east-1', 'us-east-2'], }); - expect(stderrMock.mock.calls[0][0]).toContain( - 'Running test integ.another-test-with-snapshot3.js in profile1/us-east-1', - ); - expect(stderrMock.mock.calls[1][0]).toContain( - 'Running test integ.another-test-with-snapshot2.js in profile1/us-east-2', + expect(stderrMock.mock.calls[3][0]).toContain( + 'Running test xxxxx.another-test-with-snapshot3.js in profile2/us-east-2', ); expect(stderrMock.mock.calls[2][0]).toContain( - 'Running test integ.another-test-with-snapshot.js in profile2/us-east-1', + 'Running test xxxxx.another-test-with-snapshot2.js in profile2/us-east-1', ); - expect(stderrMock.mock.calls[3][0]).toContain( - 'Running test integ.test-with-snapshot.js in profile2/us-east-2', + expect(stderrMock.mock.calls[1][0]).toContain( + 'Running test xxxxx.another-test-with-snapshot.js in profile1/us-east-2', + ); + expect(stderrMock.mock.calls[0][0]).toContain( + 'Running test xxxxx.test-with-snapshot.js in profile1/us-east-1', ); expect(results).toEqual({ failedTests: expect.arrayContaining([ { - fileName: 'integ.test-with-snapshot.js', + fileName: 'xxxxx.test-with-snapshot.js', discoveryRoot: 'test/test-data', }, { - fileName: 'integ.another-test-with-snapshot.js', + fileName: 'xxxxx.another-test-with-snapshot.js', discoveryRoot: 'test/test-data', }, { - fileName: 'integ.another-test-with-snapshot2.js', + fileName: 'xxxxx.another-test-with-snapshot2.js', discoveryRoot: 'test/test-data', }, { - fileName: 'integ.another-test-with-snapshot3.js', + fileName: 'xxxxx.another-test-with-snapshot3.js', discoveryRoot: 'test/test-data', }, ]), @@ -304,7 +306,7 @@ describe('parallel worker', () => { region: 'us-east-1', profile: 'profile1', tests: { - 'integ.another-test-with-snapshot3.js': expect.any(Number), + 'xxxxx.test-with-snapshot.js': expect.any(Number), }, }, { @@ -312,7 +314,7 @@ describe('parallel worker', () => { region: 'us-east-2', profile: 'profile1', tests: { - 'integ.another-test-with-snapshot2.js': expect.any(Number), + 'xxxxx.another-test-with-snapshot.js': expect.any(Number), }, }, { @@ -320,7 +322,7 @@ describe('parallel worker', () => { region: 'us-east-1', profile: 'profile2', tests: { - 'integ.another-test-with-snapshot.js': expect.any(Number), + 'xxxxx.another-test-with-snapshot2.js': expect.any(Number), }, }, { @@ -328,7 +330,7 @@ describe('parallel worker', () => { region: 'us-east-2', profile: 'profile2', tests: { - 'integ.test-with-snapshot.js': expect.any(Number), + 'xxxxx.another-test-with-snapshot3.js': expect.any(Number), }, }, ]), @@ -338,11 +340,11 @@ describe('parallel worker', () => { test('run multiple tests', async () => { const tests = [ { - fileName: 'integ.test-with-snapshot.js', + fileName: 'xxxxx.test-with-snapshot.js', discoveryRoot: 'test/test-data', }, { - fileName: 'integ.another-test-with-snapshot.js', + fileName: 'xxxxx.another-test-with-snapshot.js', discoveryRoot: 'test/test-data', }, ]; @@ -353,19 +355,19 @@ describe('parallel worker', () => { }); expect(stderrMock.mock.calls[1][0]).toContain( - 'Running test integ.test-with-snapshot.js in us-east-2', + 'Running test xxxxx.test-with-snapshot.js in us-east-2', ); expect(stderrMock.mock.calls[0][0]).toContain( - 'Running test integ.another-test-with-snapshot.js in us-east-1', + 'Running test xxxxx.another-test-with-snapshot.js in us-east-1', ); expect(results).toEqual({ failedTests: expect.arrayContaining([ { - fileName: 'integ.test-with-snapshot.js', + fileName: 'xxxxx.test-with-snapshot.js', discoveryRoot: 'test/test-data', }, { - fileName: 'integ.another-test-with-snapshot.js', + fileName: 'xxxxx.another-test-with-snapshot.js', discoveryRoot: 'test/test-data', }, ]), @@ -374,14 +376,14 @@ describe('parallel worker', () => { duration: expect.anything(), region: 'us-east-2', tests: { - 'integ.test-with-snapshot.js': expect.anything(), + 'xxxxx.test-with-snapshot.js': expect.anything(), }, }, { duration: expect.anything(), region: 'us-east-1', tests: { - 'integ.another-test-with-snapshot.js': expect.anything(), + 'xxxxx.another-test-with-snapshot.js': expect.anything(), }, }, ]), @@ -391,11 +393,11 @@ describe('parallel worker', () => { test('more tests than regions', async () => { const tests = [ { - fileName: 'integ.test-with-snapshot.js', + fileName: 'xxxxx.test-with-snapshot.js', discoveryRoot: 'test/test-data', }, { - fileName: 'integ.another-test-with-snapshot.js', + fileName: 'xxxxx.another-test-with-snapshot.js', discoveryRoot: 'test/test-data', }, ]; @@ -406,19 +408,19 @@ describe('parallel worker', () => { }); expect(stderrMock.mock.calls[1][0]).toContain( - 'Running test integ.test-with-snapshot.js in us-east-1', + 'Running test xxxxx.test-with-snapshot.js in us-east-1', ); expect(stderrMock.mock.calls[0][0]).toContain( - 'Running test integ.another-test-with-snapshot.js in us-east-1', + 'Running test xxxxx.another-test-with-snapshot.js in us-east-1', ); expect(results).toEqual({ failedTests: expect.arrayContaining([ { - fileName: 'integ.another-test-with-snapshot.js', + fileName: 'xxxxx.another-test-with-snapshot.js', discoveryRoot: 'test/test-data', }, { - fileName: 'integ.test-with-snapshot.js', + fileName: 'xxxxx.test-with-snapshot.js', discoveryRoot: 'test/test-data', }, ]), @@ -427,8 +429,8 @@ describe('parallel worker', () => { duration: expect.anything(), region: 'us-east-1', tests: { - 'integ.test-with-snapshot.js': expect.anything(), - 'integ.another-test-with-snapshot.js': expect.anything(), + 'xxxxx.test-with-snapshot.js': expect.anything(), + 'xxxxx.another-test-with-snapshot.js': expect.anything(), }, }, ]), @@ -438,11 +440,11 @@ describe('parallel worker', () => { test('more regions than tests', async () => { const tests = [ { - fileName: 'integ.test-with-snapshot.js', + fileName: 'xxxxx.test-with-snapshot.js', discoveryRoot: 'test/test-data', }, { - fileName: 'integ.another-test-with-snapshot.js', + fileName: 'xxxxx.another-test-with-snapshot.js', discoveryRoot: 'test/test-data', }, ]; @@ -453,19 +455,19 @@ describe('parallel worker', () => { }); expect(stderrMock.mock.calls[1][0]).toContain( - 'Running test integ.test-with-snapshot.js in us-east-2', + 'Running test xxxxx.test-with-snapshot.js in us-east-2', ); expect(stderrMock.mock.calls[0][0]).toContain( - 'Running test integ.another-test-with-snapshot.js in us-east-1', + 'Running test xxxxx.another-test-with-snapshot.js in us-east-1', ); expect(results).toEqual({ failedTests: expect.arrayContaining([ { - fileName: 'integ.test-with-snapshot.js', + fileName: 'xxxxx.test-with-snapshot.js', discoveryRoot: 'test/test-data', }, { - fileName: 'integ.another-test-with-snapshot.js', + fileName: 'xxxxx.another-test-with-snapshot.js', discoveryRoot: 'test/test-data', }, ]), @@ -474,14 +476,14 @@ describe('parallel worker', () => { duration: expect.anything(), region: 'us-east-2', tests: { - 'integ.test-with-snapshot.js': expect.anything(), + 'xxxxx.test-with-snapshot.js': expect.anything(), }, }, { duration: expect.anything(), region: 'us-east-1', tests: { - 'integ.another-test-with-snapshot.js': expect.anything(), + 'xxxxx.another-test-with-snapshot.js': expect.anything(), }, }, ]), diff --git a/packages/@aws-cdk/integ-runner/test/workers/snapshot-worker.test.ts b/packages/@aws-cdk/integ-runner/test/workers/snapshot-worker.test.ts index ac9d4cda13f60..69afed10bdd17 100644 --- a/packages/@aws-cdk/integ-runner/test/workers/snapshot-worker.test.ts +++ b/packages/@aws-cdk/integ-runner/test/workers/snapshot-worker.test.ts @@ -21,7 +21,7 @@ describe('Snapshot tests', () => { test('no snapshot', () => { // WHEN const test = { - fileName: path.join(directory, 'integ.integ-test1.js'), + fileName: path.join(directory, 'xxxxx.integ-test1.js'), discoveryRoot: directory, }; const result = snapshotTestWorker(test); @@ -35,7 +35,7 @@ describe('Snapshot tests', () => { // WHEN jest.spyOn(child_process, 'spawnSync').mockResolvedValue; const test = { - fileName: path.join(directory, 'integ.test-with-snapshot.js'), + fileName: path.join(directory, 'xxxxx.test-with-snapshot.js'), discoveryRoot: directory, }; const result = snapshotTestWorker(test); @@ -48,7 +48,7 @@ describe('Snapshot tests', () => { // WHEN jest.spyOn(child_process, 'spawnSync').mockRejectedValue; const test = { - fileName: path.join(directory, 'integ.test-with-snapshot-assets.js'), + fileName: path.join(directory, 'xxxxx.test-with-snapshot-assets.js'), discoveryRoot: directory, destructiveChanges: [], };