Statistics
| Branch: | Tag: | Revision:

mininet / mininet / test / test_nets.py @ d44a5843

History | View | Annotate | Download (1.86 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 init, Mininet
9
from mininet.node import KernelSwitch, Host, Controller, ControllerParams
10
from mininet.topo import SingleSwitchTopo, LinearTopo
11

    
12
# temporary, until user-space side is tested
13
SWITCHES = { 'kernel': KernelSwitch }
14

    
15

    
16
class testSingleSwitch( unittest.TestCase ):
17
    "For each datapath type, test ping with single switch topologies."
18

    
19
    def testMinimal( self ):
20
        "Ping test with both datapaths on minimal topology"
21
        init()
22
        for switch in SWITCHES.values():
23
            controllerParams = ControllerParams( '10.0.0.0', 8 )
24
            mn = Mininet( SingleSwitchTopo(), switch, Host, Controller,
25
                         controllerParams )
26
            dropped = mn.run( 'ping' )
27
            self.assertEqual( dropped, 0 )
28

    
29
    def testSingle5( self ):
30
        "Ping test with both datapaths on 5-host single-switch topology"
31
        init()
32
        for switch in SWITCHES.values():
33
            controllerParams = ControllerParams( '10.0.0.0', 8 )
34
            mn = Mininet( SingleSwitchTopo( k=5 ), switch, Host, Controller,
35
                         controllerParams )
36
            dropped = mn.run( 'ping' )
37
            self.assertEqual( dropped, 0 )
38

    
39

    
40
class testLinear( unittest.TestCase ):
41
    "For each datapath type, test all-pairs ping with LinearNet."
42

    
43
    def testLinear5( self ):
44
        "Ping test with both datapaths on a 5-switch topology"
45
        init()
46
        for switch in SWITCHES.values():
47
            controllerParams = ControllerParams( '10.0.0.0', 8 )
48
            mn = Mininet( LinearTopo( k=5 ), switch, Host, Controller,
49
                         controllerParams )
50
            dropped = mn.run( 'ping' )
51
            self.assertEqual( dropped, 0 )
52

    
53

    
54
if __name__ == '__main__':
55
    unittest.main()