Skip to content

Commit ba80c32

Browse files
authored
docs: adding backoff to quickstart test (#135)
* adding backoff to quickstart test * fixing lint
1 parent b86ebf8 commit ba80c32

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

dataproc/snippets/quickstart/quickstart_test.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import os
1616
import uuid
1717

18+
import backoff
19+
from google.api_core.exceptions import ServiceUnavailable
1820
from google.cloud import dataproc_v1 as dataproc
1921
from google.cloud import storage
2022
import pytest
@@ -39,7 +41,14 @@
3941
@pytest.fixture(autouse=True)
4042
def setup_teardown():
4143
storage_client = storage.Client()
42-
bucket = storage_client.create_bucket(STAGING_BUCKET)
44+
45+
@backoff.on_exception(backoff.expo,
46+
ServiceUnavailable,
47+
max_tries=5)
48+
def create_bucket():
49+
return storage_client.create_bucket(STAGING_BUCKET)
50+
51+
bucket = create_bucket()
4352
blob = bucket.blob(JOB_FILE_NAME)
4453
blob.upload_from_string(SORT_CODE)
4554

dataproc/snippets/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2+
backoff==1.10.0
13
grpcio==1.36.0
24
google-auth==1.27.0
35
google-auth-httplib2==0.0.4

0 commit comments

Comments
 (0)