Repository navigation
ci(spanner): re-enable and fix Spanner emulator system tests - #9979
danieljbruce wants to merge 4 commits into
Conversation
Uncomment and modernize .github/workflows/system-tests-against-emulator.yaml using pinned actions, pnpm frozen-lockfile install, path filtering excluding CHANGELOG.md, and a release-please--* PR guard. Add a hermetic system-test:emulator script in handwritten/spanner/package.json and fix emulator incompatibilities in handwritten/spanner/system-test/spanner.ts (rollback leaked getTransaction read-write transaction, skip emulator-incompatible parallel transaction barrier and commit-retry tests, and skip unimplemented ListBackups and 30s cleanup sleep on the emulator). Fixes googleapis#7643 For b/586916310
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces support for running system tests against the Spanner emulator by adding dedicated emulator test scripts to package.json and adjusting test behaviors in spanner.ts when the emulator is enabled (such as skipping unsupported parallel transactions, commit retries, and unnecessary cleanup delays/backup deletions). A review comment suggests using the existing IS_EMULATOR_ENABLED constant in deleteInstance instead of directly checking process.env.SPANNER_EMULATOR_HOST to maintain consistency.
There was a problem hiding this comment.
Code Review
This pull request introduces support for running system tests against the Spanner emulator by adding dedicated emulator test scripts to package.json and skipping emulator-incompatible tests or steps (such as backup deletion, parallel transactions, and commit retries) in spanner.ts. The feedback suggests using the existing IS_EMULATOR_ENABLED constant in deleteInstance instead of checking process.env.SPANNER_EMULATOR_HOST directly, ensuring consistency across the codebase.
| if (typeof process.env.SPANNER_EMULATOR_HOST === 'undefined') { | ||
| const [backups] = await instance.getBackups(); | ||
| await Promise.all(backups.map(backup => backup.delete(GAX_OPTIONS))); | ||
| } |
There was a problem hiding this comment.
For consistency and readability, use the existing IS_EMULATOR_ENABLED boolean constant instead of checking typeof process.env.SPANNER_EMULATOR_HOST === 'undefined'. This aligns with how the emulator check is performed elsewhere in this file (e.g., line 276).
| if (typeof process.env.SPANNER_EMULATOR_HOST === 'undefined') { | |
| const [backups] = await instance.getBackups(); | |
| await Promise.all(backups.map(backup => backup.delete(GAX_OPTIONS))); | |
| } | |
| if (!IS_EMULATOR_ENABLED) { | |
| const [backups] = await instance.getBackups(); | |
| await Promise.all(backups.map(backup => backup.delete(GAX_OPTIONS))); | |
| } |
Resolve GitHub Actions Scan (zizmor-output) unpinned-images failure by pinning gcr.io/cloud-spanner-emulator/emulator to 1.5.59@sha256:5f71fecd6330211789b75065ade9587d67b3a6b4678e7e5408e42c22f778c63e.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Move IS_EMULATOR_ENABLED to module scope so deleteInstance() can reference it without TS2304 after applying the Gemini code-assist suggestion.
Description
Re-enables the Spanner emulator workflow and fixes emulator test failures.
Impact
Eliminates repo-wide red-check noise and restores hermetic Spanner emulator testing.
Changes
.github/workflows/system-tests-against-emulator.yamlwithpermissions: contents: read, SHA-pinnedactions/checkout(withpersist-credentials: false) andactions/setup-node, PR-scopedconcurrency,timeout-minutes: 30, andworkflow_dispatch.pushandpull_requestpathstohandwritten/spanner/**and.github/workflows/system-tests-against-emulator.yamlwhile excluding!handwritten/spanner/CHANGELOG.md, and skiprelease-please--*PRs at the job level (preserving.github/CODEOWNERSalignment with@googleapis/spanner-team).npm installto./.github/actions/pnpm-lockfile-checkandpnpm --filter "...{handwritten/spanner}" run --if-present compile, add a bounded TCP readiness check onlocalhost:9010, and invoke a new hermeticsystem-test:emulatorscript (build/system-test/spanner.jswith--no-c8, avoiding non-hermeticinstall.tsnpm registry downloads).handwritten/spanner/system-test/spanner.tsfor the official Spanner emulator (gcr.io/cloud-spanner-emulator/emulator:1.5.59@sha256:5f71fecd6330211789b75065ade9587d67b3a6b4678e7e5408e42c22f778c63e): roll back the leakedgetTransactionread-write transaction infinally, skip the barrier-synchronizedparallel transactionsdeadlock test and the emulator-bugged precommit-token commit-retry test whenIS_EMULATOR_ENABLED, and skip unimplementedListBackupsplus the 30-second cleanup sleep on the emulator.Testing
.github/workflows/system-tests-against-emulator.yamlYAML syntax and security invariants (pinned 40-char SHAs, least-privilege permissions, path filters, andrelease-please--*guard).pnpm install --frozen-lockfile --ignore-scripts --offlineconfirmspnpm-lock.yamlremains in sync.pnpm --filter "...{handwritten/spanner}" run --if-present compileandtsc --noEmit -p tsconfig.jsonsucceed with zero errors.system-test:emulator5 consecutive times againstgcr.io/cloud-spanner-emulator/emulator:1.5.59@sha256:5f71fecd6330211789b75065ade9587d67b3a6b4678e7e5408e42c22f778c63e(SPANNER_EMULATOR_HOST=localhost:9010,GCLOUD_PROJECT=emulator-test-project): 5/5 passed (397 passing, 153 pending, 0 failing in ~46s each, clean teardown).GIT_DIFF_ARG="upstream/main...HEAD -- :!packages" node ./bin/linter.mjs --strictandci/run_conditional_tests.sh --strictpass with zero errors.system-tests-against-emulatortriggers and executes on this pull request via its self-referencing path filter.Alternatives
.github/workflows/system-tests-against-emulator.yamlwould stop the 0-job failures but lose fast, credential-less Spanner system test coverage (397 tests) in GitHub Actions and leave Spanner: system tests against emulator are failing #7643 unresolved.pnpm run system-testagainst the emulator includessystem-test/install.ts, which downloads unpinned packages from the public npm registry (typescript@^4.0.0,gts@^3.0.0) and is non-hermetic and unrelated to the Spanner emulator.Fixes #7643
For b/586916310