18
18
import backoff
19
19
from google .api_core .exceptions import InternalServerError
20
20
from google .api_core .exceptions import NotFound
21
+ from google .api_core .exceptions import ServiceUnavailable
21
22
import pytest
22
23
23
24
import snippets
@@ -67,36 +68,42 @@ def eventually_consistent_test():
67
68
assert "Deleted metric" in out
68
69
69
70
71
+ @backoff .on_exception (backoff .expo , (ServiceUnavailable ), max_tries = 3 )
70
72
def test_list_metric_descriptors (capsys ):
71
73
snippets .list_metric_descriptors (PROJECT_ID )
72
74
out , _ = capsys .readouterr ()
73
75
assert "logging.googleapis.com/byte_count" in out
74
76
75
77
78
+ @backoff .on_exception (backoff .expo , (ServiceUnavailable ), max_tries = 3 )
76
79
def test_list_resources (capsys ):
77
80
snippets .list_monitored_resources (PROJECT_ID )
78
81
out , _ = capsys .readouterr ()
79
82
assert "pubsub_topic" in out
80
83
81
84
85
+ @backoff .on_exception (backoff .expo , (ServiceUnavailable ), max_tries = 3 )
82
86
def test_get_resources (capsys ):
83
87
snippets .get_monitored_resource_descriptor (PROJECT_ID , "pubsub_topic" )
84
88
out , _ = capsys .readouterr ()
85
89
assert "A topic in Google Cloud Pub/Sub" in out
86
90
87
91
92
+ @backoff .on_exception (backoff .expo , (ServiceUnavailable ), max_tries = 3 )
88
93
def test_list_time_series (capsys , write_time_series ):
89
94
snippets .list_time_series (PROJECT_ID )
90
95
out , _ = capsys .readouterr ()
91
96
assert "gce_instance" in out
92
97
93
98
99
+ @backoff .on_exception (backoff .expo , (ServiceUnavailable ), max_tries = 3 )
94
100
def test_list_time_series_header (capsys , write_time_series ):
95
101
snippets .list_time_series_header (PROJECT_ID )
96
102
out , _ = capsys .readouterr ()
97
103
assert "gce_instance" in out
98
104
99
105
106
+ @backoff .on_exception (backoff .expo , (ServiceUnavailable ), max_tries = 3 )
100
107
def test_list_time_series_aggregate (capsys , write_time_series ):
101
108
snippets .list_time_series_aggregate (PROJECT_ID )
102
109
out , _ = capsys .readouterr ()
@@ -106,6 +113,7 @@ def test_list_time_series_aggregate(capsys, write_time_series):
106
113
assert "end_time" in out
107
114
108
115
116
+ @backoff .on_exception (backoff .expo , (ServiceUnavailable ), max_tries = 3 )
109
117
def test_list_time_series_reduce (capsys , write_time_series ):
110
118
snippets .list_time_series_reduce (PROJECT_ID )
111
119
out , _ = capsys .readouterr ()
0 commit comments