Integration tests (tests/): - 9 categories covering config, lifecycle, signals, supervision, cache, writeback, network faults, crash recovery, and CLI - Shell-based harness with mock NAS (network namespace + SFTP), fault injection (tc netem), and power loss simulation - TAP format runner (run-all.sh) with proper SKIP detection Rust unit tests (warpgate/src/): - 110 tests across 14 modules, all passing in 0.01s - Config parsing, defaults validation, RestartTracker logic, RC API response parsing, rclone arg generation, service config generation, CLI output formatting, warmup path logic Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
52 lines
1.3 KiB
Bash
Executable File
52 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
source "$SCRIPT_DIR/../harness/helpers.sh"
|
|
source "$SCRIPT_DIR/../harness/mock-nas.sh"
|
|
|
|
require_root
|
|
setup_test_env
|
|
trap teardown_test_env EXIT
|
|
|
|
# Start the mock NAS so rclone can connect via SFTP
|
|
start_mock_nas
|
|
|
|
# Generate a default config pointing at the mock NAS
|
|
gen_config
|
|
|
|
# Start warpgate and wait for full startup
|
|
start_warpgate
|
|
wait_for_log_line "Supervision active" 60
|
|
|
|
# Find rclone mount PID
|
|
rclone_pid=$(pgrep -f "rclone mount.*$TEST_MOUNT")
|
|
if [[ -z "$rclone_pid" ]]; then
|
|
echo "FAIL: rclone mount process not found" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Kill rclone -- this should trigger full warpgate shutdown
|
|
kill "$rclone_pid"
|
|
|
|
# Wait for warpgate to exit (rclone death causes full shutdown)
|
|
wait_for_exit "$WARPGATE_PID" 30
|
|
|
|
# Verify the log contains the expected critical error message
|
|
assert_log_contains "rclone mount exited unexpectedly"
|
|
|
|
# Verify warpgate exited with non-zero code (it bails on rclone death)
|
|
if kill -0 "$WARPGATE_PID" 2>/dev/null; then
|
|
echo "FAIL: warpgate is still running after rclone death" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Collect exit code (non-zero expected)
|
|
exit_code=0
|
|
wait "$WARPGATE_PID" 2>/dev/null || exit_code=$?
|
|
if [[ "$exit_code" -eq 0 ]]; then
|
|
echo "FAIL: expected non-zero exit code, got 0" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "PASS: $(basename "$0" .sh)"
|