Files
fips/testing/iface-binding/generate-configs.sh
T
Arjen 6485271ef5 test(iface-binding): cover the presence machine end to end
Two daemons whose only transports are interface-bound, run against a veth
pair the harness creates, downs, deletes and recreates underneath them.

Asserts the boot race (a daemon whose only interface is missing starts,
reports the transport absent and the node Degraded, rather than exiting on
NoTransports or skipping the transport for the life of the process), the
late attach and discovery over it, the flap in both directions,
destroy-and-recreate, and that an optional interface which never appears
never moves node health.

Also the log policy, which is the half that is easy to regress silently:
absence is logged once on the edge and not once per retry; a required
interface still absent past the ten-second bring-up window errors exactly
once, while the optional one — absent just as long — stays silent; and that
error is not repeated on a schedule. The detach edge is checked not to
error, guarded by how long detection actually took, so a slow runner skips
the check rather than failing on the harness's own latency.

The containers run FIPS_TEST_MODE=default, not chaos. The chaos entrypoint
waits up to 30 s for every configured Ethernet interface before starting the
daemon, which is precisely the workaround under test — the daemon has to do
its own waiting here or the suite proves nothing.

Host-namespace ip(8) runs in a short-lived privileged container sharing the
host network and PID namespaces, for the reason chaos/sim/veth.py documents:
on macOS the containers live in the Docker VM, so ip(8) run on the macOS
host could never reach them.

Chaos ethernet transports are marked optional: true. In that harness a
neighbour's interface disappearing is the scenario, not a fault — node_churn
stops a container, which destroys its netns and with it both ends of every
veth it held, so a surviving node watches a required interface vanish for
the 30-90 s the neighbour is down, once per churn event. Reporting that at
error is right for a deployment and wrong for a harness that tears the
interface down on purpose; the mesh-wide zero-ERROR ceiling would have
failed on injected chaos rather than on a defect.
2026-09-01 09:54:36 +01:00

93 lines
2.7 KiB
Bash
Executable File

#!/bin/bash
# Generate fixtures for the dynamic interface binding integration test.
#
# Two FIPS nodes, each with two Ethernet transports and nothing else:
#
# lab ve-lab0 required — does not exist when the daemon starts; the
# harness creates the veth pair afterwards
# dock fips-dock0 optional — never exists, on any host, ever
#
# There is deliberately no UDP transport. A node whose only transports are
# interface-bound is the case that used to be unrecoverable: every transport
# skipped at start, nothing retried, and the node up and deaf.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
# Scoped by the per-run suffix because this directory is wiped and rewritten
# below: two runs sharing one output directory would delete each other's
# fixtures out from under running containers.
GENERATED_DIR="$SCRIPT_DIR/generated-configs${FIPS_CI_NAME_SUFFIX:-}"
# Deterministic test identities (mirrors the firewall/acl-allowlist style).
KEY_A="0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20"
KEY_B="b102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1fb0"
write_file() {
local path="$1"
mkdir -p "$(dirname "$path")"
cat > "$path"
}
# Peers are found by beacon, not configured: a MAC address that does not exist
# until the harness creates the veth pair cannot be written into a config file
# ahead of time. Discovery over the late-bound interface is part of what the
# suite asserts.
write_node_config() {
write_file "$GENERATED_DIR/$1/fips.yaml" <<EOF
node:
identity:
persistent: true
# No TUN and no DNS: this suite is about transport binding, and every extra
# child is another way for a failure to be misattributed.
tun:
enabled: false
dns:
enabled: false
transports:
ethernet:
lab:
interface: "$LAB_IFACE"
listen: true
announce: true
auto_connect: true
accept_connections: true
# Fast beacons so peering after a late bind is observed in seconds
# rather than in the 30 s production default.
beacon_interval_secs: 2
dock:
interface: "$DOCK_IFACE"
# Absence is normal for this one, so it must never move node health.
optional: true
listen: true
announce: true
auto_connect: true
accept_connections: true
beacon_interval_secs: 2
peers: []
EOF
}
LAB_IFACE="${LAB_IFACE:-ve-lab0}"
DOCK_IFACE="${DOCK_IFACE:-fips-dock0}"
echo "Generating interface-binding fixtures..."
rm -rf "$GENERATED_DIR"
write_node_config node-a
write_file "$GENERATED_DIR/node-a/fips.key" <<EOF
$KEY_A
EOF
write_node_config node-b
write_file "$GENERATED_DIR/node-b/fips.key" <<EOF
$KEY_B
EOF
echo "Interface-binding fixtures written to $GENERATED_DIR"