warpgate/tests/03-signal/test-sigterm-during-mount.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

34 lines
929 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"
# No require_root: this test uses an unreachable host, no mock NAS needed
setup_test_env
trap teardown_test_env EXIT
# Generate config with an unreachable NAS host (RFC 5737 TEST-NET)
# so warpgate blocks in the mount phase waiting for SFTP connection
gen_config nas_host=192.0.2.1
# Start warpgate — it will try to connect to the unreachable host
start_warpgate
# Give it time to enter the mount-wait phase
sleep 2
# Send SIGTERM while still waiting for mount
kill -TERM "$WARPGATE_PID"
# Should exit quickly since it never completed mount
wait_for_exit "$WARPGATE_PID" 10
# Verify no orphan rclone processes remain
assert_no_orphan_rclone
# Verify the mount point is not mounted (it never was)
assert_not_mounted
echo "PASS: $(basename "$0" .sh)"