Skip to content

Cover the Pacemaker helper - #99

Merged
insatomcat merged 1 commit into
mainfrom
pacemaker-unit-coverage
Sep 14, 2026
Merged

insatomcat merged 1 commit into
mainfrom
pacemaker-unit-coverage

Conversation

@insatomcat

@insatomcat insatomcat commented Sep 7, 2026 •

Copy link
Copy Markdown
Member

First of three PRs on the helpers, towards the OpenSSF gold coverage criteria. helpers/pacemaker.py goes from 20% to 100% statement and 100% branch coverage, in 73 unit tests, with no cluster.

Everything the helper does goes through subprocess, so that module is the only seam the tests need: a recording fake replaces it inside vm_manager.helpers.pacemaker, and the assertions are on the argument list handed to crm, which is the helper's whole contract. list2cmdline is the real one, since it only builds the log lines the tests read back.

The fake carries a call budget. wait_for() polls show() until a countdown runs out, so a regression in that countdown would spin forever; without the budget the suite would hang in CI instead of failing.

No production code changes. Twelve mutations of the module are all caught in under a second each: the --force flag of delete, its clean step, the --force-stop flag, the * stripping in list_resources, the weak colocation score, the target-role of add_vm and its default priority, the is_valid_host return code test, the wait_for countdown, the empty-command guard of run_crm_cmd, the empty-host test in find_resource, and the lstrip in show.

73 unit tests against a recording subprocess fake, the module's only
seam. helpers/pacemaker.py goes from 20% to 100% statement and branch
coverage, with no cluster.

Signed-off-by: Florent Carli <florent.carli@rte-france.com>
@insatomcat
insatomcat force-pushed the pacemaker-unit-coverage branch from 6dd6fea to 1ed8625 Compare September 7, 2026 15:45
@sonarqubecloud

sonarqubecloud Bot commented Sep 7, 2026

Copy link
Copy Markdown

@insatomcat
insatomcat merged commit 0e5f6ca into main Sep 14, 2026
5 checks passed
@insatomcat
insatomcat deleted the pacemaker-unit-coverage branch September 14, 2026 11:11
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.

2 participants