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