Skip to content

test(pubsub): add unit tests for AsyncPublisher hedging and Service cancellation - #36642

Draft
feywind wants to merge 1 commit into
hedging/queue-integrationfrom
hedging/queue-unit-tests
Draft

feywind wants to merge 1 commit into
hedging/queue-integrationfrom
hedging/queue-unit-tests

Conversation

@feywind

@feywind feywind commented Oct 16, 2026 •

Copy link
Copy Markdown

Stack Structure (Stack #36644)

Layer Branch PR
1 hedging/options-and-token-bucket #36639
2 hedging/coordinator-and-scheduler #36640
3 hedging/queue-integration #36641
4 hedging/queue-unit-tests #36642 (this PR)
5 hedging/system-tests #36643

Summary

Implements Layer 4 of Cloud Pub/Sub Publish Hedging (go/sdk:pubsub-hedging) for google-cloud-pubsub:

  • AsyncPublisher hedging unit tests (test/google/cloud/pubsub/async_publisher_hedging_test.rb):
    • Default and custom hedging configuration, enabled: false, bounds/timeout validation on AsyncPublisher.new and pubsub.publisher, mutual exclusion with enable_message_ordering!, and ordered batch bypass.
    • Cold-start empty token bucket (0.0), warmup to 1.0 token, hedge consumption, and rate-limited logging on pubsub:publish-hedged.
    • Race outcomes: hedged attempt 1 wins and cancels attempt 0; attempt 0 wins before hedge_delay; attempt 0 wins after hedge dispatch and cancels attempt 1; multiple hedging (attempt 2 wins and cancels attempt 0 and attempt 1).
    • Asymmetric error handling when a hedged attempt fails vs. when attempt 0 fails terminally.
  • Service#publish & TopicAdmin::Client cancellation unit tests (test/google/cloud/pubsub/service_test.rb):
    • Verifies CancellableRetryPolicy construction, mid-flight gRPC Operation#cancel without retrying GRPC::Cancelled, and immediate interruption of retry backoff sleep.

This branch has not been deployed

No deployments
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.

1 participant