Skip to content

Commit 6e8510e

Browse files
committed
CCM-10981: sharding script.
1 parent dc6f67c commit 6e8510e

File tree

5 files changed

+43
-22
lines changed

5 files changed

+43
-22
lines changed

.github/actions/acceptance-tests/action.yaml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ inputs:
2222
runs:
2323
using: "composite"
2424

25-
strategy:
26-
fail-fast: false
27-
matrix:
28-
shardIndex: [1, 2, 3, 4]
29-
shardTotal: [4]
30-
3125
steps:
3226
- name: Fetch terraform output
3327
uses: actions/download-artifact@v5
@@ -38,9 +32,6 @@ runs:
3832
run: |
3933
npm ci
4034
41-
- name: Install Playwright browsers
42-
run: npx playwright install --with-deps
43-
4435
- name: Generate outputs file
4536
shell: bash
4637
run: |
@@ -51,10 +42,7 @@ runs:
5142
- name: Run test - ${{ inputs.testType }}
5243
shell: bash
5344
run: |
54-
npx playwright test --project=component:setup
55-
npx playwright test --project=component --no-deps --shard${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
56-
npx playwright test --project=component:teardown --no-deps
57-
45+
make test-${{ inputs.testType }}
5846
5947
- name: Archive test results
6048
uses: actions/upload-artifact@v4

tests/test-team/component.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# replicate https://playwright.dev/docs/test-sharding
5+
6+
# 1) Run 4 shards in parallel
7+
pids=()
8+
for s in 1 2 3 4; do
9+
export SHARD_ID="$s"
10+
export PLAYWRIGHT_BLOB_OUTPUT_FILE="blob-report/shard-$s.zip"
11+
npx playwright test --config config/component/component.config.ts --project='component' --shard="$s/4" --output="playwright-report/shard-$s" &
12+
pids+=($!)
13+
done
14+
15+
# Collect exit codes
16+
fail=0
17+
for pid in "${pids[@]}"; do
18+
wait "$pid" || fail=1
19+
done
20+
21+
npx playwright merge-reports --reporter html ./blob-report
22+
23+
24+
exit $fail

tests/test-team/config/component/component.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const buildCommand = [
1212
export default defineConfig({
1313
...baseConfig,
1414

15+
workers: 4,
1516
timeout: 30_000, // 30 seconds in the playwright default
1617
expect: {
1718
timeout: 10_000, // default is 5 seconds. After creating and previewing sometimes the load is slow on a cold start

tests/test-team/config/playwright.config.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ export default defineConfig({
1313
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
1414
reporter: [
1515
['line'],
16-
[
17-
'html',
18-
{
19-
outputFolder: path.resolve(__dirname, '../playwright-report'),
20-
open: process.env.CI ? 'never' : 'on-failure',
21-
},
22-
],
16+
['blob'],
17+
// [
18+
// 'html',
19+
// {
20+
// outputFolder: path.resolve(__dirname, '../playwright-report'),
21+
// open: 'never',
22+
// },
23+
// ],
2324
],
2425
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
2526
use: {

tests/test-team/helpers/auth/cognito-auth-helper.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,13 @@ export type TestUser = TestUserStaticDetails &
105105

106106
export class CognitoAuthHelper {
107107
private static authContextFile = new AuthContextFile(
108-
path.resolve(__dirname, '..', '..', '.auth', 'test-auth-context.json')
108+
path.resolve(
109+
__dirname,
110+
'..',
111+
'..',
112+
'.auth',
113+
`test-auth-context-${process.env.PLAYWRIGHT_RUN_ID}_${process.env.SHARD_ID}.json`
114+
)
109115
);
110116

111117
private notifyClientHelper: ClientConfigurationHelper;
@@ -345,8 +351,9 @@ export class CognitoAuthHelper {
345351
}
346352

347353
export function createAuthHelper() {
354+
console.log(`${process.env.PLAYWRIGHT_RUN_ID}_${process.env.SHARD_ID}`);
348355
return new CognitoAuthHelper(
349-
process.env.PLAYWRIGHT_RUN_ID,
356+
`${process.env.PLAYWRIGHT_RUN_ID}_${process.env.SHARD_ID}`,
350357
process.env.COGNITO_USER_POOL_ID,
351358
process.env.COGNITO_USER_POOL_CLIENT_ID,
352359
process.env.CLIENT_SSM_PATH_PREFIX

0 commit comments

Comments
 (0)