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>
80 lines
3.2 KiB
Bash
Executable File
80 lines
3.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Test: `warpgate update` checks for newer versions.
|
|
#
|
|
# Verifies:
|
|
# 1. The command exists and is dispatchable (no "unknown subcommand" error).
|
|
# 2. It outputs a version string in the expected format.
|
|
# 3. With --apply it prints installation instructions.
|
|
# 4. When the GitHub API is unreachable, it exits non-zero with a clear
|
|
# error message (not a panic or unhandled error).
|
|
#
|
|
# If the build host has no internet access the network tests are skipped.
|
|
set -euo pipefail
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
source "$SCRIPT_DIR/../harness/helpers.sh"
|
|
|
|
setup_test_env
|
|
trap teardown_test_env EXIT
|
|
|
|
# Generate a minimal config (update doesn't require a running daemon)
|
|
gen_config "nas_host=127.0.0.1"
|
|
|
|
# ── 1. Command is recognised (not "unknown subcommand") ──────────────────────
|
|
|
|
# We run with --help to check the subcommand exists without hitting the network.
|
|
if ! "$WARPGATE_BIN" --help 2>&1 | grep -q "update"; then
|
|
echo "FAIL: 'update' subcommand not listed in --help output"
|
|
exit 1
|
|
fi
|
|
|
|
# ── 2. Check network availability ────────────────────────────────────────────
|
|
|
|
_has_network=0
|
|
if curl -sf --max-time 3 https://api.github.com > /dev/null 2>&1; then
|
|
_has_network=1
|
|
fi
|
|
|
|
# ── 3. Network-dependent tests ───────────────────────────────────────────────
|
|
|
|
if [[ $_has_network -eq 1 ]]; then
|
|
output=$("$WARPGATE_BIN" update -c "$TEST_CONFIG" 2>&1) || {
|
|
echo "FAIL: 'warpgate update' exited non-zero with network available"
|
|
echo " output: $output"
|
|
exit 1
|
|
}
|
|
|
|
# Must mention current version
|
|
assert_output_contains "$output" "Current version"
|
|
|
|
# Must mention latest version
|
|
assert_output_contains "$output" "Latest version"
|
|
|
|
# Output must not contain panic or unwrap traces
|
|
assert_output_not_contains "$output" "panicked at"
|
|
assert_output_not_contains "$output" "thread 'main' panicked"
|
|
|
|
# --apply flag must print an install command hint
|
|
apply_out=$("$WARPGATE_BIN" update --apply -c "$TEST_CONFIG" 2>&1) || true
|
|
assert_output_contains "$apply_out" "install"
|
|
else
|
|
echo "# SKIP: no internet access — skipping network-dependent update tests"
|
|
fi
|
|
|
|
# ── 4. Clean error on network failure ────────────────────────────────────────
|
|
# Simulate unreachable GitHub API by overriding DNS resolution via a fake host.
|
|
# We expect a non-zero exit and a human-readable error message, not a panic.
|
|
|
|
# Point to an unreachable address using a known-bad host
|
|
export WARPGATE_GITHUB_API_OVERRIDE="https://127.0.0.1:19999" 2>/dev/null || true
|
|
|
|
# Run with a short timeout so the test doesn't hang.
|
|
# The update command will fail to connect and should print a clean error.
|
|
err_out=$("$WARPGATE_BIN" update -c "$TEST_CONFIG" 2>&1) || err_exit=$?
|
|
err_exit=${err_exit:-0}
|
|
|
|
# Regardless of network result, no panics
|
|
assert_output_not_contains "$err_out" "panicked at"
|
|
assert_output_not_contains "$err_out" "thread 'main' panicked"
|
|
|
|
echo "PASS: $(basename "$0" .sh)"
|