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:
aszlig 2014-11-04 07:28:08 +01:00
parent ccc768a00d
commit 8c3790b0de
No known key found for this signature in database
GPG Key ID: D0EBD0EC8C2DC961

View File

@ -3,215 +3,213 @@ 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> {
storage = { modules = singleton cfg;
disk.vdb.clear = true; }).config;
disk.vdb.initlabel = true; in pkgs.writeText "storage.xml" (builtins.toXML {
inherit (config) storage fileSystems swapDevices;
});
partition.boot.size = "100M"; ext = {
partition.boot.targetDevice = "disk.vdb"; storage = {
partition.swap.size = "500M"; disk.vdb.clear = true;
partition.swap.targetDevice = "disk.vdb"; disk.vdb.initlabel = true;
partition.nix.size = "500M";
partition.nix.targetDevice = "disk.vdb";
partition.root.grow = true;
partition.root.targetDevice = "disk.vdb";
};
fileSystems."/boot" = { partition.boot.size = "100M";
label = "boot"; partition.boot.targetDevice = "disk.vdb";
fsType = "ext2"; partition.swap.size = "500M";
storage = "partition.boot"; partition.swap.targetDevice = "disk.vdb";
}; partition.nix.size = "500M";
partition.nix.targetDevice = "disk.vdb";
partition.root.grow = true;
partition.root.targetDevice = "disk.vdb";
};
fileSystems."/nix" = { fileSystems."/boot" = {
label = "nix"; label = "boot";
fsType = "ext3"; fsType = "ext2";
storage = "partition.nix"; storage = "partition.boot";
}; };
fileSystems."/" = { fileSystems."/nix" = {
label = "root"; label = "nix";
fsType = "ext4"; fsType = "ext3";
storage = "partition.root"; storage = "partition.nix";
}; };
swapDevices = [ fileSystems."/" = {
{ label = "swap"; storage = "partition.swap"; } label = "root";
]; fsType = "ext4";
} storage = "partition.root";
''; };
btrfs = pkgs.writeText "btrfs.nix" '' swapDevices = [
{ { label = "swap"; storage = "partition.swap"; }
storage = { ];
disk.vdb.clear = true; };
disk.vdb.initlabel = true;
partition.swap1.size = "500M"; btrfs = {
partition.swap1.targetDevice = "disk.vdb"; storage = {
partition.btrfs1.grow = true; disk.vdb.clear = true;
partition.btrfs1.targetDevice = "disk.vdb"; disk.vdb.initlabel = true;
disk.vdc.clear = true; partition.swap1.size = "500M";
disk.vdc.initlabel = true; partition.swap1.targetDevice = "disk.vdb";
partition.btrfs1.grow = true;
partition.btrfs1.targetDevice = "disk.vdb";
partition.swap2.size = "500M"; disk.vdc.clear = true;
partition.swap2.targetDevice = "disk.vdc"; disk.vdc.initlabel = true;
partition.btrfs2.grow = true;
partition.btrfs2.targetDevice = "disk.vdc";
btrfs.root.data = 0; partition.swap2.size = "500M";
btrfs.root.metadata = 1; partition.swap2.targetDevice = "disk.vdc";
btrfs.root.devices = [ "partition.btrfs1" "partition.btrfs2" ]; partition.btrfs2.grow = true;
}; partition.btrfs2.targetDevice = "disk.vdc";
fileSystems."/" = { btrfs.root.data = 0;
label = "root"; btrfs.root.metadata = 1;
storage = "btrfs.root"; btrfs.root.devices = [ "partition.btrfs1" "partition.btrfs2" ];
}; };
swapDevices = [ fileSystems."/" = {
{ label = "swap1"; storage = "partition.swap1"; } label = "root";
{ label = "swap2"; storage = "partition.swap2"; } storage = "btrfs.root";
]; };
}
'';
f2fs = pkgs.writeText "f2fs.nix" '' swapDevices = [
{ { label = "swap1"; storage = "partition.swap1"; }
storage = { { label = "swap2"; storage = "partition.swap2"; }
disk.vdb.clear = true; ];
disk.vdb.initlabel = true; };
partition.swap.size = "500M"; f2fs = {
partition.swap.targetDevice = "disk.vdb"; storage = {
partition.boot.size = "100M"; disk.vdb.clear = true;
partition.boot.targetDevice = "disk.vdb"; disk.vdb.initlabel = true;
partition.root.grow = true;
partition.root.targetDevice = "disk.vdb";
};
fileSystems."/boot" = { partition.swap.size = "500M";
label = "boot"; partition.swap.targetDevice = "disk.vdb";
fsType = "f2fs"; partition.boot.size = "100M";
storage = "partition.boot"; partition.boot.targetDevice = "disk.vdb";
}; partition.root.grow = true;
partition.root.targetDevice = "disk.vdb";
};
fileSystems."/" = { fileSystems."/boot" = {
label = "root"; label = "boot";
fsType = "f2fs"; fsType = "f2fs";
storage = "partition.root"; storage = "partition.boot";
}; };
swapDevices = [ fileSystems."/" = {
{ label = "swap"; storage = "partition.swap"; } label = "root";
]; fsType = "f2fs";
} storage = "partition.root";
''; };
raid = pkgs.writeText "raid.nix" '' swapDevices = [
{ { label = "swap"; storage = "partition.swap"; }
storage = { ];
disk.vdb.clear = true; };
disk.vdb.initlabel = true;
partition.raid01.size = "200M"; raid = {
partition.raid01.targetDevice = "disk.vdb"; storage = {
partition.swap1.size = "500M"; disk.vdb.clear = true;
partition.swap1.targetDevice = "disk.vdb"; disk.vdb.initlabel = true;
partition.raid11.grow = true;
partition.raid11.targetDevice = "disk.vdb";
disk.vdc.clear = true; partition.raid01.size = "200M";
disk.vdc.initlabel = true; partition.raid01.targetDevice = "disk.vdb";
partition.swap1.size = "500M";
partition.swap1.targetDevice = "disk.vdb";
partition.raid11.grow = true;
partition.raid11.targetDevice = "disk.vdb";
partition.raid02.size = "200M"; disk.vdc.clear = true;
partition.raid02.targetDevice = "disk.vdc"; disk.vdc.initlabel = true;
partition.swap2.size = "500M";
partition.swap2.targetDevice = "disk.vdc";
partition.raid12.grow = true;
partition.raid12.targetDevice = "disk.vdc";
mdraid.boot.level = 1; partition.raid02.size = "200M";
mdraid.boot.devices = [ "partition.raid01" "partition.raid02" ]; partition.raid02.targetDevice = "disk.vdc";
partition.swap2.size = "500M";
partition.swap2.targetDevice = "disk.vdc";
partition.raid12.grow = true;
partition.raid12.targetDevice = "disk.vdc";
mdraid.root.level = 1; mdraid.boot.level = 1;
mdraid.root.devices = [ "partition.raid11" "partition.raid12" ]; mdraid.boot.devices = [ "partition.raid01" "partition.raid02" ];
};
fileSystems."/boot" = { mdraid.root.level = 1;
label = "boot"; mdraid.root.devices = [ "partition.raid11" "partition.raid12" ];
fsType = "ext3"; };
storage = "mdraid.boot";
};
fileSystems."/" = { fileSystems."/boot" = {
label = "root"; label = "boot";
fsType = "xfs"; fsType = "ext3";
storage = "mdraid.root"; storage = "mdraid.boot";
}; };
swapDevices = [ fileSystems."/" = {
{ label = "swap1"; storage = "partition.swap1"; } label = "root";
{ label = "swap2"; storage = "partition.swap2"; } fsType = "xfs";
]; storage = "mdraid.root";
} };
'';
raidLvmCrypt = pkgs.writeText "raid-lvm-crypt.nix" '' swapDevices = [
{ { label = "swap1"; storage = "partition.swap1"; }
storage = { { label = "swap2"; storage = "partition.swap2"; }
disk.vdb.clear = true; ];
disk.vdb.initlabel = true; };
partition.raid1.grow = true; raidLvmCrypt = {
partition.raid1.targetDevice = "disk.vdb"; storage = {
disk.vdb.clear = true;
disk.vdb.initlabel = true;
disk.vdc.clear = true; partition.raid1.grow = true;
disk.vdc.initlabel = true; partition.raid1.targetDevice = "disk.vdb";
partition.raid2.grow = true; disk.vdc.clear = true;
partition.raid2.targetDevice = "disk.vdc"; disk.vdc.initlabel = true;
mdraid.raid.level = 1; partition.raid2.grow = true;
mdraid.raid.devices = [ "partition.raid1" "partition.raid2" ]; partition.raid2.targetDevice = "disk.vdc";
/* TODO! mdraid.raid.level = 1;
luks.volroot.passphrase = "x"; mdraid.raid.devices = [ "partition.raid1" "partition.raid2" ];
luks.volroot.targetDevice = "mdraid.raid";
*/
volgroup.nixos.devices = [ "luks.volroot" ]; /* TODO!
luks.volroot.passphrase = "x";
luks.volroot.targetDevice = "mdraid.raid";
*/
logvol.boot.size = "200M"; volgroup.nixos.devices = [ "luks.volroot" ];
logvol.boot.group = "volgroup.nixos";
logvol.swap.size = "500M"; logvol.boot.size = "200M";
logvol.swap.group = "volgroup.nixos"; logvol.boot.group = "volgroup.nixos";
logvol.root.grow = true; logvol.swap.size = "500M";
logvol.root.group = "volgroup.nixos"; logvol.swap.group = "volgroup.nixos";
};
fileSystems."/boot" = { logvol.root.grow = true;
label = "boot"; logvol.root.group = "volgroup.nixos";
fsType = "ext3"; };
storage = "logvol.boot";
};
fileSystems."/" = { fileSystems."/boot" = {
label = "root"; label = "boot";
fsType = "ext4"; fsType = "ext3";
storage = "logvol.root"; storage = "logvol.boot";
}; };
swapDevices = [ fileSystems."/" = {
{ label = "swap"; storage = "logvol.swap"; } label = "root";
]; fsType = "ext4";
} storage = "logvol.root";
''; };
swapDevices = [
{ 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");