fix(Spanner): Make System Tests Work & Work Faster - #9401
Conversation
a0bfe04 to
6f74d5e
Compare
b6fc922 to
03cee14
Compare
| $this->assertEquals( | ||
| $serializer->encodeMessage($message), | ||
| $serializer->encodeMessage($deserializedMessage) | ||
| ); |
There was a problem hiding this comment.
What we have here is testing something different, so I don't like the change. I also don't understand why the change was made (because I do not ever recall seeing issues with this test). Could you explain it?
We do have a specific method assertProtobufEquals in Testing\GeneratedTest, so if there's a problem here, it may be better to use that (although that also calls assertEquals under the hood)
| public function resumeOperation($operationName, $methodName = null) | ||
| { | ||
| $options = $this->descriptors[$methodName]['longRunning'] ?? []; | ||
| $options = isset($methodName) ? ($this->descriptors[$methodName]['longRunning'] ?? []) : []; |
There was a problem hiding this comment.
These are generated classes and shouldnt be updated manually
| // ignore rollback failure and bubble up the original exception | ||
| } | ||
| } | ||
| throw $e; |
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)
520dae2 to
40ca056
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
40ca056 to
213aec2
Compare
…tent databases, and apply code review fixes for tests
213aec2 to
bed320e
Compare
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.