From 69f9cead914046266085f16e4181f4d16a98e425 Mon Sep 17 00:00:00 2001 From: Diego Hurtado Date: Thu, 3 Feb 2022 10:01:55 -0600 Subject: [PATCH] Mark test as flaky Fixes #2436 --- dev-requirements.txt | 1 + .../tests/metrics/test_periodic_exporting_metric_reader.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index 44e20801416..b0db3ff7a20 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -13,3 +13,4 @@ readme-renderer~=24.0 grpcio-tools~=1.41.0 mypy-protobuf~=3.0.0 protobuf~=3.18.1 +flaky>=3.7.0 diff --git a/opentelemetry-sdk/tests/metrics/test_periodic_exporting_metric_reader.py b/opentelemetry-sdk/tests/metrics/test_periodic_exporting_metric_reader.py index ca7a1676308..4552a69063f 100644 --- a/opentelemetry-sdk/tests/metrics/test_periodic_exporting_metric_reader.py +++ b/opentelemetry-sdk/tests/metrics/test_periodic_exporting_metric_reader.py @@ -15,6 +15,8 @@ import time from unittest.mock import Mock +from flaky import flaky + from opentelemetry.sdk._metrics.export import ( MetricExporter, PeriodicExportingMetricReader, @@ -99,13 +101,14 @@ def test_ticker_called(self): self.assertTrue(collect_mock.assert_called_once) pmr.shutdown() + @flaky(max_runs=3, min_passes=1) def test_ticker_collects_metrics(self): exporter = FakeMetricsExporter() pmr = self._create_periodic_reader( metrics_list, exporter, interval=100 ) - time.sleep(0.11) + time.sleep(0.15) self.assertEqual(exporter.metrics, metrics_list) pmr.shutdown()