Skip to content

Commit

Permalink
Merge pull request #1433 from keboola/zajca-ct-1894-3
Browse files Browse the repository at this point in the history
CT-1894 More fixes
  • Loading branch information
zajca authored Dec 17, 2024
2 parents f622ef4 + 0e4f751 commit c5aecd0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
5 changes: 4 additions & 1 deletion tests/Backend/CommonPart2/SnapshottingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace Keboola\Test\Backend\CommonPart2;

use Keboola\StorageApi\Metadata;
use Keboola\StorageApi\Options\GlobalSearchOptions;
use Keboola\Test\Common\MetadataTest;
use Keboola\Test\StorageApiTestCase;
use Keboola\Csv\CsvFile;
Expand Down Expand Up @@ -75,7 +76,9 @@ public function testCreateTableFromSnapshotWithDifferentName(): void
$hashedUniqueTableName = sha1('new-table-' . $this->generateDescriptionForTestObject());
$newTableId = $this->_client->createTableFromSnapshot($this->getTestBucketId(), $snapshotId, $hashedUniqueTableName);

$apiCall = fn() => $this->_client->globalSearch($hashedUniqueTableName);
$apiCall = fn() => $this->_client->globalSearch($hashedUniqueTableName, new GlobalSearchOptions(
projectIds: [$this->_client->verifyToken()['owner']['id']],
));
$assertCallback = function ($searchResult) use ($hashedUniqueTableName) {
$this->assertSame(1, $searchResult['all'], 'GlobalSearch expected result count is not 1: ' . json_encode($searchResult));
$this->assertSame('table', $searchResult['items'][0]['type'], 'GlobalSearch');
Expand Down
9 changes: 7 additions & 2 deletions tests/Backend/ExternalBuckets/BigqueryRegisterBucketTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Google\Cloud\Storage\StorageClient;
use Keboola\StorageApi\BranchAwareClient;
use Keboola\StorageApi\ClientException;
use Keboola\StorageApi\Options\GlobalSearchOptions;
use Keboola\StorageApi\TableExporter;
use Keboola\StorageApi\Workspaces;
use Keboola\TableBackendUtils\Connection\Bigquery\BigQueryClientWrapper;
Expand Down Expand Up @@ -694,7 +695,9 @@ public function testRegisterWSAsExternalBucket(string $devBranchType, string $us
$hashedUniqueBucketName,
);

$apiCall = fn() => $testClient->globalSearch($hashedUniqueBucketName);
$apiCall = fn() => $testClient->globalSearch($hashedUniqueBucketName, new GlobalSearchOptions(
projectIds: [$testClient->verifyToken()['owner']['id']],
));
$assertCallback = function ($searchResult) use ($hashedUniqueBucketName) {
$this->assertSame(1, $searchResult['all'], 'GlobalSearch');
$this->assertSame('bucket', $searchResult['items'][0]['type'], 'GlobalSearch');
Expand Down Expand Up @@ -743,7 +746,9 @@ public function testRegisterWSAsExternalBucket(string $devBranchType, string $us
$testClient->setRunId($runId);
$testClient->refreshBucket($idOfBucket);

$apiCall = fn() => $testClient->globalSearch($hashedUniqueTableName);
$apiCall = fn() => $testClient->globalSearch($hashedUniqueTableName, new GlobalSearchOptions(
projectIds: [$testClient->verifyToken()['owner']['id']],
));
$assertCallback = function ($searchResult) use ($hashedUniqueTableName) {
$this->assertSame(1, $searchResult['all'], 'GlobalSearch');
$this->assertSame('table', $searchResult['items'][0]['type'], 'GlobalSearch');
Expand Down
2 changes: 1 addition & 1 deletion tests/Backend/SOX/MergeRequestsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1767,7 +1767,7 @@ private function mergeDevBranchToProd(int $branchFromId, int $branchIntoId): int
$this->initEvents($this->getDefaultBranchStorageApiClient());
$this->prodManagerClient->mergeMergeRequest($mrId);
$assertCallback = function ($events) {
$this->assertCount(2, $events);
$this->assertCount(2, $events, (string) json_encode($events));
$params = $events[0]['params'];
unset($params['mergeRequestId']);
$this->assertEquals([
Expand Down
5 changes: 3 additions & 2 deletions tests/Backend/Workspaces/Backend/BigqueryWorkspaceBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Keboola\TableBackendUtils\Table\Bigquery\BigqueryTableReflection;
use Keboola\TableBackendUtils\View\ViewReflectionInterface;
use PDO;
use Retry\Policy\SimpleRetryPolicy;
use Retry\RetryProxy;

class BigqueryWorkspaceBackend implements WorkspaceBackend
Expand Down Expand Up @@ -137,7 +138,7 @@ public function dropTableIfExists($table)
{
if ($this->isTableExists($this->schema, $table)) {
$dataset = $this->bqClient->dataset($this->schema);
$dataset->table($table)->delete();
$dataset->table($table)->delete(['retries' => 5]);
}
}

Expand Down Expand Up @@ -219,7 +220,7 @@ protected function isTableExists(string $schema, string $table): bool
$dataset = $this->bqClient->dataset($schema);
$table = $dataset->table($table);

$exists = (new RetryProxy())->call(function () use ($table) {
$exists = (new RetryProxy(new SimpleRetryPolicy(10)))->call(function () use ($table) {
return $table->exists();
});
assert(is_bool($exists));
Expand Down

0 comments on commit c5aecd0

Please sign in to comment.