From 14e0f40cdc33aed83496ccdb12b95645447c1410 Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Mon, 9 Nov 2026 18:11:01 -0300 Subject: [PATCH] test(xcat-core): a DHCPv6 boot class answers clients of every network kea_client_classes6 builds the boot classes of one network, and the subnet names them in its additional-class list. The classes do not set the additional-only flag, so Kea also evaluates them for every client of every other subnet. A discovery client on the second network then receives the boot URL of the first network. dhcp6_boot_client_classes.t renders the classes of one network through the Kea backend and asserts that each one carries only-in-additional-list. The assertion fails on this tree. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> --- xCAT-test/unit/dhcp6_boot_client_classes.t | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/xCAT-test/unit/dhcp6_boot_client_classes.t b/xCAT-test/unit/dhcp6_boot_client_classes.t index 742fda3f19..3fb7201546 100644 --- a/xCAT-test/unit/dhcp6_boot_client_classes.t +++ b/xCAT-test/unit/dhcp6_boot_client_classes.t @@ -18,7 +18,7 @@ # So classes could not reach the config even once something built them. use strict; use warnings; -use Test::More tests => 15; +use Test::More tests => 17; use FindBin; use lib "$FindBin::Bin/../../perl-xCAT"; use JSON; @@ -113,3 +113,19 @@ my ($arch_at) = grep { $withnet->[$_]{test} =~ /0x0007/ && $withnet->[$_]{test} !~ /iPXE/ } 0 .. $#$withnet; ok( defined($ipxe_at) && defined($arch_at) && $ipxe_at < $arch_at, 'the second stage is matched before the first, or iPXE is handed the shim again' ); + +# --- each class answers only the network that lists it ------------------------------------------ +# The classes of every network are global in Dhcp6, and the subnet list only adds them to its own +# clients. A class without the additional-only flag is also evaluated for every client of every +# subnet, so a discovery client on the second network is handed the URL of the first. +my $two = $backend->render_dhcp6_config({ + interfaces => ['eth1'], + subnets => [ + { id => 1, subnet => '2001:db8:188::/64', additional_client_classes => [ map { $_->{name} } @$withnet ] }, + ], + 'client-classes' => $withnet, +}); +my $rendered = decode_json($two)->{Dhcp6}{'client-classes'} || []; +is( scalar(@$rendered), scalar(@$withnet), 'every per-network class is rendered' ); +is_deeply( [ map { $_->{name} } grep { !( $_->{'only-in-additional-list'} ) } @$rendered ], [], + 'and each one is evaluated only for a subnet that lists it' );