Test fixes and debugging (#1005)
test_controlnet: log to stdout for now test_walkthrough: wait for http server connection
This commit is contained in:
@@ -7,13 +7,15 @@ Test for controlnet.py
|
|||||||
import unittest
|
import unittest
|
||||||
from mininet.util import pexpect
|
from mininet.util import pexpect
|
||||||
|
|
||||||
|
from sys import stdout
|
||||||
|
|
||||||
class testControlNet( unittest.TestCase ):
|
class testControlNet( unittest.TestCase ):
|
||||||
|
|
||||||
prompt = 'mininet>'
|
prompt = 'mininet>'
|
||||||
|
|
||||||
def testPingall( self ):
|
def testPingall( self ):
|
||||||
"Simple pingall test that verifies 0% packet drop in data network"
|
"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.expect( self.prompt )
|
||||||
p.sendline( 'pingall' )
|
p.sendline( 'pingall' )
|
||||||
p.expect ( '(\d+)% dropped' )
|
p.expect ( '(\d+)% dropped' )
|
||||||
@@ -26,9 +28,9 @@ class testControlNet( unittest.TestCase ):
|
|||||||
def testFailover( self ):
|
def testFailover( self ):
|
||||||
"Kill controllers and verify that switch, s1, fails over properly"
|
"Kill controllers and verify that switch, s1, fails over properly"
|
||||||
count = 1
|
count = 1
|
||||||
p = pexpect.spawn( 'python -m mininet.examples.controlnet' )
|
p = pexpect.spawn( 'python -m mininet.examples.controlnet', logfile=stdout )
|
||||||
p.expect( self.prompt )
|
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' )
|
lp.expect( 'tcp:\d+\.\d+\.\d+\.(\d+):\d+: connected' )
|
||||||
ip = int( lp.match.group( 1 ) )
|
ip = int( lp.match.group( 1 ) )
|
||||||
self.assertEqual( count, ip )
|
self.assertEqual( count, ip )
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import re
|
|||||||
from mininet.util import quietRun, pexpect
|
from mininet.util import quietRun, pexpect
|
||||||
from mininet.clean import cleanup
|
from mininet.clean import cleanup
|
||||||
from distutils.version import StrictVersion
|
from distutils.version import StrictVersion
|
||||||
from time import sleep
|
from sys import stdout
|
||||||
|
|
||||||
|
|
||||||
def tsharkVersion():
|
def tsharkVersion():
|
||||||
@@ -168,14 +168,16 @@ class testWalkthrough( unittest.TestCase ):
|
|||||||
httpserver = 'SimpleHTTPServer'
|
httpserver = 'SimpleHTTPServer'
|
||||||
else:
|
else:
|
||||||
httpserver = 'http.server'
|
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.expect( self.prompt )
|
||||||
p.sendline( 'h1 python -m %s 80 &' % httpserver )
|
|
||||||
# The walkthrough doesn't specify a delay here, and
|
# The walkthrough doesn't specify a delay here, and
|
||||||
# we also don't read the output (also a possible problem),
|
# 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.
|
# 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.expect( self.prompt )
|
||||||
p.sendline( ' h2 wget -O - h1' )
|
p.sendline( ' h2 wget -O - h1' )
|
||||||
p.expect( '200 OK' )
|
p.expect( '200 OK' )
|
||||||
|
|||||||
Reference in New Issue
Block a user