From 2a6d80fb8c4b7cf3ed9a5babe9dadb7e14a649fd Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Thu, 29 Oct 2026 09:56:37 -0300 Subject: [PATCH] test(template): the address mode is answered for the cluster, not for the node post.sles.common reads MANAGEDADDRESSMODE and, for anything but static, removes the interface configuration and writes a new one with BOOTPROTO=dhcp. managed_address_mode returns site.managedaddressmode, which describes the cluster. An IPv6-only node therefore has the static IPv6 configuration in its AutoYaST profile rewritten to DHCP during the post phase, and comes up with a link-local address only. The node has no IPv4 address to ask a DHCP server for, so the site attribute cannot answer for it. The test renders MANAGEDADDRESSMODE for three nodes with the site attribute set to dhcp: an IPv6-only node, an IPv4 node and a dual-stack node. Only the IPv6-only node is expected to differ, so the other two hold the site behaviour down. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> --- xCAT-test/unit/template_ipv6_rendering.t | 25 ++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/xCAT-test/unit/template_ipv6_rendering.t b/xCAT-test/unit/template_ipv6_rendering.t index e1773089a8..ca255d655b 100644 --- a/xCAT-test/unit/template_ipv6_rendering.t +++ b/xCAT-test/unit/template_ipv6_rendering.t @@ -117,12 +117,13 @@ local $::XCATSITEVALS{managedaddressmode} = 'dhcp'; local $::XCATSITEVALS{xcatdebugmode} = '0'; sub render_minimal_template { - my ($node, $master) = @_; + my ($node, $master, $body) = @_; + $body //= "#KICKSTARTNET#\n#INSTALL_SOURCES_IN_PRE#\n"; my $tmpdir = tempdir(CLEANUP => 1); my $input = "$tmpdir/input.tmpl"; my $output = "$tmpdir/output"; open(my $template, '>', $input) or die "Unable to write template: $!"; - print {$template} "#KICKSTARTNET#\n#INSTALL_SOURCES_IN_PRE#\n"; + print {$template} $body; close($template); my $error = xCAT::Template->subvars( @@ -193,4 +194,24 @@ like( ); is($ENV{MASTER_IP}, '192.0.2.1', 'IPv4 template keeps legacy master resolution'); +# post.sles.common rewrites the interface configuration with BOOTPROTO=dhcp unless +# MANAGEDADDRESSMODE reads static, which undoes the static IPv6 configuration the +# AutoYaST profile carries for an IPv6-only node. The site attribute describes the +# cluster, so it cannot answer for a node that has no IPv4 address to ask for. +{ + my $v6_mode = + render_minimal_template('nodev6', 'master6.example.test', "#MANAGEDADDRESSMODE#\n"); + like($v6_mode, qr/^static$/m, + 'an IPv6-only node reports the static address mode whatever the site says'); + + my $v4_mode = + render_minimal_template('nodev4', 'master4.example.test', "#MANAGEDADDRESSMODE#\n"); + like($v4_mode, qr/^dhcp$/m, 'an IPv4 node keeps the site address mode'); + + my $dual_mode = + render_minimal_template('nodedual', 'master4.example.test', "#MANAGEDADDRESSMODE#\n"); + like($dual_mode, qr/^dhcp$/m, + 'a dual-stack node keeps the site address mode, since it can still use DHCP'); +} + done_testing();