From f1aca6be3bf38fa834f548552656e7930213e55b Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 14 Feb 2017 21:04:52 -0500 Subject: [PATCH] iso-sanity: New test for ISO installs This turned out to be harder than I thought; https://pagure.io/atomic-wg/issue/227 --- iso-sanity/README.md | 1 + iso-sanity/check-iso-sanity.sh | 43 ++++++++++++++++++++++++++++++++++ iso-sanity/default.ks | 1 + 3 files changed, 45 insertions(+) create mode 100644 iso-sanity/README.md create mode 100755 iso-sanity/check-iso-sanity.sh create mode 100644 iso-sanity/default.ks diff --git a/iso-sanity/README.md b/iso-sanity/README.md new file mode 100644 index 0000000..0165f2a --- /dev/null +++ b/iso-sanity/README.md @@ -0,0 +1 @@ +Run `virt-install` to install an ISO using both BIOS and EFI. diff --git a/iso-sanity/check-iso-sanity.sh b/iso-sanity/check-iso-sanity.sh new file mode 100755 index 0000000..b7cbaf2 --- /dev/null +++ b/iso-sanity/check-iso-sanity.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +set -xeuo pipefail +ISO=$1 +shift +dn=$(dirname $0) + +tempdir=$(mktemp -d /var/tmp/isosanity.XXXXX) +function cleanup () { + fusermount -u ${tempdir}/mnt || true + rm "${tempdir}" -rf +} +trap cleanup EXIT + +export LIBGUESTFS_BACKEND=direct +mkdir ${tempdir}/mnt +guestmount --ro -a ${ISO} -m /dev/sda1 ${tempdir}/mnt +(cd ${tmpdir}/mnt && python -m SimpleHTTPServer 0 >../httpd.txt) +success=false +# FIXME - detect from libvirt/define our own? +hostip=192.168.122.1 +for x in $(seq 30); do + sed -e s',Serving HTTP on 0.0.0.0 port \([0-9]*\) \.\.\.,\1,' < ${tempdir}/httpd.txt > ${tempdir}/port.txt + if cmp ${tempdir}/httpd.txt ${tempdir}/port.txt; then + port=$(tr -d '\n' < ${tempdir}/port.txt) + if curl "http://${hostip}:${port}"; then + success=true + break + fi + fi + sleep 0.1 +done +if !${success}; then + echo "Failed to wait for http server" + exit 1 +fi + +# --initrd-inject ${dn}/default.ks --extra-args=inst.ks=file:/default.ks +base_args="--ram 3192 --vcpus 4 --disk size=20 --os-variant rhel7 --location http://${hostip}:${port}/" + +virsh -c qemu:///system undefine isosanity-efi || true +virt-install ${base_args} --name isosanity-efi --boot uefi +virsh -c qemu:///system undefine isosanity-bios || true +virt-install ${base_args} --name isosanity-bios diff --git a/iso-sanity/default.ks b/iso-sanity/default.ks new file mode 100644 index 0000000..c84b266 --- /dev/null +++ b/iso-sanity/default.ks @@ -0,0 +1 @@ +%include /usr/share/anaconda/interactive-defaults.ks