frank-default-large -> frank-large (Dankclaw :7770), frank-default-small -> frank-small (Dankserver :7770), frank-default-sightsound -> frank-npu (Dankclaw :7771). Units, env files, serve scripts, deploy-plan mappings, deploy-remote dispatch (stop/disable old units + relink + enable new), and the test seams move together. Retired frank-default-npu.* artifacts moved to scripts/.AGENTTRASH/ (tracked-in-history; ignored on disk). Served aliases become frank-large / frank-small via --alias; the NPU endpoint serves the whole FLM registry, so its rename changes no served tags.
101 lines
4.8 KiB
Bash
101 lines
4.8 KiB
Bash
#!/usr/bin/env bats
|
|
# Seam: target reachability and deployment flow integrity.
|
|
# These tests assert the service-scoped deployment contract:
|
|
# - deploy.sh accepts a target, optional service scope, and --dry-run
|
|
# - deploy-remote.sh owns per-service handlers and deployment state
|
|
# - no host-wide inference restart is hidden in the dispatcher
|
|
# - every host referenced in the repo is reachable over SSH (dank@host)
|
|
# - the local git remote is configured before deploy is attempted
|
|
# Reachability tests are SKIPPED when the target is unreachable so the suite
|
|
# still runs during offline development.
|
|
|
|
load helpers
|
|
|
|
@test "deploy.sh exists and is executable" {
|
|
[ -x "$REPO_ROOT/scripts/deploy.sh" ]
|
|
}
|
|
|
|
@test "deploy.sh accepts the two known targets" {
|
|
run bash "$REPO_ROOT/scripts/deploy.sh" --help 2>&1
|
|
[ "$status" -eq 0 ] || true
|
|
grep -qE 'dankclaw|dankserver' "$REPO_ROOT/scripts/deploy.sh"
|
|
}
|
|
|
|
@test "git remote origin is configured" {
|
|
git -C "$REPO_ROOT" remote get-url origin >/dev/null 2>&1 \
|
|
|| skip "no origin remote configured yet"
|
|
}
|
|
|
|
@test "dankclaw is reachable over ssh" {
|
|
timeout 8 ssh -o BatchMode=yes -o ConnectTimeout=5 dank@dankclaw 'true' 2>/dev/null \
|
|
|| skip "dankclaw not reachable from this host"
|
|
}
|
|
|
|
@test "dankserver is reachable over ssh" {
|
|
timeout 8 ssh -o BatchMode=yes -o ConnectTimeout=5 dank@dankserver 'true' 2>/dev/null \
|
|
|| skip "dankserver not reachable from this host"
|
|
}
|
|
|
|
# Regression: the Caddyfile render step in deploy.sh must survive a bcrypt
|
|
# hash (which contains '/' characters). Reproduce the sed expression with a
|
|
# slash-bearing hash and confirm the placeholder is replaced.
|
|
@test "scoped remote runner owns Caddy reload and safe fallback" {
|
|
# Caddy is handled only when selected by the planner. A failed reload may
|
|
# restart Caddy, but must not restart the whole compose project.
|
|
grep -q 'caddy reload' "$REPO_ROOT/scripts/deploy-remote.sh"
|
|
grep -q 'podman restart caddy' "$REPO_ROOT/scripts/deploy-remote.sh"
|
|
! grep -qE 'podman-compose.*(up|restart).*\$\(' "$REPO_ROOT/scripts/deploy-remote.sh"
|
|
}
|
|
|
|
@test "Caddy migration retires the standalone Gitea proxy" {
|
|
grep -q 'retire_legacy_gitea_caddy' "$REPO_ROOT/scripts/deploy-remote.sh"
|
|
grep -q 'systemctl --user stop gitea-caddy.service' "$REPO_ROOT/scripts/deploy-remote.sh"
|
|
grep -q 'systemctl --user disable gitea-caddy.service' "$REPO_ROOT/scripts/deploy-remote.sh"
|
|
! grep -q 'deploy_gitea_unit gitea-caddy' "$REPO_ROOT/scripts/deploy-remote.sh"
|
|
}
|
|
|
|
@test "canonical Caddy deployment installs its boot-persistent quadlet" {
|
|
# 2026-08-26: a bare compose container never came back after reboot.
|
|
# deploy_caddy must install and start the quadlet unit instead of
|
|
# `podman-compose up`. Boot persistence comes from the quadlet generator's
|
|
# default.target.wants symlink (is-enabled reports "generated"), so there
|
|
# is no explicit systemctl enable — it fails on generated units.
|
|
grep -q 'install_quadlet caddy dankclaw/caddy/quadlet caddy' "$REPO_ROOT/scripts/deploy-remote.sh"
|
|
grep -q 'systemctl --user restart caddy.service' "$REPO_ROOT/scripts/deploy-remote.sh"
|
|
! grep -q 'systemctl --user enable caddy.service' "$REPO_ROOT/scripts/deploy-remote.sh"
|
|
! grep -q 'podman-compose -f dankclaw/compose.yaml up -d --no-deps caddy' "$REPO_ROOT/scripts/deploy-remote.sh"
|
|
! grep -q 'no proxy was stopped or replaced' "$REPO_ROOT/scripts/deploy-remote.sh"
|
|
}
|
|
|
|
@test "remote runner has separate handlers for both inference services" {
|
|
grep -q 'deploy_llm_large' "$REPO_ROOT/scripts/deploy-remote.sh"
|
|
grep -q 'deploy_llm_small' "$REPO_ROOT/scripts/deploy-remote.sh"
|
|
}
|
|
|
|
@test "inference restarts are absent from the top-level dispatcher" {
|
|
! grep -qE 'systemctl .*restart (frank-small|frank-large|frank-npu)' "$REPO_ROOT/scripts/deploy.sh"
|
|
}
|
|
|
|
@test "remote runner health-checks an inference endpoint" {
|
|
grep -q '127.0.0.1:7770/health' "$REPO_ROOT/scripts/deploy-remote.sh"
|
|
}
|
|
|
|
@test "deploy.sh pulls the merged checkout on the target" {
|
|
grep -q 'git pull --ff-only origin main' "$REPO_ROOT/scripts/deploy.sh"
|
|
grep -q '/home/dank/serverAppConfigs' "$REPO_ROOT/scripts/deploy.sh"
|
|
}
|
|
|
|
@test "deploy.sh Caddyfile render survives a slash-bearing bcrypt hash" {
|
|
local hash='$2a$14$dndiQ9EaycJv0w3Gp2oAYO/xH6O9x2ZRhMLJdCxrgi9rMn1te9D/spy'
|
|
local rendered
|
|
rendered=$(sed "s|REPLACE_WITH_HASH|${hash}|g" "$REPO_ROOT/dankclaw/Caddyfile")
|
|
[ -n "$rendered" ]
|
|
[[ "$rendered" == *"${hash}"* ]]
|
|
! grep -q 'REPLACE_WITH_HASH' <<< "$rendered"
|
|
# The rendered line must be exactly "dankuser <hash>". A template that
|
|
# keeps its own $2a$14$ prefix renders an invalid double-prefixed hash
|
|
# and every basicauth vhost returns 401 (2026-08-22 incident).
|
|
grep -qF "dankuser ${hash}" <<< "$rendered"
|
|
! grep -qF '$2a$14$$2a$14$' <<< "$rendered"
|
|
}
|