From 8ee8062d602c1272b528050b3ef5a6f52d7016d7 Mon Sep 17 00:00:00 2001 From: GnomeZworc Date: Sun, 11 Oct 2026 23:41:50 +0200 Subject: [PATCH] f-41: lab: s7 et s8 par l'API #41 Signed-off-by: GnomeZworc --- test/e2e/lib/node.sh | 110 ++++++++++++++++++++++- test/e2e/run_test.sh | 78 ++++++++++++++++ test/e2e/scenarios/s7-l3vni.sh | 73 +++++++++++++++ test/e2e/scenarios/s8-l3vni-migration.sh | 94 +++++++++++++++++++ 4 files changed, 354 insertions(+), 1 deletion(-) create mode 100644 test/e2e/scenarios/s7-l3vni.sh create mode 100644 test/e2e/scenarios/s8-l3vni-migration.sh diff --git a/test/e2e/lib/node.sh b/test/e2e/lib/node.sh index 0a7111c..b424c98 100644 --- a/test/e2e/lib/node.sh +++ b/test/e2e/lib/node.sh @@ -26,6 +26,10 @@ api_delete () { curl -fsS -o /dev/null -X DELETE "${API}/${1}" } +api_code () { + curl -s -o /dev/null -w '%{http_code}' -X "${1}" "${API}/${2}" +} + api_state () { curl -fsS "${API}/${1}" 2>/dev/null | jq -r .state } @@ -44,8 +48,9 @@ wait_state () { } vpc_create () { + local l3vni="${3:+,\"l3vni\":${3}}" api_state "vpcs/${1}" | grep -qx running && return 0 - api_post vpcs "{\"name\":\"${1}\",\"cidr\":\"${2}\"}" && wait_state "vpcs/${1}" running + api_post vpcs "{\"name\":\"${1}\",\"cidr\":\"${2}\"${l3vni}}" && wait_state "vpcs/${1}" running } subnet_create () { @@ -83,6 +88,7 @@ vm_key () { vm_create () { local name="${1}" subnet="${2}" ip="${3}" key="${4:-}" meta="{}" + api_state "vms/${name}" | grep -qx running && return 0 [ -n "${key}" ] && meta="{\"sshkey\":\"${key}\"}" mkdir -p "${VOLUMES}" cp "${TWO_IMAGE}" "${VOLUMES}/${name}.qcow2" || return 1 @@ -149,3 +155,105 @@ state = json.loads(buf).get("state") or {} print(" ".join(sorted(h["mac"].lower() + "=" + h["ip"] for h in state.get("hosts") or []))) PY } + +vrf_nexthops () { + ip -4 route show vrf "vrf-${1#vp-}" "${2}" | grep -o 'via [0-9.]*' | cut -d' ' -f2 | sort -u | tr '\n' ' ' | sed 's/ $//' +} + +wait_vrf_nexthops () { + local i + for i in $(seq 1 30); do + [ "$(vrf_nexthops "${1}" "${2}")" = "${3}" ] && return 0 + sleep 2 + done + echo "vrf-${1#vp-} ${2} : next-hops « $(vrf_nexthops "${1}" "${2}") », « ${3} » attendu" >&2 + return 1 +} + +ping_rate () { + vm_ssh "${1}" "${2}" "ping -q -n -c ${4:-50} -i 0.2 -W 1 ${3}" 2>/dev/null | grep -o '[0-9]* received' | cut -d' ' -f1 +} + +vrf_route_via () { + ip -4 route show vrf "vrf-${1#vp-}" "${2}" | grep -q "via ${3} " +} + +wait_vrf_route () { + local i + for i in $(seq 1 30); do + vrf_route_via "$@" && return 0 + sleep 2 + done + echo "vrf-${1#vp-} : pas de route ${2} via ${3}" >&2 + return 1 +} + +vrf_members () { + ip -o link show master "vrf-${1#vp-}" | awk -F': ' '{print $2}' | cut -d@ -f1 | sort | tr '\n' ' ' | sed 's/ $//' +} + +netns_ping_wait () { + local i + for i in $(seq 1 40); do + ip netns exec "${1}" ping -c 1 -W 2 "${2}" >/dev/null 2>&1 && return 0 + sleep 5 + done + echo "${2} injoignable depuis ${1}" >&2 + return 1 +} + +l3vni_ready () { + local out + out=$(vtysh -c "show evpn vni ${1}") && + grep -q 'Type: L3' <<<"${out}" && + grep -q 'State: Up' <<<"${out}" && + grep -qi "Router MAC: ${2}" <<<"${out}" +} + +wait_l3vni () { + local i + for i in $(seq 1 15); do + l3vni_ready "$@" && return 0 + sleep 2 + done + echo "VNI ${1} : pas de type L3 actif avec la RMAC ${2}" >&2 + return 1 +} + +vtep_host () { + ip -4 route get 10.255.255.1 | grep -o 'src [0-9.]*' | cut -d' ' -f2 +} + +bgp_paths () { + vtysh -c "show bgp vrf vrf-${1#vp-} ipv4 unicast ${2} json" 2>/dev/null | jq -r '(.paths // []) | length' +} + +bgp_best () { + vtysh -c "show bgp vrf vrf-${1#vp-} ipv4 unicast ${2} json" 2>/dev/null | + jq -r '(.paths // [])[] | select(.bestpath.overall == true) | "\(.nexthops[0].ip) (\(.bestpath.selectionReason // "seul chemin"))"' +} + +sources_reach () { + local vpc="${1}" bridge="${2}" base="${3}" dst="${4}" n ok=0 total=0 + for n in $(seq 20 59); do + ip -n "${vpc}" addr add "${base}.${n}/32" dev "${bridge}" 2>/dev/null + ip netns exec "${vpc}" ping -n -c 2 -W 1 -I "${base}.${n}" "${dst}" >/dev/null 2>&1 && ok=$((ok + 1)) + total=$((total + 1)) + ip -n "${vpc}" addr del "${base}.${n}/32" dev "${bridge}" + done + echo "${ok}/${total}" +} + +watchdog_reported () { + journalctl -u agent --since "-${2:-120}s" --no-pager -o cat | grep -F 'watchdog: inconsistency detected' | grep -qF -- "${1}" +} + +wait_watchdog () { + local i + for i in $(seq 1 30); do + watchdog_reported "$@" && return 0 + sleep 2 + done + echo "watchdog : « ${1} » non signalé" >&2 + return 1 +} diff --git a/test/e2e/run_test.sh b/test/e2e/run_test.sh index dd8022f..26393a9 100755 --- a/test/e2e/run_test.sh +++ b/test/e2e/run_test.sh @@ -133,6 +133,84 @@ test_wait_state () { teardown } +test_vrf_route_via_matches_the_next_hop_exactly () { + setup "vrf_route_via : next-hop exact dans la bonne VRF" + local stub='ip () { [ "$*" = "-4 route show vrf vrf-s7 10.241.1.10" ] && echo "10.241.1.10 nhid 12 via 192.168.14.11 dev brl3-s7 proto bgp metric 20 onlink"; }; ' + [[ $(node "${stub}vrf_route_via vp-s7 10.241.1.10 192.168.14.11 && echo OUI") == OUI ]] || fail "route présente refusée" + [[ $(node "${stub}vrf_route_via vp-s7 10.241.1.10 192.168.14.1 || echo NON") == NON ]] || fail "192.168.14.1 pris pour 192.168.14.11" + [[ $(node "${stub}vrf_route_via vp-s7b 10.241.1.10 192.168.14.11 || echo NON") == NON ]] || fail "mauvaise VRF acceptée" + teardown +} + +test_vrf_members_lists_interface_names () { + setup "vrf_members : noms triés, sans le suffixe @ du veth" + [[ $(node 'ip () { printf "%s\n" "15: l3-s7-o@if14: mtu 1500 master vrf-s7" "12: brl3-s7: mtu 1500 master vrf-s7"; }; vrf_members vp-s7') == "brl3-s7 l3-s7-o" ]] \ + || fail "lu : $(node 'ip () { printf "%s\n" "15: l3-s7-o@if14: " "12: brl3-s7: "; }; vrf_members vp-s7')" + teardown +} + +test_vm_create_is_idempotent () { + setup "vm_create : VM déjà en running, rien n'est copié ni envoyé" + [[ $(node 'api_state () { echo running; }; cp () { echo COPIE; }; api_post () { echo POST; }; vm_create v sn 10.0.0.10 && echo OK') == OK ]] \ + || fail "VM existante recréée" + teardown +} + +test_l3vni_ready_requires_type_state_and_rmac () { + setup "l3vni_ready : type L3, état Up et RMAC exigés" + local out='VNI: 2700\n Type: L3\n State: Up\n Router MAC: 02:00:00:00:27:02' + [[ $(node "vtysh () { printf '${out}\n'; }; l3vni_ready 2700 02:00:00:00:27:02 && echo OUI") == OUI ]] || fail "VNI prête refusée" + [[ $(node "vtysh () { printf '${out}\n'; }; l3vni_ready 2700 02:00:00:00:27:01 || echo NON") == NON ]] || fail "mauvaise RMAC acceptée" + [[ $(node "vtysh () { printf '${out/Up/Down}\n'; }; l3vni_ready 2700 02:00:00:00:27:02 || echo NON") == NON ]] || fail "état Down accepté" + [[ $(node "vtysh () { printf '${out/L3/L2}\n'; }; l3vni_ready 2700 02:00:00:00:27:02 || echo NON") == NON ]] || fail "VNI L2 acceptée" + teardown +} + +test_vrf_nexthops_lists_every_ecmp_member () { + setup "vrf_nexthops : un chemin, plusieurs chemins, aucun" + [[ $(node 'ip () { echo "10.242.1.50 nhid 9 via 192.168.14.12 dev brl3-s8 proto bgp metric 20 onlink"; }; vrf_nexthops vp-s8 10.242.1.50') == 192.168.14.12 ]] || fail "un chemin" + [[ $(node 'ip () { printf "%s\n" "10.242.1.0/24 nhid 90 proto bgp metric 20" " nexthop via 192.168.14.12 dev brl3-s8 weight 1 onlink" " nexthop via 192.168.14.11 dev brl3-s8 weight 1 onlink"; }; vrf_nexthops vp-s8 10.242.1.0/24') == "192.168.14.11 192.168.14.12" ]] || fail "ECMP" + [[ -z $(node 'ip () { :; }; vrf_nexthops vp-s8 10.242.1.50') ]] || fail "aucun chemin" + teardown +} + +test_bgp_best_reports_next_hop_and_reason () { + setup "bgp_paths / bgp_best : nombre de chemins, meilleur next-hop et raison" + local json='{"prefix":"10.242.1.50/32","paths":[{"nexthops":[{"ip":"192.168.14.12"}]},{"nexthops":[{"ip":"192.168.14.11"}],"bestpath":{"overall":true,"selectionReason":"Router ID"}}]}' + [[ $(node "vtysh () { echo '${json}'; }; bgp_paths vp-s8 10.242.1.50/32") == 2 ]] || fail "nombre de chemins" + [[ $(node "vtysh () { echo '${json}'; }; bgp_best vp-s8 10.242.1.50/32") == "192.168.14.11 (Router ID)" ]] || fail "meilleur : $(node "vtysh () { echo '${json}'; }; bgp_best vp-s8 10.242.1.50/32")" + [[ $(node "vtysh () { echo '{}'; }; bgp_paths vp-s8 10.242.1.50/32") == 0 ]] || fail "préfixe absent" + teardown +} + +test_vpc_create_sends_the_l3vni_only_when_given () { + setup "vpc_create : l3vni transmise si donnée, absente sinon" + local stub='api_state () { echo; }; wait_state () { :; }; api_post () { echo "$1 $2"; }; ' + [[ $(node "${stub}vpc_create vp-s7 10.241.0.0/16 2700") == 'vpcs {"name":"vp-s7","cidr":"10.241.0.0/16","l3vni":2700}' ]] \ + || fail "avec l3vni : $(node "${stub}vpc_create vp-s7 10.241.0.0/16 2700")" + [[ $(node "${stub}vpc_create vp-s1 10.210.0.0/16") == 'vpcs {"name":"vp-s1","cidr":"10.210.0.0/16"}' ]] \ + || fail "sans l3vni : $(node "${stub}vpc_create vp-s1 10.210.0.0/16")" + teardown +} + +test_api_code_returns_the_http_status () { + setup "api_code : méthode, chemin et code HTTP" + [[ $(node 'curl () { echo "$*" >&2; echo 409; }; api_code DELETE subnets/sn-a 2>/dev/null') == 409 ]] || fail "code" + [[ $(node 'curl () { echo "$*"; }; api_code DELETE subnets/sn-a') == "-s -o /dev/null -w %{http_code} -X DELETE http://127.0.0.1:8080/subnets/sn-a" ]] \ + || fail "appel : $(node 'curl () { echo "$*"; }; api_code DELETE subnets/sn-a')" + teardown +} + +test_watchdog_reported_matches_only_watchdog_alerts () { + setup "watchdog_reported : alerte du watchdog contenant le texte, rien d'autre" + local alert='{"level":"ERROR","msg":"watchdog: inconsistency detected","kind":"vpc","name":"vp-s8","problem":"route 10.242.1.99/32 exported in vrf-s8 without a running owner: its traffic is black-holed"}' + local other='{"level":"ERROR","msg":"command failed","error":"route 10.242.1.99/32 exported in vrf-s8 without a running owner"}' + [[ $(node "journalctl () { echo '${alert}'; }; watchdog_reported 'route 10.242.1.99/32 exported in vrf-s8 without a running owner' && echo OUI") == OUI ]] || fail "alerte non trouvée" + [[ $(node "journalctl () { echo '${other}'; }; watchdog_reported 'route 10.242.1.99/32 exported in vrf-s8' || echo NON") == NON ]] || fail "message hors watchdog accepté" + [[ $(node "journalctl () { echo '${alert}'; }; watchdog_reported 'route 10.242.1.98/32' || echo NON") == NON ]] || fail "autre route acceptée" + teardown +} + for T in $(declare -F | awk '{print $3}' | grep '^test_'); do "${T}" done diff --git a/test/e2e/scenarios/s7-l3vni.sh b/test/e2e/scenarios/s7-l3vni.sh new file mode 100644 index 0000000..22b02cc --- /dev/null +++ b/test/e2e/scenarios/s7-l3vni.sh @@ -0,0 +1,73 @@ +on hv1 <<'NODE' +two_image || { echo "ÉCHOUÉ: image compatible two (hv1)"; exit 0; } +KEY=$(vm_key) +check "hv1 : base BGP posée par l'agent et enregistrée dans frr.conf" grep -qx ' neighbor 10.255.255.1 peer-group fabric' /etc/frr/frr.conf +check "hv1 : VPC vp-s7, l3vni 2700" vpc_create vp-s7 10.241.0.0/16 2700 +check "hv1 : subnet sn-s7d (VNI 2711), seulement sur hv1" subnet_create sn-s7d vp-s7 2711 10.241.1.1 10.241.1.0/24 +check "hv1 : VM s7-a" vm_create s7-a sn-s7d 10.241.1.10 "${KEY}" +NODE +on hv2 <<'NODE' +two_image || { echo "ÉCHOUÉ: image compatible two (hv2)"; exit 0; } +check "hv2 : VPC vp-s7, l3vni 2700" vpc_create vp-s7 10.241.0.0/16 2700 +check "hv2 : subnet sn-s7e (VNI 2712), seulement sur hv2" subnet_create sn-s7e vp-s7 2712 10.241.2.1 10.241.2.0/24 +check "hv2 : VM s7-b" vm_create s7-b sn-s7e 10.241.2.10 +check "hv2 : VPC vp-s7b, même plage, l3vni 2701" vpc_create vp-s7b 10.241.0.0/16 2701 +check "hv2 : subnet sn-s7x (VNI 2713), même plage que sn-s7e" subnet_create sn-s7x vp-s7b 2713 10.241.2.1 10.241.2.0/24 +check "hv2 : VM s7-x dans vp-s7b" vm_create s7-x sn-s7x 10.241.2.20 +check "hv2 : l3vni 2700 déjà prise par vp-s7, refusée (409)" test "$(curl -s -o /dev/null -w '%{http_code}' -X POST -H 'Content-Type: application/json' -d '{"name":"vp-s7c","cidr":"10.249.0.0/16","l3vni":2700}' "${API}/vpcs")" = 409 +NODE +on hv1 <<'NODE' +check "s7-a joignable" vm_wait vp-s7 10.241.1.10 +check "s7-a : route vers la VPC 10.241.0.0/16 via interface_ip (DHCP)" route_via vp-s7 10.241.1.10 10.241.0.0/16 10.241.1.1 +check "hv1 : vrf-s7 contient exactement brl3-s7 et l3-s7-o" sh -c "[ \"\$1\" = 'brl3-s7 l3-s7-o' ]" _ "$(vrf_members vp-s7)" +check "hv1 : brl3-s7 sans adresse IPv4" sh -c "! ip -4 -o addr show dev brl3-s7 | grep -q inet" +check "hv1 : RMAC de brl3-s7 dérivée du VTEP 192.168.14.11" sh -c "ip -o link show brl3-s7 | grep -q 'link/ether 02:02:c0:a8:0e:0b '" +check "hv1 : route du supernet dans vp-s7 vers le transit" sh -c "ip -n vp-s7 -4 route show 10.241.0.0/16 | grep -q 'via 169.254.0.1 dev l3-s7-i'" +check "hv1 : forwarding sur brl3-s7 et l3-s7-o" sh -c "[ \"\$(sysctl -n net.ipv4.conf.brl3-s7.forwarding net.ipv4.conf.l3-s7-o.forwarding | tr '\n' ' ')\" = '1 1 ' ]" +check "hv1 : ip_forward dans le netns vp-s7" sh -c "[ \"\$(ip netns exec vp-s7 sysctl -n net.ipv4.ip_forward)\" = 1 ]" +info "hv1 : ip_forward global de l'hôte : $(sysctl -n net.ipv4.ip_forward) (non modifié par l'agent)" +check "hv1 : vrf-s7 exporte le subnet local 10.241.1.0/24 (agent)" vrf_route_via vp-s7 10.241.1.0/24 169.254.0.2 +check "hv1 : vrf-s7 exporte s7-a 10.241.1.10/32 (agent)" vrf_route_via vp-s7 10.241.1.10 169.254.0.2 +check "hv1 : session vers le RR en iBGP (internal link)" sh -c "vtysh -c 'show bgp neighbors 10.255.255.1' | grep -q 'internal link'" +NODE +on hv2 <<'NODE' +check "hv2 : s7-b joignable depuis son netns" netns_ping_wait vp-s7 10.241.2.10 +check "hv2 : s7-x joignable depuis son netns (témoin)" netns_ping_wait vp-s7b 10.241.2.20 +check "hv2 : VNI 2700 de type L3, active, RMAC 02:02:c0:a8:0e:0c" wait_l3vni 2700 02:02:c0:a8:0e:0c +check "hv2 : VNI 2701 de type L3, active, RMAC 02:02:c0:a8:0e:0c" wait_l3vni 2701 02:02:c0:a8:0e:0c +check "hv2 : vrf-s7 apprend 10.241.1.10/32 via le VTEP de hv1" wait_vrf_route vp-s7 10.241.1.10 192.168.14.11 +check "hv2 : vrf-s7 apprend 10.241.1.0/24 via le VTEP de hv1" wait_vrf_route vp-s7 10.241.1.0/24 192.168.14.11 +check "hv2 : RMAC de hv1 dans la FDB de vxl3-s7" sh -c "bridge fdb show dev vxl3-s7 | grep -q '02:02:c0:a8:0e:0b dst 192.168.14.11'" +NODE +on rr1 <<'NODE' +check "rr1 : RT-5 10.241.1.10/32 de hv1 (RD 192.168.14.11:2700) reçue et réfléchie" sh -c "vtysh -c 'show bgp l2vpn evpn route rd 192.168.14.11:2700 type prefix' | grep -q '\[10.241.1.10\]'" +check "rr1 : RT-5 10.241.2.20/32 de vp-s7b (RD 192.168.14.12:2701) présente (témoin du test négatif)" sh -c "vtysh -c 'show bgp l2vpn evpn route rd 192.168.14.12:2701 type prefix' | grep -q '\[10.241.2.20\]'" +NODE +on hv1 <<'NODE' +check "hv1 : VNI 2700 de type L3, active, RMAC 02:02:c0:a8:0e:0b" wait_l3vni 2700 02:02:c0:a8:0e:0b +check "hv1 : vrf-s7 apprend 10.241.2.10/32 via le VTEP de hv2" wait_vrf_route vp-s7 10.241.2.10 192.168.14.12 +check "hv1 : aucun VXLAN de sn-s7e (VNI 2712) sur hv1" sh -c "! ip link show vxlan-2712 >/dev/null 2>&1" +for i in $(seq 1 24); do vm_ssh vp-s7 10.241.1.10 'ping -c 1 -W 2 10.241.2.10' >/dev/null 2>&1 && break; sleep 5; done +check "s7-a (sn-s7d, hv1) joint s7-b (sn-s7e, hv2) par le L3VNI, forwarding par interface" vm_ssh vp-s7 10.241.1.10 'ping -c 3 -W 2 10.241.2.10' +check "trame pleine taille : 1472 octets en -M do" vm_ssh vp-s7 10.241.1.10 'ping -M do -s 1472 -c 2 -W 2 10.241.2.10' +check "1473 octets refusés localement (MTU 1500)" vm_grep vp-s7 10.241.1.10 'ping -M do -s 1473 -c 1 -W 2 10.241.2.10' 'message too long' +check "TTL 1 : expire à la gateway du subnet, netns de hv1 (10.241.1.1)" vm_grep vp-s7 10.241.1.10 'ping -n -c 3 -i 1.2 -W 2 -t 1 10.241.2.10' 'From 10.241.1.1 .*exceeded' +check "TTL 2 : expire dans la VRF de hv1 (169.254.0.1)" vm_grep vp-s7 10.241.1.10 'ping -n -c 3 -i 1.2 -W 2 -t 2 10.241.2.10' 'From 169.254.0.1 .*exceeded' +check "TTL 5 : atteint s7-b — quatre routeurs : gateway hv1, VRF hv1, VRF hv2, netns hv2" vm_ssh vp-s7 10.241.1.10 'ping -n -c 1 -W 2 -t 5 10.241.2.10' +check "hv1 : vrf-s7 n'importe pas 10.241.2.20/32 de vp-s7b (RT 64600:2701)" sh -c "[ -z \"\$(ip -4 route show vrf vrf-s7 10.241.2.20)\" ]" +check "s7-a ne joint pas s7-x, autre VPC, même plage" vm_fails vp-s7 10.241.1.10 'ping -c 3 -W 2 10.241.2.20' +NODE +on hv2 <<'NODE' +BGPD=$(pidof bgpd) +check "hv2 : suppression de sn-s7x refusée tant que s7-x existe (409)" test "$(api_code DELETE subnets/sn-s7x)" = 409 +check "hv2 : suppression de s7-x" vm_delete s7-x +check "hv2 : vrf-s7b ne porte plus le /32 de s7-x" test -z "$(ip -4 route show vrf vrf-s7b 10.241.2.20/32)" +check "hv2 : suppression de sn-s7x" api_delete subnets/sn-s7x +check "hv2 : sn-s7x supprimé" wait_state subnets/sn-s7x deleted +check "hv2 : suppression de vp-s7b" api_delete vpcs/vp-s7b +check "hv2 : vp-s7b supprimé" wait_state vpcs/vp-s7b deleted +check "hv2 : plus aucune interface de vp-s7b" sh -c "! ip -o link show | grep -qE '(vrf|brl3|vxl3)-s7b|l3-s7b-o'" +check "hv2 : plus rien de vrf-s7b dans FRR, en mémoire ni dans frr.conf" sh -c "! vtysh -c 'show running-config' | grep -q 'vrf-s7b' && ! grep -q 'vrf-s7b' /etc/frr/frr.conf" +check "hv2 : bgpd n'a pas redémarré pendant le démontage" sh -c "[ \"\$(pidof bgpd)\" = '${BGPD}' ]" +check "hv2 : vp-s7 toujours en service" wait_l3vni 2700 02:02:c0:a8:0e:0c +NODE diff --git a/test/e2e/scenarios/s8-l3vni-migration.sh b/test/e2e/scenarios/s8-l3vni-migration.sh new file mode 100644 index 0000000..91f15de --- /dev/null +++ b/test/e2e/scenarios/s8-l3vni-migration.sh @@ -0,0 +1,94 @@ +on hv1 <<'NODE' +two_image || { echo "ÉCHOUÉ: image compatible two (hv1)"; exit 0; } +check "hv1 : VPC vp-s8, l3vni 2800" vpc_create vp-s8 10.242.0.0/16 2800 +check "hv1 : subnet sn-s8s (VNI 2811)" subnet_create sn-s8s vp-s8 2811 10.242.1.1 10.242.1.0/24 +check "hv1 : VM s8-m1 10.242.1.50" vm_create s8-m1 sn-s8s 10.242.1.50 +check "hv1 : s8-m1 répond depuis son netns" netns_ping_wait vp-s8 10.242.1.50 +check "hv1 : /24 et /32 exportés par l'agent" sh -c "ip -4 route show vrf vrf-s8 | grep -q '^10.242.1.0/24 via 169.254.0.2' && ip -4 route show vrf vrf-s8 | grep -q '^10.242.1.50 via 169.254.0.2'" +NODE +on hv2 <<'NODE' +two_image || { echo "ÉCHOUÉ: image compatible two (hv2)"; exit 0; } +check "hv2 : VPC vp-s8, l3vni 2800" vpc_create vp-s8 10.242.0.0/16 2800 +check "hv2 : aucun subnet de vp-s8 au départ" sh -c "! ip link show vxlan-2811 >/dev/null 2>&1" +NODE +on hv3 <<'NODE' +two_image || { echo "ÉCHOUÉ: image compatible two (hv3)"; exit 0; } +KEY=$(vm_key) +check "hv3 : VPC vp-s8, l3vni 2800" vpc_create vp-s8 10.242.0.0/16 2800 +check "hv3 : subnet sn-s8t (VNI 2812), seulement sur hv3" subnet_create sn-s8t vp-s8 2812 10.242.2.1 10.242.2.0/24 +check "hv3 : VM observatrice s8-o 10.242.2.10" vm_create s8-o sn-s8t 10.242.2.10 "${KEY}" +check "s8-o joignable" vm_wait vp-s8 10.242.2.10 +check "hv3 : aucun VXLAN de sn-s8s sur l'observateur" sh -c "! ip link show vxlan-2811 >/dev/null 2>&1" +check "hv3 : /32 de s8-m1 via hv1 seulement" wait_vrf_nexthops vp-s8 10.242.1.50 192.168.14.11 +for i in $(seq 1 24); do vm_ssh vp-s8 10.242.2.10 'ping -c 1 -W 2 10.242.1.50' >/dev/null 2>&1 && break; sleep 5; done +check "s8-o (hv3) joint s8-m1 (hv1)" vm_ssh vp-s8 10.242.2.10 'ping -n -c 3 -W 2 10.242.1.50' +check "1472 octets en -M do" vm_ssh vp-s8 10.242.2.10 'ping -n -M do -s 1472 -c 2 -W 2 10.242.1.50' +NODE +on hv1 <<'NODE' +check "migration simple, 1 — suppression de s8-m1 sur hv1 : son /32 part en premier" vm_delete s8-m1 +check "hv1 : plus de /32 pour 10.242.1.50 dans vrf-s8" test -z "$(ip -4 route show vrf vrf-s8 10.242.1.50/32 | grep 169.254.0.2)" +NODE +on hv3 <<'NODE' +check "hv3 : plus aucun /32 pour 10.242.1.50" wait_vrf_nexthops vp-s8 10.242.1.50 "" +check "hv3 : le /24 de sn-s8s reste annoncé par hv1 (filet)" wait_vrf_nexthops vp-s8 10.242.1.0/24 192.168.14.11 +NODE +on hv2 <<'NODE' +check "migration simple, 2 — sn-s8s créé sur hv2 (même VNI 2811)" subnet_create sn-s8s vp-s8 2811 10.242.1.1 10.242.1.0/24 +check "migration simple, 3 — VM s8-m2 10.242.1.50 sur hv2" vm_create s8-m2 sn-s8s 10.242.1.50 +check "hv2 : s8-m2 répond depuis son netns" netns_ping_wait vp-s8 10.242.1.50 +NODE +on hv3 <<'NODE' +start=${SECONDS} +check "hv3 : /32 de 10.242.1.50 via hv2 seulement" wait_vrf_nexthops vp-s8 10.242.1.50 192.168.14.12 +info "hv3 : /32 de hv2 installé $(( SECONDS - start )) s après le passage en running de s8-m2" +check "hv3 : /24 de sn-s8s en ECMP vers hv1 et hv2" wait_vrf_nexthops vp-s8 10.242.1.0/24 "192.168.14.11 192.168.14.12" +for i in $(seq 1 24); do vm_ssh vp-s8 10.242.2.10 'ping -c 1 -W 2 10.242.1.50' >/dev/null 2>&1 && break; sleep 5; done +check "s8-o joint s8-m2 par son /32" vm_ssh vp-s8 10.242.2.10 'ping -n -c 3 -W 2 10.242.1.50' +info "après migration simple : $(ping_rate vp-s8 10.242.2.10 10.242.1.50 50)/50 réponses" +NODE +on hv1 <<'NODE' +info "orchestrée, 1 — sn-s8s présent sur hv1 (destination), /24 annoncé" +check "orchestrée, 2 — VM s8-m3 10.242.1.50 sur hv1 pendant que s8-m2 tourne sur hv2" vm_create s8-m3 sn-s8s 10.242.1.50 +check "hv1 : s8-m3 répond depuis son netns" netns_ping_wait vp-s8 10.242.1.50 +NODE +on rr1 <<'NODE' +check "rr1 : MAC de gateway anycast de sn-s8s (02:01:00:00:0a:fb), portée par hv1 et hv2, non annoncée en EVPN" sh -c "! vtysh -c 'show bgp l2vpn evpn route type macip' | grep -qi '02:01:00:00:0a:fb'" +NODE +on hv1 <<'NODE' +info "hv1 : MAC en double détectées sur la VNI 2811 : $(vtysh -c 'show evpn mac vni 2811 duplicate' 2>&1 | grep -ci '02:01:00' || true)" +NODE +on hv3 <<'NODE' +for i in $(seq 1 30); do [ "$(bgp_paths vp-s8 10.242.1.50/32)" = 2 ] && break; sleep 2; done +info "orchestrée : chemins BGP pour 10.242.1.50/32 : $(bgp_paths vp-s8 10.242.1.50/32) ; meilleur : $(bgp_best vp-s8 10.242.1.50/32) ; installés : $(vrf_nexthops vp-s8 10.242.1.50)" +check "orchestrée : deux /32 annoncés, hv1 et hv2" wait_vrf_nexthops vp-s8 10.242.1.50 "192.168.14.11 192.168.14.12" +check "deux /32, subnet présent des deux côtés : les 40 sources joignent 10.242.1.50, quel que soit le chemin ECMP" sh -c "[ \"\$1\" = 40/40 ]" _ "$(sources_reach vp-s8 br-s8t 10.242.2 10.242.1.50)" +NODE +on hv2 <<'NODE' +check "orchestrée, 3 — sn-s8s non supprimable sur hv2 tant que s8-m2 existe (409)" test "$(api_code DELETE subnets/sn-s8s)" = 409 +check "orchestrée, 4 — suppression de s8-m2 sur hv2 (source) : son /32 part en premier" vm_delete s8-m2 +check "orchestrée, 5 — suppression de sn-s8s sur hv2" api_delete subnets/sn-s8s +check "sn-s8s supprimé sur hv2" wait_state subnets/sn-s8s deleted +NODE +on hv3 <<'NODE' +check "hv3 : /32 de 10.242.1.50 via hv1 seulement" wait_vrf_nexthops vp-s8 10.242.1.50 192.168.14.11 +check "hv3 : /24 de sn-s8s via hv1 seulement" wait_vrf_nexthops vp-s8 10.242.1.0/24 192.168.14.11 +check "après la séquence orchestrée : s8-o joint s8-m3" vm_ssh vp-s8 10.242.2.10 'ping -n -c 3 -W 2 10.242.1.50' +check "après la séquence orchestrée : les 40 sources joignent s8-m3" sh -c "[ \"\$1\" = 40/40 ]" _ "$(sources_reach vp-s8 br-s8t 10.242.2 10.242.1.50)" +NODE +on hv1 <<'NODE' +check "ex-pire cas — suppression de sn-s8s sur hv1 refusée tant que s8-m3 existe (409)" test "$(api_code DELETE subnets/sn-s8s)" = 409 +check "ex-pire cas — sn-s8s toujours running sur hv1" test "$(api_state subnets/sn-s8s)" = running +check "ex-pire cas — /32 et /24 toujours exportés par hv1" sh -c "ip -4 route show vrf vrf-s8 | grep -q '^10.242.1.50 via 169.254.0.2' && ip -4 route show vrf vrf-s8 | grep -q '^10.242.1.0/24 via 169.254.0.2'" +NODE +on hv1 <<'NODE' +check "watchdog : /32 orphelin posé à la main dans vrf-s8" ip route replace 10.242.1.99/32 via 169.254.0.2 dev l3-s8-o vrf vrf-s8 +check "watchdog : /32 orphelin signalé comme trou noir" wait_watchdog "route 10.242.1.99/32 exported in vrf-s8 without a running owner" +check "watchdog : retrait du /32 orphelin" ip route del 10.242.1.99/32 vrf vrf-s8 +check "watchdog : /32 de s8-m3 retiré à la main" ip route del 10.242.1.50/32 vrf vrf-s8 +check "watchdog : /32 manquant signalé" wait_watchdog "route 10.242.1.50/32 not exported in vrf-s8" +check "watchdog : /32 de s8-m3 rétabli" ip route replace 10.242.1.50/32 via 169.254.0.2 dev l3-s8-o vrf vrf-s8 +check "watchdog : aucune alerte BGP ni L3VNI sur hv1" sh -c "! journalctl -u agent --since '-60s' --no-pager -o cat | grep -F 'watchdog: inconsistency detected' | grep -qE '\"kind\":\"bgp\"|l3vni [0-9]|interface (vrf|brl3|vxl3|l3)-'" +NODE +on hv3 <<'NODE' +check "après les essais du watchdog : s8-o joint s8-m3" vm_ssh vp-s8 10.242.2.10 'ping -n -c 3 -W 2 10.242.1.50' +NODE