Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Samples(test): Extend timeout eod receive test #653

Merged
merged 7 commits into from
Apr 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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