#!/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 drain times out when transfers cannot complete. # Extreme network latency prevents the drain from finishing within the # 300s timeout, so warpgate should log a timeout and exit anyway. # This is a slow test (>300s) — requires WARPGATE_TEST_LONG=1. require_root require_long_tests setup_test_env trap teardown_test_env EXIT start_mock_nas gen_config write_back=5s start_warpgate wait_for_mount wait_for_rc_api # Write a file so there is something to drain echo "timeout-test-data" > "$TEST_MOUNT/timeout.txt" # Allow VFS to register the write sleep 1 # Inject extreme latency — 10s per packet makes transfer effectively impossible inject_latency 10000 # Send SIGTERM to initiate shutdown + drain kill -TERM "$WARPGATE_PID" # The drain timeout is 300s; allow additional margin for shutdown wait_for_exit "$WARPGATE_PID" 320 # Verify the drain timed out assert_log_contains "write-back drain timed out" echo "PASS: $(basename "$0" .sh)"