Skip to content

Commit

Permalink
test(celery): Add test for nonzero retry count
Browse files Browse the repository at this point in the history
Add a test to verify that retry count gets set correctly, also for nonzero values.
  • Loading branch information
szokeasaurusrex committed Apr 25, 2024
1 parent 57bd97e commit edf4c0a
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion tests/integrations/celery/test_celery.py
Expand Up @@ -618,7 +618,7 @@ def example_task():
assert result.get() == "success"


def test_retry_count(init_celery, capture_events):
def test_retry_count_zero(init_celery, capture_events):
celery = init_celery(enable_tracing=True)
events = capture_events()

Expand All @@ -630,3 +630,20 @@ def task(): ...
(event,) = events
(span,) = event["spans"]
assert span["data"]["messaging.message.retry.count"] == 0


@mock.patch("celery.app.task.Task.request")
def test_retry_count_nonzero(mock_request, init_celery, capture_events):
mock_request.retries = 3

celery = init_celery(enable_tracing=True)
events = capture_events()

@celery.task()
def task(): ...

task.apply_async()

(event,) = events
(span,) = event["spans"]
assert span["data"]["messaging.message.retry.count"] == 3

0 comments on commit edf4c0a

Please sign in to comment.