Step 1 — Unify preset logic (eliminate dual implementation)
- src/cli/preset.rs: add missing fields (chunk_limit, multi_thread_streams,
multi_thread_cutoff), fix Office buffer_size 64M→128M, implement FromStr
- src/web/api.rs: post_preset() now calls Preset::apply() — no more inlined
params; Office write_back unified to 5s (was 3s in API)
Step 2 — Fix setup.rs connection test: warn→bail
- All 4 "Warning: Could not connect/resolve" prints replaced with anyhow::bail!
matching deploy/setup.rs behavior
Step 3 — Web UI: add [web] and [notifications] edit sections
- templates/web/tabs/config.html: new collapsible Web UI (password) and
Notifications (webhook_url, cache_threshold_pct, nas_offline_minutes,
writeback_depth) sections, both tagged "No restart"
- Also adds [log] section (file path + level select, "Full restart")
Step 4 — Full cron expression support in warmup scheduler
- Cargo.toml: add cron = "0.12", chrono = "0.4"
- supervisor.rs: normalize_cron_schedule() converts 5-field standard cron to
7-field cron crate format; replaces naive hour-only matching
Step 5 — Adaptive bandwidth algorithm
- supervisor.rs: extract compute_adaptive_limit() pure function; sliding
window of 6 samples, cv>0.3→congested (−25%, floor 1MiB/s), stable
near-limit→maintain, under-utilizing→+10% (capped at limit_up)
Step 6 — warpgate update command
- src/cli/update.rs: query GitHub Releases API, compare with CARGO_PKG_VERSION
- src/main.rs: add Update{apply}, SetupWifi, CloneMac{interface} commands
- src/cli/wifi.rs: TODO stub for WiFi AP setup
Unit tests (+35, total 188→223)
- cli/preset.rs: 10 tests — FromStr, all fields for each preset, idempotency,
connection/share isolation, write_back consistency regression
- supervisor.rs: 14 tests — normalize_cron_schedule (5 cases),
compute_adaptive_limit (9 cases: congestion, floor, stable, under-utilizing,
cap, zero-current, zero-max, empty window)
- config.rs: 11 tests — WebConfig (3), NotificationsConfig (4), LogConfig (4)
Shell tests (+4 scripts)
- tests/09-cli/test-preset-cli.sh: preset CLI without daemon; checks all
three presets write correct values including unified buffer_size/write_back
- tests/09-cli/test-update-command.sh: update command; skips on no-network
- tests/10-scheduled/test-cron-warmup-schedule.sh: "* * * * *" fires in <90s
- tests/10-scheduled/test-adaptive-bandwidth.sh: adaptive loop stability
- tests/harness/config-gen.sh: add warmup.warmup_schedule override support
- tests/run-all.sh: add 10-scheduled category
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
153 lines
3.8 KiB
Bash
Executable File
153 lines
3.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Warpgate Integration Test Runner
|
|
#
|
|
# Runs all test scripts across all categories and outputs TAP format results.
|
|
#
|
|
# Usage:
|
|
# sudo ./tests/run-all.sh # run all tests
|
|
# sudo WARPGATE_TEST_LONG=1 ./tests/run-all.sh # include slow tests
|
|
# sudo ./tests/run-all.sh 05-cache # run only one category
|
|
#
|
|
# Environment:
|
|
# WARPGATE_BIN Path to warpgate binary (default: auto-detect)
|
|
# WARPGATE_TEST_DIR Temp directory for tests (default: /tmp/warpgate-test)
|
|
# WARPGATE_TEST_LONG Set to 1 to run slow tests
|
|
# WARPGATE_TEST_BTRFS Path to btrfs block device for fs tests
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
|
|
# Auto-detect warpgate binary
|
|
if [[ -z "${WARPGATE_BIN:-}" ]]; then
|
|
if [[ -x "$PROJECT_ROOT/target/release/warpgate" ]]; then
|
|
export WARPGATE_BIN="$PROJECT_ROOT/target/release/warpgate"
|
|
elif [[ -x "$PROJECT_ROOT/target/debug/warpgate" ]]; then
|
|
export WARPGATE_BIN="$PROJECT_ROOT/target/debug/warpgate"
|
|
else
|
|
echo "ERROR: warpgate binary not found. Build with: cargo build --release" >&2
|
|
echo " Or set WARPGATE_BIN=/path/to/warpgate" >&2
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
echo "# Warpgate Integration Test Suite"
|
|
echo "# Binary: $WARPGATE_BIN"
|
|
echo "# Date: $(date -Iseconds)"
|
|
echo "# User: $(whoami)"
|
|
echo "#"
|
|
|
|
# Ensure test temp directory exists
|
|
mkdir -p "${WARPGATE_TEST_DIR:-/tmp/warpgate-test}"
|
|
|
|
# Test categories in execution order
|
|
CATEGORIES=(
|
|
01-config
|
|
02-lifecycle
|
|
03-signal
|
|
04-supervision
|
|
05-cache
|
|
06-writeback
|
|
07-network
|
|
08-crash-recovery
|
|
09-cli
|
|
10-scheduled
|
|
)
|
|
|
|
# Filter to specific category if requested
|
|
if [[ -n "${1:-}" ]]; then
|
|
found=0
|
|
for cat in "${CATEGORIES[@]}"; do
|
|
if [[ "$cat" == "$1" ]]; then
|
|
found=1
|
|
break
|
|
fi
|
|
done
|
|
if [[ $found -eq 0 ]]; then
|
|
echo "ERROR: unknown category: $1" >&2
|
|
echo "Available: ${CATEGORIES[*]}" >&2
|
|
exit 1
|
|
fi
|
|
CATEGORIES=("$1")
|
|
fi
|
|
|
|
# Collect all test scripts
|
|
ALL_TESTS=()
|
|
for category in "${CATEGORIES[@]}"; do
|
|
category_dir="$SCRIPT_DIR/$category"
|
|
if [[ ! -d "$category_dir" ]]; then
|
|
continue
|
|
fi
|
|
while IFS= read -r -d '' test_script; do
|
|
ALL_TESTS+=("$test_script")
|
|
done < <(find "$category_dir" -name 'test-*.sh' -type f -print0 | sort -z)
|
|
done
|
|
|
|
total=${#ALL_TESTS[@]}
|
|
if [[ $total -eq 0 ]]; then
|
|
echo "No tests found."
|
|
exit 0
|
|
fi
|
|
|
|
# TAP header
|
|
echo "1..$total"
|
|
|
|
passed=0
|
|
failed=0
|
|
skipped=0
|
|
test_num=0
|
|
|
|
for test_script in "${ALL_TESTS[@]}"; do
|
|
test_num=$((test_num + 1))
|
|
|
|
# Extract category and test name
|
|
rel_path="${test_script#$SCRIPT_DIR/}"
|
|
test_name="${rel_path%.sh}"
|
|
|
|
# Run the test, capturing output and exit code
|
|
test_output=""
|
|
test_exit=0
|
|
test_start=$(date +%s)
|
|
|
|
test_output=$(bash "$test_script" 2>&1) || test_exit=$?
|
|
|
|
test_end=$(date +%s)
|
|
test_duration=$((test_end - test_start))
|
|
|
|
if echo "$test_output" | grep -qi "^SKIP"; then
|
|
echo "ok $test_num - $test_name # SKIP ${test_duration}s"
|
|
skipped=$((skipped + 1))
|
|
elif [[ $test_exit -eq 0 ]]; then
|
|
echo "ok $test_num - $test_name # ${test_duration}s"
|
|
passed=$((passed + 1))
|
|
else
|
|
echo "not ok $test_num - $test_name # ${test_duration}s"
|
|
failed=$((failed + 1))
|
|
|
|
# Print failure details as TAP diagnostics
|
|
while IFS= read -r line; do
|
|
echo " # $line"
|
|
done <<< "$test_output"
|
|
fi
|
|
done
|
|
|
|
# Summary
|
|
echo "#"
|
|
echo "# =============================="
|
|
echo "# Test Summary"
|
|
echo "# =============================="
|
|
echo "# Total: $total"
|
|
echo "# Passed: $passed"
|
|
echo "# Failed: $failed"
|
|
echo "# Skipped: $skipped"
|
|
echo "#"
|
|
|
|
if [[ $failed -gt 0 ]]; then
|
|
echo "# RESULT: FAIL"
|
|
exit 1
|
|
else
|
|
echo "# RESULT: PASS"
|
|
exit 0
|
|
fi
|