From 46ac39b82ea149883c8b5adb0f3b817ec49367e0 Mon Sep 17 00:00:00 2001 From: Takashi Matsuo Date: Fri, 18 Sep 2020 18:14:02 +0000 Subject: [PATCH] fix(monitoring): retry in the test setup [(#4702)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/4702) fixes #4687 fixes #4688 fixes #4689 fixes #4690 --- samples/snippets/v3/cloud-client/snippets_test.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/samples/snippets/v3/cloud-client/snippets_test.py b/samples/snippets/v3/cloud-client/snippets_test.py index 23e457cd..5aabbda8 100644 --- a/samples/snippets/v3/cloud-client/snippets_test.py +++ b/samples/snippets/v3/cloud-client/snippets_test.py @@ -16,6 +16,7 @@ import re import backoff +from google.api_core.exceptions import InternalServerError from google.api_core.exceptions import NotFound import pytest @@ -42,7 +43,12 @@ def custom_metric_descriptor(capsys): @pytest.fixture(scope="module") def write_time_series(): - snippets.write_time_series(PROJECT_ID) + + @backoff.on_exception(backoff.expo, InternalServerError, max_time=120) + def write(): + snippets.write_time_series(PROJECT_ID) + + write() yield