tests: check canmount ZFS flag is respected

This commit is contained in:
Michael Hoang 2023-12-30 11:23:57 +11:00 committed by mergify[bot]
parent 0ce1b15b99
commit 583bdf4fc6
2 changed files with 53 additions and 1 deletions

View file

@ -59,6 +59,22 @@
}; };
}; };
}; };
a = {
type = "disk";
device = "/dev/sda";
content = {
type = "gpt";
partitions = {
zfs = {
size = "100%";
content = {
type = "zfs";
pool = "storage2";
};
};
};
};
};
}; };
zpool = { zpool = {
storage = { storage = {
@ -73,6 +89,20 @@
}; };
}; };
}; };
storage2 = {
type = "zpool";
mountpoint = "/storage2";
rootFsOptions = {
canmount = "off";
};
datasets = {
dataset = {
type = "zfs_fs";
mountpoint = "/storage2/dataset";
};
};
};
}; };
}; };
} }

View file

@ -14,13 +14,35 @@ diskoLib.testLib.makeDiskoTest {
filesystem = machine.execute("stat --file-system --format=%T /mnt/storage")[1].rstrip() filesystem = machine.execute("stat --file-system --format=%T /mnt/storage")[1].rstrip()
print(f"/mnt/storage {filesystem=}") print(f"/mnt/storage {filesystem=}")
assert filesystem == "zfs", "/mnt/storage is not ZFS" assert filesystem == "zfs", "/mnt/storage is not ZFS"
machine.fail("mountpoint /mnt/storage2")
machine.succeed("mountpoint /mnt/storage2/dataset")
filesystem = machine.execute("stat --file-system --format=%T /mnt/storage2")[1].rstrip()
print(f"/mnt/storage2 {filesystem=}")
assert filesystem != "zfs", "/mnt/storage should not be ZFS"
filesystem = machine.execute("stat --file-system --format=%T /mnt/storage2/dataset")[1].rstrip()
print(f"/mnt/storage2/dataset {filesystem=}")
assert filesystem == "zfs", "/mnt/storage/dataset is not ZFS"
''; '';
extraTestScript = '' extraTestScript = ''
machine.succeed("mountpoint /storage") machine.succeed("mountpoint /storage")
machine.succeed("mountpoint /storage/dataset") machine.succeed("mountpoint /storage/dataset")
filesystem = machine.execute("stat --file-system --format=%T /storage")[1].rstrip() filesystem = machine.execute("stat --file-system --format=%T /storage")[1].rstrip()
print(f"/mnt/storage {filesystem=}") print(f"/storage {filesystem=}")
assert filesystem == "zfs", "/storage is not ZFS" assert filesystem == "zfs", "/storage is not ZFS"
machine.fail("mountpoint /storage2")
machine.succeed("mountpoint /storage2/dataset")
filesystem = machine.execute("stat --file-system --format=%T /storage2")[1].rstrip()
print(f"/storage2 {filesystem=}")
assert filesystem != "zfs", "/storage should not be ZFS"
filesystem = machine.execute("stat --file-system --format=%T /storage2/dataset")[1].rstrip()
print(f"/storage2/dataset {filesystem=}")
assert filesystem == "zfs", "/storage/dataset is not ZFS"
''; '';
} }