Test for simpleperf.py """ import unittest import pexpect import sys from src.mininet.log import setLogLevel class testSimplePerf(unittest.TestCase): @unittest.skipIf('-quick' in sys.argv, 'long test') def testE2E(self): "Run the example and verify iperf results" # 10 Mb/s, plus or minus 20% tolerance BW = 10 TOLERANCE = .2 p = pexpect.spawn('python -m mininet.examples.simpleperf testmode') # check iperf results p.expect("Results: \['10M', '([\d\.]+) .bits/sec", timeout=480) measuredBw = float(p.match.group(1)) lowerBound = BW * (1 - TOLERANCE) upperBound = BW + (1 + TOLERANCE) self.assertGreaterEqual(measuredBw, lowerBound) self.assertLessEqual(measuredBw, upperBound) p.wait() if __name__ == '__main__': setLogLevel('warning') unittest.main()
net.addLink(h4, s1) # specify a different port to connect host 5 to on the switch. net.addLink(h5, s1, port1=1, port2=9) info('*** Starting network\n') net.start() # print the interfaces and their port numbers info('\n*** printing and validating the ports ' 'running on each interface\n') for intfs in s1.intfList(): if not intfs.name == "lo": info(intfs, ': ', s1.ports[intfs], '\n') info('Validating that', intfs, 'is actually on port', s1.ports[intfs], '... ') if validatePort(s1, intfs): info('Validated.\n') print '\n' # test the network with pingall net.pingAll() print '\n' info('*** Stopping network') net.stop() if __name__ == '__main__': setLogLevel('info') testPortNumbering()
hosts1 = [net.addHost('h%d' % n) for n in 3, 4] hosts2 = [net.addHost('h%d' % n) for n in 5, 6] print "*** Creating links" for h in hosts1: net.addLink(s1, h) for h in hosts2: net.addLink(s2, h) net.addLink(s1, s2) print "*** Starting network" net.build() c1.start() c2.start() s1.start([c1]) s2.start([c2]) print "*** Testing network" net.pingAll() print "*** Running CLI" CLI(net) print "*** Stopping network" net.stop() if __name__ == '__main__': setLogLevel('info') # for CLI output multiControllerNet()