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>
76 lines
1.8 KiB
Bash
Executable File
76 lines
1.8 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 config with WebDAV enabled alongside SMB
|
|
gen_config enable_webdav=true
|
|
|
|
# Start warpgate and wait for full startup
|
|
start_warpgate
|
|
wait_for_log_line "Supervision active" 60
|
|
|
|
# --- Kill smbd and wait for its independent restart ---
|
|
|
|
smbd_pid=$(pgrep -f "smbd.*--foreground")
|
|
if [[ -z "$smbd_pid" ]]; then
|
|
echo "FAIL: smbd not found" >&2
|
|
exit 1
|
|
fi
|
|
|
|
kill "$smbd_pid"
|
|
wait_for_log_line "Restarting smbd" 15
|
|
sleep 5
|
|
|
|
# Verify smbd restarted
|
|
new_smbd_pid=$(pgrep -f "smbd.*--foreground")
|
|
if [[ -z "$new_smbd_pid" ]]; then
|
|
echo "FAIL: smbd did not restart" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# --- Kill WebDAV and wait for its independent restart ---
|
|
|
|
webdav_pid=$(pgrep -f "rclone serve webdav")
|
|
if [[ -z "$webdav_pid" ]]; then
|
|
echo "FAIL: WebDAV process not found" >&2
|
|
exit 1
|
|
fi
|
|
|
|
kill "$webdav_pid"
|
|
wait_for_log_line "Restarting WebDAV" 15
|
|
sleep 5
|
|
|
|
# Verify WebDAV restarted
|
|
new_webdav_pid=$(pgrep -f "rclone serve webdav")
|
|
if [[ -z "$new_webdav_pid" ]]; then
|
|
echo "FAIL: WebDAV did not restart" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# --- Verify both restart events were logged independently ---
|
|
|
|
assert_log_contains "Restarting smbd"
|
|
assert_log_contains "Restarting WebDAV"
|
|
|
|
# Verify both services are running simultaneously after their restarts
|
|
if ! pgrep -f "smbd.*--foreground" > /dev/null; then
|
|
echo "FAIL: smbd not running after WebDAV restart" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if ! pgrep -f "rclone serve webdav" > /dev/null; then
|
|
echo "FAIL: WebDAV not running after smbd restart" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "PASS: $(basename "$0" .sh)"
|