Skip to content

ci: Add rerun failures package for flaky tests #728

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

CagriYonca
Copy link
Contributor

I'm taking the initiative and proposing the pytest-rerunfailures package for flaky tests. Only thing we should do is to add the line just before flaky tests:

    @pytest.mark.flaky(reruns=3, reruns_delay=2)   <-- ONLY THIS
    def test_flaky_test(self):
        ...

Signed-off-by: Cagri Yonca <cagri@ibm.com>
@CagriYonca CagriYonca added Do not merge Depends on another PR ci/cd labels May 7, 2025
@CagriYonca CagriYonca self-assigned this May 7, 2025
@CagriYonca
Copy link
Contributor Author

CagriYonca commented May 22, 2025

Grpcio fails randomly:

  • FAILED tests/frameworks/test_grpcio.py::TestGRPCIO::test_server_error
    def test_server_error(self) -> None:
        response = None
        with tracer.start_as_current_span("test"):
            try:
                response = self.server_stub.OneQuestionOneErrorResponse(
                    stan_pb2.QuestionRequest(question="Do u error?")
                )
            except Exception:
                pass
    
        assert not get_current_span().is_recording()
        assert not response
    
        spans = self.recorder.queued_spans()
>       assert len(spans) == 4
E       assert 3 == 4

https://app.circleci.com/pipelines/github/instana/python-sensor/3997/workflows/8223d7a0-aaa6-4c73-b322-6ea4c97f4ae5/jobs/30757/parallel-runs/0/steps/0-105

@CagriYonca
Copy link
Contributor Author

CagriYonca commented Jun 16, 2025

Kafka fails randomly:

  • tests/clients/kafka/test_confluent_kafka.py::TestConfluentKafka::test_confluent_kafka_poll_root_exit
    def test_confluent_kafka_poll_root_exit(self) -> None:
        agent.options.allow_exit_as_root = True
    
        # Produce some events
        self.producer.produce(testenv["kafka_topic"], b"raw_bytes1")
        self.producer.flush()
    
        # Consume the events
        consumer_config = self.kafka_config.copy()
        consumer_config["group.id"] = "my-group"
        consumer_config["auto.offset.reset"] = "earliest"
    
        consumer = Consumer(consumer_config)
        consumer.subscribe([testenv["kafka_topic"]])
    
        msg = consumer.poll(timeout=30)  # noqa: F841
    
        consumer.close()
    
        spans = self.recorder.queued_spans()
        assert len(spans) == 2
    
        producer_span = get_first_span_by_filter(
            spans,
            lambda span: span.n == "kafka"
            and span.data["kafka"]["access"] == "produce"
            and span.data["kafka"]["service"] == "span-topic",
        )
    
        poll_span = get_first_span_by_filter(
            spans,
            lambda span: span.n == "kafka"
            and span.data["kafka"]["access"] == "poll"
            and span.data["kafka"]["service"] == "span-topic",
        )
    
        # Same traceId
>       assert producer_span.t == poll_span.t
E       AssertionError: assert 6259974530922409176 == 3135373471331694061

https://app.circleci.com/pipelines/github/instana/python-sensor/4060/workflows/483538f3-52bc-458e-af45-87b60c6511da/jobs/31584/parallel-runs/0/steps/0-105

@CagriYonca
Copy link
Contributor Author

CagriYonca commented Jun 18, 2025

Tornado fails randomly:

  • tests/frameworks/test_tornado_server.py::TestTornadoServer::test_get_with_params_to_scrub
    def test_get_with_params_to_scrub(self) -> None:
        async def test():
            with tracer.start_as_current_span("test"):
                async with aiohttp.ClientSession() as session:
                    return await self.fetch(session, testenv["tornado_server"], params={"secret": "yeah"})
    
        response = tornado.ioloop.IOLoop.current().run_sync(test)
    
        spans = self.recorder.queued_spans()
>       assert len(spans) == 3
E       AssertionError: assert 2 == 3

https://app.circleci.com/pipelines/github/instana/python-sensor/4071/workflows/f52e3efe-42c0-4972-8a99-291b961743e1/jobs/31732/parallel-runs/0/steps/0-105

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci/cd Do not merge Depends on another PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant