[ONOS-6593]Review and Refactor ONOS startup procedures in TestON
Change-Id: I509a8ee7a26c198957bebf59da5c85a0edb8b995
diff --git a/TestON/tests/FUNC/FUNCflow/dependencies/__init__.py b/TestON/tests/FUNC/FUNCflow/dependencies/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCflow/dependencies/__init__.py
diff --git a/TestON/tests/FUNC/FUNCflow/dependencies/checkingFlow.py b/TestON/tests/FUNC/FUNCflow/dependencies/checkingFlow.py
new file mode 100644
index 0000000..5a5537c
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCflow/dependencies/checkingFlow.py
@@ -0,0 +1,47 @@
+import json
+import time
+class CheckingFlow:
+
+ def __init__( self ):
+ self.default = ''
+
+ def checkFlow( self ):
+ main.step("Check flow is in the ADDED state")
+ main.log.info( "Get the flows from ONOS" )
+ try:
+ flows = json.loads( main.ONOSrest.flows() )
+
+ stepResult = main.TRUE
+ for f in flows:
+ if "rest" in f.get( "appId" ):
+ if "ADDED" not in f.get( "state" ):
+ stepResult = main.FALSE
+ main.log.error( "Flow: %s in state: %s" % ( f.get( "id" ), f.get( "state" ) ) )
+ except TypeError:
+ main.log.error( "No Flows found by the REST API" )
+ stepResult = main.FALSE
+ except ValueError:
+ main.log.error( "Problem getting Flows state from REST API. Exiting test" )
+ main.cleanup()
+ main.exit()
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="All flows are in the ADDED state",
+ onfail="All flows are NOT in the ADDED state" )
+
+ main.step( "Check flows are in Mininet's flow table" )
+
+ # get the flow IDs that were added through rest
+ main.log.info( "Getting the flow IDs from ONOS" )
+ flowIds = [ f.get( "id" ) for f in flows if "rest" in f.get( "appId" ) ]
+ # convert the flowIDs to ints then hex and finally back to strings
+ flowIds = [ str( hex( int( x ) ) ) for x in flowIds ]
+ main.log.info( "ONOS flow IDs: {}".format( flowIds ) )
+
+ stepResult = main.Mininet1.checkFlowId( "s1", flowIds, debug=False )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="All flows are in mininet",
+ onfail="All flows are NOT in mininet" )
diff --git a/TestON/tests/FUNC/FUNCflow/dependencies/startUp.py b/TestON/tests/FUNC/FUNCflow/dependencies/startUp.py
deleted file mode 100644
index a9becf9..0000000
--- a/TestON/tests/FUNC/FUNCflow/dependencies/startUp.py
+++ /dev/null
@@ -1,33 +0,0 @@
-"""
- This wrapper function is use for starting up onos instance
-"""
-import time
-import os
-import json
-
-
-def onosBuild( main, gitBranch ):
- """
- This includes pulling ONOS and building it using maven install
- """
- buildResult = main.FALSE
-
- # Git checkout a branch of ONOS
- checkOutResult = main.ONOSbench.gitCheckout( gitBranch )
- # Does the git pull on the branch that was checked out
- if not checkOutResult:
- main.log.warn( "Failed to checked out " + gitBranch +
- " branch" )
- else:
- main.log.info( "Successfully checked out " + gitBranch +
- " branch" )
- gitPullResult = main.ONOSbench.gitPull()
- if gitPullResult == main.ERROR:
- main.log.error( "Error pulling git branch" )
- else:
- main.log.info( "Successfully pulled " + gitBranch + " branch" )
-
- # buck build
- buildResult = main.ONOSbench.buckBuild()
-
- return buildResult
diff --git a/TestON/tests/FUNC/FUNCflow/dependencies/topo.py b/TestON/tests/FUNC/FUNCflow/dependencies/topo.py
deleted file mode 100644
index 7217d4d..0000000
--- a/TestON/tests/FUNC/FUNCflow/dependencies/topo.py
+++ /dev/null
@@ -1,102 +0,0 @@
-"""
- These functions can be used for topology comparisons
-"""
-import time
-import os
-import json
-
-
-def getAllDevices( main ):
- """
- Return a list containing the devices output from each ONOS node
- """
- devices = []
- threads = []
- for i in range( main.numCtrls ):
- t = main.Thread( target=main.CLIs[ i ].devices,
- name="devices-" + str( i ),
- args=[] )
- threads.append( t )
- t.start()
-
- for t in threads:
- t.join()
- devices.append( t.result )
- return devices
-
-
-def getAllHosts( main ):
- """
- Return a list containing the hosts output from each ONOS node
- """
- hosts = []
- ipResult = main.TRUE
- threads = []
- for i in range( main.numCtrls ):
- t = main.Thread( target=main.CLIs[ i ].hosts,
- name="hosts-" + str( i ),
- args=[] )
- threads.append( t )
- t.start()
-
- for t in threads:
- t.join()
- hosts.append( t.result )
- return hosts
-
-
-def getAllPorts( main ):
- """
- Return a list containing the ports output from each ONOS node
- """
- ports = []
- threads = []
- for i in range( main.numCtrls ):
- t = main.Thread( target=main.CLIs[ i ].ports,
- name="ports-" + str( i ),
- args=[] )
- threads.append( t )
- t.start()
-
- for t in threads:
- t.join()
- ports.append( t.result )
- return ports
-
-
-def getAllLinks( main ):
- """
- Return a list containing the links output from each ONOS node
- """
- links = []
- threads = []
- for i in range( main.numCtrls ):
- t = main.Thread( target=main.CLIs[ i ].links,
- name="links-" + str( i ),
- args=[] )
- threads.append( t )
- t.start()
-
- for t in threads:
- t.join()
- links.append( t.result )
- return links
-
-
-def getAllClusters( main ):
- """
- Return a list containing the clusters output from each ONOS node
- """
- clusters = []
- threads = []
- for i in range( main.numCtrls ):
- t = main.Thread( target=main.CLIs[ i ].clusters,
- name="clusters-" + str( i ),
- args=[] )
- threads.append( t )
- t.start()
-
- for t in threads:
- t.join()
- clusters.append( t.result )
- return clusters