diff --git a/functions/helloworld_pubsub/index.php b/functions/helloworld_pubsub/index.php index 16a82da024..8794579b8b 100644 --- a/functions/helloworld_pubsub/index.php +++ b/functions/helloworld_pubsub/index.php @@ -24,8 +24,10 @@ function helloworldPubsub(CloudEvent $event): void $log = fopen(getenv('LOGGER_OUTPUT') ?: 'php://stderr', 'wb'); $cloudEventData = $event->getData(); - if (isset($cloudEventData['data'])) { - $name = htmlspecialchars(base64_decode($cloudEventData['data'])); + $pubSubData = base64_decode($cloudEventData['message']['data']); + + if ($pubSubData) { + $name = htmlspecialchars($pubSubData); } else { $name = 'World'; } diff --git a/functions/helloworld_pubsub/test/DeployTest.php b/functions/helloworld_pubsub/test/DeployTest.php index fdea505e47..3214a967e7 100644 --- a/functions/helloworld_pubsub/test/DeployTest.php +++ b/functions/helloworld_pubsub/test/DeployTest.php @@ -72,10 +72,6 @@ public function testHelloworldPubsub(string $name, string $expected, string $lab // Send Pub/Sub message. $this->publishMessage($name); - // Give event and log systems a head start. - // If log retrieval fails to find logs for our function within retry limit, increase sleep time. - sleep(60); - $fiveMinAgo = date(\DateTime::RFC3339, strtotime('-5 minutes')); $this->processFunctionLogs($fiveMinAgo, function (\Iterator $logs) use ($name, $expected, $label) { // Concatenate all relevant log messages. diff --git a/functions/helloworld_pubsub/test/IntegrationTest.php b/functions/helloworld_pubsub/test/IntegrationTest.php index 0624ea7ca2..2e351c8c2f 100644 --- a/functions/helloworld_pubsub/test/IntegrationTest.php +++ b/functions/helloworld_pubsub/test/IntegrationTest.php @@ -60,7 +60,9 @@ public function dataProvider() 'type' => 'google.cloud.pubsub.topic.v1.messagePublished', ], 'data' => [ - 'data' => base64_encode('John') + 'message' => [ + 'data' => base64_encode('John') + ] ], 'statusCode' => 200, 'expected' => 'Hello, John!',