Skip to content

Commit 8d206be

Browse files
committed
test(spanner): fix BackupTest timeout and PgQueryTest schema collision
1 parent 7dc56c3 commit 8d206be

4 files changed

Lines changed: 23 additions & 3 deletions

File tree

Spanner/tests/System/BackupTest.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,19 @@ public function testCreateBackupCopy()
324324
$this->assertArrayHasKey('progressPercent', $metadata['progress']);
325325
$this->assertArrayHasKey('startTime', $metadata['progress']);
326326

327-
$op->pollUntilComplete();
327+
$timeout = time() + self::LONG_TIMEOUT_SECONDS;
328+
while (time() < $timeout) {
329+
try {
330+
$op->pollUntilComplete([
331+
'maxPollingDurationSeconds' => $timeout - time()
332+
]);
333+
break;
334+
} catch (\Google\ApiCore\ApiException $e) {
335+
if ($e->getStatus() !== 'DEADLINE_EXCEEDED') {
336+
throw $e;
337+
}
338+
}
339+
}
328340

329341
self::$deletionQueue->add(function () use ($newBackup) {
330342
$newBackup->delete();

Spanner/tests/System/PgQueryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class PgQueryTest extends SystemTestCase
4141
{
4242
use PgSystemTestCaseTrait;
4343

44-
const TABLE_NAME = 'PgQueryTest';
44+
const TABLE_NAME = 'PgQueryTest_2';
4545

4646
public static $timestampVal;
4747

Spanner/tests/System/PgSystemTestCaseTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ protected static function setUpTestDatabase(): void
126126
boolField BOOL,
127127
PRIMARY KEY (id)
128128
)',
129-
'CREATE TABLE IF NOT EXISTS PgQueryTest (
129+
'CREATE TABLE IF NOT EXISTS PgQueryTest_2 (
130130
id bigint NOT NULL,
131131
name varchar(1024),
132132
registered bool,

env-test.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export GOOGLE_CLOUD_PROJECT="php-docs-samples-kokoro"
2+
export GOOGLE_CLOUD_QUOTA_PROJECT="php-docs-samples-kokoro"
3+
export GOOGLE_CLOUD_PHP_WHITELIST_TESTS_KEY_PATH="/Users/yejiyun/Downloads/php-docs-samples-kokoro-28f7d635913c.json"
4+
export GOOGLE_CLOUD_PHP_TESTS_KEY_PATH="/Users/yejiyun/Downloads/php-docs-samples-kokoro-28f7d635913c.json"
5+
export GOOGLE_CLOUD_SPANNER_TEST_DATABASE="php-test-std-v2"
6+
export GOOGLE_CLOUD_SPANNER_TEST_PG_DATABASE="php-test-pg-v2"
7+
export GOOGLE_CLOUD_SPANNER_TEST_BACKUP_DATABASE_1="php-test-bkp-1"
8+
export GOOGLE_CLOUD_SPANNER_TEST_BACKUP_DATABASE_2="php-test-bkp-2"

0 commit comments

Comments
 (0)