def limit( bw=10, cpu=.1 ): """Example/test of link and CPU bandwidth limits bw: interface bandwidth limit in Mbps cpu: cpu limit as fraction of overall CPU time""" intf = custom( TCIntf, bw=bw ) myTopo = TreeTopo( depth=1, fanout=2 ) for sched in 'rt', 'cfs': print '*** Testing with', sched, 'bandwidth limiting' host = custom( CPULimitedHost, sched=sched, cpu=cpu ) net = Mininet( topo=myTopo, intf=intf, host=host ) net.start() testLinkLimit( net, bw=bw ) net.runCpuLimitTest( cpu=cpu ) net.stop()
def limit(bw=10, cpu=.1): """Example/test of link and CPU bandwidth limits bw: interface bandwidth limit in Mbps cpu: cpu limit as fraction of overall CPU time""" intf = custom(TCIntf, bw=bw) myTopo = TreeTopo(depth=1, fanout=2) for sched in 'rt', 'cfs': print '*** Testing with', sched, 'bandwidth limiting' host = custom(CPULimitedHost, sched=sched, cpu=cpu) net = Mininet(topo=myTopo, intf=intf, host=host) net.start() testLinkLimit(net, bw=bw) net.runCpuLimitTest(cpu=cpu) net.stop()
def testCPULimits(self): "Verify topology creation with CPU limits set for both schedulers." CPU_FRACTION = 0.1 CPU_TOLERANCE = 0.8 # CPU fraction below which test should fail hopts = {'cpu': CPU_FRACTION} #self.runOptionsTopoTest( N, hopts=hopts ) mn = Mininet(SingleSwitchOptionsTopo(n=N, hopts=hopts), host=CPULimitedHost, switch=self.switchClass, waitConnected=True) mn.start() results = mn.runCpuLimitTest(cpu=CPU_FRACTION) mn.stop() hostUsage = '\n'.join('h%s: %s' % (n + 1, results[(n - 1) * 5:(n * 5) - 1]) for n in range(N)) hoptsStr = ', '.join('%s: %s' % (opt, value) for opt, value in hopts.items()) msg = ('\nTesting cpu limited to %d%% of cpu per host\n' 'cpu usage percent per host:\n%s\n' 'Topo = SingleSwitchTopo, %s hosts\n' 'hopts = %s\n' 'host = CPULimitedHost\n' 'Switch = %s\n' % (CPU_FRACTION * 100, hostUsage, N, hoptsStr, self.switchClass)) for pct in results: #divide cpu by 100 to convert from percentage to fraction self.assertWithinTolerance(pct / 100, CPU_FRACTION, CPU_TOLERANCE, msg)
def testCPULimits( self ): "Verify topology creation with CPU limits set for both schedulers." CPU_FRACTION = 0.1 CPU_TOLERANCE = 0.8 # CPU fraction below which test should fail hopts = { 'cpu': CPU_FRACTION } #self.runOptionsTopoTest( N, hopts=hopts ) mn = Mininet( SingleSwitchOptionsTopo( n=N, hopts=hopts ), host=CPULimitedHost, switch=self.switchClass, waitConnected=True ) mn.start() results = mn.runCpuLimitTest( cpu=CPU_FRACTION ) mn.stop() hostUsage = '\n'.join( 'h%s: %s' % ( n + 1, results[ (n - 1) * 5 : (n * 5) - 1 ] ) for n in range( N ) ) hoptsStr = ', '.join( '%s: %s' % ( opt, value ) for opt, value in hopts.items() ) msg = ( '\nTesting cpu limited to %d%% of cpu per host\n' 'cpu usage percent per host:\n%s\n' 'Topo = SingleSwitchTopo, %s hosts\n' 'hopts = %s\n' 'host = CPULimitedHost\n' 'Switch = %s\n' % ( CPU_FRACTION * 100, hostUsage, N, hoptsStr, self.switchClass ) ) for pct in results: #divide cpu by 100 to convert from percentage to fraction self.assertWithinTolerance( pct/100, CPU_FRACTION, CPU_TOLERANCE, msg )
def limit( bw=10, cpu=.1 ): """Example/test of link and CPU bandwidth limits bw: interface bandwidth limit in Mbps cpu: cpu limit as fraction of overall CPU time""" intf = custom( TCIntf, bw=bw ) myTopo = TreeTopo( depth=1, fanout=2 ) for sched in 'rt', 'cfs': info( '*** Testing with', sched, 'bandwidth limiting\n' ) if sched == 'rt': release = quietRun( 'uname -r' ).strip('\r\n') output = quietRun( 'grep CONFIG_RT_GROUP_SCHED /boot/config-%s' % release ) if output == '# CONFIG_RT_GROUP_SCHED is not set\n': info( '*** RT Scheduler is not enabled in your kernel. Skipping this test\n' ) continue host = custom( CPULimitedHost, sched=sched, cpu=cpu ) net = Mininet( topo=myTopo, intf=intf, host=host ) net.start() testLinkLimit( net, bw=bw ) net.runCpuLimitTest( cpu=cpu ) net.stop()
def testCPULimits(self): "Verify topology creation with CPU limits set for both schedulers." CPU_FRACTION = 0.1 CPU_TOLERANCE = 0.8 # CPU fraction below which test should fail hopts = {"cpu": CPU_FRACTION} # self.runOptionsTopoTest( N, hopts=hopts ) mn = Mininet(SingleSwitchOptionsTopo(n=N, hopts=hopts), host=CPULimitedHost) mn.start() results = mn.runCpuLimitTest(cpu=CPU_FRACTION) mn.stop() for cpu in results: self.assertWithinTolerance(cpu, CPU_FRACTION, CPU_TOLERANCE)
def limit(bw=10, cpu=.1): """Example/test of link and CPU bandwidth limits bw: interface bandwidth limit in Mbps cpu: cpu limit as fraction of overall CPU time""" intf = custom(TCIntf, bw=bw) myTopo = TreeTopo(depth=1, fanout=2) for sched in 'rt', 'cfs': info('*** Testing with', sched, 'bandwidth limiting\n') if sched == 'rt': release = quietRun('uname -r').strip('\r\n') output = quietRun('grep CONFIG_RT_GROUP_SCHED /boot/config-%s' % release) if output == '# CONFIG_RT_GROUP_SCHED is not set\n': info('*** RT Scheduler is not enabled in your kernel. ' 'Skipping this test\n') continue host = custom(CPULimitedHost, sched=sched, cpu=cpu) net = Mininet(topo=myTopo, intf=intf, host=host, waitConnected=True) net.start() testLinkLimit(net, bw=bw) net.runCpuLimitTest(cpu=cpu) net.stop()
def testCPULimits( self ): "Verify topology creation with CPU limits set for both schedulers." CPU_FRACTION = 0.1 CPU_TOLERANCE = 0.8 # CPU fraction below which test should fail hopts = { 'cpu': CPU_FRACTION } #self.runOptionsTopoTest( N, hopts=hopts ) mn = Mininet( SingleSwitchOptionsTopo( n=N, hopts=hopts ), host=CPULimitedHost, switch=self.switchClass ) mn.start() results = mn.runCpuLimitTest( cpu=CPU_FRACTION ) mn.stop() for cpu in results: self.assertWithinTolerance( cpu, CPU_FRACTION, CPU_TOLERANCE )
def testCPULimits( self ): "Verify topology creation with CPU limits set for both schedulers." CPU_FRACTION = 0.1 CPU_TOLERANCE = 0.8 # CPU fraction below which test should fail hopts = { 'cpu': CPU_FRACTION } #self.runOptionsTopoTest( N, hopts=hopts ) mn = Mininet( SingleSwitchOptionsTopo( n=N, hopts=hopts ), host=CPULimitedHost, switch=self.switchClass ) mn.start() results = mn.runCpuLimitTest( cpu=CPU_FRACTION ) mn.stop() for pct in results: #divide cpu by 100 to convert from percentage to fraction self.assertWithinTolerance( pct/100, CPU_FRACTION, CPU_TOLERANCE )