Skip to content

Commit

Permalink
Samples(test): Extend timeout eod receive test (#653)
Browse files Browse the repository at this point in the history
* Samples(test): Mark eod test super_flaky and extend timeout
  • Loading branch information
acocuzzo authored Apr 13, 2022
1 parent 6a81d74 commit a65eec1
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions samples/snippets/subscriber_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
C = TypeVar("C", bound=Callable[..., Any])

typed_flaky = cast(Callable[[C], C], flaky(max_runs=3, min_passes=1))
typed_super_flaky = cast(Callable[[C], C], flaky(max_runs=10, min_passes=10))


@pytest.fixture(scope="module")
Expand Down Expand Up @@ -704,33 +705,26 @@ def eventually_consistent_test() -> None:
eventually_consistent_test()


@typed_super_flaky
def test_receive_messages_with_exactly_once_delivery_enabled(
regional_publisher_client: pubsub_v1.PublisherClient,
exactly_once_delivery_topic: str,
subscription_eod: str,
capsys: CaptureFixture[str],
) -> None:

typed_backoff = cast(
Callable[[C], C], backoff.on_exception(backoff.expo, Unknown, max_time=300),
message_ids = _publish_messages(
regional_publisher_client, exactly_once_delivery_topic
)

@typed_backoff
def eventually_consistent_test() -> None:
message_ids = _publish_messages(
regional_publisher_client, exactly_once_delivery_topic
)

subscriber.receive_messages_with_exactly_once_delivery_enabled(
PROJECT_ID, SUBSCRIPTION_EOD, 10
)

out, _ = capsys.readouterr()
assert subscription_eod in out
for message_id in message_ids:
assert message_id in out
subscriber.receive_messages_with_exactly_once_delivery_enabled(
PROJECT_ID, SUBSCRIPTION_EOD, 200
)

eventually_consistent_test()
out, _ = capsys.readouterr()
assert subscription_eod in out
for message_id in message_ids:
assert message_id in out


def test_listen_for_errors(
Expand Down

0 comments on commit a65eec1

Please sign in to comment.