Skip to content

Commit 9c1f6a9

Browse files
authored
CI: add flaky to exactly-once sample test and add a non-regional test (googleapis#638)
* add flaky annotation to regional_endpoint test * add new global exactly-once test
1 parent 32cc64a commit 9c1f6a9

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

samples/snippets/subscriber_test.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
SUBSCRIPTION_EOD = f"subscription-test-subscription-eod-{PY_VERSION}-{UUID}"
4444
ENDPOINT = f"https://{PROJECT_ID}.appspot.com/push"
4545
NEW_ENDPOINT = f"https://{PROJECT_ID}.appspot.com/push2"
46+
REGIONAL_ENDPOINT = "us-east1-pubsub.googleapis.com:443"
4647
DEFAULT_MAX_DELIVERY_ATTEMPTS = 5
4748
UPDATED_MAX_DELIVERY_ATTEMPTS = 20
4849
FILTER = 'attributes.author="unknown"'
@@ -59,7 +60,7 @@ def publisher_client() -> Generator[pubsub_v1.PublisherClient, None, None]:
5960

6061
@pytest.fixture(scope="module")
6162
def regional_publisher_client() -> Generator[pubsub_v1.PublisherClient, None, None]:
62-
client_options = {"api_endpoint": "us-east1-pubsub.googleapis.com:443"}
63+
client_options = {"api_endpoint": REGIONAL_ENDPOINT}
6364
publisher = pubsub_v1.PublisherClient(client_options=client_options)
6465
yield publisher
6566

@@ -703,7 +704,8 @@ def eventually_consistent_test() -> None:
703704
eventually_consistent_test()
704705

705706

706-
def test_receive_messages_with_exactly_once_delivery_enabled(
707+
@typed_flaky
708+
def test_receive_messages_with_exactly_once_delivery_enabled_regional_endpoint(
707709
regional_publisher_client: pubsub_v1.PublisherClient,
708710
exactly_once_delivery_topic: str,
709711
subscription_eod: str,
@@ -722,6 +724,25 @@ def test_receive_messages_with_exactly_once_delivery_enabled(
722724
assert message_id in out
723725

724726

727+
def test_receive_messages_with_exactly_once_delivery_enabled(
728+
publisher_client: pubsub_v1.PublisherClient,
729+
exactly_once_delivery_topic: str,
730+
subscription_eod: str,
731+
capsys: CaptureFixture[str],
732+
) -> None:
733+
734+
message_ids = _publish_messages(publisher_client, exactly_once_delivery_topic)
735+
736+
subscriber.receive_messages_with_exactly_once_delivery_enabled(
737+
PROJECT_ID, SUBSCRIPTION_EOD, 10
738+
)
739+
740+
out, _ = capsys.readouterr()
741+
assert subscription_eod in out
742+
for message_id in message_ids:
743+
assert message_id in out
744+
745+
725746
def test_listen_for_errors(
726747
publisher_client: pubsub_v1.PublisherClient,
727748
topic: str,

0 commit comments

Comments
 (0)