GCP Scenario
Massively Parallel Playwright on Cloud Run Jobs
Use Cloud Run Jobs task parallelism to run hundreds of Playwright shards concurrently, then aggregate via a Workflow.
Architecture
Cloud Build ─► image: playwright-runner ─► Artifact Registry
│
Workflow ─► gcloud run jobs execute e2e \
--tasks 100 --parallelism 100
│
Each task: npx playwright test --shard $TASK/$TOTAL
│
JUnit + trace.zip ─► GCS
│
Workflow ─► Cloud Function: merge shards → HTML reportServices used
Steps
- 1. Build runner
Cloud Build produces a Playwright runner image (browsers preinstalled) pushed to Artifact Registry.
- 2. Fan out
Workflow calls `gcloud run jobs execute` with `--tasks N --parallelism N`; each task gets `CLOUD_RUN_TASK_INDEX`.
- 3. Execute shard
Each task runs `--shard=$((INDEX+1))/$TOTAL`, uploads JUnit + trace + video to GCS.
- 4. Merge
Function downloads shard outputs, merges into a unified HTML report and writes a `summary.json`.
- 5. Gate
Workflow checks summary; non-zero failures or duration-regression > 20% fails the release.
Takeaways
- Cloud Run Jobs `--parallelism` removes the need to manage a grid.
- Shard granularity is the main lever for wall-clock vs cost.
- Centralizing traces in GCS makes every failure replayable later.
