Skip to content

Add unit tests for osism/tasks thin task wrappers#2438

Merged
ideaship merged 1 commit into
mainfrom
implement/issue-2354-task-wrapper-tests
Jul 6, 2026
Merged

Add unit tests for osism/tasks thin task wrappers#2438
ideaship merged 1 commit into
mainfrom
implement/issue-2354-task-wrapper-tests

Conversation

@berendt

@berendt berendt commented Jul 6, 2026

Copy link
Copy Markdown
Member

Closes #2354

Summary

Adds a unit-test suite for the thin task wrappers in osism/tasks/{ansible,ceph,kolla,kubernetes,reconciler}.py. These modules are the Celery entry points that mostly delegate into the ansible runner, the Redis task locks, a subprocess call, and the task-output stream. The suite exercises that glue with every external effect mocked, so the tests need neither a broker nor a reachable Redis.

Change set

A single commit, 7d892fc Add unit tests for osism/tasks thin task wrappers, adds one new file:

  • tests/unit/tasks/test_task_wrappers.py (535 lines)

The tests are grouped by concern:

  • App config / queue routing — parametrized across the five modules: the default queue, module-pattern → queue routing, and that the tasks register under their explicit names.
  • setup_periodic_tasks receivers — schedules when the Redis lock is acquired, skips when scheduling is disabled, skips when the lock is not acquired, and the no-op receiver.
  • ansible task bodiesgather_facts delegates with defaults and forwards publish=False; run delegates with defaults, forwards its arguments, and aborts when the task lock is active; noop returns True.
  • Worker run bodies — parametrized across kolla/kubernetes/ceph: delegates with defaults, forwards overrides, and aborts when the task lock is active.
  • reconciler.run — aborts when the task lock is active, returns None when the lock is not acquired, publishes output, skips output when publishing is off, and warns when the lock was already released.
  • run_on_change — returns None when the lock is not acquired, runs the script without publishing, and warns when the lock was already released.

Notes for the reviewer


Implemented by planwerk-agent 4c14036 with Claude:claude-opus-4-8

Cover app config/queue routing, the setup_periodic_tasks receivers,
and the run/gather_facts/noop/run_on_change task bodies of
osism/tasks/{ansible,ceph,kolla,kubernetes,reconciler}.py. All
external effects -- the ansible runner, the Redis locks, the
subprocess call and the task-output stream -- are mocked, so the
tests need neither a broker nor a reachable Redis.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Christian Berendt <berendt@osism.tech>
@berendt berendt moved this from New to Ready for review in Human Board Jul 6, 2026
@berendt berendt marked this pull request as ready for review July 6, 2026 08:17

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@berendt berendt requested a review from ideaship July 6, 2026 08:40
@ideaship ideaship merged commit 5c7dbb8 into main Jul 6, 2026
4 checks passed
@ideaship ideaship deleted the implement/issue-2354-task-wrapper-tests branch July 6, 2026 09:53
@github-project-automation github-project-automation Bot moved this from Ready for review to Done in Human Board Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Unit tests for osism/tasks/{ansible,ceph,kolla,kubernetes,reconciler}.py — thin task wrappers

3 participants