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

Add retry for flaky 'topic.exists()' check. #2214

Merged
merged 1 commit into from
Aug 29, 2016
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
13 changes: 12 additions & 1 deletion system_tests/pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
import os
import unittest

from google.gax.errors import GaxError
from grpc import StatusCode
from grpc._channel import _Rendezvous
import httplib2

from gcloud import _helpers
Expand All @@ -24,10 +27,18 @@

from retry import RetryInstanceState
from retry import RetryResult
from retry import RetryErrors
from system_test_utils import EmulatorCreds
from system_test_utils import unique_resource_id


def _unavailable(exc):
return _helpers.exc_to_code(exc) == StatusCode.UNAVAILABLE


retry_unavailable = RetryErrors((GaxError, _Rendezvous), _unavailable)


class Config(object):
"""Run-time configuration to be modified at set-up.

Expand Down Expand Up @@ -124,7 +135,7 @@ def test_create_subscription_w_ack_deadline(self):
def test_list_subscriptions(self):
TOPIC_NAME = 'list-sub' + unique_resource_id('-')
topic = Config.CLIENT.topic(TOPIC_NAME)
self.assertFalse(topic.exists())
self.assertFalse(retry_unavailable(topic.exists)())
topic.create()
self.to_delete.append(topic)
empty, _ = topic.list_subscriptions()
Expand Down