From 018987d0fbd231237312c6b3716b072c1cac23f9 Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Sun, 8 Nov 2026 16:32:12 -0300 Subject: [PATCH] fix(xcat-test): the cases restart a DHCPv4 unit that Ubuntu does not have Ten cmd lines in five case files restarted the DHCPv4 server with the same inline probe of kea-dhcp4, falling back to isc-dhcp-server on Ubuntu. Kea is the backend there and its unit is kea-dhcp4-server, so the probe was false and the fallback named a unit that is not installed. The restart exited 5 with "Unit isc-dhcp-server.service not found" and failed the case. Each of those lines now calls commoncmd/restart_dhcp.sh. discovery_test also decided whether to create /var/lib/dhcpd/dhcpd.leases from the same single-unit probe, so on an Ubuntu management node it wrote an ISC leases file beside a Kea backend; it now asks restart_dhcp.sh --print-unit. Each rewritten line keeps the check that followed it. xcattest discards a cmd line that does not start with [#/$\w] and binds its checks to the previous command, so the calls are written as absolute paths. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> --- xCAT-test/autotest/testcase/discovery/discovery_test | 4 ++-- .../installation/reg_linux_diskless_installation_hierarchy | 4 ++-- xCAT-test/autotest/testcase/makedhcp/cases0 | 6 +++--- xCAT-test/autotest/testcase/migration/redhat_migration | 4 ++-- xCAT-test/autotest/testcase/migration/sles_migration | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/xCAT-test/autotest/testcase/discovery/discovery_test b/xCAT-test/autotest/testcase/discovery/discovery_test index 6c2b94b771..f88a9777f7 100755 --- a/xCAT-test/autotest/testcase/discovery/discovery_test +++ b/xCAT-test/autotest/testcase/discovery/discovery_test @@ -478,8 +478,8 @@ sub set_up_test_env_for_node_discovery { "rm -f /var/log/consoles/node-*", "rmdef $discovery_target_node", "rm -f /var/lib/dhcp/* /var/lib/kea/kea-leases4.csv 2>/dev/null; true", - "if systemctl is-active kea-dhcp4 >/dev/null 2>&1; then true; else mkdir -p /var/lib/dhcpd; touch /var/lib/dhcpd/dhcpd.leases; fi", - "if systemctl is-active kea-dhcp4 >/dev/null 2>&1; then systemctl restart kea-dhcp4; elif cat /etc/*release | grep -qi ubuntu; then service isc-dhcp-server restart; else service dhcpd restart; fi", + "if /opt/xcat/share/xcat/tools/autotest/testcase/commoncmd/restart_dhcp.sh --print-unit | grep -q '^kea'; then true; else mkdir -p /var/lib/dhcpd; touch /var/lib/dhcpd/dhcpd.leases; fi", + "/opt/xcat/share/xcat/tools/autotest/testcase/commoncmd/restart_dhcp.sh", "$predef_node_cmd", "makehosts -a $discovery_prodefine_node_name_in_automation", "makedns $discovery_prodefine_node_name_in_automation"); diff --git a/xCAT-test/autotest/testcase/installation/reg_linux_diskless_installation_hierarchy b/xCAT-test/autotest/testcase/installation/reg_linux_diskless_installation_hierarchy index fbc24cc23a..1d24d77704 100644 --- a/xCAT-test/autotest/testcase/installation/reg_linux_diskless_installation_hierarchy +++ b/xCAT-test/autotest/testcase/installation/reg_linux_diskless_installation_hierarchy @@ -34,7 +34,7 @@ cmd:makedhcp -n check:rc==0 cmd:makedhcp -a check:rc==0 -cmd:if systemctl is-active kea-dhcp4 >/dev/null 2>&1; then systemctl restart kea-dhcp4; elif cat /etc/*release | grep -qi ubuntu; then service isc-dhcp-server restart; else service dhcpd restart; fi +cmd:/opt/xcat/share/xcat/tools/autotest/testcase/commoncmd/restart_dhcp.sh check:rc==0 cmd:a=0;while true; do [ $a -eq 100 ] && exit 1;output=$(makedhcp -q $$CN);[ $? -ne 0 ] && exit 1;echo $output|grep $$CN 2>/dev/null && exit 0;a=$[$a+1];sleep 1;done check:rc==0 @@ -150,7 +150,7 @@ cmd:makedhcp -n check:rc==0 cmd:makedhcp -a check:rc==0 -cmd:if systemctl is-active kea-dhcp4 >/dev/null 2>&1; then systemctl restart kea-dhcp4; elif cat /etc/*release | grep -qi ubuntu; then service isc-dhcp-server restart; else service dhcpd restart; fi +cmd:/opt/xcat/share/xcat/tools/autotest/testcase/commoncmd/restart_dhcp.sh check:rc==0 cmd:a=0;while true; do [ $a -eq 100 ] && exit 1;output=$(makedhcp -q $$CN);[ $? -ne 0 ] && exit 1;echo $output|grep $$CN 2>/dev/null && exit 0;a=$[$a+1];sleep 1;done check:rc==0 diff --git a/xCAT-test/autotest/testcase/makedhcp/cases0 b/xCAT-test/autotest/testcase/makedhcp/cases0 index 635f9f2e33..a2f0b0b0ce 100644 --- a/xCAT-test/autotest/testcase/makedhcp/cases0 +++ b/xCAT-test/autotest/testcase/makedhcp/cases0 @@ -163,7 +163,7 @@ os:Linux label:cn_os_ready,dhcp cmd:makedhcp -a -d check:rc==0 -cmd:if systemctl is-active kea-dhcp4 >/dev/null 2>&1; then systemctl restart kea-dhcp4; elif cat /etc/*release | grep -qi ubuntu; then service isc-dhcp-server restart; else service dhcpd restart; fi +cmd:/opt/xcat/share/xcat/tools/autotest/testcase/commoncmd/restart_dhcp.sh cmd:makedhcp -q $$CN check:rc==0 check:output!~$$CN @@ -175,7 +175,7 @@ os:ubuntu label:cn_os_ready,dhcp cmd:makedhcp -a -d check:rc==0 -cmd:if systemctl is-active kea-dhcp4 >/dev/null 2>&1; then systemctl restart kea-dhcp4; elif cat /etc/*release | grep -qi ubuntu; then service isc-dhcp-server restart; else service dhcpd restart; fi +cmd:/opt/xcat/share/xcat/tools/autotest/testcase/commoncmd/restart_dhcp.sh cmd:if [ -f /var/lib/kea/kea-leases4.csv ]; then cat /var/lib/kea/kea-leases4.csv | grep $$CN; elif [ -f /var/lib/dhcp/dhcpd.leases ]; then cat /var/lib/dhcp/dhcpd.leases | grep $$CN; fi check:output!~$$CN cmd:makedhcp -a @@ -186,7 +186,7 @@ os:Linux label:cn_os_ready,dhcp cmd:makedhcp -d $$CN check:rc==0 -cmd:if systemctl is-active kea-dhcp4 >/dev/null 2>&1; then systemctl restart kea-dhcp4; elif cat /etc/*release | grep -qi ubuntu; then service isc-dhcp-server restart; else service dhcpd restart; fi +cmd:/opt/xcat/share/xcat/tools/autotest/testcase/commoncmd/restart_dhcp.sh cmd:makedhcp -q $$CN check:output!~$$CN cmd:makedhcp -a diff --git a/xCAT-test/autotest/testcase/migration/redhat_migration b/xCAT-test/autotest/testcase/migration/redhat_migration index 23add78588..0a1dd06946 100644 --- a/xCAT-test/autotest/testcase/migration/redhat_migration +++ b/xCAT-test/autotest/testcase/migration/redhat_migration @@ -24,7 +24,7 @@ cmd:makedhcp -n check:rc==0 cmd:makedhcp -a check:rc==0 -cmd:if systemctl is-active kea-dhcp4 >/dev/null 2>&1; then systemctl restart kea-dhcp4; elif cat /etc/*release | grep -qi ubuntu; then service isc-dhcp-server restart; else service dhcpd restart; fi +cmd:/opt/xcat/share/xcat/tools/autotest/testcase/commoncmd/restart_dhcp.sh check:rc==0 cmd:if [ -f /etc/kea/kea-dhcp4.conf ]; then grep $$CN /etc/kea/kea-dhcp4.conf; elif cat /etc/*release |grep SUSE >/dev/null;then cat /var/lib/dhcp/db/dhcpd.leases|grep $$CN;elif cat /etc/*release |grep "Red Hat\|Rocky\|Alma" >/dev/null;then cat /var/lib/dhcpd/dhcpd.leases|grep $$CN;fi check:output=~$$CN @@ -133,7 +133,7 @@ cmd:makedhcp -n check:rc==0 cmd:makedhcp -a check:rc==0 -cmd:if systemctl is-active kea-dhcp4 >/dev/null 2>&1; then systemctl restart kea-dhcp4; elif cat /etc/*release | grep -qi ubuntu; then service isc-dhcp-server restart; else service dhcpd restart; fi +cmd:/opt/xcat/share/xcat/tools/autotest/testcase/commoncmd/restart_dhcp.sh check:rc==0 cmd:if [ -f /etc/kea/kea-dhcp4.conf ]; then grep $$CN /etc/kea/kea-dhcp4.conf; elif cat /etc/*release |grep SUSE >/dev/null;then cat /var/lib/dhcp/db/dhcpd.leases|grep $$CN;elif cat /etc/*release |grep "Red Hat\|Rocky\|Alma" >/dev/null;then cat /var/lib/dhcpd/dhcpd.leases|grep $$CN;fi check:output=~$$CN diff --git a/xCAT-test/autotest/testcase/migration/sles_migration b/xCAT-test/autotest/testcase/migration/sles_migration index ff84e27fcd..eddaa124c8 100644 --- a/xCAT-test/autotest/testcase/migration/sles_migration +++ b/xCAT-test/autotest/testcase/migration/sles_migration @@ -23,7 +23,7 @@ cmd:makedhcp -n check:rc==0 cmd:makedhcp -a check:rc==0 -cmd:if systemctl is-active kea-dhcp4 >/dev/null 2>&1; then systemctl restart kea-dhcp4; elif cat /etc/*release | grep -qi ubuntu; then service isc-dhcp-server restart; else service dhcpd restart; fi +cmd:/opt/xcat/share/xcat/tools/autotest/testcase/commoncmd/restart_dhcp.sh check:rc==0 cmd:if [ -f /etc/kea/kea-dhcp4.conf ]; then grep $$CN /etc/kea/kea-dhcp4.conf; elif cat /etc/*release |grep SUSE >/dev/null;then cat /var/lib/dhcp/db/dhcpd.leases|grep $$CN;elif cat /etc/*release |grep "Red Hat" >/dev/null;then cat /var/lib/dhcpd/dhcpd.leases|grep $$CN;fi check:output=~$$CN @@ -142,7 +142,7 @@ cmd:makedhcp -n check:rc==0 cmd:makedhcp -a check:rc==0 -cmd:if systemctl is-active kea-dhcp4 >/dev/null 2>&1; then systemctl restart kea-dhcp4; elif cat /etc/*release | grep -qi ubuntu; then service isc-dhcp-server restart; else service dhcpd restart; fi +cmd:/opt/xcat/share/xcat/tools/autotest/testcase/commoncmd/restart_dhcp.sh check:rc==0 cmd:if [ -f /etc/kea/kea-dhcp4.conf ]; then grep $$CN /etc/kea/kea-dhcp4.conf; elif cat /etc/*release |grep SUSE >/dev/null;then cat /var/lib/dhcp/db/dhcpd.leases|grep $$CN;elif cat /etc/*release |grep "Red Hat" >/dev/null;then cat /var/lib/dhcpd/dhcpd.leases|grep $$CN;fi check:output=~$$CN