Add curing vm tests (#312)

* add some additional vm tests

* Wire things up

* Add further tests

* Fixups

* Add more exhaustive default test check

* Whoops fmt

* Disable a currently breaking test

* Repair notice content in CONTRIBUTING.md
This commit is contained in:
Ana Hobden 2023-03-09 09:29:49 -08:00 committed by GitHub
parent 385283173b
commit f2437037f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 111 additions and 11 deletions

View file

@ -196,9 +196,11 @@ nix build .#hydraJobs.vm-test.all.x86_64-linux.all -L
To run a specific distribution listed in the `nix flake show` output:
```bash
nix build .#hydraJobs.vm-test.rhel-v7.x86_64-linux.all -L
nix build .#hydraJobs.vm-test.rhel-v7.x86_64-linux.all -L -j 4
```
> You may wish to set `-j 4` to some other number. Some OS's (Ubuntu 16.04) exhibit problems rapidly updating their users/groups on a system running dozens of VMs.
For PR review, you can also test arbitrary branches or checkouts like so:
```bash
@ -276,9 +278,7 @@ git+file:///home/ana/git/determinatesystems/nix-installer
To run all of the currently supported tests:
```bash
nix build .#hydraJobs.container-test.all.x86_64-linux.all -L
```
> You may wish to set `-j 4` to some other number. Some OS's (Ubuntu 16.04) exhibit problems rapidly updating their users/groups on a system running dozens of VMs.
To run a specific distribution listed in the `nix flake show` output:

View file

@ -69,7 +69,7 @@
src = builtins.path {
name = "nix-installer-source";
path = self;
filter = (path: type: baseNameOf path != "nix" || baseNameOf path != ".github");
filter = (path: type: baseNameOf path != "nix" && baseNameOf path != ".github");
};
nativeBuildInputs = with final; [ ];

View file

@ -2,8 +2,7 @@
{ forSystem, binaryTarball }:
let
installScripts = {
installScripts = rec {
install-default = {
install = ''
NIX_PATH=$(readlink -f nix.tar.xz)
@ -12,6 +11,13 @@ let
check = ''
set -ex
if systemctl is-active nix-daemon.socket; then
echo "nix-daemon.socket was active"
else
echo "nix-daemon.socket was not active, should be"
exit 1
fi
nix-env --version
nix --extra-experimental-features nix-command store ping
@ -35,13 +41,12 @@ let
echo "nix-daemon.service was running, should not be"
exit 1
fi
sudo systemctl start nix-daemon.socket
nix-env --version
nix --extra-experimental-features nix-command store ping
out=$(nix-build --no-substitute -E 'derivation { name = "foo"; system = "x86_64-linux"; builder = "/bin/sh"; args = ["-c" "echo foobar > $out"]; }')
[[ $(cat $out) = foobar ]]
'';
};
@ -52,15 +57,76 @@ let
'';
check = ''
set -ex
sudo -i nix-env --version
sudo -i nix --extra-experimental-features nix-command store ping
echo 'derivation { name = "foo"; system = "x86_64-linux"; builder = "/bin/sh"; args = ["-c" "echo foobar > $out"]; }' | sudo tee -a /drv
out=$(sudo -i nix-build --no-substitute /drv)
[[ $(cat $out) = foobar ]]
'';
};
install-preexisting-self-working = {
preinstall = ''
NIX_PATH=$(readlink -f nix.tar.xz)
RUST_BACKTRACE="full" ./nix-installer install --nix-package-url "file://$NIX_PATH" --no-confirm
sudo mv /nix/receipt.json /nix/old-receipt.json
'';
install = install-default.install;
check = install-default.check;
};
# install-preexisting-self-broken-no-nix-path = {
# preinstall = ''
# NIX_PATH=$(readlink -f nix.tar.xz)
# RUST_BACKTRACE="full" ./nix-installer install --nix-package-url "file://$NIX_PATH" --no-confirm
# sudo mv /nix/receipt.json /nix/old-receipt.json
# sudo rm -rf /nix/
# '';
# install = install-default.install;
# check = install-default.check;
# };
install-preexisting-self-broken-missing-users = {
preinstall = ''
NIX_PATH=$(readlink -f nix.tar.xz)
RUST_BACKTRACE="full" ./nix-installer install --nix-package-url "file://$NIX_PATH" --no-confirm
sudo mv /nix/receipt.json /nix/old-receipt.json
sudo userdel nixbld1
sudo userdel nixbld3
sudo userdel nixbld16
'';
install = install-default.install;
check = install-default.check;
};
install-preexisting-self-broken-daemon-disabled = {
preinstall = ''
NIX_PATH=$(readlink -f nix.tar.xz)
RUST_BACKTRACE="full" ./nix-installer install --nix-package-url "file://$NIX_PATH" --no-confirm
sudo mv /nix/receipt.json /nix/old-receipt.json
sudo systemctl disable --now nix-daemon.socket
'';
install = install-default.install;
check = install-default.check;
};
install-preexisting-self-broken-no-etc-nix = {
preinstall = ''
NIX_PATH=$(readlink -f nix.tar.xz)
RUST_BACKTRACE="full" ./nix-installer install --nix-package-url "file://$NIX_PATH" --no-confirm
sudo mv /nix/receipt.json /nix/old-receipt.json
sudo rm -rf /etc/nix
'';
install = install-default.install;
check = install-default.check;
};
install-preexisting-self-broken-unmodified-bashrc = {
preinstall = ''
NIX_PATH=$(readlink -f nix.tar.xz)
RUST_BACKTRACE="full" ./nix-installer install --nix-package-url "file://$NIX_PATH" --no-confirm
sudo mv /nix/receipt.json /nix/old-receipt.json
sudo sed -i '/# Nix/,/# End Nix/d' /etc/bash.bashrc
'';
install = install-default.install;
check = install-default.check;
};
};
disableSELinux = "sudo setenforce 0";
@ -165,6 +231,7 @@ let
buildInputs = [ qemu_kvm openssh ];
image = image.image;
postBoot = image.postBoot or "";
preinstallScript = installScripts.${testName}.preinstall or "echo \"Not Applicable\"";
installScript = installScripts.${testName}.install;
checkScript = installScripts.${testName}.check;
installer = nix-installer-static;
@ -230,13 +297,16 @@ let
echo "Copying nix tarball..."
scp -P 20022 $ssh_opts $binaryTarball/nix-*.tar.xz vagrant@localhost:nix.tar.xz
echo "Running preinstall..."
$ssh "set -eux; $preinstallScript"
echo "Running installer..."
$ssh "set -eux; $installScript"
echo "Testing Nix installation..."
$ssh "set -eux; $checkScript"
echo "Testing Nix installation..."
echo "Testing Nix uninstallation..."
$ssh "set -eux; /nix/nix-installer uninstall --no-confirm"
echo "Done!"
@ -280,12 +350,42 @@ vm-tests // rec {
name = "all";
constituents = pkgs.lib.mapAttrsToList (name: value: value."x86_64-linux".install-daemonless) vm-tests;
});
all."x86_64-linux".install-preexisting-self-working = (with (forSystem "x86_64-linux" ({ system, pkgs, ... }: pkgs)); pkgs.releaseTools.aggregate {
name = "all";
constituents = pkgs.lib.mapAttrsToList (name: value: value."x86_64-linux".install-preexisting-self-working) vm-tests;
});
# all."x86_64-linux".install-preexisting-self-broken-no-nix-path = (with (forSystem "x86_64-linux" ({ system, pkgs, ... }: pkgs)); pkgs.releaseTools.aggregate {
# name = "all";
# constituents = pkgs.lib.mapAttrsToList (name: value: value."x86_64-linux".install-preexisting-self-broken-no-nix-path) vm-tests;
# });
all."x86_64-linux".install-preexisting-self-broken-missing-users = (with (forSystem "x86_64-linux" ({ system, pkgs, ... }: pkgs)); pkgs.releaseTools.aggregate {
name = "all";
constituents = pkgs.lib.mapAttrsToList (name: value: value."x86_64-linux".install-preexisting-self-broken-missing-users) vm-tests;
});
all."x86_64-linux".install-preexisting-self-broken-daemon-disabled = (with (forSystem "x86_64-linux" ({ system, pkgs, ... }: pkgs)); pkgs.releaseTools.aggregate {
name = "all";
constituents = pkgs.lib.mapAttrsToList (name: value: value."x86_64-linux".install-preexisting-self-broken-daemon-disabled) vm-tests;
});
all."x86_64-linux".install-preexisting-self-broken-no-etc-nix = (with (forSystem "x86_64-linux" ({ system, pkgs, ... }: pkgs)); pkgs.releaseTools.aggregate {
name = "all";
constituents = pkgs.lib.mapAttrsToList (name: value: value."x86_64-linux".install-preexisting-self-broken-no-etc-nix) vm-tests;
});
all."x86_64-linux".install-preexisting-self-broken-unmodified-bashrc = (with (forSystem "x86_64-linux" ({ system, pkgs, ... }: pkgs)); pkgs.releaseTools.aggregate {
name = "all";
constituents = pkgs.lib.mapAttrsToList (name: value: value."x86_64-linux".install-preexisting-self-broken-unmodified-bashrc) vm-tests;
});
all."x86_64-linux".all = (with (forSystem "x86_64-linux" ({ system, pkgs, ... }: pkgs)); pkgs.releaseTools.aggregate {
name = "all";
constituents = [
all."x86_64-linux".install-default
all."x86_64-linux".install-no-start-daemon
all."x86_64-linux".install-daemonless
all."x86_64-linux".install-preexisting-self-working
# all."x86_64-linux".install-preexisting-self-broken-no-nix-path
all."x86_64-linux".install-preexisting-self-broken-missing-users
all."x86_64-linux".install-preexisting-self-broken-daemon-disabled
all."x86_64-linux".install-preexisting-self-broken-no-etc-nix
all."x86_64-linux".install-preexisting-self-broken-unmodified-bashrc
];
});
}