warpgate/tests/02-lifecycle/test-rclone-immediate-exit.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

31 lines
886 B
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"
require_root
setup_test_env
trap teardown_test_env EXIT
# Start the mock NAS so the connection is reachable, but configure warpgate
# with a WRONG key file so rclone fails with "auth failed" (not "connection
# refused"). This tests the auth-failure fast-exit path.
start_mock_nas
# Generate a second SSH key that is NOT in authorized_keys
ssh-keygen -t ed25519 -f "$TEST_DIR/wrong_key" -N "" -q
gen_config nas_key_file="$TEST_DIR/wrong_key"
start_warpgate
# rclone should fail fast; allow up to 10s for warpgate to detect and exit
wait_for_exit "$WARPGATE_PID" 10
# Verify the immediate-exit message appeared in the log
assert_log_contains "rclone mount exited immediately"
echo "PASS: $(basename "$0" .sh)"