nixos/tests/lvm2: init
This commit is contained in:
parent
6a8face381
commit
6bbba30674
|
@ -274,6 +274,7 @@ in
|
|||
login = handleTest ./login.nix {};
|
||||
logrotate = handleTest ./logrotate.nix {};
|
||||
loki = handleTest ./loki.nix {};
|
||||
lvm2 = handleTest ./lvm2 {};
|
||||
lxd = handleTest ./lxd.nix {};
|
||||
lxd-image = handleTest ./lxd-image.nix {};
|
||||
lxd-nftables = handleTest ./lxd-nftables.nix {};
|
||||
|
|
26
nixos/tests/lvm2/default.nix
Normal file
26
nixos/tests/lvm2/default.nix
Normal file
|
@ -0,0 +1,26 @@
|
|||
{ system ? builtins.currentSystem
|
||||
, config ? { }
|
||||
, pkgs ? import ../../.. { inherit system config; }
|
||||
, lib ? pkgs.lib
|
||||
, kernelVersionsToTest ? [ "4.19" "5.4" "5.10" "5.15" "latest" ]
|
||||
}:
|
||||
|
||||
let
|
||||
tests = let callTest = p: lib.flip (import p) { inherit system pkgs; }; in {
|
||||
thinpool = { test = callTest ./thinpool.nix; kernelFilter = lib.id; };
|
||||
# we would like to test all versions, but the kernel module currently does not compile against the other versions
|
||||
vdo = { test = callTest ./vdo.nix; kernelFilter = lib.filter (v: v == "5.15"); };
|
||||
};
|
||||
in
|
||||
lib.listToAttrs (
|
||||
lib.filter (x: x.value != {}) (
|
||||
lib.flip lib.concatMap kernelVersionsToTest (version:
|
||||
let
|
||||
v' = lib.replaceStrings [ "." ] [ "_" ] version;
|
||||
in
|
||||
lib.flip lib.mapAttrsToList tests (name: t:
|
||||
lib.nameValuePair "lvm-${name}-linux-${v'}" (lib.optionalAttrs (builtins.elem version (t.kernelFilter kernelVersionsToTest)) (t.test { kernelPackages = pkgs."linuxPackages_${v'}"; }))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
32
nixos/tests/lvm2/thinpool.nix
Normal file
32
nixos/tests/lvm2/thinpool.nix
Normal file
|
@ -0,0 +1,32 @@
|
|||
{ kernelPackages ? null }:
|
||||
import ../make-test-python.nix ({ pkgs, ... }: {
|
||||
name = "lvm2-thinpool";
|
||||
meta.maintainers = with pkgs.lib.maintainers; [ ajs124 ];
|
||||
|
||||
nodes.machine = { pkgs, lib, ... }: {
|
||||
virtualisation.emptyDiskImages = [ 4096 ];
|
||||
services.lvm = {
|
||||
boot.thin.enable = true;
|
||||
dmeventd.enable = true;
|
||||
};
|
||||
environment.systemPackages = with pkgs; [ xfsprogs ];
|
||||
environment.etc."lvm/lvm.conf".text = ''
|
||||
activation/thin_pool_autoextend_percent = 10
|
||||
activation/thin_pool_autoextend_threshold = 80
|
||||
'';
|
||||
boot = lib.mkIf (kernelPackages != null) { inherit kernelPackages; };
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
machine.succeed("vgcreate test_vg /dev/vdb")
|
||||
machine.succeed("lvcreate -L 512M -T test_vg/test_thin_pool")
|
||||
machine.succeed("lvcreate -n test_lv -V 16G --thinpool test_thin_pool test_vg")
|
||||
machine.succeed("mkfs.xfs /dev/test_vg/test_lv")
|
||||
machine.succeed("mkdir /mnt; mount /dev/test_vg/test_lv /mnt")
|
||||
assert "/dev/mapper/test_vg-test_lv" == machine.succeed("findmnt -no SOURCE /mnt").strip()
|
||||
machine.succeed("dd if=/dev/zero of=/mnt/empty.file bs=1M count=1024")
|
||||
machine.succeed("journalctl -u dm-event.service | grep \"successfully resized\"")
|
||||
machine.succeed("umount /mnt")
|
||||
machine.succeed("vgchange -a n")
|
||||
'';
|
||||
})
|
27
nixos/tests/lvm2/vdo.nix
Normal file
27
nixos/tests/lvm2/vdo.nix
Normal file
|
@ -0,0 +1,27 @@
|
|||
{ kernelPackages ? null }:
|
||||
import ../make-test-python.nix ({ pkgs, ... }: {
|
||||
name = "lvm2-thinpool";
|
||||
meta.maintainers = with pkgs.lib.maintainers; [ ajs124 ];
|
||||
|
||||
nodes.machine = { pkgs, lib, ... }: {
|
||||
# Minimum required size for VDO volume: 5063921664 bytes
|
||||
virtualisation.emptyDiskImages = [ 8192 ];
|
||||
services.lvm = {
|
||||
boot.vdo.enable = true;
|
||||
dmeventd.enable = true;
|
||||
};
|
||||
environment.systemPackages = with pkgs; [ xfsprogs ];
|
||||
boot = lib.mkIf (kernelPackages != null) { inherit kernelPackages; };
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
machine.succeed("vgcreate test_vg /dev/vdb")
|
||||
machine.succeed("lvcreate --type vdo -n vdo_lv -L 6G -V 12G test_vg/vdo_pool_lv")
|
||||
machine.succeed("mkfs.xfs -K /dev/test_vg/vdo_lv")
|
||||
machine.succeed("mkdir /mnt; mount /dev/test_vg/vdo_lv /mnt")
|
||||
assert "/dev/mapper/test_vg-vdo_lv" == machine.succeed("findmnt -no SOURCE /mnt").strip()
|
||||
machine.succeed("umount /mnt")
|
||||
machine.succeed("vdostats")
|
||||
machine.succeed("vgchange -a n")
|
||||
'';
|
||||
})
|
Loading…
Reference in a new issue