Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(spanner): enable PG tests to run on emulator #7572

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Spanner/tests/System/PgBatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static function setUpBeforeClass(): void
*/
public function testBatchWithDbRole($dbRole, $expected)
{
// Emulator does not support FGAC
// Emulator does not support FGAC for the PG dialect.
$this->skipEmulatorTests();

$error = null;
Expand Down
2 changes: 2 additions & 0 deletions Spanner/tests/System/PgBatchWriteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class PgBatchWriteTest extends SpannerPgTestCase
const TABLE_NAME = 'BatchWrites';
public static function setUpBeforeClass(): void
{
// The BatchWrite tests are skipped for the GSQL dialect when running
// against the emulator.
self::skipEmulatorTests();
parent::setUpBeforeClass();

Expand Down
5 changes: 5 additions & 0 deletions Spanner/tests/System/PgPartitionedDmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ class PgPartitionedDmlTest extends SpannerPgTestCase

public function testPdml()
{
// Skipping temporarily while we figure out the issue with
// `executePartitionedUpdate` not accepting parameters in
// PG format.
self::skipEmulatorTests();

$db = self::$database;

$db->updateDdl('CREATE TABLE ' . self::PDML_TABLE . '(
Expand Down
10 changes: 10 additions & 0 deletions Spanner/tests/System/PgQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ public function testBindFloat64Parameter()

public function testBindFloat32Parameter()
{
// Emulator as an issue with FLOAT32 for PG.
$this->skipEmulatorTests();
$db = self::$database;

$res = $db->execute('SELECT * FROM ' . self::TABLE_NAME . ' WHERE weight = $1', [
Expand Down Expand Up @@ -544,6 +546,8 @@ public function testBindJsonbParameterNull()

public function testBindPgOidParameter()
{
// Emulator support for PG.OID is pending.
$this->skipEmulatorTests();
$db = self::$database;

$res = $db->execute('SELECT $1', [
Expand All @@ -559,6 +563,8 @@ public function testBindPgOidParameter()

public function testBindPgOidParameterNull()
{
// Emulator support for PG.OID is pending.
$this->skipEmulatorTests();
$db = self::$database;

$res = $db->execute('SELECT $1', [
Expand Down Expand Up @@ -726,6 +732,8 @@ public function arrayTypesEmptyProvider()
*/
public function testBindEmptyArrayOfType($type)
{
// Emulator support for PG.OID is pending.
$this->skipEmulatorTests();
$db = self::$database;

$res = $db->execute('SELECT $1 as foo', [
Expand Down Expand Up @@ -764,6 +772,8 @@ public function arrayTypesNullProvider()
*/
public function testBindNullArrayOfType($type)
{
// Emulator support for PG.OID is pending.
$this->skipEmulatorTests();
$db = self::$database;

$res = $db->execute('SELECT $1 as foo', [
Expand Down
1 change: 1 addition & 0 deletions Spanner/tests/System/PgReadTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ public function testReadFailsOnDeadlineExceeded()
{
$this->expectException(DeadlineExceededException::class);

// The equiavalent test for the GSQL dialect is also skipped.
$this->skipEmulatorTests();
$db = self::$database;
$keyset = new KeySet(['all' => true]);
Expand Down
2 changes: 2 additions & 0 deletions Spanner/tests/System/PgWriteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class PgWriteTest extends SpannerPgTestCase

public static function setUpBeforeClass(): void
{
// The equiavalent tests for the GSQL dialect are also skipped.
self::skipEmulatorTests();
parent::setUpBeforeClass();

self::$database->updateDdlBatch([
Expand Down
22 changes: 15 additions & 7 deletions Spanner/tests/System/SpannerPgTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public static function setUpBeforeClass(): void
return;
}

self::skipEmulatorTests();
self::getClient();

self::$instance = self::$client->instance(self::INSTANCE_NAME);
Expand Down Expand Up @@ -83,15 +82,24 @@ public static function setUpBeforeClass(): void
name varchar(1024) NOT NULL,
birthday date
)',
'CREATE ROLE ' . self::DATABASE_ROLE,
'CREATE ROLE ' . self::RESTRICTIVE_DATABASE_ROLE,
'GRANT SELECT ON TABLE ' . self::TEST_TABLE_NAME .
' TO ' . self::DATABASE_ROLE,
'GRANT SELECT(id, name), INSERT(id, name), UPDATE(id, name) ON TABLE '
. self::TEST_TABLE_NAME . ' TO ' . self::RESTRICTIVE_DATABASE_ROLE,
]
)->pollUntilComplete();

// Currently, the emulator doesn't support setting roles for the PG
// dialect.
if (!getenv("SPANNER_EMULATOR_HOST")) {
$db->updateDdlBatch(
[
'CREATE ROLE ' . self::DATABASE_ROLE,
'CREATE ROLE ' . self::RESTRICTIVE_DATABASE_ROLE,
'GRANT SELECT ON TABLE ' . self::TEST_TABLE_NAME .
' TO ' . self::DATABASE_ROLE,
'GRANT SELECT(id, name), INSERT(id, name), UPDATE(id, name) ON TABLE '
. self::TEST_TABLE_NAME . ' TO ' . self::RESTRICTIVE_DATABASE_ROLE,
]
)->pollUntilComplete();
}

self::$hasSetUp = true;
}

Expand Down
Loading