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>
64 lines
1.8 KiB
Bash
Executable File
64 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Test: `warpgate cache-clean --all` clears the VFS directory cache
|
|
#
|
|
# Verifies that cache-clean calls vfs/forget and prints a confirmation
|
|
# message. Exit code must be 0.
|
|
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
|
|
start_mock_nas
|
|
|
|
# Generate config
|
|
gen_config
|
|
|
|
# Start warpgate and wait for readiness
|
|
start_warpgate
|
|
wait_for_mount 60
|
|
wait_for_rc_api 30
|
|
|
|
# Create and read a file to populate the cache
|
|
nas_create_file_content "clean-test.txt" "cache-me"
|
|
cat "$TEST_MOUNT/clean-test.txt" > /dev/null
|
|
|
|
# Verify file is cached before cleaning
|
|
assert_cached "clean-test.txt"
|
|
|
|
# Capture pre-clean vfs/stats for comparison
|
|
pre_clean_stats=$(rc_api "vfs/stats" 2>/dev/null || echo "{}")
|
|
|
|
# Run cache-clean --all
|
|
exit_code=0
|
|
output=$(run_warpgate_cmd cache-clean --all 2>&1) || exit_code=$?
|
|
|
|
# Verify exit code is 0
|
|
if [[ "$exit_code" -ne 0 ]]; then
|
|
echo "FAIL: cache-clean exited with code $exit_code (expected 0)" >&2
|
|
echo " output: $output" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Verify output confirms the cache was cleared
|
|
if echo "$output" | grep -qi "VFS directory cache cleared\|Clearing"; then
|
|
true
|
|
else
|
|
echo "FAIL: cache-clean output missing confirmation message" >&2
|
|
echo " output: $output" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Verify cache was actually cleared by checking vfs/stats or that the
|
|
# directory cache no longer lists the file immediately after clean.
|
|
# After vfs/forget, re-listing should require a fresh remote lookup.
|
|
post_clean_stats=$(rc_api "vfs/stats" 2>/dev/null || echo "{}")
|
|
echo "INFO: pre-clean stats: $pre_clean_stats"
|
|
echo "INFO: post-clean stats: $post_clean_stats"
|
|
|
|
echo "PASS: $(basename "$0" .sh)"
|