Skip to content

Commit 7ea2aa7

Browse files
authored
Merge pull request #1562 from keboola/vb/DMD-367/credentials-endpoint-test-for-dynamic-backend-sizes
DMD-367 - test for dynamic backend sizes in credentials endpoint
2 parents aab878c + d7dbcd8 commit 7ea2aa7

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

tests/Backend/Workspaces/SnowflakeDynamicBackendsTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,33 @@ public function testWorkspaceCreate(
7777
true,
7878
);
7979

80+
// Check queries against warehouse - no exception expected
81+
$db = WorkspaceBackendFactory::createWorkspaceForSnowflakeDbal($workspace);
82+
// -- Pick the warehouse you want to test
83+
$db->executeQuery("USE WAREHOUSE {$workspace['connection']['warehouse']};");
84+
// -- Ensure it actually spins compute (no result cache)
85+
$db->executeQuery('ALTER SESSION SET USE_CACHED_RESULT = FALSE;');
86+
// -- Easiest dummy SELECT that runs on the warehouse
87+
$db->executeQuery('SELECT CURRENT_WAREHOUSE(), CURRENT_TIMESTAMP(), RANDOM();');
88+
8089
$this->assertSame('snowflake', $workspace['connection']['backend']);
8190
$this->assertSame($expectedBackendSize, $workspace['backendSize']);
8291
$this->assertStringEndsWith($expectedWarehouseSuffix, $workspace['connection']['warehouse']);
92+
93+
$credentials = $this->workspaces->createCredentials($workspace['id']);
94+
95+
// Check queries against warehouse - no exception expected
96+
$db2 = WorkspaceBackendFactory::createWorkspaceForSnowflakeDbal($credentials);
97+
// -- Pick the warehouse you want to test
98+
$db2->executeQuery("USE WAREHOUSE {$credentials['connection']['warehouse']};");
99+
// -- Ensure it actually spins compute (no result cache)
100+
$db2->executeQuery('ALTER SESSION SET USE_CACHED_RESULT = FALSE;');
101+
// -- Easiest dummy SELECT that runs on the warehouse
102+
$db2->executeQuery('SELECT CURRENT_WAREHOUSE(), CURRENT_TIMESTAMP(), RANDOM();');
103+
104+
$this->assertSame('snowflake', $credentials['connection']['backend']);
105+
$this->assertSame($expectedBackendSize, $credentials['backendSize']);
106+
$this->assertStringEndsWith($expectedWarehouseSuffix, $credentials['connection']['warehouse']);
83107
}
84108

85109
public function testWorkspaceLoadLinkedDataFromProjectWithDynamicBackends(): void

0 commit comments

Comments
 (0)