Skip to content

Commit

Permalink
samples(test): fix flaky sync pull test (#434)
Browse files Browse the repository at this point in the history
* samples(test): flaky sync pull test

* address peter's comment
  • Loading branch information
anguillanneuf authored Jun 23, 2021
1 parent 05e3f2f commit 86f1f68
Showing 1 changed file with 8 additions and 1 deletion.
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)
subscriber.synchronous_pull_with_lease_management(PROJECT_ID, SUBSCRIPTION_SYNC)

run_sample()
Expand Down

0 comments on commit 86f1f68

Please sign in to comment.