Files
Juan DenisandClaude Opus 4.8 f744106d64 test(scripts): Phase 4 — vm update/uninstall tests + 7-distro CI matrix
Hardening plan §7. Catches distro-specific regressions before release.

- scripts/test/vm-update.sh: install → forced local update (full blue/green
  deploy/migrate/switch/health) → re-run to confirm the "Already up to date"
  version-gate. Same VM harness contract as vm-install.sh (log + status file).
- scripts/test/vm-uninstall.sh: install + seed data → default uninstall asserts
  data preserved (DB snapshot in backups, /var/lib survives) → reinstall →
  --purge asserts data removed. End-to-end proof of the unified uninstaller.
- scripts-ci.yml: now runs all three serverless suites (update+install+lib),
  lints the new lib/ + test/ files (error severity) and keeps scripts/lib/*
  warning-clean, and expands the cross-distro unit matrix to Ubuntu 22.04/24.04,
  Debian 12, Rocky 9, AlmaLinux 9, Fedora 40, and openSUSE Leap 15.5.
- test_install.sh: +choose_pkg_manager graceful-failure case (7.4); a no-op
  docker stub so the uninstall-matrix cases run where docker isn't installed.
- test_lib.sh: neutralize the ambient container=oci env var (RPM/SUSE images)
  and force an empty PATH for the "no package manager" case — both bugs the new
  matrix surfaced (the tests, not the code).
- README: fixed the stale Fedora box, documented the new VM scripts + suites.

Validated by running the exact CI container logic locally across all seven
images: test_update 13/13, test_install 15-16/0, test_lib 13/13 everywhere.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 01:00:45 -04:00

72 lines
2.9 KiB
Bash

#!/bin/bash
# Runs inside the test VM. End-to-end test of the unified uninstaller
# (uninstall.sh + scripts/lib/uninstall.sh), proving the data-handling matrix on
# a real box:
# 1. Install ServerKit and seed sample data (a sentinel under /var/lib + a DB).
# 2. Default uninstall (--yes): the install tree is gone, but user data is
# preserved — the /var/lib sentinel survives AND a pre-uninstall DB snapshot
# lands in /var/backups/serverkit.
# 3. Reinstall.
# 4. Purge uninstall (--purge --yes): the data dirs (/var/lib, /etc/serverkit)
# are removed.
#
# Writes OK/FAIL to /tmp/serverkit-uninstall-status and a full log to
# /var/log/serverkit-test-uninstall.log (both pulled back by the harness).
set -u # not -e: capture failures and still emit a report
SRC=/opt/serverkit-src
INSTALL_DIR=/opt/serverkit
LOG=/var/log/serverkit-test-uninstall.log
STATUS=/tmp/serverkit-uninstall-status
SENTINEL=/var/lib/serverkit/.vm-uninstall-sentinel
log() { echo "[vm-uninstall] $*" | tee -a "$LOG"; }
fail() { echo "[vm-uninstall] FAIL: $*" | tee -a "$LOG"; echo FAIL > "$STATUS"; exit 1; }
mkdir -p "$(dirname "$LOG")"
: > "$LOG"
install_sk() {
[ -f "$SRC/install.sh" ] || fail "install.sh not found in $SRC"
log "Installing ServerKit (clones release, installs deps)..."
bash "$SRC/install.sh" >> "$LOG" 2>&1 || fail "install.sh failed (rc=$?)"
[ -d "$INSTALL_DIR" ] || fail "install.sh did not create $INSTALL_DIR"
}
[ -d "$SRC" ] || fail "source dir $SRC missing — transfer broken"
# 1. Install + seed sample data.
log "Step 1/4: install + seed data"
install_sk
mkdir -p /var/lib/serverkit "$INSTALL_DIR/backend/instance"
echo "keep-me" > "$SENTINEL"
[ -f "$INSTALL_DIR/backend/instance/serverkit.db" ] || echo "sample-db" > "$INSTALL_DIR/backend/instance/serverkit.db"
log "Seeded sentinel + database."
# 2. Default uninstall — data must be preserved.
log "Step 2/4: default uninstall (data preserved)"
bash "$SRC/uninstall.sh" --yes >> "$LOG" 2>&1 || fail "default uninstall failed (rc=$?)"
[ ! -d "$INSTALL_DIR" ] || fail "install dir still present after default uninstall"
[ -f "$SENTINEL" ] || fail "default uninstall destroyed /var/lib/serverkit data"
if ls /var/backups/serverkit/serverkit-pre-uninstall-*.db >/dev/null 2>&1; then
log "DB snapshot present in /var/backups/serverkit."
else
fail "default uninstall did not snapshot the database to backups"
fi
log "Default uninstall preserved user data. OK."
# 3. Reinstall.
log "Step 3/4: reinstall"
install_sk
# 4. Purge uninstall — data must be removed.
log "Step 4/4: purge uninstall (--purge)"
bash "$SRC/uninstall.sh" --purge --yes >> "$LOG" 2>&1 || fail "purge uninstall failed (rc=$?)"
[ ! -d "$INSTALL_DIR" ] || fail "install dir still present after purge"
[ ! -e "$SENTINEL" ] || fail "--purge did not remove /var/lib/serverkit"
[ ! -d /etc/serverkit ] || fail "--purge did not remove /etc/serverkit"
log "Purge removed all data. OK."
echo OK > "$STATUS"
exit 0