Merge pull request #318 from cdburkard/patches/hifi_fix
added support in iperf for different result formats.
This commit is contained in:
+3
-1
@@ -651,7 +651,7 @@ class Mininet( object ):
|
|||||||
|
|
||||||
# XXX This should be cleaned up
|
# XXX This should be cleaned up
|
||||||
|
|
||||||
def iperf( self, hosts=None, l4Type='TCP', udpBw='10M' ):
|
def iperf( self, hosts=None, l4Type='TCP', udpBw='10M', format=None ):
|
||||||
"""Run iperf between two hosts.
|
"""Run iperf between two hosts.
|
||||||
hosts: list of hosts; if None, uses opposite hosts
|
hosts: list of hosts; if None, uses opposite hosts
|
||||||
l4Type: string, one of [ TCP, UDP ]
|
l4Type: string, one of [ TCP, UDP ]
|
||||||
@@ -674,6 +674,8 @@ class Mininet( object ):
|
|||||||
bwArgs = '-b ' + udpBw + ' '
|
bwArgs = '-b ' + udpBw + ' '
|
||||||
elif l4Type != 'TCP':
|
elif l4Type != 'TCP':
|
||||||
raise Exception( 'Unexpected l4 type: %s' % l4Type )
|
raise Exception( 'Unexpected l4 type: %s' % l4Type )
|
||||||
|
if format:
|
||||||
|
iperfArgs += '-f %s ' %format
|
||||||
server.sendCmd( iperfArgs + '-s', printPid=True )
|
server.sendCmd( iperfArgs + '-s', printPid=True )
|
||||||
servout = ''
|
servout = ''
|
||||||
while server.lastPid is None:
|
while server.lastPid is None:
|
||||||
|
|||||||
@@ -55,6 +55,9 @@ class testOptionsTopoCommon( object ):
|
|||||||
"""
|
"""
|
||||||
self.assertGreaterEqual( float(measured),
|
self.assertGreaterEqual( float(measured),
|
||||||
float(expected) * tolerance_frac )
|
float(expected) * tolerance_frac )
|
||||||
|
self.assertLessEqual( float( measured ),
|
||||||
|
float(expected) + (1-tolerance_frac)
|
||||||
|
* float( expected ) )
|
||||||
|
|
||||||
def testCPULimits( self ):
|
def testCPULimits( self ):
|
||||||
"Verify topology creation with CPU limits set for both schedulers."
|
"Verify topology creation with CPU limits set for both schedulers."
|
||||||
@@ -68,19 +71,20 @@ class testOptionsTopoCommon( object ):
|
|||||||
mn.start()
|
mn.start()
|
||||||
results = mn.runCpuLimitTest( cpu=CPU_FRACTION )
|
results = mn.runCpuLimitTest( cpu=CPU_FRACTION )
|
||||||
mn.stop()
|
mn.stop()
|
||||||
for cpu in results:
|
for pct in results:
|
||||||
self.assertWithinTolerance( cpu, CPU_FRACTION, CPU_TOLERANCE )
|
#divide cpu by 100 to convert from percentage to fraction
|
||||||
|
self.assertWithinTolerance( pct/100, CPU_FRACTION, CPU_TOLERANCE )
|
||||||
|
|
||||||
def testLinkBandwidth( self ):
|
def testLinkBandwidth( self ):
|
||||||
"Verify that link bandwidths are accurate within a bound."
|
"Verify that link bandwidths are accurate within a bound."
|
||||||
BW = 5 # Mbps
|
BW = .5 # Mbps
|
||||||
BW_TOLERANCE = 0.8 # BW fraction below which test should fail
|
BW_TOLERANCE = 0.8 # BW fraction below which test should fail
|
||||||
# Verify ability to create limited-link topo first;
|
# Verify ability to create limited-link topo first;
|
||||||
lopts = { 'bw': BW, 'use_htb': True }
|
lopts = { 'bw': BW, 'use_htb': True }
|
||||||
# Also verify correctness of limit limitng within a bound.
|
# Also verify correctness of limit limitng within a bound.
|
||||||
mn = Mininet( SingleSwitchOptionsTopo( n=N, lopts=lopts ),
|
mn = Mininet( SingleSwitchOptionsTopo( n=N, lopts=lopts ),
|
||||||
link=TCLink, switch=self.switchClass )
|
link=TCLink, switch=self.switchClass )
|
||||||
bw_strs = mn.run( mn.iperf )
|
bw_strs = mn.run( mn.iperf, format='m' )
|
||||||
for bw_str in bw_strs:
|
for bw_str in bw_strs:
|
||||||
bw = float( bw_str.split(' ')[0] )
|
bw = float( bw_str.split(' ')[0] )
|
||||||
self.assertWithinTolerance( bw, BW, BW_TOLERANCE )
|
self.assertWithinTolerance( bw, BW, BW_TOLERANCE )
|
||||||
@@ -91,7 +95,7 @@ class testOptionsTopoCommon( object ):
|
|||||||
DELAY_TOLERANCE = 0.8 # Delay fraction below which test should fail
|
DELAY_TOLERANCE = 0.8 # Delay fraction below which test should fail
|
||||||
lopts = { 'delay': '%sms' % DELAY_MS, 'use_htb': True }
|
lopts = { 'delay': '%sms' % DELAY_MS, 'use_htb': True }
|
||||||
mn = Mininet( SingleSwitchOptionsTopo( n=N, lopts=lopts ),
|
mn = Mininet( SingleSwitchOptionsTopo( n=N, lopts=lopts ),
|
||||||
link=TCLink, switch=self.switchClass )
|
link=TCLink, switch=self.switchClass, autoStaticArp=True )
|
||||||
ping_delays = mn.run( mn.pingFull )
|
ping_delays = mn.run( mn.pingFull )
|
||||||
test_outputs = ping_delays[0]
|
test_outputs = ping_delays[0]
|
||||||
# Ignore unused variables below
|
# Ignore unused variables below
|
||||||
@@ -105,6 +109,7 @@ class testOptionsTopoCommon( object ):
|
|||||||
self.assertWithinTolerance( rttval, DELAY_MS * 4.0,
|
self.assertWithinTolerance( rttval, DELAY_MS * 4.0,
|
||||||
DELAY_TOLERANCE)
|
DELAY_TOLERANCE)
|
||||||
|
|
||||||
|
|
||||||
def testLinkLoss( self ):
|
def testLinkLoss( self ):
|
||||||
"Verify that we see packet drops with a high configured loss rate."
|
"Verify that we see packet drops with a high configured loss rate."
|
||||||
LOSS_PERCENT = 99
|
LOSS_PERCENT = 99
|
||||||
|
|||||||
Reference in New Issue
Block a user