Update Cluster Driver
Change-Id: I8a3a57e19637ff210548e57d41178e6f194cf694
diff --git a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/scaleTopoFunction.py b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/scaleTopoFunction.py
index 43f80eb..6f2647d 100644
--- a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/scaleTopoFunction.py
+++ b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/scaleTopoFunction.py
@@ -77,7 +77,7 @@
'''
try:
- termInfo = main.CLIs[ index ].logSearch( mode=Mode, searchTerm=term )
+ termInfo = main.Cluster.active( index ).CLI.logSearch( mode=Mode, searchTerm=term )
termTime = getTimestampFromString( main, termInfo[ 0 ] )
roleRequestTime = getRoleRequestTimeFromTshark( main )
if termTime == -1 or roleRequestTime == -1:
@@ -108,8 +108,8 @@
'''
try:
- termInfo1 = main.CLIs[ index ].logSearch( mode=mode1, searchTerm=term1 )
- termInfo2 = main.CLIs[ index ].logSearch( mode=mode2, searchTerm=term2 )
+ termInfo1 = main.Cluster.active( index ).CLI.logSearch( mode=mode1, searchTerm=term1 )
+ termInfo2 = main.Cluster.active( index ).CLI.logSearch( mode=mode2, searchTerm=term2 )
if funcMode == 'TD':
startTime = getTimestampFromString( main, termInfo1[0] )
endTime = getTimestampFromString ( main, termInfo2[0] )
@@ -243,78 +243,16 @@
Compare topology( devices, links, ports, hosts ) between ONOS and
mininet using sts
"""
- devices = []
- links = []
- ports = []
- hosts = []
- switchResult = []
- linksResult = []
- portsResult = []
- hostsResult = []
- mnSwitches = main.Mininet1.getSwitches()
- mnLinks = main.Mininet1.getLinks()
- mnHosts = main.Mininet1.getHosts()
- compareTopoResult = main.TRUE
-
- for i in range( main.numCtrls ):
- devices.append( json.loads( main.CLIs[ i ].devices() ) )
- links.append( json.loads( main.CLIs[ i ].links() ) )
- ports.append( json.loads( main.CLIs[ i ].ports() ) )
- hosts.append( json.loads( main.CLIs[ i ].hosts() ) )
-
- # Comparing switches
- main.log.info( main.topoName + ": Comparing switches in each ONOS nodes" +
- " with Mininet" )
- for i in range( main.numCtrls ):
- tempResult = main.Mininet1.compareSwitches( mnSwitches,
- devices[ i ],
- ports[ i ] )
- switchResult.append( tempResult )
- if tempResult == main.FALSE:
- main.log.error( main.topoName + ": ONOS-" + str( i + 1 ) +
- " switch view is incorrect " )
-
- if all( result == main.TRUE for result in switchResult ):
- main.log.info( main.topoName + ": Switch view in all ONOS nodes "+
- "are correct " )
- else:
- compareTopoResult = main.FALSE
-
- # Comparing links
- main.log.info( main.topoName + ": Comparing links in each ONOS nodes" +
- " with Mininet" )
- for i in range( main.numCtrls ):
- tempResult = main.Mininet1.compareLinks( mnSwitches,
- mnLinks,
- links[ i ] )
- linksResult.append( tempResult )
- if tempResult == main.FALSE:
- main.log.error( main.topoName + ": ONOS-" + str( i + 1 ) +
- " links view are incorrect " )
-
- if all( result == main.TRUE for result in linksResult ):
- main.log.info( main.topoName + ": Links view in all ONOS nodes "+
- "are correct " )
- else:
- compareTopoResult = main.FALSE
-
- # Comparing hosts
- main.log.info( main.topoName + ": Comparing hosts in each ONOS nodes" +
- " with Mininet" )
- for i in range( main.numCtrls ):
- tempResult = main.Mininet1.compareHosts( mnHosts, hosts[ i ] )
- hostsResult.append( tempResult )
- if tempResult == main.FALSE:
- main.log.error( main.topoName + ": ONOS-" + str( i + 1 ) +
- " hosts view are incorrect " )
-
- if all( result == main.TRUE for result in hostsResult ):
- main.log.info( main.topoName + ": Hosts view in all ONOS nodes "+
- "are correct " )
- else:
- compareTopoResult = main.FALSE
-
- return compareTopoResult
+ try:
+ from tests.dependencies.topology import Topology
+ except ImportError:
+ main.log.error( "Topology not found exiting the test" )
+ main.exit()
+ try:
+ main.topoRelated
+ except ( NameError, AttributeError ):
+ main.topoRelated = Topology()
+ return main.topoRelated.compareTopos( main.Mininet1 )
def assignSwitch( main ):
"""
@@ -324,12 +262,12 @@
assignResult = main.TRUE
switchList = main.Mininet1.getSwitch()
assignResult = main.Mininet1.assignSwController( sw=switchList,
- ip=main.ONOSip[ 0 ],
+ ip=main.Cluster.active( 0 ).ipAddress,
port=6633 )
for sw in switchList:
response = main.Mininet1.getSwController( sw )
- if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
+ if re.search( "tcp:" + main.Cluster.active( 0 ).ipAddress, response ):
assignResult = assignResult and main.TRUE
else:
assignResult = main.FALSE
@@ -344,15 +282,15 @@
appCheck = main.TRUE
getDataResult = main.TRUE
main.log.info( main.topoName + ": Activating reactive forwarding app " )
- activateResult = main.CLIs[ 0 ].activateApp( "org.onosproject.fwd" )
+ activateResult = main.Cluster.active( 0 ).activateApp( "org.onosproject.fwd" )
if main.hostsData:
main.hostsData = {}
- for i in range( main.numCtrls ):
- appCheck = appCheck and main.CLIs[ i ].appToIDCheck()
+ for ctrl in main.Cluster.active():
+ appCheck = appCheck and ctrl.CLI.appToIDCheck()
if appCheck != main.TRUE:
- main.log.warn( main.CLIs[ i ].apps() )
- main.log.warn( main.CLIs[ i ].appIDs() )
+ main.log.warn( ctrl.CLI.apps() )
+ main.log.warn( ctrl.CLI.appIDs() )
time.sleep( main.fwdSleep )
@@ -362,12 +300,12 @@
acceptableFailed=acceptableFailed )
main.log.info( main.topoName + ": Deactivate reactive forwarding app " )
- activateResult = main.CLIs[ 0 ].deactivateApp( "org.onosproject.fwd" )
- for i in range( main.numCtrls ):
- appCheck = appCheck and main.CLIs[ i ].appToIDCheck()
+ activateResult = main.Cluster.active( 0 ).deactivateApp( "org.onosproject.fwd" )
+ for ctrl in main.Cluster.active():
+ appCheck = appCheck and ctrl.CLI.appToIDCheck()
if appCheck != main.TRUE:
- main.log.warn( main.CLIs[ i ].apps() )
- main.log.warn( main.CLIs[ i ].appIDs() )
+ main.log.warn( ctrl.CLI.apps() )
+ main.log.warn( ctrl.CLI.appIDs() )
return pingResult
@@ -379,21 +317,21 @@
appCheck = main.TRUE
getDataResult = main.TRUE
main.log.info( main.topoName + ": Activating reactive forwarding app " )
- activateResult = main.CLIs[ 0 ].activateApp( "org.onosproject.fwd" )
+ activateResult = main.Cluster.active( 0 ).CLI.activateApp( "org.onosproject.fwd" )
if main.hostsData:
main.hostsData = {}
- for i in range( main.numCtrls ):
- appCheck = appCheck and main.CLIs[ i ].appToIDCheck()
+ for ctrl in main.Cluster.active():
+ appCheck = appCheck and ctrl.CLI.appToIDCheck()
if appCheck != main.TRUE:
- main.log.warn( main.CLIs[ i ].apps() )
- main.log.warn( main.CLIs[ i ].appIDs() )
+ main.log.warn( ctrl.CLI.apps() )
+ main.log.warn( ctrl.CLI.appIDs() )
time.sleep( main.fwdSleep )
# Discover hosts using pingall
pingResult = main.Mininet1.pingall( timeout=900 )
- hostsJson = json.loads( main.CLIs[ 0 ].hosts() )
+ hostsJson = json.loads( main.Cluster.active( 0 ).CLI.hosts() )
hosts = main.Mininet1.getHosts().keys()
for host in hosts:
@@ -419,12 +357,12 @@
getDataResult = main.FALSE
main.log.info( main.topoName + ": Deactivate reactive forwarding app " )
- activateResult = main.CLIs[ 0 ].deactivateApp( "org.onosproject.fwd" )
- for i in range( main.numCtrls ):
- appCheck = appCheck and main.CLIs[ i ].appToIDCheck()
+ activateResult = main.Cluster.active( 0 ).CLI.deactivateApp( "org.onosproject.fwd" )
+ for ctrl in main.Cluster.active():
+ appCheck = appCheck and ctrl.CLI.appToIDCheck()
if appCheck != main.TRUE:
- main.log.warn( main.CLIs[ i ].apps() )
- main.log.warn( main.CLIs[ i ].appIDs() )
+ main.log.warn( ctrl.CLI.apps() )
+ main.log.warn( ctrl.CLI.appIDs() )
# This data can be use later for intents
print main.hostsData
@@ -439,65 +377,40 @@
Return:
Retruns main.TRUE for a successful restart, main.FALSE otherwise.
"""
- uninstallResult = []
- installResult = []
stopResult = []
startResult = []
onosIsUpResult = []
restartResult = main.TRUE
- main.log.info( main.topoName + ": Uninstall ONOS cluster" )
- for ip in main.ONOSip:
- uninstallResult.append( main.ONOSbench.onosUninstall( nodeIp=ip ) )
-
- if all( result == main.TRUE for result in uninstallResult ):
- main.log.info( main.topoName + ": Successfully uninstall ONOS cluster" )
- else:
+ uninstallResult = main.testSetUp.uninstallOnos( main.Cluster, False )
+ if uninstallResult != main.TRUE:
restartResult = main.FALSE
- main.log.error( main.topoName + ": Failed to uninstall ONOS cluster" )
-
- time.sleep( main.startUpSleep )
-
- main.log.info( main.topoName + ": Installing ONOS cluster" )
-
- for i in range( main.numCtrls ):
- installResult.append( main.ONOSbench.onosInstall(
- node=main.ONOSip[ i ] ) )
-
- if all( result == main.TRUE for result in installResult ):
- main.log.info( main.topoName + ": Successfully installed ONOS cluster" )
- else:
- restartResult = main.FALSE
- main.log.error( main.topoName + ": Failed to install ONOS cluster" )
-
- main.log.info( main.topoName + ": set up ONOS secure SSH" )
- secureSshResult = []
- for i in range( int( main.numCtrls ) ):
- secureSshResult.append( main.onosSecureSSH( node=main.ONOSip[i] ) )
- if all( result == main.TRUE for result in secureSshResult ):
- main.log.info( main.topoName + ": Successfully set up ONOS secure SSH" )
- else:
- main.log.error( main.topoName + ": Failed to set up ONOS secure SSH" )
+ installResult = main.testSetUp.installOnos( main.Cluster, False )
+ if installResult != main.TRUE:
restartResult = main.FALSE
- for i in range( main.numCtrls ):
- onosIsUpResult.append( main.ONOSbench.isup( main.ONOSip[ i ] ) )
+ secureSshResult = main.testSetUp.setupSsh( main.Cluster )
+ if secureSshResult != main.TRUE:
+ restartResult = main.FALSE
+
+ for ctrl in main.Cluster.runningNodes:
+ onosIsUpResult.append( main.ONOSbench.isup( ctrl.ipAddress ) )
if all( result == main.TRUE for result in onosIsUpResult ):
main.log.report( "ONOS instance is up and ready" )
else:
main.log.report( "ONOS instance may not be up, stop and " +
"start ONOS again " )
- for i in range( main.numCtrls ):
- stopResult.append( main.ONOSbench.onosStop( main.ONOSip[ i ] ) )
+ for ctrl in main.Cluster.runningNodes:
+ stopResult.append( main.ONOSbench.onosStop( ctrl.ipAddress ) )
if all( result == main.TRUE for result in stopResult ):
main.log.info( main.topoName + ": Successfully stop ONOS cluster" )
else:
main.log.error( main.topoName + ": Failed to stop ONOS cluster" )
- for i in range( main.numCtrls ):
- startResult.append( main.ONOSbench.onosStart( main.ONOSip[ i ] ) )
+ for ctrl in main.Cluster.runningNodes:
+ startResult.append( main.ONOSbench.onosStart( ctrl.ipAddress ) )
if all( result == main.TRUE for result in startResult ):
main.log.info( main.topoName + ": Successfully start ONOS cluster" )
@@ -505,14 +418,8 @@
main.log.error( main.topoName + ": Failed to start ONOS cluster" )
main.log.info( main.topoName + ": Starting ONOS CLI" )
- cliResult = []
- for i in range( main.numCtrls ):
- cliResult.append( main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] ) )
-
- if all( result == main.TRUE for result in cliResult ):
- main.log.info( main.topoName + ": Successfully start ONOS cli" )
- else:
- main.log.error( main.topoName + ": Failed to start ONOS cli" )
+ cliResult = main.testSetUp.startOnosClis( main.Cluster )
+ if cliResult != main.TRUE:
restartResult = main.FALSE
diff --git a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/topo.py b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/topo.py
index 74f8751..c5c1f88 100644
--- a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/topo.py
+++ b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/topo.py
@@ -43,7 +43,7 @@
main.Mininet1.arping( srcHost=hostList, dstHost="10.0.0.1", output=main.FALSE, noResult=True )
try:
summaryStr = ""
- summaryStr = json.loads( main.CLIs[0].summary().encode() )
+ summaryStr = json.loads( main.Cluster.active( 0 ).CLI.summary().encode() )
hostNum = summaryStr.get( 'hosts' )
except (TypeError, ValueError):