Revision 0e2cc609 mininet/test/test_nets.py

View differences:

mininet/test/test_nets.py
7 7

  
8 8
from mininet.net import Mininet
9 9
from mininet.node import Host, Controller
10
from mininet.node import UserSwitch, OVSKernelSwitch
10
from mininet.node import UserSwitch, OVSKernelSwitch, IVSSwitch
11 11
from mininet.topo import SingleSwitchTopo, LinearTopo
12 12
from mininet.log import setLogLevel
13 13

  
14
SWITCHES = { 'user': UserSwitch,
15
             'ovsk': OVSKernelSwitch,
16
}
17 14

  
15
class testSingleSwitchCommon( object ):
16
    "Test ping with single switch topology (common code)."
18 17

  
19
class testSingleSwitch( unittest.TestCase ):
20
    "For each datapath type, test ping with single switch topologies."
18
    switchClass = None # overridden in subclasses
21 19

  
22 20
    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 )
21
        "Ping test on minimal topology"
22
        mn = Mininet( SingleSwitchTopo(), self.switchClass, Host, Controller )
23
        dropped = mn.run( mn.ping )
24
        self.assertEqual( dropped, 0 )
28 25

  
29 26
    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 )
27
        "Ping test on 5-host single-switch topology"
28
        mn = Mininet( SingleSwitchTopo( k=5 ), self.switchClass, Host, Controller )
29
        dropped = mn.run( mn.ping )
30
        self.assertEqual( dropped, 0 )
35 31

  
32
class testSingleSwitchOVSKernel( testSingleSwitchCommon, unittest.TestCase ):
33
    "Test ping with single switch topology (OVS kernel switch)."
34
    switchClass = OVSKernelSwitch
36 35

  
37
class testLinear( unittest.TestCase ):
38
    "For each datapath type, test all-pairs ping with LinearNet."
36
class testSingleSwitchIVS( testSingleSwitchCommon, unittest.TestCase ):
37
    "Test ping with single switch topology (IVS switch)."
38
    switchClass = IVSSwitch
39

  
40
class testSingleSwitchUserspace( testSingleSwitchCommon, unittest.TestCase ):
41
    "Test ping with single switch topology (Userspace switch)."
42
    switchClass = UserSwitch
43

  
44

  
45
class testLinearCommon( object ):
46
    "Test all-pairs ping with LinearNet (common code)."
47

  
48
    switchClass = None # overridden in subclasses
39 49

  
40 50
    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 )
51
        "Ping test on a 5-switch topology"
52
        mn = Mininet( LinearTopo( k=5 ), self.switchClass, Host, Controller )
53
        dropped = mn.run( mn.ping )
54
        self.assertEqual( dropped, 0 )
55

  
56
class testLinearOVSKernel( testLinearCommon, unittest.TestCase ):
57
    "Test all-pairs ping with LinearNet (OVS kernel switch)."
58
    switchClass = OVSKernelSwitch
59

  
60
class testLinearIVS( testLinearCommon, unittest.TestCase ):
61
    "Test all-pairs ping with LinearNet (IVS switch)."
62
    switchClass = IVSSwitch
63

  
64
class testLinearUserspace( testLinearCommon, unittest.TestCase ):
65
    "Test all-pairs ping with LinearNet (Userspace switch)."
66
    switchClass = UserSwitch
46 67

  
47 68

  
48 69
if __name__ == '__main__':

Also available in: Unified diff