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>
54 lines
1.9 KiB
Bash
Executable File
54 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Test: VFS cache stores files at the expected filesystem path
|
|
#
|
|
# Verifies that when a file is read through the FUSE mount, it appears
|
|
# at $CACHE_DIR/vfs/nas/FILENAME — the exact path that warmup's
|
|
# is_cached logic checks to decide whether to skip a file.
|
|
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 create files at various depths
|
|
start_mock_nas
|
|
nas_create_file_content "root-file.txt" "root-level"
|
|
nas_create_file_content "sub/nested-file.txt" "nested"
|
|
nas_create_file_content "sub/deep/deep-file.txt" "deep-nested"
|
|
|
|
# Generate default config (remote_path="/")
|
|
gen_config
|
|
|
|
# Start warpgate and wait for readiness
|
|
start_warpgate
|
|
wait_for_mount
|
|
wait_for_rc_api
|
|
|
|
# Read each file through the FUSE mount to trigger caching
|
|
cat "$TEST_MOUNT/root-file.txt" > /dev/null
|
|
cat "$TEST_MOUNT/sub/nested-file.txt" > /dev/null
|
|
cat "$TEST_MOUNT/sub/deep/deep-file.txt" > /dev/null
|
|
|
|
# Verify that each file is cached at the expected path under
|
|
# $CACHE_DIR/vfs/nas/ (since remote_path="/", no extra prefix)
|
|
assert_cached "root-file.txt"
|
|
assert_cached "sub/nested-file.txt"
|
|
assert_cached "sub/deep/deep-file.txt"
|
|
|
|
# Also verify the actual on-disk paths exist and have correct content
|
|
assert_file_content "$CACHE_DIR/vfs/nas/root-file.txt" "root-level"
|
|
assert_file_content "$CACHE_DIR/vfs/nas/sub/nested-file.txt" "nested"
|
|
assert_file_content "$CACHE_DIR/vfs/nas/sub/deep/deep-file.txt" "deep-nested"
|
|
|
|
# Test that assert_cached works on files placed directly into the cache
|
|
# directory (bypassing FUSE). This validates the cache path detection used
|
|
# by warmup's is_cached logic.
|
|
mkdir -p "$CACHE_DIR/vfs/nas"
|
|
echo -n "manually-placed" > "$CACHE_DIR/vfs/nas/manual-file.txt"
|
|
assert_cached "manual-file.txt"
|
|
|
|
echo "PASS: $(basename "$0" .sh)"
|