-
Notifications
You must be signed in to change notification settings - Fork 4k
/
cdk-integ.ts
67 lines (54 loc) · 2.11 KB
/
cdk-integ.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env node
// Exercise all integ stacks and if they deploy, update the expected synth files
import * as yargs from 'yargs';
import { DEFAULT_SYNTH_OPTIONS, IntegrationTests } from '../lib/integ-helpers';
// tslint:disable:no-console
async function main() {
const argv = yargs
.usage('Usage: cdk-integ [TEST...]')
.option('list', { type: 'boolean', default: false, desc: 'List tests instead of running them' })
.option('clean', { type: 'boolean', default: true, desc: 'Skips stack clean up after test is completed (use --no-clean to negate)' })
.option('verbose', { type: 'boolean', default: false, alias: 'v', desc: 'Verbose logs' })
.argv;
const tests = await new IntegrationTests('test').fromCliArgs(argv._);
if (argv.list) {
process.stdout.write(tests.map(t => t.name).join(' ') + '\n');
return;
}
for (const test of tests) {
console.error(`Trying to deploy ${test.name}`);
const stackToDeploy = await test.determineTestStack();
console.error(`Selected stack: ${stackToDeploy}`);
const args = new Array<string>();
// inject "--verbose" to the command line of "cdk" if we are in verbose mode
if (argv.verbose) {
args.push('--verbose');
}
try {
// tslint:disable-next-line:max-line-length
await test.invoke([ ...args, 'deploy', '--require-approval', 'never', ...stackToDeploy ], {
verbose: argv.verbose,
// Note: no "context" and "env", so use default user settings!
});
console.error('Success! Writing out reference synth.');
// If this all worked, write the new expectation file
const actual = await test.invoke([ ...args, '--json', 'synth', ...stackToDeploy ], {
json: true,
verbose: argv.verbose,
...DEFAULT_SYNTH_OPTIONS,
});
await test.writeExpected(actual);
} finally {
if (argv.clean) {
console.error('Cleaning up.');
await test.invoke(['destroy', '--force', ...stackToDeploy ]);
} else {
console.error('Skipping clean up (--no-clean).');
}
}
}
}
main().catch(e => {
console.error(e);
process.exit(1);
});