hosts/van.conf: record the R5C's current dongles; tests read host values
The R5C's 2.4GHz AP now uses the D-Link dongle wlxf4f26d1760a7 (the same dongle hosts/wan.conf lists — it moves between hosts) and a Wi-Fi WAN test dongle wlx200bd04dc756 is configured (not always attached; van-failover treats an absent device as "not present"). The tests no longer hardcode this host's hardware: assertions read the expected interface names from the host file (hv helper), and the "no Wi-Fi WAN" path (no wifis: stanza, `wifi WAN: none`) is covered with a synthetic copy of van.conf with WIFI_WAN_IFACE emptied. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KqhjP7nud5gdBg25zCiRk9
This commit is contained in:
@@ -50,6 +50,7 @@ done
|
||||
|
||||
# 5. host-specific values land in the rendered output
|
||||
r() { VANLINK_CONF="hosts/$1.conf" ./deploy.sh render "$2"; }
|
||||
hv() { ( . "hosts/$1.conf"; printf %s "${!2-}" ); } # hv <host> <VAR>: a value from a host file (so hardware changes need no test edits)
|
||||
expect() { # expect <host> <file> <fixed string that must appear>
|
||||
if r "$1" "$2" | grep -qF -- "$3"; then ok "$1: $2 has '$3'"; else bad "$1: $2 lacks '$3'"; fi
|
||||
}
|
||||
@@ -63,9 +64,9 @@ expect van ap/nftables.conf 'ip saddr 10.42.1.0/24'
|
||||
expect wan ap/nftables.conf 'ip saddr 10.42.0.0/24'
|
||||
expect van ap/van-br0-setup.service 'brctl addif br0 enP1p17s0'
|
||||
expect wan ap/van-br0-setup.service 'brctl addif br0 enx00e04c331140'
|
||||
expect van failover/config.json '"device": ""'
|
||||
expect van failover/config.json "\"device\": \"$(hv van WIFI_WAN_IFACE)\""
|
||||
expect wan failover/config.json '"device": "wlan0"'
|
||||
expect van router-status/config.json '"wifi_wan_iface": ""'
|
||||
expect van router-status/config.json "\"wifi_wan_iface\": \"$(hv van WIFI_WAN_IFACE)\""
|
||||
expect van failover/van-wlan-watchdog.service 'ExecStart=/usr/local/sbin/van-wlan-watchdog'
|
||||
expect wan failover/van-wlan-watchdog.service 'van-wlan-watchdog wlan0'
|
||||
expect van ap/van-ap-unmanaged.conf 'interface-name:enP1p17s0'
|
||||
@@ -75,7 +76,7 @@ expect van power/nvme-watch-config.json '"nvme_device": ""'
|
||||
expect wan ap/hostapd.conf 'interface=wlxc83a35a4ee55'
|
||||
expect van ap/hostapd.conf 'interface=wlp1s0'
|
||||
expect wan ap/hostapd-2g.conf 'interface=wlxf4f26d1760a7'
|
||||
expect van ap/hostapd-2g.conf 'interface=wlx3c3332002066'
|
||||
expect van ap/hostapd-2g.conf "interface=$(hv van WIFI_2G_IFACE)"
|
||||
expect_line wan ap/hostapd.conf 'ssid=VanLink'
|
||||
expect_line van ap/hostapd.conf 'ssid=VanLink2'
|
||||
expect_line wan ap/hostapd-2g.conf 'ssid=VanLink'
|
||||
@@ -216,7 +217,17 @@ tmpw=$(mktemp)
|
||||
VANLINK_CONF=hosts/wan.conf ./deploy.sh --render-wan-netplan > "$tmpw"
|
||||
if [ "$want" = "$(cat "$tmpw")" ]; then ok "wan.conf: split netplan renders identical to the old single template"; else bad "wan.conf: netplan render changed by the split"; diff <(echo "$want") "$tmpw" | head -10 | sed 's/^/ /' || true; fi
|
||||
if grep -qF '/etc/vanlink.conf' "$tmpw"; then bad "wan.conf: rendered netplan mentions /etc/vanlink.conf (a comment was re-edited; live hosts would report differs)"; else ok "wan.conf: rendered netplan keeps the original comments (no /etc/vanlink.conf)"; fi
|
||||
if VANLINK_CONF=hosts/van.conf ./deploy.sh --render-wan-netplan | grep -q '^ wifis:'; then bad "van.conf: wifis stanza must be omitted (WIFI_WAN_IFACE empty)"; else ok "van.conf: no wifis stanza"; fi
|
||||
# van's Wi-Fi uplink (if any) is whatever its host file names; the "no Wi-Fi WAN" path is covered with a synthetic conf
|
||||
vw=$(hv van WIFI_WAN_IFACE)
|
||||
vnp=$(VANLINK_CONF=hosts/van.conf ./deploy.sh --render-wan-netplan)
|
||||
if [ -n "$vw" ]; then
|
||||
if [[ $vnp == *" ${vw}:"* ]]; then ok "van.conf: wifis stanza names $vw"; else bad "van.conf: wifis stanza lacks $vw"; fi
|
||||
else
|
||||
if [[ $vnp == *" wifis:"* ]]; then bad "van.conf: wifis stanza must be omitted (WIFI_WAN_IFACE empty)"; else ok "van.conf: no wifis stanza"; fi
|
||||
fi
|
||||
nw=$(mktemp); sed -E 's/^WIFI_WAN_IFACE=[^[:space:]#]*/WIFI_WAN_IFACE=/' hosts/van.conf > "$nw"
|
||||
nnp=$(VANLINK_CONF="$nw" ./deploy.sh --render-wan-netplan)
|
||||
if [[ $nnp == *" wifis:"* ]]; then bad "empty WIFI_WAN_IFACE: wifis stanza must be omitted"; else ok "empty WIFI_WAN_IFACE: no wifis stanza"; fi
|
||||
rm -f "$tmpw" "$old"
|
||||
|
||||
# 15. cellular connection name comes from the host config
|
||||
@@ -237,7 +248,10 @@ for h in van wan; do
|
||||
echo "$p" | grep -q '^wan-plan: ENABLE_NM_WAN=1$' && ok "$h: wan-plan header" || bad "$h: wan-plan header"
|
||||
echo "$p" | grep -q 'cellular profile: Koodo apn=sp.koodo.com' && ok "$h: wan-plan cellular" || bad "$h: wan-plan cellular"
|
||||
done
|
||||
p=$(VANLINK_CONF=hosts/van.conf ./deploy.sh --wan-plan); echo "$p" | grep -q 'wifi WAN: none' && ok "van: wan-plan says no Wi-Fi WAN" || bad "van: wan-plan Wi-Fi WAN"
|
||||
want_wp="wifi WAN: ${vw:-none}"
|
||||
p=$(VANLINK_CONF=hosts/van.conf ./deploy.sh --wan-plan); [[ $p == *"$want_wp"* ]] && ok "van: wan-plan says '$want_wp'" || bad "van: wan-plan Wi-Fi WAN (want '$want_wp')"
|
||||
p=$(VANLINK_CONF="$nw" ./deploy.sh --wan-plan); [[ $p == *"wifi WAN: none"* ]] && ok "empty WIFI_WAN_IFACE: wan-plan says no Wi-Fi WAN" || bad "empty WIFI_WAN_IFACE: wan-plan Wi-Fi WAN"
|
||||
rm -f "$nw"
|
||||
p=$(VANLINK_CONF=hosts/wan.conf ./deploy.sh --wan-plan); echo "$p" | grep -q 'wifi WAN: wlan0' && ok "wan: wan-plan Wi-Fi WAN wlan0" || bad "wan: wan-plan Wi-Fi WAN"
|
||||
# CELLULAR_UUID is derived in pure bash (no uuidgen dependency) and stable
|
||||
u1=$(VANLINK_CONF=hosts/van.conf ./deploy.sh render ap/cellular.nmconnection | grep '^uuid=')
|
||||
|
||||
Reference in New Issue
Block a user