From 58eeb74c985af5065f8f3dc3868a02aef993bedc Mon Sep 17 00:00:00 2001 From: Achilleas Koutsou Date: Wed, 5 Oct 2022 13:14:27 +0200 Subject: [PATCH] test: update raw image script to skip BIOS boot on Fedora --- test/cases/ostree-raw-image.sh | 109 +++++++++++++++++---------------- 1 file changed, 57 insertions(+), 52 deletions(-) diff --git a/test/cases/ostree-raw-image.sh b/test/cases/ostree-raw-image.sh index 1d0cdebe8..60a1da3d7 100755 --- a/test/cases/ostree-raw-image.sh +++ b/test/cases/ostree-raw-image.sh @@ -422,57 +422,59 @@ greenprint "๐Ÿงน Clean up raw-image blueprint and compose" sudo composer-cli compose delete "${COMPOSE_ID}" > /dev/null sudo composer-cli blueprints delete raw-image > /dev/null -################################################################## -## -## Install and test edge vm with edge-raw-image (BIOS) -## -################################################################## -# Prepare qcow2 file for BIOS -sudo cp "${IMAGE_KEY}.qcow2" /var/lib/libvirt/images/ LIBVIRT_IMAGE_PATH=/var/lib/libvirt/images/${IMAGE_KEY}.qcow2 -# Ensure SELinux is happy with our new images. -greenprint "๐Ÿ‘ฟ Running restorecon on image directory" -sudo restorecon -Rv /var/lib/libvirt/images/ +if [[ "$ID" != "fedora" ]]; then + ################################################################## + ## + ## Install and test edge vm with edge-raw-image (BIOS) + ## + ################################################################## + # Prepare qcow2 file for BIOS + sudo cp "${IMAGE_KEY}.qcow2" /var/lib/libvirt/images/ -greenprint "๐Ÿ’ฟ Installing raw image on BIOS VM" -# TODO: os-type is deprecated in newer versions; remove conditionally -sudo virt-install --name="${IMAGE_KEY}-bios"\ - --disk path="${LIBVIRT_IMAGE_PATH}",format=qcow2 \ - --ram 3072 \ - --vcpus 2 \ - --network network=integration,mac=34:49:22:B0:83:30 \ - --import \ - --os-type linux \ - --os-variant ${OS_VARIANT} \ - --nographics \ - --noautoconsole \ - --wait=-1 \ - --noreboot + # Ensure SELinux is happy with our new images. + greenprint "๐Ÿ‘ฟ Running restorecon on image directory" + sudo restorecon -Rv /var/lib/libvirt/images/ -# Start VM. -greenprint "๐Ÿ’ป Start BIOS VM" -sudo virsh start "${IMAGE_KEY}-bios" + greenprint "๐Ÿ’ฟ Installing raw image on BIOS VM" + # TODO: os-type is deprecated in newer versions; remove conditionally + sudo virt-install --name="${IMAGE_KEY}-bios"\ + --disk path="${LIBVIRT_IMAGE_PATH}",format=qcow2 \ + --ram 3072 \ + --vcpus 2 \ + --network network=integration,mac=34:49:22:B0:83:30 \ + --import \ + --os-type linux \ + --os-variant ${OS_VARIANT} \ + --nographics \ + --noautoconsole \ + --wait=-1 \ + --noreboot -# Check for ssh ready to go. -greenprint "๐Ÿ›ƒ Checking for SSH is ready to go" -for LOOP_COUNTER in $(seq 0 30); do - RESULTS="$(wait_for_ssh_up $BIOS_GUEST_ADDRESS)" - if [[ $RESULTS == 1 ]]; then - echo "SSH is ready now! ๐Ÿฅณ" - break - fi - sleep 10 -done + # Start VM. + greenprint "๐Ÿ’ป Start BIOS VM" + sudo virsh start "${IMAGE_KEY}-bios" -# Check image installation result -check_result + # Check for ssh ready to go. + greenprint "๐Ÿ›ƒ Checking for SSH is ready to go" + for LOOP_COUNTER in $(seq 0 30); do + RESULTS="$(wait_for_ssh_up $BIOS_GUEST_ADDRESS)" + if [[ $RESULTS == 1 ]]; then + echo "SSH is ready now! ๐Ÿฅณ" + break + fi + sleep 10 + done -greenprint "๐Ÿ•น Get ostree install commit value" -INSTALL_HASH=$(curl "${PROD_REPO_URL}/refs/heads/${OSTREE_REF}") + # Check image installation result + check_result -# Add instance IP address into /etc/ansible/hosts -sudo tee "${TEMPDIR}"/inventory > /dev/null << EOF + greenprint "๐Ÿ•น Get ostree install commit value" + INSTALL_HASH=$(curl "${PROD_REPO_URL}/refs/heads/${OSTREE_REF}") + + # Add instance IP address into /etc/ansible/hosts + sudo tee "${TEMPDIR}"/inventory > /dev/null << EOF [ostree_guest] ${BIOS_GUEST_ADDRESS} @@ -486,17 +488,20 @@ ansible_become_method=sudo ansible_become_pass=${EDGE_USER_PASSWORD} EOF -# Test IoT/Edge OS -sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type="${OSTREE_OSNAME}" -e ostree_commit="${INSTALL_HASH}" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 -check_result + # Test IoT/Edge OS + sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type="${OSTREE_OSNAME}" -e ostree_commit="${INSTALL_HASH}" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 + check_result -# Clean up BIOS VM -greenprint "๐Ÿงน Clean up BIOS VM" -if [[ $(sudo virsh domstate "${IMAGE_KEY}-bios") == "running" ]]; then - sudo virsh destroy "${IMAGE_KEY}-bios" + # Clean up BIOS VM + greenprint "๐Ÿงน Clean up BIOS VM" + if [[ $(sudo virsh domstate "${IMAGE_KEY}-bios") == "running" ]]; then + sudo virsh destroy "${IMAGE_KEY}-bios" + fi + sudo virsh undefine "${IMAGE_KEY}-bios" + sudo rm -fr LIBVIRT_IMAGE_PATH +else + greenprint "Skipping BIOS boot for Fedora IoT (not supported)" fi -sudo virsh undefine "${IMAGE_KEY}-bios" -sudo rm -fr LIBVIRT_IMAGE_PATH ################################################################## ##