Rewrite tolerance to be saner (plus or minus 20%)
This commit is contained in:
@@ -13,27 +13,29 @@ class testIntfOptions( unittest.TestCase ):
|
|||||||
def testIntfOptions( self ):
|
def testIntfOptions( self ):
|
||||||
"verify that intf.config is correctly limiting traffic"
|
"verify that intf.config is correctly limiting traffic"
|
||||||
p = pexpect.spawn( 'python -m mininet.examples.intfoptions ' )
|
p = pexpect.spawn( 'python -m mininet.examples.intfoptions ' )
|
||||||
tolerance = .8
|
tolerance = .2 # plus or minus 20%
|
||||||
opts = [ "Results: \['([\d\.]+) .bits/sec",
|
opts = [ "Results: \['([\d\.]+) .bits/sec",
|
||||||
"Results: \['10M', '([\d\.]+) .bits/sec",
|
"Results: \['10M', '([\d\.]+) .bits/sec",
|
||||||
"h(\d+)->h(\d+): (\d)/(\d), rtt min/avg/max/mdev ([\d\.]+)/([\d\.]+)/([\d\.]+)/([\d\.]+) ms",
|
"h(\d+)->h(\d+): (\d)/(\d),"
|
||||||
|
"rtt min/avg/max/mdev ([\d\.]+)/([\d\.]+)/([\d\.]+)/([\d\.]+) ms",
|
||||||
pexpect.EOF ]
|
pexpect.EOF ]
|
||||||
while True:
|
while True:
|
||||||
index = p.expect( opts, timeout=600 )
|
index = p.expect( opts, timeout=600 )
|
||||||
if index == 0:
|
if index == 0:
|
||||||
|
BW = 5
|
||||||
bw = float( p.match.group( 1 ) )
|
bw = float( p.match.group( 1 ) )
|
||||||
self.assertGreaterEqual( bw, float( 5 * tolerance ) )
|
self.assertGreaterEqual( bw, BW * ( 1 - tolerance ) )
|
||||||
self.assertLessEqual( bw, float( 5 + 5 * ( 1 - tolerance ) ) )
|
self.assertLessEqual( bw, BW * ( 1 + tolerance ) )
|
||||||
elif index == 1:
|
elif index == 1:
|
||||||
BW = 10
|
BW = 10
|
||||||
measuredBw = float( p.match.group( 1 ) )
|
measuredBw = float( p.match.group( 1 ) )
|
||||||
loss = ( measuredBw / BW ) * 100
|
loss = ( measuredBw / BW ) * 100
|
||||||
self.assertGreaterEqual( loss, 50 * tolerance )
|
self.assertGreaterEqual( loss, 50 * ( 1 - tolerance ) )
|
||||||
self.assertLessEqual( loss, 50 + 50 * ( 1 - tolerance ) )
|
self.assertLessEqual( loss, 50 * ( 1 + tolerance ) )
|
||||||
elif index == 2:
|
elif index == 2:
|
||||||
delay = float( p.match.group( 6 ) )
|
delay = float( p.match.group( 6 ) )
|
||||||
self.assertGreaterEqual( delay, 15 * tolerance )
|
self.assertGreaterEqual( delay, 15 * ( 1 - tolerance ) )
|
||||||
self.assertLessEqual( delay, 15 + 15 * ( 1 - tolerance ) )
|
self.assertLessEqual( delay, 15 * ( 1 + tolerance ) )
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user