diff --git a/system_tests/pubsub.py b/system_tests/pubsub.py index 6a420fccd197..e544755a7440 100644 --- a/system_tests/pubsub.py +++ b/system_tests/pubsub.py @@ -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 @@ -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. @@ -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()