fix(Spanner): Make System Tests Work & Work Faster - #9401
Open
cy-yun wants to merge 15 commits into
Open
Conversation
cy-yun
force-pushed
the
fix-spanner-system-tests
branch
2 times, most recently
from
July 27, 2026 21:26
a0bfe04 to
6f74d5e
Compare
cy-yun
marked this pull request as ready for review
July 28, 2026 18:23
cy-yun
force-pushed
the
fix-spanner-system-tests
branch
from
July 28, 2026 21:26
b6fc922 to
03cee14
Compare
bshaffer
reviewed
Jul 28, 2026
cy-yun
force-pushed
the
fix-spanner-system-tests
branch
10 times, most recently
from
July 30, 2026 19:40
bed320e to
8532688
Compare
cy-yun
force-pushed
the
fix-spanner-system-tests
branch
from
July 30, 2026 19:42
8532688 to
8121741
Compare
test(spanner): consolidate test database provisioning fix(spanner): fix PgReadTest index creation on shared database test(spanner): Consolidate DDL operations into test setup suite test(spanner): fix schema mismatches for partitionedDml and PgQueryTest test(spanner): rename PgQueryTest_2 back to PgQueryTest test(spanner): fix PostgreSQL column name mismatches for test tables
test(spanner): Handle DEADLINE_EXCEEDED in BackupTest test(spanner): fix BackupTest timeout and PgQueryTest schema collision test(spanner): add deadline exceeded polling to testCreateBackup2 refactor(spanner): DRY up extended polling loop in BackupTest
…ger range test(spanner): restore seedTable in BatchTest to fix test coverage test(spanner): fix array_rand bug and batch mutations in seedTable test(spanner): fix fundamentally broken partitionRead test logic in BatchTest fix: move seedTable back to its original location fix(cs): fix style issues in BatchTest.php fix(cs): format multi-line args
…tent databases, and apply code review fixes for tests
cy-yun
force-pushed
the
fix-spanner-system-tests
branch
from
July 30, 2026 22:15
f321d02 to
60871d1
Compare
Hectorhammett
requested changes
Jul 31, 2026
cy-yun
force-pushed
the
fix-spanner-system-tests
branch
2 times, most recently
from
July 31, 2026 23:08
c10e607 to
d601dd3
Compare
…ption catching Refactors backup tests for clarity and adds catching of ApiException where appropriate. Also adds debug logging to system tests for better observability.
Hectorhammett
approved these changes
Aug 4, 2026
Collaborator
|
It lgtm but there seems to be some tests failing 🤨 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses the ongoing flakiness, high database provisioning overhead, and parallel-execution collisions of the Spanner system tests.
By consolidating test database provisioning, we reduce overall execution time through database reuse. Furthermore, we've removed structural bottlenecks (such as ID collisions and schema mismatches) that prevented these tests from running concurrently. Configurations were also added to allow for both sequential and parallel execution of the tests (using paratest, non-functional mode).
Additionally,
BackupTestwas significantly refactored, andbackup2was removed entirely without impacting test coverage. This sped up the backup tests by roughly 33%.Below is a detailed breakdown of the specific problems and fixes implemented in this PR:
1. Test Database Provisioning Overhead & DDL Consolidation
CREATE TABLE), causingTable already existscollisions when tests were executed against a shared persistent database.TestDatabaseManagerto provision a shared Spanner test database and reuse it across all test classes.SystemTestCaseTrait.php(Standard Spanner) andPgSystemTestCaseTrait.php(Postgres Spanner).CREATE TABLEandDROP TABLEoperations from over a dozen individual test classes (e.g.,BatchTest,WriteTest,PgBatchTest).2. PostgreSQL DDL Compatibility & Schema Mismatches
CREATE TABLEcommands to fail because the tables already existed. Additionally, there was schema drift between individual tests.IF NOT EXISTSto PostgreSQL DDL statements in thePg*Testclasses.PgQueryTestandPgPartitionedDmlTestto align exactly with the unified setup suite definitions.PgReadTest.phpso that secondary index creation operates safely on shared databases without conflicting with concurrent tests.3. Row ID Collisions on Persistent Databases
TransactionTest,OperationsTest,BackupTest) share the sameUserstest table, tests running sequentially on a persistent database were slowly filling up the table. Tests generated random keys using narrow ranges likerand(1, 346464), leading to frequentALREADY_EXISTSerrors during insertion due to the Birthday Paradox.SystemTestCase::randId()generator to use a massive 1-billion key space:rand(1, 999999999).rand()ranges in tests likeTransactionTest.phpandPgTransactionTest.phpto use the unifiedself::randId()helper.insertOrUpdatemutations in places where exact state tracking wasn't required to prevent persistent insertion failures.4.
BackupTestReliability, Timeouts & Speed OptimizationBackupTestoperations were flaking due to transient errors,DEADLINE_EXCEEDEDerrors when GCP was slow, and improper polling configurations. Creating multiple backups was also heavily bottlenecking the test suite.BackupTestto removebackup2, completely eliminating redundant backup operations without impacting test coverage and bringing the time down by ~33%.maxPollingDurationSecondsvia an extended timeout loop for all Backup and Restore operations.pollWithExtendedTimeout($op)helper method.DEADLINE_EXCEEDEDexceptions emitted during intermediate polling attempts.5. CI Configuration & Parallel Execution
phpunit-system.xml.distnow that stability is restored.paratestin non-functional parallel mode.