2022-12-21 05:05:02 +01:00
|
|
|
{ system ? builtins.currentSystem
|
|
|
|
, config ? {}
|
|
|
|
, pkgs ? import ../.. { inherit system config; }
|
|
|
|
, systemdStage1 ? false
|
|
|
|
}:
|
|
|
|
|
2019-11-05 00:38:50 +01:00
|
|
|
import ./make-test-python.nix {
|
2018-08-22 03:39:27 +02:00
|
|
|
name = "fsck";
|
|
|
|
|
2022-03-21 00:15:30 +01:00
|
|
|
nodes.machine = { lib, ... }: {
|
2018-08-22 03:39:27 +02:00
|
|
|
virtualisation.emptyDiskImages = [ 1 ];
|
|
|
|
|
2021-02-14 12:23:50 +01:00
|
|
|
virtualisation.fileSystems = {
|
2018-08-22 03:39:27 +02:00
|
|
|
"/mnt" = {
|
|
|
|
device = "/dev/vdb";
|
|
|
|
fsType = "ext4";
|
|
|
|
autoFormat = true;
|
|
|
|
};
|
|
|
|
};
|
2022-12-21 05:05:02 +01:00
|
|
|
|
|
|
|
boot.initrd.systemd.enable = systemdStage1;
|
2018-08-22 03:39:27 +02:00
|
|
|
};
|
|
|
|
|
nixos/qemu-vm: use persistent block device names
This change removes the bespoke logic around identifying block devices.
Instead of trying to find the right device by iterating over
`qemu.drives` and guessing the right partition number (e.g.
/dev/vda{1,2}), devices are now identified by persistent names provided
by udev in /dev/disk/by-*.
Before this change, the root device was formatted on demand in the
initrd. However, this makes it impossible to use filesystem identifiers
to identify devices. Now, the formatting step is performed before the VM
is started. Because some tests, however, rely on this behaviour, a
utility function to replace this behaviour in added in
/nixos/tests/common/auto-format-root-device.nix.
Devices that contain neither a partition table nor a filesystem are
identified by their hardware serial number which is injecetd via QEMU
(and is thus persistent and predictable). PCI paths are not a reliably
way to identify devices because their availability and numbering depends
on the QEMU machine type.
This change makes the module more robust against changes in QEMU and the
kernel (non-persistent device naming) and by decoupling abstractions
(i.e. rootDevice, bootPartition, and bootLoaderDevice) enables further
improvement down the line.
2023-06-08 02:34:10 +02:00
|
|
|
testScript = { nodes, ...}:
|
|
|
|
let
|
|
|
|
rootDevice = nodes.machine.virtualisation.rootDevice;
|
|
|
|
in
|
|
|
|
''
|
2019-11-05 00:38:50 +01:00
|
|
|
machine.wait_for_unit("default.target")
|
2018-08-22 03:39:27 +02:00
|
|
|
|
2019-11-05 00:38:50 +01:00
|
|
|
with subtest("root fs is fsckd"):
|
2022-12-21 05:05:02 +01:00
|
|
|
machine.succeed("journalctl -b | grep '${if systemdStage1
|
nixos/qemu-vm: use persistent block device names
This change removes the bespoke logic around identifying block devices.
Instead of trying to find the right device by iterating over
`qemu.drives` and guessing the right partition number (e.g.
/dev/vda{1,2}), devices are now identified by persistent names provided
by udev in /dev/disk/by-*.
Before this change, the root device was formatted on demand in the
initrd. However, this makes it impossible to use filesystem identifiers
to identify devices. Now, the formatting step is performed before the VM
is started. Because some tests, however, rely on this behaviour, a
utility function to replace this behaviour in added in
/nixos/tests/common/auto-format-root-device.nix.
Devices that contain neither a partition table nor a filesystem are
identified by their hardware serial number which is injecetd via QEMU
(and is thus persistent and predictable). PCI paths are not a reliably
way to identify devices because their availability and numbering depends
on the QEMU machine type.
This change makes the module more robust against changes in QEMU and the
kernel (non-persistent device naming) and by decoupling abstractions
(i.e. rootDevice, bootPartition, and bootLoaderDevice) enables further
improvement down the line.
2023-06-08 02:34:10 +02:00
|
|
|
then "fsck.*${builtins.baseNameOf rootDevice}.*clean"
|
|
|
|
else "fsck.ext4.*${rootDevice}"}'")
|
2018-08-22 03:39:27 +02:00
|
|
|
|
2019-11-05 00:38:50 +01:00
|
|
|
with subtest("mnt fs is fsckd"):
|
2023-05-29 22:14:18 +02:00
|
|
|
machine.succeed("journalctl -b | grep 'fsck.*vdb.*clean'")
|
2019-11-05 00:38:50 +01:00
|
|
|
machine.succeed(
|
|
|
|
"grep 'Requires=systemd-fsck@dev-vdb.service' /run/systemd/generator/mnt.mount"
|
|
|
|
)
|
|
|
|
machine.succeed(
|
|
|
|
"grep 'After=systemd-fsck@dev-vdb.service' /run/systemd/generator/mnt.mount"
|
|
|
|
)
|
2018-08-22 03:39:27 +02:00
|
|
|
'';
|
|
|
|
}
|