From a65eec1faccc7a5e418a80a9762e047d2b61fe8c Mon Sep 17 00:00:00 2001 From: Anna Cocuzzo <63511057+acocuzzo@users.noreply.github.com> Date: Wed, 13 Apr 2022 17:08:32 -0400 Subject: [PATCH] Samples(test): Extend timeout eod receive test (#653) * Samples(test): Mark eod test super_flaky and extend timeout --- samples/snippets/subscriber_test.py | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/samples/snippets/subscriber_test.py b/samples/snippets/subscriber_test.py index 5a5062564..868720fd4 100644 --- a/samples/snippets/subscriber_test.py +++ b/samples/snippets/subscriber_test.py @@ -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") @@ -704,6 +705,7 @@ 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, @@ -711,26 +713,18 @@ def test_receive_messages_with_exactly_once_delivery_enabled( 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(