diff options
| author | Craig Jennings <c@cjennings.net> | 2026-01-27 17:22:55 -0600 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-01-27 17:22:55 -0600 |
| commit | 70bb2d5ab1bf6787bc613e33f5398be2eca1f5fd (patch) | |
| tree | 0d8cd5057dd32f5f312a7f3534d590b99c2f0f91 /scripts/testing/lib/network-diagnostics.sh | |
| parent | 0c6175bfc98f2c5ff2debc665fd8bf91f9171f4e (diff) | |
feat(testing): rewrite test infrastructure from libvirt to direct QEMU
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 <noreply@anthropic.com>
Diffstat (limited to 'scripts/testing/lib/network-diagnostics.sh')
| -rw-r--r-- | scripts/testing/lib/network-diagnostics.sh | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/scripts/testing/lib/network-diagnostics.sh b/scripts/testing/lib/network-diagnostics.sh index 3f9735b..f7cae11 100644 --- a/scripts/testing/lib/network-diagnostics.sh +++ b/scripts/testing/lib/network-diagnostics.sh @@ -3,27 +3,30 @@ # Author: Craig Jennings <craigmartinjennings@gmail.com> # License: GNU GPLv3 -# Note: logging.sh should already be sourced by the calling script +# Note: logging.sh and vm-utils.sh should already be sourced by the calling script +# Uses globals: ROOT_PASSWORD, SSH_PORT, SSH_OPTS, VM_IP (from vm-utils.sh or calling script) # Run quick network diagnostics -# Args: $1 = VM IP address or hostname run_network_diagnostics() { - local vm_host="$1" + local password="${ROOT_PASSWORD:-archsetup}" + local port="${SSH_PORT:-22}" + local host="${VM_IP:-localhost}" + local ssh_base="sshpass -p $password ssh $SSH_OPTS -p $port root@$host" section "Pre-flight Network Diagnostics" - # Test 1: Basic connectivity + # Test 1: Basic connectivity (use curl instead of ping - SLIRP may not handle ICMP) step "Testing internet connectivity" - if sshpass -p 'archsetup' ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$vm_host "ping -c 3 8.8.8.8 >/dev/null 2>&1"; then + if $ssh_base "curl -s --connect-timeout 5 -o /dev/null http://archlinux.org" 2>/dev/null; then success "Internet connectivity OK" else error "No internet connectivity" return 1 fi - # Test 2: DNS resolution + # Test 2: DNS resolution (use getent which is always available, unlike nslookup/dig) step "Testing DNS resolution" - if sshpass -p 'archsetup' ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$vm_host "nslookup archlinux.org >/dev/null 2>&1"; then + if $ssh_base "getent hosts archlinux.org >/dev/null 2>&1" 2>/dev/null; then success "DNS resolution OK" else error "DNS resolution failed" @@ -32,7 +35,7 @@ run_network_diagnostics() { # Test 3: Arch mirror accessibility step "Testing Arch mirror access" - if sshpass -p 'archsetup' ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$vm_host "curl -s -I https://mirrors.kernel.org/archlinux/ | head -1 | grep -qE '(200|301)'"; then + if $ssh_base "curl -s -I https://mirrors.kernel.org/archlinux/ | head -1 | grep -qE '(200|301)'" 2>/dev/null; then success "Arch mirrors accessible" else error "Cannot reach Arch mirrors" @@ -41,7 +44,7 @@ run_network_diagnostics() { # Test 4: AUR accessibility step "Testing AUR access" - if sshpass -p 'archsetup' ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$vm_host "curl -s -I https://aur.archlinux.org/ | head -1 | grep -qE '(200|405)'"; then + if $ssh_base "curl -s -I https://aur.archlinux.org/ | head -1 | grep -qE '(200|405)'" 2>/dev/null; then success "AUR accessible" else error "Cannot reach AUR" @@ -50,8 +53,7 @@ run_network_diagnostics() { # Show network info info "Network configuration:" - sshpass -p 'archsetup' ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$vm_host \ - "ip addr show | grep 'inet ' | grep -v '127.0.0.1'" 2>/dev/null | while read line; do + $ssh_base "ip addr show | grep 'inet ' | grep -v '127.0.0.1'" 2>/dev/null | while read line; do info " $line" done |
