Skip to content

Commit

Permalink
chore(tests): [PubSub] run rest tests against the emulator (#8056)
Browse files Browse the repository at this point in the history
* chore(tests): [PubSub] run rest tests against the emulator

* fix cs

* skip rest tests which are timing out
  • Loading branch information
bshaffer authored Feb 2, 2025
1 parent 8931351 commit af302a6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/system-tests-pubsub-emulator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- run: ./.github/emulator/start-emulator.sh pubsub 413.0.0-emulators
- run: ./.github/emulator/start-emulator.sh pubsub

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
30 changes: 14 additions & 16 deletions PubSub/tests/System/PubSubTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ public function clientProvider()
{
self::setUpTestFixtures();

$result = [
'grpc' => [self::$grpcClient],
];
if (!self::isEmulatorUsed()) {
$result['rest'] = [self::$restClient];
if (is_null(self::$grpcClient)) {
return ['rest' => [self::$restClient]];
}
return $result;

return [
'grpc' => [self::$grpcClient, 'grpc'],
'rest' => [self::$restClient, 'rest'],
];
}

/**
Expand All @@ -53,14 +54,16 @@ public static function setUpTestFixtures(): void
}

$keyFilePath = getenv('GOOGLE_CLOUD_PHP_TESTS_KEY_PATH');
self::$restClient = new PubSubClientRest([
self::$restClient = new PubSubClient([
'credentials' => $keyFilePath,
'transport' => 'rest',
]);
self::$grpcClient = new PubSubClientGrpc([
'credentials' => $keyFilePath,
'transport' => 'grpc',
]);
if (extension_loaded('grpc')) {
self::$grpcClient = new PubSubClient([
'credentials' => $keyFilePath,
'transport' => 'grpc',
]);
}
self::setUsingEmulatorForClassPrefix((bool) getenv('PUBSUB_EMULATOR_HOST'));
self::setupQueue();
self::$hasSetUp = true;
Expand Down Expand Up @@ -104,8 +107,3 @@ public static function topicAndSubscription(PubSubClient $client, array $topicCo
return [$topic, $sub];
}
}

//@codingStandardsIgnoreStart
class PubSubClientRest extends PubSubClient {}
class PubSubClientGrpc extends PubSubClient {}
//@codingStandardsIgnoreEnd
5 changes: 4 additions & 1 deletion PubSub/tests/System/PublishAndPullTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,11 @@ public function testPublishMessagesAndPull($client)
/**
* @dataProvider clientProvider
*/
public function testOrderingKeys($client)
public function testOrderingKeys($client, $transport)
{
if ($transport === 'rest' && $this->isEmulatorUsed()) {
$this->markTestSkipped('This times out for REST transport emulator tests');
}
list ($topic, $sub) = self::topicAndSubscription($client, [], [
'enableMessageOrdering' => true
]);
Expand Down

0 comments on commit af302a6

Please sign in to comment.