Skip to content
This repository was archived by the owner on Jul 16, 2024. It is now read-only.

Commit ef827a3

Browse files
authored
Merge pull request #676 from aws-samples/fix-e2e-tests
test: use AwsCdkCli for deployments
2 parents 1ccb838 + 5b4fc2e commit ef827a3

31 files changed

+512
-520
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
build:
77
runs-on: ubuntu-22.04
88
env:
9-
CI: "true"
9+
CI: 'true'
1010
steps:
1111
- name: Checkout
1212
uses: actions/checkout@v2
@@ -22,8 +22,10 @@ jobs:
2222
with:
2323
distribution: 'zulu' # OpenJDK
2424
java-version: '11'
25+
- name: make shims writable for pip force-reinstall
26+
run: sudo chmod 777 -R /opt/pyenv/shims
2527
- name: force cryptography version
26-
run: pip install --force-reinstall "cryptography==38.0.4"
28+
run: pip install --force-reinstall "cryptography==38.0.4"
2729
- name: Install dependencies
2830
run: cd core && yarn install --check-files --frozen-lockfile
2931
- name: Set git identity
@@ -43,7 +45,8 @@ jobs:
4345
HEAD:$REF'
4446
- if: steps.git_diff.outputs.has_changes
4547
name: Update status check (if changed)
46-
run: gh api -X POST /repos/$FULL_NAME/check-runs -F name="build" -F head_sha="$(git rev-parse HEAD)" -F
48+
run:
49+
gh api -X POST /repos/$FULL_NAME/check-runs -F name="build" -F head_sha="$(git rev-parse HEAD)" -F
4750
status="completed" -F conclusion="success"
4851
env:
4952
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

core/.projen/deps.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/.projen/tasks.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/.projenrc.js

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const { basename, join, dirname, relative } = require('path');
55
const fs = require('fs');
66
const glob = require('glob');
77

8-
98
const { awscdk } = require('projen');
109

1110
const CDK_VERSION = '2.84.0';
@@ -18,12 +17,7 @@ const project = new awscdk.AwsCdkConstructLibrary({
1817
homepage: 'https://aws-samples.github.io/aws-analytics-reference-architecture/',
1918
copyrightPeriod: `2021-${new Date().getFullYear()}`,
2019
copyrightOwner: 'Amazon.com, Inc. or its affiliates. All Rights Reserved.',
21-
keywords: [
22-
'aws',
23-
'constructs',
24-
'cdk',
25-
'analytics',
26-
],
20+
keywords: ['aws', 'constructs', 'cdk', 'analytics'],
2721

2822
cdkVersion: CDK_VERSION,
2923
jsiiVersion: '~5.0.0',
@@ -60,7 +54,6 @@ const project = new awscdk.AwsCdkConstructLibrary({
6054
'aws-cdk-lib',
6155
`aws-cdk@${CDK_VERSION}`,
6256
`cdk-assets@${CDK_VERSION}`,
63-
`@aws-cdk/cx-api@${CDK_VERSION}`,
6457
`@aws-cdk/cloudformation-diff@${CDK_VERSION}`,
6558
'jest-runner-groups',
6659
'promptly',
@@ -69,8 +62,9 @@ const project = new awscdk.AwsCdkConstructLibrary({
6962
7063
`@aws-cdk/aws-redshift-alpha@${CDK_VERSION}-alpha.0`,
7164
`@aws-cdk/aws-glue-alpha@${CDK_VERSION}-alpha.0`,
65+
`@aws-cdk/cli-lib-alpha@${CDK_VERSION}-alpha.0`,
7266
'@aws-cdk/lambda-layer-kubectl-v22',
73-
'@aws-cdk/lambda-layer-kubectl-v25'
67+
'@aws-cdk/lambda-layer-kubectl-v25',
7468
],
7569

7670
peerDeps: [
@@ -84,13 +78,7 @@ const project = new awscdk.AwsCdkConstructLibrary({
8478
},
8579
},
8680

87-
bundledDeps: [
88-
'js-yaml',
89-
'uuid',
90-
'aws-sdk',
91-
'@exodus/schemasafe',
92-
'simple-base',
93-
],
81+
bundledDeps: ['js-yaml', 'uuid', 'aws-sdk', '@exodus/schemasafe', 'simple-base'],
9482

9583
python: {
9684
distName: 'aws_analytics_reference_architecture',
@@ -106,7 +94,6 @@ const project = new awscdk.AwsCdkConstructLibrary({
10694
},
10795

10896
stability: 'experimental',
109-
11097
});
11198

11299
project.testTask.reset('jest --group=unit');
@@ -137,7 +124,6 @@ project.addTask('test:destroy', {
137124
exec: 'cdk destroy --app=./lib/integ.default.js',
138125
});
139126

140-
141127
project.addDevDeps('glob');
142128

143129
/**
@@ -204,7 +190,6 @@ project.compileTask.exec('npx projen pip-install');
204190
* @returns Array of directory paths
205191
*/
206192
function findAllPythonLambdaDir(rootDir) {
207-
208193
return glob.sync(`${rootDir}/**/requirements.txt`).map((pathWithReq) => {
209194
return pathWithReq;
210195
});

core/package.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/test/e2e/ara-bucket.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22
// SPDX-License-Identifier: MIT-0
33

44
/**
5-
* Tests AraBucket
6-
*
7-
* @group integ/ara-bucket
8-
*/
5+
* Tests AraBucket
6+
*
7+
* @group integ/ara-bucket
8+
*/
99

1010
import * as cdk from 'aws-cdk-lib';
11-
import { deployStack, destroyStack } from './utils';
11+
import { TestStack } from './utils/TestStack';
1212

1313
import { AraBucket } from '../../src/ara-bucket';
1414

1515
jest.setTimeout(100000);
1616
// GIVEN
17-
const integTestApp = new cdk.App();
18-
const stack = new cdk.Stack(integTestApp, 'AraBucketE2eTest');
17+
const testStack = new TestStack('AraBucketE2eTest');
18+
const { stack } = testStack;
1919

20-
const araBucket = AraBucket.getOrCreate(stack, {
20+
const araBucket = AraBucket.getOrCreate(stack, {
2121
bucketName: 'my-ara-bucket',
2222
serverAccessLogsPrefix: 'test',
2323
});
@@ -30,13 +30,13 @@ new cdk.CfnOutput(stack, 'BucketName', {
3030
describe('deploy succeed', () => {
3131
it('can be deploy succcessfully', async () => {
3232
// GIVEN
33-
const deployResult = await deployStack(integTestApp, stack);
33+
const deployResult = await testStack.deploy();
3434

3535
// THEN
36-
expect(deployResult.outputs.BucketName).toContain('my-ara-bucket-');
36+
expect(deployResult.BucketName).toContain('my-ara-bucket-');
3737
}, 9000000);
3838
});
3939

4040
afterAll(async () => {
41-
await destroyStack(integTestApp, stack);
41+
await testStack.destroy();
4242
});

core/test/e2e/athena-demo-setup.test.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,25 @@
22
// SPDX-License-Identifier: MIT-0
33

44
/**
5-
* Tests AthenaDemoSetup
6-
*
7-
* @group integ/athena-demo-setup
8-
*/
5+
* Tests AthenaDemoSetup
6+
*
7+
* @group integ/athena-demo-setup
8+
*/
99

1010
import * as cdk from 'aws-cdk-lib';
11-
import { deployStack, destroyStack } from './utils';
11+
import { TestStack } from './utils/TestStack';
1212

1313
import { AthenaDemoSetup } from '../../src/athena-demo-setup';
1414

1515
jest.setTimeout(100000);
1616
// GIVEN
17-
const integTestApp = new cdk.App();
18-
const stack = new cdk.Stack(integTestApp, 'AthenaDemoSetupE2eTest');
17+
const testStack = new TestStack('AthenaDemoSetupE2eTest');
18+
const { stack } = testStack;
1919

2020
const athenaSetup = new AthenaDemoSetup(stack, 'AthenaSetup', {});
21-
const athenaSetup2 = new AthenaDemoSetup(stack, 'AthenaSetup2', {workgroupName: 'custom'});
21+
const athenaSetup2 = new AthenaDemoSetup(stack, 'AthenaSetup2', {
22+
workgroupName: 'custom',
23+
});
2224

2325
new cdk.CfnOutput(stack, 'ResultsBucketName', {
2426
value: athenaSetup.resultBucket.bucketName,
@@ -42,18 +44,16 @@ new cdk.CfnOutput(stack, 'ResultsBucketName2', {
4244

4345
describe('deploy succeed', () => {
4446
it('can be deploy succcessfully', async () => {
45-
const deployResult = await deployStack(integTestApp, stack);
47+
const deployResult = await testStack.deploy();
4648

47-
4849
// THEN
49-
expect(deployResult.outputs.AthenaWorkgroupName).toEqual('demo');
50-
expect(deployResult.outputs.AthenaWorkgroupName2).toEqual('custom');
51-
expect(deployResult.outputs.ResultsBucketName).toContain('demo-athena-logs');
52-
expect(deployResult.outputs.ResultsBucketName2).toContain('custom-athena-logs');
53-
50+
expect(deployResult.AthenaWorkgroupName).toEqual('demo');
51+
expect(deployResult.AthenaWorkgroupName2).toEqual('custom');
52+
expect(deployResult.ResultsBucketName).toContain('demo-athena-logs');
53+
expect(deployResult.ResultsBucketName2).toContain('custom-athena-logs');
5454
}, 9000000);
5555
});
5656

5757
afterAll(async () => {
58-
await destroyStack(integTestApp, stack);
58+
await testStack.destroy();
5959
});

0 commit comments

Comments
 (0)