From 1c1b933a1e0e7571f62163e055b1c48a2c96674a Mon Sep 17 00:00:00 2001 From: zajca Date: Tue, 20 Aug 2024 10:05:08 +0200 Subject: [PATCH 1/3] testRefreshTablesInformation test alias update --- .../SnowflakeBucketsRefreshTablesInformationTest.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/Backend/ExternalBuckets/SnowflakeBucketsRefreshTablesInformationTest.php b/tests/Backend/ExternalBuckets/SnowflakeBucketsRefreshTablesInformationTest.php index 18841fe00..4c2a3af91 100644 --- a/tests/Backend/ExternalBuckets/SnowflakeBucketsRefreshTablesInformationTest.php +++ b/tests/Backend/ExternalBuckets/SnowflakeBucketsRefreshTablesInformationTest.php @@ -41,6 +41,7 @@ public function testRefreshTablesInformation(): void $bucket = $this->_client->getBucket($bucketId); $tableId = $this->createTableWithRandomData('refresh-tables-information-test-table', $createdTableRows, 2); + $aliasId = $this->_client->createAliasTable($bucketId, $tableId, 'alias'); $table = $this->_client->getTable($tableId); $rowsCount = $table['rowsCount']; @@ -81,7 +82,7 @@ public function testRefreshTablesInformation(): void $db->executeQuery( sprintf( - 'INSERT INTO %s ("col_1","col_2") VALUES (\'testvalue 1\', \'testvalue 2\')', + 'INSERT INTO %s ("col_1","col_2") VALUES (\'testvalue 1\', \'testvalue 2\'),(\'testvalue 1\', \'testvalue 2\')', SnowflakeQuote::quoteSingleIdentifier($table['name']), ), ); @@ -91,12 +92,15 @@ public function testRefreshTablesInformation(): void $bClient->refreshTableInformationInBucket($bucketId); $refreshedTable = $this->_client->getTable($tableId); + $refreshedTableAlias = $this->_client->getTable($aliasId); - $this->assertEquals($rowsCount + 1, $refreshedTable['rowsCount']); + $this->assertEquals($rowsCount + 2, $refreshedTable['rowsCount']); + $this->assertEquals($refreshedTable['rowsCount'], $refreshedTableAlias['rowsCount']); // TODO: check dataSizeBytes did not change but rowsCount did // $this->assertNotEquals($dataSizeBytes, $refreshedTable['dataSizeBytes']); +// $this->assertNotEquals($refreshedTable['dataSizeBytes'], $refreshedTableAlias['dataSizeBytes']); - $this->_client->dropTable($tableId); + $this->_client->dropTable($tableId, ['force' => true]); $this->_client->dropBucket($bucketId); $workspaces->deleteWorkspace($workspace['id']); From 119f3bf2973a85b71521c9a1910d3f9543db4127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Fejfar?= Date: Wed, 21 Aug 2024 11:39:34 +0200 Subject: [PATCH 2/3] CT-1693 fix broken test --- ...wflakeBucketsRefreshTablesInformationTest.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/Backend/ExternalBuckets/SnowflakeBucketsRefreshTablesInformationTest.php b/tests/Backend/ExternalBuckets/SnowflakeBucketsRefreshTablesInformationTest.php index 4c2a3af91..72085243f 100644 --- a/tests/Backend/ExternalBuckets/SnowflakeBucketsRefreshTablesInformationTest.php +++ b/tests/Backend/ExternalBuckets/SnowflakeBucketsRefreshTablesInformationTest.php @@ -26,7 +26,7 @@ public function testRefreshTablesInformationEndpointExists(): void public function testRefreshTablesInformation(): void { - $this->markTestSkipped('Test is not working, needs to be fixed; CT-1691'); + //$this->markTestSkipped('Test is not working, needs to be fixed; CT-1691'); $createdTableRows = 10; $workspaces = new Workspaces($this->_client); @@ -59,6 +59,13 @@ public function testRefreshTablesInformation(): void ), ); + $db->executeQuery( + sprintf( + 'USE ROLE %s;', + SnowflakeQuote::quoteSingleIdentifier($workspace['connection']['database']), + ), + ); + $db->executeQuery( sprintf( 'USE WAREHOUSE %s;', @@ -104,6 +111,13 @@ public function testRefreshTablesInformation(): void $this->_client->dropBucket($bucketId); $workspaces->deleteWorkspace($workspace['id']); + $db->executeQuery( + sprintf( + 'USE ROLE %s;', + SnowflakeQuote::quoteSingleIdentifier((string) getenv('SNOWFLAKE_USER')), + ), + ); + $db->executeQuery( sprintf( 'REVOKE ROLE %s FROM USER %s;', From cd78fec5c723474570c2fb7adee8830e49c76a41 Mon Sep 17 00:00:00 2001 From: zajca Date: Wed, 21 Aug 2024 11:48:18 +0200 Subject: [PATCH 3/3] update baseline --- phpstan-baseline.neon | 24 ++++++++----------- ...akeBucketsRefreshTablesInformationTest.php | 1 - 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index cf9241476..cb8165339 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -750,11 +750,21 @@ parameters: count: 1 path: src/Keboola/StorageApi/Client.php + - + message: "#^Method Keboola\\\\StorageApi\\\\Client\\:\\:validateColumnNames\\(\\) has no return type specified\\.$#" + count: 1 + path: src/Keboola/StorageApi/Client.php + - message: "#^Method Keboola\\\\StorageApi\\\\Client\\:\\:waitForJob\\(\\) has parameter \\$jobId with no type specified\\.$#" count: 1 path: src/Keboola/StorageApi/Client.php + - + message: "#^Method Keboola\\\\StorageApi\\\\Client\\:\\:webalizeColumnNames\\(\\) has no return type specified\\.$#" + count: 1 + path: src/Keboola/StorageApi/Client.php + - message: "#^Method Keboola\\\\StorageApi\\\\Client\\:\\:webalizeDisplayName\\(\\) has no return type specified\\.$#" count: 1 @@ -2510,11 +2520,6 @@ parameters: count: 1 path: tests/Backend/Export/ExportParamsTest.php - - - message: "#^Unreachable statement \\- code above always terminates\\.$#" - count: 1 - path: tests/Backend/ExternalBuckets/SnowflakeBucketsRefreshTablesInformationTest.php - - message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#" count: 1 @@ -5224,12 +5229,3 @@ parameters: message: "#^Parameter \\#1 \\$filename of function file_get_contents expects string, string\\|false given\\.$#" count: 1 path: tests/bootstrap.php - - - message: "#^Method Keboola\\\\StorageApi\\\\Client\\:\\:webalizeColumnNames\\(\\) has no return type specified\\.$#" - count: 1 - path: src/Keboola/StorageApi/Client.php - - - - message: "#^Method Keboola\\\\StorageApi\\\\Client\\:\\:validateColumnNames\\(\\) has no return type specified\\.$#" - count: 1 - path: src/Keboola/StorageApi/Client.php diff --git a/tests/Backend/ExternalBuckets/SnowflakeBucketsRefreshTablesInformationTest.php b/tests/Backend/ExternalBuckets/SnowflakeBucketsRefreshTablesInformationTest.php index 72085243f..abc7c706a 100644 --- a/tests/Backend/ExternalBuckets/SnowflakeBucketsRefreshTablesInformationTest.php +++ b/tests/Backend/ExternalBuckets/SnowflakeBucketsRefreshTablesInformationTest.php @@ -26,7 +26,6 @@ public function testRefreshTablesInformationEndpointExists(): void public function testRefreshTablesInformation(): void { - //$this->markTestSkipped('Test is not working, needs to be fixed; CT-1691'); $createdTableRows = 10; $workspaces = new Workspaces($this->_client);