8 from mininet.util import pexpect
10 class testControlNet( unittest.TestCase ):
14 def testPingall( self ):
15 "Simple pingall test that verifies 0% packet drop in data network"
16 p = pexpect.spawn( 'python -m mininet.examples.controlnet' )
17 p.expect( self.prompt )
18 p.sendline( 'pingall' )
19 p.expect ( '(\d+)% dropped' )
20 percent = int( p.match.group( 1 ) ) if p.match else -1
21 self.assertEqual( percent, 0 )
22 p.expect( self.prompt )
26 def testFailover( self ):
27 "Kill controllers and verify that switch, s1, fails over properly"
29 p = pexpect.spawn( 'python -m mininet.examples.controlnet' )
30 p.expect( self.prompt )
31 lp = pexpect.spawn( 'tail -f /tmp/s1-ofp.log' )
32 lp.expect( 'tcp:\d+\.\d+\.\d+\.(\d+):\d+: connected' )
33 ip = int( lp.match.group( 1 ) )
34 self.assertEqual( count, ip )
36 for c in [ 'c0', 'c1' ]:
37 p.sendline( '%s ifconfig %s-eth0 down' % ( c, c) )
38 p.expect( self.prompt )
39 lp.expect( 'tcp:\d+\.\d+\.\d+\.(\d+):\d+: connected' )
40 ip = int( lp.match.group( 1 ) )
41 self.assertEqual( count, ip )
46 if __name__ == '__main__':