fix(spanner): preserve user call options in execute/read and consolidate test databases#9329
fix(spanner): preserve user call options in execute/read and consolidate test databases#9329cy-yun wants to merge 7 commits into
Conversation
d69b03a to
169514a
Compare
bfd11cb to
41272ef
Compare
| // Poll for completion with the extended timeout | ||
| $op->pollUntilComplete([ | ||
| $op->pollUntilComplete( | ||
| [ |
There was a problem hiding this comment.
Did the linter suggested this change? This change feels wrong to me. I mean it still is valid, but I would expect either the previous iteration or something like:
$op->pollUntilComplete(
[
'timeoutMillis' => ...
]
)As it is right now, having the braces on the same level as the key feels off.
There was a problem hiding this comment.
But I still think the previous one should be valid 🤷
There was a problem hiding this comment.
I fixed the formatting of the code such that it is consistent with the original & phpcbf is not upset
|
|
||
| $this->assertTrue($backup->exists()); | ||
| // Cancellation usually drops the backup. We don't assert exists() | ||
| // to avoid flakiness with asynchronous deletion. |
There was a problem hiding this comment.
Wait, isn't this testing that if you execute a backup deletion and cancel it, it shouldn't be still available? Or am i misreading the test?
There was a problem hiding this comment.
Actually, this test is meant to test canceling a backup creation operation, not a deletion. Previously, the test was calling $op->pollUntilComplete() before $op->cancel(). That meant it was waiting for the backup to fully finish creating, and then issuing a cancel command on a completed operation (which basically does nothing), hence why it used to assert that the backup still existed.
By removing the polling, we are now properly canceling the operation while it is still in-progress. Because we cancelled it mid-flight, Spanner usually drops the incomplete backup, so asserting that it still exists makes the test extremely flaky.
41272ef to
2e68fb4
Compare
2e68fb4 to
921a05c
Compare
921a05c to
122401c
Compare
4bd521e to
bc64d80
Compare
bc64d80 to
5798d9e
Compare
Fix Spanner System Tests Reliability and Provisioning Overhead
This PR addresses the ongoing flakiness and high database provisioning overhead of the Spanner system tests (resolving #9230).
While this PR consolidates test database provisioning (reducing overall execution time by reusing databases), the test suite as a whole will still take a long time to run (~1.5 hours) due to the inherent slowness of operations like Backup and Restore. (Parallelizing these tests with
paratestto bring the time down to minutes is planned for a subsequent follow-up).Below is a breakdown of the specific problems and fixes implemented in this PR:
1. Dropped
$optionsArray (FixingReadTestflakiness & SDK Bug)$optionsarray was inadvertently being omitted when making calls throughDatabase::execute()andTransactionalReadTraitmethods. In the test suite, this surfaced as flakiness intestReadFailsOnDeadlineExceeded(because the 1mstimeoutMillisoption was not passed through, allowing the request to reach the backend). For users, this meant that custom RPC settings (likerequestTimeout,headers, orretrySettings) passed to queries or reads were not being applied to the underlying gRPC requests.Operation::validateOptions()to centrally and explicitly whitelist the internal Spanner SDK options (begin,transactionType, etc.) so that they are cleanly consumed and ignored byOptionsValidator. This allowed us to safely pass the entire$optionsarray straight from the user'sDatabase::execute()call down to the underlyingOperationlayer without throwing unexpected option errors, restoring the proper client-side configuration behavior and fixing the test.2. Test Database Provisioning Overhead
TestDatabaseManagerto provision a single shared Spanner test database and reuse it across all test classes.3. PostgreSQL DDL Compatibility
CREATE TABLEcommands to fail because the tables already existed.IF NOT EXISTSto PostgreSQL DDL statements in thePg*Testclasses.4. Emulator Transaction Leaks
testLockHintReadWriteTransactionwas leaving a transaction hanging without rollback.$res->transaction()->rollback()totestLockHintReadWriteTransaction, and added an unhandled exception catch block inDatabase::runTransactionto rollback non-single-use active transactions before bubbling up the exception.5.
BackupTestReliabilityBackupTestoperations were flaking due to transient errors and improper polling configurations (e.g.timeoutMillisinstead ofmaxPollingDurationSecondsfor GAX long-running operations). The backup cancellation test was also flawed because it tried to wait for a cancelled backup to exist.maxPollingDurationSeconds. Added retry logic forUNAVAILABLEerrors intestRestoreDatabase. Split the backup creation and cancellation tests to prevent the cancellation from interfering with tests that depend on a successfully created backup.6. PHP 8.1 Deprecation Warnings
nullto non-nullable internal string parameters threw deprecation warnings in PHP 8.1 (e.g. inValueMapper). Additionally, themethodkey was sometimes missing when resuming operations in admin clients.ValueMapperand addedissetchecks formethodinLongRunningClientConnectionand*AdminClient.7. CI Configuration
phpunit-system.xml.dist.