Skip to content

Commit

Permalink
fix(sample-test): add backoff around the cleanup code (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
Takashi Matsuo authored Oct 16, 2020
1 parent 14571c7 commit 5b22fa8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions packages/google-cloud-dlp/samples/snippets/inspect_content_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
import os
import uuid

import backoff
import google.api_core.exceptions
from google.api_core.exceptions import ServiceUnavailable
import google.cloud.bigquery
import google.cloud.datastore
import google.cloud.dlp_v2
Expand Down Expand Up @@ -122,7 +124,11 @@ def datastore_project():

yield GCLOUD_PROJECT

datastore_client.delete(key)
@backoff.on_exception(backoff.expo, ServiceUnavailable, max_time=120)
def cleanup():
datastore_client.delete(key)

cleanup()


@pytest.fixture(scope="module")
Expand Down Expand Up @@ -157,7 +163,11 @@ def bigquery_project():

yield GCLOUD_PROJECT

bigquery_client.delete_dataset(dataset_ref, delete_contents=True)
@backoff.on_exception(backoff.expo, ServiceUnavailable, max_time=120)
def cleanup():
bigquery_client.delete_dataset(dataset_ref, delete_contents=True)

cleanup()


def test_inspect_string_basic(capsys):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
backoff==1.10.0
pytest==6.0.1
flaky==3.7.0
mock==4.0.2

0 comments on commit 5b22fa8

Please sign in to comment.