Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

test: harden Vagrant/RHEL E2E harness; add vm-install overlay script

Juan Denise3bb163221f0
diff --git a/scripts/test/full-stack-test.ps1 b/scripts/test/full-stack-test.ps1
index 12906e92..4ce3be28 100644
--- a/scripts/test/full-stack-test.ps1
+++ b/scripts/test/full-stack-test.ps1
@@ -27,10 +27,12 @@
#>
[CmdletBinding()]
param(
- # Default suite: Ubuntu LTSes via Multipass + non-Ubuntu via Vagrant
- # + Hyper-V provider. Vagrant boxes are heavier (first launch downloads
- # ~600 MB each), so first full run is long. -Only to subset.
- [string[]] $Distros = @('ubuntu22','ubuntu24','debian12','fedora','rocky9'),
+ # Default suite: Ubuntu LTSes via Multipass + Debian 12 / Rocky 9
+ # via Vagrant + Hyper-V. Fedora is *not* in the default — Vagrant
+ # Cloud's generic/fedora boxes stop at fedora39 (EOL Nov 2024) and no
+ # newer pre-built Hyper-V box exists. Use `-Only fedora` to opt in
+ # once you've pinned a box you trust.
+ [string[]] $Distros = @('ubuntu22','ubuntu24','debian12','rocky9'),
[string] $Only,
[switch] $Keep,
[string] $ReuseVm,
diff --git a/scripts/test/vagrant/Vagrantfile b/scripts/test/vagrant/Vagrantfile
index 7b151d14..8d922a8f 100644
--- a/scripts/test/vagrant/Vagrantfile
+++ b/scripts/test/vagrant/Vagrantfile
@@ -44,15 +44,30 @@ Vagrant.configure("2") do |config|
# Bootstrap: ensure rsync + curl are present (mirrors the multipass
# cloud-init). Best effort — different distros use different package
# managers, so try them in order.
+ #
+ # IMPORTANT — on Rocky/RHEL, calling `dnf install` here pulls in
+ # the latest libcurl as a dep upgrade, which transitively upgrades
+ # openssl-libs from 3.0.x to 3.5.x. The box's openssh-server
+ # (openssh-server-8.7p1-34.el9) was built against the 3.0.x ABI and
+ # there is currently no matching el9 rebuild against 3.5.x in the
+ # repos. Every new sshd fork then dies with "OpenSSL version
+ # mismatch", TCP accepts then RSTs before the banner, and every
+ # subsequent `vagrant upload` / `vagrant ssh -c` from the harness
+ # fails silently. So skip dnf entirely when rsync+curl are already
+ # present (they ship preinstalled in generic/rocky9). If a future
+ # RHEL-family box drops them, we'll fail loudly here rather than
+ # silently corrupting the run downstream.
config.vm.provision "shell", inline: <<-SHELL
set -e
if command -v apt-get >/dev/null 2>&1; then
export DEBIAN_FRONTEND=noninteractive
apt-get update -qq && apt-get install -y -qq rsync curl
- elif command -v dnf >/dev/null 2>&1; then
- dnf install -y -q rsync curl
- elif command -v yum >/dev/null 2>&1; then
- yum install -y -q rsync curl
+ elif command -v dnf >/dev/null 2>&1 || command -v yum >/dev/null 2>&1; then
+ if ! command -v rsync >/dev/null 2>&1 || ! command -v curl >/dev/null 2>&1; then
+ echo "ERROR: rsync/curl missing on RHEL-family box — running dnf install"
+ echo " would upgrade openssl and break sshd. See Vagrantfile comment."
+ exit 1
+ fi
fi
SHELL
end
diff --git a/scripts/test/vm-install.sh b/scripts/test/vm-install.sh
index 5666f657..899a5467 100644
--- a/scripts/test/vm-install.sh
+++ b/scripts/test/vm-install.sh
@@ -20,14 +20,62 @@ fail() { echo "[vm-install] FAIL: $*" | tee -a "$LOG"; exit 1; }
mkdir -p "$(dirname "$LOG")"
: > "$LOG"
+# Capture sshd/firewall/network state at named checkpoints so post-mortems
+# work even when install.sh leaves SSH unreachable (Rocky 9 has done this).
+# Output goes to $LOG which is later copied back to the host by the harness.
+snapshot() {
+ local label="$1"
+ {
+ echo
+ echo "===== SNAPSHOT: $label ($(date -Iseconds)) ====="
+ echo "--- systemctl status sshd ---"
+ systemctl status sshd --no-pager 2>&1 | head -30
+ echo "--- ss -tlnp (listeners) ---"
+ ss -tlnp 2>&1 | head -30
+ echo "--- firewall-cmd state ---"
+ if command -v firewall-cmd >/dev/null 2>&1; then
+ systemctl is-active firewalld 2>&1
+ firewall-cmd --state 2>&1
+ firewall-cmd --get-default-zone 2>&1
+ firewall-cmd --list-all 2>&1
+ else
+ echo "firewall-cmd not present"
+ fi
+ echo "--- iptables -L INPUT ---"
+ iptables -L INPUT -n 2>&1 | head -40 || true
+ echo "--- ip addr ---"
+ ip -4 addr 2>&1
+ echo "===== END SNAPSHOT: $label ====="
+ echo
+ } >> "$LOG" 2>&1
+}
+
+# Snapshot system state on every exit path. Snapshot only — we deliberately
+# do NOT `systemctl restart sshd` here. On Rocky 9 the running sshd is
+# linked against an older libssl than what `dnf` ends up with on disk, so
+# a restart spawns a fresh sshd that segfaults on OpenSSL version mismatch
+# and the host can't reconnect for the pytest phase. The running sshd
+# parent keeps working with its mapped-in libssl, so leaving it alone is
+# the right move.
+cleanup() {
+ local rc=$?
+ echo "[vm-install] cleanup: exit rc=$rc" >> "$LOG" 2>&1
+ snapshot "cleanup (rc=$rc)"
+ return $rc
+}
+trap cleanup EXIT
+
[ -d "$SRC" ] || fail "source dir $SRC missing — multipass transfer broken"
[ -f "$SRC/install.sh" ] || fail "install.sh not found in source"
+snapshot "pre-install"
+
log "Step 1/4: running install.sh (this clones origin/main, installs deps)"
# install.sh clones from GitHub — we let it, then overlay our local code.
bash "$SRC/install.sh" >> "$LOG" 2>&1
INSTALL_RC=$?
log "install.sh exit=$INSTALL_RC"
+snapshot "post-install.sh"
if [ ! -d "$INSTALL_DIR" ]; then
fail "install.sh did not create $INSTALL_DIR (rc=$INSTALL_RC)"