Skip to content

Commit

Permalink
Deflake bigtable and spanner tests. [(#2224)](GoogleCloudPlatform/pyt…
Browse files Browse the repository at this point in the history
…hon-docs-samples#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.
  • Loading branch information
theacodes authored Jun 14, 2019
1 parent 8ef175a commit 2fcd9ee
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions samples/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

0 comments on commit 2fcd9ee

Please sign in to comment.