Skip to content

Commit 61725f4

Browse files
authored
test: advanced test use cases (aws-powertools#3737)
1 parent 0c26e13 commit 61725f4

Some content is hidden

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

41 files changed

+1727
-1863
lines changed

.github/scripts/get_pr_info.js

-30
This file was deleted.

.github/workflows/run-e2e-tests.yml

+14-10
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,21 @@ jobs:
1717
env:
1818
NODE_ENV: dev
1919
PR_NUMBER: ${{ inputs.prNumber }}
20+
GH_TOKEN: ${{ github.token }}
2021
permissions:
2122
id-token: write # needed to interact with GitHub's OIDC Token endpoint.
2223
contents: read
2324
strategy:
24-
max-parallel: 30
25+
max-parallel: 25
2526
matrix:
2627
package:
2728
[
28-
layers,
29+
packages/idempotency,
2930
packages/logger,
3031
packages/metrics,
31-
packages/tracer,
3232
packages/parameters,
33-
packages/idempotency,
33+
packages/tracer,
34+
layers,
3435
]
3536
version: [18, 20, 22]
3637
arch: [x86_64, arm64]
@@ -42,11 +43,14 @@ jobs:
4243
- name: Extract PR details
4344
id: extract_PR_details
4445
if: ${{ inputs.prNumber != '' }}
45-
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
46-
with:
47-
script: |
48-
const script = require('.github/scripts/get_pr_info.js');
49-
await script({github, context, core});
46+
run: |
47+
# Get the PR number from the input
48+
pr_number=${{ inputs.prNumber }}
49+
# Get the headSHA of the PR
50+
head_sha=$(gh pr view $pr_number --json headRefOid -q '.headRefOid')
51+
# Set the headSHA as an output variable
52+
echo "headSHA=$head_sha" >> $GITHUB_OUTPUT
53+
echo "headSHA=$head_sha"
5054
# Only if a PR Number was passed and the headSHA of the PR extracted,
5155
# we checkout the PR at that point in time
5256
- name: Checkout PR code
@@ -75,4 +79,4 @@ jobs:
7579
ARCH: ${{ matrix.arch }}
7680
JSII_SILENCE_WARNING_DEPRECATED_NODE_VERSION: true
7781
RUNNER_DEBUG: ${{ env.RUNNER_DEBUG }}
78-
run: npm run test:e2e -w ${{ matrix.package }}
82+
run: npm run test:e2e -w ${{ matrix.package }}

layers/tests/e2e/constants.ts

-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
11
export const RESOURCE_NAME_PREFIX = 'Layers-E2E';
2-
export const ONE_MINUTE = 60 * 1000;
3-
export const TEST_CASE_TIMEOUT = 3 * ONE_MINUTE;
4-
export const SETUP_TIMEOUT = 7 * ONE_MINUTE;
5-
export const TEARDOWN_TIMEOUT = 5 * ONE_MINUTE;

layers/tests/e2e/layerPublisher.test.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ import { LayerVersion } from 'aws-cdk-lib/aws-lambda';
1111
import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest';
1212
import packageJson from '../../package.json';
1313
import { LayerPublisherStack } from '../../src/layer-publisher-stack.js';
14-
import {
15-
RESOURCE_NAME_PREFIX,
16-
SETUP_TIMEOUT,
17-
TEARDOWN_TIMEOUT,
18-
} from './constants.js';
14+
import { RESOURCE_NAME_PREFIX } from './constants.js';
1915

2016
/**
2117
* This test has two stacks:
@@ -121,7 +117,7 @@ describe('Layers E2E tests', () => {
121117
})
122118
);
123119
}
124-
}, SETUP_TIMEOUT);
120+
});
125121

126122
it.each(cases)(
127123
'imports and instantiates all utilities (%s)',
@@ -198,5 +194,5 @@ describe('Layers E2E tests', () => {
198194
await testLayerStack.destroy();
199195
await testStack.destroy();
200196
}
201-
}, TEARDOWN_TIMEOUT);
197+
});
202198
});

layers/vitest.config.ts

+2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@ import { defineProject } from 'vitest/config';
33
export default defineProject({
44
test: {
55
environment: 'node',
6+
hookTimeout: 1_000 * 60 * 10, // 10 minutes
7+
testTimeout: 1_000 * 60 * 3, // 3 minutes
68
},
79
});

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"typedoc-plugin-missing-exports": "^3.1.0",
6666
"typedoc-plugin-zod": "^1.4.0",
6767
"typescript": "^5.8.2",
68-
"vitest": "^3.0.5"
68+
"vitest": "^3.0.9"
6969
},
7070
"lint-staged": {
7171
"*.{js,ts}": "biome check --write",
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
11
export const RESOURCE_NAME_PREFIX = 'Idempotency';
2-
3-
export const ONE_MINUTE = 60 * 1_000;
4-
export const TEARDOWN_TIMEOUT = 5 * ONE_MINUTE;
5-
export const SETUP_TIMEOUT = 7 * ONE_MINUTE;
6-
export const TEST_CASE_TIMEOUT = 5 * ONE_MINUTE;

0 commit comments

Comments
 (0)