b7c412073a
Ubuntu 20.04 fixes:
- fixes sshd test
- speeds up examples/{treeping64,tree1024}.py
- debugging hacks/output for testLinkChange
- removes cfs from examples/popen.py
- improves nat in nodelib (netplan fixes?)
- makes some tests executable
- waits for switches to connect in tests to
avoid race conditions
-- adds mn -w option and wait CLI command
Changes:
- REMOVES default "-v" argument for Controller()
and adds verbose(=False) option; avoiding logging
makes it faster
- CHANGES waitConnected to wait for 5 seconds
as documented; we may wish to implement an argument
to -w to set this timeout
Issues?
- There may still be an issue with the ovs-netplan-clean
service causing the boot to hang ;-(
58 lines
1.8 KiB
Python
Executable File
58 lines
1.8 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
"""
|
|
Test for natnet.py
|
|
"""
|
|
|
|
import unittest
|
|
from mininet.util import pexpect
|
|
from mininet.util import quietRun
|
|
|
|
class testNATNet( unittest.TestCase ):
|
|
|
|
prompt = 'mininet>'
|
|
|
|
def setUp( self ):
|
|
self.net = pexpect.spawn( 'python -m mininet.examples.natnet' )
|
|
self.net.expect( self.prompt )
|
|
|
|
def testPublicPing( self ):
|
|
"Attempt to ping the public server (h0) from h1 and h2"
|
|
self.net.sendline( 'h1 ping -c 1 h0' )
|
|
self.net.expect ( '(\d+)% packet loss' )
|
|
percent = int( self.net.match.group( 1 ) ) if self.net.match else -1
|
|
self.assertEqual( percent, 0 )
|
|
self.net.expect( self.prompt )
|
|
|
|
self.net.sendline( 'h2 ping -c 1 h0' )
|
|
self.net.expect ( '(\d+)% packet loss' )
|
|
percent = int( self.net.match.group( 1 ) ) if self.net.match else -1
|
|
self.assertEqual( percent, 0 )
|
|
self.net.expect( self.prompt )
|
|
|
|
def testPrivatePing( self ):
|
|
"Attempt to ping h1 and h2 from public server"
|
|
self.net.sendline( 'h0 ping -c 1 -t 1 h1' )
|
|
result = self.net.expect ( [ 'unreachable', 'loss' ] )
|
|
self.assertEqual( result, 0 )
|
|
self.net.expect( self.prompt )
|
|
|
|
self.net.sendline( 'h0 ping -c 1 -t 1 h2' )
|
|
result = self.net.expect ( [ 'unreachable', 'loss' ] )
|
|
self.assertEqual( result, 0 )
|
|
self.net.expect( self.prompt )
|
|
|
|
def testPrivateToPrivatePing( self ):
|
|
"Attempt to ping from NAT'ed host h1 to NAT'ed host h2"
|
|
self.net.sendline( 'h1 ping -c 1 -t 1 h2' )
|
|
result = self.net.expect ( [ '[Uu]nreachable', 'loss' ] )
|
|
self.assertEqual( result, 0 )
|
|
self.net.expect( self.prompt )
|
|
|
|
def tearDown( self ):
|
|
self.net.sendline( 'exit' )
|
|
self.net.wait()
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|