From 70bb2d5ab1bf6787bc613e33f5398be2eca1f5fd Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 27 Jan 2026 17:22:55 -0600 Subject: feat(testing): rewrite test infrastructure from libvirt to direct QEMU MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace the never-fully-operational libvirt-based VM test infrastructure with direct QEMU management and archangel ISO for fully automated, unattended base VM creation. Key changes: - vm-utils.sh: complete rewrite — QEMU process mgmt via PID file, monitor socket for graceful shutdown, qemu-img snapshots, SSH port forwarding (localhost:2222) - create-base-vm.sh: boots archangel ISO, SSHs in, runs unattended install via config file, verifies, creates clean-install snapshot - run-test.sh: snapshot revert, git bundle transfer, detached archsetup execution with setsid, polling, validation, and report generation - debug-vm.sh: CoW overlay disk, GTK display, auto-cleanup on close - setup-testing-env.sh: reduced deps to qemu-full/sshpass/edk2-ovmf/socat - cleanup-tests.sh: PID-based process management, orphan detection - validation.sh: port-based SSH (backward compatible), fuzzel/foot for Hyprland, corrected package list paths - network-diagnostics.sh: getent/curl instead of nslookup/ping (SLIRP) New files: - archsetup-test.conf: archangel config for base VM (btrfs, no encrypt) - archsetup-vm.conf: archsetup config for unattended test execution - assets/archangel.conf.example: reference archangel config Deleted: - finalize-base-vm.sh: merged into create-base-vm.sh - archinstall-config.json: replaced by archangel .conf format Tested: full end-to-end run — 51 validations passed, 0 failures. Co-Authored-By: Claude Opus 4.5 --- scripts/testing/setup-testing-env.sh | 104 +++++++---------------------------- 1 file changed, 20 insertions(+), 84 deletions(-) (limited to 'scripts/testing/setup-testing-env.sh') diff --git a/scripts/testing/setup-testing-env.sh b/scripts/testing/setup-testing-env.sh index e682553..f0e63aa 100755 --- a/scripts/testing/setup-testing-env.sh +++ b/scripts/testing/setup-testing-env.sh @@ -4,9 +4,7 @@ # License: GNU GPLv3 # # This script performs one-time setup of the testing infrastructure: -# - Installs QEMU/KVM and libvirt -# - Configures libvirt networking -# - Adds user to libvirt group +# - Installs QEMU/KVM, sshpass, OVMF firmware, and socat # - Verifies KVM support # - Creates directories for test artifacts @@ -20,6 +18,7 @@ PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" source "$SCRIPT_DIR/lib/logging.sh" # Initialize logging +mkdir -p "$PROJECT_ROOT/test-results" LOGFILE="$PROJECT_ROOT/test-results/setup-$(date +'%Y%m%d-%H%M%S').log" init_logging "$LOGFILE" @@ -41,13 +40,9 @@ section "Installing Required Packages" PACKAGES=( qemu-full - libvirt - virt-manager - dnsmasq - bridge-utils - iptables - virt-install - libguestfs + sshpass + edk2-ovmf + socat ) for pkg in "${PACKAGES[@]}"; do @@ -64,46 +59,6 @@ for pkg in "${PACKAGES[@]}"; do fi done -# Enable and start libvirt service -section "Configuring libvirt Service" - -step "Enabling libvirtd service" -if sudo systemctl enable libvirtd.service >> "$LOGFILE" 2>&1; then - success "libvirtd service enabled" -else - warn "Failed to enable libvirtd service (may already be enabled)" -fi - -step "Starting libvirtd service" -if sudo systemctl start libvirtd.service >> "$LOGFILE" 2>&1; then - success "libvirtd service started" -else - if sudo systemctl is-active --quiet libvirtd.service; then - info "libvirtd service is already running" - else - error "Failed to start libvirtd service" - fatal "Service startup failed" - fi -fi - -# Add user to libvirt group -section "Configuring User Permissions" - -if groups | grep -q libvirt; then - success "User $USER is already in libvirt group" -else - step "Adding user $USER to libvirt group" - if sudo usermod -a -G libvirt "$USER" >> "$LOGFILE" 2>&1; then - success "User added to libvirt group" - warn "You must log out and back in for group membership to take effect" - warn "After logging back in, re-run this script to continue" - exit 0 - else - error "Failed to add user to libvirt group" - fatal "User configuration failed" - fi -fi - # Verify KVM support section "Verifying KVM Support" @@ -126,6 +81,18 @@ else info "Load with: sudo modprobe kvm-intel (or kvm-amd)" fi +# Verify OVMF firmware +section "Verifying OVMF Firmware" + +OVMF_CODE="/usr/share/edk2/x64/OVMF_CODE.4m.fd" +OVMF_VARS="/usr/share/edk2/x64/OVMF_VARS.4m.fd" + +if [ -f "$OVMF_CODE" ] && [ -f "$OVMF_VARS" ]; then + success "OVMF firmware files present" +else + fatal "OVMF firmware files not found (expected at $OVMF_CODE)" +fi + # Create directory structure section "Creating Directory Structure" @@ -147,45 +114,14 @@ for dir in "${DIRS[@]}"; do fi done -# Configure default libvirt network -section "Configuring libvirt Network" - -if virsh net-info default &>/dev/null; then - info "Default network exists" - - if virsh net-info default | grep -q "Active:.*yes"; then - success "Default network is active" - else - step "Starting default network" - if virsh net-start default >> "$LOGFILE" 2>&1; then - success "Default network started" - else - error "Failed to start default network" - fi - fi - - if virsh net-info default | grep -q "Autostart:.*yes"; then - info "Default network autostart is enabled" - else - step "Enabling default network autostart" - if virsh net-autostart default >> "$LOGFILE" 2>&1; then - success "Default network autostart enabled" - else - warn "Failed to enable default network autostart" - fi - fi -else - error "Default network not found" - info "This is unusual - libvirt should create it automatically" -fi - # Summary section "Setup Complete" success "Testing environment is ready" info "" info "Next steps:" -info " 1. Create base VM: ./scripts/testing/create-base-vm.sh" -info " 2. Run a test: ./scripts/testing/run-test.sh" +info " 1. Copy an archangel ISO to: $PROJECT_ROOT/vm-images/" +info " 2. Create base VM: ./scripts/testing/create-base-vm.sh" +info " 3. Run a test: ./scripts/testing/run-test.sh" info "" info "Log file: $LOGFILE" -- cgit v1.2.3