From 3a9081b5b1a28b0c9068b27d1a19f78fe6d0ce5a Mon Sep 17 00:00:00 2001 From: Bob Lantz Date: Fri, 21 Oct 2016 15:31:33 -0700 Subject: [PATCH] Add small wait before wget in web test. Although the walkthrough doesn't specify waiting, it is a race condition that we occasionally hit in tests. Adding a 2 second delay seems realistic (for when a human is doing the walkthrough) and should reduce the likelihood of hitting the race condition. --- mininet/test/test_walkthrough.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mininet/test/test_walkthrough.py b/mininet/test/test_walkthrough.py index 466bf28..b87118c 100755 --- a/mininet/test/test_walkthrough.py +++ b/mininet/test/test_walkthrough.py @@ -12,6 +12,7 @@ import os import re from mininet.util import quietRun from distutils.version import StrictVersion +from time import sleep def tsharkVersion(): "Return tshark version" @@ -157,6 +158,11 @@ class testWalkthrough( unittest.TestCase ): p = pexpect.spawn( 'mn' ) p.expect( self.prompt ) p.sendline( 'h1 python -m SimpleHTTPServer 80 &' ) + # The walkthrough doesn't specify a delay here, and + # we also don't read the output (also a possible problem), + # but for now let's wait a couple of seconds to make + # it less likely to fail due to the race condition. + sleep( 2 ) p.expect( self.prompt ) p.sendline( ' h2 wget -O - h1' ) p.expect( '200 OK' )