Skip to content

Commit

Permalink
fix system test
Browse files Browse the repository at this point in the history
  • Loading branch information
bshaffer committed Nov 27, 2024
1 parent 4583ac1 commit c53edc3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
10 changes: 8 additions & 2 deletions Core/src/LongRunning/LongRunningGapicConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@

use Google\ApiCore\OperationResponse;
use Google\ApiCore\Serializer;
use Google\Cloud\Core\RequestProcessorTrait;
use Google\LongRunning\Operation;
use Google\LongRunning\ListOperationsRequest;
use Google\LongRunning\GetOperationRequest;
use Google\LongRunning\CancelOperationRequest;
use Google\LongRunning\DeleteOperationRequest;
use Google\Cloud\Core\RequestProcessorTrait;
use Google\Protobuf\Any;

/**
* Defines the calls required to manage Long Running Operations using a GAPIC
Expand Down Expand Up @@ -97,7 +98,12 @@ private function operationResponseToArray(OperationResponse $operationResponse)
$metaType = $response['metadata']['typeUrl'];

// unpack result Any type
$response['response'] = $this->handleResponse($operationResponse->getResult());
$result = $operationResponse->getResult();
if ($result instanceof Any) {
// For some reason we aren't doing this in GAX OperationResponse (but we should)
$result = $result->unpack();
}
$response['response'] = $this->handleResponse($result);

// unpack error Any type
$response['error'] = $this->handleResponse($operationResponse->getError());
Expand Down
16 changes: 8 additions & 8 deletions Spanner/tests/System/AdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

namespace Google\Cloud\Spanner\Tests\System;

use Google\ApiCore\OperationResponse;
use Google\Cloud\Core\Exception\FailedPreconditionException;
use Google\Cloud\Core\LongRunning\LongRunningOperation;
use Google\Cloud\Spanner\Admin\Database\V1\Client\DatabaseAdminClient;
use Google\Cloud\Spanner\Admin\Database\V1\DatabaseDialect;
use Google\Cloud\Spanner\Admin\Instance\V1\Client\InstanceAdminClient;
Expand Down Expand Up @@ -62,7 +62,7 @@ public function testInstance()
'processingUnits' => $processingUnits,
]);

$this->assertInstanceOf(OperationResponse::class, $op);
$this->assertInstanceOf(LongRunningOperation::class, $op);
$op->pollUntilComplete();

$instance = $client->instance(self::INSTANCE_NAME);
Expand Down Expand Up @@ -97,9 +97,9 @@ public function testDatabase()
$dbName = uniqid(self::TESTING_PREFIX);
$op = $instance->createDatabase($dbName);

$this->assertInstanceOf(OperationResponse::class, $op);
$this->assertInstanceOf(LongRunningOperation::class, $op);
$op->pollUntilComplete();
$db = $op->getResult();
$db = $op->result();
$this->assertInstanceOf(Database::class, $db);

self::$deletionQueue->add(function () use ($db) {
Expand Down Expand Up @@ -141,9 +141,9 @@ public function testDatabaseDropProtection()
$dbName = uniqid(self::TESTING_PREFIX);
$op = $instance->createDatabase($dbName);

$this->assertInstanceOf(OperationResponse::class, $op);
$this->assertInstanceOf(LongRunningOperation::class, $op);
$op->pollUntilComplete();
$db = $op->getResult();
$db = $op->result();
$this->assertInstanceOf(Database::class, $db);

$info = $db->reload();
Expand Down Expand Up @@ -207,7 +207,7 @@ public function testCreateCustomerManagedInstanceConfiguration()
$replicas[array_rand($replicas)]['defaultLeaderLocation'] = true;
$op = $customConfiguration->create($baseConfig, $replicas);

$this->assertInstanceOf(OperationResponse::class, $op);
$this->assertInstanceOf(LongRunningOperation::class, $op);
$op->pollUntilComplete();

$this->assertTrue($customConfiguration->exists());
Expand Down Expand Up @@ -293,7 +293,7 @@ public function testPgDatabase()
'databaseDialect' => DatabaseDialect::POSTGRESQL
]);

$this->assertInstanceOf(OperationResponse::class, $op);
$this->assertInstanceOf(LongRunningOperation::class, $op);
$db = $op->pollUntilComplete();
$this->assertInstanceOf(Database::class, $db);

Expand Down

0 comments on commit c53edc3

Please sign in to comment.