mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-11-23 10:52:29 +00:00
test(xcat-core): nothing asserts the DHCPv6 reservation pair of a netboot=ipxe node
A netboot=ipxe node is two DHCPv6 clients. The firmware solicits first and takes the Microsoft-signed shim over TFTP; the iPXE it chainloads solicits again with a DUID built from the same vpd.uuid in RFC 4122 order and takes the boot script of the node over HTTP. Its sibling case makedhcp_dhcpv6_boot_intent defines its node netboot=grub2, so no case read the pair, and a cell could report green with every iPXE line of dhcp.pm broken. makedhcp_dhcpv6_ipxe_boot_intent reads the rendered kea-dhcp6.conf. It counts the reservations keyed on the two expected DUIDs, compares both entries byte for byte, asserts the two DUIDs differ, and moves the address between the clients with mac.duid to say WHICH client gets WHICH file. A grub2 arm and a return to iPXE are the discriminator: a case that cannot tell the two methods apart only measures that a reservation exists. The loader check is first. dhcp6_bootfile_url_for_node returns empty when the UEFI loader is not under the tftpdir of the node and makedhcp still exits 0, so every later assertion would pass vacuously on a management node with no ipxe-xcat. Measured against the rendered reservations of this tree: reverting dhcp6_chainloads to return 0 takes the count from 2 to 1 and leaves the first reservation and the grub2 arm passing; deleting the "if ($client eq 'ipxe')" arm of dhcp6_bootfile_url_for_node turns the second URL into the TFTP shim and leaves nine of the eleven value assertions passing. ipxe-xcat is packaged for x86_64 only, so a bundle must name this case for an x86_64 cell. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
@@ -302,6 +302,143 @@ cmd:sh -c 'makedhcp -d ci-ipv6-cn >/dev/null 2>&1; makehosts -d ci-ipv6-cn; chta
|
||||
check:rc==0
|
||||
end
|
||||
|
||||
start:makedhcp_dhcpv6_ipxe_boot_intent
|
||||
description:makedhcp reserves a netboot=ipxe node for both of its DHCPv6 clients, each with its own boot file
|
||||
label:mn_only,ipv6
|
||||
# A netboot=ipxe node is TWO DHCPv6 clients. The firmware solicits first and is given the
|
||||
# Microsoft-signed shim over TFTP; the iPXE it chainloads solicits again with a DUID built from
|
||||
# the same vpd.uuid in RFC 4122 order and is given the boot script of the node over HTTP. The
|
||||
# shim reads ipxe.efi from the directory it came from, which iPXE cannot do, so an iPXE client
|
||||
# given the shim again stops at "Failed to open ipxe.efi".
|
||||
#
|
||||
# Its sibling makedhcp_dhcpv6_boot_intent defines its node netboot=grub2, so no case asserted the
|
||||
# pair and the cell could stay green with every iPXE line of dhcp.pm broken.
|
||||
#
|
||||
# ipxe-xcat is packaged for x86_64 only, so a bundle must name this case for an x86_64 cell.
|
||||
# The first check below is what says so out loud.
|
||||
#
|
||||
# THE LOADER FIRST. dhcp6_bootfile_url_for_node returns empty when the UEFI loader is not under
|
||||
# the tftpdir of the node, and makedhcp still exits 0, so every assertion after it would pass
|
||||
# vacuously on a management node that has no ipxe-xcat.
|
||||
cmd:sh -c 'd=$(lsdef -t site -i tftpdir -c 2>/dev/null | sed -n "s/.*tftpdir=//p"); d=${d:-/tftpboot}; echo looking under "$d"; test -e "$d/xcat/ipxe/x86_64-sb/snponly-shim.efi"'
|
||||
check:rc==0
|
||||
# PRE-CLEAN, because xcattest stops a case at its first failed check and the cleanup at the end
|
||||
# would then not run. Without this a failed run leaves an address, a network and a node behind
|
||||
# and the next run measures the leftovers.
|
||||
cmd:sh -c 'makedhcp -d ci-ipxe-cn >/dev/null 2>&1; makehosts -d ci-ipxe-cn >/dev/null 2>&1; chtab -d node=ci-ipxe-cn vpd >/dev/null 2>&1; rmdef -t node ci-ipxe-cn >/dev/null 2>&1; rmdef -t network ci-ipxe >/dev/null 2>&1; ip -6 addr del 2001:db8:178::1/64 dev $$SECONDNIC >/dev/null 2>&1; true'
|
||||
check:rc==0
|
||||
# A prefix of its own, documentation-reserved (RFC 3849). The sibling cases hold 2001:db8:176::/64
|
||||
# and 2001:db8:177::/64, and two xCAT network rows on one prefix make Kea reject the whole file.
|
||||
cmd:ip -6 addr add 2001:db8:178::1/64 dev $$SECONDNIC
|
||||
check:rc==0
|
||||
cmd:mkdef -t network -o ci-ipxe net=2001:db8:178:: mask=/64 mgtifname=$$SECONDNIC dynamicrange=2001:db8:178::1000-2001:db8:178::1fff
|
||||
check:rc==0
|
||||
# The uuid is fixed, because both DUIDs below are derived from it and a generated uuid would make
|
||||
# them unknowable.
|
||||
cmd:mkdef -t node ci-ipxe-cn groups=all mgt=kvm netboot=ipxe ip=2001:db8:178::20 mac=aa:bb:cc:dd:ee:03
|
||||
check:rc==0
|
||||
cmd:chtab node=ci-ipxe-cn vpd.uuid=c78c76bf-3286-46f3-b80d-8fe079dd6de7
|
||||
check:rc==0
|
||||
cmd:makehosts ci-ipxe-cn
|
||||
check:rc==0
|
||||
# makedhcp -n first: makedhcp <node> only writes into a subnet that is already in the file, and
|
||||
# without the subnet it SKIPS the node with a warning and still exits 0.
|
||||
cmd:makedhcp -n
|
||||
check:rc==0
|
||||
cmd:makedhcp ci-ipxe-cn
|
||||
check:rc==0
|
||||
# Kea must accept its own configuration. A reservation xCAT renders and Kea rejects serves nobody.
|
||||
cmd:kea-dhcp6 -t /etc/kea/kea-dhcp6.conf
|
||||
check:rc==0
|
||||
# THE COUNT. This is the check a one-reservation regression fails: a node that solicits twice and
|
||||
# is reserved once leaves its second client unanswered.
|
||||
cmd:python3 -c 'import json;d=json.load(open("/etc/kea/kea-dhcp6.conf"));w={"00:04:bf:76:8c:c7:86:32:f3:46:b8:0d:8f:e0:79:dd:6d:e7","00:04:c7:8c:76:bf:32:86:46:f3:b8:0d:8f:e0:79:dd:6d:e7"};print("IPXE"+"_PAIR="+str(sum(1 for s in d["Dhcp6"]["subnet6"] for r in s.get("reservations",[]) if r.get("duid") in w)))'
|
||||
check:rc==0
|
||||
check:output==IPXE_PAIR=2
|
||||
# THE TWO DUIDS DIFFER. A bug that derives both from one byte order writes two IDENTICAL entries,
|
||||
# which the count above still reads as two and kea-dhcp6 -t may still accept. The set is printed
|
||||
# sorted, so it names both values and nothing else.
|
||||
cmd:python3 -c 'import json;d=json.load(open("/etc/kea/kea-dhcp6.conf"));w={"00:04:bf:76:8c:c7:86:32:f3:46:b8:0d:8f:e0:79:dd:6d:e7","00:04:c7:8c:76:bf:32:86:46:f3:b8:0d:8f:e0:79:dd:6d:e7"};print("DU"+"IDS="+" ".join(sorted({r["duid"] for s in d["Dhcp6"]["subnet6"] for r in s.get("reservations",[]) if r.get("duid") in w})))'
|
||||
check:rc==0
|
||||
check:output==DUIDS=00:04:bf:76:8c:c7:86:32:f3:46:b8:0d:8f:e0:79:dd:6d:e7 00:04:c7:8c:76:bf:32:86:46:f3:b8:0d:8f:e0:79:dd:6d:e7
|
||||
# RESERVATION ONE, byte-exact. Without a duid attribute the firmware DUID is the primary, so this
|
||||
# entry keeps the hostname and the reserved address. EDK2 stores the first three UUID fields
|
||||
# little-endian in SMBIOS and copies them into its DUID-UUID in that order, which is why these
|
||||
# octets are the uuid above with those fields reversed.
|
||||
cmd:python3 -c 'import json;d=json.load(open("/etc/kea/kea-dhcp6.conf"));f="00:04:bf:76:8c:c7:86:32:f3:46:b8:0d:8f:e0:79:dd:6d:e7";r=([x for s in d["Dhcp6"]["subnet6"] for x in s.get("reservations",[]) if x.get("duid")==f]+[{}])[0];print("FIRM"+"WARE="+r.get("hostname","")+"|"+",".join(r.get("ip-addresses",[]))+"|"+"".join(o.get("data","") for o in r.get("option-data",[]) if o.get("name")=="bootfile-url"))'
|
||||
check:rc==0
|
||||
check:output==FIRMWARE=ci-ipxe-cn|2001:db8:178::20|tftp://[2001:db8:178::1]/xcat/ipxe/x86_64-sb/snponly-shim.efi
|
||||
# RESERVATION TWO, byte-exact. It carries NO hostname and NO address: Kea refuses a second
|
||||
# reservation for one address, and a shared hostname makes upsert_reservations replace one entry
|
||||
# with the other. The iPXE client takes an address from the dynamic range and needs only its
|
||||
# boot file, which is the per-node script over HTTP.
|
||||
cmd:python3 -c 'import json;d=json.load(open("/etc/kea/kea-dhcp6.conf"));c="00:04:c7:8c:76:bf:32:86:46:f3:b8:0d:8f:e0:79:dd:6d:e7";r=([x for s in d["Dhcp6"]["subnet6"] for x in s.get("reservations",[]) if x.get("duid")==c]+[{}])[0];print("CHAIN"+"LOAD="+r.get("hostname","")+"|"+",".join(r.get("ip-addresses",[]))+"|"+"".join(o.get("data","") for o in r.get("option-data",[]) if o.get("name")=="bootfile-url"))'
|
||||
check:rc==0
|
||||
check:output==CHAINLOAD=||http://[2001:db8:178::1]/tftpboot/xcat/ipxe/nodes/ci-ipxe-cn.uefi
|
||||
# WHICH CLIENT GETS WHICH FILE. duid=canonical makes the RFC 4122 order the primary, so the
|
||||
# address moves to the client that sends it -- and that client is iPXE, because iPXE converts the
|
||||
# SMBIOS bytes to RFC 4122 order before it builds its DUID. So the canonical entry takes the
|
||||
# hostname, the address AND the HTTP script, and the firmware entry keeps the TFTP shim. The pair
|
||||
# is still two entries with the same two DUIDs.
|
||||
cmd:chdef -t node ci-ipxe-cn duid=canonical
|
||||
check:rc==0
|
||||
cmd:makedhcp ci-ipxe-cn
|
||||
check:rc==0
|
||||
cmd:kea-dhcp6 -t /etc/kea/kea-dhcp6.conf
|
||||
check:rc==0
|
||||
cmd:python3 -c 'import json;d=json.load(open("/etc/kea/kea-dhcp6.conf"));w={"00:04:bf:76:8c:c7:86:32:f3:46:b8:0d:8f:e0:79:dd:6d:e7","00:04:c7:8c:76:bf:32:86:46:f3:b8:0d:8f:e0:79:dd:6d:e7"};print("CANON"+"_PAIR="+" ".join(sorted({r["duid"] for s in d["Dhcp6"]["subnet6"] for r in s.get("reservations",[]) if r.get("duid") in w})))'
|
||||
check:rc==0
|
||||
check:output==CANON_PAIR=00:04:bf:76:8c:c7:86:32:f3:46:b8:0d:8f:e0:79:dd:6d:e7 00:04:c7:8c:76:bf:32:86:46:f3:b8:0d:8f:e0:79:dd:6d:e7
|
||||
cmd:python3 -c 'import json;d=json.load(open("/etc/kea/kea-dhcp6.conf"));c="00:04:c7:8c:76:bf:32:86:46:f3:b8:0d:8f:e0:79:dd:6d:e7";r=([x for s in d["Dhcp6"]["subnet6"] for x in s.get("reservations",[]) if x.get("duid")==c]+[{}])[0];print("CANON"+"ICAL="+r.get("hostname","")+"|"+",".join(r.get("ip-addresses",[]))+"|"+"".join(o.get("data","") for o in r.get("option-data",[]) if o.get("name")=="bootfile-url"))'
|
||||
check:rc==0
|
||||
check:output==CANONICAL=ci-ipxe-cn|2001:db8:178::20|http://[2001:db8:178::1]/tftpboot/xcat/ipxe/nodes/ci-ipxe-cn.uefi
|
||||
cmd:python3 -c 'import json;d=json.load(open("/etc/kea/kea-dhcp6.conf"));f="00:04:bf:76:8c:c7:86:32:f3:46:b8:0d:8f:e0:79:dd:6d:e7";r=([x for s in d["Dhcp6"]["subnet6"] for x in s.get("reservations",[]) if x.get("duid")==f]+[{}])[0];print("SECOND"+"ARY="+r.get("hostname","")+"|"+",".join(r.get("ip-addresses",[]))+"|"+"".join(o.get("data","") for o in r.get("option-data",[]) if o.get("name")=="bootfile-url"))'
|
||||
check:rc==0
|
||||
check:output==SECONDARY=||tftp://[2001:db8:178::1]/xcat/ipxe/x86_64-sb/snponly-shim.efi
|
||||
cmd:chdef -t node ci-ipxe-cn duid=
|
||||
check:rc==0
|
||||
cmd:makedhcp ci-ipxe-cn
|
||||
check:rc==0
|
||||
# THE GRUB2 DISCRIMINATOR. A case that cannot tell the two netboot methods apart is measuring
|
||||
# "a reservation exists". grub2 is loaded by the firmware and asks for nothing more, so a grub2
|
||||
# node is ONE client with the grub2 loader over TFTP.
|
||||
#
|
||||
# The delete runs while the node is still netboot=ipxe. The match list of a grub2 node names only
|
||||
# its first DUID, so a delete after the change would leave the chainload entry behind.
|
||||
cmd:makedhcp -d ci-ipxe-cn
|
||||
check:rc==0
|
||||
cmd:chdef -t node ci-ipxe-cn netboot=grub2
|
||||
check:rc==0
|
||||
cmd:makedhcp ci-ipxe-cn
|
||||
check:rc==0
|
||||
cmd:kea-dhcp6 -t /etc/kea/kea-dhcp6.conf
|
||||
check:rc==0
|
||||
cmd:python3 -c 'import json;d=json.load(open("/etc/kea/kea-dhcp6.conf"));w={"00:04:bf:76:8c:c7:86:32:f3:46:b8:0d:8f:e0:79:dd:6d:e7","00:04:c7:8c:76:bf:32:86:46:f3:b8:0d:8f:e0:79:dd:6d:e7"};print("GRUB2"+"_ONE="+str(sum(1 for s in d["Dhcp6"]["subnet6"] for r in s.get("reservations",[]) if r.get("duid") in w)))'
|
||||
check:rc==0
|
||||
check:output==GRUB2_ONE=1
|
||||
cmd:python3 -c 'import json;d=json.load(open("/etc/kea/kea-dhcp6.conf"));print("GRUB2"+"_URL="+"".join(o.get("data","") for s in d["Dhcp6"]["subnet6"] for r in s.get("reservations",[]) if r.get("hostname")=="ci-ipxe-cn" for o in r.get("option-data",[]) if o.get("name")=="bootfile-url"))'
|
||||
check:rc==0
|
||||
check:output==GRUB2_URL=tftp://[2001:db8:178::1]/boot/grub2/grub2-ci-ipxe-cn
|
||||
# Back to iPXE, and the pair comes back. A one-way change would leave the cell measuring grub2.
|
||||
cmd:makedhcp -d ci-ipxe-cn
|
||||
check:rc==0
|
||||
cmd:chdef -t node ci-ipxe-cn netboot=ipxe
|
||||
check:rc==0
|
||||
cmd:makedhcp ci-ipxe-cn
|
||||
check:rc==0
|
||||
cmd:python3 -c 'import json;d=json.load(open("/etc/kea/kea-dhcp6.conf"));w={"00:04:bf:76:8c:c7:86:32:f3:46:b8:0d:8f:e0:79:dd:6d:e7","00:04:c7:8c:76:bf:32:86:46:f3:b8:0d:8f:e0:79:dd:6d:e7"};print("BACK"+"_PAIR="+str(sum(1 for s in d["Dhcp6"]["subnet6"] for r in s.get("reservations",[]) if r.get("duid") in w)))'
|
||||
check:rc==0
|
||||
check:output==BACK_PAIR=2
|
||||
# NOTHING ON IPv4. An IPv6-only node gets no DHCPv4 reservation and no client class, not even a
|
||||
# DROP class, whichever netboot method it carries.
|
||||
cmd:python3 -c 'import json,os;p="/etc/kea/kea-dhcp4.conf";d=json.load(open(p)) if os.path.exists(p) else {"Dhcp4":{}};print("V4"+"_COUNT="+str(sum(1 for s in d["Dhcp4"].get("subnet4",[]) for r in s.get("reservations",[]) if r.get("hostname")=="ci-ipxe-cn")+sum(1 for c in d["Dhcp4"].get("client-classes",[]) if "ci-ipxe-cn" in c.get("name",""))))'
|
||||
check:rc==0
|
||||
check:output==V4_COUNT=0
|
||||
# Leave the management node as it was found.
|
||||
cmd:sh -c 'makedhcp -d ci-ipxe-cn >/dev/null 2>&1; makehosts -d ci-ipxe-cn; chtab -d node=ci-ipxe-cn vpd; rmdef -t node ci-ipxe-cn; rmdef -t network ci-ipxe; ip -6 addr del 2001:db8:178::1/64 dev $$SECONDNIC; true'
|
||||
check:rc==0
|
||||
end
|
||||
|
||||
start:makedhcp_dhcpv6_dual_stack_boot_server
|
||||
description:makedhcp keeps the DHCPv6 boot URL for a grub2 node whose tftpserver is IPv4
|
||||
label:mn_only,ipv6
|
||||
|
||||
Reference in New Issue
Block a user