carlosmscabral | f40ecd1 | 2013-02-01 18:15:58 -0200 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | """Package: mininet |
| 4 | Test creation and all-pairs ping for each included mininet topo type.""" |
| 5 | |
| 6 | import unittest |
| 7 | |
| 8 | from mininet.net import Mininet |
| 9 | from mininet.node import Host, Controller |
| 10 | from mininet.node import UserSwitch, OVSKernelSwitch |
| 11 | from mininet.topo import SingleSwitchTopo, LinearTopo |
| 12 | from mininet.log import setLogLevel |
| 13 | |
| 14 | SWITCHES = { 'user': UserSwitch, |
| 15 | 'ovsk': OVSKernelSwitch, |
| 16 | } |
| 17 | |
| 18 | |
| 19 | class testSingleSwitch( unittest.TestCase ): |
| 20 | "For each datapath type, test ping with single switch topologies." |
| 21 | |
| 22 | def testMinimal( self ): |
| 23 | "Ping test with both datapaths on minimal topology" |
| 24 | for switch in SWITCHES.values(): |
| 25 | mn = Mininet( SingleSwitchTopo(), switch, Host, Controller ) |
| 26 | dropped = mn.run( mn.ping ) |
| 27 | self.assertEqual( dropped, 0 ) |
| 28 | |
| 29 | def testSingle5( self ): |
| 30 | "Ping test with both datapaths on 5-host single-switch topology" |
| 31 | for switch in SWITCHES.values(): |
| 32 | mn = Mininet( SingleSwitchTopo( k=5 ), switch, Host, Controller ) |
| 33 | dropped = mn.run( mn.ping ) |
| 34 | self.assertEqual( dropped, 0 ) |
| 35 | |
| 36 | |
| 37 | class testLinear( unittest.TestCase ): |
| 38 | "For each datapath type, test all-pairs ping with LinearNet." |
| 39 | |
| 40 | def testLinear5( self ): |
| 41 | "Ping test with both datapaths on a 5-switch topology" |
| 42 | for switch in SWITCHES.values(): |
| 43 | mn = Mininet( LinearTopo( k=5 ), switch, Host, Controller ) |
| 44 | dropped = mn.run( mn.ping ) |
| 45 | self.assertEqual( dropped, 0 ) |
| 46 | |
| 47 | |
| 48 | if __name__ == '__main__': |
| 49 | setLogLevel( 'warning' ) |
| 50 | unittest.main() |