Skip to content

Commit b4d2532

Browse files
anoopcs9phlogistonjohn
authored andcommitted
Test new/replaced ctdb leader admin command
Signed-off-by: Anoop C S <[email protected]>
1 parent 39cf99a commit b4d2532

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tests/test_ctdb.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -527,13 +527,15 @@ def test_cli_leader_locator(tmpdir, monkeypatch, caplog):
527527
caplog.set_level(logging.INFO)
528528
fake_ctdb = tmpdir / "fake_ctdb.sh"
529529
monkeypatch.setattr(sambacc.samba_cmds, "_GLOBAL_PREFIX", [fake_ctdb])
530+
monkeypatch.setenv("SAMBA_SPECIFICS", "ctdb_leader_admin_command")
531+
ldr_admin_cmd = sambacc.samba_cmds.ctdb_leader_admin_cmd()
530532

531533
def _fake_ctdb_script(pnn, recmaster):
532534
with open(fake_ctdb, "w") as fh:
533535
fh.write("#!/bin/sh\n")
534536
fh.write("case $2 in\n")
535537
fh.write(f"pnn) {pnn};;\n")
536-
fh.write(f"recmaster) {recmaster};;\n")
538+
fh.write(f"{ldr_admin_cmd}) {recmaster};;\n")
537539
fh.write("esac\n")
538540
fh.write("exit 5\n")
539541
os.chmod(fake_ctdb, 0o700)
@@ -551,18 +553,18 @@ def _fake_ctdb_script(pnn, recmaster):
551553
with ctdb.CLILeaderLocator() as status:
552554
assert not status.is_leader()
553555
assert "pnn" in caplog.records[-1].getMessage()
554-
assert "recmaster" not in caplog.records[-1].getMessage()
556+
assert "['" + ldr_admin_cmd + "']" not in caplog.records[-1].getMessage()
555557
_fake_ctdb_script(pnn="echo 1; exit 0", recmaster="exit 1")
556558
with ctdb.CLILeaderLocator() as status:
557559
assert not status.is_leader()
558560
assert "pnn" not in caplog.records[-1].getMessage()
559-
assert "recmaster" in caplog.records[-1].getMessage()
561+
assert "['" + ldr_admin_cmd + "']" in caplog.records[-1].getMessage()
560562

561563
os.unlink(fake_ctdb)
562564
with ctdb.CLILeaderLocator() as status:
563565
assert not status.is_leader()
564566
assert "pnn" in caplog.records[-2].getMessage()
565-
assert "recmaster" in caplog.records[-1].getMessage()
567+
assert "['" + ldr_admin_cmd + "']" in caplog.records[-1].getMessage()
566568

567569

568570
def test_check_nodestatus(tmp_path):

0 commit comments

Comments
 (0)