-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an installer test #7043
Merged
Merged
Add an installer test #7043
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
fae3b4f
Add an installer test
edolstra 0a8e666
Add Fedora 36
edolstra 906c947
Enable daemon installation test on Fedora
edolstra cc6e312
Get Ubuntu 22.10 to work
edolstra fe958a6
Test building
edolstra 29aaec1
Make cross product of images and tests
edolstra 5c8cdb9
Add Ubuntu 22.04 LTS
edolstra ef714aa
Remove pre-release Ubuntu 22.10
edolstra 503f31e
Use libvirt image
edolstra a96ad2a
Add RHEL 7/8
edolstra ba04b5b
Disable Ubuntu 14.04
edolstra 3dd313a
Add RHEL 9
edolstra 0d4bf9c
Fix evaluation
edolstra eceaf19
Remove FIXME
edolstra 71e364c
Quote URLs
edolstra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,220 @@ | ||
{ binaryTarballs | ||
, nixpkgsFor | ||
}: | ||
|
||
let | ||
|
||
installScripts = { | ||
install-default = { | ||
script = '' | ||
tar -xf ./nix.tar.xz | ||
mv ./nix-* nix | ||
./nix/install --no-channel-add | ||
''; | ||
}; | ||
|
||
install-force-no-daemon = { | ||
script = '' | ||
tar -xf ./nix.tar.xz | ||
mv ./nix-* nix | ||
./nix/install --no-daemon | ||
''; | ||
}; | ||
|
||
install-force-daemon = { | ||
script = '' | ||
tar -xf ./nix.tar.xz | ||
mv ./nix-* nix | ||
./nix/install --daemon --no-channel-add | ||
''; | ||
}; | ||
}; | ||
|
||
disableSELinux = "sudo setenforce 0"; | ||
|
||
images = { | ||
|
||
/* | ||
"ubuntu-14-04" = { | ||
image = import <nix/fetchurl.nix> { | ||
url = "https://app.vagrantup.com/ubuntu/boxes/trusty64/versions/20190514.0.0/providers/virtualbox.box"; | ||
hash = "sha256-iUUXyRY8iW7DGirb0zwGgf1fRbLA7wimTJKgP7l/OQ8="; | ||
}; | ||
rootDisk = "box-disk1.vmdk"; | ||
system = "x86_64-linux"; | ||
}; | ||
*/ | ||
|
||
"ubuntu-16-04" = { | ||
image = import <nix/fetchurl.nix> { | ||
url = "https://app.vagrantup.com/generic/boxes/ubuntu1604/versions/4.1.12/providers/libvirt.box"; | ||
hash = "sha256-lO4oYQR2tCh5auxAYe6bPOgEqOgv3Y3GC1QM1tEEEU8="; | ||
}; | ||
rootDisk = "box.img"; | ||
system = "x86_64-linux"; | ||
}; | ||
|
||
"ubuntu-22-04" = { | ||
image = import <nix/fetchurl.nix> { | ||
url = "https://app.vagrantup.com/generic/boxes/ubuntu2204/versions/4.1.12/providers/libvirt.box"; | ||
hash = "sha256-HNll0Qikw/xGIcogni5lz01vUv+R3o8xowP2EtqjuUQ="; | ||
}; | ||
rootDisk = "box.img"; | ||
system = "x86_64-linux"; | ||
}; | ||
|
||
"fedora-36" = { | ||
image = import <nix/fetchurl.nix> { | ||
url = "https://app.vagrantup.com/generic/boxes/fedora36/versions/4.1.12/providers/libvirt.box"; | ||
hash = "sha256-rxPgnDnFkTDwvdqn2CV3ZUo3re9AdPtSZ9SvOHNvaks="; | ||
}; | ||
rootDisk = "box.img"; | ||
system = "x86_64-linux"; | ||
postBoot = disableSELinux; | ||
}; | ||
|
||
# Currently fails with 'error while loading shared libraries: | ||
# libsodium.so.23: cannot stat shared object: Invalid argument'. | ||
/* | ||
"rhel-6" = { | ||
image = import <nix/fetchurl.nix> { | ||
url = "https://app.vagrantup.com/generic/boxes/rhel6/versions/4.1.12/providers/libvirt.box"; | ||
hash = "sha256-QwzbvRoRRGqUCQptM7X/InRWFSP2sqwRt2HaaO6zBGM="; | ||
}; | ||
rootDisk = "box.img"; | ||
system = "x86_64-linux"; | ||
}; | ||
*/ | ||
|
||
"rhel-7" = { | ||
image = import <nix/fetchurl.nix> { | ||
url = "https://app.vagrantup.com/generic/boxes/rhel7/versions/4.1.12/providers/libvirt.box"; | ||
hash = "sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="; | ||
}; | ||
rootDisk = "box.img"; | ||
system = "x86_64-linux"; | ||
}; | ||
|
||
"rhel-8" = { | ||
image = import <nix/fetchurl.nix> { | ||
url = "https://app.vagrantup.com/generic/boxes/rhel8/versions/4.1.12/providers/libvirt.box"; | ||
hash = "sha256-zFOPjSputy1dPgrQRixBXmlyN88cAKjJ21VvjSWUCUY="; | ||
}; | ||
rootDisk = "box.img"; | ||
system = "x86_64-linux"; | ||
postBoot = disableSELinux; | ||
}; | ||
|
||
"rhel-9" = { | ||
image = import <nix/fetchurl.nix> { | ||
url = "https://app.vagrantup.com/generic/boxes/rhel9/versions/4.1.12/providers/libvirt.box"; | ||
hash = "sha256-vL/FbB3kK1rcSaR627nWmScYGKGk4seSmAdq6N5diMg="; | ||
}; | ||
rootDisk = "box.img"; | ||
system = "x86_64-linux"; | ||
postBoot = disableSELinux; | ||
extraQemuOpts = "-cpu Westmere-v2"; | ||
}; | ||
|
||
}; | ||
|
||
makeTest = imageName: testName: | ||
let image = images.${imageName}; in | ||
with nixpkgsFor.${image.system}; | ||
runCommand | ||
"installer-test-${imageName}-${testName}" | ||
{ buildInputs = [ qemu_kvm openssh ]; | ||
image = image.image; | ||
postBoot = image.postBoot or ""; | ||
installScript = installScripts.${testName}.script; | ||
binaryTarball = binaryTarballs.${system}; | ||
} | ||
'' | ||
shopt -s nullglob | ||
|
||
echo "Unpacking Vagrant box $image..." | ||
tar xvf $image | ||
|
||
image_type=$(qemu-img info ${image.rootDisk} | sed 's/file format: \(.*\)/\1/; t; d') | ||
|
||
qemu-img create -b ./${image.rootDisk} -F "$image_type" -f qcow2 ./disk.qcow2 | ||
|
||
extra_qemu_opts="${image.extraQemuOpts or ""}" | ||
|
||
# Add the config disk, required by the Ubuntu images. | ||
config_drive=$(echo *configdrive.vmdk || true) | ||
if [[ -n $config_drive ]]; then | ||
extra_qemu_opts+=" -drive id=disk2,file=$config_drive,if=virtio" | ||
fi | ||
|
||
echo "Starting qemu..." | ||
qemu-kvm -m 4096 -nographic \ | ||
-drive id=disk1,file=./disk.qcow2,if=virtio \ | ||
-netdev user,id=net0,restrict=yes,hostfwd=tcp::20022-:22 -device virtio-net-pci,netdev=net0 \ | ||
$extra_qemu_opts & | ||
qemu_pid=$! | ||
trap "kill $qemu_pid" EXIT | ||
|
||
if ! [ -e ./vagrant_insecure_key ]; then | ||
cp ${./vagrant_insecure_key} vagrant_insecure_key | ||
fi | ||
|
||
chmod 0400 ./vagrant_insecure_key | ||
|
||
ssh_opts="-o StrictHostKeyChecking=no -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedKeyTypes=+ssh-rsa -i ./vagrant_insecure_key" | ||
ssh="ssh -p 20022 -q $ssh_opts vagrant@localhost" | ||
|
||
echo "Waiting for SSH..." | ||
for ((i = 0; i < 120; i++)); do | ||
echo "[ssh] Trying to connect..." | ||
if $ssh -- true; then | ||
echo "[ssh] Connected!" | ||
break | ||
fi | ||
if ! kill -0 $qemu_pid; then | ||
echo "qemu died unexpectedly" | ||
exit 1 | ||
fi | ||
sleep 1 | ||
done | ||
|
||
if [[ -n $postBoot ]]; then | ||
echo "Running post-boot commands..." | ||
$ssh "set -ex; $postBoot" | ||
fi | ||
|
||
echo "Copying installer..." | ||
scp -P 20022 $ssh_opts $binaryTarball/nix-*.tar.xz vagrant@localhost:nix.tar.xz | ||
|
||
echo "Running installer..." | ||
$ssh "set -eux; $installScript" | ||
|
||
echo "Testing Nix installation..." | ||
$ssh <<EOF | ||
set -ex | ||
|
||
# FIXME: get rid of this; ideally ssh should just work. | ||
source ~/.bash_profile || true | ||
source ~/.bash_login || true | ||
source ~/.profile || true | ||
source /etc/bashrc || true | ||
|
||
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 ]] | ||
EOF | ||
|
||
echo "Done!" | ||
touch $out | ||
''; | ||
|
||
in | ||
|
||
builtins.mapAttrs (imageName: image: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be quite convenient to have an |
||
{ ${image.system} = builtins.mapAttrs (testName: test: | ||
makeTest imageName testName | ||
) installScripts; | ||
} | ||
) images |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-----BEGIN RSA PRIVATE KEY----- | ||
MIIEogIBAAKCAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzI | ||
w+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoP | ||
kcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2 | ||
hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NO | ||
Td0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcW | ||
yLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQIBIwKCAQEA4iqWPJXtzZA68mKd | ||
ELs4jJsdyky+ewdZ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||
kda/AoGANWrLCz708y7VYgAtW2Uf1DPOIYMdvo6fxIB5i9ZfISgcJ/bbCUkFrhoH | ||
+vq/5CIWxCPp0f85R4qxxQ5ihxJ0YDQT9Jpx4TMss4PSavPaBH3RXow5Ohe+bYoQ | ||
NE5OgEXk2wVfZczCZpigBKbKZHNYcelXtTt/nP3rsCuGcM4h53s= | ||
-----END RSA PRIVATE KEY----- |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any chance we could directly call
vagrant
instead of reimplementing the logic ourselves?It seems like
vagrant box add --name testVM ${image.rootDisk} && vagrant init testVM
should allow running vagrant against a local imageThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you continue from there? I tried
vagrant up
, but it requires libvirt. I tried to run libvirtd inside a derivation and got into trouble[1]. There's https://github.com/billyan2018/vagrant-qemu which looks interesting though.[1] After fixing the unix socket path in the Vagrantfile
libvirt failed with some permission / path errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pulling in vagrant and libvirt adds a lot of complexity compared to calling qemu directly that I'd rather avoid...