Statistics
| Branch: | Tag: | Revision:

mininet / mininet / test / test_nets.py @ 0e2cc609

History | View | Annotate | Download (2.35 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

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

    
14

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

    
18
    switchClass = None # overridden in subclasses
19

    
20
    def testMinimal( self ):
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 )
25

    
26
    def testSingle5( self ):
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 )
31

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

    
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
49

    
50
    def testLinear5( self ):
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
67

    
68

    
69
if __name__ == '__main__':
70
    setLogLevel( 'warning' )
71
    unittest.main()