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>
62 lines
1.6 KiB
Bash
Executable File
62 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Test: write-back survives a network outage and resumes on reconnect
|
|
#
|
|
# Writes a file through the FUSE mount, cuts the network before write-back
|
|
# can complete, waits, restores the network, and verifies that the file
|
|
# eventually reaches the NAS with the correct content.
|
|
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
|
|
|
|
# --- Arrange ---
|
|
start_mock_nas
|
|
|
|
# Short write-back so the upload attempt happens quickly
|
|
gen_config write_back=2s
|
|
|
|
start_warpgate
|
|
wait_for_mount
|
|
wait_for_rc_api
|
|
|
|
# --- Act ---
|
|
# Write a file through the FUSE mount
|
|
echo "resilient-data" > "$TEST_MOUNT/resilient.txt"
|
|
|
|
# Sever the network before write-back succeeds
|
|
inject_network_down
|
|
|
|
# Wait long enough for at least one write-back attempt to fail
|
|
sleep 5
|
|
|
|
# Verify the file is still dirty (upload could not complete)
|
|
dirty=$(get_dirty_count)
|
|
if [[ "$dirty" -lt 1 ]]; then
|
|
echo "FAIL: expected dirty count > 0 while network is down, got $dirty" >&2
|
|
inject_network_up
|
|
exit 1
|
|
fi
|
|
|
|
# Restore the network
|
|
inject_network_up
|
|
|
|
# --- Assert ---
|
|
# Wait for the write-back queue to drain (rclone retries should succeed now)
|
|
wait_for_dirty_zero 120
|
|
|
|
# Verify the file arrived on the NAS
|
|
assert_file_exists "$NAS_ROOT/resilient.txt"
|
|
|
|
# Verify the content matches what we wrote
|
|
actual=$(cat "$NAS_ROOT/resilient.txt")
|
|
if [[ "$actual" != "resilient-data" ]]; then
|
|
echo "FAIL: NAS file content mismatch: expected 'resilient-data', got '$actual'" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "PASS: $(basename "$0" .sh)"
|