Skip to content

Commit

Permalink
Merge pull request #2214 from tseaver/2111-pubsub-topic-exists-unavai…
Browse files Browse the repository at this point in the history
…lable

Add retry for flaky 'topic.exists()' check.
  • Loading branch information
tseaver authored Aug 29, 2016
2 parents 3784293 + 13a35cd commit e8c064b
Showing 1 changed file with 12 additions and 1 deletion.
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

0 comments on commit e8c064b

Please sign in to comment.