flaky test for opentelemetry-sdk in CI
Describe your environment
OS: Windows Python version: Python3.8 SDK version: main API version: main
What happened?
================================== FAILURES ===================================
_______ TestBatchSpanProcessor.test_batch_span_processor_reset_timeout ________
self = <tests.trace.export.test_export.TestBatchSpanProcessor testMethod=test_batch_span_processor_reset_timeout>
@mark.skipif(
python_implementation() == "PyPy" and system() == "Windows",
reason="This test randomly fails in Windows with PyPy",
)
def test_batch_span_processor_reset_timeout(self):
"""Test that the scheduled timeout is reset on cycles without spans"""
spans_names_list = []
export_event = threading.Event()
my_exporter = MySpanExporter(
destination=spans_names_list,
export_event=export_event,
export_timeout_millis=50,
)
span_processor = export.BatchSpanProcessor(
my_exporter,
schedule_delay_millis=50,
)
with mock.patch.object(span_processor.condition, "wait") as mock_wait:
resource = Resource.create({})
_create_start_and_end_span("foo", span_processor, resource)
self.assertTrue(export_event.wait(2))
# give some time for exporter to loop
# since wait is mocked it should return immediately
time.sleep(0.1)
mock_wait_calls = list(mock_wait.mock_calls)
# find the index of the call that processed the singular span
for idx, wait_call in enumerate(mock_wait_calls):
_, args, __ = wait_call
if args[0] <= 0:
after_calls = mock_wait_calls[idx + 1 :]
break
self.assertTrue(
> all(args[0] >= 0.05 for _, args, __ in after_calls)
)
E UnboundLocalError: local variable 'after_calls' referenced before assignment
Steps to Reproduce
Run in CI https://github.com/open-telemetry/opentelemetry-python/actions/runs/10041807138/job/27750740610
Expected Result
Test pass every time
Actual Result
Some runs test don't pass
Additional context
No response
Would you like to implement a fix?
None
Hi @emdneto , I am looking into this, will open a PR shortly.
Hi @emdneto , Can I work on this?
@Ali-Alnosairi, I think there is an open PR. Feel free to improve it
@emdneto may I pick this up given there's been no activity for many months?
@emdneto it appears that this test was deleted in https://github.com/open-telemetry/opentelemetry-python/commit/3497e6662984edb345eaac4c4d3ac4872d438a55#diff-73d0e7899abf301636c4ce674f9d18cbebe6718a6a210c18161024d1663bf6aaL522-L527
I guess this issue can be closed?
I guess this issue can be closed?
Indeed, thanks!