Skip to content

Commit

Permalink
chore: even more integ tests fixes
Browse files Browse the repository at this point in the history
- Properly pass on the `$STACK_NAME_PREFIX` to the CDK app, or the tests
and app will disagree on stack names.
- Change the app fixture setup to not be done for every individual
test. It won't be mutated anyway, and this saves a lot of time.
- Fix the 'generating and loading assembly test', it needed 2 synths.
  • Loading branch information
rix0rrr authored May 14, 2020
1 parent 540a7e6 commit a48767c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
5 changes: 4 additions & 1 deletion packages/aws-cdk/test/integ/cli/bootstrapping.integtest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ import { cdk, cleanupOldStacks, fullStackName, prepareAppFixture } from './cdk-h

jest.setTimeout(600 * 1000);

beforeEach(async () => {
beforeAll(async () => {
await prepareAppFixture();
});

beforeEach(async () => {
await cleanupOldStacks();
});

Expand Down
1 change: 1 addition & 0 deletions packages/aws-cdk/test/integ/cli/cdk-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export async function cdk(args: string[], options: CdkCliOptions = {}) {
modEnv: {
AWS_REGION: (await testEnv()).region,
AWS_DEFAULT_REGION: (await testEnv()).region,
STACK_NAME_PREFIX,
...options.modEnv,
},
});
Expand Down
20 changes: 16 additions & 4 deletions packages/aws-cdk/test/integ/cli/cli.integtest.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { promises as fs } from 'fs';
import * as os from 'os';
import * as path from 'path';
import { afterSeconds, cloudFormation, iam, lambda, retry, sns, sts, testEnv } from './aws-helpers';
import { afterSeconds, cloudFormation, iam, lambda, retry, sleep, sns, sts, testEnv } from './aws-helpers';
import { cdk, cdkDeploy, cdkDestroy, cleanupOldStacks, cloneDirectory, fullStackName,
INTEG_TEST_DIR, log, prepareAppFixture, shell, STACK_NAME_PREFIX } from './cdk-helpers';

jest.setTimeout(600 * 1000);

beforeEach(async () => {
beforeAll(async () => {
await prepareAppFixture();
});

beforeEach(async () => {
await cleanupOldStacks();
});

Expand Down Expand Up @@ -304,6 +307,11 @@ test('deploy with role', async () => {
});
});

// In principle, the role has replicated from 'us-east-1' to wherever we're testing.
// Give it a little more sleep to make sure CloudFormation is not hitting a box
// that doesn't have it yet.
await sleep(5000);

await cdkDeploy('test-2', {
options: ['--role-arn', roleArn],
});
Expand Down Expand Up @@ -502,10 +510,14 @@ test('generating and loading assembly', async () => {
const asmOutputDir = path.join(os.tmpdir(), 'cdk-integ-asm');
await shell(['rm', '-rf', asmOutputDir]);

// Synthesize a Cloud Assembly
// Make sure our fixture directory is clean
await prepareAppFixture();

// Synthesize a Cloud Assembly tothe default directory (cdk.out) and a specific directory.
await cdk(['synth']);
await cdk(['synth', '--output', asmOutputDir]);

// cdk.out in the current direc,tory and the indicated --output should be the same
// cdk.out in the current directory and the indicated --output should be the same
await shell(['diff', 'cdk.out', asmOutputDir], {
cwd: INTEG_TEST_DIR,
});
Expand Down

0 comments on commit a48767c

Please sign in to comment.