mininet / mininet / test / test_nets.py @ 54932125
History | View | Annotate | Download (3.14 KB)
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 |
from functools import partial |
8 |
|
9 |
from mininet.net import Mininet |
10 |
from mininet.node import Host, Controller |
11 |
from mininet.node import UserSwitch, OVSSwitch, IVSSwitch |
12 |
from mininet.topo import SingleSwitchTopo, LinearTopo |
13 |
from mininet.log import setLogLevel |
14 |
from mininet.util import quietRun |
15 |
|
16 |
|
17 |
class testSingleSwitchCommon( object ): |
18 |
"Test ping with single switch topology (common code)."
|
19 |
|
20 |
switchClass = None # overridden in subclasses |
21 |
|
22 |
def testMinimal( self ): |
23 |
"Ping test on minimal topology"
|
24 |
mn = Mininet( SingleSwitchTopo(), self.switchClass, Host, Controller )
|
25 |
dropped = mn.run( mn.ping ) |
26 |
self.assertEqual( dropped, 0 ) |
27 |
|
28 |
def testSingle5( self ): |
29 |
"Ping test on 5-host single-switch topology"
|
30 |
mn = Mininet( SingleSwitchTopo( k=5 ), self.switchClass, Host, Controller ) |
31 |
dropped = mn.run( mn.ping ) |
32 |
self.assertEqual( dropped, 0 ) |
33 |
|
34 |
class testSingleSwitchOVSKernel( testSingleSwitchCommon, unittest.TestCase ): |
35 |
"Test ping with single switch topology (OVS kernel switch)."
|
36 |
switchClass = OVSSwitch |
37 |
|
38 |
class testSingleSwitchOVSUser( testSingleSwitchCommon, unittest.TestCase ): |
39 |
"Test ping with single switch topology (OVS user switch)."
|
40 |
switchClass = partial( OVSSwitch, datapath='user' )
|
41 |
|
42 |
@unittest.skipUnless( quietRun( 'which ivs-ctl' ), 'IVS is not installed' ) |
43 |
class testSingleSwitchIVS( testSingleSwitchCommon, unittest.TestCase ): |
44 |
"Test ping with single switch topology (IVS switch)."
|
45 |
switchClass = IVSSwitch |
46 |
|
47 |
@unittest.skipUnless( quietRun( 'which ofprotocol' ), |
48 |
'Reference user switch is not installed' )
|
49 |
class testSingleSwitchUserspace( testSingleSwitchCommon, unittest.TestCase ): |
50 |
"Test ping with single switch topology (Userspace switch)."
|
51 |
switchClass = UserSwitch |
52 |
|
53 |
|
54 |
class testLinearCommon( object ): |
55 |
"Test all-pairs ping with LinearNet (common code)."
|
56 |
|
57 |
switchClass = None # overridden in subclasses |
58 |
|
59 |
def testLinear5( self ): |
60 |
"Ping test on a 5-switch topology"
|
61 |
mn = Mininet( LinearTopo( k=5 ), self.switchClass, Host, Controller ) |
62 |
dropped = mn.run( mn.ping ) |
63 |
self.assertEqual( dropped, 0 ) |
64 |
|
65 |
|
66 |
class testLinearOVSKernel( testLinearCommon, unittest.TestCase ): |
67 |
"Test all-pairs ping with LinearNet (OVS kernel switch)."
|
68 |
switchClass = OVSSwitch |
69 |
|
70 |
class testLinearOVSUser( testLinearCommon, unittest.TestCase ): |
71 |
"Test all-pairs ping with LinearNet (OVS user switch)."
|
72 |
switchClass = partial( OVSSwitch, datapath='user' )
|
73 |
|
74 |
@unittest.skipUnless( quietRun( 'which ivs-ctl' ), 'IVS is not installed' ) |
75 |
class testLinearIVS( testLinearCommon, unittest.TestCase ): |
76 |
"Test all-pairs ping with LinearNet (IVS switch)."
|
77 |
switchClass = IVSSwitch |
78 |
|
79 |
@unittest.skipUnless( quietRun( 'which ofprotocol' ), |
80 |
'Reference user switch is not installed' )
|
81 |
class testLinearUserspace( testLinearCommon, unittest.TestCase ): |
82 |
"Test all-pairs ping with LinearNet (Userspace switch)."
|
83 |
switchClass = UserSwitch |
84 |
|
85 |
|
86 |
if __name__ == '__main__': |
87 |
setLogLevel( 'warning' )
|
88 |
unittest.main() |