From 7fd7ee7d9261032f5d7ab1e71cc12ac8c96df49e Mon Sep 17 00:00:00 2001
From: Daniel Hilst <392820+dhilst@users.noreply.github.com>
Date: Thu, 29 Oct 2026 09:58:17 -0300
Subject: [PATCH] test(template): an IPv6-only node is given an IPv4 resolver
it cannot reach
site.nameservers holds one list for the whole cluster, so an IPv6-only node takes the
IPv4 resolver of an IPv4 network when its own network names none. The AutoYaST profile
of a Leap 15.6 node carried 192.168.156.1 while the node had
no IPv4 address at all.
An unreachable server in resolv.conf is not a failure the node reports. Every lookup
waits for its timeout before the next server is tried.
The test adds a node whose configured resolvers are IPv4 only and asserts the section
carries none of them, and that the gateway stands in.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
---
xCAT-test/unit/autoyast_ipv6_network.t | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/xCAT-test/unit/autoyast_ipv6_network.t b/xCAT-test/unit/autoyast_ipv6_network.t
index b718cc04fa..6796d2ef30 100644
--- a/xCAT-test/unit/autoyast_ipv6_network.t
+++ b/xCAT-test/unit/autoyast_ipv6_network.t
@@ -12,7 +12,7 @@ no warnings 'once';
use File::Spec;
use FindBin;
-use Test::More tests => 14;
+use Test::More tests => 16;
my $repo_root = File::Spec->catdir($FindBin::Bin, '..', '..');
$ENV{XCATROOT} = File::Spec->catdir($repo_root, 'xCAT-server');
@@ -27,12 +27,18 @@ my %cfg = (
cn6nogw => [ '2001:db8:2::50', 'cn6nogw', '', 64 ],
cn6bad => [ undef, undef, undef, undef ],
cn6long => [ '2001:db8:3::50', 'cn6long', '2001:db8:3::fe', 129 ],
+ cn6v4ns => [ '2001:db8:4::50', 'cn6v4ns', '2001:db8:4::fe', 64 ],
);
no warnings 'redefine';
*xCAT::NetworkUtils::getNodeNetworkCfg6 = sub { my $n = $_[-1]; return @{ $cfg{$n} || [] } };
*xCAT::NetworkUtils::ipv6_server_for_node = sub { return $_[-1] };
*xCAT::NetworkUtils::getNodeDomains = sub { return { map { $_ => 'xcat.lab' } @{ $_[-1] } } };
-*xCAT::NetworkUtils::getNodeNameservers = sub { return { map { $_ => '2001:db8:1::fe' } @{ $_[-1] } } };
+# site.nameservers holds one list for the cluster, so an IPv6-only node can be given the
+# IPv4 resolver of an IPv4 network.
+my %resolvers = ( cn6v4ns => '192.0.2.53,198.51.100.53' );
+*xCAT::NetworkUtils::getNodeNameservers = sub {
+ return { map { $_ => ( $resolvers{$_} // '2001:db8:1::fe' ) } @{ $_[-1] } };
+};
use warnings 'redefine';
my $template = File::Spec->catfile($repo_root, 'xCAT-server/lib/perl/xCAT/Template.pm');
@@ -47,6 +53,14 @@ unlike($xml, qr{(?!-)}, 'no IPv4 netmask is emitted for the interface')
like($xml, qr{\Q2001:db8:1::fe\E}, 'the default route carries the IPv6 gateway');
like($xml, qr{\Q2001:db8:1::fe\E}, 'and the resolver is the IPv6 one');
+# An IPv4 resolver cannot be reached from an IPv6-only node, and an unreachable server in
+# resolv.conf makes every lookup wait for its timeout before the next one is tried.
+my $v4ns = xCAT::Template::_autoyast_network6('cn6v4ns');
+unlike($v4ns, qr{\Q192.0.2.53\E},
+ 'an IPv4 resolver is not given to an IPv6-only node');
+like($v4ns, qr{\Q2001:db8:4::fe\E},
+ 'the gateway stands in when the node is configured with no IPv6 resolver');
+
# dhcp_resolv says whether DHCP may overwrite resolv.conf. The AutoYaST schema of Leap 15.6
# does not accept it, and one invalid element makes YaST reject the whole profile: it reports
# "Extra element networking in interleave" and then that no profile could be retrieved. The