Revision 0e2cc609 mininet/test/test_hifi.py

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' )

Also available in: Unified diff