#!/usr/bin/env bash # Test: writing through FUSE mount creates a dirty file in VFS # # Verifies that a file written through the mount point shows up as a # pending upload (dirty) in the rclone VFS stats when write-back delay # is long enough to observe it. 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 with a long write-back delay so the file stays dirty gen_config write_back=60s # Start warpgate and wait for readiness start_warpgate wait_for_mount wait_for_rc_api # Write a file through the FUSE mount echo "test-write" > "$TEST_MOUNT/written.txt" # Allow a moment for VFS to register the write sleep 2 # Verify the file is counted as dirty (not yet written back) dirty=$(get_dirty_count) if [[ "$dirty" -lt 1 ]]; then echo "FAIL: expected dirty count > 0, got $dirty" >&2 exit 1 fi # Verify the file is readable through the mount assert_file_content "$TEST_MOUNT/written.txt" "test-write" echo "PASS: $(basename "$0" .sh)"