Skip to content

test(pubsub): run the Pub/Sub end-to-end tests against Google Cloud - #348

Merged
sigurdm merged 3 commits into
mainfrom
pubsub-gcb-integration
Sep 17, 2026
Merged

sigurdm merged 3 commits into
mainfrom
pubsub-gcb-integration

Conversation

@sigurdm

@sigurdm sigurdm commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

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.dart picks up application default credentials when
PUBSUB_EMULATOR_HOST is unset, and a couple of them already branch on
isEmulator), but nothing selected them in the Cloud Build integration
job, and the project did not have the API enabled in Terraform.

Terraform

  • Enable pubsub.googleapis.com in .gcb/builds/services/main.tf.

Tests

  • Tag the eight end-to-end tests google-cloud in addition to
    firebase-emulator. .gcb/scripts/integration.sh runs
    dart test . -P google-cloud from the repo root, so the root
    dart_test.yaml governs, and it already defines the tag and the
    preset. Nothing in .gcb/ needs to change.

    I verified that a file tagged with both firebase-emulator and
    google-cloud really is selected by -P google-cloud from the repo
    root and by -P firebase-emulator from inside the package, and is
    still excluded from a plain dart test.

  • 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 pkgs/google_cloud_pubsub would run the tests
    against whatever project the developer's credentials point at.

  • Replace the DateTime.now().millisecondsSinceEpoch name suffixes with
    a random suffix (testResourceName), following the pattern in
    google_cloud_storage's test_utils.dart. 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 observe
    the other's messages.

Verification

dart format, dart analyze clean; dart test . and
dart test -P firebase-emulator (14 tests) pass locally.

TAG=agy
CONV=4ecd3490-bbbe-499e-90e5-07ea5e14a460

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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread .gcb/builds/grants/main.tf Outdated
member = "serviceAccount:${data.google_service_account.integration-test-runner.email}"
}

# The service account needs to create and delete topics and subscriptions, and

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed because it is controlled by terraform and we already have this enabled.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed — thanks!

As noted in review, `integration-test-runner@` already receives
project-level permissions outside this Terraform module.

TAG=agy
CONV=4ecd3490-bbbe-499e-90e5-07ea5e14a460
@sigurdm

sigurdm commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

/gcbrun

@sigurdm
sigurdm merged commit cdc4967 into main Sep 17, 2026
29 of 30 checks passed
@sigurdm
sigurdm deleted the pubsub-gcb-integration branch September 17, 2026 09:42
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants