Skip to content

Commit

Permalink
sdk: make test_batch_span_processor_scheduled_delay a bit more robust
Browse files Browse the repository at this point in the history
It happened that tests failed because the delay was fired some
microseconds earlier:

>       self.assertGreaterEqual((export_time - start_time) * 1e3, 500)
E       AssertionError: 499.9737739562988 not greater than or equal to 500

Use assertAlmostEqual to accept a similar enough value (delta=25) and
avoid too big values.

Skip tests on windows pypy because of random huge spikes:

E AssertionError: 2253.103017807007 != 500 within 25 delta (1744.1030178070068 difference)

Fix open-telemetry#3911
  • Loading branch information
xrmx committed Jun 13, 2024
1 parent ba22b16 commit 81efc53
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion opentelemetry-sdk/tests/trace/export/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,10 @@ def _target():

span_processor.shutdown()

@mark.skipif(
python_implementation() == "PyPy" and system() == "Windows",
reason="This test randomly fails with huge delta in Windows with PyPy",
)
def test_batch_span_processor_scheduled_delay(self):
"""Test that spans are exported each schedule_delay_millis"""
spans_names_list = []
Expand All @@ -482,7 +486,7 @@ def test_batch_span_processor_scheduled_delay(self):
self.assertTrue(export_event.wait(2))
export_time = time.time()
self.assertEqual(len(spans_names_list), 1)
self.assertGreaterEqual((export_time - start_time) * 1e3, 500)
self.assertAlmostEqual((export_time - start_time) * 1e3, 500, delta=25)

span_processor.shutdown()

Expand Down

0 comments on commit 81efc53

Please sign in to comment.