Merge branch 'master' of https://github.com/opennetworkinglab/ONLabTest into newMNdriver
diff --git a/TestON/drivers/common/cli/.onosclidriver.py.swo b/TestON/drivers/common/cli/.onosclidriver.py.swo
new file mode 100644
index 0000000..84bf367
--- /dev/null
+++ b/TestON/drivers/common/cli/.onosclidriver.py.swo
Binary files differ
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index 95e0cb9..c9b39ea 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -59,20 +59,48 @@
"""
Here the main is the TestON instance after creating
all the log handles."""
- for key in connectargs:
- vars( self )[ key ] = connectargs[ key ]
+ try:
+ for key in connectargs:
+ vars( self )[ key ] = connectargs[ key ]
- self.name = self.options[ 'name' ]
- self.handle = super(
- MininetCliDriver,
- self ).connect(
- user_name=self.user_name,
- ip_address=self.ip_address,
- port=None,
- pwd=self.pwd )
+ self.name = self.options[ 'name' ]
+ self.handle = super(
+ MininetCliDriver,
+ self ).connect(
+ user_name=self.user_name,
+ ip_address=self.ip_address,
+ port=None,
+ pwd=self.pwd )
- self.sshHandle = self.handle
+ self.sshHandle = self.handle
+ if self.handle:
+ main.log.info("Connection successful to the host " +
+ self.user_name +
+ "@" +
+ self.ip_address )
+ return main.TRUE
+ else:
+ main.log.error( "Connection failed to the host " +
+ self.user_name +
+ "@" +
+ self.ip_address )
+ msin.log.error( "Failed to connect to the Mininet CLI" )
+ return main.FALSE
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ except:
+ main.log.info( self.name + ":::::::::::::::::::::::" )
+ main.log.error( traceback.print_exc() )
+ main.log.info( ":::::::::::::::::::::::" )
+ main.cleanup()
+ main.exit()
+
+
+ """
if self.handle:
main.log.info(
self.name +
@@ -99,51 +127,99 @@
main.log.error(
self.name +
": Something while cleaning MN took too long... " )
+ """
- main.log.info( self.name + ": building fresh mininet" )
- # for reactive/PARP enabled tests
- cmdString = "sudo mn " + self.options[ 'arg1' ] +\
- " " + self.options[ 'arg2' ] +\
- " --mac --controller " +\
- self.options[ 'controller' ] + " " +\
- self.options[ 'arg3' ]
+ def startNet( self, topoFile = '', args = '', timeout = 120 ):
- argList = self.options[ 'arg1' ].split( "," )
- global topoArgList
- topoArgList = argList[ 0 ].split( " " )
- argList = map( int, argList[ 1: ] )
- topoArgList = topoArgList[ 1: ] + argList
-
- self.handle.sendline( cmdString )
- self.handle.expect( [ "sudo mn", pexpect.EOF, pexpect.TIMEOUT ] )
- while True:
- i = self.handle.expect( [ 'mininet>',
- '\*\*\*',
- 'Exception',
+ self.name = self.options[ 'name' ]
+ if self.handle:
+ main.log.info(
+ self.name +
+ ": Clearing any residual state or processes" )
+ self.handle.sendline( "sudo mn -c" )
+ i = self.handle.expect( [ 'password\sfor\s',
+ 'Cleanup\scomplete',
+ pexpect.EOF,
+ pexpect.TIMEOUT ],
+ timeout )
+ if i == 0:
+ main.log.info( self.name + ": Sending sudo password" )
+ self.handle.sendline( self.pwd )
+ i = self.handle.expect( [ '%s:' % ( self.user ),
+ '\$',
pexpect.EOF,
pexpect.TIMEOUT ],
- 300 )
- if i == 0:
- main.log.info( self.name + ": mininet built" )
- return main.TRUE
- if i == 1:
- self.handle.expect(
- [ "\n", pexpect.EOF, pexpect.TIMEOUT ] )
- main.log.info( self.handle.before )
- elif i == 2:
- main.log.error(
- self.name +
- ": Launching mininet failed..." )
- return main.FALSE
- elif i == 3:
- main.log.error( self.name + ": Connection timeout" )
- return main.FALSE
- elif i == 4: # timeout
- main.log.error(
- self.name +
- ": Something took too long... " )
- return main.FALSE
- return main.TRUE
+ timeout )
+ if i == 1:
+ main.log.info( self.name + ": Clean" )
+ elif i == 2:
+ main.log.error( self.name + ": Connection terminated" )
+ elif i == 3: # timeout
+ main.log.error(
+ self.name +
+ ": Something while cleaning MN took too long... " )
+ if topoFile == '' and args == '':
+ main.log.info( self.name + ": building fresh mininet" )
+ # for reactive/PARP enabled tests
+ cmdString = "sudo mn " + self.options[ 'arg1' ] +\
+ " " + self.options[ 'arg2' ] +\
+ " --mac --controller " +\
+ self.options[ 'controller' ] + " " +\
+ self.options[ 'arg3' ]
+
+ argList = self.options[ 'arg1' ].split( "," )
+ global topoArgList
+ topoArgList = argList[ 0 ].split( " " )
+ argList = map( int, argList[ 1: ] )
+ topoArgList = topoArgList[ 1: ] + argList
+
+ self.handle.sendline( cmdString )
+ self.handle.expect( [ "sudo mn",
+ pexpect.EOF,
+ pexpect.TIMEOUT ] )
+ while True:
+ i = self.handle.expect( [ 'mininet>',
+ '\*\*\*',
+ 'Exception',
+ pexpect.EOF,
+ pexpect.TIMEOUT ],
+ timeout )
+ if i == 0:
+ main.log.info( self.name + ": mininet built" )
+ return main.TRUE
+ if i == 1:
+ self.handle.expect(
+ [ "\n", pexpect.EOF, pexpect.TIMEOUT ] )
+ main.log.info( self.handle.before )
+ elif i == 2:
+ main.log.error(
+ self.name +
+ ": Launching mininet failed..." )
+ return main.FALSE
+ elif i == 3:
+ main.log.error( self.name + ": Connection timeout" )
+ return main.FALSE
+ elif i == 4: # timeout
+ main.log.error(
+ self.name +
+ ": Something took too long... " )
+ return main.FALSE
+ return main.TRUE
+ else:
+ main.log.info( "Starting topo file " + topoFile )
+ if args == None:
+ args = ''
+ else:
+ main.log.info( "args = " + args)
+ self.handle.sendline( 'sudo ' + topoFile + ' ' + args)
+ i = 1
+ i = self.handle.expect( [ 'mininet>',
+ pexpect.EOF ,
+ pexpect.TIMEOUT ],
+ timeout)
+ main.log.info(self.name + ": Network started")
+ return main.TRUE
+
else: # if no handle
main.log.error(
self.name +
@@ -1108,6 +1184,29 @@
main.exit()
def disconnect( self ):
+ """
+ Called at the end of the test to disconnect the handle.
+ """
+ self.handle.sendline('')
+ i = 1
+ i = self.handle.expect( ['mininet>',pexpect.EOF,pexpect.TIMEOUT ], timeout = 2)
+ if i == 0:
+ self.stopNet()
+ response = ''
+ # print "Disconnecting Mininet"
+ if self.handle:
+ self.handle.sendline( "exit" )
+ self.handle.expect( "exit" )
+ self.handle.expect( "(.*)" )
+ main.log.info( "Mininet CLI is successfully disconnected" )
+ response = self.handle.before
+ else:
+ main.log.error( "Connection failed to the host" )
+ response = main.FALSE
+
+ return response
+
+ def stopNet( self ):
main.log.info( self.name + ": Disconnecting mininet..." )
response = ''
if self.handle:
@@ -1116,10 +1215,7 @@
cmd="exit",
prompt="(.*)",
timeout=120 )
- response = self.execute(
- cmd="exit",
- prompt="(.*)",
- timeout=120 )
+ main.log.info( self.name + ": Disconnected")
self.handle.sendline( "sudo mn -c" )
response = main.TRUE
except pexpect.EOF:
@@ -1132,6 +1228,8 @@
response = main.FALSE
return response
+
+
def arping( self, src, dest, destmac ):
self.handle.sendline( '' )
self.handle.expect( [ "mininet", pexpect.EOF, pexpect.TIMEOUT ] )
diff --git a/TestON/tests/Ping2topoExample/Ping2topoExample.params b/TestON/tests/Ping2topoExample/Ping2topoExample.params
new file mode 100644
index 0000000..651bd4e
--- /dev/null
+++ b/TestON/tests/Ping2topoExample/Ping2topoExample.params
@@ -0,0 +1,21 @@
+<PARAMS>
+ <testcases>1,4,5,3</testcases>
+ <ENV>
+ <cellName>kelvin</cellName>
+ </ENV>
+ <Git>True</Git>
+ <TOPO1>
+ <file>~/mininet/examples/attTopo.py</file>
+ <args></args>
+ </TOPO1>
+
+ <TOPO2>
+ <file></file>
+ <args></args>
+ </TOPO2>
+
+ <CTRL>
+ <ip1>10.128.10.21</ip1>
+ <port1>6633</port1>
+ </CTRL>
+</PARAMS>
diff --git a/TestON/tests/Ping2topoExample/Ping2topoExample.py b/TestON/tests/Ping2topoExample/Ping2topoExample.py
new file mode 100644
index 0000000..cbf2cc0
--- /dev/null
+++ b/TestON/tests/Ping2topoExample/Ping2topoExample.py
@@ -0,0 +1,231 @@
+"""
+Description: This test is an example of a simple single node ONOS test
+with 2 different topology on one test test
+List of test cases:
+CASE1: Compile ONOS and push it to the test machine: Also starts first topology
+CASE2: Assign mastership to controller: first topology
+CASE3: Pingall
+CASE4: Creates new topology: second topology
+CASE5: Assign mastership to controller: second topology
+"""
+class Ping2topoExample:
+
+ def __init__( self ):
+ self.default = ''
+
+ def CASE1( self, main ):
+ """
+ CASE1 is to compile ONOS and push it to the test machines
+
+ Startup sequence:
+ git pull
+ mvn clean install
+ onos-package
+ cell <name>
+ onos-verify-cell
+ onos-install -f
+ onos-wait-for-start
+ """
+ desc = "Testing ping all function on two topology in one test run"
+ main.log.report( desc )
+ main.case( "Setting up test environment" )
+
+ # load some vairables from the params file
+ PULLCODE = False
+ if main.params[ 'Git' ] == 'True':
+ PULLCODE = True
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+
+ main.step( "Applying cell variable to environment" )
+ cellResult = main.ONOSbench.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+
+ main.log.report( "Uninstalling ONOS" )
+ main.ONOSbench.onosUninstall( ONOS1Ip )
+
+ cleanInstallResult = main.TRUE
+ gitPullResult = main.TRUE
+
+ main.step( "Compiling the latest version of ONOS" )
+ if PULLCODE:
+ main.step( "Git checkout and pull master" )
+ main.ONOSbench.gitCheckout( "master" )
+ gitPullResult = main.ONOSbench.gitPull()
+
+ main.step( "Using mvn clean & install" )
+ cleanInstallResult = main.TRUE
+ if gitPullResult == main.TRUE:
+ cleanInstallResult = main.ONOSbench.cleanInstall()
+ else:
+ main.log.warn( "Did not pull new code so skipping mvn " +
+ "clean install" )
+ main.ONOSbench.getVersion( report=True )
+
+ cellResult = main.ONOSbench.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+
+ main.step( "Installing ONOS package" )
+ onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
+ node=ONOS1Ip )
+
+ main.step( "Checking if ONOS is up yet" )
+ for i in range( 2 ):
+ onos1Isup = main.ONOSbench.isup( ONOS1Ip )
+ if onos1Isup:
+ break
+ if not onos1Isup:
+ main.log.report( "ONOS1 didn't start!" )
+
+ # TODO: if it becomes an issue, we can retry this step a few times
+
+ cliResult = main.ONOScli1.startOnosCli( ONOS1Ip )
+
+ case1Result = ( cleanInstallResult and packageResult and
+ cellResult and verifyResult and
+ onos1InstallResult and
+ onos1Isup and cliResult )
+
+ utilities.assert_equals( expect=main.TRUE, actual=case1Result,
+ onpass="Test startup successful",
+ onfail="Test startup NOT successful" )
+
+ if case1Result == main.FALSE:
+ main.cleanup()
+ main.exit()
+
+ main.step( "Starting Mininet CLI..." )
+ netIsUp = main.Mininet1.startNet()
+ if netIsUp:
+ main.log.info("Mininet CLI is up")
+ else:
+ main.log.info("Mininet CLI is down")
+
+ def CASE2( self, main ):
+ """
+ Assign mastership to controller : topology 1 has 13 switches
+ """
+ import re
+
+ main.log.report( "Assigning switches to controller" )
+ main.case( "Assigning Controller" )
+ main.step( "Assign switches to controller" )
+
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
+
+ for i in range( 1, 14 ):
+ main.Mininet1.assignSwController(
+ sw=str( i ),
+ ip1=ONOS1Ip,
+ port1=ONOS1Port )
+
+ mastershipCheck = main.TRUE
+ for i in range( 1, 14 ):
+ response = main.Mininet1.getSwController( "s" + str( i ) )
+ try:
+ main.log.info( str( response ) )
+ except:
+ main.log.info( repr( response ) )
+ if re.search( "tcp:" + ONOS1Ip, response ):
+ mastershipCheck = mastershipCheck and main.TRUE
+ else:
+ mastershipCheck = main.FALSE
+ if mastershipCheck == main.TRUE:
+ main.log.report( "Switch mastership assigned correctly" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=mastershipCheck,
+ onpass="Switch mastership assigned correctly",
+ onfail="Switches not assigned correctly to controllers" )
+
+ def CASE3( self, main ):
+ """
+ Assign intents
+ """
+ import time
+
+ main.log.report( "Run Pingall" )
+ main.case( "Run Pingall" )
+
+ # install onos-app-fwd
+ main.log.info( "Install reactive forwarding app" )
+ main.ONOScli1.featureInstall( "onos-app-fwd" )
+
+ # REACTIVE FWD test
+ pingResult = main.FALSE
+ time1 = time.time()
+ pingResult = main.Mininet1.pingall()
+ time2 = time.time()
+ main.log.info( "Time for pingall: %2f seconds" % ( time2 - time1 ) )
+
+ # uninstall onos-app-fwd
+ main.log.info( "Uninstall reactive forwarding app" )
+ main.ONOScli1.featureUninstall( "onos-app-fwd" )
+
+ utilities.assert_equals( expect=main.TRUE, actual=pingResult,
+ onpass="All hosts are reachable",
+ onfail="Some pings failed" )
+
+ def CASE4( self, main):
+ """
+ Stop mininet and start a new one using different topology
+ """
+ main.log.info ("Starts new topology")
+ main.log.info( "Stopping Mininet..." )
+ main.Mininet1.stopNet()
+
+ main.log.info( "Starting Mininet..." )
+ topoFile = main.params[ 'TOPO1' ][ 'file' ]
+ args = main.params[ 'TOPO1' ][ 'args' ]
+
+ isMnUp = main.FALSE
+ isMnUp = main.Mininet1.startNet(topoFile = topoFile, args = args)
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=isMnUp,
+ onpass="New mininet topology is up and runing",
+ onfail="New mininet topology failed to run" )
+
+
+
+ def CASE5( self, main ):
+ """
+ Assign mastership to controller: topology 2 has 25 switches
+ """
+ import re
+
+ main.log.report( "Assigning switches to controller" )
+ main.case( "Assigning Controller" )
+ main.step( "Assign switches to controller" )
+
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
+
+ for i in range( 1, 26 ):
+ main.Mininet1.assignSwController(
+ sw=str( i ),
+ ip1=ONOS1Ip,
+ port1=ONOS1Port )
+
+ mastershipCheck = main.TRUE
+ for i in range( 1, 26 ):
+ response = main.Mininet1.getSwController( "s" + str( i ) )
+ try:
+ main.log.info( str( response ) )
+ except:
+ main.log.info( repr( response ) )
+ if re.search( "tcp:" + ONOS1Ip, response ):
+ mastershipCheck = mastershipCheck and main.TRUE
+ else:
+ mastershipCheck = main.FALSE
+ if mastershipCheck == main.TRUE:
+ main.log.report( "Switch mastership assigned correctly" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=mastershipCheck,
+ onpass="Switch mastership assigned correctly",
+ onfail="Switches not assigned correctly to controllers" )
diff --git a/TestON/tests/Ping2topoExample/Ping2topoExample.topo b/TestON/tests/Ping2topoExample/Ping2topoExample.topo
new file mode 100644
index 0000000..dba7a5d
--- /dev/null
+++ b/TestON/tests/Ping2topoExample/Ping2topoExample.topo
@@ -0,0 +1,47 @@
+<TOPOLOGY>
+ <COMPONENT>
+
+ <ONOSbench>
+ <host>10.128.10.20</host>
+ <user>admin</user>
+ <password></password>
+ <type>OnosDriver</type>
+ <connect_order>1</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOSbench>
+
+ <ONOScli1>
+ <host>10.128.10.20</host>
+ <user>admin</user>
+ <password></password>
+ <type>OnosCliDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli1>
+
+ <ONOS1>
+ <host>10.128.10.21</host>
+ <user>admin</user>
+ <password></password>
+ <type>OnosDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS1>
+
+ <Mininet1>
+ <host>10.128.10.20</host>
+ <user>admin</user>
+ <password></password>
+ <type>MininetCliDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS>
+ #Specify the Option for mininet
+ <arg1> --topo=tree,3,3 </arg1>
+ <arg2> </arg2>
+ <arg3> </arg3>
+ <controller> remote </controller>
+ </COMPONENTS>
+ </Mininet1>
+
+ </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/Ping2topoExample/__init__.py b/TestON/tests/Ping2topoExample/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/Ping2topoExample/__init__.py
diff --git a/TestON/tests/PingallExample/PingallExample.params b/TestON/tests/PingallExample/PingallExample.params
index aecaab6..85a576e 100644
--- a/TestON/tests/PingallExample/PingallExample.params
+++ b/TestON/tests/PingallExample/PingallExample.params
@@ -1,12 +1,22 @@
<PARAMS>
<testcases>1,2,3</testcases>
<ENV>
- <cellName>HA</cellName>
+ <cellName>kelvin</cellName>
</ENV>
<Git>True</Git>
+ <TOPO1>
+ <file>~/mininet/examples/attTopo.py</file>
+ <args>--mac</args>
+ </TOPO1>
+
+ <TOPO2>
+ <file></file>
+ <args></args>
+ </TOPO2>
+
<CTRL>
- <ip1>10.128.30.11</ip1>
+ <ip1>10.128.10.21</ip1>
<port1>6633</port1>
</CTRL>
</PARAMS>
diff --git a/TestON/tests/PingallExample/PingallExample.py b/TestON/tests/PingallExample/PingallExample.py
index bb2b1cf..653397e 100644
--- a/TestON/tests/PingallExample/PingallExample.py
+++ b/TestON/tests/PingallExample/PingallExample.py
@@ -94,6 +94,14 @@
if case1Result == main.FALSE:
main.cleanup()
main.exit()
+
+ # Starting the mininet using the old way
+ main.step( "Starting Mininet ..." )
+ netIsUp = main.Mininet1.startNet()
+ if netIsUp:
+ main.log.info("Mininet CLI is up")
+ else:
+ main.log.info("Mininet CLI is down")
def CASE2( self, main ):
"""
diff --git a/TestON/tests/PingallExample/PingallExample.topo b/TestON/tests/PingallExample/PingallExample.topo
index 1712756..dba7a5d 100644
--- a/TestON/tests/PingallExample/PingallExample.topo
+++ b/TestON/tests/PingallExample/PingallExample.topo
@@ -2,7 +2,7 @@
<COMPONENT>
<ONOSbench>
- <host>10.128.30.10</host>
+ <host>10.128.10.20</host>
<user>admin</user>
<password></password>
<type>OnosDriver</type>
@@ -11,7 +11,7 @@
</ONOSbench>
<ONOScli1>
- <host>10.128.30.10</host>
+ <host>10.128.10.20</host>
<user>admin</user>
<password></password>
<type>OnosCliDriver</type>
@@ -20,16 +20,16 @@
</ONOScli1>
<ONOS1>
- <host>10.128.30.11</host>
- <user>sdn</user>
- <password>rocks</password>
+ <host>10.128.10.21</host>
+ <user>admin</user>
+ <password></password>
<type>OnosDriver</type>
<connect_order>3</connect_order>
<COMPONENTS> </COMPONENTS>
</ONOS1>
<Mininet1>
- <host>10.128.30.9</host>
+ <host>10.128.10.20</host>
<user>admin</user>
<password></password>
<type>MininetCliDriver</type>
diff --git a/TestON/tests/PortTest/PortTest.params b/TestON/tests/PortTest/PortTest.params
new file mode 100755
index 0000000..2d1f421
--- /dev/null
+++ b/TestON/tests/PortTest/PortTest.params
@@ -0,0 +1,48 @@
+<PARAMS>
+
+ <testcases>1,4,9</testcases>
+ #Environment variables
+ <ENV>
+ <cellName>driver_test</cellName>
+ </ENV>
+
+ <CTRL>
+ <ip1>10.128.20.11</ip1>
+ <port1>6633</port1>
+ </CTRL>
+
+ <PING>
+ <source1>h8</source1>
+ <source2>h9</source2>
+ <source3>h10</source3>
+ <source4>h11</source4>
+ <source5>h12</source5>
+ <source6>h13</source6>
+ <source7>h14</source7>
+ <source8>h15</source8>
+ <source9>h16</source9>
+ <source10>h17</source10>
+ <target1>10.0.0.18</target1>
+ <target2>10.0.0.19</target2>
+ <target3>10.0.0.20</target3>
+ <target4>10.0.0.21</target4>
+ <target5>10.0.0.22</target5>
+ <target6>10.0.0.23</target6>
+ <target7>10.0.0.24</target7>
+ <target8>10.0.0.25</target8>
+ <target9>10.0.0.26</target9>
+ <target10>10.0.0.27</target10>
+ </PING>
+
+ <timers>
+ <LinkDiscovery>5</LinkDiscovery>
+ <SwitchDiscovery>15</SwitchDiscovery>
+ </timers>
+
+ <OPTICAL>
+ <jsonfile> /home/admin/ONOS/tools/test/topos/oe-nonlinear-4.json </jsonfile>
+ </OPTICAL>
+
+
+
+</PARAMS>
diff --git a/TestON/tests/PortTest/PortTest.py b/TestON/tests/PortTest/PortTest.py
new file mode 100644
index 0000000..bb2b1cf
--- /dev/null
+++ b/TestON/tests/PortTest/PortTest.py
@@ -0,0 +1,162 @@
+"""
+Description: This test is an example of a simple single node ONOS test
+
+List of test cases:
+CASE1: Compile ONOS and push it to the test machine
+CASE2: Assign mastership to controller
+CASE3: Pingall
+"""
+class PingallExample:
+
+ def __init__( self ):
+ self.default = ''
+
+ def CASE1( self, main ):
+ """
+ CASE1 is to compile ONOS and push it to the test machines
+
+ Startup sequence:
+ git pull
+ mvn clean install
+ onos-package
+ cell <name>
+ onos-verify-cell
+ onos-install -f
+ onos-wait-for-start
+ """
+ desc = "ONOS Single node cluster restart HA test - initialization"
+ main.log.report( desc )
+ main.case( "Setting up test environment" )
+
+ # load some vairables from the params file
+ PULLCODE = False
+ if main.params[ 'Git' ] == 'True':
+ PULLCODE = True
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+
+ main.step( "Applying cell variable to environment" )
+ cellResult = main.ONOSbench.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+
+ main.log.report( "Uninstalling ONOS" )
+ main.ONOSbench.onosUninstall( ONOS1Ip )
+
+ cleanInstallResult = main.TRUE
+ gitPullResult = main.TRUE
+
+ main.step( "Compiling the latest version of ONOS" )
+ if PULLCODE:
+ main.step( "Git checkout and pull master" )
+ main.ONOSbench.gitCheckout( "master" )
+ gitPullResult = main.ONOSbench.gitPull()
+
+ main.step( "Using mvn clean & install" )
+ cleanInstallResult = main.TRUE
+ if gitPullResult == main.TRUE:
+ cleanInstallResult = main.ONOSbench.cleanInstall()
+ else:
+ main.log.warn( "Did not pull new code so skipping mvn " +
+ "clean install" )
+ main.ONOSbench.getVersion( report=True )
+
+ cellResult = main.ONOSbench.setCell( cellName )
+ verifyResult = main.ONOSbench.verifyCell()
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage()
+
+ main.step( "Installing ONOS package" )
+ onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
+ node=ONOS1Ip )
+
+ main.step( "Checking if ONOS is up yet" )
+ for i in range( 2 ):
+ onos1Isup = main.ONOSbench.isup( ONOS1Ip )
+ if onos1Isup:
+ break
+ if not onos1Isup:
+ main.log.report( "ONOS1 didn't start!" )
+
+ # TODO: if it becomes an issue, we can retry this step a few times
+
+ cliResult = main.ONOScli1.startOnosCli( ONOS1Ip )
+
+ case1Result = ( cleanInstallResult and packageResult and
+ cellResult and verifyResult and
+ onos1InstallResult and
+ onos1Isup and cliResult )
+
+ utilities.assert_equals( expect=main.TRUE, actual=case1Result,
+ onpass="Test startup successful",
+ onfail="Test startup NOT successful" )
+
+ if case1Result == main.FALSE:
+ main.cleanup()
+ main.exit()
+
+ def CASE2( self, main ):
+ """
+ Assign mastership to controller
+ """
+ import re
+
+ main.log.report( "Assigning switches to controller" )
+ main.case( "Assigning Controller" )
+ main.step( "Assign switches to controller" )
+
+ ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
+
+ for i in range( 1, 14 ):
+ main.Mininet1.assignSwController(
+ sw=str( i ),
+ ip1=ONOS1Ip,
+ port1=ONOS1Port )
+
+ mastershipCheck = main.TRUE
+ for i in range( 1, 14 ):
+ response = main.Mininet1.getSwController( "s" + str( i ) )
+ try:
+ main.log.info( str( response ) )
+ except:
+ main.log.info( repr( response ) )
+ if re.search( "tcp:" + ONOS1Ip, response ):
+ mastershipCheck = mastershipCheck and main.TRUE
+ else:
+ mastershipCheck = main.FALSE
+ if mastershipCheck == main.TRUE:
+ main.log.report( "Switch mastership assigned correctly" )
+ utilities.assert_equals(
+ expect=main.TRUE,
+ actual=mastershipCheck,
+ onpass="Switch mastership assigned correctly",
+ onfail="Switches not assigned correctly to controllers" )
+
+ def CASE3( self, main ):
+ """
+ Assign intents
+ """
+ import time
+
+ main.log.report( "Run Pingall" )
+ main.case( "Run Pingall" )
+
+ # install onos-app-fwd
+ main.log.info( "Install reactive forwarding app" )
+ main.ONOScli1.featureInstall( "onos-app-fwd" )
+
+ # REACTIVE FWD test
+ pingResult = main.FALSE
+ time1 = time.time()
+ pingResult = main.Mininet1.pingall()
+ time2 = time.time()
+ main.log.info( "Time for pingall: %2f seconds" % ( time2 - time1 ) )
+
+ # uninstall onos-app-fwd
+ main.log.info( "Uninstall reactive forwarding app" )
+ main.ONOScli1.featureUninstall( "onos-app-fwd" )
+
+ utilities.assert_equals( expect=main.TRUE, actual=pingResult,
+ onpass="All hosts are reachable",
+ onfail="Some pings failed" )
diff --git a/TestON/tests/PortTest/PortTest.topo b/TestON/tests/PortTest/PortTest.topo
new file mode 100755
index 0000000..7dff686
--- /dev/null
+++ b/TestON/tests/PortTest/PortTest.topo
@@ -0,0 +1,103 @@
+<TOPOLOGY>
+ <COMPONENT>
+
+ <ONOSbench>
+ <host>10.128.10.11</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosDriver</type>
+ <connect_order>1</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOSbench>
+
+ <ONOS1>
+ <host>10.128.10.11</host>
+ <user>sdn</user>
+ <password>sdn</password>
+ <type>OnosDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS1>
+
+ <ONOS2>
+ <host>10.128.10.11</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS2>
+
+ <ONOS3>
+ <host>10.128.10.11</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS3>
+
+
+ <Mininet1>
+ <host>10.128.10.11</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>MininetCliDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS>
+ #Specify the Option for mininet
+ <arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
+ <arg2> --topo mytopo </arg2>
+ <arg3> --switch ovs,protocols=OpenFlow10 </arg3>
+ <controller> remote </controller>
+ </COMPONENTS>
+ </Mininet1>
+
+ <Mininet2>
+ <host>10.128.10.11</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>RemoteMininetDriver</type>
+ <connect_order>6</connect_order>
+ <COMPONENTS>
+ #Specify the Option for mininet
+ <arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
+ <arg2> --topo mytopo </arg2>
+ <arg3> --switch ovs,protocols=OpenFlow13 </arg3>
+ <controller> remote </controller>
+ </COMPONENTS>
+ </Mininet2>
+
+ <LincOE1>
+ <host>10.128.20.30</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>LincOEDriver</type>
+ <connect_order>7</connect_order>
+ <COMPONENTS>
+ <arg1> </arg1>
+ </COMPONENTS>
+ </LincOE1>
+
+ <LincOE2>
+ <host>10.128.20.30</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>RemoteMininetDriver</type>
+ <connect_order>8</connect_order>
+ <COMPONENTS>
+ <arg1> sudo python /home/admin/optical.py </arg1>
+ <arg2> </arg2>
+ </COMPONENTS>
+ </LincOE2>
+
+ <LincOE3>
+ <host>10.128.20.30</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>LincOEDriver</type>
+ <connect_order>9</connect_order>
+ </LincOE3>
+
+ </COMPONENT>
+</TOPOLOGY>