diff --git a/standup-test-fix.zip b/standup-test-fix.zip new file mode 100644 index 0000000..7534897 --- /dev/null +++ b/standup-test-fix.zip Binary files differ diff --git a/tests/make_fixtures.py b/tests/make_fixtures.py deleted file mode 100644 index d63f2de..0000000 --- a/tests/make_fixtures.py +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/env python3 -# tests/phase-00-maas-standup/make_fixtures.py -# Emits fix/_{subnets,spaces,vlans,ipranges,fabrics}.json for the -# phase-00-maas-standup.sh behavior harness. ASCII + LF. -import json, os - -HERE = os.path.dirname(os.path.abspath(__file__)) -FIX = os.path.join(HERE, "fix") -os.makedirs(FIX, exist_ok=True) - - -def sub(cidr, sid, space, vid, fab, mtu=1500, gw=None, managed=True, dns=None): - return {"cidr": cidr, "id": sid, "space": space, - "vlan": {"vid": vid, "fabric_id": fab, "mtu": mtu}, - "gateway_ip": gw, "managed": managed, "dns_servers": dns or []} - - -def vlan(vid, vid_id, fab, space, mtu=1500): - return {"vid": vid, "id": vid_id, "fabric_id": fab, "space": space, "mtu": mtu} - - -def dump(scn, subnets, spaces, vlans, ipranges, fabrics): - for name, obj in (("subnets", subnets), ("spaces", spaces), ("vlans", vlans), - ("ipranges", ipranges), ("fabrics", fabrics)): - with open(os.path.join(FIX, f"{scn}_{name}.json"), "w") as f: - json.dump(obj, f, indent=2) - f.write("\n") - - -def spaces_list(names): - return [{"name": n, "id": i + 1} for i, n in enumerate(names)] - - -def fabrics_list(pairs): # [(name,id)] - return [{"name": n, "id": i} for n, i in pairs] - - -# ---- FRESH: nothing exists -> full create plan ---- -dump("fresh", [], [], [], [], []) - -# ---- DONE: D-058 fully present + correct -> all SKIP, zero WOULD ---- -fabs = fabrics_list([("provider", 1), ("metal", 2), ("data", 3), ("storage", 4), ("replication", 5)]) -vl = [ - vlan(0, 10, 1, "provider-public"), vlan(104, 11, 1, "provider-vip"), - vlan(0, 20, 2, "metal-admin"), vlan(103, 21, 2, "metal-internal", mtu=9000), - vlan(0, 30, 3, "data-tenant"), vlan(0, 40, 4, "storage"), vlan(0, 50, 5, "replication"), -] -subs = [ - sub("10.12.4.0/22", 1, "provider-public", 0, 1, gw="10.12.4.1"), - sub("10.12.8.0/22", 2, "provider-vip", 104, 1, gw="10.12.8.1"), # dns mirrors metal-internal (which is unset) -> left unset - sub("10.12.12.0/22", 3, "metal-admin", 0, 2, gw="10.12.12.1"), - sub("10.12.16.0/22", 4, "metal-internal", 103, 2, mtu=9000), - sub("10.12.20.0/22", 5, "data-tenant", 0, 3), - sub("10.12.32.0/22", 6, "storage", 0, 4), - sub("10.12.36.0/22", 7, "replication", 0, 5), -] -spc = spaces_list(["provider-public", "provider-vip", "metal-admin", "metal-internal", - "data-tenant", "storage", "replication"]) -ipr = [{"type": "reserved", "start_ip": lo, "end_ip": hi, "subnet": {"id": sid}} - for lo, hi, sid in [("10.12.5.0", "10.12.7.254", 1), # FIP pool (provider-public) - ("10.12.4.101", "10.12.4.110", 1), # provider-public mgmt - ("10.12.8.2", "10.12.8.100", 2), # provider-vip API VIP - ("10.12.12.2", "10.12.12.100", 3), # metal-admin API VIP - ("10.12.12.101", "10.12.12.110", 3), # metal-admin mgmt - ("10.12.16.2", "10.12.16.100", 4)]] # metal-internal API VIP -dump("done", subs, spc, vl, ipr, fabs) - -# ---- D-052 CURRENT (old live scheme): the three migrating planes drift ---- -fabs_c = fabrics_list([("1_provider", 1), ("2_metal", 2), ("4_data", 3), - ("8_storage", 4), ("9_replication", 5)]) -vl_c = [ - vlan(0, 10, 1, "provider-public"), - vlan(0, 20, 2, "metal-admin"), vlan(103, 21, 2, "metal-internal", mtu=9000), - vlan(0, 30, 3, "data-tenant"), vlan(0, 40, 4, "storage"), vlan(0, 50, 5, "replication"), -] -subs_c = [ - sub("10.12.4.0/22", 1, "provider-public", 0, 1, gw="10.12.4.1"), # correct under D-058 -> SKIP - sub("10.12.8.0/22", 2, "metal-admin", 0, 2, gw="10.12.8.1"), # D-058 wants provider-vip -> DRIFT - sub("10.12.12.0/22", 3, "metal-internal", 103, 2, mtu=9000), # D-058 wants metal-admin -> DRIFT - sub("10.12.16.0/22", 4, "data-tenant", 0, 3), # D-058 wants metal-internal -> DRIFT - sub("10.12.32.0/22", 6, "storage", 0, 4), # correct -> SKIP - sub("10.12.36.0/22", 7, "replication", 0, 5), # correct -> SKIP -] -spc_c = spaces_list(["provider-public", "metal-admin", "metal-internal", - "data-tenant", "storage", "replication"]) -dump("d052", subs_c, spc_c, vl_c, [], fabs_c) - -# ---- WRONG-VID: provider-vip subnet present at .8 but on VID 99 ---- -vl_w = [v for v in vl if v["vid"] != 104] + [vlan(99, 11, 1, "provider-vip")] -subs_w = [s for s in subs if s["cidr"] != "10.12.8.0/22"] + \ - [sub("10.12.8.0/22", 2, "provider-vip", 99, 1, gw="10.12.8.1")] -dump("wrongvid", subs_w, spc, vl_w, ipr, fabs) - -print("fixtures written to", FIX) diff --git a/tests/phase-00-maas-standup/make_fixtures.py b/tests/phase-00-maas-standup/make_fixtures.py index 8d023cc..d63f2de 100644 --- a/tests/phase-00-maas-standup/make_fixtures.py +++ b/tests/phase-00-maas-standup/make_fixtures.py @@ -57,9 +57,12 @@ spc = spaces_list(["provider-public", "provider-vip", "metal-admin", "metal-internal", "data-tenant", "storage", "replication"]) ipr = [{"type": "reserved", "start_ip": lo, "end_ip": hi, "subnet": {"id": sid}} - for lo, hi, sid in [("10.12.8.2", "10.12.8.100", 2), - ("10.12.12.2", "10.12.12.100", 3), - ("10.12.16.2", "10.12.16.100", 4)]] + for lo, hi, sid in [("10.12.5.0", "10.12.7.254", 1), # FIP pool (provider-public) + ("10.12.4.101", "10.12.4.110", 1), # provider-public mgmt + ("10.12.8.2", "10.12.8.100", 2), # provider-vip API VIP + ("10.12.12.2", "10.12.12.100", 3), # metal-admin API VIP + ("10.12.12.101", "10.12.12.110", 3), # metal-admin mgmt + ("10.12.16.2", "10.12.16.100", 4)]] # metal-internal API VIP dump("done", subs, spc, vl, ipr, fabs) # ---- D-052 CURRENT (old live scheme): the three migrating planes drift ---- diff --git a/tests/phase-00-maas-standup/run-tests.sh b/tests/phase-00-maas-standup/run-tests.sh index ea50f45..60ec8d9 100644 --- a/tests/phase-00-maas-standup/run-tests.sh +++ b/tests/phase-00-maas-standup/run-tests.sh @@ -39,7 +39,9 @@ has 'WOULD: create subnet 10\.12\.12\.0/22' has 'WOULD: create subnet 10\.12\.20\.0/22' has 'WOULD: subnet 10\.12\.8\.0/22 -> gateway_ip=10\.12\.8\.1' -has 'WOULD: create reserved API-VIP band 10\.12\.16\.2-10\.12\.16\.100' +has 'WOULD: create reserved range 10\.12\.5\.0-10\.12\.7\.254' # FIP pool (consolidated from carve) +has 'WOULD: create reserved range 10\.12\.4\.101-10\.12\.4\.110' # provider-public mgmt +has 'WOULD: create reserved range 10\.12\.16\.2-10\.12\.16\.100' # metal-internal API VIP absent 'DRIFT' run 0 "D-058 done: all SKIP, zero WOULD" done @@ -50,6 +52,7 @@ has 'subnet 10\.12\.16\.0/22 exists -- SKIP' has 'gateway_ip already 10\.12\.12\.1 -- SKIP' has 'reserved range starting 10\.12\.8\.2 exists -- SKIP' +has 'reserved range starting 10\.12\.5\.0 exists -- SKIP' # FIP pool now SKIPs in DONE has 'OK \(dryrun\) -- topology consistent with D-058' run 1 "D-052 current: 3 migrating planes drift + refuse" d052 diff --git a/tests/run-tests.sh b/tests/run-tests.sh deleted file mode 100644 index dead104..0000000 --- a/tests/run-tests.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env bash -# Behavior regression for phase-00-maas-recidr.sh (D-052/053 -> D-058). Fake maas + real jq. -set -uo pipefail -HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -SCRIPT="$(cd "$HERE/../../scripts" && pwd)/phase-00-maas-recidr.sh" -BIN="$HERE/fakebin"; FIX="$HERE/fix" -chmod +x "$BIN"/* 2>/dev/null || true -command -v jq >/dev/null || { echo "FAIL: jq required"; exit 1; } -python3 "$HERE/make_fixtures.py" >/dev/null -rc_all=0; OUT="$(mktemp)" -run() { # want label scenario [--apply] - local want="$1" label="$2" s="$3"; shift 3 - PATH="$BIN:$PATH" FIX_SUBNETS="$FIX/${s}_subnets.json" FIX_VLANS="$FIX/${s}_vlans.json" \ - FIX_IPRANGES="$FIX/${s}_ipranges.json" FIX_IPADDRS="$FIX/${s}_ipaddrs.json" \ - bash "$SCRIPT" "$@" >"$OUT" 2>&1 - local rc=$? - if [ "$rc" -ne "$want" ]; then printf ' [XX] %-44s exit %s (want %s)\n' "$label" "$rc" "$want"; sed 's/^/ /' "$OUT"; rc_all=1; return 1; fi - printf ' [ok] %-44s exit %s\n' "$label" "$rc"; return 0 -} -has() { grep -qE "$1" "$OUT" || { printf ' MISS /%s/\n' "$1"; rc_all=1; }; } -absent(){ grep -qE "$1" "$OUT" && { printf ' LEAK /%s/\n' "$1"; rc_all=1; } || true; } -before(){ local x y; x=$(grep -nE "$1" "$OUT"|head -1|cut -d: -f1); y=$(grep -nE "$2" "$OUT"|head -1|cut -d: -f1); { [ -n "$x" ] && [ -n "$y" ] && [ "$x" -lt "$y" ]; } || { printf ' ORDER /%s/ not before /%s/\n' "$1" "$2"; rc_all=1; }; } - -echo "=== phase-00-maas-recidr.sh -- D-052/053 -> D-058 (fake maas + real jq) ===" -run 0 "pre-migration (d052): dry-run plan" d052 -has 'metal-admin: 10\.12\.8\.0/22 .*fabric 2, vid 0. -> 10\.12\.12\.0/22' -has 'metal-internal: 10\.12\.12\.0/22 .*vid 103. -> 10\.12\.16\.0/22' -has 'data-tenant: 10\.12\.16\.0/22 .*fabric 3.*-> 10\.12\.20\.0/22' -has 'metal fabric .* = 2' -has 'data fabric .* = 3' -has 'reserved range ids to delete first: 100' -has 're-run with --apply' -absent 'DO:' - -run 0 "pre-migration (d052): --apply, deletes BEFORE creates" d052 --apply -has 'DO: delete iprange 100' -has 'DO: delete subnet id=2' -has 'DO: create subnet 10\.12\.12\.0/22 on fabric 2 vid 0' -has 'DO: create subnet 10\.12\.16\.0/22 on fabric 2 vid 103' -has 'DO: create subnet 10\.12\.20\.0/22 on fabric 3 vid 0' -before 'MUTATE 1/2' 'MUTATE 2/2' -before 'DO: delete subnet id=4' 'DO: create subnet 10\.12\.12' - -run 0 "migrated (done): nothing to migrate" done -has 'already migrated or not this plane; SKIP' -has 'nothing to migrate' -absent 'DO:' -absent 'WOULD:' - -run 1 "wrong VID at old .12 -> refuse" wrongvid -has "subnet 10\.12\.12\.0/22 on VID '99', expected 103 -- refusing" - -echo -[ "$rc_all" -eq 0 ] && echo "ALL PASS" || echo "SOME FAILED" -rm -f "$OUT"; exit "$rc_all"