Statistics
| Branch: | Tag: | Revision:

mininet / mininet / test / test_nets.py @ d44a5843

History | View | Annotate | Download (1.86 KB)

1 ff43615a Brandon Heller
#!/usr/bin/env python
2
3 235415cf Bob Lantz
"""Package: mininet
4
   Test creation and all-pairs ping for each included mininet topo type."""
5 ff43615a Brandon Heller
6
import unittest
7
8 c98514ae Brandon Heller
from mininet.net import init, Mininet
9 433a7cc8 Brandon Heller
from mininet.node import KernelSwitch, Host, Controller, ControllerParams
10
from mininet.topo import SingleSwitchTopo, LinearTopo
11 8b5062a3 Brandon Heller
12
# temporary, until user-space side is tested
13 235415cf Bob Lantz
SWITCHES = { 'kernel': KernelSwitch }
14 ff43615a Brandon Heller
15 433a7cc8 Brandon Heller
16 235415cf Bob Lantz
class testSingleSwitch( unittest.TestCase ):
17
    "For each datapath type, test ping with single switch topologies."
18 ff43615a Brandon Heller
19 235415cf Bob Lantz
    def testMinimal( self ):
20
        "Ping test with both datapaths on minimal topology"
21 ff43615a Brandon Heller
        init()
22 1bb4412f Brandon Heller
        for switch in SWITCHES.values():
23 d44a5843 Bob Lantz
            controllerParams = ControllerParams( '10.0.0.0', 8 )
24 235415cf Bob Lantz
            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 c98514ae Brandon Heller
        init()
32
        for switch in SWITCHES.values():
33 d44a5843 Bob Lantz
            controllerParams = ControllerParams( '10.0.0.0', 8 )
34 235415cf Bob Lantz
            mn = Mininet( SingleSwitchTopo( k=5 ), switch, Host, Controller,
35
                         controllerParams )
36
            dropped = mn.run( 'ping' )
37
            self.assertEqual( dropped, 0 )
38 c98514ae Brandon Heller
39
40 235415cf Bob Lantz
class testLinear( unittest.TestCase ):
41
    "For each datapath type, test all-pairs ping with LinearNet."
42 c98514ae Brandon Heller
43 235415cf Bob Lantz
    def testLinear5( self ):
44
        "Ping test with both datapaths on a 5-switch topology"
45 c98514ae Brandon Heller
        init()
46
        for switch in SWITCHES.values():
47 d44a5843 Bob Lantz
            controllerParams = ControllerParams( '10.0.0.0', 8 )
48 235415cf Bob Lantz
            mn = Mininet( LinearTopo( k=5 ), switch, Host, Controller,
49
                         controllerParams )
50
            dropped = mn.run( 'ping' )
51
            self.assertEqual( dropped, 0 )
52 ff43615a Brandon Heller
53
54
if __name__ == '__main__':
55 723d068c Brandon Heller
    unittest.main()