From 3bbd5ecfaed83c66a7a6dec20a6f41b3f3583159 Mon Sep 17 00:00:00 2001 From: Takashi Matsuo Date: Wed, 22 Jul 2020 13:51:56 -0700 Subject: [PATCH] testing(automl): retry upon InternalServerError [(#4350)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/4350) fixes #4343 --- samples/snippets/list_operation_status_test.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/samples/snippets/list_operation_status_test.py b/samples/snippets/list_operation_status_test.py index ff6a0973..aaeccaaf 100644 --- a/samples/snippets/list_operation_status_test.py +++ b/samples/snippets/list_operation_status_test.py @@ -14,6 +14,8 @@ import os +import backoff +from google.api_core.exceptions import InternalServerError import pytest import list_operation_status @@ -23,6 +25,11 @@ @pytest.mark.slow def test_list_operation_status(capsys): - list_operation_status.list_operation_status(PROJECT_ID) + # We saw 500 InternalServerError. Now we just retry few times. + @backoff.on_exception(backoff.expo, InternalServerError, max_time=120) + def run_sample(): + list_operation_status.list_operation_status(PROJECT_ID) + + run_sample() out, _ = capsys.readouterr() assert "Operation details" in out