Skip to content

Commit

Permalink
Use pytest-retry on flaky test case
Browse files Browse the repository at this point in the history
  • Loading branch information
ocelotl committed Jul 3, 2024
1 parent 21b9ef8 commit e96ea89
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions opentelemetry-sdk/test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ tomli==2.0.1
typing_extensions==4.10.0
wrapt==1.16.0
zipp==3.17.0
pytest-retry==1.6.3
-e tests/opentelemetry-test-utils
-e opentelemetry-api
-e opentelemetry-semantic-conventions
Expand Down
9 changes: 5 additions & 4 deletions opentelemetry-sdk/tests/trace/export/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,10 @@ def _target():

span_processor.shutdown()

@mark.skipif(
python_implementation() == "PyPy" or system() == "Windows",
reason="This test randomly fails with huge delta in Windows with PyPy",
@mark.flaky(
retries=3,
only_on=[AssertionError],
condition=(python_implementation == "PyPy" or system() == "Windows"),
)
def test_batch_span_processor_scheduled_delay(self):
"""Test that spans are exported each schedule_delay_millis"""
Expand All @@ -486,7 +487,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.assertAlmostEqual((export_time - start_time) * 1e3, 500, delta=25)
self.assertAlmostEqual((export_time - start_time) * 1e3, 500, delta=40)

span_processor.shutdown()

Expand Down

0 comments on commit e96ea89

Please sign in to comment.