Revision 0e2cc609

View differences:

mininet/test/test_hifi.py
6 6
import unittest
7 7

  
8 8
from mininet.net import Mininet
9
from mininet.node import OVSKernelSwitch
9
from mininet.node import OVSKernelSwitch, UserSwitch, IVSSwitch
10 10
from mininet.node import CPULimitedHost
11 11
from mininet.link import TCLink
12 12
from mininet.topo import Topo
13 13
from mininet.log import setLogLevel
14 14

  
15

  
16
SWITCH = OVSKernelSwitch
17 15
# Number of hosts for each test
18 16
N = 2
19 17

  
......
32 30
            self.addLink(host, switch)
33 31

  
34 32

  
35
class testOptionsTopo( unittest.TestCase ):
36
    "Verify ability to create networks with host and link options."
33
class testOptionsTopoCommon( object ):
34
    "Verify ability to create networks with host and link options (common code)."
35

  
36
    switchClass = None # overridden in subclasses
37 37

  
38 38
    def runOptionsTopoTest( self, n, hopts=None, lopts=None ):
39 39
        "Generic topology-with-options test runner."
40 40
        mn = Mininet( topo=SingleSwitchOptionsTopo( n=n, hopts=hopts,
41 41
                                                    lopts=lopts ),
42
                      host=CPULimitedHost, link=TCLink, switch=SWITCH )
42
                      host=CPULimitedHost, link=TCLink, switch=self.switchClass )
43 43
        dropped = mn.run( mn.ping )
44 44
        self.assertEqual( dropped, 0 )
45 45

  
......
58 58
        #self.runOptionsTopoTest( N, hopts=hopts )
59 59

  
60 60
        mn = Mininet( SingleSwitchOptionsTopo( n=N, hopts=hopts ),
61
                      host=CPULimitedHost, switch=SWITCH )
61
                      host=CPULimitedHost, switch=self.switchClass )
62 62
        mn.start()
63 63
        results = mn.runCpuLimitTest( cpu=CPU_FRACTION )
64 64
        mn.stop()
......
73 73
        lopts = { 'bw': BW, 'use_htb': True }
74 74
        # Also verify correctness of limit limitng within a bound.
75 75
        mn = Mininet( SingleSwitchOptionsTopo( n=N, lopts=lopts ),
76
                      link=TCLink, switch=SWITCH )
76
                      link=TCLink, switch=self.switchClass )
77 77
        bw_strs = mn.run( mn.iperf )
78 78
        for bw_str in bw_strs:
79 79
            bw = float( bw_str.split(' ')[0] )
......
85 85
        DELAY_TOLERANCE = 0.8  # Delay fraction below which test should fail
86 86
        lopts = { 'delay': '%sms' % DELAY_MS, 'use_htb': True }
87 87
        mn = Mininet( SingleSwitchOptionsTopo( n=N, lopts=lopts ),
88
                      link=TCLink, switch=SWITCH )
88
                      link=TCLink, switch=self.switchClass )
89 89
        ping_delays = mn.run( mn.pingFull )
90 90
        test_outputs = ping_delays[0]
91 91
        # Ignore unused variables below
......
105 105
        REPS = 1
106 106
        lopts = { 'loss': LOSS_PERCENT, 'use_htb': True }
107 107
        mn = Mininet( topo=SingleSwitchOptionsTopo( n=N, lopts=lopts ),
108
                      host=CPULimitedHost, link=TCLink, switch=SWITCH )
108
                      host=CPULimitedHost, link=TCLink, switch=self.switchClass )
109 109
        # Drops are probabilistic, but the chance of no dropped packets is
110 110
        # 1 in 100 million with 4 hops for a link w/99% loss.
111 111
        dropped_total = 0
......
121 121
        hopts = { 'cpu': 0.5 / N }
122 122
        self.runOptionsTopoTest( N, hopts=hopts, lopts=lopts )
123 123

  
124
class testOptionsTopoOVSKernel( testOptionsTopoCommon, unittest.TestCase ):
125
    "Verify ability to create networks with host and link options (OVS kernel switch)."
126
    switchClass = OVSKernelSwitch
127

  
128
class testOptionsTopoIVS( testOptionsTopoCommon, unittest.TestCase ):
129
    "Verify ability to create networks with host and link options (IVS switch)."
130
    switchClass = IVSSwitch
131

  
132
class testOptionsTopoUserspace( testOptionsTopoCommon, unittest.TestCase ):
133
    "Verify ability to create networks with host and link options (Userspace switch)."
134
    switchClass = UserSwitch
124 135

  
125 136
if __name__ == '__main__':
126 137
    setLogLevel( 'warning' )
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