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>
39 lines
1.4 KiB
Bash
Executable File
39 lines
1.4 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 mock NAS and bring warpgate to full supervision
|
|
start_mock_nas
|
|
gen_config
|
|
start_warpgate
|
|
wait_for_log_line "Supervision active" 60
|
|
|
|
# Initiate graceful shutdown
|
|
stop_warpgate
|
|
|
|
# Verify shutdown messages appear in the correct order
|
|
assert_log_contains "Shutting down"
|
|
assert_log_order "SMB: stopped" "FUSE: unmounted"
|
|
assert_log_order "FUSE: unmounted" "rclone: stopped"
|
|
|
|
# Verify the drain step appears between SMB stop and FUSE unmount
|
|
# The supervisor should drain dirty writes before tearing down the FUSE mount.
|
|
if grep -q "Write-back queue drained\|Waiting for write-back" "$TEST_DIR/warpgate.log" 2>/dev/null; then
|
|
assert_log_order "SMB: stopped" "Write-back queue drained\|Waiting for write-back"
|
|
# Verify drain completes before FUSE unmount
|
|
drain_line=$(grep -n "Write-back queue drained\|Waiting for write-back" "$TEST_DIR/warpgate.log" | head -1 | cut -d: -f1)
|
|
fuse_line=$(grep -n "FUSE: unmounted" "$TEST_DIR/warpgate.log" | head -1 | cut -d: -f1)
|
|
if [[ -n "$drain_line" && -n "$fuse_line" && "$drain_line" -ge "$fuse_line" ]]; then
|
|
echo "FAIL: drain step should appear before FUSE unmount" >&2
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
echo "PASS: $(basename "$0" .sh)"
|