* Parameterize the installer test to support different partitioning
schemes. * Added a test for installing NixOS with a separate /boot partition. svn path=/nixos/trunk/; revision=19283
This commit is contained in:
parent
fdc63c54e4
commit
a776afb085
21
release.nix
21
release.nix
@ -111,6 +111,10 @@ let
|
|||||||
minimal_install_archive = {system ? "i686-linux"}: (iso_minimal {inherit system;})
|
minimal_install_archive = {system ? "i686-linux"}: (iso_minimal {inherit system;})
|
||||||
.config.system.build.minimalInstallArchive;
|
.config.system.build.minimalInstallArchive;
|
||||||
|
|
||||||
|
# the archive installer can't be tested without chroot which requires being root
|
||||||
|
# options: run in kvm or uml ?
|
||||||
|
# TODO
|
||||||
|
|
||||||
tests =
|
tests =
|
||||||
{ services ? ../services }:
|
{ services ? ../services }:
|
||||||
let
|
let
|
||||||
@ -120,27 +124,14 @@ let
|
|||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
firefox = t.firefox.test;
|
firefox = t.firefox.test;
|
||||||
installer = t.installer.test;
|
installer.simple = t.installer.simple.test;
|
||||||
|
installer.separateBoot = t.installer.separateBoot.test;
|
||||||
kde4 = t.kde4.test;
|
kde4 = t.kde4.test;
|
||||||
quake3 = t.quake3.test;
|
quake3 = t.quake3.test;
|
||||||
subversion = t.subversion.report;
|
subversion = t.subversion.report;
|
||||||
trac = t.trac.test;
|
trac = t.trac.test;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
### tests about installing NixOS
|
|
||||||
|
|
||||||
# installs NixOs in a qemu_kvm instance using a tweaked iso.
|
|
||||||
tests.nixosInstallation =
|
|
||||||
(import ./tests/test-nixos-install-from-cd/test.nix {
|
|
||||||
inherit nixpkgs;
|
|
||||||
}).test;
|
|
||||||
*/
|
|
||||||
|
|
||||||
# the archive installer can't be tested without chroot which requires being root
|
|
||||||
# options: run in kvm or uml ?
|
|
||||||
# TODO
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,25 +9,27 @@ let
|
|||||||
(import ../lib/build-vms.nix { inherit nixpkgs services system; }) //
|
(import ../lib/build-vms.nix { inherit nixpkgs services system; }) //
|
||||||
(import ../lib/testing.nix { inherit nixpkgs services system; });
|
(import ../lib/testing.nix { inherit nixpkgs services system; });
|
||||||
|
|
||||||
apply = testFun:
|
in with testLib; let
|
||||||
with testLib;
|
|
||||||
let
|
call = f: f { inherit pkgs nixpkgs system testLib; };
|
||||||
t = testFun { inherit pkgs nixpkgs system testLib; };
|
|
||||||
in t // rec {
|
apply = testFun: complete (call testFun);
|
||||||
nodes =
|
|
||||||
if t ? nodes then t.nodes else
|
complete = t: t // rec {
|
||||||
if t ? machine then { machine = t.machine; }
|
nodes =
|
||||||
else { };
|
if t ? nodes then t.nodes else
|
||||||
vms = buildVirtualNetwork { inherit nodes; };
|
if t ? machine then { machine = t.machine; }
|
||||||
test = runTests vms t.testScript;
|
else { };
|
||||||
report = makeReport test;
|
vms = buildVirtualNetwork { inherit nodes; };
|
||||||
};
|
test = runTests vms t.testScript;
|
||||||
|
report = makeReport test;
|
||||||
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
firefox = apply (import ./firefox.nix);
|
firefox = apply (import ./firefox.nix);
|
||||||
installer = apply (import ./installer.nix);
|
installer = pkgs.lib.mapAttrs (name: complete) (call (import ./installer.nix));
|
||||||
kde4 = apply (import ./kde4.nix);
|
kde4 = apply (import ./kde4.nix);
|
||||||
quake3 = apply (import ./quake3.nix);
|
quake3 = apply (import ./quake3.nix);
|
||||||
subversion = apply (import ./subversion.nix);
|
subversion = apply (import ./subversion.nix);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{ pkgs, nixpkgs, system, ... }:
|
{ pkgs, nixpkgs, system, ... }:
|
||||||
|
|
||||||
rec {
|
let
|
||||||
|
|
||||||
# Build the ISO. This is the regular installation CD but with test
|
# Build the ISO. This is the regular installation CD but with test
|
||||||
# instrumentation.
|
# instrumentation.
|
||||||
@ -26,7 +26,7 @@ rec {
|
|||||||
}).config.system.build.isoImage;
|
}).config.system.build.isoImage;
|
||||||
|
|
||||||
# The configuration to install.
|
# The configuration to install.
|
||||||
config = pkgs.writeText "configuration.nix"
|
config = { fileSystems }: pkgs.writeText "configuration.nix"
|
||||||
''
|
''
|
||||||
{ config, pkgs, modulesPath, ... }:
|
{ config, pkgs, modulesPath, ... }:
|
||||||
|
|
||||||
@ -40,9 +40,7 @@ rec {
|
|||||||
boot.initrd.kernelModules = [ "ext3" ];
|
boot.initrd.kernelModules = [ "ext3" ];
|
||||||
|
|
||||||
fileSystems =
|
fileSystems =
|
||||||
[ { mountPoint = "/";
|
[ ${fileSystems}
|
||||||
device = "/dev/disk/by-label/nixos";
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
|
|
||||||
swapDevices =
|
swapDevices =
|
||||||
@ -50,9 +48,23 @@ rec {
|
|||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
rootFS =
|
||||||
|
''
|
||||||
|
{ mountPoint = "/";
|
||||||
|
device = "/dev/disk/by-label/nixos";
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
|
||||||
|
bootFS =
|
||||||
|
''
|
||||||
|
{ mountPoint = "/boot";
|
||||||
|
device = "/dev/disk/by-label/boot";
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
|
||||||
# The test script boots the CD, installs NixOS on an empty hard
|
# The test script boots the CD, installs NixOS on an empty hard
|
||||||
# disk, and then reboot from the hard disk.
|
# disk, and then reboot from the hard disk.
|
||||||
testScript =
|
testScriptFun = { createPartitions, fileSystems }:
|
||||||
''
|
''
|
||||||
createDisk("harddisk", 4 * 1024);
|
createDisk("harddisk", 4 * 1024);
|
||||||
|
|
||||||
@ -76,17 +88,7 @@ rec {
|
|||||||
or die "bad `hello' output";
|
or die "bad `hello' output";
|
||||||
|
|
||||||
# Partition the disk.
|
# Partition the disk.
|
||||||
$machine->mustSucceed(
|
${createPartitions}
|
||||||
"parted /dev/vda mklabel msdos",
|
|
||||||
"parted /dev/vda -- mkpart primary linux-swap 1M 1024M",
|
|
||||||
"parted /dev/vda -- mkpart primary ext2 1024M -1s",
|
|
||||||
# It can take udev a moment to create /dev/vda*.
|
|
||||||
"udevadm settle",
|
|
||||||
"mkswap /dev/vda1 -L swap",
|
|
||||||
"swapon -L swap",
|
|
||||||
"mkfs.ext3 -L nixos /dev/vda2",
|
|
||||||
"mount LABEL=nixos /mnt",
|
|
||||||
);
|
|
||||||
|
|
||||||
# Create the NixOS configuration.
|
# Create the NixOS configuration.
|
||||||
$machine->mustSucceed(
|
$machine->mustSucceed(
|
||||||
@ -97,11 +99,15 @@ rec {
|
|||||||
my $cfg = $machine->mustSucceed("cat /mnt/etc/nixos/hardware.nix");
|
my $cfg = $machine->mustSucceed("cat /mnt/etc/nixos/hardware.nix");
|
||||||
print STDERR "Result of the hardware scan:\n$cfg\n";
|
print STDERR "Result of the hardware scan:\n$cfg\n";
|
||||||
|
|
||||||
$machine->copyFileFromHost("${config}", "/mnt/etc/nixos/configuration.nix");
|
$machine->copyFileFromHost(
|
||||||
|
"${ config { inherit fileSystems; } }",
|
||||||
|
"/mnt/etc/nixos/configuration.nix");
|
||||||
|
|
||||||
# Perform the installation.
|
# Perform the installation.
|
||||||
$machine->mustSucceed("nixos-install >&2");
|
$machine->mustSucceed("nixos-install >&2");
|
||||||
|
|
||||||
|
$machine->mustSucceed("cat /boot/grub/grub.cfg >&2");
|
||||||
|
|
||||||
$machine->shutdown;
|
$machine->shutdown;
|
||||||
|
|
||||||
# Now see if we can boot the installation.
|
# Now see if we can boot the installation.
|
||||||
@ -109,12 +115,18 @@ rec {
|
|||||||
|
|
||||||
$machine->mustSucceed("echo hello");
|
$machine->mustSucceed("echo hello");
|
||||||
|
|
||||||
|
# Did /boot get mounted, if appropriate?
|
||||||
|
$machine->mustSucceed("initctl start filesystems");
|
||||||
|
$machine->mustSucceed("test -e /boot/grub/grub.cfg");
|
||||||
|
|
||||||
$machine->mustSucceed("nix-env -i coreutils >&2");
|
$machine->mustSucceed("nix-env -i coreutils >&2");
|
||||||
$machine->mustSucceed("type -tP ls") =~ /profiles/
|
$machine->mustSucceed("type -tP ls") =~ /profiles/
|
||||||
or die "nix-env failed";
|
or die "nix-env failed";
|
||||||
|
|
||||||
$machine->mustSucceed("nixos-rebuild switch >&2");
|
$machine->mustSucceed("nixos-rebuild switch >&2");
|
||||||
|
|
||||||
|
$machine->mustSucceed("cat /boot/grub/grub.cfg >&2");
|
||||||
|
|
||||||
$machine->shutdown;
|
$machine->shutdown;
|
||||||
|
|
||||||
# And just to be sure, check that the machine still boots after
|
# And just to be sure, check that the machine still boots after
|
||||||
@ -124,4 +136,54 @@ rec {
|
|||||||
$machine->shutdown;
|
$machine->shutdown;
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
makeTest = { createPartitions, fileSystems }:
|
||||||
|
{ inherit iso;
|
||||||
|
testScript = testScriptFun { inherit createPartitions fileSystems; };
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
in {
|
||||||
|
|
||||||
|
# The (almost) simplest partitioning scheme: a swap partition and
|
||||||
|
# one big filesystem partition.
|
||||||
|
simple = makeTest
|
||||||
|
{ createPartitions =
|
||||||
|
''
|
||||||
|
$machine->mustSucceed(
|
||||||
|
"parted /dev/vda mklabel msdos",
|
||||||
|
"parted /dev/vda -- mkpart primary linux-swap 1M 1024M",
|
||||||
|
"parted /dev/vda -- mkpart primary ext2 1024M -1s",
|
||||||
|
# It can take udev a moment to create /dev/vda*.
|
||||||
|
"udevadm settle",
|
||||||
|
"mkswap /dev/vda1 -L swap",
|
||||||
|
"swapon -L swap",
|
||||||
|
"mkfs.ext3 -L nixos /dev/vda2",
|
||||||
|
"mount LABEL=nixos /mnt",
|
||||||
|
);
|
||||||
|
'';
|
||||||
|
fileSystems = rootFS;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Same as the previous, but now with a separate /boot partition.
|
||||||
|
separateBoot = makeTest
|
||||||
|
{ createPartitions =
|
||||||
|
''
|
||||||
|
$machine->mustSucceed(
|
||||||
|
"parted /dev/vda mklabel msdos",
|
||||||
|
"parted /dev/vda -- mkpart primary ext2 1M 50MB", # /boot
|
||||||
|
"parted /dev/vda -- mkpart primary linux-swap 50MB 1024M",
|
||||||
|
"parted /dev/vda -- mkpart primary ext2 1024M -1s", # /
|
||||||
|
"udevadm settle",
|
||||||
|
"mkswap /dev/vda2 -L swap",
|
||||||
|
"swapon -L swap",
|
||||||
|
"mkfs.ext3 -L nixos /dev/vda3",
|
||||||
|
"mount LABEL=nixos /mnt",
|
||||||
|
"mkfs.ext3 -L boot /dev/vda1",
|
||||||
|
"mkdir /mnt/boot",
|
||||||
|
"mount LABEL=boot /mnt/boot",
|
||||||
|
);
|
||||||
|
'';
|
||||||
|
fileSystems = rootFS + bootFS;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user