* [PATCH] autotests: p2p: Make waiting for dhclient more reliable
@ 2021-11-22 14:42 Andrew Zaborowski
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Zaborowski @ 2021-11-22 14:42 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 3212 bytes --]
Make sure we wipe the leases file both for server and client, so that
dhclient doesn't try to re-use leases from previous tests (should really
happen) and waste time waiting for a reply. Extend the timeout from 1s
to 5s, sometimes it takes dhclient 1s just to start. Disable verbose
mode if not needed to avoid dhclient stalling if the pipe is not being
read.
---
autotests/testP2P/connection_test.py | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/autotests/testP2P/connection_test.py b/autotests/testP2P/connection_test.py
index ddebc70a..d1681164 100644
--- a/autotests/testP2P/connection_test.py
+++ b/autotests/testP2P/connection_test.py
@@ -12,6 +12,8 @@ from config import ctx
from wpas import Wpas
class Test(unittest.TestCase):
+ leases_path = '/tmp/dhcp.lease'
+
def test_1_client_go_neg_responder(self):
self.p2p_connect_test(preauthorize=False, go=False)
@@ -92,10 +94,11 @@ class Test(unittest.TestCase):
peer_ifname = wpas.p2p_group['ifname']
self.assertEqual(wpas.p2p_group['role'], 'GO' if not go else 'client')
+ os.system('> ' + self.leases_path)
+
if not go:
ctx.start_process(['ip', 'addr', 'add','dev', peer_ifname, '192.168.1.20/255.255.255.0']).wait()
- os.system('> /tmp/dhcp.leases')
- dhcp = ctx.start_process(['dhcpd', '-f', '-cf', '/tmp/dhcpd.conf', '-lf', '/tmp/dhcp.leases', peer_ifname])
+ dhcp = ctx.start_process(['dhcpd', '-f', '-cf', '/tmp/dhcpd.conf', '-lf', self.leases_path, peer_ifname])
self.dhcp = dhcp
wd.wait_for_object_condition(wpas, 'len(obj.p2p_clients) == 1', max_wait=3)
@@ -105,12 +108,17 @@ class Test(unittest.TestCase):
self.assertEqual(wpas.p2p_group['ip_addr'], '192.168.1.2')
self.assertEqual(wpas.p2p_group['ip_mask'], '255.255.255.240')
self.assertEqual(wpas.p2p_group['go_ip_addr'], '192.168.1.1')
- dhcp = ctx.start_process(['dhclient', '-v', '-d', '--no-pid', '-cf', '/dev/null', '-lf', '/tmp/dhcp.leases',
- '-sf', '/tmp/dhclient-script', peer_ifname])
+
+ extra_params = []
+ if ctx.is_verbose('dhclient'):
+ extra_params.append('-v')
+
+ dhcp = ctx.start_process(['dhclient', '-d', '--no-pid', '-cf', '/dev/null', '-lf', self.leases_path,
+ '-sf', '/tmp/dhclient-script'] + extra_params + [peer_ifname])
self.dhcp = dhcp
wd.wait_for_object_condition(peer, 'obj.connected', max_wait=15)
- time.sleep(1) # Give the client time to set the IP
+ time.sleep(5) # Give the client time to set the IP
testutil.test_ip_address_match(peer_ifname, peer.connected_ip)
if not go:
@@ -146,7 +154,7 @@ class Test(unittest.TestCase):
self.wpas = None
if self.dhcp is not None:
ctx.stop_process(self.dhcp)
- for path in ['/tmp/dhcp.leases']:
+ for path in [self.leases_path, self.leases_path + '~']:
if os.path.exists(path):
os.remove(path)
--
2.32.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] autotests: p2p: Make waiting for dhclient more reliable
@ 2021-11-30 21:49 Denis Kenzior
0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2021-11-30 21:49 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 610 bytes --]
Hi Andrew,
On 11/22/21 8:42 AM, Andrew Zaborowski wrote:
> Make sure we wipe the leases file both for server and client, so that
> dhclient doesn't try to re-use leases from previous tests (should really
> happen) and waste time waiting for a reply. Extend the timeout from 1s
> to 5s, sometimes it takes dhclient 1s just to start. Disable verbose
> mode if not needed to avoid dhclient stalling if the pipe is not being
> read.
> ---
> autotests/testP2P/connection_test.py | 20 ++++++++++++++------
> 1 file changed, 14 insertions(+), 6 deletions(-)
Applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-11-30 21:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-30 21:49 [PATCH] autotests: p2p: Make waiting for dhclient more reliable Denis Kenzior
-- strict thread matches above, loose matches on Subject: below --
2021-11-22 14:42 Andrew Zaborowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox