Skip to content

ci(spanner): re-enable and fix Spanner emulator system tests - #9979

Draft
danieljbruce wants to merge 4 commits into
googleapis:mainfrom
danieljbruce:fix/spanner-system-tests-emulator
Draft

danieljbruce wants to merge 4 commits into
googleapis:mainfrom
danieljbruce:fix/spanner-system-tests-emulator

Conversation

@danieljbruce

@danieljbruce danieljbruce commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Uncomment and modernize .github/workflows/system-tests-against-emulator.yaml with permissions: contents: read, SHA-pinned actions/checkout (with persist-credentials: false) and actions/setup-node, PR-scoped concurrency, timeout-minutes: 30, and workflow_dispatch.
  • Scope workflow push and pull_request paths to handwritten/spanner/** and .github/workflows/system-tests-against-emulator.yaml while excluding !handwritten/spanner/CHANGELOG.md, and skip release-please--* PRs at the job level (preserving .github/CODEOWNERS alignment with @googleapis/spanner-team).
  • Migrate setup from legacy npm install to ./.github/actions/pnpm-lockfile-check and pnpm --filter "...{handwritten/spanner}" run --if-present compile, add a bounded TCP readiness check on localhost:9010, and invoke a new hermetic system-test:emulator script (build/system-test/spanner.js with --no-c8, avoiding non-hermetic install.ts npm registry downloads).
  • Fix handwritten/spanner/system-test/spanner.ts for the official Spanner emulator (gcr.io/cloud-spanner-emulator/emulator:1.5.59@sha256:5f71fecd6330211789b75065ade9587d67b3a6b4678e7e5408e42c22f778c63e): roll back the leaked getTransaction read-write transaction in finally, skip the barrier-synchronized parallel transactions deadlock test and the emulator-bugged precommit-token commit-retry test when IS_EMULATOR_ENABLED, and skip unimplemented ListBackups plus the 30-second cleanup sleep on the emulator.

Testing

  • Validated .github/workflows/system-tests-against-emulator.yaml YAML syntax and security invariants (pinned 40-char SHAs, least-privilege permissions, path filters, and release-please--* guard).
  • Verified pnpm install --frozen-lockfile --ignore-scripts --offline confirms pnpm-lock.yaml remains in sync.
  • Verified pnpm --filter "...{handwritten/spanner}" run --if-present compile and tsc --noEmit -p tsconfig.json succeed with zero errors.
  • Executed system-test:emulator 5 consecutive times against gcr.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).
  • Verified Spanner unit and observability tests pass 5/5 runs on Node.js (2,010 passing each) and 5/5 runs on Bun (2,010 passing each).
  • Verified GIT_DIFF_ARG="upstream/main...HEAD -- :!packages" node ./bin/linter.mjs --strict and ci/run_conditional_tests.sh --strict pass with zero errors.
  • Confirmed system-tests-against-emulator triggers and executes on this pull request via its self-referencing path filter.

Alternatives

  • Deleting .github/workflows/system-tests-against-emulator.yaml would 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.
  • Running full pnpm run system-test against the emulator includes system-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.
  • Leaving the workflow commented out continues generating repo-wide red-check failures on every push and pull request.

Fixes #7643
For b/586916310

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
@product-auto-label product-auto-label Bot added the api: spanner Issues related to the Spanner API. label Nov 25, 2026
@danieljbruce

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +9186 to +9189
if (typeof process.env.SPANNER_EMULATOR_HOST === 'undefined') {
const [backups] = await instance.getBackups();
await Promise.all(backups.map(backup => backup.delete(GAX_OPTIONS)));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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).

Suggested change
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)));
}

danieljbruce and others added 3 commits November 25, 2026 17:54
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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the Spanner API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spanner: system tests against emulator are failing

1 participant