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): flaky sync pull test #434

Merged
merged 2 commits into from
Jun 23, 2021
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
9 changes: 8 additions & 1 deletion samples/snippets/subscriber_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import os
import re
import sys
import time
import uuid

import backoff
Expand Down Expand Up @@ -475,7 +476,13 @@ def test_receive_synchronously_with_lease(
):
@backoff.on_exception(backoff.expo, Unknown, max_time=300)
def run_sample():
_publish_messages(publisher_client, topic, message_num=3)
_publish_messages(publisher_client, topic, message_num=10)
# Pausing 10s to allow the subscriber to establish the connection
# because sync pull often returns fewer messages than requested.
# The intention is to fix flaky tests reporting errors like
# `google.api_core.exceptions.Unknown: None Stream removed` as
# in https://github.com/googleapis/python-pubsub/issues/341.
time.sleep(10)
Copy link
Contributor

@plamut plamut Jun 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a comment why this is needed?

Waiting for a fixed amount of time is of course far from ideal, but if it resolves or at least significantly mitigates the flakiness, it's fine to have it, as flakiness has really been getting into the way recently.

Edit: Whoa, samples tests passed on the first attempt. Could be a coincidence, of course, but it's a good start nevertheless. 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment. Please take a look now to see if it's sufficient.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

subscriber.synchronous_pull_with_lease_management(PROJECT_ID, SUBSCRIPTION_SYNC)

run_sample()
Expand Down