2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-11-20 17:32:15 +00:00
Files
xcat-core/xCAT-test/unit/dhcp6_boot_server.t
T
Daniel Hilst 4509c4bb5d fix(xcat-core): the ISC path got no IPv6 reverse zone, and the Kea test passed under JSON::PP
getzonesfornet in dhcp.pm rounded the prefix itself and passed the rounded value beside a
network that still carried its own. getIPv6PrefixLength prefers the embedded prefix, so the
rounded value was ignored and no reverse zone was written at all: dhcpd updated no PTR record
for a /62 or /126 network and reported nothing. The ddns.pm copy stripped the prefix first and
was unaffected, so the previous commit's claim that both copies were fixed was wrong.

The zones now come from xCAT::NetworkUtils::getIPv6ReverseZones, which both copies call. A
network whose prefix is not a multiple of 4 is covered by the zones of the next nibble -- a /62
by its four /64 zones -- which is what the IPv4 arm does with a /22. Rounding down to the /60
made xCAT answer for three networks it does not own.

kea_subnet_id_numeric.t only observes the encoding under the XS backend, and passed 6 of 6
under JSON::PP with the bug in place. It skips unless JSON->backend is the XS one, and the
workflow installs libjson-xs-perl so the backend is there.

dhcp6_boot_server now reports a substituted boot server, so an unresolvable tftpserver is not
silent, and the caller reports a warning that arrives with a server. The routine also moved
below grub2_node_loader, whose comment it had separated from it.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-27 11:38:48 -03:00

64 lines
2.6 KiB
Perl

#!/usr/bin/env perl
# The IPv6 boot server a grub2 node gets, and what makedhcp reports when there is none.
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/../../perl-xCAT";
use Test::More tests => 13;
use xCAT::DHCP::BootPolicy;
sub choose { return xCAT::DHCP::BootPolicy->dhcp6_boot_server(@_); }
# A tftpserver that resolves over IPv6 is used as it stands.
my ($server, $warning) = choose(
configured => 'mn.cluster',
configured_v6 => 'fd00::1',
facing_v6 => 'fd00::2',
);
is($server, 'fd00::1', 'the resolved tftpserver is the boot server');
is($warning, undef, 'a resolved tftpserver raises no warning');
# A dual-stack node keeps an IPv4 tftpserver. It has no IPv6 address, so the management node
# address facing the node is used instead of failing makedhcp.
($server, $warning) = choose(
configured => '192.0.2.10',
configured_v6 => undef,
facing_v6 => 'fd00::2',
);
is($server, 'fd00::2', 'an IPv4 tftpserver falls back to the facing address');
like($warning, qr/\Q192.0.2.10\E/,
'and the fallback is reported, so a typo or a DNS outage is not silent');
like($warning, qr/\Qfd00::2\E/, 'naming the address that was used instead');
# <xcatmaster>, or no tftpserver at all.
($server, $warning) = choose(facing_v6 => 'fd00::2');
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 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 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.
($server, $warning) = choose(reason => 'node IPv6 address is in an undefined subnet');
is($server, undef, 'no configured server and no facing address yields none');
is($warning, 'node IPv6 address is in an undefined subnet',
'the warning is the reason alone when no server was configured');
# my_ip_facing_family can return an empty list, which leaves no reason to report.
($server, $warning) = choose();
is($warning, 'no IPv6-facing address was found',
'a missing reason falls back to a stated default');
# An empty tftpserver is not a configured server.
(undef, $warning) = choose(configured => '', reason => 'no route');
is($warning, 'no route', 'an empty configured server is not named in the warning');