Skip to content

Add tests for celery tasks#77

Closed
gijzelaerr wants to merge 2 commits into
mainfrom
spotify/add-celery-task-tests
Closed

Add tests for celery tasks#77
gijzelaerr wants to merge 2 commits into
mainfrom
spotify/add-celery-task-tests

Conversation

@gijzelaerr

Copy link
Copy Markdown
Member

Summary

Adds test coverage for the four celery tasks that drive Lemur's production automation — previously had zero tests.

certificate_rotate (6 tests)

  • Dispatches to cli_certificate.rotate with correct args
  • Passes ENABLE_ROTATION_NOTIFICATION config
  • Routes to rotate_region when region kwarg is given
  • Handles SoftTimeLimitExceeded (logs + timeout metric, no crash)
  • Skips when duplicate task is already active
  • Emits success metric

certificate_reissue (4 tests)

  • Dispatches to cli_certificate.reissue
  • Passes ENABLE_REISSUE_NOTIFICATION config
  • Handles SoftTimeLimitExceeded
  • Emits success metric

notify_expirations (3 tests)

  • Dispatches to cli_notification.expirations
  • Passes EXCLUDE_CN_FROM_NOTIFICATION and DISABLE_NOTIFICATION_PLUGINS config
  • Handles SoftTimeLimitExceeded

clean_all_sources (2 tests)

  • Dispatches one clean_source.delay() per source
  • Emits success metric

Context

These tasks run on a celery beat schedule and are the backbone of automated cert lifecycle management. The certificate_rotate task is what triggered the list-mutation bug (PR #71) in production — having tests at the task level ensures the orchestration layer is correct in addition to the CLI layer (PR #76).

…notify_expirations, clean_all_sources)

These scheduled tasks are the core of Lemur's automation — they run
certificate rotation, reissuance, expiry notifications, and source
cleanup on a schedule. Previously had zero test coverage.

Tests cover:
- certificate_rotate: CLI dispatch, notification config, region
  routing, SoftTimeLimitExceeded handling, duplicate task guard,
  success metric
- certificate_reissue: CLI dispatch, notification config, timeout
  handling, success metric
- notify_expirations: CLI dispatch, config passthrough, timeout
- clean_all_sources: per-source task dispatch, success metric
@gijzelaerr

Copy link
Copy Markdown
Member Author

Superseded by new PR based on main

@gijzelaerr gijzelaerr closed this Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant