Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

docs: adding backoff to quickstart test #135

Merged
merged 3 commits into from Mar 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion samples/snippets/quickstart/quickstart_test.py
Expand Up @@ -15,6 +15,8 @@
import os
import uuid

import backoff
from google.api_core.exceptions import ServiceUnavailable
from google.cloud import dataproc_v1 as dataproc
from google.cloud import storage
import pytest
Expand All @@ -39,7 +41,14 @@
@pytest.fixture(autouse=True)
def setup_teardown():
storage_client = storage.Client()
bucket = storage_client.create_bucket(STAGING_BUCKET)

@backoff.on_exception(backoff.expo,
ServiceUnavailable,
max_tries=5)
def create_bucket():
return storage_client.create_bucket(STAGING_BUCKET)

bucket = create_bucket()
blob = bucket.blob(JOB_FILE_NAME)
blob.upload_from_string(SORT_CODE)

Expand Down
2 changes: 2 additions & 0 deletions samples/snippets/requirements.txt
@@ -1,3 +1,5 @@

backoff==1.10.0
grpcio==1.36.0
google-auth==1.27.0
google-auth-httplib2==0.0.4
Expand Down