fix(Spanner): Make System Tests Work & Work Faster - #9401
Open
cy-yun wants to merge 5 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
| // ignore rollback failure and bubble up the original exception | ||
| } | ||
| } | ||
| throw $e; |
Contributor
There was a problem hiding this comment.
This looks really important, but this seems like a separate fix or a feature, as it's ensuring an active transaction which fails is rolled back appropriately. I think it should be in a separate PR (with tests)
cy-yun
force-pushed
the
fix-spanner-system-tests
branch
10 times, most recently
from
July 30, 2026 19:40
bed320e to
8532688
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 19:42
8532688 to
8121741
Compare
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. (Parallelizing these tests with
paratestto bring the time down to minutes locally is planned for a subsequent follow-up).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 single 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 inTransactionTest.phpandPgTransactionTest.phpto use the unifiedself::randId()helper.4.
BackupTestReliability & TimeoutsBackupTestoperations were flaking due to transient errors,DEADLINE_EXCEEDEDerrors when GCP was slow, and improper polling configurations.maxPollingDurationSecondsvia an extended timeout loop for all Backup and Restore operations.pollWithExtendedTimeout($op)helper method inBackupTest.DEADLINE_EXCEEDEDexceptions emitted during intermediate polling attempts.5. Emulator Transaction Leaks
Database::runTransactionto rollback non-single-use active transactions before bubbling up the exception. EnsuredReadTest.phpproperly cleans up local emulator transaction state.6. CI Configuration
phpunit-system.xml.distnow that stability is restored.