nixos/tests/storage: Pass storage config as XML.
We're internally calling nix-instantiate to get the required options from the configuration, so let's pass it through an option that skips this step. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
parent
ccc768a00d
commit
8c3790b0de
|
@ -3,8 +3,15 @@ import ./make-test.nix ({ pkgs, ... }:
|
||||||
with pkgs.lib;
|
with pkgs.lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
ext = pkgs.writeText "ext.nix" ''
|
mkConf = cfg: let
|
||||||
{
|
config = (import <nixpkgs/nixos/lib/eval-config.nix> {
|
||||||
|
modules = singleton cfg;
|
||||||
|
}).config;
|
||||||
|
in pkgs.writeText "storage.xml" (builtins.toXML {
|
||||||
|
inherit (config) storage fileSystems swapDevices;
|
||||||
|
});
|
||||||
|
|
||||||
|
ext = {
|
||||||
storage = {
|
storage = {
|
||||||
disk.vdb.clear = true;
|
disk.vdb.clear = true;
|
||||||
disk.vdb.initlabel = true;
|
disk.vdb.initlabel = true;
|
||||||
|
@ -40,11 +47,9 @@ let
|
||||||
swapDevices = [
|
swapDevices = [
|
||||||
{ label = "swap"; storage = "partition.swap"; }
|
{ label = "swap"; storage = "partition.swap"; }
|
||||||
];
|
];
|
||||||
}
|
};
|
||||||
'';
|
|
||||||
|
|
||||||
btrfs = pkgs.writeText "btrfs.nix" ''
|
btrfs = {
|
||||||
{
|
|
||||||
storage = {
|
storage = {
|
||||||
disk.vdb.clear = true;
|
disk.vdb.clear = true;
|
||||||
disk.vdb.initlabel = true;
|
disk.vdb.initlabel = true;
|
||||||
|
@ -76,11 +81,9 @@ let
|
||||||
{ label = "swap1"; storage = "partition.swap1"; }
|
{ label = "swap1"; storage = "partition.swap1"; }
|
||||||
{ label = "swap2"; storage = "partition.swap2"; }
|
{ label = "swap2"; storage = "partition.swap2"; }
|
||||||
];
|
];
|
||||||
}
|
};
|
||||||
'';
|
|
||||||
|
|
||||||
f2fs = pkgs.writeText "f2fs.nix" ''
|
f2fs = {
|
||||||
{
|
|
||||||
storage = {
|
storage = {
|
||||||
disk.vdb.clear = true;
|
disk.vdb.clear = true;
|
||||||
disk.vdb.initlabel = true;
|
disk.vdb.initlabel = true;
|
||||||
|
@ -108,11 +111,9 @@ let
|
||||||
swapDevices = [
|
swapDevices = [
|
||||||
{ label = "swap"; storage = "partition.swap"; }
|
{ label = "swap"; storage = "partition.swap"; }
|
||||||
];
|
];
|
||||||
}
|
};
|
||||||
'';
|
|
||||||
|
|
||||||
raid = pkgs.writeText "raid.nix" ''
|
raid = {
|
||||||
{
|
|
||||||
storage = {
|
storage = {
|
||||||
disk.vdb.clear = true;
|
disk.vdb.clear = true;
|
||||||
disk.vdb.initlabel = true;
|
disk.vdb.initlabel = true;
|
||||||
|
@ -157,11 +158,9 @@ let
|
||||||
{ label = "swap1"; storage = "partition.swap1"; }
|
{ label = "swap1"; storage = "partition.swap1"; }
|
||||||
{ label = "swap2"; storage = "partition.swap2"; }
|
{ label = "swap2"; storage = "partition.swap2"; }
|
||||||
];
|
];
|
||||||
}
|
};
|
||||||
'';
|
|
||||||
|
|
||||||
raidLvmCrypt = pkgs.writeText "raid-lvm-crypt.nix" ''
|
raidLvmCrypt = {
|
||||||
{
|
|
||||||
storage = {
|
storage = {
|
||||||
disk.vdb.clear = true;
|
disk.vdb.clear = true;
|
||||||
disk.vdb.initlabel = true;
|
disk.vdb.initlabel = true;
|
||||||
|
@ -210,8 +209,7 @@ let
|
||||||
swapDevices = [
|
swapDevices = [
|
||||||
{ label = "swap"; storage = "logvol.swap"; }
|
{ label = "swap"; storage = "logvol.swap"; }
|
||||||
];
|
];
|
||||||
}
|
};
|
||||||
'';
|
|
||||||
|
|
||||||
in {
|
in {
|
||||||
name = "partitiion";
|
name = "partitiion";
|
||||||
|
@ -273,8 +271,8 @@ in {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub nixpart {
|
sub nixpart {
|
||||||
$machine->copyFileFromHost($_[0], "/storage.nix");
|
$machine->copyFileFromHost($_[0], "/storage.xml");
|
||||||
$machine->succeed("nixpart -v /storage.nix");
|
$machine->succeed("nixpart -v --from-xml /storage.xml");
|
||||||
ensureSanity;
|
ensureSanity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,7 +314,7 @@ in {
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
# Try to remount with nixpart
|
# Try to remount with nixpart
|
||||||
$machine->succeed("nixpart -vm /storage.nix");
|
$machine->succeed("nixpart -vm --from-xml /storage.xml");
|
||||||
ensureMountPoint("/mnt");
|
ensureMountPoint("/mnt");
|
||||||
# Check if our beloved canaries are dead
|
# Check if our beloved canaries are dead
|
||||||
chomp $canaries;
|
chomp $canaries;
|
||||||
|
@ -329,7 +327,7 @@ in {
|
||||||
}
|
}
|
||||||
|
|
||||||
parttest "ext2, ext3 and ext4 filesystems", sub {
|
parttest "ext2, ext3 and ext4 filesystems", sub {
|
||||||
nixpart("${ext}");
|
nixpart("${mkConf ext}");
|
||||||
ensurePartition("boot", "ext2");
|
ensurePartition("boot", "ext2");
|
||||||
ensurePartition("swap", "swap");
|
ensurePartition("swap", "swap");
|
||||||
ensurePartition("nix", "ext3");
|
ensurePartition("nix", "ext3");
|
||||||
|
@ -344,7 +342,7 @@ in {
|
||||||
|
|
||||||
parttest "btrfs filesystem", sub {
|
parttest "btrfs filesystem", sub {
|
||||||
$machine->succeed("modprobe btrfs");
|
$machine->succeed("modprobe btrfs");
|
||||||
nixpart("${btrfs}");
|
nixpart("${mkConf btrfs}");
|
||||||
ensurePartition("swap1", "swap");
|
ensurePartition("swap1", "swap");
|
||||||
ensurePartition("swap2", "swap");
|
ensurePartition("swap2", "swap");
|
||||||
ensurePartition("/dev/vdb2", "btrfs");
|
ensurePartition("/dev/vdb2", "btrfs");
|
||||||
|
@ -356,7 +354,7 @@ in {
|
||||||
|
|
||||||
parttest "f2fs filesystem", sub {
|
parttest "f2fs filesystem", sub {
|
||||||
$machine->succeed("modprobe f2fs");
|
$machine->succeed("modprobe f2fs");
|
||||||
nixpart("${f2fs}");
|
nixpart("${mkConf f2fs}");
|
||||||
ensurePartition("swap", "swap");
|
ensurePartition("swap", "swap");
|
||||||
ensurePartition("boot", "f2fs");
|
ensurePartition("boot", "f2fs");
|
||||||
ensurePartition("root", "f2fs");
|
ensurePartition("root", "f2fs");
|
||||||
|
@ -365,7 +363,7 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
parttest "RAID1 with XFS", sub {
|
parttest "RAID1 with XFS", sub {
|
||||||
nixpart("${raid}");
|
nixpart("${mkConf raid}");
|
||||||
ensurePartition("swap1", "swap");
|
ensurePartition("swap1", "swap");
|
||||||
ensurePartition("swap2", "swap");
|
ensurePartition("swap2", "swap");
|
||||||
ensurePartition("/dev/md0", "ext3");
|
ensurePartition("/dev/md0", "ext3");
|
||||||
|
@ -378,7 +376,7 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
parttest "RAID1 with LUKS and LVM", sub {
|
parttest "RAID1 with LUKS and LVM", sub {
|
||||||
nixpart("${raidLvmCrypt}");
|
nixpart("${mkConf raidLvmCrypt}");
|
||||||
ensurePartition("/dev/vdb1", "data");
|
ensurePartition("/dev/vdb1", "data");
|
||||||
ensureNoPartition("vdb2");
|
ensureNoPartition("vdb2");
|
||||||
ensurePartition("/dev/vdc1", "data");
|
ensurePartition("/dev/vdc1", "data");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user