Files
kit-busrouter/tests/bats/decide.bats
T
kitadmin 24d8fbd366 fix: revert TUNNEL_LOCAL_SSH_PORT to 2223, fix registry, add incident docs
- wizard.sh + connect.conf: TUNNEL_LOCAL_SSH_PORT back to 2223 (Synology SSH port)
- port-registry: renamed x6340 → x4662 (matches QuickConnect ID)
- port-registry: added MR2200ac mesh satellite note for x4662
- deployment checklist: added kit-connect section, post-deployment rules,
  incident log, and complete fleet port registry table
- memory: added fleet-router-inventory.md with full fleet state
- hub README: updated with current status and locations

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-22 21:20:08 +00:00

22 lines
1.5 KiB
Bash

setup(){ load '../../package/kit-busrouter/files/usr/lib/busrouter/lib-decide.sh'; }
@test "equal scores -> 50/50" { run wan_weight 70 70; [ "$output" -eq 50 ]; }
# 50 + 2*(80-60) = 90 -> clamp to 80 (max). So 80 is the true formula result.
@test "weight = 50 + 2*diff, rounded to 10" { run wan_weight 80 60; [ "$output" -eq 80 ]; }
@test "clamped to 20..80 (high)" { run wan_weight 100 0; [ "$output" -eq 80 ]; }
@test "clamped to 20..80 (low)" { run wan_weight 0 100; [ "$output" -eq 20 ]; }
# 50 + 2*(58-55) = 56 -> round to nearest 10 -> 60
@test "rounds to nearest 10" { run wan_weight 58 55; [ "$output" -eq 60 ]; }
@test "no change if within hysteresis band" { run weight_changed 50 54; [ "$status" -eq 1 ]; }
@test "change if crosses a 10% step" { run weight_changed 50 65; [ "$status" -eq 0 ]; }
@test "change is symmetric (decrease)" { run weight_changed 60 50; [ "$status" -eq 0 ]; }
@test "sim switch only after N bad cycles" { run sim_should_switch 3 3; [ "$status" -eq 0 ]; }
@test "sim no switch before threshold" { run sim_should_switch 2 3; [ "$status" -eq 1 ]; }
@test "gw_verdict: 3/3 -> alive" { run gw_verdict 1 1 1; [ "$status" -eq 0 ]; }
@test "gw_verdict: 2/3 no http -> alive" { run gw_verdict 1 1 0; [ "$status" -eq 0 ]; }
@test "gw_verdict: 2/3 no ping -> alive" { run gw_verdict 1 0 1; [ "$status" -eq 0 ]; }
@test "gw_verdict: 2/3 no dns -> alive" { run gw_verdict 0 1 1; [ "$status" -eq 0 ]; }
@test "gw_verdict: 1/3 -> dead" { run gw_verdict 1 0 0; [ "$status" -eq 1 ]; }
@test "gw_verdict: 0/3 -> dead" { run gw_verdict 0 0 0; [ "$status" -eq 1 ]; }