15
15
import os
16
16
import uuid
17
17
18
- from gcp_devrel . testing import eventually_consistent
18
+ import backoff
19
19
from google .cloud import pubsub_v1
20
20
import pytest
21
21
@@ -110,20 +110,24 @@ def subscription_async(subscriber_client, topic):
110
110
111
111
112
112
def 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 ():
115
115
subscriber .list_subscriptions_in_topic (PROJECT , TOPIC )
116
116
out , _ = capsys .readouterr ()
117
117
assert subscription_admin in out
118
118
119
+ eventually_consistent_test ()
120
+
119
121
120
122
def 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 ():
123
125
subscriber .list_subscriptions_in_project (PROJECT )
124
126
out , _ = capsys .readouterr ()
125
127
assert subscription_admin in out
126
128
129
+ eventually_consistent_test ()
130
+
127
131
128
132
def test_create (subscriber_client ):
129
133
subscription_path = subscriber_client .subscription_path (
@@ -137,10 +141,12 @@ def test_create(subscriber_client):
137
141
138
142
subscriber .create_subscription (PROJECT , TOPIC , SUBSCRIPTION_ADMIN )
139
143
140
- @eventually_consistent . call
141
- def _ ():
144
+ @backoff . on_exception ( backoff . expo , AssertionError , max_time = 60 )
145
+ def eventually_consistent_test ():
142
146
assert subscriber_client .get_subscription (subscription_path )
143
147
148
+ eventually_consistent_test ()
149
+
144
150
145
151
def test_create_push (subscriber_client ):
146
152
subscription_path = subscriber_client .subscription_path (
@@ -155,10 +161,12 @@ def test_create_push(subscriber_client):
155
161
PROJECT , TOPIC , SUBSCRIPTION_ADMIN , ENDPOINT
156
162
)
157
163
158
- @eventually_consistent . call
159
- def _ ():
164
+ @backoff . on_exception ( backoff . expo , AssertionError , max_time = 60 )
165
+ def eventually_consistent_test ():
160
166
assert subscriber_client .get_subscription (subscription_path )
161
167
168
+ eventually_consistent_test ()
169
+
162
170
163
171
def test_update (subscriber_client , subscription_admin , capsys ):
164
172
subscriber .update_subscription (PROJECT , SUBSCRIPTION_ADMIN , NEW_ENDPOINT )
@@ -170,11 +178,13 @@ def test_update(subscriber_client, subscription_admin, capsys):
170
178
def test_delete (subscriber_client , subscription_admin ):
171
179
subscriber .delete_subscription (PROJECT , SUBSCRIPTION_ADMIN )
172
180
173
- @eventually_consistent . call
174
- def _ ():
181
+ @backoff . on_exception ( backoff . expo , AssertionError , max_time = 60 )
182
+ def eventually_consistent_test ():
175
183
with pytest .raises (Exception ):
176
184
subscriber_client .get_subscription (subscription_admin )
177
185
186
+ eventually_consistent_test ()
187
+
178
188
179
189
def _publish_messages (publisher_client , topic ):
180
190
for n in range (5 ):
0 commit comments