Skip to content

Commit 92a683e

Browse files
fix: Update logging library (GoogleCloudPlatform#6472)
* fix: Update logging library * lint * fix syntax * Update logging manual * Update test * Update e2e_test.py * Update e2e_test.py Co-authored-by: Dan Lee <71398022+dandhlee@users.noreply.github.com>
1 parent 90ad906 commit 92a683e

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

run/logging-manual/e2e_test.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import time
2323
import uuid
2424

25-
from google.cloud import logging_v2
25+
from google.cloud.logging_v2.services.logging_service_v2 import LoggingServiceV2Client
2626

2727
import pytest
2828

@@ -174,7 +174,7 @@ def test_end_to_end(service_url_auth_token, deployed_service):
174174

175175
# Test that the logs are writing properly to stackdriver
176176
time.sleep(10) # Slight delay writing to stackdriver
177-
client = logging_v2.LoggingServiceV2Client()
177+
client = LoggingServiceV2Client()
178178
resource_names = [f"projects/{PROJECT}"]
179179
# We add timestamp for making the query faster.
180180
now = datetime.datetime.now(datetime.timezone.utc)
@@ -188,12 +188,17 @@ def test_end_to_end(service_url_auth_token, deployed_service):
188188
)
189189

190190
# Retry a maximum number of 10 times to find results in stackdriver
191+
found = False
191192
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})
193194
for entry in iterator:
195+
found = True
194196
# If there are any results, exit loop
195197
break
198+
# When message found, exit loop
199+
if found:
200+
break
196201
# Linear backoff
197202
time.sleep(3 * x)
198203

199-
assert iterator.num_results
204+
assert found

run/pubsub/e2e_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
import uuid
2222

2323
from google.api_core.exceptions import NotFound
24-
from google.cloud import logging_v2
2524
from google.cloud import pubsub_v1
25+
from google.cloud.logging_v2.services.logging_service_v2 import LoggingServiceV2Client
2626

2727

2828
import pytest
@@ -196,7 +196,7 @@ def test_end_to_end(pubsub_topic):
196196

197197
# Check the logs for "Hello Runner"
198198
time.sleep(20) # Slight delay writing to stackdriver
199-
client = logging_v2.LoggingServiceV2Client()
199+
client = LoggingServiceV2Client()
200200
resource_names = [f"projects/{PROJECT}"]
201201

202202
# We add timestamp for making the query faster.
@@ -211,7 +211,7 @@ def test_end_to_end(pubsub_topic):
211211
# Retry a maximum number of 10 times to find results in stackdriver
212212
found = False
213213
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})
215215
for entry in iterator:
216216
if entry.text_payload == "Hello Runner!":
217217
found = True

0 commit comments

Comments
 (0)