Use 0% loss when testing examples/simpleperf.py
Also clarified the code in test_simpleperf.py. Fixes #590
This commit is contained in:
+14
-5
@@ -16,22 +16,30 @@ from mininet.link import TCLink
|
|||||||
from mininet.util import dumpNodeConnections
|
from mininet.util import dumpNodeConnections
|
||||||
from mininet.log import setLogLevel
|
from mininet.log import setLogLevel
|
||||||
|
|
||||||
|
from sys import argv
|
||||||
|
|
||||||
class SingleSwitchTopo(Topo):
|
class SingleSwitchTopo(Topo):
|
||||||
"Single switch connected to n hosts."
|
"Single switch connected to n hosts."
|
||||||
def __init__(self, n=2, **opts):
|
def __init__(self, n=2, lossy=True, **opts):
|
||||||
Topo.__init__(self, **opts)
|
Topo.__init__(self, **opts)
|
||||||
switch = self.addSwitch('s1')
|
switch = self.addSwitch('s1')
|
||||||
for h in range(n):
|
for h in range(n):
|
||||||
# Each host gets 50%/n of system CPU
|
# Each host gets 50%/n of system CPU
|
||||||
host = self.addHost('h%s' % (h + 1),
|
host = self.addHost('h%s' % (h + 1),
|
||||||
cpu=.5 / n)
|
cpu=.5 / n)
|
||||||
# 10 Mbps, 5ms delay, 10% loss
|
if lossy:
|
||||||
|
# 10 Mbps, 5ms delay, 10% packet loss
|
||||||
self.addLink(host, switch,
|
self.addLink(host, switch,
|
||||||
bw=10, delay='5ms', loss=10, use_htb=True)
|
bw=10, delay='5ms', loss=10, use_htb=True)
|
||||||
|
else:
|
||||||
|
# 10 Mbps, 5ms delay, no packet loss
|
||||||
|
self.addLink(host, switch,
|
||||||
|
bw=10, delay='5ms', loss=0, use_htb=True)
|
||||||
|
|
||||||
def perfTest():
|
|
||||||
|
def perfTest( lossy=True ):
|
||||||
"Create network and run simple performance test"
|
"Create network and run simple performance test"
|
||||||
topo = SingleSwitchTopo( n=4 )
|
topo = SingleSwitchTopo( n=4, lossy=lossy )
|
||||||
net = Mininet( topo=topo,
|
net = Mininet( topo=topo,
|
||||||
host=CPULimitedHost, link=TCLink,
|
host=CPULimitedHost, link=TCLink,
|
||||||
autoStaticArp=True )
|
autoStaticArp=True )
|
||||||
@@ -45,4 +53,5 @@ def perfTest():
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
setLogLevel( 'info' )
|
setLogLevel( 'info' )
|
||||||
perfTest()
|
# Prevent test_simpleperf from failing due to packet loss
|
||||||
|
perfTest( lossy=( 'testmode' not in argv ) )
|
||||||
|
|||||||
@@ -16,15 +16,15 @@ class testSimplePerf( unittest.TestCase ):
|
|||||||
@unittest.skipIf( '-quick' in sys.argv, 'long test' )
|
@unittest.skipIf( '-quick' in sys.argv, 'long test' )
|
||||||
def testE2E( self ):
|
def testE2E( self ):
|
||||||
"Run the example and verify iperf results"
|
"Run the example and verify iperf results"
|
||||||
|
# 10 Mb/s, plus or minus 20% tolerance
|
||||||
BW = 10
|
BW = 10
|
||||||
TOLERANCE = .8
|
TOLERANCE = .2
|
||||||
expectedBw = BW * TOLERANCE
|
p = pexpect.spawn( 'python -m mininet.examples.simpleperf testmode' )
|
||||||
p = pexpect.spawn( 'python -m mininet.examples.simpleperf' )
|
|
||||||
# check iperf results
|
# check iperf results
|
||||||
p.expect( "Results: \['10M', '([\d\.]+) .bits/sec", timeout=480 )
|
p.expect( "Results: \['10M', '([\d\.]+) .bits/sec", timeout=480 )
|
||||||
measuredBw = float( p.match.group( 1 ) )
|
measuredBw = float( p.match.group( 1 ) )
|
||||||
lowerBound = expectedBw * TOLERANCE
|
lowerBound = BW * ( 1 - TOLERANCE )
|
||||||
upperBound = expectedBw + expectedBw * ( 1 - TOLERANCE )
|
upperBound = BW + ( 1 + TOLERANCE )
|
||||||
self.assertGreaterEqual( measuredBw, lowerBound )
|
self.assertGreaterEqual( measuredBw, lowerBound )
|
||||||
self.assertLessEqual( measuredBw, upperBound )
|
self.assertLessEqual( measuredBw, upperBound )
|
||||||
p.wait()
|
p.wait()
|
||||||
|
|||||||
Reference in New Issue
Block a user