Fix pylint errors
This commit is contained in:
@@ -14,11 +14,13 @@ from mininet.util import quietRun
|
|||||||
from distutils.version import StrictVersion
|
from distutils.version import StrictVersion
|
||||||
|
|
||||||
def tsharkVersion():
|
def tsharkVersion():
|
||||||
|
"Return tshark version"
|
||||||
versionStr = quietRun( 'tshark -v' )
|
versionStr = quietRun( 'tshark -v' )
|
||||||
versionMatch = re.findall( 'TShark \d+.\d+.\d+', versionStr )[0]
|
versionMatch = re.findall( r'TShark \d+.\d+.\d+', versionStr )[0]
|
||||||
return versionMatch.split()[ 1 ]
|
return versionMatch.split()[ 1 ]
|
||||||
|
|
||||||
class testWalkthrough( unittest.TestCase ):
|
class testWalkthrough( unittest.TestCase ):
|
||||||
|
"Test Mininet walkthrough"
|
||||||
|
|
||||||
prompt = 'mininet>'
|
prompt = 'mininet>'
|
||||||
|
|
||||||
@@ -31,6 +33,8 @@ class testWalkthrough( unittest.TestCase ):
|
|||||||
|
|
||||||
def testWireshark( self ):
|
def testWireshark( self ):
|
||||||
"Use tshark to test the of dissector"
|
"Use tshark to test the of dissector"
|
||||||
|
# Satisfy pylint:
|
||||||
|
assert self
|
||||||
if StrictVersion( tsharkVersion() ) < StrictVersion( '1.12.0' ):
|
if StrictVersion( tsharkVersion() ) < StrictVersion( '1.12.0' ):
|
||||||
tshark = pexpect.spawn( 'tshark -i lo -R of' )
|
tshark = pexpect.spawn( 'tshark -i lo -R of' )
|
||||||
else:
|
else:
|
||||||
@@ -51,7 +55,7 @@ class testWalkthrough( unittest.TestCase ):
|
|||||||
self.assertEqual( index, 0, 'No output for "help" command')
|
self.assertEqual( index, 0, 'No output for "help" command')
|
||||||
# nodes command
|
# nodes command
|
||||||
p.sendline( 'nodes' )
|
p.sendline( 'nodes' )
|
||||||
p.expect( '([chs]\d ?){4}' )
|
p.expect( r'([chs]\d ?){4}' )
|
||||||
nodes = p.match.group( 0 ).split()
|
nodes = p.match.group( 0 ).split()
|
||||||
self.assertEqual( len( nodes ), 4, 'No nodes in "nodes" command')
|
self.assertEqual( len( nodes ), 4, 'No nodes in "nodes" command')
|
||||||
p.expect( self.prompt )
|
p.expect( self.prompt )
|
||||||
@@ -67,7 +71,7 @@ class testWalkthrough( unittest.TestCase ):
|
|||||||
p.expect( self.prompt )
|
p.expect( self.prompt )
|
||||||
# dump command
|
# dump command
|
||||||
p.sendline( 'dump' )
|
p.sendline( 'dump' )
|
||||||
expected = [ '<\w+ (%s)' % n for n in nodes ]
|
expected = [ r'<\w+ (%s)' % n for n in nodes ]
|
||||||
actual = []
|
actual = []
|
||||||
for _ in nodes:
|
for _ in nodes:
|
||||||
index = p.expect( expected )
|
index = p.expect( expected )
|
||||||
@@ -161,7 +165,7 @@ class testWalkthrough( unittest.TestCase ):
|
|||||||
p.expect( pexpect.EOF )
|
p.expect( pexpect.EOF )
|
||||||
# test iperf
|
# test iperf
|
||||||
p = pexpect.spawn( 'mn --test iperf' )
|
p = pexpect.spawn( 'mn --test iperf' )
|
||||||
p.expect( "Results: \['([\d\.]+) .bits/sec'," )
|
p.expect( r"Results: \['([\d\.]+) .bits/sec'," )
|
||||||
bw = float( p.match.group( 1 ) )
|
bw = float( p.match.group( 1 ) )
|
||||||
self.assertTrue( bw > 0 )
|
self.assertTrue( bw > 0 )
|
||||||
p.expect( pexpect.EOF )
|
p.expect( pexpect.EOF )
|
||||||
@@ -170,7 +174,7 @@ class testWalkthrough( unittest.TestCase ):
|
|||||||
"Test pingall on single,3 and linear,4 topos"
|
"Test pingall on single,3 and linear,4 topos"
|
||||||
# testing single,3
|
# testing single,3
|
||||||
p = pexpect.spawn( 'mn --test pingall --topo single,3' )
|
p = pexpect.spawn( 'mn --test pingall --topo single,3' )
|
||||||
p.expect( '(\d+)/(\d+) received')
|
p.expect( r'(\d+)/(\d+) received')
|
||||||
received = int( p.match.group( 1 ) )
|
received = int( p.match.group( 1 ) )
|
||||||
sent = int( p.match.group( 2 ) )
|
sent = int( p.match.group( 2 ) )
|
||||||
self.assertEqual( sent, 6, 'Wrong number of pings sent in single,3' )
|
self.assertEqual( sent, 6, 'Wrong number of pings sent in single,3' )
|
||||||
@@ -178,7 +182,7 @@ class testWalkthrough( unittest.TestCase ):
|
|||||||
p.expect( pexpect.EOF )
|
p.expect( pexpect.EOF )
|
||||||
# testing linear,4
|
# testing linear,4
|
||||||
p = pexpect.spawn( 'mn --test pingall --topo linear,4' )
|
p = pexpect.spawn( 'mn --test pingall --topo linear,4' )
|
||||||
p.expect( '(\d+)/(\d+) received')
|
p.expect( r'(\d+)/(\d+) received')
|
||||||
received = int( p.match.group( 1 ) )
|
received = int( p.match.group( 1 ) )
|
||||||
sent = int( p.match.group( 2 ) )
|
sent = int( p.match.group( 2 ) )
|
||||||
self.assertEqual( sent, 12, 'Wrong number of pings sent in linear,4' )
|
self.assertEqual( sent, 12, 'Wrong number of pings sent in linear,4' )
|
||||||
@@ -191,14 +195,14 @@ class testWalkthrough( unittest.TestCase ):
|
|||||||
# test bw
|
# test bw
|
||||||
p.expect( self.prompt )
|
p.expect( self.prompt )
|
||||||
p.sendline( 'iperf' )
|
p.sendline( 'iperf' )
|
||||||
p.expect( "Results: \['([\d\.]+) Mbits/sec'," )
|
p.expect( r"Results: \['([\d\.]+) Mbits/sec'," )
|
||||||
bw = float( p.match.group( 1 ) )
|
bw = float( p.match.group( 1 ) )
|
||||||
self.assertTrue( bw < 10.1, 'Bandwidth > 10 Mb/s')
|
self.assertTrue( bw < 10.1, 'Bandwidth > 10 Mb/s')
|
||||||
self.assertTrue( bw > 9.0, 'Bandwidth < 9 Mb/s')
|
self.assertTrue( bw > 9.0, 'Bandwidth < 9 Mb/s')
|
||||||
p.expect( self.prompt )
|
p.expect( self.prompt )
|
||||||
# test delay
|
# test delay
|
||||||
p.sendline( 'h1 ping -c 4 h2' )
|
p.sendline( 'h1 ping -c 4 h2' )
|
||||||
p.expect( 'rtt min/avg/max/mdev = ([\d\.]+)/([\d\.]+)/([\d\.]+)/([\d\.]+) ms' )
|
p.expect( r'rtt min/avg/max/mdev = ([\d\.]+)/([\d\.]+)/([\d\.]+)/([\d\.]+) ms' )
|
||||||
delay = float( p.match.group( 2 ) )
|
delay = float( p.match.group( 2 ) )
|
||||||
self.assertTrue( delay > 40, 'Delay < 40ms' )
|
self.assertTrue( delay > 40, 'Delay < 40ms' )
|
||||||
self.assertTrue( delay < 45, 'Delay > 40ms' )
|
self.assertTrue( delay < 45, 'Delay > 40ms' )
|
||||||
@@ -243,7 +247,7 @@ class testWalkthrough( unittest.TestCase ):
|
|||||||
switches = [ 'user', 'ovsk' ]
|
switches = [ 'user', 'ovsk' ]
|
||||||
for sw in switches:
|
for sw in switches:
|
||||||
p = pexpect.spawn( 'mn --switch %s --test iperf' % sw )
|
p = pexpect.spawn( 'mn --switch %s --test iperf' % sw )
|
||||||
p.expect( "Results: \['([\d\.]+) .bits/sec'," )
|
p.expect( r"Results: \['([\d\.]+) .bits/sec'," )
|
||||||
bw = float( p.match.group( 1 ) )
|
bw = float( p.match.group( 1 ) )
|
||||||
self.assertTrue( bw > 0 )
|
self.assertTrue( bw > 0 )
|
||||||
p.expect( pexpect.EOF )
|
p.expect( pexpect.EOF )
|
||||||
@@ -251,7 +255,7 @@ class testWalkthrough( unittest.TestCase ):
|
|||||||
def testBenchmark( self ):
|
def testBenchmark( self ):
|
||||||
"Run benchmark and verify that it takes less than 2 seconds"
|
"Run benchmark and verify that it takes less than 2 seconds"
|
||||||
p = pexpect.spawn( 'mn --test none' )
|
p = pexpect.spawn( 'mn --test none' )
|
||||||
p.expect( 'completed in ([\d\.]+) seconds' )
|
p.expect( r'completed in ([\d\.]+) seconds' )
|
||||||
time = float( p.match.group( 1 ) )
|
time = float( p.match.group( 1 ) )
|
||||||
self.assertTrue( time < 2, 'Benchmark takes more than 2 seconds' )
|
self.assertTrue( time < 2, 'Benchmark takes more than 2 seconds' )
|
||||||
|
|
||||||
@@ -275,7 +279,7 @@ class testWalkthrough( unittest.TestCase ):
|
|||||||
self.assertEqual( ifcount, 2, 'Missing interfaces on s1' )
|
self.assertEqual( ifcount, 2, 'Missing interfaces on s1' )
|
||||||
# verify that all hosts a reachable
|
# verify that all hosts a reachable
|
||||||
p.sendline( 'pingall' )
|
p.sendline( 'pingall' )
|
||||||
p.expect( '(\d+)% dropped' )
|
p.expect( r'(\d+)% dropped' )
|
||||||
dropped = int( p.match.group( 1 ) )
|
dropped = int( p.match.group( 1 ) )
|
||||||
self.assertEqual( dropped, 0, 'pingall failed')
|
self.assertEqual( dropped, 0, 'pingall failed')
|
||||||
p.expect( self.prompt )
|
p.expect( self.prompt )
|
||||||
|
|||||||
Reference in New Issue
Block a user