warpgate/tests/05-cache/test-writeback-complete.sh
grabbit a2d49137f9 Add comprehensive test suite: 63 integration tests + 110 Rust unit tests
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>
2026-02-18 11:21:35 +08:00

37 lines
1010 B
Bash
Executable File

#!/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)"