f-42: e2e: 46-passerelle-nat, nettoyage des passerelles par le harnais #42

Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
GnomeZworc 2026-10-29 20:32:13 +01:00
commit 2a5ea40cdc
Signed by: nicolas.boufideline
GPG key ID: 4406BBBF8845D632
4 changed files with 166 additions and 11 deletions

View file

@ -2,7 +2,7 @@ STATE_DIR=/var/tmp/e2e
SCRATCH_DIR=/tmp
owned () {
grep -E "^(vp-|sn-)?t${T}"
grep -E "^(vp-|sn-|ng-)?t${T}"
}
api_names () {
@ -39,11 +39,11 @@ clean_scratch () {
}
teardown_owned () {
delete_owned vms && delete_owned subnets && delete_owned vpcs || return 1
delete_owned vms && delete_owned subnets && delete_owned nat-gateways && delete_owned vpcs || return 1
rm -f "${VOLUMES}/t${T}"-*
clean_scratch || return 1
local left="" kind names
for kind in vms subnets vpcs; do
for kind in vms subnets nat-gateways vpcs; do
names=$(api_names "${kind}") || return 1
left="${left}$(owned <<<"${names}" | sed "s|^|${kind}/|" | tr '\n' ' ')"
done
@ -67,7 +67,7 @@ host_state () {
prepare_test () {
mkdir -p "${STATE_DIR}"
curl -fsS -o /dev/null "${API}/vpcs" || echo "ÉCHOUÉ: ${HOST} : API de l'agent injoignable avant le test"
if [ -n "$(for kind in vms subnets vpcs; do api_names "${kind}" | owned; done)$(scratch_netns)$(scratch_files)" ]; then
if [ -n "$(for kind in vms subnets nat-gateways vpcs; do api_names "${kind}" | owned; done)$(scratch_netns)$(scratch_files)" ]; then
info "${HOST} : ressources, netns ou fichiers t${T} d'un passage précédent, suppression"
check "${HOST} : nettoyage des ressources t${T} restantes" teardown_owned
fi

View file

@ -126,6 +126,8 @@ def match(kind, a, f):
return t == b'\x08\x06' and f[20:22] == b'\x00\x01' and f[38:42] == ipb(a[0])
if kind == 'arp-from':
return t == b'\x08\x06' and f[28:32] == ipb(a[0])
if kind == 'icmp-from':
return t == b'\x08\x00' and f[23] == 1 and f[26:30] == ipb(a[0])
if kind == 'udp-from':
return t == b'\x08\x00' and f[23] == 17 and f[26:30] == ipb(a[0]) and struct.unpack('!H', f[34:36])[0] == int(a[1])
if kind == 'marker':