Test fixes and debugging (#1005)

test_controlnet: log to stdout for now
test_walkthrough: wait for http server connection
This commit is contained in:
lantz
2021-01-09 18:53:50 -08:00
committed by GitHub
parent 77c473687e
commit 53975940de
2 changed files with 12 additions and 8 deletions
+5 -3
View File
@@ -7,13 +7,15 @@ Test for controlnet.py
import unittest
from mininet.util import pexpect
from sys import stdout
class testControlNet( unittest.TestCase ):
prompt = 'mininet>'
def testPingall( self ):
"Simple pingall test that verifies 0% packet drop in data network"
p = pexpect.spawn( 'python -m mininet.examples.controlnet' )
p = pexpect.spawn( 'python -m mininet.examples.controlnet', logfile=stdout)
p.expect( self.prompt )
p.sendline( 'pingall' )
p.expect ( '(\d+)% dropped' )
@@ -26,9 +28,9 @@ class testControlNet( unittest.TestCase ):
def testFailover( self ):
"Kill controllers and verify that switch, s1, fails over properly"
count = 1
p = pexpect.spawn( 'python -m mininet.examples.controlnet' )
p = pexpect.spawn( 'python -m mininet.examples.controlnet', logfile=stdout )
p.expect( self.prompt )
lp = pexpect.spawn( 'tail -f /tmp/s1-ofp.log' )
lp = pexpect.spawn( 'tail -f /tmp/s1-ofp.log', logfile=stdout )
lp.expect( 'tcp:\d+\.\d+\.\d+\.(\d+):\d+: connected' )
ip = int( lp.match.group( 1 ) )
self.assertEqual( count, ip )
+7 -5
View File
@@ -12,7 +12,7 @@ import re
from mininet.util import quietRun, pexpect
from mininet.clean import cleanup
from distutils.version import StrictVersion
from time import sleep
from sys import stdout
def tsharkVersion():
@@ -168,14 +168,16 @@ class testWalkthrough( unittest.TestCase ):
httpserver = 'SimpleHTTPServer'
else:
httpserver = 'http.server'
p = pexpect.spawn( 'mn -w' )
p = pexpect.spawn( 'mn -w', logfile=stdout )
p.expect( self.prompt )
p.sendline( 'h1 python -m %s 80 >& /dev/null &' % httpserver )
p.expect( self.prompt )
p.sendline( 'h1 python -m %s 80 &' % httpserver )
# 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
# but for now let's wait a number of seconds to make
# it less likely to fail due to the race condition.
sleep( 2 )
p.sendline( 'px from mininet.util import waitListening;'
'waitListening(h1, port=80, timeout=30)' )
p.expect( self.prompt )
p.sendline( ' h2 wget -O - h1' )
p.expect( '200 OK' )