warpgate/tests/06-writeback/test-writeback-delay-zero.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

41 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
source "$SCRIPT_DIR/../harness/helpers.sh"
source "$SCRIPT_DIR/../harness/mock-nas.sh"
# Test: write_back=0s causes immediate upload — no dirty files linger.
# With zero write-back delay, rclone should upload files as soon as they
# are closed, so the dirty count should reach 0 quickly.
require_root
setup_test_env
trap teardown_test_env EXIT
start_mock_nas
# Zero write-back delay — files are uploaded immediately
gen_config write_back=0s
start_warpgate
wait_for_mount
wait_for_rc_api
# Write a file through the FUSE mount
echo "instant-wb" > "$TEST_MOUNT/instant.txt"
# Give time for the immediate write-back to complete
sleep 5
# Dirty count should be 0 — the file was already uploaded
dirty=$(get_dirty_count)
if [[ "$dirty" -ne 0 ]]; then
echo "FAIL: expected dirty count 0 with write_back=0s, got $dirty" >&2
exit 1
fi
# Verify the file arrived on the NAS with correct content
assert_file_content "$NAS_ROOT/instant.txt" "instant-wb"
echo "PASS: $(basename "$0" .sh)"