Fixes for DHCP tests
cover Fixes for DHCP tests
Hi,
while debugging a failure of DHCP tests on SUSE Linux Enterprise I did some fixes and enhancements of these tests. I tested patchset on various versions of Debian, SUSE and CentOS, using NetworkManager and Wicked.
Due different approach of using dhclient in these two network managers and specific /sbin/dhclient-script for each distro it's quite pain to have these tests working on all distros, so there might be more patches.
Kind regards,
Petr
Petr Vorel (5):
net/dhcp: Add support for wicked
net/dhcp: Disable DNS for dnsmasq
net/dhcp: Print client and server versions net/dhcp: Pass lease file location to dhcpd via -lf net/dhcp: TBROK when dnsmasq does not start
testcases/network/dhcp/dhcp_lib.sh | 21 +++++++++++++++++++++ testcases/network/dhcp/dhcpd_tests.sh | 13 +++++++------ testcases/network/dhcp/dnsmasq_tests.sh | 7 ++++++- 3 files changed, 34 insertions(+), 7 deletions(-)
Signature · 1 line
2.19.0
PATCH 1/5 net/dhcp: Add support for wicked
wicked network configuration daemon conflicts with dhclient. In order to use dhclient, it requires wicked to be disabled.
daemonlib.sh currently doesn't have support for enabling detection. While we could add support for it, wicked is used only in openSUSE/SLE with systemd let's ignore non-systemd versions.
--- testcases/network/dhcp/dhcp_lib.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
testcases/network/dhcp/dhcp_lib.sh +14 -1
@@ -12,6 +12,7 @@ TST_NEEDS_ROOT=1 TST_NEEDS_CMDS="cat $dhcp_name awk ip pgrep pkill dhclient" . tst_net.sh +. daemonlib.sh iface0="ltp_veth0" iface1="ltp_veth1"
@@ -89,10 +90,11 @@ cleanup() test01() { + local wicked + tst_res TINFO "starting DHCPv$TST_IPVER server on $iface0" start_dhcp$TST_IPV6 - sleep 1 if [ "$(pgrep '$dhcp_name')" ]; then
@@ -100,6 +102,12 @@ test01() tst_brk TBROK "Failed to start $dhcp_name" fi + if [ $HAVE_SYSTEMCTL -eq 1 ] && \ + systemctl --no-pager -p Id show network.service | grep -q Id=wicked.service; then + tst_res TINFO "temporarily disabling wicked" + wicked=1 + systemctl disable wicked + fi tst_res TINFO "starting dhclient -$TST_IPVER $iface1" dhclient -$TST_IPVER $iface1 || tst_brk TBROK "dhclient failed"
@@ -112,5 +120,10 @@ test01() print_dhcp_log fi + if [ "$wicked" ]; then + tst_res TINFO "reenabling wicked" + systemctl enable wicked + fi + stop_dhcp }
Signature · 1 line
2.19.0
PATCH 2/5 net/dhcp: Disable DNS for dnsmasq
In reply to Petr VorelThis fixes error when another DNS server is already running:
dnsmasq: failed to create listening socket for port 53: Address already in use
--- testcases/network/dhcp/dnsmasq_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/network/dhcp/dnsmasq_tests.sh +1 -1
@@ -10,7 +10,7 @@ dhcp_name="dnsmasq" common_opt="--no-hosts --no-resolv --dhcp-authoritative \ --log-facility=./tst_dnsmasq.log --interface=$iface0 \ - --dhcp-leasefile=tst_dnsmasq.lease --conf-file= " + --dhcp-leasefile=tst_dnsmasq.lease --port=0 --conf-file= " start_dhcp() {
Signature · 1 line
2.19.0
PATCH 3/5 net/dhcp: Print client and server versions
In reply to Petr Vorel--- testcases/network/dhcp/dhcp_lib.sh | 3 +++ testcases/network/dhcp/dhcpd_tests.sh | 5 +++++ testcases/network/dhcp/dnsmasq_tests.sh | 5 +++++ 3 files changed, 13 insertions(+)
testcases/network/dhcp/dhcp_lib.sh +3 -0
@@ -92,6 +92,9 @@ test01() { local wicked + tst_res TINFO "testing DHCP server $dhcp_name: $(print_dhcp_version)" + tst_res TINFO "using DHCP client: $(dhclient --version 2>&1)" + tst_res TINFO "starting DHCPv$TST_IPVER server on $iface0" start_dhcp$TST_IPV6
testcases/network/dhcp/dhcpd_tests.sh +5 -0
@@ -77,4 +77,9 @@ print_dhcp_log() cat tst_dhcpd.err } +print_dhcp_version() +{ + dhcpd --version 2>&1 +} + tst_run
testcases/network/dhcp/dnsmasq_tests.sh +5 -0
@@ -40,4 +40,9 @@ print_dhcp_log() cat tst_dnsmasq.log } +print_dhcp_version() +{ + dnsmasq --version | head -2 +} + tst_run
Signature · 1 line
2.19.0
PATCH 4/5 net/dhcp: Pass lease file location to dhcpd via -lf
In reply to Petr Voreland create it with touch. This fixes error when lease file was missing in default directory (/var/lib/dhcp/) or directory was not writable:
dhcpd_tests 1 TINFO: starting DHCPv4 server on ltp_veth0
dhcpd -4 ltp_veth0 > tst_dhcpd.err 2>&1
Internet Systems Consortium DHCP Server 4.3.3
Copyright 2004-2015 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Not searching LDAP since ldap-server, ldap-port and ldap-base-dn were not specified in the config file Config file: /etc/dhcpd.conf
Database file: /var/lib/dhcp/db/dhcpd.leases
PID file: /var/run/dhcpd.pid
Can't open lease database /var/lib/dhcp/db/dhcpd.leases: No such file or directory --
check for failed database rewrite attempt!
Please read the dhcpd.leases manual page if you
don't know what to do about this.
--- testcases/network/dhcp/dhcpd_tests.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
testcases/network/dhcp/dhcpd_tests.sh +2 -1
@@ -29,7 +29,8 @@ setup_dhcpd_conf() start_dhcpd() { - dhcpd -$TST_IPVER $iface0 > tst_dhcpd.err 2>&1 + touch tst_hdcpd.lease + dhcpd -lf tst_hdcpd.lease -$TST_IPVER $iface0 > tst_dhcpd.err 2>&1 if [ $? -ne 0 ]; then cat tst_dhcpd.err tst_brk TBROK "Failed to start dhcpd"
Signature · 1 line
2.19.0
PATCH 5/5 net/dhcp: TBROK when dnsmasq does not start
In reply to Petr VorelMove error handling detection from dhcpd test to library to be used also by dnsmasq test.
--- testcases/network/dhcp/dhcp_lib.sh | 5 +++++ testcases/network/dhcp/dhcpd_tests.sh | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-)
testcases/network/dhcp/dhcp_lib.sh +5 -0
@@ -98,6 +98,11 @@ test01() tst_res TINFO "starting DHCPv$TST_IPVER server on $iface0" start_dhcp$TST_IPV6 + if [ $? -ne 0 ]; then + print_dhcp_log + tst_brk TBROK "Failed to start $dhcp_name" + fi + sleep 1 if [ "$(pgrep '$dhcp_name')" ]; then
testcases/network/dhcp/dhcpd_tests.sh +0 -5
@@ -31,11 +31,6 @@ start_dhcpd() { touch tst_hdcpd.lease dhcpd -lf tst_hdcpd.lease -$TST_IPVER $iface0 > tst_dhcpd.err 2>&1 - if [ $? -ne 0 ]; then - cat tst_dhcpd.err - tst_brk TBROK "Failed to start dhcpd" - fi - } start_dhcp()
Signature · 1 line
2.19.0
cover Fixes for DHCP tests
In reply to Petr VorelQuoted 20 lines · Petr Vorel
Hi,
while debugging a failure of DHCP tests on SUSE Linux Enterprise I did some fixes and enhancements of these tests. I tested patchset on various versions of Debian, SUSE and CentOS, using NetworkManager and Wicked.
Due different approach of using dhclient in these two network managers and specific
/sbin/dhclient-scriptfor each distro it's quite pain to have these tests working on all distros, so there might be more patches.Kind regards,
PetrPetr Vorel (5):
net/dhcp: Add support for wicked
net/dhcp: Disable DNS for dnsmasq
net/dhcp: Print client and server versions net/dhcp: Pass lease file location to dhcpd via -lf net/dhcp: TBROK when dnsmasq does not start
Quoted 5 lines
testcases/network/dhcp/dhcp_lib.sh | 21 +++++++++++++++++++++ testcases/network/dhcp/dhcpd_tests.sh | 13 +++++++------ testcases/network/dhcp/dnsmasq_tests.sh | 7 ++++++- 3 files changed, 34 insertions(+), 7 deletions(-)
The patch-set looks good, acked. Thanks Petr!
cover Fixes for DHCP tests
In reply to Petr VorelHi Alexey,
Quoted 8 lines
Quoted 6 lines
Petr Vorel (5):
net/dhcp: Add support for wicked
net/dhcp: Disable DNS for dnsmasq
net/dhcp: Print client and server versions net/dhcp: Pass lease file location to dhcpd via -lf net/dhcp: TBROK when dnsmasq does not startThe patch-set looks good, acked. Thanks Petr!
Thanks for your review, pushed with your ack.
I also added one more patch-set for DHCP ("DHCP tests and AppArmor improvements")
Kind regards,
Petr