mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-11-22 10:22:18 +00:00
test(xcat-core): cover the dual-stack DHCPv6 boot server on a management node
makedhcp_dhcpv6_boot_intent declares a node with no tftpserver, so it measures only the <xcatmaster> path. A dual-stack node keeps an IPv4 tftpserver, and that is the path on which makedhcp exited 1 and dropped the boot URL. makedhcp_dhcpv6_dual_stack_boot_server declares a grub2 node with an IPv6 address and an IPv4 tftpserver, then asserts that makedhcp exits 0, that Kea accepts the configuration, and that the bootfile-url names the IPv6 address of the management node facing the node. Both values are compared exactly, so a dropped option and a wrong authority each fail. The test addresses move to the documentation ranges at the same time. The three networkutils tests carried a link-local address read off a lab NIC, and dhcp_kea_plugin_intent.t carried two addresses from the management network. They are fixtures that nothing dials, so this only keeps the internal topology out of the upstream tree. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
@@ -301,3 +301,43 @@ check:output==0
|
||||
cmd:sh -c 'makedhcp -d ci-ipv6-cn >/dev/null 2>&1; makehosts -d ci-ipv6-cn; chtab -d node=ci-ipv6-cn vpd; rmdef -t node ci-ipv6-cn; rmdef -t network ci-ipv6; ip -6 addr del 2001:db8:176::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
|
||||
# PRE-CLEAN, for the same reason as makedhcp_dhcpv6_boot_intent: a case stops at its first failed
|
||||
# check, so the cleanup at the end does not run and the next run measures the leftovers.
|
||||
cmd:sh -c 'makedhcp -d ci-ipv6-ds >/dev/null 2>&1; makehosts -d ci-ipv6-ds >/dev/null 2>&1; rmdef -t node ci-ipv6-ds >/dev/null 2>&1; rmdef -t network ci-ipv6ds >/dev/null 2>&1; ip -6 addr del 2001:db8:177::1/64 dev $$SECONDNIC >/dev/null 2>&1; true'
|
||||
check:rc==0
|
||||
# A second documentation prefix (RFC 3849), so this case cannot read the address the IPv6-only
|
||||
# case adds. The node IP below shares this /64 and no other.
|
||||
cmd:ip -6 addr add 2001:db8:177::1/64 dev $$SECONDNIC
|
||||
check:rc==0
|
||||
cmd:mkdef -t network -o ci-ipv6ds net=2001:db8:177:: mask=/64 mgtifname=$$SECONDNIC dynamicrange=2001:db8:177::1000-2001:db8:177::1fff
|
||||
check:rc==0
|
||||
# A dual-stack node keeps an IPv4 tftpserver. The address is TEST-NET-1, so it has no IPv6 form
|
||||
# and nothing resolves it off this host.
|
||||
cmd:mkdef -t node ci-ipv6-ds groups=all mgt=kvm netboot=grub2 ip=2001:db8:177::20 mac=aa:bb:cc:dd:ee:02 tftpserver=192.0.2.10
|
||||
check:rc==0
|
||||
cmd:makehosts ci-ipv6-ds
|
||||
check:rc==0
|
||||
# makedhcp MUST SUCCEED. It resolved the tftpserver as IPv6, got no answer, and reported an error
|
||||
# with errorcode 1, so the whole command exited 1 for a node that boots over IPv4.
|
||||
cmd:makedhcp ci-ipv6-ds
|
||||
check:rc==0
|
||||
cmd:kea-dhcp6 -t /etc/kea/kea-dhcp6.conf
|
||||
check:rc==0
|
||||
# The boot URL survives, and its authority is the address of this management node that faces the
|
||||
# node, which is what <xcatmaster> already resolved to. Compared EXACTLY: an IPv4 tftpserver that
|
||||
# reached the URL, or a dropped option, both differ from this string.
|
||||
cmd:python3 -c 'import json;d=json.load(open("/etc/kea/kea-dhcp6.conf"));print("".join(o.get("data","") for s in d["Dhcp6"]["subnet6"] for r in s.get("reservations",[]) if r.get("hostname")=="ci-ipv6-ds" for o in r.get("option-data",[]) if o.get("name")=="bootfile-url"))'
|
||||
check:rc==0
|
||||
check:output==tftp://[2001:db8:177::1]/boot/grub2/grub2-ci-ipv6-ds
|
||||
# The reservation still identifies the client. Without a uuid or a duid attribute that is the MAC.
|
||||
cmd:python3 -c 'import json;d=json.load(open("/etc/kea/kea-dhcp6.conf"));print("".join(r.get("hw-address","") for s in d["Dhcp6"]["subnet6"] for r in s.get("reservations",[]) if r.get("hostname")=="ci-ipv6-ds"))'
|
||||
check:rc==0
|
||||
check:output==aa:bb:cc:dd:ee:02
|
||||
# Leave the management node as it was found.
|
||||
cmd:sh -c 'makedhcp -d ci-ipv6-ds >/dev/null 2>&1; makehosts -d ci-ipv6-ds; rmdef -t node ci-ipv6-ds; rmdef -t network ci-ipv6ds; ip -6 addr del 2001:db8:177::1/64 dev $$SECONDNIC; true'
|
||||
check:rc==0
|
||||
end
|
||||
|
||||
@@ -37,12 +37,12 @@ is($server, 'fd00::2', 'with no configured server the facing address is used');
|
||||
# Nothing resolves. The caller keeps the reservation, so this is a warning and not an error.
|
||||
($server, $warning) = choose(
|
||||
configured => '192.0.2.10',
|
||||
reason => 'the xcat76-cn can not be resolved as IPv6',
|
||||
reason => 'the node1 can not be resolved as IPv6',
|
||||
);
|
||||
is($server, undef, 'an unresolvable server yields no boot server');
|
||||
like($warning, qr/\Q192.0.2.10\E/,
|
||||
'the warning names the configured server that did not resolve');
|
||||
like($warning, qr/\Qthe xcat76-cn can not be resolved as IPv6\E/,
|
||||
like($warning, qr/\Qthe node1 can not be resolved as IPv6\E/,
|
||||
'the warning carries the resolution reason');
|
||||
|
||||
# With no configured server there is nothing to name, so the reason stands alone.
|
||||
|
||||
@@ -1034,7 +1034,7 @@ foreach my $case (@sysconfig_policy_cases) {
|
||||
package main;
|
||||
|
||||
my %res_tables = (
|
||||
noderes => DHCPKeaResTable->new( { 'svc01' => { netboot => 'xnba', servicenode => '192.168.201.20', tftpserver => '<xcatmaster>' } } ),
|
||||
noderes => DHCPKeaResTable->new( { 'svc01' => { netboot => 'xnba', servicenode => '192.0.2.20', tftpserver => '<xcatmaster>' } } ),
|
||||
chain => DHCPKeaResTable->new( { 'svc01' => {} } ),
|
||||
nodetype => DHCPKeaResTable->new( { 'svc01' => { arch => 'x86_64', provmethod => 'install', os => 'rhels9' } } ),
|
||||
iscsi => DHCPKeaResTable->new( {} ),
|
||||
@@ -1049,13 +1049,13 @@ foreach my $case (@sysconfig_policy_cases) {
|
||||
my $svc_getipaddr = sub {
|
||||
my ( $host, %opt ) = @_;
|
||||
return if $opt{OnlyV6};
|
||||
return '192.168.201.21';
|
||||
return '192.0.2.21';
|
||||
};
|
||||
local *xCAT::NetworkUtils::getipaddr = $svc_getipaddr;
|
||||
# dhcp.pm imports getipaddr into its own namespace at use-time, so override
|
||||
# the imported copy as well.
|
||||
local *xCAT_plugin::dhcp::getipaddr = $svc_getipaddr;
|
||||
local *xCAT::NetworkUtils::my_ip_facing = sub { return ( 0, '192.168.201.20' ); };
|
||||
local *xCAT::NetworkUtils::my_ip_facing = sub { return ( 0, '192.0.2.20' ); };
|
||||
local *xCAT_plugin::dhcp::ipIsDynamic = sub { return 0; };
|
||||
|
||||
my @errors;
|
||||
@@ -1075,7 +1075,7 @@ foreach my $case (@sysconfig_policy_cases) {
|
||||
is( scalar(@errors), 0, 'service node reservation builds without errors' );
|
||||
is( scalar( @{ $reservations || [] } ), 1, 'service node yields exactly one Kea host reservation' );
|
||||
my $r = $reservations->[0] || {};
|
||||
is( $r->{'ip-address'}, '192.168.201.21', 'service node reservation carries the node IP' );
|
||||
is( $r->{'ip-address'}, '192.0.2.21', 'service node reservation carries the node IP' );
|
||||
is( $r->{'hw-address'}, '42:d7:c0:a8:c9:15', 'service node reservation carries the node MAC' );
|
||||
# S-74. The reservation names the node in two places and both are needed.
|
||||
# The "hostname" field is the only name a client cannot displace: with the
|
||||
@@ -2591,7 +2591,7 @@ for my $case (['80', ''], ['080', ':080'], ['8080', ':8080']) {
|
||||
# skips an IPv6-only node, so the node still reached the IPv4 resolver. With noderes.xcatmaster
|
||||
# naming a host that has only an AAAA record, inet_aton fails, the sub reports "Unable to resolve
|
||||
# the tftpserver" with errorcode 1, and makedhcp exits 1 on a node whose DHCPv6 reservation and
|
||||
# bootfile-url it had just written correctly -- measured on xcat76-cn, 2026-10-23.
|
||||
# bootfile-url it had just written correctly, which a run reproduced.
|
||||
#
|
||||
# 6f171a22b made the same call lazy in kea_node_reservations and missed this site. The assertion
|
||||
# is on the CALL, not on the exit code, because the error is what the exit code is made of.
|
||||
|
||||
@@ -60,12 +60,12 @@ sub resolve {
|
||||
return xCAT::NetworkUtils->getipaddr( 'mn.example.com', @extra );
|
||||
}
|
||||
|
||||
is( resolve( [ 'fe80::4054:ff:fec9:9ad2', '2001:db8::50' ] ),
|
||||
is( resolve( [ 'fe80::5054:ff:fe12:3456', '2001:db8::50' ] ),
|
||||
'2001:db8::50',
|
||||
'getipaddr answers the routable address when the resolver lists link-local first'
|
||||
);
|
||||
|
||||
is( resolve( [ 'fe80::4054:ff:fec9:9ad2', '192.0.2.154' ] ),
|
||||
is( resolve( [ 'fe80::5054:ff:fe12:3456', '192.0.2.154' ] ),
|
||||
'192.0.2.154',
|
||||
'getipaddr answers the IPv4 address when the resolver lists link-local first'
|
||||
);
|
||||
@@ -91,7 +91,7 @@ is_deeply(
|
||||
'GetAllAddresses lists every routable address before the link-local one'
|
||||
);
|
||||
|
||||
is( resolve( [ 'fe80::4054:ff:fec9:9ad2', '2001:db8::50' ], OnlyV6 => 1 ),
|
||||
is( resolve( [ 'fe80::5054:ff:fe12:3456', '2001:db8::50' ], OnlyV6 => 1 ),
|
||||
'2001:db8::50',
|
||||
'an OnlyV6 lookup answers the routable IPv6 address, not the link-local one'
|
||||
);
|
||||
|
||||
@@ -63,12 +63,12 @@ sub resolve {
|
||||
return xCAT::NetworkUtils->getipaddr( 'mn.example.com', @extra );
|
||||
}
|
||||
|
||||
is( resolve( [ 'fe80::4054:ff:fec9:9ad2', '2001:db8::50' ] ),
|
||||
is( resolve( [ 'fe80::5054:ff:fe12:3456', '2001:db8::50' ] ),
|
||||
'2001:db8::50',
|
||||
'getipaddr answers the routable address when the resolver lists link-local first'
|
||||
);
|
||||
|
||||
is( resolve( [ 'fe80::4054:ff:fec9:9ad2', '192.0.2.154' ] ),
|
||||
is( resolve( [ 'fe80::5054:ff:fe12:3456', '192.0.2.154' ] ),
|
||||
'192.0.2.154',
|
||||
'getipaddr answers the IPv4 address when the resolver lists link-local first'
|
||||
);
|
||||
@@ -94,7 +94,7 @@ is_deeply(
|
||||
'GetAllAddresses lists every routable address before the link-local one'
|
||||
);
|
||||
|
||||
is( resolve( [ 'fe80::4054:ff:fec9:9ad2', '2001:db8::50' ], OnlyV6 => 1 ),
|
||||
is( resolve( [ 'fe80::5054:ff:fe12:3456', '2001:db8::50' ], OnlyV6 => 1 ),
|
||||
'2001:db8::50',
|
||||
'an OnlyV6 lookup answers the routable IPv6 address, not the link-local one'
|
||||
);
|
||||
|
||||
@@ -16,16 +16,16 @@ use xCAT::NetworkUtils;
|
||||
|
||||
my @cases = (
|
||||
[ 'a global IPv6 address outranks a link-local one',
|
||||
[ 'fe80::4054:ff:fec9:9ad2', '2001:db8::50' ],
|
||||
[ 'fe80::5054:ff:fe12:3456', '2001:db8::50' ],
|
||||
'2001:db8::50',
|
||||
],
|
||||
[ 'an IPv4 address outranks a link-local IPv6 address',
|
||||
[ 'fe80::4054:ff:fec9:9ad2', '192.0.2.154' ],
|
||||
[ 'fe80::5054:ff:fe12:3456', '192.0.2.154' ],
|
||||
'192.0.2.154',
|
||||
],
|
||||
[ 'the zone identifier is removed from the address that is returned',
|
||||
[ 'fe80::4054:ff:fec9:9ad2%mgmt0' ],
|
||||
'fe80::4054:ff:fec9:9ad2',
|
||||
[ 'fe80::5054:ff:fe12:3456%mgmt0' ],
|
||||
'fe80::5054:ff:fe12:3456',
|
||||
],
|
||||
[ 'a link-local address is still returned when it is the only one',
|
||||
[ 'fe80::1%eth0' ],
|
||||
@@ -69,7 +69,7 @@ is_deeply( [ xCAT::NetworkUtils->prefer_routable_addresses() ],
|
||||
local *Socket6::NI_NUMERICHOST = sub { 1 };
|
||||
local *Socket6::getnameinfo = sub {
|
||||
my %address_of = (
|
||||
PACKED_LINKLOCAL => 'fe80::4054:ff:fec9:9ad2',
|
||||
PACKED_LINKLOCAL => 'fe80::5054:ff:fe12:3456',
|
||||
PACKED_GLOBAL => '2001:db8::50',
|
||||
PACKED_V4 => '192.0.2.154',
|
||||
PACKED_BROKEN => undef,
|
||||
|
||||
Reference in New Issue
Block a user