Skip to content

Commit 231be14

Browse files
authored
Deflake bigtable and spanner tests. (#2224)
* Spanner doesn't actually promise the order of the results, so make the assertion work regardless of ordering. * Bigtable might need some more time to scale, so retry the assertion up to 10 times.
1 parent 1ac7d42 commit 231be14

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

bigtable/metricscaler/metricscaler_test.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,27 @@ def test_scale_bigtable():
4646

4747
scale_bigtable(BIGTABLE_INSTANCE, BIGTABLE_INSTANCE, True)
4848

49-
time.sleep(10)
50-
cluster.reload()
51-
52-
new_node_count = cluster.serve_nodes
53-
assert (new_node_count == (original_node_count + SIZE_CHANGE_STEP))
49+
for n in range(10):
50+
time.sleep(10)
51+
cluster.reload()
52+
new_node_count = cluster.serve_nodes
53+
try:
54+
assert (new_node_count == (original_node_count + SIZE_CHANGE_STEP))
55+
except AssertionError:
56+
if n == 9:
57+
raise
5458

5559
scale_bigtable(BIGTABLE_INSTANCE, BIGTABLE_INSTANCE, False)
56-
time.sleep(10)
57-
cluster.reload()
58-
final_node_count = cluster.serve_nodes
59-
assert final_node_count == original_node_count
60+
61+
for n in range(10):
62+
time.sleep(10)
63+
cluster.reload()
64+
final_node_count = cluster.serve_nodes
65+
try:
66+
assert final_node_count == original_node_count
67+
except AssertionError:
68+
if n == 9:
69+
raise
6070

6171

6272
# Unit test for logic

spanner/cloud-client/snippets_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,9 @@ def test_query_with_struct(capsys):
202202
def test_query_with_array_of_struct(capsys):
203203
snippets.query_with_array_of_struct(INSTANCE_ID, DATABASE_ID)
204204
out, _ = capsys.readouterr()
205-
assert 'SingerId: 8\nSingerId: 7\nSingerId: 6' in out
205+
assert 'SingerId: 8' in out
206+
assert 'SingerId: 7' in out
207+
assert 'SingerId: 6' in out
206208

207209

208210
def test_query_struct_field(capsys):

0 commit comments

Comments
 (0)