1515import os
1616import uuid
1717
18- from gcp_devrel . testing import eventually_consistent
18+ import backoff
1919from google .cloud import pubsub_v1
2020import pytest
2121
@@ -110,20 +110,24 @@ def subscription_async(subscriber_client, topic):
110110
111111
112112def test_list_in_topic (subscription_admin , capsys ):
113- @eventually_consistent . call
114- def _ ():
113+ @backoff . on_exception ( backoff . expo , AssertionError , max_time = 60 )
114+ def eventually_consistent_test ():
115115 subscriber .list_subscriptions_in_topic (PROJECT , TOPIC )
116116 out , _ = capsys .readouterr ()
117117 assert subscription_admin in out
118118
119+ eventually_consistent_test ()
120+
119121
120122def test_list_in_project (subscription_admin , capsys ):
121- @eventually_consistent . call
122- def _ ():
123+ @backoff . on_exception ( backoff . expo , AssertionError , max_time = 60 )
124+ def eventually_consistent_test ():
123125 subscriber .list_subscriptions_in_project (PROJECT )
124126 out , _ = capsys .readouterr ()
125127 assert subscription_admin in out
126128
129+ eventually_consistent_test ()
130+
127131
128132def test_create (subscriber_client ):
129133 subscription_path = subscriber_client .subscription_path (
@@ -137,10 +141,12 @@ def test_create(subscriber_client):
137141
138142 subscriber .create_subscription (PROJECT , TOPIC , SUBSCRIPTION_ADMIN )
139143
140- @eventually_consistent . call
141- def _ ():
144+ @backoff . on_exception ( backoff . expo , AssertionError , max_time = 60 )
145+ def eventually_consistent_test ():
142146 assert subscriber_client .get_subscription (subscription_path )
143147
148+ eventually_consistent_test ()
149+
144150
145151def test_create_push (subscriber_client ):
146152 subscription_path = subscriber_client .subscription_path (
@@ -155,10 +161,12 @@ def test_create_push(subscriber_client):
155161 PROJECT , TOPIC , SUBSCRIPTION_ADMIN , ENDPOINT
156162 )
157163
158- @eventually_consistent . call
159- def _ ():
164+ @backoff . on_exception ( backoff . expo , AssertionError , max_time = 60 )
165+ def eventually_consistent_test ():
160166 assert subscriber_client .get_subscription (subscription_path )
161167
168+ eventually_consistent_test ()
169+
162170
163171def test_update (subscriber_client , subscription_admin , capsys ):
164172 subscriber .update_subscription (PROJECT , SUBSCRIPTION_ADMIN , NEW_ENDPOINT )
@@ -170,11 +178,13 @@ def test_update(subscriber_client, subscription_admin, capsys):
170178def test_delete (subscriber_client , subscription_admin ):
171179 subscriber .delete_subscription (PROJECT , SUBSCRIPTION_ADMIN )
172180
173- @eventually_consistent . call
174- def _ ():
181+ @backoff . on_exception ( backoff . expo , AssertionError , max_time = 60 )
182+ def eventually_consistent_test ():
175183 with pytest .raises (Exception ):
176184 subscriber_client .get_subscription (subscription_admin )
177185
186+ eventually_consistent_test ()
187+
178188
179189def _publish_messages (publisher_client , topic ):
180190 for n in range (5 ):
0 commit comments