Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flaky test for opentelemetry-sdk in CI #4070

Open
emdneto opened this issue Jul 22, 2024 · 3 comments · May be fixed by #4096
Open

flaky test for opentelemetry-sdk in CI #4070

emdneto opened this issue Jul 22, 2024 · 3 comments · May be fixed by #4096
Assignees
Labels
bug Something isn't working good first issue Good first issue help wanted

Comments

@emdneto
Copy link
Member

emdneto commented Jul 22, 2024

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

@emdneto emdneto added the bug Something isn't working label Jul 22, 2024
@arunk1988
Copy link
Contributor

Hi @emdneto , I am looking into this, will open a PR shortly.

@arunk1988 arunk1988 mentioned this issue Jul 23, 2024
8 tasks
@arunk1988 arunk1988 linked a pull request Jul 31, 2024 that will close this issue
8 tasks
@Ali-Alnosairi
Copy link
Contributor

Hi @emdneto ,
Can I work on this?

@emdneto
Copy link
Member Author

emdneto commented Sep 9, 2024

@Ali-Alnosairi, I think there is an open PR. Feel free to improve it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good first issue help wanted
Projects
None yet
3 participants