tests: run all tests with OVS, IVS, and userspace switches

Each switch gets its own class so that the test results are listed separately.
This commit is contained in:
Rich Lane
2013-07-10 11:19:25 -07:00
parent 60abb34497
commit 0e2cc609df
2 changed files with 65 additions and 33 deletions
+21 -10
View File
@@ -6,14 +6,12 @@
import unittest import unittest
from mininet.net import Mininet from mininet.net import Mininet
from mininet.node import OVSKernelSwitch from mininet.node import OVSKernelSwitch, UserSwitch, IVSSwitch
from mininet.node import CPULimitedHost from mininet.node import CPULimitedHost
from mininet.link import TCLink from mininet.link import TCLink
from mininet.topo import Topo from mininet.topo import Topo
from mininet.log import setLogLevel from mininet.log import setLogLevel
SWITCH = OVSKernelSwitch
# Number of hosts for each test # Number of hosts for each test
N = 2 N = 2
@@ -32,14 +30,16 @@ class SingleSwitchOptionsTopo(Topo):
self.addLink(host, switch) self.addLink(host, switch)
class testOptionsTopo( unittest.TestCase ): class testOptionsTopoCommon( object ):
"Verify ability to create networks with host and link options." "Verify ability to create networks with host and link options (common code)."
switchClass = None # overridden in subclasses
def runOptionsTopoTest( self, n, hopts=None, lopts=None ): def runOptionsTopoTest( self, n, hopts=None, lopts=None ):
"Generic topology-with-options test runner." "Generic topology-with-options test runner."
mn = Mininet( topo=SingleSwitchOptionsTopo( n=n, hopts=hopts, mn = Mininet( topo=SingleSwitchOptionsTopo( n=n, hopts=hopts,
lopts=lopts ), lopts=lopts ),
host=CPULimitedHost, link=TCLink, switch=SWITCH ) host=CPULimitedHost, link=TCLink, switch=self.switchClass )
dropped = mn.run( mn.ping ) dropped = mn.run( mn.ping )
self.assertEqual( dropped, 0 ) self.assertEqual( dropped, 0 )
@@ -58,7 +58,7 @@ class testOptionsTopo( unittest.TestCase ):
#self.runOptionsTopoTest( N, hopts=hopts ) #self.runOptionsTopoTest( N, hopts=hopts )
mn = Mininet( SingleSwitchOptionsTopo( n=N, hopts=hopts ), mn = Mininet( SingleSwitchOptionsTopo( n=N, hopts=hopts ),
host=CPULimitedHost, switch=SWITCH ) host=CPULimitedHost, switch=self.switchClass )
mn.start() mn.start()
results = mn.runCpuLimitTest( cpu=CPU_FRACTION ) results = mn.runCpuLimitTest( cpu=CPU_FRACTION )
mn.stop() mn.stop()
@@ -73,7 +73,7 @@ class testOptionsTopo( unittest.TestCase ):
lopts = { 'bw': BW, 'use_htb': True } lopts = { 'bw': BW, 'use_htb': True }
# Also verify correctness of limit limitng within a bound. # Also verify correctness of limit limitng within a bound.
mn = Mininet( SingleSwitchOptionsTopo( n=N, lopts=lopts ), mn = Mininet( SingleSwitchOptionsTopo( n=N, lopts=lopts ),
link=TCLink, switch=SWITCH ) link=TCLink, switch=self.switchClass )
bw_strs = mn.run( mn.iperf ) bw_strs = mn.run( mn.iperf )
for bw_str in bw_strs: for bw_str in bw_strs:
bw = float( bw_str.split(' ')[0] ) bw = float( bw_str.split(' ')[0] )
@@ -85,7 +85,7 @@ class testOptionsTopo( unittest.TestCase ):
DELAY_TOLERANCE = 0.8 # Delay fraction below which test should fail DELAY_TOLERANCE = 0.8 # Delay fraction below which test should fail
lopts = { 'delay': '%sms' % DELAY_MS, 'use_htb': True } lopts = { 'delay': '%sms' % DELAY_MS, 'use_htb': True }
mn = Mininet( SingleSwitchOptionsTopo( n=N, lopts=lopts ), mn = Mininet( SingleSwitchOptionsTopo( n=N, lopts=lopts ),
link=TCLink, switch=SWITCH ) link=TCLink, switch=self.switchClass )
ping_delays = mn.run( mn.pingFull ) ping_delays = mn.run( mn.pingFull )
test_outputs = ping_delays[0] test_outputs = ping_delays[0]
# Ignore unused variables below # Ignore unused variables below
@@ -105,7 +105,7 @@ class testOptionsTopo( unittest.TestCase ):
REPS = 1 REPS = 1
lopts = { 'loss': LOSS_PERCENT, 'use_htb': True } lopts = { 'loss': LOSS_PERCENT, 'use_htb': True }
mn = Mininet( topo=SingleSwitchOptionsTopo( n=N, lopts=lopts ), mn = Mininet( topo=SingleSwitchOptionsTopo( n=N, lopts=lopts ),
host=CPULimitedHost, link=TCLink, switch=SWITCH ) host=CPULimitedHost, link=TCLink, switch=self.switchClass )
# Drops are probabilistic, but the chance of no dropped packets is # Drops are probabilistic, but the chance of no dropped packets is
# 1 in 100 million with 4 hops for a link w/99% loss. # 1 in 100 million with 4 hops for a link w/99% loss.
dropped_total = 0 dropped_total = 0
@@ -121,6 +121,17 @@ class testOptionsTopo( unittest.TestCase ):
hopts = { 'cpu': 0.5 / N } hopts = { 'cpu': 0.5 / N }
self.runOptionsTopoTest( N, hopts=hopts, lopts=lopts ) self.runOptionsTopoTest( N, hopts=hopts, lopts=lopts )
class testOptionsTopoOVSKernel( testOptionsTopoCommon, unittest.TestCase ):
"Verify ability to create networks with host and link options (OVS kernel switch)."
switchClass = OVSKernelSwitch
class testOptionsTopoIVS( testOptionsTopoCommon, unittest.TestCase ):
"Verify ability to create networks with host and link options (IVS switch)."
switchClass = IVSSwitch
class testOptionsTopoUserspace( testOptionsTopoCommon, unittest.TestCase ):
"Verify ability to create networks with host and link options (Userspace switch)."
switchClass = UserSwitch
if __name__ == '__main__': if __name__ == '__main__':
setLogLevel( 'warning' ) setLogLevel( 'warning' )
+38 -17
View File
@@ -7,43 +7,64 @@ import unittest
from mininet.net import Mininet from mininet.net import Mininet
from mininet.node import Host, Controller from mininet.node import Host, Controller
from mininet.node import UserSwitch, OVSKernelSwitch from mininet.node import UserSwitch, OVSKernelSwitch, IVSSwitch
from mininet.topo import SingleSwitchTopo, LinearTopo from mininet.topo import SingleSwitchTopo, LinearTopo
from mininet.log import setLogLevel from mininet.log import setLogLevel
SWITCHES = { 'user': UserSwitch,
'ovsk': OVSKernelSwitch,
}
class testSingleSwitchCommon( object ):
"Test ping with single switch topology (common code)."
class testSingleSwitch( unittest.TestCase ): switchClass = None # overridden in subclasses
"For each datapath type, test ping with single switch topologies."
def testMinimal( self ): def testMinimal( self ):
"Ping test with both datapaths on minimal topology" "Ping test on minimal topology"
for switch in SWITCHES.values(): mn = Mininet( SingleSwitchTopo(), self.switchClass, Host, Controller )
mn = Mininet( SingleSwitchTopo(), switch, Host, Controller )
dropped = mn.run( mn.ping ) dropped = mn.run( mn.ping )
self.assertEqual( dropped, 0 ) self.assertEqual( dropped, 0 )
def testSingle5( self ): def testSingle5( self ):
"Ping test with both datapaths on 5-host single-switch topology" "Ping test on 5-host single-switch topology"
for switch in SWITCHES.values(): mn = Mininet( SingleSwitchTopo( k=5 ), self.switchClass, Host, Controller )
mn = Mininet( SingleSwitchTopo( k=5 ), switch, Host, Controller )
dropped = mn.run( mn.ping ) dropped = mn.run( mn.ping )
self.assertEqual( dropped, 0 ) self.assertEqual( dropped, 0 )
class testSingleSwitchOVSKernel( testSingleSwitchCommon, unittest.TestCase ):
"Test ping with single switch topology (OVS kernel switch)."
switchClass = OVSKernelSwitch
class testLinear( unittest.TestCase ): class testSingleSwitchIVS( testSingleSwitchCommon, unittest.TestCase ):
"For each datapath type, test all-pairs ping with LinearNet." "Test ping with single switch topology (IVS switch)."
switchClass = IVSSwitch
class testSingleSwitchUserspace( testSingleSwitchCommon, unittest.TestCase ):
"Test ping with single switch topology (Userspace switch)."
switchClass = UserSwitch
class testLinearCommon( object ):
"Test all-pairs ping with LinearNet (common code)."
switchClass = None # overridden in subclasses
def testLinear5( self ): def testLinear5( self ):
"Ping test with both datapaths on a 5-switch topology" "Ping test on a 5-switch topology"
for switch in SWITCHES.values(): mn = Mininet( LinearTopo( k=5 ), self.switchClass, Host, Controller )
mn = Mininet( LinearTopo( k=5 ), switch, Host, Controller )
dropped = mn.run( mn.ping ) dropped = mn.run( mn.ping )
self.assertEqual( dropped, 0 ) self.assertEqual( dropped, 0 )
class testLinearOVSKernel( testLinearCommon, unittest.TestCase ):
"Test all-pairs ping with LinearNet (OVS kernel switch)."
switchClass = OVSKernelSwitch
class testLinearIVS( testLinearCommon, unittest.TestCase ):
"Test all-pairs ping with LinearNet (IVS switch)."
switchClass = IVSSwitch
class testLinearUserspace( testLinearCommon, unittest.TestCase ):
"Test all-pairs ping with LinearNet (Userspace switch)."
switchClass = UserSwitch
if __name__ == '__main__': if __name__ == '__main__':
setLogLevel( 'warning' ) setLogLevel( 'warning' )