From c4639ee3f5e60f2ae62ff9bb95a2bf775ea6d784 Mon Sep 17 00:00:00 2001 From: Owais Lone Date: Thu, 2 Sep 2021 13:44:38 +0530 Subject: [PATCH] Fix flaky celery docker test (#652) The test was actually generating 2 spans but on very fast systems we only saw one as the test ran faster than the message would travel through the broker, trigger a task and generate 2nd span. Switched from .delay() to .apply() so only one span is generated which is enough for the test in question. --- .../tests/celery/test_celery_functional.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/opentelemetry-docker-tests/tests/celery/test_celery_functional.py b/tests/opentelemetry-docker-tests/tests/celery/test_celery_functional.py index c85952aa7d..0f707a4571 100644 --- a/tests/opentelemetry-docker-tests/tests/celery/test_celery_functional.py +++ b/tests/opentelemetry-docker-tests/tests/celery/test_celery_functional.py @@ -15,7 +15,6 @@ import celery from celery.exceptions import Retry -from flaky import flaky from pytest import mark import opentelemetry.instrumentation.celery @@ -559,8 +558,6 @@ class CelerySubClass(CelerySuperClass): ) == async_run_span.attributes.get(SpanAttributes.MESSAGING_MESSAGE_ID) -# FIXME find a permanent solution for the flakiness of this test -@flaky def test_custom_tracer_provider(celery_app, memory_exporter): @celery_app.task def fn_task(): @@ -576,7 +573,7 @@ def fn_task(): CeleryInstrumentor().uninstrument() CeleryInstrumentor().instrument(tracer_provider=tracer_provider) - fn_task.delay() + fn_task.apply() spans_list = memory_exporter.get_finished_spans() assert len(spans_list) == 1