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>
53 lines
1.3 KiB
Bash
Executable File
53 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Test: `warpgate bwlimit --up 10M --down 50M` sets bandwidth limits
|
|
#
|
|
# Verifies that setting bandwidth limits prints a confirmation message,
|
|
# and that a subsequent query reflects the new limits.
|
|
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
|
|
gen_config
|
|
|
|
# Start warpgate and wait for readiness
|
|
start_warpgate
|
|
wait_for_mount 60
|
|
wait_for_rc_api 30
|
|
|
|
# Set new bandwidth limits
|
|
output=$(run_warpgate_cmd bwlimit --up 10M --down 50M)
|
|
|
|
# Verify the set command confirms the update
|
|
assert_output_contains "$output" "Updated bandwidth limits"
|
|
|
|
# Query limits again to verify they are reflected
|
|
output2=$(run_warpgate_cmd bwlimit)
|
|
|
|
# The query should show the limits we just set (10M up, 50M down)
|
|
if echo "$output2" | grep -qi "10M\|10 M\|10240"; then
|
|
true
|
|
else
|
|
echo "FAIL: bwlimit query does not reflect the 10M upload limit" >&2
|
|
echo " output: $output2" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if echo "$output2" | grep -qi "50M\|50 M\|51200"; then
|
|
true
|
|
else
|
|
echo "FAIL: bwlimit query does not reflect the 50M download limit" >&2
|
|
echo " output: $output2" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "PASS: $(basename "$0" .sh)"
|