mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 15:03:28 +00:00
* 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;})
|
||||
.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 =
|
||||
{ services ? ../services }:
|
||||
let
|
||||
@ -120,27 +124,14 @@ let
|
||||
};
|
||||
in {
|
||||
firefox = t.firefox.test;
|
||||
installer = t.installer.test;
|
||||
installer.simple = t.installer.simple.test;
|
||||
installer.separateBoot = t.installer.separateBoot.test;
|
||||
kde4 = t.kde4.test;
|
||||
quake3 = t.quake3.test;
|
||||
subversion = t.subversion.report;
|
||||
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/testing.nix { inherit nixpkgs services system; });
|
||||
|
||||
apply = testFun:
|
||||
with testLib;
|
||||
let
|
||||
t = testFun { inherit pkgs nixpkgs system testLib; };
|
||||
in t // rec {
|
||||
nodes =
|
||||
if t ? nodes then t.nodes else
|
||||
if t ? machine then { machine = t.machine; }
|
||||
else { };
|
||||
vms = buildVirtualNetwork { inherit nodes; };
|
||||
test = runTests vms t.testScript;
|
||||
report = makeReport test;
|
||||
};
|
||||
in with testLib; let
|
||||
|
||||
call = f: f { inherit pkgs nixpkgs system testLib; };
|
||||
|
||||
apply = testFun: complete (call testFun);
|
||||
|
||||
complete = t: t // rec {
|
||||
nodes =
|
||||
if t ? nodes then t.nodes else
|
||||
if t ? machine then { machine = t.machine; }
|
||||
else { };
|
||||
vms = buildVirtualNetwork { inherit nodes; };
|
||||
test = runTests vms t.testScript;
|
||||
report = makeReport test;
|
||||
};
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
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);
|
||||
quake3 = apply (import ./quake3.nix);
|
||||
subversion = apply (import ./subversion.nix);
|
||||
|
@ -1,6 +1,6 @@
|
||||
{ pkgs, nixpkgs, system, ... }:
|
||||
|
||||
rec {
|
||||
let
|
||||
|
||||
# Build the ISO. This is the regular installation CD but with test
|
||||
# instrumentation.
|
||||
@ -26,7 +26,7 @@ rec {
|
||||
}).config.system.build.isoImage;
|
||||
|
||||
# The configuration to install.
|
||||
config = pkgs.writeText "configuration.nix"
|
||||
config = { fileSystems }: pkgs.writeText "configuration.nix"
|
||||
''
|
||||
{ config, pkgs, modulesPath, ... }:
|
||||
|
||||
@ -40,9 +40,7 @@ rec {
|
||||
boot.initrd.kernelModules = [ "ext3" ];
|
||||
|
||||
fileSystems =
|
||||
[ { mountPoint = "/";
|
||||
device = "/dev/disk/by-label/nixos";
|
||||
}
|
||||
[ ${fileSystems}
|
||||
];
|
||||
|
||||
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
|
||||
# disk, and then reboot from the hard disk.
|
||||
testScript =
|
||||
testScriptFun = { createPartitions, fileSystems }:
|
||||
''
|
||||
createDisk("harddisk", 4 * 1024);
|
||||
|
||||
@ -76,17 +88,7 @@ rec {
|
||||
or die "bad `hello' output";
|
||||
|
||||
# Partition the disk.
|
||||
$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",
|
||||
);
|
||||
${createPartitions}
|
||||
|
||||
# Create the NixOS configuration.
|
||||
$machine->mustSucceed(
|
||||
@ -97,11 +99,15 @@ rec {
|
||||
my $cfg = $machine->mustSucceed("cat /mnt/etc/nixos/hardware.nix");
|
||||
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.
|
||||
$machine->mustSucceed("nixos-install >&2");
|
||||
|
||||
$machine->mustSucceed("cat /boot/grub/grub.cfg >&2");
|
||||
|
||||
$machine->shutdown;
|
||||
|
||||
# Now see if we can boot the installation.
|
||||
@ -109,12 +115,18 @@ rec {
|
||||
|
||||
$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("type -tP ls") =~ /profiles/
|
||||
or die "nix-env failed";
|
||||
|
||||
$machine->mustSucceed("nixos-rebuild switch >&2");
|
||||
|
||||
$machine->mustSucceed("cat /boot/grub/grub.cfg >&2");
|
||||
|
||||
$machine->shutdown;
|
||||
|
||||
# And just to be sure, check that the machine still boots after
|
||||
@ -124,4 +136,54 @@ rec {
|
||||
$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…
Reference in New Issue
Block a user