zfs: expand testing to include a failing multi case
This commit is contained in:
parent
089fac3623
commit
2656b8db19
@ -25,6 +25,11 @@ testPkgs.testers.runNixOSTest {
|
|||||||
# Test multi-command logic: service with multiple serviceMountWithZpool calls
|
# Test multi-command logic: service with multiple serviceMountWithZpool calls
|
||||||
(lib.serviceMountWithZpool "multi-service" "rpool" [ "/mnt/rpool_data" ])
|
(lib.serviceMountWithZpool "multi-service" "rpool" [ "/mnt/rpool_data" ])
|
||||||
(lib.serviceMountWithZpool "multi-service" "rpool2" [ "/mnt/rpool2_data" ])
|
(lib.serviceMountWithZpool "multi-service" "rpool2" [ "/mnt/rpool2_data" ])
|
||||||
|
|
||||||
|
# Test multi-command logic: service with multiple serviceMountWithZpool calls
|
||||||
|
# BUT this one should fail as `/mnt/rpool_moar_data` is not on rpool2
|
||||||
|
(lib.serviceMountWithZpool "multi-service-fail" "rpool" [ "/mnt/rpool_data" ])
|
||||||
|
(lib.serviceMountWithZpool "multi-service-fail" "rpool2" [ "/mnt/rpool_moar_data" ])
|
||||||
];
|
];
|
||||||
|
|
||||||
virtualisation = {
|
virtualisation = {
|
||||||
@ -68,6 +73,14 @@ testPkgs.testers.runNixOSTest {
|
|||||||
ExecStart = lib.getExe pkgs.bash;
|
ExecStart = lib.getExe pkgs.bash;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
systemd.services."multi-service-fail" = {
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
RemainAfterExit = true;
|
||||||
|
ExecStart = lib.getExe pkgs.bash;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
@ -92,6 +105,8 @@ testPkgs.testers.runNixOSTest {
|
|||||||
|
|
||||||
machine.succeed("zfs create -o mountpoint=/mnt/rpool2_data rpool2/data")
|
machine.succeed("zfs create -o mountpoint=/mnt/rpool2_data rpool2/data")
|
||||||
|
|
||||||
|
machine.succeed("zfs create -o mountpoint=/mnt/rpool_moar_data rpool/moar_data")
|
||||||
|
|
||||||
# Test that valid service starts successfully
|
# Test that valid service starts successfully
|
||||||
machine.succeed("systemctl start test-service")
|
machine.succeed("systemctl start test-service")
|
||||||
|
|
||||||
@ -117,6 +132,21 @@ testPkgs.testers.runNixOSTest {
|
|||||||
assert "Expected pool: rpool2" in journal_output
|
assert "Expected pool: rpool2" in journal_output
|
||||||
assert "Actual pool: rpool" in journal_output
|
assert "Actual pool: rpool" in journal_output
|
||||||
|
|
||||||
|
|
||||||
|
# Test that invalid-service mount service fails validation
|
||||||
|
machine.fail("systemctl start multi-service-fail.service")
|
||||||
|
|
||||||
|
# Check the journal for our detailed validation error message
|
||||||
|
journal_output = machine.succeed("journalctl -u multi-service-fail-mounts.service --no-pager")
|
||||||
|
print("JOURNAL OUTPUT:")
|
||||||
|
print(journal_output)
|
||||||
|
|
||||||
|
# Verify our validation error is in the journal using Python string matching
|
||||||
|
assert "ERROR: ZFS pool mismatch for /mnt/rpool_moar_data" in journal_output, "no zfs pool mismatch found (1)"
|
||||||
|
assert "Expected pool: rpool2" in journal_output, "no zfs pool mismatch found (2)"
|
||||||
|
assert "Actual pool: rpool" in journal_output, "no zfs pool mismatch found (3)"
|
||||||
|
|
||||||
|
|
||||||
machine.succeed("systemctl start multi-service")
|
machine.succeed("systemctl start multi-service")
|
||||||
machine.succeed("systemctl is-active multi-service-mounts.service")
|
machine.succeed("systemctl is-active multi-service-mounts.service")
|
||||||
'';
|
'';
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user