diff --git a/sdks/python/apache_beam/runners/worker/statesampler_test.py b/sdks/python/apache_beam/runners/worker/statesampler_test.py index 176f6e52b407..97fe6d97c0cf 100644 --- a/sdks/python/apache_beam/runners/worker/statesampler_test.py +++ b/sdks/python/apache_beam/runners/worker/statesampler_test.py @@ -95,6 +95,9 @@ def test_basic_sampler(self): self.assertGreater(actual_value, expected_value * (1.0 - margin_of_error)) self.assertLess(actual_value, expected_value * (1.0 + margin_of_error)) + # TODO: This test is flaky when it is run under load. A better solution + # would be to change the test structure to not depend on specific timings. + @retry(reraise=True, stop=stop_after_attempt(3)) def test_sampler_transition_overhead(self): # Set up state sampler. counter_factory = CounterFactory() @@ -117,6 +120,11 @@ def test_sampler_transition_overhead(self): elapsed_time = time.time() - start_time state_transition_count = sampler.get_info().transition_count overhead_us = 1000000.0 * elapsed_time / state_transition_count + + # TODO: This test is flaky when it is run under load. A better solution + # would be to change the test structure to not depend on specific timings. + overhead_us = 2 * overhead_us + logging.info('Overhead per transition: %fus', overhead_us) # Conservative upper bound on overhead in microseconds (we expect this to # take 0.17us when compiled in opt mode or 0.48 us when compiled with in