Skip to content

Finish the vm_manager_cluster coverage and fix the two CLI flag bugs - #98

Merged
insatomcat merged 5 commits into
mainfrom
cluster-unit-coverage-2
Sep 7, 2026
Merged

insatomcat merged 5 commits into
mainfrom
cluster-unit-coverage-2

Conversation

@insatomcat

@insatomcat insatomcat commented Sep 7, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #97, which left fourteen functions of vm_manager_cluster.py uncovered.

They are covered now, so the module reaches 100% statement and 100% branch coverage, with 275 unit tests instead of 228 and still no cluster. SonarCloud overall goes from 66.4% to 73.3%.

The last two commits fix the two CLI bugs #94 found and left as strict xfail. enable and live_migration are never argparse dests: they are the destinations main() fills from --disable and --enable-live-migration. The create branch guarded both assignments behind "enable" in args and "live_migration" in args, always false, and the clone branch never assigned enable at all. So create --disable, clone --disable and create --enable-live-migration did nothing. Both branches now do what add-to-cluster already did, and the three xfail markers are gone.

No flag is added, removed or renamed. What changes is that three flags start having the effect their help text advertises.

disable_vm, start, stop, status and is_enabled are thin Pacemaker
wrappers that no test reached. They now run against the fake
Pacemaker, which grows show(), delete(), start() and stop(), plus a
resource state and an undeletable-resource set the tests drive.

list_resources() moves from the fake to the stub the cluster fixture
builds, so it answers on the class as well as on an instance. The real
Pacemaker declares it static, and is_enabled() calls it that way.

Signed-off-by: Florent Carli <florent.carli@rte-france.com>
_create_vm_group owns the force path that removes an existing VM and
the check that the group Ceph reported creating is really there. The
fake gets create_group() and a set of group names it must accept
without creating, to reach that check.

list_vms picks its source from the enabled flag: the Ceph groups, or
the Pacemaker resources without touching Ceph at all.

Signed-off-by: Florent Carli <florent.carli@rte-france.com>
list_snapshots, list_metadata, get_metadata, set_metadata,
add_colocation, add_pacemaker_remote and remove_pacemaker_remote are
the last uncovered functions of the module. The fakes grow
list_image_metadata() on the Ceph side and add_colocation(),
add_meta() and remove_meta() on the Pacemaker side.

The tests pin down what the wrappers actually decide: the name
validation set_metadata, add_colocation and add_pacemaker_remote run
before touching anything, the optional port and timeout that stay out
of both stores when they are not given, and the KeyError
remove_pacemaker_remote swallows on a VM that carries no remote
configuration.

With them vm_manager_cluster.py reaches 100% statement and branch
coverage.

Signed-off-by: Florent Carli <florent.carli@rte-france.com>
Both assignments sat behind "enable" in args and "live_migration" in
args. Neither is an argparse dest, so both guards were always false
and the two flags did nothing. Assign unconditionally, the way
add-to-cluster already does.

Signed-off-by: Florent Carli <florent.carli@rte-france.com>
The clone branch never set args.enable, and _configure_vm() reads a
missing key as True, so --disable enabled the clone anyway.

Signed-off-by: Florent Carli <florent.carli@rte-france.com>
@insatomcat insatomcat changed the title Finish the vm_manager_cluster coverage Finish the vm_manager_cluster coverage and fix the two CLI flag bugs Sep 7, 2026
@sonarqubecloud

sonarqubecloud Bot commented Sep 7, 2026

Copy link
Copy Markdown

@insatomcat
insatomcat merged commit 016b7a4 into main Sep 7, 2026
5 checks passed
@insatomcat
insatomcat deleted the cluster-unit-coverage-2 branch September 7, 2026 15:44
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