File tree Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change 22
22
import time
23
23
import uuid
24
24
25
- from google .cloud import logging_v2
25
+ from google .cloud . logging_v2 . services . logging_service_v2 import LoggingServiceV2Client
26
26
27
27
import pytest
28
28
@@ -174,7 +174,7 @@ def test_end_to_end(service_url_auth_token, deployed_service):
174
174
175
175
# Test that the logs are writing properly to stackdriver
176
176
time .sleep (10 ) # Slight delay writing to stackdriver
177
- client = logging_v2 . LoggingServiceV2Client ()
177
+ client = LoggingServiceV2Client ()
178
178
resource_names = [f"projects/{ PROJECT } " ]
179
179
# We add timestamp for making the query faster.
180
180
now = datetime .datetime .now (datetime .timezone .utc )
@@ -188,12 +188,17 @@ def test_end_to_end(service_url_auth_token, deployed_service):
188
188
)
189
189
190
190
# Retry a maximum number of 10 times to find results in stackdriver
191
+ found = False
191
192
for x in range (10 ):
192
- iterator = client .list_log_entries (resource_names , filter_ = filters )
193
+ iterator = client .list_log_entries ({ " resource_names" : resource_names , "filter" : filters } )
193
194
for entry in iterator :
195
+ found = True
194
196
# If there are any results, exit loop
195
197
break
198
+ # When message found, exit loop
199
+ if found :
200
+ break
196
201
# Linear backoff
197
202
time .sleep (3 * x )
198
203
199
- assert iterator . num_results
204
+ assert found
Original file line number Diff line number Diff line change 21
21
import uuid
22
22
23
23
from google .api_core .exceptions import NotFound
24
- from google .cloud import logging_v2
25
24
from google .cloud import pubsub_v1
25
+ from google .cloud .logging_v2 .services .logging_service_v2 import LoggingServiceV2Client
26
26
27
27
28
28
import pytest
@@ -196,7 +196,7 @@ def test_end_to_end(pubsub_topic):
196
196
197
197
# Check the logs for "Hello Runner"
198
198
time .sleep (20 ) # Slight delay writing to stackdriver
199
- client = logging_v2 . LoggingServiceV2Client ()
199
+ client = LoggingServiceV2Client ()
200
200
resource_names = [f"projects/{ PROJECT } " ]
201
201
202
202
# We add timestamp for making the query faster.
@@ -211,7 +211,7 @@ def test_end_to_end(pubsub_topic):
211
211
# Retry a maximum number of 10 times to find results in stackdriver
212
212
found = False
213
213
for x in range (10 ):
214
- iterator = client .list_log_entries (resource_names , filter_ = filters )
214
+ iterator = client .list_log_entries ({ " resource_names" : resource_names , "filter" : filters } )
215
215
for entry in iterator :
216
216
if entry .text_payload == "Hello Runner!" :
217
217
found = True
You can’t perform that action at this time.
0 commit comments