#!/usr/bin/env bash # Test: cache miss triggers remote file pull into local VFS cache # # Verifies that reading a file through the FUSE mount for the first time # fetches it from the remote NAS via rclone and stores it in $CACHE_DIR/vfs/nas/. 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 place a 1 MB raw photo file on it start_mock_nas nas_create_file "photo.cr3" 1024 # Generate default config pointing at mock NAS gen_config # Start warpgate and wait for mount + RC API readiness start_warpgate wait_for_mount wait_for_rc_api # Verify the file is NOT cached yet assert_not_cached "photo.cr3" # Read the file through the FUSE mount (triggers cache-miss pull) cat "$TEST_MOUNT/photo.cr3" > /dev/null # Verify the content matches the source file on the NAS diff "$TEST_MOUNT/photo.cr3" "$NAS_ROOT/photo.cr3" # Verify the file is now present in the VFS cache assert_cached "photo.cr3" echo "PASS: $(basename "$0" .sh)"