Skip to content

Commit cc88595

Browse files
authored
test: add gen2 e2e tests (#833)
1 parent d78e4de commit cc88595

File tree

19 files changed

+3375
-301
lines changed

19 files changed

+3375
-301
lines changed

.codebuild/e2e_workflow.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,27 @@ batch:
7878
debug-session: true
7979
depend-on:
8080
- publish_to_local_registry
81+
- identifier: l_graphql_generator_gen2
82+
buildspec: .codebuild/run_gen2_e2e_test.yml
83+
env:
84+
compute-type: BUILD_GENERAL1_LARGE
85+
variables:
86+
TEST_SUITE: src/__tests__/graphql-generator-gen2.test.ts
87+
CLI_REGION: us-west-2
88+
depend-on:
89+
- publish_to_local_registry
90+
- identifier: w_graphql_generator_gen2
91+
buildspec: .codebuild/run_gen2_e2e_test_windows.yml
92+
env:
93+
compute-type: BUILD_GENERAL1_LARGE
94+
image: $WINDOWS_IMAGE_2019
95+
type: WINDOWS_SERVER_2019_CONTAINER
96+
variables:
97+
TEST_SUITE: src/__tests__/graphql-generator-gen2.test.ts
98+
CLI_REGION: us-east-1
99+
depend-on:
100+
- publish_to_local_registry
101+
- build_windows
81102
- identifier: >-
82103
l_add_codegen_ios_configure_codegen_android_configure_codegen_js_graphql_codegen_android
83104
buildspec: .codebuild/run_e2e_tests.yml

.codebuild/e2e_workflow_base.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,24 @@ batch:
7878
debug-session: true
7979
depend-on:
8080
- publish_to_local_registry
81+
- identifier: l_graphql_generator_gen2
82+
buildspec: .codebuild/run_gen2_e2e_test.yml
83+
env:
84+
compute-type: BUILD_GENERAL1_LARGE
85+
variables:
86+
TEST_SUITE: src/__tests__/graphql-generator-gen2.test.ts
87+
CLI_REGION: us-west-2
88+
depend-on:
89+
- publish_to_local_registry
90+
- identifier: w_graphql_generator_gen2
91+
buildspec: .codebuild/run_gen2_e2e_test_windows.yml
92+
env:
93+
compute-type: BUILD_GENERAL1_LARGE
94+
image: $WINDOWS_IMAGE_2019
95+
type: WINDOWS_SERVER_2019_CONTAINER
96+
variables:
97+
TEST_SUITE: src/__tests__/graphql-generator-gen2.test.ts
98+
CLI_REGION: us-east-1
99+
depend-on:
100+
- publish_to_local_registry
101+
- build_windows

.codebuild/run_gen2_e2e_test.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
version: 0.2
2+
env:
3+
shell: bash
4+
variables:
5+
CI: true
6+
CODEBUILD: true
7+
NODE_OPTIONS: --max-old-space-size=8096
8+
9+
phases:
10+
build:
11+
commands:
12+
- source ./shared-scripts.sh && _setupGen2E2ETestsLinux
13+
- source ./shared-scripts.sh && _runGen2E2ETestsLinux
14+
post_build:
15+
commands:
16+
- source ./shared-scripts.sh && _unassumeTestAccountCredentials
17+
- aws sts get-caller-identity
18+
- source ./shared-scripts.sh && _scanArtifacts
19+
20+
artifacts:
21+
files:
22+
- '**/*'
23+
base-directory: $CODEBUILD_SRC_DIR/packages/amplify-codegen-e2e-tests/amplify-e2e-reports
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: 0.2
2+
env:
3+
shell: powershell.exe
4+
variables:
5+
CI: true
6+
CODEBUILD: true
7+
NODE_OPTIONS: --max-old-space-size=8096
8+
phases:
9+
build:
10+
commands:
11+
# commands need to be run in stand-alone bash scripts so that bash can be used on windows
12+
- bash ./.codebuild/scripts/gen2_e2e_test_windows.sh
13+
post_build:
14+
commands:
15+
# commands need to be run in stand-alone bash scripts so that bash can be used on windows
16+
- bash ./.codebuild/scripts/post_e2e_test.sh
17+
18+
artifacts:
19+
files:
20+
- '**/*'
21+
base-directory: $Env:CODEBUILD_SRC_DIR\packages\amplify-codegen-e2e-tests\amplify-e2e-reports
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
# set exit on error to true
4+
set -e
5+
6+
source ./shared-scripts.sh && _setupGen2E2ETestsWindows
7+
codebuild-breakpoint
8+
source ./shared-scripts.sh && _runGen2E2ETestsWindows

dependency_licenses.txt

Lines changed: 782 additions & 292 deletions
Large diffs are not rendered by default.

packages/amplify-codegen-e2e-core/src/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ export function getCLIPath(testingWithLatestCodebase = false) {
3333
return getCommandPath(commandName);
3434
}
3535

36+
export function getScriptRunnerPath(testingWithLatestCodebase = false) {
37+
if (!testingWithLatestCodebase) {
38+
return process.platform === 'win32' ? 'node.exe' : 'exec';
39+
}
40+
41+
// nodejs executable
42+
return process.execPath;
43+
}
44+
3645
export function isCI(): boolean {
3746
return process.env.CI && process.env.CODEBUILD ? true : false;
3847
}

packages/amplify-codegen-e2e-tests/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"private": true,
1919
"scripts": {
2020
"e2e": "npm run setup-profile && jest --verbose --forceExit",
21+
"e2e-gen2": "jest --verbose --forceExit",
2122
"setup-profile": "ts-node ./src/configure_tests.ts",
2223
"clean-e2e-resources": "ts-node ./src/cleanup-e2e-resources.ts"
2324
},
@@ -41,6 +42,7 @@
4142
},
4243
"devDependencies": {
4344
"@types/jest": "^27.0.0",
45+
"@aws-amplify/backend": "^1.0.0",
4446
"graphql": "^15.8.0",
4547
"ts-node": "^8.10.1"
4648
},
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { Schema } from '../resource'
2+
3+
export const handler: Schema["echoMutation"]["functionHandler"] = async (event, context) => {
4+
return {
5+
id: 'todo1',
6+
content: `Echoing content: ${event.arguments.requiredContent}`,
7+
status: 'COMPLETED',
8+
createdAt: performance.now().toString(),
9+
updatedAt: performance.now().toString(),
10+
};
11+
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { Schema } from '../resource'
2+
3+
export const handler: Schema["echoQuery"]["functionHandler"] = async (event, context) => {
4+
const start = performance.now();
5+
return {
6+
content: `Echoing content: ${event.arguments.content}`,
7+
executionDuration: performance.now() - start
8+
};
9+
};

0 commit comments

Comments
 (0)