From 7b9fef4df3d1f0b1ce5e2fe1033856fefcaa8def Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Wed, 26 Aug 2026 22:21:41 -0300 Subject: [PATCH] test(dhcp): preserve hosts on failed replacement --- xCAT-test/unit/dhcp_static_host_markers.t | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/xCAT-test/unit/dhcp_static_host_markers.t b/xCAT-test/unit/dhcp_static_host_markers.t index 5a87dabc3..8409a1965 100644 --- a/xCAT-test/unit/dhcp_static_host_markers.t +++ b/xCAT-test/unit/dhcp_static_host_markers.t @@ -154,4 +154,31 @@ ok( 'a disabled static update leaves the configuration unchanged', ); +my @lazy_config; +xCAT_plugin::dhcp::_add_isc_static_host( + 'node06', 'node06-old', '00:11:22:33:44:11', 1, + 'eth0', '192.0.2.7', '', 0, \@lazy_config, +); +my $before_failed_update = join( '', @lazy_config ); +my $update_started = 0; +xCAT_plugin::dhcp::_add_isc_static_host( + 'node06', 'node06-current', '00:11:22:33:44:22', 1, + 'eth0', undef, '', 0, \@lazy_config, \$update_started, +); +is(join( '', @lazy_config ), $before_failed_update, + 'an unresolved replacement preserves the existing static host'); +is($update_started, 0, + 'an unresolved replacement does not begin the static update'); +xCAT_plugin::dhcp::_add_isc_static_host( + 'node06', 'node06-current', '00:11:22:33:44:22', 1, + 'eth0', '192.0.2.8', '', 0, \@lazy_config, \$update_started, +); +my $lazy_replacement = join( '', @lazy_config ); +unlike($lazy_replacement, qr/^host node06-old \{$/m, + 'the first valid replacement removes stale node identities'); +like($lazy_replacement, qr/^host node06-current \{$/m, + 'the first valid replacement writes the current identity'); +is($update_started, 1, + 'the successful replacement records that cleanup has started'); + done_testing();