From 2f9cdcb9e0e1d6c339794e59a191f6e77871a1fe Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Mon, 20 Oct 2025 22:47:37 +0000 Subject: [PATCH 01/16] chore(deps): update gcr.io/cloud-spanner-emulator/emulator docker tag to v1.5.42 --- .github/workflows/emulator-system-tests-spanner.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/emulator-system-tests-spanner.yaml b/.github/workflows/emulator-system-tests-spanner.yaml index 16ba9df46bc3..6982b0589dff 100644 --- a/.github/workflows/emulator-system-tests-spanner.yaml +++ b/.github/workflows/emulator-system-tests-spanner.yaml @@ -18,7 +18,7 @@ jobs: runs-on: 'ubuntu-24.04' services: emulator: - image: gcr.io/cloud-spanner-emulator/emulator:1.5.34 + image: gcr.io/cloud-spanner-emulator/emulator:1.5.42 ports: - 9010:9010 - 9020:9020 From 7e085743a814fc95b9617697bd30e088aa814487 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Tue, 21 Oct 2025 16:29:39 +0000 Subject: [PATCH 02/16] chore(Spanner): updates to support new Spanner emulator --- Spanner/src/Result.php | 2 +- Spanner/tests/System/PgBatchTest.php | 36 ++++++++++++------------ Spanner/tests/System/SpannerTestCase.php | 5 +++- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/Spanner/src/Result.php b/Spanner/src/Result.php index 482dc7b82de8..43d66775edfe 100644 --- a/Spanner/src/Result.php +++ b/Spanner/src/Result.php @@ -520,7 +520,7 @@ private function setSnapshotOrTransaction(array $result): void [], $this->mapper ); - if (isset($result['precommitToken'])) { + if (isset($result['precommitToken']['precommitToken'])) { // @TODO: Can we move this logic to the serializer or value mapper? $this->transaction->setPrecommitToken( (new MultiplexedSessionPrecommitToken()) diff --git a/Spanner/tests/System/PgBatchTest.php b/Spanner/tests/System/PgBatchTest.php index 15d592491be2..eb5a71824eb2 100644 --- a/Spanner/tests/System/PgBatchTest.php +++ b/Spanner/tests/System/PgBatchTest.php @@ -55,27 +55,27 @@ public static function setUpTestFixtures(): void ))->pollUntilComplete(); if (self::$database->info()['databaseDialect'] == DatabaseDialect::POSTGRESQL) { - self::$database->updateDdlBatch([ - sprintf( - 'CREATE ROLE %s', - self::$dbRole - ), - sprintf( - 'CREATE ROLE %s', - self::$restrictiveDbRole - ), - sprintf( + $statements = [ + sprintf('CREATE ROLE %s', self::$dbRole), + sprintf('CREATE ROLE %s', self::$restrictiveDbRole), + ]; + + if (!self::isEmulatorUsed()) { + $statements[] = sprintf( 'GRANT SELECT(id) ON TABLE %s TO %s', self::$tableName, self::$restrictiveDbRole - ), - sprintf( - 'GRANT SELECT ON TABLE %s TO %s', - self::$tableName, - self::$dbRole - ) - ])->pollUntilComplete(); - } + ); + } + + $statements[] = sprintf( + 'GRANT SELECT ON TABLE %s TO %s', + self::$tableName, + self::$dbRole + ); + + self::$database->updateDdlBatch($statements)->pollUntilComplete(); + } self::seedTable(); self::$isSetup = true; diff --git a/Spanner/tests/System/SpannerTestCase.php b/Spanner/tests/System/SpannerTestCase.php index 7566789b4b3f..91f06e5c371a 100644 --- a/Spanner/tests/System/SpannerTestCase.php +++ b/Spanner/tests/System/SpannerTestCase.php @@ -78,7 +78,10 @@ protected static function setUpTestDatabase(): void ); $op->pollUntilComplete(); - if (self::$database->info()['databaseDialect'] == DatabaseDialect::GOOGLE_STANDARD_SQL) { + if ( + self::$database->info()['databaseDialect'] == DatabaseDialect::GOOGLE_STANDARD_SQL + && !self::isEmulatorUsed() + ) { self::$database->updateDdlBatch( [ 'CREATE ROLE ' . self::DATABASE_ROLE, From 5715ab20598d33d22004739f2b6554b811341305 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Tue, 21 Oct 2025 16:53:15 +0000 Subject: [PATCH 03/16] more emulator test fixes --- Spanner/tests/System/AdminTest.php | 10 +---- Spanner/tests/System/BatchTest.php | 38 +++++++++---------- .../System/GeneratedAdminEmulatorTest.php | 4 +- Spanner/tests/System/PgBatchTest.php | 12 +++--- Spanner/tests/System/SpannerPgTestCase.php | 9 +---- ...tTransactionsIncrementValueWithExecute.php | 2 +- ...rentTransactionsIncrementValueWithRead.php | 2 +- 7 files changed, 30 insertions(+), 47 deletions(-) diff --git a/Spanner/tests/System/AdminTest.php b/Spanner/tests/System/AdminTest.php index fa2790440775..10522442172a 100644 --- a/Spanner/tests/System/AdminTest.php +++ b/Spanner/tests/System/AdminTest.php @@ -123,15 +123,7 @@ public function testDatabase() $this->assertInstanceOf(Database::class, current($database)); $this->assertTrue($db->exists()); - - $expectedDatabaseDialect = DatabaseDialect::GOOGLE_STANDARD_SQL; - - // TODO: Remove this, when the emulator supports PGSQL - if ((bool) getenv('SPANNER_EMULATOR_HOST')) { - $expectedDatabaseDialect = DatabaseDialect::DATABASE_DIALECT_UNSPECIFIED; - } - - $this->assertEquals($db->info()['databaseDialect'], $expectedDatabaseDialect); + $this->assertEquals($db->info()['databaseDialect'], DatabaseDialect::GOOGLE_STANDARD_SQL); $stmt = "CREATE TABLE Ids (\n" . " id INT64 NOT NULL,\n" . diff --git a/Spanner/tests/System/BatchTest.php b/Spanner/tests/System/BatchTest.php index f90537099581..55b7bb951895 100644 --- a/Spanner/tests/System/BatchTest.php +++ b/Spanner/tests/System/BatchTest.php @@ -55,27 +55,27 @@ public static function setUpTestFixtures(): void self::$tableName ))->pollUntilComplete(); - if (self::$database->info()['databaseDialect'] == DatabaseDialect::GOOGLE_STANDARD_SQL) { - self::$database->updateDdlBatch([ - sprintf( - 'CREATE ROLE %s', - self::$dbRole - ), - sprintf( - 'CREATE ROLE %s', - self::$restrictiveDbRole - ), - sprintf( - 'GRANT SELECT(id) ON TABLE %s TO ROLE %s', + if (self::$database->info()['databaseDialect'] == DatabaseDialect::POSTGRESQL) { + $statements = [ + sprintf('CREATE ROLE %s', self::$dbRole), + sprintf('CREATE ROLE %s', self::$restrictiveDbRole), + ]; + + if (!self::isEmulatorUsed()) { + $statements[] = sprintf( + 'GRANT SELECT(id) ON TABLE %s TO %s', self::$tableName, self::$restrictiveDbRole - ), - sprintf( - 'GRANT SELECT ON TABLE %s TO ROLE %s', - self::$tableName, - self::$dbRole - ) - ])->pollUntilComplete(); + ); + } + + $statements[] = sprintf( + 'GRANT SELECT ON TABLE %s TO %s', + self::$tableName, + self::$dbRole + ); + + self::$database->updateDdlBatch($statements)->pollUntilComplete(); } self::seedTable(); diff --git a/Spanner/tests/System/GeneratedAdminEmulatorTest.php b/Spanner/tests/System/GeneratedAdminEmulatorTest.php index cef39e7faef7..6fc88f249b16 100644 --- a/Spanner/tests/System/GeneratedAdminEmulatorTest.php +++ b/Spanner/tests/System/GeneratedAdminEmulatorTest.php @@ -42,9 +42,7 @@ public static function setUpTestFixtures(): void public function testAdminClientEmulatorSupport() { - if (!getenv('SPANNER_EMULATOR_HOST')) { - self::markTestSkipped('This test is required to run only in the emulator.'); - } + self::emulatorOnly(); $instanceId = uniqid(self::INSTANCE_NAME); $databaseId = uniqid(self::TESTING_PREFIX); diff --git a/Spanner/tests/System/PgBatchTest.php b/Spanner/tests/System/PgBatchTest.php index eb5a71824eb2..b65483496acc 100644 --- a/Spanner/tests/System/PgBatchTest.php +++ b/Spanner/tests/System/PgBatchTest.php @@ -66,13 +66,13 @@ public static function setUpTestFixtures(): void self::$tableName, self::$restrictiveDbRole ); - } + $statements[] = sprintf( + 'GRANT SELECT ON TABLE %s TO %s', + self::$tableName, + self::$dbRole + ); - $statements[] = sprintf( - 'GRANT SELECT ON TABLE %s TO %s', - self::$tableName, - self::$dbRole - ); + } self::$database->updateDdlBatch($statements)->pollUntilComplete(); } diff --git a/Spanner/tests/System/SpannerPgTestCase.php b/Spanner/tests/System/SpannerPgTestCase.php index 45c8eaab85e3..fb4fb09f741f 100644 --- a/Spanner/tests/System/SpannerPgTestCase.php +++ b/Spanner/tests/System/SpannerPgTestCase.php @@ -87,7 +87,7 @@ protected static function setUpTestDatabase(): void // Currently, the emulator doesn't support setting roles for the PG // dialect. - if (!getenv('SPANNER_EMULATOR_HOST')) { + if (!self::isEmulatorUsed()) { $db->updateDdlBatch( [ 'CREATE ROLE ' . self::DATABASE_ROLE, @@ -131,13 +131,6 @@ public static function getDatabaseInstance($dbName) return self::$client->connect(self::INSTANCE_NAME, $dbName); } - public static function skipEmulatorTests() - { - if ((bool) getenv('SPANNER_EMULATOR_HOST')) { - self::markTestSkipped('This test is not supported by the emulator.'); - } - } - public static function getDbWithReaderRole() { return self::getDatabaseFromInstance( diff --git a/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithExecute.php b/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithExecute.php index 5818f0541b50..f943e0bb1a57 100644 --- a/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithExecute.php +++ b/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithExecute.php @@ -13,7 +13,7 @@ $callable = function ($dbName, $tableName, $id) use ($tmpFile) { $iterations = 0; $db = SpannerTestCase::getDatabaseInstance($dbName); - if (getenv('SPANNER_EMULATOR_HOST')) { + if (SpannerTestCase::isEmulatorUsed()) { // the emulator requires us to manually request a new session // presumably because multiplexed sessions aren't properly supported $db->session()->refresh(); diff --git a/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithRead.php b/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithRead.php index 9ec00ec07bfe..d28e5ba20db2 100644 --- a/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithRead.php +++ b/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithRead.php @@ -17,7 +17,7 @@ $callable = function ($dbName, KeySet $keyset, array $columns, $tableName) use ($tmpFile) { $iterations = 0; $db = SpannerTestCase::getDatabaseInstance($dbName); - if (getenv('SPANNER_EMULATOR_HOST')) { + if (SpannerTestCase::isEmulatorUsed()) { // the emulator requires us to manually request a new session // presumably because multiplexed sessions aren't properly supported $db->session()->refresh(); From 0eb1f37d26524595a961d9432635581cabc3cc29 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Tue, 21 Oct 2025 17:09:18 +0000 Subject: [PATCH 04/16] cleanup SpannerPgTest --- Spanner/tests/System/SpannerPgTestCase.php | 76 +--------------------- 1 file changed, 1 insertion(+), 75 deletions(-) diff --git a/Spanner/tests/System/SpannerPgTestCase.php b/Spanner/tests/System/SpannerPgTestCase.php index fb4fb09f741f..fb4e43fd12dc 100644 --- a/Spanner/tests/System/SpannerPgTestCase.php +++ b/Spanner/tests/System/SpannerPgTestCase.php @@ -17,34 +17,14 @@ namespace Google\Cloud\Spanner\Tests\System; -use Google\Auth\Cache\MemoryCacheItemPool; -use Google\Cloud\Core\Testing\System\SystemTestCase; use Google\Cloud\Spanner; -use Google\Cloud\Spanner\Admin\Database\V1\DatabaseDialect; -use Google\Cloud\Spanner\Session\CacheSessionPool; -use Google\Cloud\Spanner\SpannerClient; /** * @group spanner * @group spanner-postgres */ -abstract class SpannerPgTestCase extends SystemTestCase +abstract class SpannerPgTestCase extends SpannerTestCase { - const TESTING_PREFIX = 'gcloud_testing_'; - const INSTANCE_NAME = 'google-cloud-php-system-tests'; - - const TEST_TABLE_NAME = 'Users'; - const TEST_INDEX_NAME = 'uniqueIndex'; - - const DATABASE_ROLE = 'Reader'; - const RESTRICTIVE_DATABASE_ROLE = 'RestrictiveReader'; - - protected static $client; - protected static $instance; - protected static $database; - protected static $database2; - protected static $dbName; - private static $hasSetUp = false; protected static function setUpTestDatabase(): void @@ -103,60 +83,6 @@ protected static function setUpTestDatabase(): void self::$hasSetUp = true; } - public static function getDatabaseFromInstance($instance, $dbName, $options = []) - { - $instance = self::$client->instance($instance); - return $instance->database($dbName, $options); - } - - public static function getDatabaseWithSessionPool($dbName, $options = []) - { - $sessionCache = new MemoryCacheItemPool(); - $sessionPool = new CacheSessionPool( - $sessionCache, - $options - ); - - return self::$client->connect( - self::INSTANCE_NAME, - $dbName, - [ - 'sessionPool' => $sessionPool - ] - ); - } - - public static function getDatabaseInstance($dbName) - { - return self::$client->connect(self::INSTANCE_NAME, $dbName); - } - - public static function getDbWithReaderRole() - { - return self::getDatabaseFromInstance( - self::INSTANCE_NAME, - self::$dbName, - ['databaseRole' => self::DATABASE_ROLE] - ); - } - - public static function getDbWithRestrictiveRole() - { - return self::getDatabaseFromInstance( - self::INSTANCE_NAME, - self::$dbName, - ['databaseRole' => self::RESTRICTIVE_DATABASE_ROLE] - ); - } - - public static function getDbWithSessionPoolRestrictiveRole() - { - return self::getDatabaseWithSessionPool( - self::$dbName, - ['minSessions' => 1, 'maxSession' => 2, 'databaseRole' => self::RESTRICTIVE_DATABASE_ROLE] - ); - } - private static function getClient() { if (self::$client) { From 9bc69845e1ccaa897bc0698d7bee11d7e978b9ec Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Tue, 21 Oct 2025 17:14:54 +0000 Subject: [PATCH 05/16] add back database dialect --- Spanner/tests/System/PgBatchTest.php | 3 +-- Spanner/tests/System/SpannerPgTestCase.php | 1 + Spanner/tests/System/SpannerTestCase.php | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Spanner/tests/System/PgBatchTest.php b/Spanner/tests/System/PgBatchTest.php index b65483496acc..cf685e7ff2fb 100644 --- a/Spanner/tests/System/PgBatchTest.php +++ b/Spanner/tests/System/PgBatchTest.php @@ -71,11 +71,10 @@ public static function setUpTestFixtures(): void self::$tableName, self::$dbRole ); - } self::$database->updateDdlBatch($statements)->pollUntilComplete(); - } + } self::seedTable(); self::$isSetup = true; diff --git a/Spanner/tests/System/SpannerPgTestCase.php b/Spanner/tests/System/SpannerPgTestCase.php index fb4e43fd12dc..e06c9a4f8572 100644 --- a/Spanner/tests/System/SpannerPgTestCase.php +++ b/Spanner/tests/System/SpannerPgTestCase.php @@ -18,6 +18,7 @@ namespace Google\Cloud\Spanner\Tests\System; use Google\Cloud\Spanner; +use Google\Cloud\Spanner\Admin\Database\V1\DatabaseDialect; /** * @group spanner diff --git a/Spanner/tests/System/SpannerTestCase.php b/Spanner/tests/System/SpannerTestCase.php index 91f06e5c371a..ee0710eba327 100644 --- a/Spanner/tests/System/SpannerTestCase.php +++ b/Spanner/tests/System/SpannerTestCase.php @@ -78,8 +78,7 @@ protected static function setUpTestDatabase(): void ); $op->pollUntilComplete(); - if ( - self::$database->info()['databaseDialect'] == DatabaseDialect::GOOGLE_STANDARD_SQL + if (self::$database->info()['databaseDialect'] == DatabaseDialect::GOOGLE_STANDARD_SQL && !self::isEmulatorUsed() ) { self::$database->updateDdlBatch( From f918e7c25e2d7f729569732e185b995267e11572 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Tue, 21 Oct 2025 17:23:28 +0000 Subject: [PATCH 06/16] fix access levels --- Spanner/tests/System/BackupTest.php | 6 +++--- Spanner/tests/System/SpannerPgTestCase.php | 4 +--- Spanner/tests/System/SpannerTestCase.php | 5 ++--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Spanner/tests/System/BackupTest.php b/Spanner/tests/System/BackupTest.php index 6b3dcbf55bd4..e3522475058c 100644 --- a/Spanner/tests/System/BackupTest.php +++ b/Spanner/tests/System/BackupTest.php @@ -47,7 +47,7 @@ class BackupTest extends SpannerTestCase protected static $project; - private static $hasSetUp = false; + private static $hasSetUpBackup = false; /** * @beforeClass @@ -59,7 +59,7 @@ public static function setUpTestFixtures(): void self::emulatorOnly(); self::setUpTestDatabase(); - if (self::$hasSetUp) { + if (self::$hasSetUpBackup) { return; } @@ -112,7 +112,7 @@ public static function setUpTestFixtures(): void self::$backupId1 = uniqid(self::BACKUP_PREFIX); self::$backupId2 = uniqid('users-'); self::$copyBackupId = uniqid('copy-'); - self::$hasSetUp = true; + self::$hasSetUpBackup = true; } public function testCreateBackup() diff --git a/Spanner/tests/System/SpannerPgTestCase.php b/Spanner/tests/System/SpannerPgTestCase.php index e06c9a4f8572..40d882fd9f58 100644 --- a/Spanner/tests/System/SpannerPgTestCase.php +++ b/Spanner/tests/System/SpannerPgTestCase.php @@ -26,8 +26,6 @@ */ abstract class SpannerPgTestCase extends SpannerTestCase { - private static $hasSetUp = false; - protected static function setUpTestDatabase(): void { if (self::$hasSetUp) { @@ -84,7 +82,7 @@ protected static function setUpTestDatabase(): void self::$hasSetUp = true; } - private static function getClient() + protected static function getClient() { if (self::$client) { return self::$client; diff --git a/Spanner/tests/System/SpannerTestCase.php b/Spanner/tests/System/SpannerTestCase.php index ee0710eba327..51d57e8ccf38 100644 --- a/Spanner/tests/System/SpannerTestCase.php +++ b/Spanner/tests/System/SpannerTestCase.php @@ -41,8 +41,7 @@ abstract class SpannerTestCase extends SystemTestCase protected static $database; protected static $database2; protected static $dbName; - - private static $hasSetUp = false; + protected static $hasSetUp = false; protected static function setUpTestDatabase(): void { @@ -98,7 +97,7 @@ protected static function setUpTestDatabase(): void self::$hasSetUp = true; } - private static function getClient() + protected static function getClient() { if (self::$client) { return self::$client; From d38dbfd803a174792b9b52be0c89a0fe6d8191ab Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Tue, 21 Oct 2025 18:29:35 +0000 Subject: [PATCH 07/16] add SystemTestCaseTrait, skip setting up batch tests on emulator --- Spanner/tests/System/PgBatchTest.php | 11 +- Spanner/tests/System/SpannerPgTestCase.php | 43 +------ Spanner/tests/System/SpannerTestCase.php | 105 +--------------- Spanner/tests/System/SystemTestCaseTrait.php | 119 +++++++++++++++++++ 4 files changed, 135 insertions(+), 143 deletions(-) create mode 100644 Spanner/tests/System/SystemTestCaseTrait.php diff --git a/Spanner/tests/System/PgBatchTest.php b/Spanner/tests/System/PgBatchTest.php index cf685e7ff2fb..c1c09407c72b 100644 --- a/Spanner/tests/System/PgBatchTest.php +++ b/Spanner/tests/System/PgBatchTest.php @@ -32,14 +32,19 @@ class PgBatchTest extends SpannerPgTestCase use DatabaseRoleTrait; private static $tableName; - private static $isSetup = false; + private static $hasSetupBatch = false; /** * @beforeClass */ public static function setUpTestFixtures(): void { - if (self::$isSetup) { + // skip setting up fixutres for the emulator as there's only one test which does not + // suppport the emulator. + // NOTE: remove this if emulator tests are adde + self::skipEmulatorTests(); + + if (self::$hasSetupBatch) { return; } self::setUpTestDatabase(); @@ -77,7 +82,7 @@ public static function setUpTestFixtures(): void } self::seedTable(); - self::$isSetup = true; + self::$hasSetupBatch = true; } /** diff --git a/Spanner/tests/System/SpannerPgTestCase.php b/Spanner/tests/System/SpannerPgTestCase.php index 40d882fd9f58..2c054c194250 100644 --- a/Spanner/tests/System/SpannerPgTestCase.php +++ b/Spanner/tests/System/SpannerPgTestCase.php @@ -17,24 +17,24 @@ namespace Google\Cloud\Spanner\Tests\System; -use Google\Cloud\Spanner; +use Google\Cloud\Core\Testing\System\SystemTestCase; use Google\Cloud\Spanner\Admin\Database\V1\DatabaseDialect; /** * @group spanner * @group spanner-postgres */ -abstract class SpannerPgTestCase extends SpannerTestCase +abstract class SpannerPgTestCase extends SystemTestCase { + use SystemTestCaseTrait; + protected static function setUpTestDatabase(): void { if (self::$hasSetUp) { return; } - self::getClient(); - - self::$instance = self::$client->instance(self::INSTANCE_NAME); + self::$instance = self::getClient()->instance(self::INSTANCE_NAME); self::$dbName = uniqid(self::TESTING_PREFIX); @@ -81,37 +81,4 @@ protected static function setUpTestDatabase(): void self::$hasSetUp = true; } - - protected static function getClient() - { - if (self::$client) { - return self::$client; - } - - $keyFilePath = getenv('GOOGLE_CLOUD_PHP_TESTS_KEY_PATH'); - - $clientConfig = [ - 'keyFilePath' => $keyFilePath, - 'cacheItemPool' => self::getCacheItemPool(), - ]; - - $serviceAddress = getenv('SPANNER_SERVICE_ADDRESS'); - if ($serviceAddress) { - $gapicConfig = [ - 'serviceAddress' => $serviceAddress - ]; - - $clientConfig['gapicSpannerClient'] = new Spanner\V1\SpannerClient($gapicConfig); - $clientConfig['gapicSpannerDatabaseAdminClient'] = - new Spanner\Admin\Database\V1\DatabaseAdminClient($gapicConfig); - $clientConfig['gapicSpannerInstanceAdminClient'] = - new Spanner\Admin\Instance\V1\InstanceAdminClient($gapicConfig); - - echo 'Using Service Address: ' . $serviceAddress . PHP_EOL; - } - - self::$client = new SpannerClient($clientConfig); - - return self::$client; - } } diff --git a/Spanner/tests/System/SpannerTestCase.php b/Spanner/tests/System/SpannerTestCase.php index 51d57e8ccf38..73b3be6e0822 100644 --- a/Spanner/tests/System/SpannerTestCase.php +++ b/Spanner/tests/System/SpannerTestCase.php @@ -18,40 +18,22 @@ namespace Google\Cloud\Spanner\Tests\System; use Google\Cloud\Core\Testing\System\SystemTestCase; -use Google\Cloud\Spanner; use Google\Cloud\Spanner\Admin\Database\V1\DatabaseDialect; -use Google\Cloud\Spanner\SpannerClient; /** * @group spanner */ abstract class SpannerTestCase extends SystemTestCase { - const TESTING_PREFIX = 'gcloud_testing_'; - const INSTANCE_NAME = 'google-cloud-php-system-tests'; - - const TEST_TABLE_NAME = 'Users'; - const TEST_INDEX_NAME = 'uniqueIndex'; - - const DATABASE_ROLE = 'Reader'; - const RESTRICTIVE_DATABASE_ROLE = 'RestrictiveReader'; - - protected static $client; - protected static $instance; - protected static $database; - protected static $database2; - protected static $dbName; - protected static $hasSetUp = false; + use SystemTestCaseTrait; protected static function setUpTestDatabase(): void { if (self::$hasSetUp) { return; - } - - self::getClient(); + } - self::$instance = self::$client->instance(self::INSTANCE_NAME); + self::$instance = self::getClient()->instance(self::INSTANCE_NAME); if (!self::$dbName = getenv('GOOGLE_CLOUD_SPANNER_TEST_DATABASE')) { self::$dbName = uniqid(self::TESTING_PREFIX); @@ -96,85 +78,4 @@ protected static function setUpTestDatabase(): void self::$database2 = self::getDatabaseInstance(self::$dbName); self::$hasSetUp = true; } - - protected static function getClient() - { - if (self::$client) { - return self::$client; - } - - $keyFilePath = getenv('GOOGLE_CLOUD_PHP_TESTS_KEY_PATH'); - - $clientConfig = [ - 'keyFilePath' => $keyFilePath, - 'cacheItemPool' => self::getCacheItemPool(), - ]; - - $serviceAddress = getenv('SPANNER_SERVICE_ADDRESS'); - if ($serviceAddress) { - $gapicConfig = [ - 'serviceAddress' => $serviceAddress - ]; - - $clientConfig['gapicSpannerClient'] = new Spanner\V1\Client\SpannerClient($gapicConfig); - $clientConfig['gapicSpannerDatabaseAdminClient'] = - new Spanner\Admin\Database\V1\Client\DatabaseAdminClient($gapicConfig); - $clientConfig['gapicSpannerInstanceAdminClient'] = - new Spanner\Admin\Instance\V1\Client\InstanceAdminClient($gapicConfig); - - echo 'Using Service Address: ' . $serviceAddress . PHP_EOL; - } - - self::$client = new SpannerClient($clientConfig); - - return self::$client; - } - - public static function getDatabaseInstance($dbName, $options = []) - { - return self::getClient()->connect(self::INSTANCE_NAME, $dbName, $options); - } - - public static function getDatabaseFromInstance($instance, $dbName, $options = []) - { - $instance = self::$client->instance($instance); - return $instance->database($dbName, $options); - } - - public static function skipEmulatorTests() - { - if (self::isEmulatorUsed()) { - self::markTestSkipped('This test is not supported by the emulator.'); - } - } - - public static function emulatorOnly() - { - if (!self::isEmulatorUsed()) { - self::markTestSkipped('This test is only supported by the emulator.'); - } - } - - public static function isEmulatorUsed(): bool - { - return (bool) getenv('SPANNER_EMULATOR_HOST'); - } - - public static function getDbWithReaderRole() - { - return self::getDatabaseFromInstance( - self::INSTANCE_NAME, - self::$dbName, - ['databaseRole' => self::DATABASE_ROLE] - ); - } - - public static function getDbWithRestrictiveRole() - { - return self::getDatabaseFromInstance( - self::INSTANCE_NAME, - self::$dbName, - ['databaseRole' => self::RESTRICTIVE_DATABASE_ROLE] - ); - } } diff --git a/Spanner/tests/System/SystemTestCaseTrait.php b/Spanner/tests/System/SystemTestCaseTrait.php new file mode 100644 index 000000000000..eb83824d2b0a --- /dev/null +++ b/Spanner/tests/System/SystemTestCaseTrait.php @@ -0,0 +1,119 @@ + $keyFilePath, + 'cacheItemPool' => self::getCacheItemPool(), + ]; + + $serviceAddress = getenv('SPANNER_SERVICE_ADDRESS'); + if ($serviceAddress) { + $gapicConfig = [ + 'serviceAddress' => $serviceAddress + ]; + + $clientConfig['gapicSpannerClient'] = new Spanner\V1\Client\SpannerClient($gapicConfig); + $clientConfig['gapicSpannerDatabaseAdminClient'] = + new Spanner\Admin\Database\V1\Client\DatabaseAdminClient($gapicConfig); + $clientConfig['gapicSpannerInstanceAdminClient'] = + new Spanner\Admin\Instance\V1\Client\InstanceAdminClient($gapicConfig); + + echo 'Using Service Address: ' . $serviceAddress . PHP_EOL; + } + + return self::$client = new SpannerClient($clientConfig); + } + + public static function getDatabaseInstance($dbName, $options = []) + { + return self::getClient()->connect(self::INSTANCE_NAME, $dbName, $options); + } + + public static function getDatabaseFromInstance($instance, $dbName, $options = []) + { + $instance = self::getClient()->instance($instance); + return $instance->database($dbName, $options); + } + + public static function skipEmulatorTests() + { + if (self::isEmulatorUsed()) { + self::markTestSkipped('This test is not supported by the emulator.'); + } + } + + public static function emulatorOnly() + { + if (!self::isEmulatorUsed()) { + self::markTestSkipped('This test is only supported by the emulator.'); + } + } + + public static function isEmulatorUsed(): bool + { + return (bool) getenv('SPANNER_EMULATOR_HOST'); + } + + public static function getDbWithReaderRole() + { + return self::getDatabaseFromInstance( + self::INSTANCE_NAME, + self::$dbName, + ['databaseRole' => self::DATABASE_ROLE] + ); + } + + public static function getDbWithRestrictiveRole() + { + return self::getDatabaseFromInstance( + self::INSTANCE_NAME, + self::$dbName, + ['databaseRole' => self::RESTRICTIVE_DATABASE_ROLE] + ); + } +} From 60060ccb509cea1e2b60e16439984f2c3778dfec Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Tue, 21 Oct 2025 19:50:42 +0000 Subject: [PATCH 08/16] use traits instead of base classes --- .../emulator-system-tests-spanner.yaml | 2 +- Spanner/tests/System/AdminTest.php | 5 +- Spanner/tests/System/BackupTest.php | 5 +- Spanner/tests/System/BatchTest.php | 4 +- Spanner/tests/System/BatchWriteTest.php | 5 +- Spanner/tests/System/DatabaseRoleTrait.php | 4 +- .../System/GeneratedAdminEmulatorTest.php | 5 +- Spanner/tests/System/LargeReadTest.php | 5 +- Spanner/tests/System/OperationsTest.php | 4 +- Spanner/tests/System/PartitionedDmlTest.php | 6 +- Spanner/tests/System/PgBatchTest.php | 4 +- Spanner/tests/System/PgBatchWriteTest.php | 5 +- Spanner/tests/System/PgOperationsTest.php | 4 +- Spanner/tests/System/PgPartitionedDmlTest.php | 6 +- Spanner/tests/System/PgQueryTest.php | 5 +- Spanner/tests/System/PgReadTest.php | 5 +- ...TestCase.php => PgSystemTestCaseTrait.php} | 4 +- Spanner/tests/System/PgTransactionTest.php | 4 +- Spanner/tests/System/PgWriteTest.php | 4 +- Spanner/tests/System/QueryTest.php | 5 +- Spanner/tests/System/ReadTest.php | 5 +- Spanner/tests/System/SnapshotTest.php | 5 +- Spanner/tests/System/SpannerTestCase.php | 81 ----------------- Spanner/tests/System/SystemTestCaseTrait.php | 90 +++++++++++++++---- Spanner/tests/System/TransactionTest.php | 6 +- Spanner/tests/System/UniverseDomainTest.php | 12 ++- Spanner/tests/System/WriteTest.php | 4 +- .../System/pcntl/AbortedErrorCausesRetry.php | 6 +- ...tTransactionsIncrementValueWithExecute.php | 6 +- ...rentTransactionsIncrementValueWithRead.php | 6 +- 30 files changed, 170 insertions(+), 142 deletions(-) rename Spanner/tests/System/{SpannerPgTestCase.php => PgSystemTestCaseTrait.php} (93%) delete mode 100644 Spanner/tests/System/SpannerTestCase.php diff --git a/.github/workflows/emulator-system-tests-spanner.yaml b/.github/workflows/emulator-system-tests-spanner.yaml index 6982b0589dff..92dc68ddf488 100644 --- a/.github/workflows/emulator-system-tests-spanner.yaml +++ b/.github/workflows/emulator-system-tests-spanner.yaml @@ -41,7 +41,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.1' + php-version: '8.4' ini-values: grpc.enable_fork_support=1 tools: pecl extensions: bcmath, grpc, pcntl diff --git a/Spanner/tests/System/AdminTest.php b/Spanner/tests/System/AdminTest.php index 10522442172a..383c60a0eeba 100644 --- a/Spanner/tests/System/AdminTest.php +++ b/Spanner/tests/System/AdminTest.php @@ -19,6 +19,7 @@ use Google\Cloud\Core\Exception\FailedPreconditionException; use Google\Cloud\Core\LongRunning\LongRunningOperation; +use Google\Cloud\Core\Testing\System\SystemTestCase; use Google\Cloud\Spanner\Admin\Database\V1\Client\DatabaseAdminClient; use Google\Cloud\Spanner\Admin\Database\V1\DatabaseDialect; use Google\Cloud\Spanner\Admin\Instance\V1\Client\InstanceAdminClient; @@ -31,8 +32,10 @@ * @group spanner * @group admin */ -class AdminTest extends SpannerTestCase +class AdminTest extends SystemTestCase { + use SystemTestCaseTrait; + /** * @beforeClass */ diff --git a/Spanner/tests/System/BackupTest.php b/Spanner/tests/System/BackupTest.php index e3522475058c..1e91d8076859 100644 --- a/Spanner/tests/System/BackupTest.php +++ b/Spanner/tests/System/BackupTest.php @@ -20,6 +20,7 @@ use Google\Cloud\Core\Exception\BadRequestException; use Google\Cloud\Core\Exception\ConflictException; use Google\Cloud\Core\LongRunning\LongRunningOperation; +use Google\Cloud\Core\Testing\System\SystemTestCase; use Google\Cloud\Spanner\Admin\Database\V1\Client\DatabaseAdminClient; use Google\Cloud\Spanner\Admin\Database\V1\CreateBackupEncryptionConfig; use Google\Cloud\Spanner\Admin\Database\V1\EncryptionInfo\Type; @@ -30,8 +31,10 @@ /** * @group spanner */ -class BackupTest extends SpannerTestCase +class BackupTest extends SystemTestCase { + use SystemTestCaseTrait; + const BACKUP_PREFIX = 'spanner_backup_'; protected static $backupId1; diff --git a/Spanner/tests/System/BatchTest.php b/Spanner/tests/System/BatchTest.php index 55b7bb951895..bd2d92b63fa1 100644 --- a/Spanner/tests/System/BatchTest.php +++ b/Spanner/tests/System/BatchTest.php @@ -18,6 +18,7 @@ namespace Google\Cloud\Spanner\Tests\System; use Google\Cloud\Core\Exception\ServiceException; +use Google\Cloud\Core\Testing\System\SystemTestCase; use Google\Cloud\Spanner\Admin\Database\V1\DatabaseDialect; use Google\Cloud\Spanner\Batch\BatchClient; use Google\Cloud\Spanner\Batch\BatchSnapshot; @@ -28,8 +29,9 @@ * @group spanner * @group spanner-batch */ -class BatchTest extends SpannerTestCase +class BatchTest extends SystemTestCase { + use SystemTestCaseTrait; use DatabaseRoleTrait; private static $tableName; diff --git a/Spanner/tests/System/BatchWriteTest.php b/Spanner/tests/System/BatchWriteTest.php index 2bc30b34bd60..a6e93f74f99f 100644 --- a/Spanner/tests/System/BatchWriteTest.php +++ b/Spanner/tests/System/BatchWriteTest.php @@ -18,12 +18,15 @@ namespace Google\Cloud\Spanner\Tests\System; use Google\Rpc\Code; +use Google\Cloud\Core\Testing\System\SystemTestCase; /** * @group spanner */ -class BatchWriteTest extends SpannerTestCase +class BatchWriteTest extends SystemTestCase { + use SystemTestCaseTrait; + const TABLE_NAME = 'BatchWrites'; /** * @beforeClass diff --git a/Spanner/tests/System/DatabaseRoleTrait.php b/Spanner/tests/System/DatabaseRoleTrait.php index b602d8bb666d..123749a87056 100644 --- a/Spanner/tests/System/DatabaseRoleTrait.php +++ b/Spanner/tests/System/DatabaseRoleTrait.php @@ -46,7 +46,7 @@ public function insertDbProvider() self::getDbWithRestrictiveRole(), [ 'id' => rand(1, 346464), - 'name' => uniqid(SpannerTestCase::TESTING_PREFIX), + 'name' => uniqid(self::TESTING_PREFIX), 'birthday' => new Date(new \DateTime('2000-01-01')) ], 'PERMISSION_DENIED' @@ -55,7 +55,7 @@ public function insertDbProvider() self::getDbWithRestrictiveRole(), [ 'id' => rand(1, 346464), - 'name' => uniqid(SpannerTestCase::TESTING_PREFIX) + 'name' => uniqid(self::TESTING_PREFIX) ], null ] diff --git a/Spanner/tests/System/GeneratedAdminEmulatorTest.php b/Spanner/tests/System/GeneratedAdminEmulatorTest.php index 6fc88f249b16..fe86fdbe6de2 100644 --- a/Spanner/tests/System/GeneratedAdminEmulatorTest.php +++ b/Spanner/tests/System/GeneratedAdminEmulatorTest.php @@ -17,6 +17,7 @@ namespace Google\Cloud\Spanner\Tests\System; +use Google\Cloud\Core\Testing\System\SystemTestCase; use Google\Cloud\Spanner\Admin\Database\V1\Client\DatabaseAdminClient; use Google\Cloud\Spanner\Admin\Database\V1\CreateDatabaseRequest; use Google\Cloud\Spanner\Admin\Database\V1\GetDatabaseRequest; @@ -28,8 +29,10 @@ /** * @group spanner */ -class GeneratedAdminEmulatorTest extends SpannerTestCase +class GeneratedAdminEmulatorTest extends SystemTestCase { + use SystemTestCaseTrait; + private static $projectId; /** diff --git a/Spanner/tests/System/LargeReadTest.php b/Spanner/tests/System/LargeReadTest.php index d54583db0822..cf9530f7280c 100644 --- a/Spanner/tests/System/LargeReadTest.php +++ b/Spanner/tests/System/LargeReadTest.php @@ -17,6 +17,7 @@ namespace Google\Cloud\Spanner\Tests\System; +use Google\Cloud\Core\Testing\System\SystemTestCase; use Google\Cloud\Spanner\Bytes; use Google\Cloud\Spanner\KeySet; @@ -24,8 +25,10 @@ * @group spanner * @group spanner-large-read */ -class LargeReadTest extends SpannerTestCase +class LargeReadTest extends SystemTestCase { + use SystemTestCaseTrait; + private static $tableName; private static $row = []; diff --git a/Spanner/tests/System/OperationsTest.php b/Spanner/tests/System/OperationsTest.php index 82a6a645210e..ca21dc7e375c 100644 --- a/Spanner/tests/System/OperationsTest.php +++ b/Spanner/tests/System/OperationsTest.php @@ -17,6 +17,7 @@ namespace Google\Cloud\Spanner\Tests\System; +use Google\Cloud\Core\Testing\System\SystemTestCase; use Google\Cloud\Core\Exception\ServiceException; use Google\Cloud\Spanner\Date; use Google\Cloud\Spanner\Timestamp; @@ -24,9 +25,10 @@ /** * @group spanner */ -class OperationsTest extends SpannerTestCase +class OperationsTest extends SystemTestCase { use DatabaseRoleTrait; + use SystemTestCaseTrait; private static $id1; private static $id2; diff --git a/Spanner/tests/System/PartitionedDmlTest.php b/Spanner/tests/System/PartitionedDmlTest.php index 7f512c884b1f..ecf4b3fb6f1a 100644 --- a/Spanner/tests/System/PartitionedDmlTest.php +++ b/Spanner/tests/System/PartitionedDmlTest.php @@ -17,12 +17,16 @@ namespace Google\Cloud\Spanner\Tests\System; +use Google\Cloud\Core\Testing\System\SystemTestCase; + /** * @group spanner * @group spanner-pdml */ -class PartitionedDmlTest extends SpannerTestCase +class PartitionedDmlTest extends SystemTestCase { + use SystemTestCaseTrait; + const PDML_TABLE = 'partitionedDml'; /** diff --git a/Spanner/tests/System/PgBatchTest.php b/Spanner/tests/System/PgBatchTest.php index c1c09407c72b..07552e395f59 100644 --- a/Spanner/tests/System/PgBatchTest.php +++ b/Spanner/tests/System/PgBatchTest.php @@ -18,6 +18,7 @@ namespace Google\Cloud\Spanner\Tests\System; use Google\Cloud\Core\Exception\ServiceException; +use Google\Cloud\Core\Testing\System\SystemTestCase; use Google\Cloud\Spanner\Admin\Database\V1\DatabaseDialect; use Google\Cloud\Spanner\Batch\BatchClient; use Google\Cloud\Spanner\Batch\BatchSnapshot; @@ -27,8 +28,9 @@ * @group spanner-batch * @group spanner-postgres */ -class PgBatchTest extends SpannerPgTestCase +class PgBatchTest extends SystemTestCase { + use PgSystemTestCaseTrait; use DatabaseRoleTrait; private static $tableName; diff --git a/Spanner/tests/System/PgBatchWriteTest.php b/Spanner/tests/System/PgBatchWriteTest.php index 69bbe39a7fcb..ffd775daaeeb 100644 --- a/Spanner/tests/System/PgBatchWriteTest.php +++ b/Spanner/tests/System/PgBatchWriteTest.php @@ -17,14 +17,17 @@ namespace Google\Cloud\Spanner\Tests\System; +use Google\Cloud\Core\Testing\System\SystemTestCase; use Google\Rpc\Code; /** * @group spanner * @group spanner-postgres */ -class PgBatchWriteTest extends SpannerPgTestCase +class PgBatchWriteTest extends SystemTestCase { + use PgSystemTestCaseTrait; + const TABLE_NAME = 'BatchWrites'; /** * @beforeClass diff --git a/Spanner/tests/System/PgOperationsTest.php b/Spanner/tests/System/PgOperationsTest.php index 016a1407eb97..b9fb6c88b120 100644 --- a/Spanner/tests/System/PgOperationsTest.php +++ b/Spanner/tests/System/PgOperationsTest.php @@ -18,6 +18,7 @@ namespace Google\Cloud\Spanner\Tests\System; use Google\Cloud\Core\Exception\ServiceException; +use Google\Cloud\Core\Testing\System\SystemTestCase; use Google\Cloud\Spanner\Date; /** @@ -25,9 +26,10 @@ * @group spanner-operations * @group spanner-postgres */ -class PgOperationsTest extends SpannerPgTestCase +class PgOperationsTest extends SystemTestCase { use DatabaseRoleTrait; + use PgSystemTestCaseTrait; private static $row = []; diff --git a/Spanner/tests/System/PgPartitionedDmlTest.php b/Spanner/tests/System/PgPartitionedDmlTest.php index 840cbcdad7e6..48bce3dbf0e2 100644 --- a/Spanner/tests/System/PgPartitionedDmlTest.php +++ b/Spanner/tests/System/PgPartitionedDmlTest.php @@ -17,13 +17,17 @@ namespace Google\Cloud\Spanner\Tests\System; +use Google\Cloud\Core\Testing\System\SystemTestCase; + /** * @group spanner * @group spanner-pdml * @group spanner-postgres */ -class PgPartitionedDmlTest extends SpannerPgTestCase +class PgPartitionedDmlTest extends SystemTestCase { + use PgSystemTestCaseTrait; + const PDML_TABLE = 'partitionedDml'; /** diff --git a/Spanner/tests/System/PgQueryTest.php b/Spanner/tests/System/PgQueryTest.php index 2bcf5419c9f6..9129fec7fb51 100644 --- a/Spanner/tests/System/PgQueryTest.php +++ b/Spanner/tests/System/PgQueryTest.php @@ -19,6 +19,7 @@ use Google\Cloud\Core\Exception\BadRequestException; use Google\Cloud\Core\Int64; +use Google\Cloud\Core\Testing\System\SystemTestCase; use Google\Cloud\Spanner\ArrayType; use Google\Cloud\Spanner\Bytes; use Google\Cloud\Spanner\Database; @@ -35,8 +36,10 @@ * @group spanner-query * @group spanner-postgres */ -class PgQueryTest extends SpannerPgTestCase +class PgQueryTest extends SystemTestCase { + use PgSystemTestCaseTrait; + const TABLE_NAME = 'test'; public static $timestampVal; diff --git a/Spanner/tests/System/PgReadTest.php b/Spanner/tests/System/PgReadTest.php index b4a9b6600ae8..317c9b36895f 100644 --- a/Spanner/tests/System/PgReadTest.php +++ b/Spanner/tests/System/PgReadTest.php @@ -19,6 +19,7 @@ use Google\Cloud\Core\Exception\DeadlineExceededException; use Google\Cloud\Core\Exception\NotFoundException; +use Google\Cloud\Core\Testing\System\SystemTestCase; use Google\Cloud\Spanner\KeyRange; use Google\Cloud\Spanner\KeySet; @@ -27,8 +28,10 @@ * @group spanner-read * @group spanner-postgres */ -class PgReadTest extends SpannerPgTestCase +class PgReadTest extends SystemTestCase { + use PgSystemTestCaseTrait; + private static $readTableName; private static $rangeTableName; private static $indexes = []; diff --git a/Spanner/tests/System/SpannerPgTestCase.php b/Spanner/tests/System/PgSystemTestCaseTrait.php similarity index 93% rename from Spanner/tests/System/SpannerPgTestCase.php rename to Spanner/tests/System/PgSystemTestCaseTrait.php index 2c054c194250..d07653be184b 100644 --- a/Spanner/tests/System/SpannerPgTestCase.php +++ b/Spanner/tests/System/PgSystemTestCaseTrait.php @@ -17,14 +17,13 @@ namespace Google\Cloud\Spanner\Tests\System; -use Google\Cloud\Core\Testing\System\SystemTestCase; use Google\Cloud\Spanner\Admin\Database\V1\DatabaseDialect; /** * @group spanner * @group spanner-postgres */ -abstract class SpannerPgTestCase extends SystemTestCase +trait PgSystemTestCaseTrait { use SystemTestCaseTrait; @@ -52,7 +51,6 @@ protected static function setUpTestDatabase(): void }); self::$database = $db; - self::$database2 = self::getDatabaseInstance(self::$dbName); $db->updateDdlBatch( [ diff --git a/Spanner/tests/System/PgTransactionTest.php b/Spanner/tests/System/PgTransactionTest.php index 187211b69e80..e0718a5f07d7 100644 --- a/Spanner/tests/System/PgTransactionTest.php +++ b/Spanner/tests/System/PgTransactionTest.php @@ -18,6 +18,7 @@ namespace Google\Cloud\Spanner\Tests\System; use Google\Cloud\Core\Exception\ServiceException; +use Google\Cloud\Core\Testing\System\SystemTestCase; use Google\Cloud\Spanner\Date; use Google\Cloud\Spanner\KeySet; use Google\Cloud\Spanner\Timestamp; @@ -28,9 +29,10 @@ * @group spanner-transaction * @group spanner-postgres */ -class PgTransactionTest extends SpannerPgTestCase +class PgTransactionTest extends SystemTestCase { use DatabaseRoleTrait; + use PgSystemTestCaseTrait; private static $row = []; diff --git a/Spanner/tests/System/PgWriteTest.php b/Spanner/tests/System/PgWriteTest.php index 1217716956e7..5cb8be03f341 100644 --- a/Spanner/tests/System/PgWriteTest.php +++ b/Spanner/tests/System/PgWriteTest.php @@ -20,6 +20,7 @@ use Google\Cloud\Core\Exception\BadRequestException; use Google\Cloud\Core\Exception\FailedPreconditionException; use Google\Cloud\Core\Exception\NotFoundException; +use Google\Cloud\Core\Testing\System\SystemTestCase; use Google\Cloud\Core\TimeTrait; use Google\Cloud\Spanner\Bytes; use Google\Cloud\Spanner\CommitTimestamp; @@ -35,8 +36,9 @@ * @group spanner-write * @group spanner-postgres */ -class PgWriteTest extends SpannerPgTestCase +class PgWriteTest extends SystemTestCase { + use PgSystemTestCaseTrait; use TimeTrait; const TABLE_NAME = 'Writes'; diff --git a/Spanner/tests/System/QueryTest.php b/Spanner/tests/System/QueryTest.php index 8016b1138a60..4aa5a2b45de8 100644 --- a/Spanner/tests/System/QueryTest.php +++ b/Spanner/tests/System/QueryTest.php @@ -19,6 +19,7 @@ use Google\Cloud\Core\Exception\BadRequestException; use Google\Cloud\Core\Int64; +use Google\Cloud\Core\Testing\System\SystemTestCase; use Google\Cloud\Spanner\ArrayType; use Google\Cloud\Spanner\Bytes; use Google\Cloud\Spanner\Database; @@ -35,8 +36,10 @@ * @group spanner * @group spanner-query */ -class QueryTest extends SpannerTestCase +class QueryTest extends SystemTestCase { + use SystemTestCaseTrait; + /** * @beforeClass */ diff --git a/Spanner/tests/System/ReadTest.php b/Spanner/tests/System/ReadTest.php index c96528c475c7..7c8c314e40e5 100644 --- a/Spanner/tests/System/ReadTest.php +++ b/Spanner/tests/System/ReadTest.php @@ -21,6 +21,7 @@ use Google\Cloud\Core\Exception\ConflictException; use Google\Cloud\Core\Exception\DeadlineExceededException; use Google\Cloud\Core\Exception\NotFoundException; +use Google\Cloud\Core\Testing\System\SystemTestCase; use Google\Cloud\Spanner\Database; use Google\Cloud\Spanner\KeyRange; use Google\Cloud\Spanner\KeySet; @@ -31,8 +32,10 @@ * @group spanner * @group spanner-read */ -class ReadTest extends SpannerTestCase +class ReadTest extends SystemTestCase { + use SystemTestCaseTrait; + private static $readTableName; private static $rangeTableName; private static $indexes = []; diff --git a/Spanner/tests/System/SnapshotTest.php b/Spanner/tests/System/SnapshotTest.php index 6cb2fbc966ff..780eaca1bf5d 100644 --- a/Spanner/tests/System/SnapshotTest.php +++ b/Spanner/tests/System/SnapshotTest.php @@ -18,6 +18,7 @@ namespace Google\Cloud\Spanner\Tests\System; use Google\Cloud\Core\Exception\BadRequestException; +use Google\Cloud\Core\Testing\System\SystemTestCase; use Google\Cloud\Spanner\KeySet; use Google\Cloud\Spanner\Timestamp; use Google\Cloud\Spanner\V1\ReadRequest\LockHint; @@ -28,8 +29,10 @@ * @group spanner * @group spanner-snapshot */ -class SnapshotTest extends SpannerTestCase +class SnapshotTest extends SystemTestCase { + use SystemTestCaseTrait; + const TABLE_NAME = 'Snapshots'; private static $tableName; diff --git a/Spanner/tests/System/SpannerTestCase.php b/Spanner/tests/System/SpannerTestCase.php deleted file mode 100644 index 73b3be6e0822..000000000000 --- a/Spanner/tests/System/SpannerTestCase.php +++ /dev/null @@ -1,81 +0,0 @@ -instance(self::INSTANCE_NAME); - - if (!self::$dbName = getenv('GOOGLE_CLOUD_SPANNER_TEST_DATABASE')) { - self::$dbName = uniqid(self::TESTING_PREFIX); - self::$deletionQueue->add(function () { - self::getDatabaseInstance(self::$dbName)->drop(); - }); - } - self::$database = self::getDatabaseInstance(self::$dbName); - - if (!self::$database->exists()) { - $op = self::$instance->createDatabase(self::$dbName); - $op->pollUntilComplete(); - $op = self::$database->updateDdlBatch( - [ - 'CREATE TABLE ' . self::TEST_TABLE_NAME . ' ( - id INT64 NOT NULL, - name STRING(MAX) NOT NULL, - birthday DATE - ) PRIMARY KEY (id)', - 'CREATE UNIQUE INDEX ' . self::TEST_INDEX_NAME . ' - ON ' . self::TEST_TABLE_NAME . ' (name)', - ] - ); - $op->pollUntilComplete(); - - if (self::$database->info()['databaseDialect'] == DatabaseDialect::GOOGLE_STANDARD_SQL - && !self::isEmulatorUsed() - ) { - self::$database->updateDdlBatch( - [ - 'CREATE ROLE ' . self::DATABASE_ROLE, - 'CREATE ROLE ' . self::RESTRICTIVE_DATABASE_ROLE, - 'GRANT SELECT ON TABLE ' . self::TEST_TABLE_NAME . - ' TO ROLE ' . self::DATABASE_ROLE, - 'GRANT SELECT(id, name), INSERT(id, name), UPDATE(id, name) ON TABLE ' - . self::TEST_TABLE_NAME . ' TO ROLE ' . self::RESTRICTIVE_DATABASE_ROLE, - ] - )->pollUntilComplete(); - } - } - - self::$database2 = self::getDatabaseInstance(self::$dbName); - self::$hasSetUp = true; - } -} diff --git a/Spanner/tests/System/SystemTestCaseTrait.php b/Spanner/tests/System/SystemTestCaseTrait.php index eb83824d2b0a..966411eb4320 100644 --- a/Spanner/tests/System/SystemTestCaseTrait.php +++ b/Spanner/tests/System/SystemTestCaseTrait.php @@ -17,26 +17,30 @@ namespace Google\Cloud\Spanner\Tests\System; -use Google\Cloud\Spanner; +use Google\Cloud\Core\Testing\System\SystemTestCase; +use Google\Cloud\Spanner\Admin\Database\V1\Client\DatabaseAdminClient; +use Google\Cloud\Spanner\Admin\Instance\V1\Client\InstanceAdminClient; use Google\Cloud\Spanner\SpannerClient; +use Google\Cloud\Spanner\V1\Client\SpannerClient as SpannerGapicClient; +use Google\Cloud\Spanner\Admin\Database\V1\DatabaseDialect; trait SystemTestCaseTrait { - const TESTING_PREFIX = 'gcloud_testing_'; - const INSTANCE_NAME = 'google-cloud-php-system-tests'; + protected const TESTING_PREFIX = 'gcloud_testing_'; + protected const INSTANCE_NAME = 'google-cloud-php-system-tests'; - const TEST_TABLE_NAME = 'Users'; - const TEST_INDEX_NAME = 'uniqueIndex'; + protected const TEST_TABLE_NAME = 'Users'; + protected const TEST_INDEX_NAME = 'uniqueIndex'; - const DATABASE_ROLE = 'Reader'; - const RESTRICTIVE_DATABASE_ROLE = 'RestrictiveReader'; + private const DATABASE_ROLE = 'Reader'; + private const RESTRICTIVE_DATABASE_ROLE = 'RestrictiveReader'; protected static $client; protected static $instance; protected static $database; - protected static $database2; protected static $dbName; - protected static $hasSetUp = false; + + private static $hasSetUp = false; protected static function getClient() { @@ -57,11 +61,11 @@ protected static function getClient() 'serviceAddress' => $serviceAddress ]; - $clientConfig['gapicSpannerClient'] = new Spanner\V1\Client\SpannerClient($gapicConfig); + $clientConfig['gapicSpannerClient'] = new SpannerGapicClient($gapicConfig); $clientConfig['gapicSpannerDatabaseAdminClient'] = - new Spanner\Admin\Database\V1\Client\DatabaseAdminClient($gapicConfig); + new DatabaseAdminClient($gapicConfig); $clientConfig['gapicSpannerInstanceAdminClient'] = - new Spanner\Admin\Instance\V1\Client\InstanceAdminClient($gapicConfig); + new InstanceAdminClient($gapicConfig); echo 'Using Service Address: ' . $serviceAddress . PHP_EOL; } @@ -69,15 +73,60 @@ protected static function getClient() return self::$client = new SpannerClient($clientConfig); } - public static function getDatabaseInstance($dbName, $options = []) + protected static function setUpTestDatabase(): void { - return self::getClient()->connect(self::INSTANCE_NAME, $dbName, $options); + if (self::$hasSetUp) { + return; + } + + self::$instance = self::getClient()->instance(self::INSTANCE_NAME); + + if (!self::$dbName = getenv('GOOGLE_CLOUD_SPANNER_TEST_DATABASE')) { + self::$dbName = uniqid(self::TESTING_PREFIX); + self::$deletionQueue->add(function () { + self::getDatabaseInstance(self::$dbName)->drop(); + }); + } + self::$database = self::getDatabaseInstance(self::$dbName); + + if (!self::$database->exists()) { + $op = self::$instance->createDatabase(self::$dbName); + $op->pollUntilComplete(); + $op = self::$database->updateDdlBatch( + [ + 'CREATE TABLE ' . self::TEST_TABLE_NAME . ' ( + id INT64 NOT NULL, + name STRING(MAX) NOT NULL, + birthday DATE + ) PRIMARY KEY (id)', + 'CREATE UNIQUE INDEX ' . self::TEST_INDEX_NAME . ' + ON ' . self::TEST_TABLE_NAME . ' (name)', + ] + ); + $op->pollUntilComplete(); + + if (self::$database->info()['databaseDialect'] == DatabaseDialect::GOOGLE_STANDARD_SQL + && !self::isEmulatorUsed() + ) { + self::$database->updateDdlBatch( + [ + 'CREATE ROLE ' . self::DATABASE_ROLE, + 'CREATE ROLE ' . self::RESTRICTIVE_DATABASE_ROLE, + 'GRANT SELECT ON TABLE ' . self::TEST_TABLE_NAME . + ' TO ROLE ' . self::DATABASE_ROLE, + 'GRANT SELECT(id, name), INSERT(id, name), UPDATE(id, name) ON TABLE ' + . self::TEST_TABLE_NAME . ' TO ROLE ' . self::RESTRICTIVE_DATABASE_ROLE, + ] + )->pollUntilComplete(); + } + } + + self::$hasSetUp = true; } - public static function getDatabaseFromInstance($instance, $dbName, $options = []) + public static function getDatabaseInstance($dbName, $options = []) { - $instance = self::getClient()->instance($instance); - return $instance->database($dbName, $options); + return self::getClient()->connect(self::INSTANCE_NAME, $dbName, $options); } public static function skipEmulatorTests() @@ -116,4 +165,11 @@ public static function getDbWithRestrictiveRole() ['databaseRole' => self::RESTRICTIVE_DATABASE_ROLE] ); } + + private static function getDatabaseFromInstance($instance, $dbName, $options = []) + { + $instance = self::getClient()->instance($instance); + return $instance->database($dbName, $options); + } + } diff --git a/Spanner/tests/System/TransactionTest.php b/Spanner/tests/System/TransactionTest.php index 121e2f1b1398..c74ac820b72c 100644 --- a/Spanner/tests/System/TransactionTest.php +++ b/Spanner/tests/System/TransactionTest.php @@ -18,6 +18,7 @@ namespace Google\Cloud\Spanner\Tests\System; use Google\Cloud\Core\Exception\ServiceException; +use Google\Cloud\Core\Testing\System\SystemTestCase; use Google\Cloud\Spanner\Date; use Google\Cloud\Spanner\KeySet; use Google\Cloud\Spanner\Timestamp; @@ -33,9 +34,11 @@ * @group spanner * @group spanner-transaction */ -class TransactionTest extends SpannerTestCase +class TransactionTest extends SystemTestCase { use DatabaseRoleTrait; + use SystemTestCaseTrait; + const TABLE_NAME = 'Transactions'; @@ -176,7 +179,6 @@ public function testAbortedErrorCausesRetry() } $db = self::$database; - $db2 = self::$database2; $id = $this->randId(); $db->insert(self::$tableName, [ diff --git a/Spanner/tests/System/UniverseDomainTest.php b/Spanner/tests/System/UniverseDomainTest.php index c010f4cef4fb..23f9aaa59f8d 100644 --- a/Spanner/tests/System/UniverseDomainTest.php +++ b/Spanner/tests/System/UniverseDomainTest.php @@ -24,11 +24,9 @@ class UniverseDomainTest extends SystemTestCase { - private static $client; - private static $instance; + use SystemTestCaseTrait; + private static $instanceId; - private static $database; - private static $dbName; private static $tableName; /** @@ -52,9 +50,9 @@ public static function setUpTestFixtures(): void ]); // Create a unique instance ID for this test - self::$instanceId = uniqid(SpannerTestCase::INSTANCE_NAME); - self::$dbName = uniqid(SpannerTestCase::TESTING_PREFIX); - self::$tableName = uniqid(SpannerTestCase::TESTING_PREFIX); + self::$instanceId = uniqid(self::INSTANCE_NAME); + self::$dbName = uniqid(self::TESTING_PREFIX); + self::$tableName = uniqid(self::TESTING_PREFIX); } /** diff --git a/Spanner/tests/System/WriteTest.php b/Spanner/tests/System/WriteTest.php index 2d63db8a23e6..ef0d17979fa9 100644 --- a/Spanner/tests/System/WriteTest.php +++ b/Spanner/tests/System/WriteTest.php @@ -20,6 +20,7 @@ use Google\Cloud\Core\Exception\BadRequestException; use Google\Cloud\Core\Exception\FailedPreconditionException; use Google\Cloud\Core\Exception\NotFoundException; +use Google\Cloud\Core\Testing\System\SystemTestCase; use Google\Cloud\Core\TimeTrait; use Google\Cloud\Spanner\Bytes; use Google\Cloud\Spanner\CommitTimestamp; @@ -36,9 +37,10 @@ * @group spanner * @group spanner-write */ -class WriteTest extends SpannerTestCase +class WriteTest extends SystemTestCase { use TimeTrait; + use SystemTestCaseTrait; const TABLE_NAME = 'Writes'; const COMMIT_TIMESTAMP_TABLE_NAME = 'CommitTimestamps'; diff --git a/Spanner/tests/System/pcntl/AbortedErrorCausesRetry.php b/Spanner/tests/System/pcntl/AbortedErrorCausesRetry.php index 9dfbb3639f86..579e068d9bbc 100644 --- a/Spanner/tests/System/pcntl/AbortedErrorCausesRetry.php +++ b/Spanner/tests/System/pcntl/AbortedErrorCausesRetry.php @@ -4,7 +4,7 @@ include __DIR__ . '/forked-process-test.php'; use Google\Cloud\Core\Exception\AbortedException; -use Google\Cloud\Spanner\Tests\System\SpannerTestCase; +use Google\Cloud\Spanner\Tests\System\SystemTestCaseTrait; list($dbName, $tableName, $id) = getInputArgs(); $delay = 5000; @@ -12,7 +12,7 @@ if ($childPID1 = pcntl_fork()) { usleep($delay); $iteration = 0; - $db1 = SpannerTestCase::getDatabaseInstance($dbName); + $db1 = SystemTestCaseTrait::getDatabaseInstance($dbName); $db1->runTransaction(function ($t) use ($id, $tableName, $delay, &$iteration) { $iteration++; usleep(2 * $delay); @@ -39,7 +39,7 @@ echo $iteration; pcntl_waitpid($childPID1, $status1); } else { - $db2 = SpannerTestCase::getDatabaseInstance($dbName); + $db2 = SystemTestCaseTrait::getDatabaseInstance($dbName); $db2->runTransaction(function ($t) use ($id, $tableName) { $row = $t->execute('SELECT id, number FROM ' . $tableName . ' WHERE ID = @id', [ 'parameters' => ['id' => (int) $id] diff --git a/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithExecute.php b/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithExecute.php index f943e0bb1a57..b1d0dcbd72d0 100644 --- a/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithExecute.php +++ b/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithExecute.php @@ -3,7 +3,7 @@ include __DIR__ . '/../../../vendor/autoload.php'; include __DIR__ . '/forked-process-test.php'; -use Google\Cloud\Spanner\Tests\System\SpannerTestCase; +use Google\Cloud\Spanner\Tests\System\SystemTestCaseTrait; list($dbName, $tableName, $id) = getInputArgs(); @@ -12,8 +12,8 @@ $callable = function ($dbName, $tableName, $id) use ($tmpFile) { $iterations = 0; - $db = SpannerTestCase::getDatabaseInstance($dbName); - if (SpannerTestCase::isEmulatorUsed()) { + $db = SystemTestCaseTrait::getDatabaseInstance($dbName); + if (SystemTestCaseTrait::isEmulatorUsed()) { // the emulator requires us to manually request a new session // presumably because multiplexed sessions aren't properly supported $db->session()->refresh(); diff --git a/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithRead.php b/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithRead.php index d28e5ba20db2..b2283e8c8c36 100644 --- a/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithRead.php +++ b/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithRead.php @@ -4,7 +4,7 @@ include __DIR__ . '/forked-process-test.php'; use Google\Cloud\Spanner\KeySet; -use Google\Cloud\Spanner\Tests\System\SpannerTestCase; +use Google\Cloud\Spanner\Tests\System\SystemTestCaseTrait; list($dbName, $tableName, $id) = getInputArgs(); @@ -16,8 +16,8 @@ $callable = function ($dbName, KeySet $keyset, array $columns, $tableName) use ($tmpFile) { $iterations = 0; - $db = SpannerTestCase::getDatabaseInstance($dbName); - if (SpannerTestCase::isEmulatorUsed()) { + $db = SystemTestCaseTrait::getDatabaseInstance($dbName); + if (SystemTestCaseTrait::isEmulatorUsed()) { // the emulator requires us to manually request a new session // presumably because multiplexed sessions aren't properly supported $db->session()->refresh(); From a1b1b4aca2952c14df7fa33c2d0c23a38c8b4aeb Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Tue, 21 Oct 2025 19:59:18 +0000 Subject: [PATCH 09/16] fix pcntl tests and cs --- Core/src/Testing/System/SystemTestCase.php | 8 -------- Spanner/tests/System/PgSystemTestCaseTrait.php | 6 +----- Spanner/tests/System/SystemTestCaseTrait.php | 9 ++++++++- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/Core/src/Testing/System/SystemTestCase.php b/Core/src/Testing/System/SystemTestCase.php index 9f21d8472bb8..1b1e257c5aec 100644 --- a/Core/src/Testing/System/SystemTestCase.php +++ b/Core/src/Testing/System/SystemTestCase.php @@ -28,7 +28,6 @@ use Google\Cloud\Storage\StorageClient; use Google\Cloud\Core\Testing\System\DeletionQueue; use PHPUnit\Framework\TestCase; -use Symfony\Component\Cache\Adapter\FilesystemAdapter; /** * SystemTestCase can be extended to implement system tests @@ -287,11 +286,4 @@ public static function skipIfEmulatorUsed($reason = null) self::markTestSkipped($reason ?: 'This test is not supported by the emulator.'); } } - - protected static function getCacheItemPool() - { - return new FilesystemAdapter( - directory: __DIR__ . '/../../../../.cache' - ); - } } diff --git a/Spanner/tests/System/PgSystemTestCaseTrait.php b/Spanner/tests/System/PgSystemTestCaseTrait.php index d07653be184b..4acf8ec3d0c9 100644 --- a/Spanner/tests/System/PgSystemTestCaseTrait.php +++ b/Spanner/tests/System/PgSystemTestCaseTrait.php @@ -1,6 +1,6 @@ instance(self::INSTANCE_NAME); @@ -172,4 +173,10 @@ private static function getDatabaseFromInstance($instance, $dbName, $options = [ return $instance->database($dbName, $options); } + protected static function getCacheItemPool() + { + return new FilesystemAdapter( + directory: __DIR__ . '/../../../.cache' + ); + } } From 3e52ba3e827afe20586b260edf2fb7b2ecc2e8f3 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Tue, 21 Oct 2025 20:07:48 +0000 Subject: [PATCH 10/16] attempt to fix failing transaction tests --- Spanner/tests/System/SystemTestCaseTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Spanner/tests/System/SystemTestCaseTrait.php b/Spanner/tests/System/SystemTestCaseTrait.php index cf7a9094d1a7..ca77917f002d 100644 --- a/Spanner/tests/System/SystemTestCaseTrait.php +++ b/Spanner/tests/System/SystemTestCaseTrait.php @@ -127,7 +127,7 @@ protected static function setUpTestDatabase(): void public static function getDatabaseInstance($dbName, $options = []) { - return self::getClient()->connect(self::INSTANCE_NAME, $dbName, $options); + return self::getClient()->connect(SystemTestCaseTrait::INSTANCE_NAME, $dbName, $options); } public static function skipEmulatorTests() From 8fe50f7e1d6aba6b825d9fa4a19ca604e7eee430 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Tue, 21 Oct 2025 20:12:33 +0000 Subject: [PATCH 11/16] make constant public --- Spanner/tests/System/SystemTestCaseTrait.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Spanner/tests/System/SystemTestCaseTrait.php b/Spanner/tests/System/SystemTestCaseTrait.php index ca77917f002d..2299c0a29e9e 100644 --- a/Spanner/tests/System/SystemTestCaseTrait.php +++ b/Spanner/tests/System/SystemTestCaseTrait.php @@ -27,9 +27,9 @@ trait SystemTestCaseTrait { - protected const TESTING_PREFIX = 'gcloud_testing_'; - protected const INSTANCE_NAME = 'google-cloud-php-system-tests'; + public const INSTANCE_NAME = 'google-cloud-php-system-tests'; + protected const TESTING_PREFIX = 'gcloud_testing_'; protected const TEST_TABLE_NAME = 'Users'; protected const TEST_INDEX_NAME = 'uniqueIndex'; From df3ffb672b987988dd0cda865e6182b9d4585084 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Tue, 21 Oct 2025 20:43:33 +0000 Subject: [PATCH 12/16] refactor concurrent tests --- Spanner/composer.json | 12 ++ Spanner/tests/System/SystemTestCaseTrait.php | 35 +++--- .../System/pcntl/AbortedErrorCausesRetry.php | 106 ++++++++++-------- ...tTransactionsIncrementValueWithExecute.php | 72 +++++++----- ...rentTransactionsIncrementValueWithRead.php | 60 ++++++---- 5 files changed, 169 insertions(+), 116 deletions(-) diff --git a/Spanner/composer.json b/Spanner/composer.json index 92284fdad439..d42e8f51c68f 100644 --- a/Spanner/composer.json +++ b/Spanner/composer.json @@ -63,5 +63,17 @@ "@test-snippets", "@test-system" ] + }, + "repositories": { + "local": { + "type": "path", + "url": "../Core", + "options": { + "versions": { + "google/cloud-core": "1.100" + } + }, + "canonical": false + } } } diff --git a/Spanner/tests/System/SystemTestCaseTrait.php b/Spanner/tests/System/SystemTestCaseTrait.php index 2299c0a29e9e..4dbb4b1f36cf 100644 --- a/Spanner/tests/System/SystemTestCaseTrait.php +++ b/Spanner/tests/System/SystemTestCaseTrait.php @@ -27,23 +27,20 @@ trait SystemTestCaseTrait { - public const INSTANCE_NAME = 'google-cloud-php-system-tests'; - - protected const TESTING_PREFIX = 'gcloud_testing_'; - protected const TEST_TABLE_NAME = 'Users'; - protected const TEST_INDEX_NAME = 'uniqueIndex'; - + private const TESTING_PREFIX = 'gcloud_testing_'; + private const INSTANCE_NAME = 'google-cloud-php-system-tests'; + private const TEST_TABLE_NAME = 'Users'; + private const TEST_INDEX_NAME = 'uniqueIndex'; private const DATABASE_ROLE = 'Reader'; private const RESTRICTIVE_DATABASE_ROLE = 'RestrictiveReader'; - protected static $client; - protected static $instance; - protected static $database; - protected static $dbName; - + private static $client; + private static $instance; + private static $database; + private static $dbName; private static $hasSetUp = false; - protected static function getClient() + private static function getClient() { if (self::$client) { return self::$client; @@ -74,7 +71,7 @@ protected static function getClient() return self::$client = new SpannerClient($clientConfig); } - protected static function setUpTestDatabase(): void + private static function setUpTestDatabase(): void { if (self::$hasSetUp) { return; @@ -125,12 +122,12 @@ protected static function setUpTestDatabase(): void self::$hasSetUp = true; } - public static function getDatabaseInstance($dbName, $options = []) + private static function getDatabaseInstance($dbName, $options = []) { - return self::getClient()->connect(SystemTestCaseTrait::INSTANCE_NAME, $dbName, $options); + return self::getClient()->connect(self::INSTANCE_NAME, $dbName, $options); } - public static function skipEmulatorTests() + private static function skipEmulatorTests() { if (self::isEmulatorUsed()) { self::markTestSkipped('This test is not supported by the emulator.'); @@ -149,7 +146,7 @@ public static function isEmulatorUsed(): bool return (bool) getenv('SPANNER_EMULATOR_HOST'); } - public static function getDbWithReaderRole() + private static function getDbWithReaderRole() { return self::getDatabaseFromInstance( self::INSTANCE_NAME, @@ -158,7 +155,7 @@ public static function getDbWithReaderRole() ); } - public static function getDbWithRestrictiveRole() + private static function getDbWithRestrictiveRole() { return self::getDatabaseFromInstance( self::INSTANCE_NAME, @@ -173,7 +170,7 @@ private static function getDatabaseFromInstance($instance, $dbName, $options = [ return $instance->database($dbName, $options); } - protected static function getCacheItemPool() + private static function getCacheItemPool() { return new FilesystemAdapter( directory: __DIR__ . '/../../../.cache' diff --git a/Spanner/tests/System/pcntl/AbortedErrorCausesRetry.php b/Spanner/tests/System/pcntl/AbortedErrorCausesRetry.php index 579e068d9bbc..0fc1d6d8cf80 100644 --- a/Spanner/tests/System/pcntl/AbortedErrorCausesRetry.php +++ b/Spanner/tests/System/pcntl/AbortedErrorCausesRetry.php @@ -9,48 +9,64 @@ list($dbName, $tableName, $id) = getInputArgs(); $delay = 5000; -if ($childPID1 = pcntl_fork()) { - usleep($delay); - $iteration = 0; - $db1 = SystemTestCaseTrait::getDatabaseInstance($dbName); - $db1->runTransaction(function ($t) use ($id, $tableName, $delay, &$iteration) { - $iteration++; - usleep(2 * $delay); - $row = $t->execute('SELECT id, number FROM ' . $tableName . ' WHERE ID = @id', [ - 'parameters' => ['id' => (int) $id] - ])->rows()->current(); - - if ($iteration === 1) { - throw new AbortedException('foo', 409, null, [ - [ - 'retryDelay' => [ - 'seconds' => 1, - 'nanos' => 0 - ] - ] - ]); - } - - $row['number'] += 1; - $t->update($tableName, $row); - $t->commit(); - }); - - echo $iteration; - pcntl_waitpid($childPID1, $status1); -} else { - $db2 = SystemTestCaseTrait::getDatabaseInstance($dbName); - $db2->runTransaction(function ($t) use ($id, $tableName) { - $row = $t->execute('SELECT id, number FROM ' . $tableName . ' WHERE ID = @id', [ - 'parameters' => ['id' => (int) $id] - ])->rows()->current(); - - $row['number'] += 1; - $t->update($tableName, $row); - $t->commit(); - }); - - exit(0); -} - -exit(0); +$abortedErrorRetry = new class($dbName, $tableName, $id, $delay) { + use SystemTestCaseTrait; + + public function __construct( + string $dbName, + private string $tableName, + private int $id, + private int $delay, + ) { + self::$dbName = $dbName; + } + + public function run(): int + { + if ($childPID1 = pcntl_fork()) { + usleep($this->delay); + $iteration = 0; + $db1 = self::getDatabaseInstance(self::$dbName); + $db1->runTransaction(function ($t) use (&$iteration) { + $iteration++; + usleep(2 * $this->delay); + $row = $t->execute('SELECT id, number FROM ' . $this->tableName . ' WHERE ID = @id', [ + 'parameters' => ['id' => $this->id] + ])->rows()->current(); + + if ($iteration === 1) { + throw new AbortedException('foo', 409, null, [ + [ + 'retryDelay' => [ + 'seconds' => 1, + 'nanos' => 0 + ] + ] + ]); + } + $row['number'] += 1; + $t->update($this->tableName, $row); + $t->commit(); + }); + + echo $iteration; + pcntl_waitpid($childPID1, $status1); + } else { + $db2 = self::getDatabaseInstance(self::$dbName); + $db2->runTransaction(function ($t) { + $row = $t->execute('SELECT id, number FROM ' . $this->tableName . ' WHERE ID = @id', [ + 'parameters' => ['id' => $this->id] + ])->rows()->current(); + + $row['number'] += 1; + $t->update($this->tableName, $row); + $t->commit(); + }); + } + + return 0; + } +}; + +exit($abortedErrorRetry->run()); + diff --git a/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithExecute.php b/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithExecute.php index b1d0dcbd72d0..029e5eb2bd4c 100644 --- a/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithExecute.php +++ b/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithExecute.php @@ -10,30 +10,46 @@ $tmpFile = sys_get_temp_dir() . '/ConcurrentTransactionsIncremementValueWithExecute.txt'; setupIterationTracker($tmpFile); -$callable = function ($dbName, $tableName, $id) use ($tmpFile) { - $iterations = 0; - $db = SystemTestCaseTrait::getDatabaseInstance($dbName); - if (SystemTestCaseTrait::isEmulatorUsed()) { - // the emulator requires us to manually request a new session - // presumably because multiplexed sessions aren't properly supported - $db->session()->refresh(); +$concurrentExecute = new class($dbName, $tableName, $id, $tmpFile) { + use SystemTestCaseTrait; + + public function __construct( + string $dbName, + private string $tableName, + private int $id, + private string $tmpFile, + ) { + self::$dbName = $dbName; } - $db->runTransaction(function ($transaction) use ($id, $tableName, &$iterations) { - $iterations++; - $row = $transaction->execute('SELECT * FROM ' . $tableName . ' WHERE id = @id', [ - 'parameters' => [ - 'id' => (int) $id - ] - ])->rows()->current(); - - $row['number'] += 1; - - $transaction->update($tableName, $row); - $transaction->commit(); - }); - - updateIterationTracker($tmpFile, $iterations); + public function run(): int + { + $iterations = 0; + $db = self::getDatabaseInstance(self::$dbName); + if (self::isEmulatorUsed()) { + // the emulator requires us to manually request a new session + // presumably because multiplexed sessions aren't properly supported + $db->session()->refresh(); + } + $db->runTransaction(function ($transaction) use (&$iterations) { + $iterations++; + + $row = $transaction->execute('SELECT * FROM ' . $this->tableName . ' WHERE id = @id', [ + 'parameters' => [ + 'id' => $this->id, + ] + ])->rows()->current(); + + $row['number'] += 1; + + $transaction->update($this->tableName, $row); + $transaction->commit(); + }); + + updateIterationTracker($this->tmpFile, $iterations); + + return 0; + } }; $delay = 2000; @@ -41,20 +57,18 @@ if ($childPID1 = pcntl_fork()) { usleep($delay); - $callable($dbName, $tableName, $id); + $status = $concurrentExecute->run(); while (pcntl_waitpid($childPID1, $status1, WNOHANG) == 0 && $retryLimit) { usleep(2 * $delay); $retryLimit--; } + + echo file_get_contents($tmpFile); + exit($status); } else { usleep(2 * $delay); - $callable($dbName, $tableName, $id); - - exit(0); + exit($concurrentExecute->run()); } -echo file_get_contents($tmpFile); - -exit(0); diff --git a/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithRead.php b/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithRead.php index b2283e8c8c36..62aeb8d7e454 100644 --- a/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithRead.php +++ b/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithRead.php @@ -14,25 +14,42 @@ $keyset = new KeySet(['keys' => [$id]]); $columns = ['id', 'number']; -$callable = function ($dbName, KeySet $keyset, array $columns, $tableName) use ($tmpFile) { - $iterations = 0; - $db = SystemTestCaseTrait::getDatabaseInstance($dbName); - if (SystemTestCaseTrait::isEmulatorUsed()) { - // the emulator requires us to manually request a new session - // presumably because multiplexed sessions aren't properly supported - $db->session()->refresh(); +$concurrentRead = new class($dbName, $keyset, $columns, $tableName, $tmpFile) { + use SystemTestCaseTrait; + + public function __construct( + string $dbName, + private KeySet $keyset, + private array $columns, + private string $tableName, + private string $tmpFile + ) { + self::$dbName = $dbName; } - $db->runTransaction(function ($transaction) use ($keyset, $columns, $tableName, &$iterations) { - $iterations++; - $row = $transaction->read($tableName, $keyset, $columns)->rows()->current(); - $row['number'] += 1; + public function run(): int + { + $iterations = 0; + $db = self::getDatabaseInstance(self::$dbName); + if (self::isEmulatorUsed()) { + // the emulator requires us to manually request a new session + // presumably because multiplexed sessions aren't properly supported + $db->session()->refresh(); + } + $db->runTransaction(function ($transaction) use (&$iterations) { + $iterations++; + $row = $transaction->read($this->tableName, $this->keyset, $this->columns)->rows()->current(); - $transaction->update($tableName, $row); - $transaction->commit(); - }); + $row['number'] += 1; - updateIterationTracker($tmpFile, $iterations); + $transaction->update($this->tableName, $row); + $transaction->commit(); + }); + + updateIterationTracker($this->tmpFile, $iterations); + + return 0; + } }; $delay = 2000; @@ -40,20 +57,17 @@ if ($childPID1 = pcntl_fork()) { usleep($delay); - $callable($dbName, $keyset, $columns, $tableName); + $status = $concurrentRead->run(); while (pcntl_waitpid($childPID1, $status1, WNOHANG) == 0 && $retryLimit) { usleep(2 * $delay); $retryLimit--; } + + echo file_get_contents($tmpFile); + exit($status); } else { usleep(2 * $delay); - $callable($dbName, $keyset, $columns, $tableName); - - exit(0); + exit($concurrentRead->run()); } - -echo file_get_contents($tmpFile); - -exit(0); From e3b168ecb9b66ffb42f16df6ff30ed242091cef4 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Tue, 21 Oct 2025 20:48:14 +0000 Subject: [PATCH 13/16] revert composer change, fix styles --- Spanner/composer.json | 12 ------------ Spanner/tests/System/BatchTest.php | 2 +- .../tests/System/pcntl/AbortedErrorCausesRetry.php | 5 ++--- ...ncurrentTransactionsIncrementValueWithExecute.php | 5 ++--- .../ConcurrentTransactionsIncrementValueWithRead.php | 12 ++++++------ 5 files changed, 11 insertions(+), 25 deletions(-) diff --git a/Spanner/composer.json b/Spanner/composer.json index d42e8f51c68f..92284fdad439 100644 --- a/Spanner/composer.json +++ b/Spanner/composer.json @@ -63,17 +63,5 @@ "@test-snippets", "@test-system" ] - }, - "repositories": { - "local": { - "type": "path", - "url": "../Core", - "options": { - "versions": { - "google/cloud-core": "1.100" - } - }, - "canonical": false - } } } diff --git a/Spanner/tests/System/BatchTest.php b/Spanner/tests/System/BatchTest.php index bd2d92b63fa1..55b17fe758ee 100644 --- a/Spanner/tests/System/BatchTest.php +++ b/Spanner/tests/System/BatchTest.php @@ -57,7 +57,7 @@ public static function setUpTestFixtures(): void self::$tableName ))->pollUntilComplete(); - if (self::$database->info()['databaseDialect'] == DatabaseDialect::POSTGRESQL) { + if (self::$database->info()['databaseDialect'] == DatabaseDialect::GOOGLE_STANDARD_SQL) { $statements = [ sprintf('CREATE ROLE %s', self::$dbRole), sprintf('CREATE ROLE %s', self::$restrictiveDbRole), diff --git a/Spanner/tests/System/pcntl/AbortedErrorCausesRetry.php b/Spanner/tests/System/pcntl/AbortedErrorCausesRetry.php index 0fc1d6d8cf80..6c4389b49cc9 100644 --- a/Spanner/tests/System/pcntl/AbortedErrorCausesRetry.php +++ b/Spanner/tests/System/pcntl/AbortedErrorCausesRetry.php @@ -18,7 +18,7 @@ public function __construct( private int $id, private int $delay, ) { - self::$dbName = $dbName; + self::$dbName = $dbName; } public function run(): int @@ -62,11 +62,10 @@ public function run(): int $t->update($this->tableName, $row); $t->commit(); }); - } + } return 0; } }; exit($abortedErrorRetry->run()); - diff --git a/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithExecute.php b/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithExecute.php index 029e5eb2bd4c..bc868ab1cb80 100644 --- a/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithExecute.php +++ b/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithExecute.php @@ -46,9 +46,9 @@ public function run(): int $transaction->commit(); }); - updateIterationTracker($this->tmpFile, $iterations); + updateIterationTracker($this->tmpFile, $iterations); - return 0; + return 0; } }; @@ -71,4 +71,3 @@ public function run(): int exit($concurrentExecute->run()); } - diff --git a/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithRead.php b/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithRead.php index 62aeb8d7e454..9f83cd433af4 100644 --- a/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithRead.php +++ b/Spanner/tests/System/pcntl/ConcurrentTransactionsIncrementValueWithRead.php @@ -19,10 +19,10 @@ public function __construct( string $dbName, - private KeySet $keyset, - private array $columns, - private string $tableName, - private string $tmpFile + private KeySet $keyset, + private array $columns, + private string $tableName, + private string $tmpFile ) { self::$dbName = $dbName; } @@ -46,9 +46,9 @@ public function run(): int $transaction->commit(); }); - updateIterationTracker($this->tmpFile, $iterations); + updateIterationTracker($this->tmpFile, $iterations); - return 0; + return 0; } }; From f159a77d236570918e3d93aa248734118f230431 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Tue, 21 Oct 2025 15:32:30 -0700 Subject: [PATCH 14/16] fix role syntax --- Spanner/tests/System/BatchTest.php | 14 +++++++------- Spanner/tests/System/DatabaseRoleTrait.php | 7 ++----- Spanner/tests/System/PgBatchTest.php | 10 +++++----- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/Spanner/tests/System/BatchTest.php b/Spanner/tests/System/BatchTest.php index 55b17fe758ee..2e02192f40a5 100644 --- a/Spanner/tests/System/BatchTest.php +++ b/Spanner/tests/System/BatchTest.php @@ -31,8 +31,8 @@ */ class BatchTest extends SystemTestCase { - use SystemTestCaseTrait; use DatabaseRoleTrait; + use SystemTestCaseTrait; private static $tableName; private static $isSetup = false; @@ -59,22 +59,22 @@ public static function setUpTestFixtures(): void if (self::$database->info()['databaseDialect'] == DatabaseDialect::GOOGLE_STANDARD_SQL) { $statements = [ - sprintf('CREATE ROLE %s', self::$dbRole), - sprintf('CREATE ROLE %s', self::$restrictiveDbRole), + sprintf('CREATE ROLE %s', self::DATABASE_ROLE), + sprintf('CREATE ROLE %s', self::RESTRICTIVE_DATABASE_ROLE), ]; if (!self::isEmulatorUsed()) { $statements[] = sprintf( - 'GRANT SELECT(id) ON TABLE %s TO %s', + 'GRANT SELECT(id) ON TABLE %s TO ROLE %s', self::$tableName, - self::$restrictiveDbRole + self::RESTRICTIVE_DATABASE_ROLE ); } $statements[] = sprintf( - 'GRANT SELECT ON TABLE %s TO %s', + 'GRANT SELECT ON TABLE %s TO ROLE %s', self::$tableName, - self::$dbRole + self::DATABASE_ROLE ); self::$database->updateDdlBatch($statements)->pollUntilComplete(); diff --git a/Spanner/tests/System/DatabaseRoleTrait.php b/Spanner/tests/System/DatabaseRoleTrait.php index 123749a87056..d9c2fbeb770b 100644 --- a/Spanner/tests/System/DatabaseRoleTrait.php +++ b/Spanner/tests/System/DatabaseRoleTrait.php @@ -24,17 +24,14 @@ */ trait DatabaseRoleTrait { - private static $restrictiveDbRole = 'restrictiveReaderRole'; - private static $dbRole = 'readerRole'; - abstract public static function setUpBeforeClass(); public function dbProvider() { self::setUpTestFixtures(); return [ - [self::$restrictiveDbRole, 'PERMISSION_DENIED'], - [self::$dbRole, null] + [self::RESTRICTIVE_DATABASE_ROLE, 'PERMISSION_DENIED'], + [self::DATABASE_ROLE, null] ]; } diff --git a/Spanner/tests/System/PgBatchTest.php b/Spanner/tests/System/PgBatchTest.php index 07552e395f59..659e72dc3e81 100644 --- a/Spanner/tests/System/PgBatchTest.php +++ b/Spanner/tests/System/PgBatchTest.php @@ -30,8 +30,8 @@ */ class PgBatchTest extends SystemTestCase { - use PgSystemTestCaseTrait; use DatabaseRoleTrait; + use PgSystemTestCaseTrait; private static $tableName; private static $hasSetupBatch = false; @@ -63,20 +63,20 @@ public static function setUpTestFixtures(): void if (self::$database->info()['databaseDialect'] == DatabaseDialect::POSTGRESQL) { $statements = [ - sprintf('CREATE ROLE %s', self::$dbRole), - sprintf('CREATE ROLE %s', self::$restrictiveDbRole), + sprintf('CREATE ROLE %s', self::DATABASE_ROLE), + sprintf('CREATE ROLE %s', self::RESTRICTIVE_DATABASE_ROLE), ]; if (!self::isEmulatorUsed()) { $statements[] = sprintf( 'GRANT SELECT(id) ON TABLE %s TO %s', self::$tableName, - self::$restrictiveDbRole + self::RESTRICTIVE_DATABASE_ROLE ); $statements[] = sprintf( 'GRANT SELECT ON TABLE %s TO %s', self::$tableName, - self::$dbRole + self::DATABASE_ROLE ); } From 841ada4c4c8a06db8289d3dc483fc0dbf7677ae3 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Tue, 21 Oct 2025 16:00:51 -0700 Subject: [PATCH 15/16] remove unnecessary refactor --- Spanner/tests/System/BatchTest.php | 10 +++++----- Spanner/tests/System/DatabaseRoleTrait.php | 7 +++++-- Spanner/tests/System/PgBatchTest.php | 10 +++++----- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Spanner/tests/System/BatchTest.php b/Spanner/tests/System/BatchTest.php index 2e02192f40a5..651e97682e66 100644 --- a/Spanner/tests/System/BatchTest.php +++ b/Spanner/tests/System/BatchTest.php @@ -31,8 +31,8 @@ */ class BatchTest extends SystemTestCase { - use DatabaseRoleTrait; use SystemTestCaseTrait; + use DatabaseRoleTrait; private static $tableName; private static $isSetup = false; @@ -59,22 +59,22 @@ public static function setUpTestFixtures(): void if (self::$database->info()['databaseDialect'] == DatabaseDialect::GOOGLE_STANDARD_SQL) { $statements = [ - sprintf('CREATE ROLE %s', self::DATABASE_ROLE), - sprintf('CREATE ROLE %s', self::RESTRICTIVE_DATABASE_ROLE), + sprintf('CREATE ROLE %s', self::$dbRole), + sprintf('CREATE ROLE %s', self::$restrictiveDbRole), ]; if (!self::isEmulatorUsed()) { $statements[] = sprintf( 'GRANT SELECT(id) ON TABLE %s TO ROLE %s', self::$tableName, - self::RESTRICTIVE_DATABASE_ROLE + self::$restrictiveDbRole ); } $statements[] = sprintf( 'GRANT SELECT ON TABLE %s TO ROLE %s', self::$tableName, - self::DATABASE_ROLE + self::$dbRole ); self::$database->updateDdlBatch($statements)->pollUntilComplete(); diff --git a/Spanner/tests/System/DatabaseRoleTrait.php b/Spanner/tests/System/DatabaseRoleTrait.php index d9c2fbeb770b..123749a87056 100644 --- a/Spanner/tests/System/DatabaseRoleTrait.php +++ b/Spanner/tests/System/DatabaseRoleTrait.php @@ -24,14 +24,17 @@ */ trait DatabaseRoleTrait { + private static $restrictiveDbRole = 'restrictiveReaderRole'; + private static $dbRole = 'readerRole'; + abstract public static function setUpBeforeClass(); public function dbProvider() { self::setUpTestFixtures(); return [ - [self::RESTRICTIVE_DATABASE_ROLE, 'PERMISSION_DENIED'], - [self::DATABASE_ROLE, null] + [self::$restrictiveDbRole, 'PERMISSION_DENIED'], + [self::$dbRole, null] ]; } diff --git a/Spanner/tests/System/PgBatchTest.php b/Spanner/tests/System/PgBatchTest.php index 659e72dc3e81..07552e395f59 100644 --- a/Spanner/tests/System/PgBatchTest.php +++ b/Spanner/tests/System/PgBatchTest.php @@ -30,8 +30,8 @@ */ class PgBatchTest extends SystemTestCase { - use DatabaseRoleTrait; use PgSystemTestCaseTrait; + use DatabaseRoleTrait; private static $tableName; private static $hasSetupBatch = false; @@ -63,20 +63,20 @@ public static function setUpTestFixtures(): void if (self::$database->info()['databaseDialect'] == DatabaseDialect::POSTGRESQL) { $statements = [ - sprintf('CREATE ROLE %s', self::DATABASE_ROLE), - sprintf('CREATE ROLE %s', self::RESTRICTIVE_DATABASE_ROLE), + sprintf('CREATE ROLE %s', self::$dbRole), + sprintf('CREATE ROLE %s', self::$restrictiveDbRole), ]; if (!self::isEmulatorUsed()) { $statements[] = sprintf( 'GRANT SELECT(id) ON TABLE %s TO %s', self::$tableName, - self::RESTRICTIVE_DATABASE_ROLE + self::$restrictiveDbRole ); $statements[] = sprintf( 'GRANT SELECT ON TABLE %s TO %s', self::$tableName, - self::DATABASE_ROLE + self::$dbRole ); } From 956fb1a95c73fdc9713e57a781403a99153193d3 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Wed, 22 Oct 2025 13:47:38 -0700 Subject: [PATCH 16/16] typo fixes --- Spanner/tests/System/PgBatchTest.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Spanner/tests/System/PgBatchTest.php b/Spanner/tests/System/PgBatchTest.php index 07552e395f59..7849bc2fa334 100644 --- a/Spanner/tests/System/PgBatchTest.php +++ b/Spanner/tests/System/PgBatchTest.php @@ -41,9 +41,8 @@ class PgBatchTest extends SystemTestCase */ public static function setUpTestFixtures(): void { - // skip setting up fixutres for the emulator as there's only one test which does not - // suppport the emulator. - // NOTE: remove this if emulator tests are adde + // Skip setting up fixutres for the emulator as there's only one test which does not suppport the emulator. + // NOTE: remove this if new tests tests are added which support the emulator. self::skipEmulatorTests(); if (self::$hasSetupBatch) {