Skip to content

Commit

Permalink
Deflake bigtable and spanner tests. (#2224)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
theacodes authored Jun 14, 2019
1 parent 1ac7d42 commit 231be14
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
28 changes: 19 additions & 9 deletions bigtable/metricscaler/metricscaler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,27 @@ def test_scale_bigtable():

scale_bigtable(BIGTABLE_INSTANCE, BIGTABLE_INSTANCE, True)

time.sleep(10)
cluster.reload()

new_node_count = cluster.serve_nodes
assert (new_node_count == (original_node_count + SIZE_CHANGE_STEP))
for n in range(10):
time.sleep(10)
cluster.reload()
new_node_count = cluster.serve_nodes
try:
assert (new_node_count == (original_node_count + SIZE_CHANGE_STEP))
except AssertionError:
if n == 9:
raise

scale_bigtable(BIGTABLE_INSTANCE, BIGTABLE_INSTANCE, False)
time.sleep(10)
cluster.reload()
final_node_count = cluster.serve_nodes
assert final_node_count == original_node_count

for n in range(10):
time.sleep(10)
cluster.reload()
final_node_count = cluster.serve_nodes
try:
assert final_node_count == original_node_count
except AssertionError:
if n == 9:
raise


# Unit test for logic
Expand Down
4 changes: 3 additions & 1 deletion spanner/cloud-client/snippets_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ def test_query_with_struct(capsys):
def test_query_with_array_of_struct(capsys):
snippets.query_with_array_of_struct(INSTANCE_ID, DATABASE_ID)
out, _ = capsys.readouterr()
assert 'SingerId: 8\nSingerId: 7\nSingerId: 6' in out
assert 'SingerId: 8' in out
assert 'SingerId: 7' in out
assert 'SingerId: 6' in out


def test_query_struct_field(capsys):
Expand Down

0 comments on commit 231be14

Please sign in to comment.