Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions monitoring/api/v3/api-client/custom_metric_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,15 @@ def test_custom_metric(client, custom_metric):
# Use a constant seed so psuedo random number is known ahead of time
random.seed(1)
pseudo_random_value = random.randint(0, 10)
# Reseed it
random.seed(1)

INSTANCE_ID = "test_instance"

# It's rare, but write can fail with HttpError 500, so we retry.
@backoff.on_exception(backoff.expo, HttpError, max_time=120)
def write_value():
# Reseed it to make sure the sample code will pick the same
# value.
random.seed(1)
write_timeseries_value(client, PROJECT_RESOURCE,
METRIC_RESOURCE, INSTANCE_ID,
METRIC_KIND)
Expand All @@ -108,6 +109,6 @@ def eventually_consistent_test():
value = int(
response['timeSeries'][0]['points'][0]['value']['int64Value'])
# using seed of 1 will create a value of 1
assert value == pseudo_random_value
assert pseudo_random_value == value

eventually_consistent_test()