Skip to content

Commit 96ccfbe

Browse files
author
Takashi Matsuo
authored
fix(datastore): longer LRO timeout (GoogleCloudPlatform#5426)
* fix(datastore): longer LRO timeout fixes GoogleCloudPlatform#5250 also remove unnecessarily long `max_time`. * also bump the max_time for snippet tests * remove commas from the license header * use namespace for Task tests * lint * use uuid for namespace
1 parent 29d877a commit 96ccfbe

File tree

6 files changed

+35
-28
lines changed

6 files changed

+35
-28
lines changed

datastore/cloud-client/admin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2016, Google, Inc.
1+
# Copyright 2016 Google, Inc.
22
# Licensed under the Apache License, Version 2.0 (the "License");
33
# you may not use this file except in compliance with the License.
44
# You may obtain a copy of the License at
@@ -39,7 +39,7 @@ def export_entities(project_id, output_url_prefix):
3939
op = client.export_entities(
4040
{"project_id": project_id, "output_url_prefix": output_url_prefix}
4141
)
42-
response = op.result(timeout=200)
42+
response = op.result(timeout=300)
4343

4444
print("Entities were exported\n")
4545
return response
@@ -58,7 +58,7 @@ def import_entities(project_id, input_url):
5858
op = client.import_entities(
5959
{"project_id": project_id, "input_url": input_url}
6060
)
61-
response = op.result(timeout=200)
61+
response = op.result(timeout=300)
6262

6363
print("Entities were imported\n")
6464
return response

datastore/cloud-client/admin_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2016, Google, Inc.
1+
# Copyright 2016 Google, Inc.
22
# Licensed under the Apache License, Version 2.0 (the "License");
33
# you may not use this file except in compliance with the License.
44
# You may obtain a copy of the License at
@@ -40,7 +40,7 @@ def test_get_index(self):
4040
def test_list_index(self):
4141
assert admin.list_indexes(PROJECT)
4242

43-
@backoff.on_exception(backoff.expo, AssertionError, max_tries=3, max_time=540000)
43+
@backoff.on_exception(backoff.expo, AssertionError, max_tries=3)
4444
def test_export_import_entities(self):
4545
response = admin.export_entities(PROJECT, "gs://" + BUCKET)
4646
assert response

datastore/cloud-client/snippets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2016, Google, Inc.
1+
# Copyright 2016 Google, Inc.
22
# Licensed under the Apache License, Version 2.0 (the "License");
33
# you may not use this file except in compliance with the License.
44
# You may obtain a copy of the License at

datastore/cloud-client/snippets_test.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2015, Google, Inc.
1+
# Copyright 2015 Google, Inc.
22
# Licensed under the Apache License, Version 2.0 (the "License");
33
# you may not use this file except in compliance with the License.
44
# You may obtain a copy of the License at
@@ -106,19 +106,19 @@ def test_batch_lookup(self, client):
106106
def test_batch_delete(self, client):
107107
snippets.batch_delete(client)
108108

109-
@backoff.on_exception(backoff.expo, AssertionError, max_time=120)
109+
@backoff.on_exception(backoff.expo, AssertionError, max_time=240)
110110
def test_unindexed_property_query(self, client):
111111
tasks = snippets.unindexed_property_query(client)
112112
client.entities_to_delete.extend(tasks)
113113
assert tasks
114114

115-
@backoff.on_exception(backoff.expo, AssertionError, max_time=120)
115+
@backoff.on_exception(backoff.expo, AssertionError, max_time=240)
116116
def test_basic_query(self, client):
117117
tasks = snippets.basic_query(client)
118118
client.entities_to_delete.extend(tasks)
119119
assert tasks
120120

121-
@backoff.on_exception(backoff.expo, AssertionError, max_time=120)
121+
@backoff.on_exception(backoff.expo, AssertionError, max_time=240)
122122
def test_projection_query(self, client):
123123
priorities, percents = snippets.projection_query(client)
124124
client.entities_to_delete.extend(client.query(kind="Task").fetch())
@@ -137,7 +137,7 @@ def test_cursor_paging(self, client):
137137
for n in range(6):
138138
client.entities_to_delete.append(snippets.insert(client))
139139

140-
@backoff.on_exception(backoff.expo, AssertionError, max_time=120)
140+
@backoff.on_exception(backoff.expo, AssertionError, max_time=240)
141141
def run_sample():
142142
results = snippets.cursor_paging(client)
143143
page_one, cursor_one, page_two, cursor_two = results
@@ -148,49 +148,49 @@ def run_sample():
148148

149149
run_sample()
150150

151-
@backoff.on_exception(backoff.expo, AssertionError, max_time=120)
151+
@backoff.on_exception(backoff.expo, AssertionError, max_time=240)
152152
def test_property_filter(self, client):
153153
tasks = snippets.property_filter(client)
154154
client.entities_to_delete.extend(tasks)
155155
assert tasks
156156

157-
@backoff.on_exception(backoff.expo, AssertionError, max_time=120)
157+
@backoff.on_exception(backoff.expo, AssertionError, max_time=240)
158158
def test_composite_filter(self, client):
159159
tasks = snippets.composite_filter(client)
160160
client.entities_to_delete.extend(tasks)
161161
assert tasks
162162

163-
@backoff.on_exception(backoff.expo, AssertionError, max_time=120)
163+
@backoff.on_exception(backoff.expo, AssertionError, max_time=240)
164164
def test_key_filter(self, client):
165165
tasks = snippets.key_filter(client)
166166
client.entities_to_delete.extend(tasks)
167167
assert tasks
168168

169-
@backoff.on_exception(backoff.expo, AssertionError, max_time=120)
169+
@backoff.on_exception(backoff.expo, AssertionError, max_time=240)
170170
def test_ascending_sort(self, client):
171171
tasks = snippets.ascending_sort(client)
172172
client.entities_to_delete.extend(tasks)
173173
assert tasks
174174

175-
@backoff.on_exception(backoff.expo, AssertionError, max_time=120)
175+
@backoff.on_exception(backoff.expo, AssertionError, max_time=240)
176176
def test_descending_sort(self, client):
177177
tasks = snippets.descending_sort(client)
178178
client.entities_to_delete.extend(tasks)
179179
assert tasks
180180

181-
@backoff.on_exception(backoff.expo, AssertionError, max_time=120)
181+
@backoff.on_exception(backoff.expo, AssertionError, max_time=240)
182182
def test_multi_sort(self, client):
183183
tasks = snippets.multi_sort(client)
184184
client.entities_to_delete.extend(tasks)
185185
assert tasks
186186

187-
@backoff.on_exception(backoff.expo, AssertionError, max_time=120)
187+
@backoff.on_exception(backoff.expo, AssertionError, max_time=240)
188188
def test_keys_only_query(self, client):
189189
keys = snippets.keys_only_query(client)
190190
client.entities_to_delete.extend(client.query(kind="Task").fetch())
191191
assert keys
192192

193-
@backoff.on_exception(backoff.expo, AssertionError, max_time=120)
193+
@backoff.on_exception(backoff.expo, AssertionError, max_time=240)
194194
def test_distinct_on_query(self, client):
195195
tasks = snippets.distinct_on_query(client)
196196
client.entities_to_delete.extend(tasks)
@@ -246,33 +246,33 @@ def transactional_single_entity_group_read_only(self, client):
246246
assert task_list
247247
assert tasks_in_list
248248

249-
@backoff.on_exception(backoff.expo, AssertionError, max_time=120)
249+
@backoff.on_exception(backoff.expo, AssertionError, max_time=240)
250250
def test_namespace_run_query(self, client):
251251
all_namespaces, filtered_namespaces = snippets.namespace_run_query(client)
252252
assert all_namespaces
253253
assert filtered_namespaces
254254
assert "google" in filtered_namespaces
255255

256-
@backoff.on_exception(backoff.expo, AssertionError, max_time=120)
256+
@backoff.on_exception(backoff.expo, AssertionError, max_time=240)
257257
def test_kind_run_query(self, client):
258258
kinds = snippets.kind_run_query(client)
259259
client.entities_to_delete.extend(client.query(kind="Task").fetch())
260260
assert kinds
261261
assert "Task" in kinds
262262

263-
@backoff.on_exception(backoff.expo, AssertionError, max_time=120)
263+
@backoff.on_exception(backoff.expo, AssertionError, max_time=240)
264264
def test_property_run_query(self, client):
265265
kinds = snippets.property_run_query(client)
266266
client.entities_to_delete.extend(client.query(kind="Task").fetch())
267267
assert kinds
268268
assert "Task" in kinds
269269

270-
@backoff.on_exception(backoff.expo, AssertionError, max_time=120)
270+
@backoff.on_exception(backoff.expo, AssertionError, max_time=240)
271271
def test_property_by_kind_run_query(self, client):
272272
reprs = snippets.property_by_kind_run_query(client)
273273
client.entities_to_delete.extend(client.query(kind="Task").fetch())
274274
assert reprs
275275

276-
@backoff.on_exception(backoff.expo, AssertionError, max_time=120)
276+
@backoff.on_exception(backoff.expo, AssertionError, max_time=240)
277277
def test_index_merge_queries(self, client):
278278
snippets.index_merge_queries(client)

datastore/cloud-client/tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2016, Google, Inc.
1+
# Copyright 2016 Google, Inc.
22
# Licensed under the Apache License, Version 2.0 (the "License");
33
# you may not use this file except in compliance with the License.
44
# You may obtain a copy of the License at

datastore/cloud-client/tasks_test.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2015, Google, Inc.
1+
# Copyright 2015 Google, Inc.
22
# Licensed under the Apache License, Version 2.0 (the "License");
33
# you may not use this file except in compliance with the License.
44
# You may obtain a copy of the License at
@@ -12,6 +12,7 @@
1212
# limitations under the License.
1313

1414
import os
15+
import uuid
1516

1617
import backoff
1718
from google.cloud import datastore
@@ -24,11 +25,17 @@
2425

2526
@pytest.yield_fixture
2627
def client():
27-
client = datastore.Client(PROJECT)
28+
# We use namespace for isolating builds.
29+
namespace = uuid.uuid4().hex
30+
client = datastore.Client(PROJECT, namespace=namespace)
31+
32+
# Delete anything created during the tests in the past.
33+
with client.batch():
34+
client.delete_multi([x.key for x in client.query(kind="Task").fetch()])
2835

2936
yield client
3037

31-
# Delete anything created during the test.
38+
# Delete anything created during the tests.
3239
with client.batch():
3340
client.delete_multi([x.key for x in client.query(kind="Task").fetch()])
3441

0 commit comments

Comments
 (0)