Skip to content

Commit 7e1a978

Browse files
authored
chore: forward merge 'master' into 'v2-main' (#19999)
Automated action from aws/cdk-ops
2 parents ab455f1 + 756fac4 commit 7e1a978

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+5614
-1973
lines changed

INTEGRATION_TESTS.md

+38
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on what type of changes require integrations tests and how you should write inte
1010
- [New L2 Constructs](#new-l2-constructs)
1111
- [Existing L2 Constructs](#existing-l2-constructs)
1212
- [Assertions](#assertions)
13+
- [Running Integration Tests](#running-integration-tests)
1314

1415
## What are CDK Integration Tests
1516

@@ -223,3 +224,40 @@ to deploy the Lambda Function _and_ then rerun the assertions to ensure that the
223224

224225
### Assertions
225226
...Coming soon...
227+
228+
## Running Integration Tests
229+
230+
Most of the time you will only need to run integration tests for an individual module (i.e. `aws-lambda`). Other times you may need to run tests across multiple modules.
231+
In this case I would recommend running from the root directory like below.
232+
233+
_Run snapshot tests only_
234+
```bash
235+
yarn integ-runner --directory packages/@aws-cdk
236+
```
237+
238+
_Run snapshot tests and then re-run integration tests for failed snapshots_
239+
```bash
240+
yarn integ-runner --directory packages/@aws-cdk --update-on-failed
241+
```
242+
243+
One benefit of running from the root directory like this is that it will only collect tests from "built" modules. If you have built the entire
244+
repo it will run all integration tests, but if you have only built a couple modules it will only run tests from those.
245+
246+
### Running large numbers of Tests
247+
248+
If you need to re-run a large number of tests you can run them in parallel like this.
249+
250+
```bash
251+
yarn integ-runner --directory packages/@aws-cdk --update-on-failed \
252+
--parallel-regions us-east-1 \
253+
--parallel-regions us-east-2 \
254+
--parallel-regions us-west-2 \
255+
--parallel-regions eu-west-1 \
256+
--profiles profile1 \
257+
--profiles profile2 \
258+
--profiles profile3 \
259+
--verbose
260+
```
261+
262+
When using both `--parallel-regions` and `--profiles` it will execute (regions*profiles) tests in parallel (in this example 12)
263+
If you want to execute more than 16 tests in parallel you can pass a higher value to `--max-workers`.
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"17.0.0"}
1+
{"version":"17.0.0"}

packages/@aws-cdk/cloud-assembly-schema/schema/integ.schema.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -471,4 +471,4 @@
471471
}
472472
},
473473
"$schema": "http://json-schema.org/draft-07/schema#"
474-
}
474+
}

packages/@aws-cdk/integ-runner/README.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ to be a self contained CDK app. The runner will execute the following for each f
4444
- `--clean` (default=`true`)
4545
Destroy stacks after deploy (use `--no-clean` for debugging)
4646
- `--verbose` (default=`false`)
47-
verbose logging
48-
- `--parallel` (default=`true`)
49-
Run tests in parallel across default regions
47+
verbose logging, including integration test metrics
5048
- `--parallel-regions` (default=`us-east-1`,`us-east-2`, `us-west-2`)
5149
List of regions to run tests in. If this is provided then all tests will
5250
be run in parallel across these regions
@@ -66,11 +64,18 @@ to be a self contained CDK app. The runner will execute the following for each f
6664
Example:
6765

6866
```bash
69-
integ-runner --update --parallel --parallel-regions us-east-1 --parallel-regions us-east-2 --parallel-regions us-west-2 --directory ./
67+
integ-runner --update-on-failed --parallel-regions us-east-1 --parallel-regions us-east-2 --parallel-regions us-west-2 --directory ./
7068
```
7169

7270
This will search for integration tests recursively from the current directory and then execute them in parallel across `us-east-1`, `us-east-2`, & `us-west-2`.
7371

72+
If you are providing a list of tests to execute, either as CLI arguments or from a file, the name of the test needs to be relative to the `directory`.
73+
For example, if there is a test `aws-iam/test/integ.policy.js` and the current working directory is `aws-iam` you would provide `integ.policy.js`
74+
75+
```bash
76+
yarn integ integ.policy.js
77+
```
78+
7479
### Common Workflow
7580

7681
A common workflow to use when running integration tests is to first run the integration tests to see if there are any snapshot differences.

packages/@aws-cdk/integ-runner/THIRD_PARTY_LICENSES

+1,906-192
Large diffs are not rendered by default.

packages/@aws-cdk/integ-runner/lib/cli.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as path from 'path';
33
import * as chalk from 'chalk';
44
import * as workerpool from 'workerpool';
55
import * as logger from './logger';
6-
import { IntegrationTests, IntegTestConfig } from './runner/integ-tests';
6+
import { IntegrationTests, IntegTestConfig } from './runner/integration-tests';
77
import { runSnapshotTests, runIntegrationTests, IntegRunnerMetrics, IntegTestWorkerConfig, DestructiveChange } from './workers';
88

99
// https://github.com/yargs/yargs/issues/1929
@@ -17,13 +17,12 @@ async function main() {
1717
.usage('Usage: integ-runner [TEST...]')
1818
.option('list', { type: 'boolean', default: false, desc: 'List tests instead of running them' })
1919
.option('clean', { type: 'boolean', default: true, desc: 'Skips stack clean up after test is completed (use --no-clean to negate)' })
20-
.option('verbose', { type: 'boolean', default: false, alias: 'v', desc: 'Verbose logs' })
20+
.option('verbose', { type: 'boolean', default: false, alias: 'v', desc: 'Verbose logs and metrics on integration tests durations' })
2121
.option('dry-run', { type: 'boolean', default: false, desc: 'do not actually deploy the stack. just update the snapshot (not recommended!)' })
2222
.option('update-on-failed', { type: 'boolean', default: false, desc: 'rerun integration tests and update snapshots for failed tests.' })
2323
.option('force', { type: 'boolean', default: false, desc: 'Rerun all integration tests even if tests are passing' })
24-
.option('parallel', { type: 'boolean', default: false, desc: 'run integration tests in parallel' })
25-
.option('parallel-regions', { type: 'array', desc: 'if --parallel is used then these regions are used to run tests in parallel', nargs: 1, default: [] })
26-
.options('directory', { type: 'string', default: 'test', desc: 'starting directory to discover integration tests' })
24+
.option('parallel-regions', { type: 'array', desc: 'Tests are run in parallel across these regions. To prevent tests from running in parallel, provide only a single region', nargs: 1, default: [] })
25+
.options('directory', { type: 'string', default: 'test', desc: 'starting directory to discover integration tests. Tests will be discovered recursively from this directory' })
2726
.options('profiles', { type: 'array', desc: 'list of AWS profiles to use. Tests will be run in parallel across each profile+regions', nargs: 1, default: [] })
2827
.options('max-workers', { type: 'number', desc: 'The max number of workerpool workers to use when running integration tests in parallel', default: 16 })
2928
.options('exclude', { type: 'boolean', desc: 'All tests should be run, except for the list of tests provided', default: false })
@@ -61,11 +60,11 @@ async function main() {
6160
if (argv._.length > 0 && fromFile) {
6261
throw new Error('A list of tests cannot be provided if "--from-file" is provided');
6362
} else if (argv._.length === 0 && !fromFile) {
64-
testsFromArgs.push(...(await new IntegrationTests(argv.directory).fromCliArgs()));
63+
testsFromArgs.push(...(await new IntegrationTests(path.resolve(argv.directory)).fromCliArgs()));
6564
} else if (fromFile) {
66-
testsFromArgs.push(...(await new IntegrationTests(argv.directory).fromFile(fromFile)));
65+
testsFromArgs.push(...(await new IntegrationTests(path.resolve(argv.directory)).fromFile(path.resolve(fromFile))));
6766
} else {
68-
testsFromArgs.push(...(await new IntegrationTests(argv.directory).fromCliArgs(argv._.map((x: any) => x.toString()), exclude)));
67+
testsFromArgs.push(...(await new IntegrationTests(path.resolve(argv.directory)).fromCliArgs(argv._.map((x: any) => x.toString()), exclude)));
6968
}
7069

7170
// always run snapshot tests, but if '--force' is passed then
@@ -93,7 +92,7 @@ async function main() {
9392
clean: argv.clean,
9493
dryRun: argv['dry-run'],
9594
verbose: argv.verbose,
96-
updateWorkflow: !argv['disable-update-workflow'],
95+
updateWorkflow: !!argv['disable-update-workflow'],
9796
});
9897

9998
if (argv.clean === false) {
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
export * from './runners';
2-
export * from './integ-tests';
1+
export * from './runner-base';
2+
export * from './integ-test-suite';
3+
export * from './integ-test-runner';
4+
export * from './snapshot-test-runner';
5+
export * from './integration-tests';

0 commit comments

Comments
 (0)