Statistics
| Branch: | Tag: | Revision:

mininet / mininet / test / test_nets.py @ 723d068c

History | View | Annotate | Download (1.89 KB)

1
#!/usr/bin/env python
2
'''@package mininet
3

4
Test creation and all-pairs ping for each included mininet topo type.
5
'''
6

    
7
import unittest
8

    
9
from mininet.net import init, Mininet
10
from mininet.node import KernelSwitch, Host, Controller, ControllerParams
11
from mininet.topo import SingleSwitchTopo, LinearTopo
12

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

    
16

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

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

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

    
40

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

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

    
54

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