diff --git a/xCAT-test/unit/subiquity_ipv6_netplan.t b/xCAT-test/unit/subiquity_ipv6_netplan.t index 1385483a32..e56de261d3 100644 --- a/xCAT-test/unit/subiquity_ipv6_netplan.t +++ b/xCAT-test/unit/subiquity_ipv6_netplan.t @@ -38,6 +38,9 @@ my $nameservers = ',192.0.2.53'; my $DEFAULT_CFG6 = [ @$cfg6 ]; my $DEFAULT_NAMESERVERS = $nameservers; +# A resolver named by host name has an AAAA record, which ipv6_server_for_node looks up. +my %RESOLVED = ( 'ns6.example.test' => '2001:db8:147::54' ); + no warnings 'redefine'; local *xCAT::NetworkUtils::getNodeNetworkCfg6 = sub { my $candidate = shift; @@ -49,6 +52,7 @@ local *xCAT::NetworkUtils::ipv6_server_for_node = sub { $candidate = shift if defined($candidate) && $candidate eq 'xCAT::NetworkUtils'; my $server = shift; return $MASTER if defined($server) && $server eq ''; + return $RESOLVED{$server} if defined($server) && exists $RESOLVED{$server}; return $server; }; local *xCAT::NetworkUtils::getNodeNameservers = sub { @@ -80,6 +84,8 @@ is( target_for(0), my $v6 = keys_for( 1, 8 ); is( $v6, <<'EOV6' =~ s/\n\z//r, 'an IPv6-only node is given its reserved address, statically' ); dhcp4: false + dhcp6: false + accept-ra: false addresses: [2001:db8:147::20/64] routes: - to: default @@ -95,7 +101,13 @@ like( $v6, qr/^\s+addresses: \[\Q$MASTER\E\]$/m, '... resolving through the IPv6 unlike( $v6, qr/192\.0\.2\.53/, '... and not through the IPv4 resolver it cannot reach' ); like( $v6, qr/^\s+dhcp4: false$/m, '... with DHCPv4 turned off explicitly' ); -unlike( $v6, qr/dhcp6/, '... asking for no DHCPv6, whose DUID matches no reservation' ); +unlike( $v6, qr/dhcp6: true/, '... asking for no DHCPv6, whose DUID matches no reservation' ); +# A router advertisement with the managed flag starts DHCPv6 in systemd-networkd even when +# netplan says dhcp6: false. The pool address it gets has no PTR record, so the callback that +# flips the node to local boot is refused and the node boots the installer again. +like( $v6, qr/^\s+dhcp6: false$/m, '... with DHCPv6 turned off explicitly' ); +like( $v6, qr/^\s+accept-ra: false$/m, + '... and router advertisements ignored, so a managed flag cannot start DHCPv6' ); unlike( $v6, qr/dhcp4: true/, '... never asking for DHCPv4' ); # A literal resolver address is kept as it stands; only the IPv4 one is dropped. @@ -107,6 +119,17 @@ unlike( $v6, qr/dhcp4: true/, '... never asking for DHCPv4' ); 'a resolver named by address is used as it stands' ); } +# A resolver named by host name is resolved to its IPv6 address, not dropped for lacking a colon. +{ + $nameservers = 'ns6.example.test,192.0.2.53'; + my $named = keys_for( 1, 8 ); + $nameservers = $DEFAULT_NAMESERVERS; + like( $named, qr/^\s+addresses: \[2001:db8:147::54\]$/m, + 'a resolver named by host name is used through its AAAA record' ); + unlike( $named, qr/addresses: \[\Q$MASTER\E\]/, + '... and the management node does not replace it' ); +} + # A node with no address must fail the template rather than install and hang at post.xcat. { $cfg6 = [ undef, $NODE, '', undef ]; @@ -128,7 +151,8 @@ unlike( $v6, qr/dhcp4: true/, '... never asking for DHCPv4' ); # ---- the netplan of the installed system ------------------------------------------------------- my $t6 = target_for(1); is( $t6, - '" dhcp4: false" " addresses: [2001:db8:147::20/64]" " routes:"' + '" dhcp4: false" " dhcp6: false" " accept-ra: false"' + . ' " addresses: [2001:db8:147::20/64]" " routes:"' . ' " - to: default" " via: 2001:db8:147::1" " nameservers:"' . ' " addresses: [2001:db8:147::1]"', 'the installed system keeps the same static address' ); @@ -139,11 +163,13 @@ like( $t6, qr/" via: \Q$MASTER\E"/, '... through the resolved gateway' unlike( $t6, qr/" dhcp6: true"/, '... never asking for DHCPv6, which would take a third address' ); unlike( $t6, qr/dhcp4: true/, '... and never for DHCPv4' ); +like( $t6, qr/" accept-ra: false"/, + '... and ignoring router advertisements in the installed system too' ); # The indent is what keeps the YAML valid where the tag sits. is( keys_for( 0, 8 ), ' dhcp4: true', 'the keys are indented as the tag asks' ); is( keys_for( 0, 6 ), ' dhcp4: true', '... at whichever indent it asks for' ); -like( keys_for( 1, 4 ), qr/^ dhcp4: false\n addresses: /, +like( keys_for( 1, 4 ), qr/^ dhcp4: false\n dhcp6: false\n accept-ra: false\n addresses: /, 'and the IPv6 form shares that indent' ); # The templates carry the tags rather than a literal, or the subs are dead code.