From e474f57d2f48a2b2f191c3f823055021f183b64b Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Sun, 8 Nov 2026 11:08:35 -0300 Subject: [PATCH] test(xcat-core): a per-network iPXE script needs a host on an IPv6 network mknb writes one boot script per network under xcat/ipxe/nets, and that script is what an unknown client boots: it carries destiny=discover and no node name, so the Genesis image asks to be discovered. Every URL in it named the server with ${next-server}. DHCPv4 fills that from the siaddr of the offer, and DHCPv6 has no next-server option, so iPXE leaves it empty and the fetch has no host. The new test asks xCAT::NetworkUtils for the base of those URLs and holds down both families. Measured on xcat88-mn: the per-node script, which boots, carries http://[2001:db8:188::1]/ while the per-network script carried http://${next-server}/. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> --- xCAT-test/unit/ipxe_script_http_base.t | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 xCAT-test/unit/ipxe_script_http_base.t diff --git a/xCAT-test/unit/ipxe_script_http_base.t b/xCAT-test/unit/ipxe_script_http_base.t new file mode 100644 index 0000000000..33e316a170 --- /dev/null +++ b/xCAT-test/unit/ipxe_script_http_base.t @@ -0,0 +1,36 @@ +#!/usr/bin/perl +# Every URL in a per-network iPXE boot script needs a host. +# +# mknb writes one script per network under xcat/ipxe/nets, and that script is what an unknown +# client boots: it carries destiny=discover and no node name, so the Genesis image asks to be +# discovered. The script used ${next-server} for the server in every URL. DHCPv4 fills that from +# the siaddr of the offer; DHCPv6 has no next-server option at all, so iPXE leaves it empty and +# the fetch has no host. Measured on xcat88-mn: the per-NODE script, which boots, carries +# http://[2001:db8:188::1]/... while the per-NETWORK script carried http://${next-server}/... +use strict; +use warnings; +use Test::More tests => 7; +use FindBin; +use lib "$FindBin::Bin/../../perl-xCAT"; + +require xCAT::NetworkUtils; + +can_ok( 'xCAT::NetworkUtils', 'ipxe_script_http_base' ); + +my $v6 = xCAT::NetworkUtils::ipxe_script_http_base( '2001:db8:188::1', '[2001:db8:188::1]', '' ); +is( $v6, 'http://[2001:db8:188::1]', + 'an IPv6 network carries the address of the management node, because DHCPv6 has no next-server' ); +unlike( $v6, qr/next-server/, 'and nothing is left for iPXE to fill in' ); + +is( xCAT::NetworkUtils::ipxe_script_http_base( '192.168.88.1', '192.168.88.1', '' ), + 'http://${next-server}', + 'an IPv4 network keeps ${next-server}, which its offer fills in' ); + +is( xCAT::NetworkUtils::ipxe_script_http_base( '2001:db8:188::1', '[2001:db8:188::1]', ':8080' ), + 'http://[2001:db8:188::1]:8080', 'the port suffix is kept on an IPv6 network' ); +is( xCAT::NetworkUtils::ipxe_script_http_base( '192.168.88.1', '192.168.88.1', ':8080' ), + 'http://${next-server}:8080', 'the port suffix is kept on an IPv4 network' ); + +# A network with no address of its own must not produce a URL with a bracketed empty host. +is( xCAT::NetworkUtils::ipxe_script_http_base( undef, undef, '' ), + 'http://${next-server}', 'an unknown family falls back to the DHCPv4 form' );