test(pubsub): run the Pub/Sub end-to-end tests against Google Cloud - #348
Merged
Merged
Conversation
The eight Pub/Sub end-to-end tests were only ever run against the
emulator. They were already written to work against either backend
(`test_utils.dart` picks up application default credentials when
`PUBSUB_EMULATOR_HOST` is unset), but nothing selected them in the
Cloud Build integration job.
Terraform:
* Enable `pubsub.googleapis.com` on the project.
* Grant `roles/pubsub.editor` to `integration-test-runner@`. Editor
rather than admin: the tests create, delete, publish to and consume
from topics and subscriptions, but never read or write IAM policies
on them.
Tests:
* Tag the eight end-to-end tests `google-cloud` in addition to
`firebase-emulator`, so `dart test . -P google-cloud` (what
`.gcb/scripts/integration.sh` runs) picks them up. No change is
needed to `integration.yaml` or the root `dart_test.yaml`, which
already define the tag and the preset.
* Declare the `google-cloud` tag and preset in the package's own
`dart_test.yaml`, and exclude it by default. Without this, a plain
`dart test` from inside the package would run the tests against
whatever project the developer's credentials point at.
* Replace the `DateTime.now().millisecondsSinceEpoch` name suffixes
with a random suffix. Against the shared `dart-sdk-testing` project
two builds can now overlap, and a shared name would make one of them
fail with a `ConflictException` or see the other's messages.
TAG=agy
CONV=4ecd3490-bbbe-499e-90e5-07ea5e14a460
Contributor
There was a problem hiding this comment.
Code Review
This pull request configures and enables Pub/Sub integration tests to run against a real Google Cloud project. It updates the Terraform configuration to enable the Pub/Sub service and grant the necessary IAM permissions (roles/pubsub.editor) to the integration test runner. Additionally, it introduces a google-cloud test tag and preset, and updates the test files to use a new testResourceName helper that generates random suffixes for resource names to prevent conflicts during concurrent test runs. I have no feedback to provide as there are no review comments.
| member = "serviceAccount:${data.google_service_account.integration-test-runner.email}" | ||
| } | ||
|
|
||
| # The service account needs to create and delete topics and subscriptions, and |
Contributor
There was a problem hiding this comment.
This is not needed because it is controlled by terraform and we already have this enabled.
brianquinlan
approved these changes
Sep 15, 2026
As noted in review, `integration-test-runner@` already receives project-level permissions outside this Terraform module. TAG=agy CONV=4ecd3490-bbbe-499e-90e5-07ea5e14a460
Contributor
Author
|
/gcbrun |
sigurdm
added a commit
that referenced
this pull request
Sep 17, 2026
…iably Now that #348 has landed, tag `batching_e2e_test.dart` with `google-cloud` so it runs in Cloud Build integration tests as well as the emulator. Also switch resource names to `testResourceName` and use `pullReliably` after `modifyAckDeadlineNow(0)` so eventual consistency on real GCP does not flake on the first pull. TAG=agy CONV=4ecd3490-bbbe-499e-90e5-07ea5e14a460
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The eight Pub/Sub end-to-end tests were only ever run against the
emulator. They were already written to work against either backend
(
test/test_utils.dartpicks up application default credentials whenPUBSUB_EMULATOR_HOSTis unset, and a couple of them already branch onisEmulator), but nothing selected them in the Cloud Build integrationjob, and the project did not have the API enabled in Terraform.
Terraform
pubsub.googleapis.comin.gcb/builds/services/main.tf.Tests
Tag the eight end-to-end tests
google-cloudin addition tofirebase-emulator..gcb/scripts/integration.shrunsdart test . -P google-cloudfrom the repo root, so the rootdart_test.yamlgoverns, and it already defines the tag and thepreset. Nothing in
.gcb/needs to change.I verified that a file tagged with both
firebase-emulatorandgoogle-cloudreally is selected by-P google-cloudfrom the reporoot and by
-P firebase-emulatorfrom inside the package, and isstill excluded from a plain
dart test.Declare the
google-cloudtag and preset in the package's owndart_test.yamland exclude it by default. Without this, a plaindart testfrom insidepkgs/google_cloud_pubsubwould run the testsagainst whatever project the developer's credentials point at.
Replace the
DateTime.now().millisecondsSinceEpochname suffixes witha random suffix (
testResourceName), following the pattern ingoogle_cloud_storage'stest_utils.dart. Against the shareddart-sdk-testingproject two builds can now overlap, and a sharedname would make one of them fail with a
ConflictExceptionor observethe other's messages.
Verification
dart format,dart analyzeclean;dart test .anddart test -P firebase-emulator(14 tests) pass locally.TAG=agy
CONV=4ecd3490-bbbe-499e-90e5-07ea5e14a460