All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 0/5] Fixes for DHCP tests
@ 2018-10-03 15:37 Petr Vorel
  2018-10-03 15:37 ` [LTP] [PATCH 1/5] net/dhcp: Add support for wicked Petr Vorel
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Petr Vorel @ 2018-10-03 15:37 UTC (permalink / raw)
  To: ltp

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(-)

-- 
2.19.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [LTP] [PATCH 1/5] net/dhcp: Add support for wicked
  2018-10-03 15:37 [LTP] [PATCH 0/5] Fixes for DHCP tests Petr Vorel
@ 2018-10-03 15:37 ` Petr Vorel
  2018-10-03 15:37 ` [LTP] [PATCH 2/5] net/dhcp: Disable DNS for dnsmasq Petr Vorel
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2018-10-03 15:37 UTC (permalink / raw)
  To: ltp

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.

Fixes: openSUSE/SLE using wicked

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/network/dhcp/dhcp_lib.sh | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/testcases/network/dhcp/dhcp_lib.sh b/testcases/network/dhcp/dhcp_lib.sh
index 0c4c76be2..b3cb70267 100755
--- a/testcases/network/dhcp/dhcp_lib.sh
+++ b/testcases/network/dhcp/dhcp_lib.sh
@@ -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
 }
-- 
2.19.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [LTP] [PATCH 2/5] net/dhcp: Disable DNS for dnsmasq
  2018-10-03 15:37 [LTP] [PATCH 0/5] Fixes for DHCP tests Petr Vorel
  2018-10-03 15:37 ` [LTP] [PATCH 1/5] net/dhcp: Add support for wicked Petr Vorel
@ 2018-10-03 15:37 ` Petr Vorel
  2018-10-03 15:37 ` [LTP] [PATCH 3/5] net/dhcp: Print client and server versions Petr Vorel
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2018-10-03 15:37 UTC (permalink / raw)
  To: ltp

This fixes error when another DNS server is already running:
dnsmasq: failed to create listening socket for port 53: Address already in use

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/network/dhcp/dnsmasq_tests.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/network/dhcp/dnsmasq_tests.sh b/testcases/network/dhcp/dnsmasq_tests.sh
index 3d29abea3..2edefd1c1 100755
--- a/testcases/network/dhcp/dnsmasq_tests.sh
+++ b/testcases/network/dhcp/dnsmasq_tests.sh
@@ -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()
 {
-- 
2.19.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [LTP] [PATCH 3/5] net/dhcp: Print client and server versions
  2018-10-03 15:37 [LTP] [PATCH 0/5] Fixes for DHCP tests Petr Vorel
  2018-10-03 15:37 ` [LTP] [PATCH 1/5] net/dhcp: Add support for wicked Petr Vorel
  2018-10-03 15:37 ` [LTP] [PATCH 2/5] net/dhcp: Disable DNS for dnsmasq Petr Vorel
@ 2018-10-03 15:37 ` Petr Vorel
  2018-10-03 15:37 ` [LTP] [PATCH 4/5] net/dhcp: Pass lease file location to dhcpd via -lf Petr Vorel
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2018-10-03 15:37 UTC (permalink / raw)
  To: ltp

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 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(+)

diff --git a/testcases/network/dhcp/dhcp_lib.sh b/testcases/network/dhcp/dhcp_lib.sh
index b3cb70267..07d5ff131 100755
--- a/testcases/network/dhcp/dhcp_lib.sh
+++ b/testcases/network/dhcp/dhcp_lib.sh
@@ -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
diff --git a/testcases/network/dhcp/dhcpd_tests.sh b/testcases/network/dhcp/dhcpd_tests.sh
index b42d55777..0f53db66e 100755
--- a/testcases/network/dhcp/dhcpd_tests.sh
+++ b/testcases/network/dhcp/dhcpd_tests.sh
@@ -77,4 +77,9 @@ print_dhcp_log()
 	cat tst_dhcpd.err
 }
 
+print_dhcp_version()
+{
+	dhcpd --version 2>&1
+}
+
 tst_run
diff --git a/testcases/network/dhcp/dnsmasq_tests.sh b/testcases/network/dhcp/dnsmasq_tests.sh
index 2edefd1c1..a9255c7c1 100755
--- a/testcases/network/dhcp/dnsmasq_tests.sh
+++ b/testcases/network/dhcp/dnsmasq_tests.sh
@@ -40,4 +40,9 @@ print_dhcp_log()
 	cat tst_dnsmasq.log
 }
 
+print_dhcp_version()
+{
+	dnsmasq --version | head -2
+}
+
 tst_run
-- 
2.19.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [LTP] [PATCH 4/5] net/dhcp: Pass lease file location to dhcpd via -lf
  2018-10-03 15:37 [LTP] [PATCH 0/5] Fixes for DHCP tests Petr Vorel
                   ` (2 preceding siblings ...)
  2018-10-03 15:37 ` [LTP] [PATCH 3/5] net/dhcp: Print client and server versions Petr Vorel
@ 2018-10-03 15:37 ` Petr Vorel
  2018-10-03 15:37 ` [LTP] [PATCH 5/5] net/dhcp: TBROK when dnsmasq does not start Petr Vorel
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2018-10-03 15:37 UTC (permalink / raw)
  To: ltp

and 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.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/network/dhcp/dhcpd_tests.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/testcases/network/dhcp/dhcpd_tests.sh b/testcases/network/dhcp/dhcpd_tests.sh
index 0f53db66e..29d688551 100755
--- a/testcases/network/dhcp/dhcpd_tests.sh
+++ b/testcases/network/dhcp/dhcpd_tests.sh
@@ -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"
-- 
2.19.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [LTP] [PATCH 5/5] net/dhcp: TBROK when dnsmasq does not start
  2018-10-03 15:37 [LTP] [PATCH 0/5] Fixes for DHCP tests Petr Vorel
                   ` (3 preceding siblings ...)
  2018-10-03 15:37 ` [LTP] [PATCH 4/5] net/dhcp: Pass lease file location to dhcpd via -lf Petr Vorel
@ 2018-10-03 15:37 ` Petr Vorel
  2018-10-04 12:04 ` [LTP] [PATCH 0/5] Fixes for DHCP tests Alexey Kodanev
  2018-10-11 22:10 ` Petr Vorel
  6 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2018-10-03 15:37 UTC (permalink / raw)
  To: ltp

Move error handling detection from dhcpd test to library to be used
also by dnsmasq test.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/network/dhcp/dhcp_lib.sh    | 5 +++++
 testcases/network/dhcp/dhcpd_tests.sh | 5 -----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/testcases/network/dhcp/dhcp_lib.sh b/testcases/network/dhcp/dhcp_lib.sh
index 07d5ff131..76bf11800 100755
--- a/testcases/network/dhcp/dhcp_lib.sh
+++ b/testcases/network/dhcp/dhcp_lib.sh
@@ -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
diff --git a/testcases/network/dhcp/dhcpd_tests.sh b/testcases/network/dhcp/dhcpd_tests.sh
index 29d688551..f1af09153 100755
--- a/testcases/network/dhcp/dhcpd_tests.sh
+++ b/testcases/network/dhcp/dhcpd_tests.sh
@@ -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()
-- 
2.19.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [LTP] [PATCH 0/5] Fixes for DHCP tests
  2018-10-03 15:37 [LTP] [PATCH 0/5] Fixes for DHCP tests Petr Vorel
                   ` (4 preceding siblings ...)
  2018-10-03 15:37 ` [LTP] [PATCH 5/5] net/dhcp: TBROK when dnsmasq does not start Petr Vorel
@ 2018-10-04 12:04 ` Alexey Kodanev
  2018-10-11 22:10 ` Petr Vorel
  6 siblings, 0 replies; 8+ messages in thread
From: Alexey Kodanev @ 2018-10-04 12:04 UTC (permalink / raw)
  To: ltp

On 10/03/2018 06:37 PM, Petr Vorel wrote:
> 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(-)
> 

The patch-set looks good, acked. Thanks Petr!

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [LTP] [PATCH 0/5] Fixes for DHCP tests
  2018-10-03 15:37 [LTP] [PATCH 0/5] Fixes for DHCP tests Petr Vorel
                   ` (5 preceding siblings ...)
  2018-10-04 12:04 ` [LTP] [PATCH 0/5] Fixes for DHCP tests Alexey Kodanev
@ 2018-10-11 22:10 ` Petr Vorel
  6 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2018-10-11 22:10 UTC (permalink / raw)
  To: ltp

Hi Alexey,

> > 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

> The 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-10-11 22:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-03 15:37 [LTP] [PATCH 0/5] Fixes for DHCP tests Petr Vorel
2018-10-03 15:37 ` [LTP] [PATCH 1/5] net/dhcp: Add support for wicked Petr Vorel
2018-10-03 15:37 ` [LTP] [PATCH 2/5] net/dhcp: Disable DNS for dnsmasq Petr Vorel
2018-10-03 15:37 ` [LTP] [PATCH 3/5] net/dhcp: Print client and server versions Petr Vorel
2018-10-03 15:37 ` [LTP] [PATCH 4/5] net/dhcp: Pass lease file location to dhcpd via -lf Petr Vorel
2018-10-03 15:37 ` [LTP] [PATCH 5/5] net/dhcp: TBROK when dnsmasq does not start Petr Vorel
2018-10-04 12:04 ` [LTP] [PATCH 0/5] Fixes for DHCP tests Alexey Kodanev
2018-10-11 22:10 ` Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.