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>
45 lines
1.1 KiB
Bash
Executable File
45 lines
1.1 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
|
|
start_mock_nas
|
|
|
|
# Create large test files on the NAS to make warmup take time
|
|
for i in $(seq 1 10); do
|
|
create_test_file "warmup/file-${i}.dat" 1024
|
|
done
|
|
|
|
# Generate config with auto-warmup enabled and a rule matching our files
|
|
gen_config warmup_auto=true \
|
|
"warmup.rules=[[warmup.rules]]
|
|
path = \"warmup/\""
|
|
|
|
# Start warpgate and wait for warmup to begin
|
|
start_warpgate
|
|
wait_for_log_line "Running auto-warmup" 60
|
|
|
|
# Immediately send SIGTERM to interrupt warmup
|
|
kill -TERM "$WARPGATE_PID"
|
|
|
|
# Wait for the process to exit cleanly
|
|
wait_for_exit "$WARPGATE_PID" 30
|
|
|
|
# Verify clean exit — signal handler should stop warmup and proceed
|
|
# through orderly shutdown
|
|
assert_log_contains "Signal received, shutting down"
|
|
|
|
# Verify the FUSE mount was removed
|
|
assert_not_mounted
|
|
|
|
# Verify no orphan rclone processes remain
|
|
assert_no_orphan_rclone
|
|
|
|
echo "PASS: $(basename "$0" .sh)"
|