#!/usr/bin/env bash # Test: write-back completes and file appears on NAS # # Verifies that after a file is written through the mount, the rclone VFS # write-back mechanism flushes it to the remote NAS within the configured # write-back delay, and the dirty count returns to zero. 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 short write-back delay (2s) gen_config write_back=2s # Start warpgate and wait for readiness start_warpgate wait_for_mount wait_for_rc_api # Write a file through the FUSE mount echo "writeback-test" > "$TEST_MOUNT/wb.txt" # Wait for the dirty count to return to zero (write-back complete) wait_for_dirty_zero 30 # Verify the file arrived on the NAS with correct content assert_file_content "$NAS_ROOT/wb.txt" "writeback-test" echo "PASS: $(basename "$0" .sh)"