Added install-test.sh - automatic verification of rescue-cd-configurable.nix (currently it passes)

svn path=/nixos/trunk/; revision=12006
This commit is contained in:
Michael Raskin 2008-06-07 10:52:44 +00:00
parent b8aa6c6f31
commit ae4ead1a33
5 changed files with 124 additions and 1 deletions

View File

@ -1,4 +1,7 @@
{platform ? __currentSystem} :
{
platform ? __currentSystem
,hostConnectPort ? "3737"
} :
let
isoFun = import ./rescue-cd-configurable.nix;
in
@ -33,6 +36,7 @@ in
pkgs.wpa_supplicant
pkgs.emacs
pkgs.vimHugeX
pkgs.socat
];
/*
@ -48,4 +52,17 @@ in
target = "/root/.ssh/authorized_keys";
}
];
additionalJobs = [
{
name = "Socat-ssh-proxy";
job = ''
start on sshd/started
script
sleep 5
/var/run/current-system/sw/bin/socat tcp:10.0.2.2:${hostConnectPort} tcp:127.0.0.1:22
end script
'';
}
];
}).rescueCD

View File

@ -39,15 +39,45 @@ cat > /mnt/etc/nixos/configuration.nix <<EOF
sshd = {
enable = true;
};
extraJobs = [
{
name = "Host-call-back";
job = ''
start on network-interfaces/started
script
while ! /var/run/current-system/sw/sbin/ifconfig eth0 |
/var/run/current-system/sw/bin/grep "inet addr:" &>/dev/null; do
sleep 1;
done
echo -e "Installation finished\nOK" | /var/run/current-system/sw/bin/socat stdio tcp:10.0.2.2:4424 | {
read;
if [ "\\\$REPLY" = "reboot" ] ; then
/var/run/current-system/sw/sbin/start ctrl-alt-delete;
fi;
}
end script
'';
}
];
};
fonts = {
enableFontConfig = false;
};
environment = {
extraPackages = pkgs: [
pkgs.socat
];
};
}
EOF
nixos-install
echo Installation finished
start ctrl-alt-delete

View File

@ -2,6 +2,10 @@
nohup bash -c 'NIX_REMOTE= ./install-script.sh &>/dev/tty11' &
sleep 1;
chvt 11 || true;
disown
exit

View File

@ -0,0 +1,69 @@
#! /bin/sh -i
if test -z "$INSTALL_TEST_RUNNING" ; then
export INSTALL_TEST_RUNNING=1;
export ORIGINAL_NAME="$0";
sh -i < "$ORIGINAL_NAME";
exit;
fi;
if ! eval ' ( sleep 0.1; exit 0; ) & fg ' ; then
echo "Failing job control test";
exit;
fi;
set -x
echo "Installation starting.." > report
nix-build -o socat /etc/nixos/nixpkgs -A socat
nix-build -o qemu /etc/nixos/nixpkgs -A qemu
echo "reboot" | ./socat/bin/socat tcp-listen:4424 stdio >> report &
if ( ! [ -d dvd/iso ] ) || ( [ -z "$USE_LEFTOVER_DVD" ] ); then
rm dvd
nix-build -o dvd /etc/nixos/nixos/configuration/closed-install.nix
fi;
if ( ! [ -f install-test.img ] ) || ( [ -z "$JUST_BOOT" ] ); then
rm install-test.img
./qemu/bin/qemu-img create -f qcow2 install-test.img 5G
./qemu/bin/qemu --kernel-kqemu -m 512 -cdrom dvd/iso/nixos-*.iso -hda install-test.img -boot d -no-reboot &
./socat/bin/socat tcp-listen:4425 tcp-listen:3737 &
sleep 1;
sed -e '/^127[.]0[.]0[.]1/d; /^\[127[.]0[.]0[.]1/d' -i ~/.ssh/known_hosts || true;
(
echo "cat > install-script.sh <<BIGEOF"
cat $(dirname "$ORIGINAL_NAME")/install-script.sh
echo BIGEOF
echo "cat > install-start.sh <<BIGEOF"
cat $(dirname "$ORIGINAL_NAME")/install-start.sh
echo BIGEOF
echo 'chmod a+x *.sh'
echo './install-start.sh'
) | ssh -l root -i /var/certs/ssh/id_livedvd -o StrictHostKeyChecking=no 127.0.0.1 -p 4425
fi;
./qemu/bin/qemu --kernel-kqemu -m 512 install-test.img -no-reboot
echo "Report contains: "
cat report
set +x
if [ -n "$GC_DVD" ] ; then
rm dvd; nix-store --delete $(readlink -f dvd);
fi;
if [ -n "$DO_CLEANUP" ]; then
rm dvd ; rm socat ; rm qemu ; rm install-test.img ;
fi;
test OK = "$(tail -1 report)";

View File

@ -41,6 +41,7 @@
,additionalFiles ? []
,compressImage ? false
,nixpkgsPath ? ../../nixpkgs
,additionalJobs ? []
}:
let
realLib = if lib != null then lib else (import (nixpkgsPath+"/pkgs/lib"));
@ -182,6 +183,8 @@ rec {
}
]
++ additionalJobs
++
(lib.optional manualEnabled