Skip to content

Commit d5d980a

Browse files
authored
add backoff to fix flaky test (GoogleCloudPlatform#8054)
* add backoff to fix flaky test * fix lint
1 parent 3b73e71 commit d5d980a

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

composer/2022_airflow_summit/data_analytics_process_test.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
import os
2121
import uuid
2222

23-
from google.api_core.exceptions import NotFound
23+
import backoff
24+
from google.api_core.exceptions import Aborted, NotFound
2425
from google.cloud import bigquery
2526
from google.cloud import dataproc_v1 as dataproc
2627
from google.cloud import storage
@@ -122,13 +123,13 @@ def bq_dataset(test_bucket):
122123
print(f"Ignoring NotFound on cleanup, details: {e}")
123124

124125

126+
# Retry if we see a flaky 409 "subnet not ready" exception
127+
@backoff.on_exception(backoff.expo, Aborted, max_tries=3)
125128
def test_process(test_bucket):
126129
# check that the results table isnt there
127130
with pytest.raises(NotFound):
128131
BQ_CLIENT.get_table(f"{BQ_DATASET}.{BQ_WRITE_TABLE}")
129132

130-
# do the process
131-
# assert the column is there
132133
# create a batch
133134
dataproc_client = dataproc.BatchControllerClient(
134135
client_options={
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
pytest==7.0.1
22
cloud-composer-dag-test-utils==1.0.0
33
markupsafe==2.0.1
4+
backoff==2.0.1

0 commit comments

Comments
 (0)