warpgate/tests/05-cache/test-warmup-cache-path.sh
grabbit 6bb7ec4d27 Web UI overhaul: interactive config editor, SSE live updates, log viewer, and SMB reload fixes
- Replace raw TOML textarea with Alpine.js interactive form editor (10 collapsible
  sections with change-tier badges, dynamic array management for connections/shares/
  warmup rules, proper input controls per field type)
- Add SSE-based live dashboard updates replacing htmx polling
- Add log viewer tab with ring buffer backend and incremental polling
- Fix SMB not seeing new shares after config reload: kill entire smbd process group
  (not just parent PID) so forked workers release port 445
- Add SIGHUP-based smbd config reload for share changes instead of full restart,
  preserving existing client connections
- Generate human-readable commented TOML from config editor instead of bare
  toml::to_string_pretty() output
- Fix Alpine.js 2.x __x.$data calls in dashboard/share templates (now Alpine 3.x)
- Fix toggle switch CSS overlap with field labels
- Fix dashboard going blank on tab switch (remove hx-swap-oob from tab content)
- Add htmx:afterSettle → Alpine.initTree() bridge for robust tab switching

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 18:06:52 +08:00

55 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/<connection_name>/FILENAME — the exact path that warmup's
# is_cached logic checks to decide whether to skip a file.
# The default connection name is "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 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)"