[ONOS-7039] [ONOS-7044] Fix PEP8 Warnings in TestON
Change-Id: Ied79ff9caff5487a6df50466307f757468d7ca3a
diff --git a/TestON/tests/SCPF/SCPFcbench/SCPFcbench.py b/TestON/tests/SCPF/SCPFcbench/SCPFcbench.py
index 0bafefb..c139d48 100644
--- a/TestON/tests/SCPF/SCPFcbench/SCPFcbench.py
+++ b/TestON/tests/SCPF/SCPFcbench/SCPFcbench.py
@@ -22,13 +22,13 @@
main.case( "pre-condition for cbench test." )
try:
- if type( init ) is not bool:
+ if not isinstance( init, bool ):
init = False
except NameError:
init = False
# -- INIT SECTION, ONLY RUNS ONCE -- #
- if init == False:
+ if not init:
init = True
try:
from tests.dependencies.ONOSSetup import ONOSSetup
@@ -80,7 +80,6 @@
onpass="Successfully configure onos for cbench test ",
onfail="Failed to configure onos for cbench test" )
-
def CASE2( self, main ):
main.case( "Running Cbench" )
main.step( "Issuing cbench commands and grab returned results" )
@@ -119,7 +118,7 @@
main.log.info( "Standard Deviation: \t" + stdev )
try:
- dbFileName="/tmp/CbenchDB"
+ dbFileName = "/tmp/CbenchDB"
dbfile = open( dbFileName, "w+" )
temp = "'" + main.commit + "',"
temp += "'" + mode + "',"
@@ -133,7 +132,7 @@
stepResult = main.TRUE
break
- if ( validFlag == False ):
+ if not validFlag:
main.log.warn( "Cbench Test produced no valid results!!!!" )
stepResult = main.FALSE
@@ -141,4 +140,3 @@
actual=stepResult,
onpass="Successfully tested onos for cbench. ",
onfail="Failed to obtain valid onos cbench result!" )
-
diff --git a/TestON/tests/SCPF/SCPFflowTp1g/SCPFflowTp1g.py b/TestON/tests/SCPF/SCPFflowTp1g/SCPFflowTp1g.py
index 41b09aa..c86ecac 100644
--- a/TestON/tests/SCPF/SCPFflowTp1g/SCPFflowTp1g.py
+++ b/TestON/tests/SCPF/SCPFflowTp1g/SCPFflowTp1g.py
@@ -1,5 +1,5 @@
"""
-Copyright 2015 Open Networking Foundation (ONF)
+Copyright 2015 Open Networking Foundation ( ONF )
Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -8,7 +8,7 @@
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,6 @@
You should have received a copy of the GNU General Public License
along with TestON. If not, see <http://www.gnu.org/licenses/>.
"""
-
# ScaleOutTemplate -> flowTP
#
# CASE1 starts number of nodes specified in param file
@@ -40,24 +39,24 @@
from tests.dependencies.ONOSSetup import ONOSSetup
main.testSetUp = ONOSSetup()
except ImportError:
- main.log.error("ONOSSetup not found. exiting the test")
+ main.log.error( "ONOSSetup not found. exiting the test" )
main.cleanAndExit()
main.testSetUp.envSetupDescription()
try:
- #Load values from params file
+ # Load values from params file
cellName = main.params[ 'ENV' ][ 'cellName' ]
main.apps = main.params[ 'ENV' ][ 'cellApps' ]
BENCHUser = main.params[ 'BENCH' ][ 'user' ]
BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
- main.scale = ( main.params[ 'SCALE' ] ).split( "," )
+ main.scale = ( main.params[ 'SCALE' ] ).split( "," )
main.flowRuleCfg = main.params[ 'CFG' ][ 'flowRule' ]
main.neighbor = ( main.params[ 'TEST' ][ 'neighbors' ] ).split( "," )
main.nullProviderCfg = main.params[ 'CFG' ][ 'nullProvider' ]
isFlowObj = main.params[ 'TEST' ][ 'flowObj' ] == "True"
if isFlowObj:
- resultFile = main.params[ 'TEST' ][ 'flowObjResultFile' ]
+ resultFile = main.params[ 'TEST' ][ 'flowObjResultFile' ]
else:
- resultFile = main.params[ 'TEST' ][ 'flowResultFile' ]
+ resultFile = main.params[ 'TEST' ][ 'flowResultFile' ]
stepResult = main.testSetUp.envSetup()
resultsDB = open( str( resultFile ), "w+" )
resultsDB.close()
@@ -110,13 +109,13 @@
main.step( "\tNEIGHBORS:\t" + neighbors )
main.log.info( "=============================================================" )
main.log.info( "=============================================================" )
- #write file to configure nil link
+ # write file to configure nil link
ipCSV = ""
- for i in range ( main.Cluster.maxCtrls ):
+ for i in range( main.Cluster.maxCtrls ):
tempstr = "ip" + str( i + 1 )
ipCSV += main.params[ 'CTRL' ][ tempstr ]
if i + 1 < main.Cluster.maxCtrls:
- ipCSV +=","
+ ipCSV += ","
main.ONOSbench.onosCfgSet( main.Cluster.active( 0 ).ipAddress,
main.flowRuleCfg,
@@ -142,51 +141,51 @@
main.ONOSbench.handle.expect( ":~" )
time.sleep( 5 )
main.ONOSbench.handle.sendline( "onos $OC1 roles " )
- main.ONOSbench.handle.expect ( ":~" )
+ main.ONOSbench.handle.expect( ":~" )
main.log.info( "switch masterships:" + str( main.ONOSbench.handle.before ) )
break
time.sleep( 5 )
- #divide flows/flowObjectives
+ # divide flows/flowObjectives
if isFlowObj:
- toInstall = "FlowObjectives"
- installCount = int( main.params[ 'TEST' ][ 'flowObjectives' ] )
- ifFailed = "FLOW_OBJ_TESTER.PY FAILURE"
- resultFile = main.params[ 'TEST' ][ 'flowObjResultFile' ]
+ toInstall = "FlowObjectives"
+ installCount = int( main.params[ 'TEST' ][ 'flowObjectives' ] )
+ ifFailed = "FLOW_OBJ_TESTER.PY FAILURE"
+ resultFile = main.params[ 'TEST' ][ 'flowObjResultFile' ]
else:
- toInstall = "Flows"
- installCount = int( main.params[ 'TEST' ][ 'flows' ] )
- ifFailed = "FLOW_TESTER.PY FAILURE"
- resultFile = main.params[ 'TEST' ][ 'flowResultFile' ]
+ toInstall = "Flows"
+ installCount = int( main.params[ 'TEST' ][ 'flows' ] )
+ ifFailed = "FLOW_TESTER.PY FAILURE"
+ resultFile = main.params[ 'TEST' ][ 'flowResultFile' ]
main.log.info( toInstall + " Target = " + str( installCount ) )
- installCountPerSwitch = ( installCount *max( int ( neighbors ) + 1, int( servers ) ) )/( ( int( neighbors ) + 1 )*int( servers )*( switches ) )
+ installCountPerSwitch = ( installCount * max( int( neighbors ) + 1, int( servers ) ) ) / ( ( int( neighbors ) + 1 ) * int( servers ) * ( switches ) )
main.log.info( toInstall + " per switch = " + str( installCountPerSwitch ) )
- #build list of servers in "$OC1, $OC2...." format
+ # build list of servers in "$OC1, $OC2...." format
serverEnvVars = ""
for i in range( int( servers ) ):
serverEnvVars += ( "-s " + main.Cluster.active( i ).ipAddress + " " )
- data = [ [ "" ]*int( servers ) ]*int( sampleSize )
- maxes = [ "" ]*int( sampleSize )
+ data = [ [ "" ] * int( servers ) ] * int( sampleSize )
+ maxes = [ "" ] * int( sampleSize )
flowCMD = "python3 " + homeDir + "/onos/tools/test/bin/"
if isFlowObj:
- flowCMD += testCMD[ 2 ] + " " + str( installCountPerSwitch ) + " " + testCMD[ 1 ]
- flowCMD += " " + neighbors + " " + testCMD[ 3 ] + " " + str( flowObjType ) + " " + str( serverEnvVars ) + "-j"
+ flowCMD += testCMD[ 2 ] + " " + str( installCountPerSwitch ) + " " + testCMD[ 1 ]
+ flowCMD += " " + neighbors + " " + testCMD[ 3 ] + " " + str( flowObjType ) + " " + str( serverEnvVars ) + "-j"
else:
- flowCMD += testCMD[ 0 ] + " " + str( installCountPerSwitch ) + " " + testCMD[ 1 ]
- flowCMD += " " + neighbors + " " + str( serverEnvVars ) + "-j"
+ flowCMD += testCMD[ 0 ] + " " + str( installCountPerSwitch ) + " " + testCMD[ 1 ]
+ flowCMD += " " + neighbors + " " + str( serverEnvVars ) + "-j"
main.log.info( flowCMD )
- #time.sleep( 60 )
+ # time.sleep( 60 )
for test in range( 0, warmUp + sampleSize ):
if test < warmUp:
main.log.info( "Warm up " + str( test + 1 ) + " of " + str( warmUp ) )
else:
- main.log.info( "====== Test run: " + str( test-warmUp+1 ) + " ======" )
+ main.log.info( "====== Test run: " + str( test - warmUp + 1 ) + " ======" )
main.ONOSbench.handle.sendline( flowCMD )
main.ONOSbench.handle.expect( ":~" )
@@ -205,17 +204,17 @@
main.log.info( main.ONOSbench.handle.before )
break
- result = [ "" ]*( main.Cluster.numCtrls )
+ result = [ "" ] * ( main.Cluster.numCtrls )
rawResult = rawResult.splitlines()
for node in range( main.Cluster.numCtrls ):
for line in rawResult:
- #print( "line: " + line )
+ # print( "line: " + line )
if main.Cluster.active( node ).ipAddress in line and "server" in line:
temp = line.split( " " )
for word in temp:
- #print ( "word: " + word )
+ # print ( "word: " + word )
if "elapsed" in repr( word ):
index = temp.index( word ) + 1
myParsed = ( temp[ index ] ).replace( ",", "" )
@@ -231,11 +230,11 @@
main.log.error( "Missing data point, critical failure incoming" )
print result
- maxes[ test-warmUp ] = max( result )
- main.log.info( "Data collection iteration: " + str( test-warmUp ) + " of " + str( sampleSize ) )
- main.log.info( "Throughput time: " + str( maxes[ test-warmUp ] ) + "(ms)" )
+ maxes[ test - warmUp ] = max( result )
+ main.log.info( "Data collection iteration: " + str( test - warmUp ) + " of " + str( sampleSize ) )
+ main.log.info( "Throughput time: " + str( maxes[ test - warmUp ] ) + "(ms)" )
- data[ test-warmUp ] = result
+ data[ test - warmUp ] = result
# wait for flows = 0
for checkCount in range( 0, 5 ):
@@ -257,7 +256,6 @@
main.log.info( "raw data: " + str( data ) )
main.log.info( "maxes:" + str( maxes ) )
-
# report data
print( "" )
main.log.info( "\t Results (measurments are in milliseconds)" )
@@ -285,7 +283,7 @@
main.log.info( "Standard Deviation of max values: " + str( stdOfMaxes ) )
print( "\n\n" )
- avgTP = int( installCount ) / avgOfMaxes #result in kflows/second
+ avgTP = int( installCount ) / avgOfMaxes # result in kflows/second
tp = []
for i in maxes:
@@ -308,4 +306,4 @@
main.log.report( "Result line to file: " + resultString )
- main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, [ "ERROR", "WARNING", "EXCEPT" ], outputMode="d" )
\ No newline at end of file
+ main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, [ "ERROR", "WARNING", "EXCEPT" ], outputMode="d" )
diff --git a/TestON/tests/SCPF/SCPFhostLat/SCPFhostLat.py b/TestON/tests/SCPF/SCPFhostLat/SCPFhostLat.py
index 4298c3d..b742960 100644
--- a/TestON/tests/SCPF/SCPFhostLat/SCPFhostLat.py
+++ b/TestON/tests/SCPF/SCPFhostLat/SCPFhostLat.py
@@ -1,5 +1,5 @@
"""
-Copyright 2016 Open Networking Foundation (ONF)
+Copyright 2016 Open Networking Foundation ( ONF )
Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -8,7 +8,7 @@
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,6 @@
You should have received a copy of the GNU General Public License
along with TestON. If not, see <http://www.gnu.org/licenses/>.
"""
-
"""
SCPFhostLat
This test will test the host found latency.
@@ -213,7 +212,7 @@
caseResult = main.FALSE
resultFile.close()
# Compare the timestemps, and get the lowest one.
- temp = 0;
+ temp = 0
# Get host event timestamps from each nodes
for ctrl in main.Cluster.active():
metricsResult = json.loads( ctrl.CLI.topologyEventsMetrics() )
@@ -229,7 +228,7 @@
# gethost to remove
gethost = main.Cluster.active( 0 ).REST.hosts()
HosttoRemove = []
- HosttoRemove.append( json.loads( gethost[ 1:len( gethost )-1 ] ).get( 'id' ) )
+ HosttoRemove.append( json.loads( gethost[ 1:len( gethost ) - 1 ] ).get( 'id' ) )
main.Cluster.active( 0 ).CLI.removeHost( HosttoRemove )
main.log.info( "Result List: {}".format( addingHostTime ) )
@@ -260,7 +259,7 @@
assertion = main.TRUE
utilities.assert_equals( expect=main.TRUE, actual=assertion,
- onpass='Host latency test successful',
- onfail='Host latency test failed' )
+ onpass='Host latency test successful',
+ onfail='Host latency test failed' )
main.Utils.mininetCleanup( main.Mininet1 )
diff --git a/TestON/tests/SCPF/SCPFintentEventTp/SCPFintentEventTp.py b/TestON/tests/SCPF/SCPFintentEventTp/SCPFintentEventTp.py
index 97f6039..7be0cc3 100644
--- a/TestON/tests/SCPF/SCPFintentEventTp/SCPFintentEventTp.py
+++ b/TestON/tests/SCPF/SCPFintentEventTp/SCPFintentEventTp.py
@@ -1,5 +1,5 @@
"""
-Copyright 2015 Open Networking Foundation (ONF)
+Copyright 2015 Open Networking Foundation ( ONF )
Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -8,7 +8,7 @@
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,25 +18,24 @@
You should have received a copy of the GNU General Public License
along with TestON. If not, see <http://www.gnu.org/licenses/>.
"""
-
-'''
+"""
SCPFintentEventTp
- Use intentperf app to generate a lot of intent install and withdraw events
- Test will run with 1,3,5,7 nodes, and with all neighbors
- Test will run 400 seconds and grep the overall rate from intent-perf summary
yunpeng@onlab.us
-'''
-
+"""
import time
class SCPFintentEventTp:
+
def __init__( self ):
self.default = ''
def CASE0( self, main ):
- '''
+ """
- GIT
- BUILDING ONOS
Pull specific ONOS branch, then Build ONOS ono ONOS Bench.
@@ -44,7 +43,7 @@
test env. We want Jenkins jobs to pull&build for flexibility to handle
different versions of ONOS.
- Construct tests variables
- '''
+ """
try:
from tests.dependencies.ONOSSetup import ONOSSetup
main.testSetUp = ONOSSetup()
@@ -120,6 +119,7 @@
# balanceMasters
main.Cluster.active( 0 ).CLI.balanceMasters()
time.sleep( main.startUpSleep )
+
def CASE2( self, main ):
import numpy
@@ -158,7 +158,7 @@
resultString = "'" + main.commit + "',"
resultString += "'1gig',"
resultString += str( main.Cluster.numCtrls ) + ","
- resultString += "'baremetal" + str( nodes + 1 ) + "',"
+ resultString += "'baremetal" + str(nodes + 1) + "',"
resultString += neighbors + ","
resultString += result[ main.Cluster.active( nodes ).ipAddress ] + ","
resultString += str( 0 ) + "\n" # no stddev
diff --git a/TestON/tests/SCPF/SCPFintentInstallWithdrawLat/SCPFintentInstallWithdrawLat.py b/TestON/tests/SCPF/SCPFintentInstallWithdrawLat/SCPFintentInstallWithdrawLat.py
index 78a2b34..44e0b6e 100644
--- a/TestON/tests/SCPF/SCPFintentInstallWithdrawLat/SCPFintentInstallWithdrawLat.py
+++ b/TestON/tests/SCPF/SCPFintentInstallWithdrawLat/SCPFintentInstallWithdrawLat.py
@@ -1,5 +1,5 @@
"""
-Copyright 2015 Open Networking Foundation (ONF)
+Copyright 2015 Open Networking Foundation ( ONF )
Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -8,7 +8,7 @@
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,23 +18,23 @@
You should have received a copy of the GNU General Public License
along with TestON. If not, see <http://www.gnu.org/licenses/>.
"""
-
"""
SCPFintentInstallWithdrawLat:
- Test the latency of intent installed and withdrawn
- Use Push-test-intents command to push intents
- Use Null provider with 7 devices and linear topology
- Always push intents between 1/6 and 7/5
- - The batch size is defined in parm file. ( default 1,100,1000)
+ - The batch size is defined in parm file. ( default 1,100,1000 )
yunpeng@onlab.us
"""
class SCPFintentInstallWithdrawLat:
+
def __init__( self ):
self.default = ''
def CASE0( self, main ):
- '''
+ """
- GIT
- BUILDING ONOS
Pull specific ONOS branch, then Build ONOS ono ONOS Bench.
@@ -42,8 +42,7 @@
test env. We want Jenkins jobs to pull&build for flexibility to handle
different versions of ONOS.
- Construct tests variables
- '''
-
+ """
try:
from tests.dependencies.ONOSSetup import ONOSSetup
main.testSetUp = ONOSSetup()
@@ -97,6 +96,7 @@
main.testSetUp.envSetupException( e )
main.testSetUp.evnSetupConclusion( stepResult )
main.commit = main.commit.split( " " )[ 1 ]
+
def CASE1( self, main ):
# Clean up test environment and set up
import time
@@ -156,7 +156,7 @@
options="-i",
timeout=main.timeout,
getResponse=True )
- if type( installResult ) is str:
+ if isinstance( installResult, str ):
if "Failure" in installResult:
main.log.error( "Install Intents failure, ignore this iteration." )
if validrun < main.warmUp:
@@ -195,7 +195,7 @@
timeout=main.timeout,
getResponse=True )
- if type( withdrawResult ) is str:
+ if isinstance( withdrawResult, str ):
if "Failure" in withdrawResult:
main.log.error( "withdraw Intents failure, ignore this iteration." )
if validrun < main.warmUp:
@@ -238,8 +238,8 @@
main.log.report( "Install average: {} std: {}".format( installave, installstd ) )
main.log.report( "Withdraw average: {} std: {}".format( withdrawave, withdrawstd ) )
# write result to database file
- if not ( numpy.isnan( installave ) or numpy.isnan( installstd ) or\
- numpy.isnan( withdrawstd ) or numpy.isnan( withdrawave ) ):
+ if not ( numpy.isnan( installave ) or numpy.isnan( installstd ) or
+ numpy.isnan( withdrawstd ) or numpy.isnan( withdrawave ) ):
databaseString = "'" + main.commit + "',"
databaseString += str( main.Cluster.numCtrls ) + ","
databaseString += str( batchSize ) + ","
diff --git a/TestON/tests/SCPF/SCPFintentRerouteLat/SCPFintentRerouteLat.py b/TestON/tests/SCPF/SCPFintentRerouteLat/SCPFintentRerouteLat.py
index 285e12d..41a3408 100644
--- a/TestON/tests/SCPF/SCPFintentRerouteLat/SCPFintentRerouteLat.py
+++ b/TestON/tests/SCPF/SCPFintentRerouteLat/SCPFintentRerouteLat.py
@@ -1,5 +1,5 @@
"""
-Copyright 2015 Open Networking Foundation (ONF)
+Copyright 2015 Open Networking Foundation ( ONF )
Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -8,7 +8,7 @@
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,6 @@
You should have received a copy of the GNU General Public License
along with TestON. If not, see <http://www.gnu.org/licenses/>.
"""
-
# SCPFintentRerouteLat
"""
SCPFintentRerouteLat
@@ -26,24 +25,23 @@
- Test Algorithm:
1. Start Null Provider reroute Topology
2. Using Push-test-intents to push batch size intents from switch 1 to switch 7
- 3. Cut the link between switch 3 and switch 4 (the path will reroute to switch 8)
+ 3. Cut the link between switch 3 and switch 4 ( the path will reroute to switch 8 )
4. Get the topology time stamp
- 5. Get Intent reroute(Installed) time stamp from each nodes
+ 5. Get Intent reroute( Installed ) time stamp from each nodes
6. Use the latest intent time stamp subtract topology time stamp
- This test will run 5 warm up by default, warm up iteration can be setup in Param file
- The intent batch size will default set to 1, 100, and 1000, also can be set in Param file
- The unit of the latency result is milliseconds
"""
-
-
class SCPFintentRerouteLat:
+
def __init__( self ):
self.default = ''
def CASE0( self, main ):
import imp
import os
- '''
+ """
- GIT
- BUILDING ONOS
Pull specific ONOS branch, then Build ONOS ono ONOS Bench.
@@ -51,7 +49,7 @@
test env. We want Jenkins jobs to pull&build for flexibility to handle
different versions of ONOS.
- Construct tests variables
- '''
+ """
try:
from tests.dependencies.ONOSSetup import ONOSSetup
main.testSetUp = ONOSSetup()
@@ -115,11 +113,10 @@
main.testSetUp.evnSetupConclusion( stepResult )
main.commit = main.commit.split( " " )[ 1 ]
-
def CASE1( self, main ):
- '''
+ """
clean up test environment and set up
- '''
+ """
import time
main.maxNumBatch = 0
@@ -239,7 +236,8 @@
main.startLine[ i ] = timestamp
main.log.info( "Timestamp of last LINK_REMOVED event on node {} is {}".format( i + 1,
main.startLine[ i ] ) )
- if skip: continue
+ if skip:
+ continue
# calculate values
topologyTimestamps = main.intentRerouteLatFuncs.getTopologyTimestamps( main )
diff --git a/TestON/tests/SCPF/SCPFintentRerouteLat/dependencies/intentRerouteLatFuncs.py b/TestON/tests/SCPF/SCPFintentRerouteLat/dependencies/intentRerouteLatFuncs.py
index d9d0271..d91f09e 100644
--- a/TestON/tests/SCPF/SCPFintentRerouteLat/dependencies/intentRerouteLatFuncs.py
+++ b/TestON/tests/SCPF/SCPFintentRerouteLat/dependencies/intentRerouteLatFuncs.py
@@ -1,37 +1,39 @@
-'''
+"""
The functions for intentRerouteLat
-'''
+"""
import numpy
import time
import json
+
def _init_( self ):
self.default = ''
+
def sanityCheck( main, linkNumExpected, flowNumExpected, intentNumExpected ):
- '''
+ """
Sanity check on numbers of links, flows and intents in ONOS
- '''
+ """
attemps = 0
main.verify = main.FALSE
linkNum = 0
flowNum = 0
intentNum = 0
while attemps <= main.verifyAttempts:
- time.sleep(main.verifySleep)
+ time.sleep( main.verifySleep )
summary = json.loads( main.Cluster.active( 0 ).CLI.summary( timeout=main.timeout ) )
- linkNum = summary.get("links")
- flowNum = summary.get("flows")
- intentNum = summary.get("intents")
+ linkNum = summary.get( "links" )
+ flowNum = summary.get( "flows" )
+ intentNum = summary.get( "intents" )
if linkNum == linkNumExpected and flowNum == flowNumExpected and intentNum == intentNumExpected:
- main.log.info("links: {}, flows: {}, intents: {}".format(linkNum, flowNum, intentNum))
+ main.log.info( "links: {}, flows: {}, intents: {}".format( linkNum, flowNum, intentNum ) )
main.verify = main.TRUE
break
attemps += 1
if not main.verify:
- main.log.warn("Links or flows or intents number not as expected")
- main.log.warn("links: {}, flows: {}, intents: {}".format(linkNum, flowNum, intentNum))
+ main.log.warn( "Links or flows or intents number not as expected" )
+ main.log.warn( "links: {}, flows: {}, intents: {}".format( linkNum, flowNum, intentNum ) )
# bring back topology
bringBackTopology( main )
if main.validRun >= main.warmUp:
@@ -39,6 +41,7 @@
else:
main.validRun += 1
+
def bringBackTopology( main ):
main.log.info( "Bring back topology " )
main.Cluster.active( 0 ).CLI.pushTestIntents( main.ingress,
@@ -46,20 +49,20 @@
main.batchSize,
offset=1,
options="-w",
- timeout=main.timeout)
+ timeout=main.timeout )
main.Cluster.active( 0 ).CLI.purgeWithdrawnIntents()
main.Cluster.active( 0 ).CLI.setCfg( main.nullProviderCfg,
"deviceCount",
- value=0)
+ value=0 )
main.Cluster.active( 0 ).CLI.setCfg( main.nullProviderCfg,
"enabled",
- value="false")
+ value="false" )
main.Cluster.active( 0 ).CLI.setCfg( main.nullProviderCfg,
"deviceCount",
- value=main.deviceCount)
+ value=main.deviceCount )
main.Cluster.active( 0 ).CLI.setCfg( main.nullProviderCfg,
"enabled",
- value="true")
+ value="true" )
main.Cluster.active( 0 ).CLI.balanceMasters()
time.sleep( main.setMasterSleep )
if main.Cluster.numCtrls > 1:
@@ -69,10 +72,11 @@
main.Cluster.active( 0 ).ipAddress )
time.sleep( main.setMasterSleep )
+
def getLogNum( main, nodeId ):
- '''
+ """
Return the number of karaf log files
- '''
+ """
try:
logNameList = main.ONOSbench.listLog( main.Cluster.active( nodeId ).ipAddress )
assert logNameList is not None
@@ -81,13 +85,14 @@
return 2
return 1
except AssertionError:
- main.log.error("There is no karaf log")
+ main.log.error( "There is no karaf log" )
return -1
+
def getTopologyTimestamps( main ):
- '''
+ """
Get timestamps for the last topology events on all cluster nodes
- '''
+ """
timestamps = []
for i in range( main.Cluster.numCtrls ):
# Search for last topology event in karaf log
@@ -99,7 +104,7 @@
main.log.error( "Error when trying to get topology event timestamp" )
return main.ERROR
try:
- timestampField = lines[0].split( "creationTime=" )
+ timestampField = lines[ 0 ].split( "creationTime=" )
timestamp = timestampField[ 1 ].split( "," )
timestamp = int( timestamp[ 0 ] )
timestamps.append( timestamp )
@@ -108,10 +113,11 @@
return main.ERROR
return timestamps
+
def getIntentTimestamps( main ):
- '''
+ """
Get timestamps for all intent keys on all cluster nodes
- '''
+ """
timestamps = {}
for i in range( main.Cluster.numCtrls ):
# Search for intent INSTALLED event in karaf log
@@ -128,7 +134,7 @@
keyField = line.split( "key=" )
key = keyField[ 1 ].split( "," )
key = key[ 0 ]
- if not key in timestamps.keys():
+ if key not in timestamps.keys():
timestamps[ key ] = []
# Get timestamp
timestampField = line.split( "time = " )
@@ -140,10 +146,11 @@
return main.ERROR
return timestamps
+
def calculateLatency( main, topologyTimestamps, intentTimestamps ):
- '''
+ """
Calculate reroute latency values using timestamps
- '''
+ """
topologyTimestamp = numpy.min( topologyTimestamps )
firstInstalledLatency = {}
lastInstalledLatency = {}
diff --git a/TestON/tests/SCPF/SCPFmastershipFailoverLat/SCPFmastershipFailoverLat.py b/TestON/tests/SCPF/SCPFmastershipFailoverLat/SCPFmastershipFailoverLat.py
index ecbf5cd..0a99c41 100644
--- a/TestON/tests/SCPF/SCPFmastershipFailoverLat/SCPFmastershipFailoverLat.py
+++ b/TestON/tests/SCPF/SCPFmastershipFailoverLat/SCPFmastershipFailoverLat.py
@@ -1,5 +1,5 @@
"""
-Copyright 2017 Open Networking Foundation (ONF)
+Copyright 2017 Open Networking Foundation ( ONF )
Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -8,7 +8,7 @@
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,15 +18,15 @@
You should have received a copy of the GNU General Public License
along with TestON. If not, see <http://www.gnu.org/licenses/>.
"""
-
class SCPFmastershipFailoverLat:
+
def __init__( self ):
self.default = ''
def CASE0( self, main ):
import os
import imp
- '''
+ """
- GIT
- BUILDING ONOS
Pull specific ONOS branch, then Build ONOS ono ONOS Bench.
@@ -34,7 +34,7 @@
test env. We want Jenkins jobs to pull&build for flexibility to handle
different versions of ONOS.
- Construct tests variables
- '''
+ """
try:
from tests.dependencies.ONOSSetup import ONOSSetup
main.testSetUp = ONOSSetup()
@@ -79,8 +79,6 @@
main.testSetUp.envSetupException( e )
main.testSetUp.evnSetupConclusion( stepResult )
-
-
def CASE1( self, main ):
# Clean up test environment and set up
import time
@@ -110,11 +108,10 @@
onpass="Mininet was set up correctly.",
onfail="Mininet was NOT set up correctly." )
-
def CASE2( self, main ):
"""
Kill ONOS node, and measure the latency for INSTANCE_DEACTIVATED, MASTER_CHANGED, and role request
- (tshark time), then bring the node back up.
+ ( tshark time ), then bring the node back up.
"""
import time
import datetime
@@ -123,14 +120,17 @@
main.HA = HA()
- main.latencyData = { 'kill_to_deactivation' : [],
- 'deactivation_to_role_request' : [] }
+ main.latencyData = { 'kill_to_deactivation': [],
+ 'deactivation_to_role_request': [] }
main.failCounter = 0
passingResult = True
criticalError = False
- main.step( "Gathering data starting with " + str( main.warmUp ) + " warm ups and a sample size of " + str( main.sampleSize ) )
+ main.step( "Gathering data starting with "
+ + str( main.warmUp )
+ + " warm ups and a sample size of "
+ + str( main.sampleSize ) )
for iteration in range( 0, main.sampleSize + main.warmUp ):
@@ -185,10 +185,12 @@
eventOutput = main.Cluster.active( CLInum ).CLI.events( args='-a' ).split( "\r\n" )
for line in reversed( eventOutput ):
if "INSTANCE_DEACTIVATED" in line and len( instanceDeactivatedLats ) == CLInum:
- deactivateTime = float( datetime.datetime.strptime( line.split()[ 0 ], "%Y-%m-%dT%H:%M:%S.%f" ).strftime( '%s.%f' ) ) * 1000.0
+ deactivateTime = float( datetime.datetime.strptime(
+ line.split()[ 0 ], "%Y-%m-%dT%H:%M:%S.%f" ).strftime( '%s.%f' ) ) * 1000.0
instanceDeactivatedLats.append( deactivateTime - time1 )
elif "MASTER_CHANGED" in line and len( masterChangedLats ) == CLInum:
- changedTime = float( datetime.datetime.strptime( line.split()[ 0 ], "%Y-%m-%dT%H:%M:%S.%f" ).strftime( '%s.%f' ) ) * 1000.0
+ changedTime = float( datetime.datetime.strptime(
+ line.split()[ 0 ], "%Y-%m-%dT%H:%M:%S.%f" ).strftime( '%s.%f' ) ) * 1000.0
masterChangedLats.append( changedTime - time1 )
if len( instanceDeactivatedLats ) > CLInum and len( masterChangedLats ) > CLInum:
break
@@ -228,9 +230,10 @@
if eventLatCheck and tsharkLatCheck and validDataCheck:
main.log.info( "Saving data..." )
- main.latencyData[ 'kill_to_deactivation' ].append( instanceDeactivated )
- main.latencyData[ 'deactivation_to_role_request' ].append( roleRequestLat - instanceDeactivated )
-
+ main.latencyData[ 'kill_to_deactivation' ]\
+ .append( instanceDeactivated )
+ main.latencyData[ 'deactivation_to_role_request' ]\
+ .append( roleRequestLat - instanceDeactivated )
# Restart ONOS node
main.log.info( "Restart ONOS node " + strNodeNumToKill + " and checking status of restart." )
@@ -279,24 +282,28 @@
main.failCounter += 1
main.log.warn( "Iteration failed. Failure count: " + str( main.failCounter ) )
if float( main.failCounter ) / float( main.sampleSize ) >= main.failPercent or criticalError:
- main.log.error( str( main.failPercent * 100 ) + "% or more of data is invalid, or a critical error has occurred." )
+ main.log.error( str( main.failPercent * 100 )
+ + "% or more of data is invalid, or a critical error has occurred." )
passingResult = False
break
utilities.assert_equals( expect=True, actual=passingResult,
- onpass="Node scaling " + str( main.Cluster.numCtrls ) + " data gathering was successful.",
- onfail="Node scaling " + str( main.Cluster.numCtrls ) + " data gathering FAILED. Stopping test.")
+ onpass="Node scaling "
+ + str( main.Cluster.numCtrls )
+ + " data gathering was successful.",
+ onfail="Node scaling "
+ + str( main.Cluster.numCtrls )
+ + " data gathering FAILED. Stopping test." )
if not passingResult:
main.cleanAndExit()
-
def CASE3( self, main ):
"""
Write results to database file.
Omit this case if you don't want to write to database.
"""
import numpy
- result = { 'avg' : {}, 'stddev' : {} }
+ result = { 'avg': {}, 'stddev': {} }
for i in main.latencyData:
result[ 'avg' ][ i ] = numpy.average( main.latencyData[ i ] )
@@ -305,7 +312,7 @@
main.log.info( "result: " + str( result ) )
with open( main.dbFileName, "a" ) as dbFile:
strToWrite = str( main.Cluster.numCtrls ) + ",'baremetal1'"
- strToWrite += ",'" + main.commit.split()[ 1 ] + "'"
+ strToWrite += ",'" + main.commit.split()[1] + "'"
for i in result:
for j in result[ i ]:
strToWrite += "," + str( result[ i ][ j ] )
diff --git a/TestON/tests/SCPF/SCPFportLat/SCPFportLat.py b/TestON/tests/SCPF/SCPFportLat/SCPFportLat.py
index 0c18564..180d860 100644
--- a/TestON/tests/SCPF/SCPFportLat/SCPFportLat.py
+++ b/TestON/tests/SCPF/SCPFportLat/SCPFportLat.py
@@ -1,5 +1,5 @@
"""
-Copyright 2015 Open Networking Foundation (ONF)
+Copyright 2015 Open Networking Foundation ( ONF )
Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -8,7 +8,7 @@
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,23 +18,23 @@
You should have received a copy of the GNU General Public License
along with TestON. If not, see <http://www.gnu.org/licenses/>.
"""
-
-'''
+"""
SCPFportLat test
Test latency for port status change
Up & Down:
PortStatus --- Device --- Link --- Graph
yunpeng@onlab.us
-'''
+"""
class SCPFportLat:
+
def __init__( self ):
self.default = ''
def CASE0( self, main ):
import os
import imp
- '''
+ """
- GIT
- BUILDING ONOS
Pull specific ONOS branch, then Build ONOS ono ONOS Bench.
@@ -42,7 +42,7 @@
test env. We want Jenkins jobs to pull&build for flexibility to handle
different versions of ONOS.
- Construct tests variables
- '''
+ """
try:
from tests.dependencies.ONOSSetup import ONOSSetup
main.testSetUp = ONOSSetup()
@@ -87,9 +87,9 @@
resultsDB.close()
main.portFunc = imp.load_source( main.dependencyFunc,
- main.dependencyPath +
- main.dependencyFunc +
- ".py" )
+ main.dependencyPath +
+ main.dependencyFunc +
+ ".py" )
except Exception as e:
main.testSetUp.envSetupException( e )
main.testSetUp.evnSetupConclusion( stepResult )
@@ -111,9 +111,9 @@
time.sleep( 1 )
main.log.info( "Copy topology file to Mininet" )
main.ONOSbench.copyMininetFile( main.topoName,
- main.dependencyPath,
- main.Mininet1.user_name,
- main.Mininet1.ip_address )
+ main.dependencyPath,
+ main.Mininet1.user_name,
+ main.Mininet1.ip_address )
try:
from tests.dependencies.utils import Utils
except ImportError:
@@ -140,7 +140,7 @@
import time
import numpy
# dictionary for each node and each timestamps
- resultDict = { 'up' : {}, 'down' : {} }
+ resultDict = { 'up': {}, 'down': {} }
for d in resultDict:
for i in range( 1, main.Cluster.numCtrls + 1 ):
resultDict[ d ][ 'node' + str( i ) ] = {}
@@ -152,7 +152,7 @@
resultDict[ d ][ 'node' + str( i ) ][ 'LtoG' ] = []
for i in range( 0, main.sampleSize + main.warmUp ):
main.log.info( "==========================================" )
- main.log.info( "================iteration:{}==============".format( str ( i + 1 ) ) )
+ main.log.info( "================iteration:{}==============".format( str( i + 1 ) ) )
if i >= main.warmUp:
# Portdown iteration
main.portFunc.capturePortStatusPack( main,
@@ -185,7 +185,7 @@
True )
# Dictionary for result
- maxDict = {}
+ maxDict = {}
maxDict[ 'down' ] = {}
maxDict[ 'up' ] = {}
maxDict[ 'down' ][ 'max' ] = 0
diff --git a/TestON/tests/SCPF/SCPFportLat/dependencies/portFunc.py b/TestON/tests/SCPF/SCPFportLat/dependencies/portFunc.py
index f773da3..4c94193 100644
--- a/TestON/tests/SCPF/SCPFportLat/dependencies/portFunc.py
+++ b/TestON/tests/SCPF/SCPFportLat/dependencies/portFunc.py
@@ -1,5 +1,5 @@
"""
-Copyright 2016 Open Networking Foundation (ONF)
+Copyright 2016 Open Networking Foundation ( ONF )
Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -8,7 +8,7 @@
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,15 +18,13 @@
You should have received a copy of the GNU General Public License
along with TestON. If not, see <http://www.gnu.org/licenses/>.
"""
-
import time
import json
-'''
+"""
Warp function for SCPFportLat test
-'''
-
+"""
def capturePortStatusPack( main, deviceName, interface, portStatus, resultDict, warmup ):
- '''
+ """
Change device port status and use tshark to capture openflow port package
Args:
main: TestON class
@@ -36,10 +34,10 @@
resultDict: put result to dictionary
warmup: if warmup, ignore results
- '''
+ """
main.log.info( "Clean up tshark" )
with open( main.tsharkResultPath, "w" ) as tshark:
- tshark.write("")
+ tshark.write( "" )
main.log.info( "Starting tshark capture" )
main.ONOSbench.tsharkGrep( main.ofportStatus, main.tsharkResultPath )
time.sleep( main.measurementSleep )
@@ -55,7 +53,7 @@
main.log.info( "Capture result:" + resultText )
resultText = resultText.split( " " )
if len( resultText ) > 1:
- tsharkResultTime = int( float( resultText[1] ) * 1000.0 )
+ tsharkResultTime = int( float( resultText[ 1 ] ) * 1000.0 )
resultFile.close()
for i in range( 1, main.Cluster.numCtrls + 1 ):
main.log.info( "================================================" )
@@ -92,9 +90,9 @@
else:
# put result to dictionary
if not warmup:
- resultDict[ portStatus ][ 'node' + str(i) ]['EtoE'].append( EtoE )
- resultDict[ portStatus ][ 'node' + str(i) ]['PtoD'].append( PtoD )
- resultDict[ portStatus ][ 'node' + str(i) ]['DtoL'].append( DtoL )
- resultDict[ portStatus ][ 'node' + str(i) ]['LtoG'].append( LtoG )
+ resultDict[ portStatus ][ 'node' + str( i ) ][ 'EtoE' ].append( EtoE )
+ resultDict[ portStatus ][ 'node' + str( i ) ][ 'PtoD' ].append( PtoD )
+ resultDict[ portStatus ][ 'node' + str( i ) ][ 'DtoL' ].append( DtoL )
+ resultDict[ portStatus ][ 'node' + str( i ) ][ 'LtoG' ].append( LtoG )
else:
main.log.error( "Unexpected tshark output file" )
diff --git a/TestON/tests/SCPF/SCPFportLat/dependencies/topo-perf-2sw.py b/TestON/tests/SCPF/SCPFportLat/dependencies/topo-perf-2sw.py
index 828e44a..7efed0c 100644
--- a/TestON/tests/SCPF/SCPFportLat/dependencies/topo-perf-2sw.py
+++ b/TestON/tests/SCPF/SCPFportLat/dependencies/topo-perf-2sw.py
@@ -1,5 +1,5 @@
"""
-Copyright 2016 Open Networking Foundation (ONF)
+Copyright 2016 Open Networking Foundation ( ONF )
Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -8,7 +8,7 @@
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,18 +18,18 @@
You should have received a copy of the GNU General Public License
along with TestON. If not, see <http://www.gnu.org/licenses/>.
"""
-
-'''
+"""
Simple 2 switch topology for topologoy performance test
-'''
-
+"""
from mininet.topo import Topo
+
class MyTopo( Topo ):
- def __init__(self):
- Topo.__init__(self)
- s1 = self.addSwitch( "s1", dpid="0000000000000001")
- s2 = self.addSwitch( "s2", dpid="0000000000000002")
+
+ def __init__( self ):
+ Topo.__init__( self )
+ s1 = self.addSwitch( "s1", dpid="0000000000000001" )
+ s2 = self.addSwitch( "s2", dpid="0000000000000002" )
h1 = self.addHost( "h1" )
h2 = self.addHost( "h2" )
diff --git a/TestON/tests/SCPF/SCPFscaleTopo/SCPFscaleTopo.py b/TestON/tests/SCPF/SCPFscaleTopo/SCPFscaleTopo.py
index 0ecee0b..d4740f4 100644
--- a/TestON/tests/SCPF/SCPFscaleTopo/SCPFscaleTopo.py
+++ b/TestON/tests/SCPF/SCPFscaleTopo/SCPFscaleTopo.py
@@ -1,5 +1,5 @@
"""
-Copyright 2015 Open Networking Foundation (ONF)
+Copyright 2015 Open Networking Foundation ( ONF )
Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -8,7 +8,7 @@
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,10 +18,10 @@
You should have received a copy of the GNU General Public License
along with TestON. If not, see <http://www.gnu.org/licenses/>.
"""
-
# Testing network scalability, this test suite scales up a network topology
# using mininet and verifies ONOS stability
+
class SCPFscaleTopo:
def __init__( self ):
@@ -81,19 +81,18 @@
main.homeDir = os.path.expanduser( '~' )
main.hostsData = {}
-
stepResult = main.testSetUp.envSetup()
- main.allinfo = {} # The dictionary to record all the data from karaf.log
+ main.allinfo = {} # The dictionary to record all the data from karaf.log
for i in range( 2 ):
- main.allinfo[ i ]={}
- for w in range ( 3 ):
+ main.allinfo[ i ] = {}
+ for w in range( 3 ):
# Totaltime: the time from the new switchConnection to its end
# swConnection: the time from the first new switchConnection to the last new switchConnection
# lastSwToLastRr: the time from the last new switchConnection to the last role request
# lastRrToLastTopology: the time form the last role request to the last topology
# disconnectRate: the rate that shows how many switch disconnect after connection
- main.allinfo[ i ][ 'info' + str( w ) ]= { 'totalTime': 0, 'swConnection': 0, 'lastSwToLastRr': 0, 'lastRrToLastTopology': 0, 'disconnectRate': 0 }
+ main.allinfo[ i ][ 'info' + str( w ) ] = { 'totalTime': 0, 'swConnection': 0, 'lastSwToLastRr': 0, 'lastRrToLastTopology': 0, 'disconnectRate': 0 }
main.dbFilePath = main.params[ 'DATABASE' ][ 'dbPath' ]
main.log.info( "Create Database file " + main.dbFilePath )
@@ -149,20 +148,20 @@
"""
Starting up torus topology
"""
-
main.case( "Starting up Mininet and verifying topology" )
main.caseExplanation = "Starting Mininet with a scalling topology and " +\
"comparing topology elements between Mininet and ONOS"
if main.topoScale:
main.currScale = main.topoScale.pop( 0 )
- else: main.log.error( "topology scale is empty" )
+ else:
+ main.log.error( "topology scale is empty" )
main.step( "Starting up TORUS %sx%s topology" % ( main.currScale, main.currScale ) )
main.log.info( "Constructing Mininet command" )
mnCmd = " mn --custom " + main.Mininet1.home + main.multiovs + \
" --switch ovsm --topo " + main.topoName + "," + main.currScale + "," + main.currScale
for ctrl in main.Cluster.runningNodes:
- mnCmd += " --controller remote,ip=" + ctrl.ipAddress
+ mnCmd += " --controller remote,ip=" + ctrl.ipAddress
stepResult = main.Mininet1.startNet( mnCmd=mnCmd )
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
@@ -226,7 +225,7 @@
main.step( "Comparing MN topology to ONOS topology" )
compareRetry = 0
while compareRetry < 3:
- #While loop for retry
+ # While loop for retry
devices = main.topoRelated.getAll( "devices" )
ports = main.topoRelated.getAll( "ports" )
links = main.topoRelated.getAll( "links" )
@@ -240,8 +239,8 @@
devices, ports )
currentLinksResult = main.topoRelated.compareBase( links, controller,
- main.Mininet1.compareLinks,
- [ mnSwitches, mnLinks ] )
+ main.Mininet1.compareLinks,
+ [ mnSwitches, mnLinks ] )
stepResult = stepResult and currentDevicesResult and currentLinksResult
if stepResult:
@@ -250,24 +249,24 @@
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
onpass=" Topology match Mininet",
- onfail="ONOS Topology doesn't match Mininet")
+ onfail="ONOS Topology doesn't match Mininet" )
if stepResult:
if main.hostDiscover:
hostList = []
for i in range( 1, int( main.currScale ) + 1 ):
- for j in range( 1, int( main.currScale ) + 1) :
+ for j in range( 1, int( main.currScale ) + 1 ):
# Generate host list
- hoststr = "h" + str(i) + "x" + str(j)
- hostList.append(hoststr)
- for i in range( len(hostList) ):
- totalHost = main.topo.sendArpPackage( main, hostList[i] )
+ hoststr = "h" + str( i ) + "x" + str( j )
+ hostList.append( hoststr )
+ for i in range( len( hostList ) ):
+ totalHost = main.topo.sendArpPackage( main, hostList[ i ] )
time.sleep( main.hostDiscoverSleep )
if totalHost < 0:
# if totalHost less than 0 which means dependence function has exception.
main.log.info( "Error when discover host!" )
break
- if totalHost == int( main.currScale ) * int( main.currScale ):
+ if totalHost == int( main.currScale ) * int( main.currScale ):
main.log.info( "Discovered all hosts" )
stepResult = stepResult and main.TRUE
else:
@@ -276,18 +275,17 @@
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
onpass=" Topology match Mininet",
- onfail="ONOS Topology doesn't match Mininet")
+ onfail="ONOS Topology doesn't match Mininet" )
main.log.info( "Finished this iteration, continue to scale next topology." )
else:
main.log.info( "Clean up and exit TestON. Finished this test." )
main.cleanAndExit()
def CASE100( self, main ):
- '''
+ """
Bring Down node 3
- '''
-
- main.case("Bring ONOS node 3 down: TORUS %sx%s" % (main.currScale, main.currScale))
+ """
+ main.case( "Bring ONOS node 3 down: TORUS %sx%s" % ( main.currScale, main.currScale ) )
main.caseExplanation = "Balance masters to make sure " +\
"each controller has some devices and " +\
"stop ONOS node 3 service. "
@@ -309,11 +307,10 @@
onfail="Failed to bring down node 3" )
def CASE200( self, main ):
- '''
+ """
Bring up onos node
- '''
-
- main.case("Bring ONOS node 3 up: TORUS %sx%s" % (main.currScale, main.currScale))
+ """
+ main.case( "Bring ONOS node 3 up: TORUS %sx%s" % ( main.currScale, main.currScale ) )
main.caseExplanation = "Bring node 3 back up and balance the masters"
ctrl = main.Cluster.runningNodes[ main.deadNode ]
node = main.deadNode + 1
@@ -330,15 +327,13 @@
onpass="Successfully brought up onos node %s" % node,
onfail="Failed to bring up onos node %s" % node )
-
- time.sleep(main.nodeSleep)
+ time.sleep( main.nodeSleep )
def CASE300( self, main ):
- '''
-
+ """
Balancing Masters
- '''
- time.sleep(main.balanceSleep)
+ """
+ time.sleep( main.balanceSleep )
main.step( "Balancing Masters" )
stepResult = main.FALSE
@@ -353,56 +348,56 @@
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
onpass="Balance masters was successfull",
- onfail="Failed to balance masters")
+ onfail="Failed to balance masters" )
time.sleep( main.balanceSleep )
def CASE1000( self, main ):
- '''
+ """
Report errors/warnings/exceptions
- '''
+ """
# Compare the slowest Node through total time of each node
slowestNode = 0
slowestTotalTime = 0
# Second capture
for i in range( 3 ):
# Calculate total time
- main.allinfo[ 1 ][ 'info' + str( i )][ 'totalTime' ] = main.scaleTopoFunction.getInfoFromLog( main,
- main.searchTerm[ 'start' ],
- 'first',
- main.searchTerm[ 'end' ],
- 'last',
- index=i,
- funcMode='TD' )
+ main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ] = main.scaleTopoFunction.getInfoFromLog( main,
+ main.searchTerm[ 'start' ],
+ 'first',
+ main.searchTerm[ 'end' ],
+ 'last',
+ index=i,
+ funcMode='TD' )
# Compare the total time
if main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ] > slowestTotalTime:
slowestTotalTime = main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ]
slowestNode = i
# Calculate switch connection time
- main.allinfo[ 1 ][ 'info' + str( i )][ 'swConnection' ] = main.scaleTopoFunction.getInfoFromLog( main,
- main.searchTerm[ 'start' ],
- 'first',
- main.searchTerm[ 'start' ],
- 'last',
- index=i,
- funcMode='TD' )
+ main.allinfo[ 1 ][ 'info' + str( i ) ][ 'swConnection' ] = main.scaleTopoFunction.getInfoFromLog( main,
+ main.searchTerm[ 'start' ],
+ 'first',
+ main.searchTerm[ 'start' ],
+ 'last',
+ index=i,
+ funcMode='TD' )
# Calculate the time from last switch connection to the last role request
- main.allinfo[ 1 ][ 'info' + str( i )][ 'lastSwToLastRr' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main,
- main.searchTerm[ 'start' ],
- 'last',
- index=i )
+ main.allinfo[ 1 ][ 'info' + str( i ) ][ 'lastSwToLastRr' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main,
+ main.searchTerm[ 'start' ],
+ 'last',
+ index=i )
# Calculate the time from the last role request to the last topology
- main.allinfo[ 1 ][ 'info' + str( i )][ 'lastRrToLastTopology' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main,
- main.searchTerm[ 'end' ],
- 'last',
- index=i )
+ main.allinfo[ 1 ][ 'info' + str( i ) ][ 'lastRrToLastTopology' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main,
+ main.searchTerm[ 'end' ],
+ 'last',
+ index=i )
# Calculate the disconnecti rate
- main.allinfo[ 1 ][ 'info' + str( i )][ 'disconnectRate' ] = main.scaleTopoFunction.getInfoFromLog( main,
- main.searchTerm[ 'Disconnect' ],
- 'num',
- main.searchTerm[ 'start' ],
- 'num',
- index=i,
- funcMode='DR' )
+ main.allinfo[ 1 ][ 'info' + str( i ) ][ 'disconnectRate' ] = main.scaleTopoFunction.getInfoFromLog( main,
+ main.searchTerm[ 'Disconnect' ],
+ 'num',
+ main.searchTerm[ 'start' ],
+ 'num',
+ index=i,
+ funcMode='DR' )
if ( main.allinfo[ 0 ] != main.allinfo[ 1 ] ):
main.log.error( "The results of two capture are different!" )
@@ -414,11 +409,11 @@
temp = str( main.currScale )
temp += ",'baremetal1'"
# put result from second capture into data base
- temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'totalTime' ] )
- temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'swConnection' ] )
- temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'lastSwToLastRr' ] )
- temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'lastRrToLastTopology' ] )
- temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'disconnectRate' ] )
+ temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode ) ][ 'totalTime' ] )
+ temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode ) ][ 'swConnection' ] )
+ temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode ) ][ 'lastSwToLastRr' ] )
+ temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode ) ][ 'lastRrToLastTopology' ] )
+ temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode ) ][ 'disconnectRate' ] )
temp += "\n"
dbFile.write( temp )
else:
diff --git a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/multiovs.py b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/multiovs.py
old mode 100755
new mode 100644
index 9849069..e15fe72
--- a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/multiovs.py
+++ b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/multiovs.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
"""
-Copyright 2015 Open Networking Foundation (ONF)
+Copyright 2015 Open Networking Foundation ( ONF )
Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -10,7 +10,7 @@
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -20,7 +20,6 @@
You should have received a copy of the GNU General Public License
along with TestON. If not, see <http://www.gnu.org/licenses/>.
"""
-
"""
Multiple ovsdb OVS!!
@@ -32,7 +31,6 @@
delegated to the ovsdb instance.
"""
-
from mininet.net import Mininet
from mininet.node import Node, OVSSwitch
from mininet.node import OVSBridge
@@ -46,7 +44,9 @@
from itertools import groupby
from operator import attrgetter
+
class OVSDB( Node ):
+
"Namespace for an OVSDB instance"
privateDirs = [ '/etc/openvswitch',
@@ -70,7 +70,7 @@
info( '### Adding NAT for control and data networks'
' (use --nat flush=0 for data network)\n' )
cls.cnet = cnet
- cls.nat = cnet.addNAT( 'ovsdbnat0')
+ cls.nat = cnet.addNAT( 'ovsdbnat0' )
cnet.start()
info( '### Control network started\n' )
return cnet
@@ -155,6 +155,7 @@
class OVSSwitchNS( OVSSwitch ):
+
"OVS Switch in shared OVSNS namespace"
isSetup = False
@@ -162,7 +163,7 @@
@classmethod
def batchStartup( cls, switches ):
result = []
- for ovsdb, switchGroup in groupby( switches, attrgetter( 'ovsdb') ):
+ for ovsdb, switchGroup in groupby( switches, attrgetter( 'ovsdb' ) ):
switchGroup = list( switchGroup )
info( '(%s)' % ovsdb )
result += OVSSwitch.batchStartup( switchGroup, run=ovsdb.cmd )
@@ -171,7 +172,7 @@
@classmethod
def batchShutdown( cls, switches ):
result = []
- for ovsdb, switchGroup in groupby( switches, attrgetter( 'ovsdb') ):
+ for ovsdb, switchGroup in groupby( switches, attrgetter( 'ovsdb' ) ):
switchGroup = list( switchGroup )
info( '(%s)' % ovsdb )
for switch in switches:
@@ -214,7 +215,7 @@
# Delegate methods and initialize local vars
attrs = ( 'cmd', 'cmdPrint', 'sendCmd', 'waitOutput',
'monitor', 'write', 'read',
- 'pid', 'shell', 'stdout',)
+ 'pid', 'shell', 'stdout', )
for attr in attrs:
setattr( self, attr, getattr( ovsdb, attr ) )
self.defaultIntf().updateIP()
@@ -246,14 +247,14 @@
super( OVSSwitchNS, self ).terminate( *args, **kwargs )
else:
self.pid = None
- self.shell= None
+ self.shell = None
def defaultIntf( self ):
return self.ovsdb.defaultIntf()
def __init__( self, *args, **kwargs ):
"""n: number of OVS instances per OVSDB
- shell: run private shell/bash process? (False)
+ shell: run private shell/bash process? ( False )
If shell is shared/not private, cmd() and popen() are
delegated to the OVSDB instance, which is different than
regular OVSSwitch semantics!!"""
@@ -261,7 +262,9 @@
self.privateShell = kwargs.pop( 'shell', False )
super( OVSSwitchNS, self ).__init__( *args, **kwargs )
+
class OVSLinkNS( Link ):
+
"OVSLink that supports OVSSwitchNS"
def __init__( self, node1, node2, **kwargs ):
@@ -279,6 +282,7 @@
links = { 'ovs': OVSLinkNS }
+
def test():
"Test OVSNS switch"
setLogLevel( 'info' )
diff --git a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/newFuncTopo.py b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/newFuncTopo.py
old mode 100755
new mode 100644
index 1f1c487..596ff2c
--- a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/newFuncTopo.py
+++ b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/newFuncTopo.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
"""
-Copyright 2015 Open Networking Foundation (ONF)
+Copyright 2015 Open Networking Foundation ( ONF )
Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -10,7 +10,7 @@
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -20,7 +20,6 @@
You should have received a copy of the GNU General Public License
along with TestON. If not, see <http://www.gnu.org/licenses/>.
"""
-
"""
Custom topology for Mininet
"""
@@ -35,19 +34,23 @@
from mininet.util import dumpNodeConnections
from mininet.node import ( UserSwitch, OVSSwitch, IVSSwitch )
+
class VLANHost( Host ):
+
def config( self, vlan=100, **params ):
r = super( Host, self ).config( **params )
intf = self.defaultIntf()
self.cmd( 'ifconfig %s inet 0' % intf )
self.cmd( 'vconfig add %s %d' % ( intf, vlan ) )
- self.cmd( 'ifconfig %s.%d inet %s' % ( intf, vlan, params['ip'] ) )
+ self.cmd( 'ifconfig %s.%d inet %s' % ( intf, vlan, params[ 'ip' ] ) )
newName = '%s.%d' % ( intf, vlan )
intf.name = newName
self.nameToIntf[ newName ] = intf
return r
+
class IPv6Host( Host ):
+
def config( self, v6Addr='1000:1/64', **params ):
r = super( Host, self ).config( **params )
intf = self.defaultIntf()
@@ -55,56 +58,59 @@
self.cmd( 'ip -6 addr add %s dev %s' % ( v6Addr, intf ) )
return r
+
class dualStackHost( Host ):
+
def config( self, v6Addr='2000:1/64', **params ):
r = super( Host, self ).config( **params )
intf = self.defaultIntf()
self.cmd( 'ip -6 addr add %s dev %s' % ( v6Addr, intf ) )
return r
+
class MyTopo( Topo ):
def __init__( self ):
# Initialize topology
Topo.__init__( self )
# Switch S5 Hosts
- host1=self.addHost( 'h1', ip='10.1.0.2/24' )
- host2=self.addHost( 'h2', cls=IPv6Host, v6Addr='1000::2/64' )
- host3=self.addHost( 'h3', ip='10.1.0.3/24', cls=dualStackHost, v6Addr='2000::2/64' )
- #VLAN hosts
- host4=self.addHost( 'h4', ip='100.1.0.2/24', cls=VLANHost, vlan=100 )
- host5=self.addHost( 'h5', ip='200.1.0.2/24', cls=VLANHost, vlan=200 )
- #VPN-1 and VPN-2 Hosts
- host6=self.addHost( 'h6', ip='11.1.0.2/24' )
- host7=self.addHost( 'h7', ip='12.1.0.2/24' )
- #Multicast Sender
- host8=self.addHost( 'h8', ip='10.1.0.4/24' )
+ host1 = self.addHost( 'h1', ip='10.1.0.2/24' )
+ host2 = self.addHost( 'h2', cls=IPv6Host, v6Addr='1000::2/64' )
+ host3 = self.addHost( 'h3', ip='10.1.0.3/24', cls=dualStackHost, v6Addr='2000::2/64' )
+ # VLAN hosts
+ host4 = self.addHost( 'h4', ip='100.1.0.2/24', cls=VLANHost, vlan=100 )
+ host5 = self.addHost( 'h5', ip='200.1.0.2/24', cls=VLANHost, vlan=200 )
+ # VPN-1 and VPN-2 Hosts
+ host6 = self.addHost( 'h6', ip='11.1.0.2/24' )
+ host7 = self.addHost( 'h7', ip='12.1.0.2/24' )
+ # Multicast Sender
+ host8 = self.addHost( 'h8', ip='10.1.0.4/24' )
# Switch S6 Hosts
- host9=self.addHost( 'h9', ip='10.1.0.5/24' )
- host10=self.addHost( 'h10', cls=IPv6Host, v6Addr='1000::3/64' )
- host11=self.addHost( 'h11', ip='10.1.0.6/24', cls=dualStackHost, v6Addr='2000::3/64' )
- #VLAN hosts
- host12=self.addHost( 'h12', ip='100.1.0.3/24', cls=VLANHost, vlan=100 )
- host13=self.addHost( 'h13', ip='200.1.0.3/24', cls=VLANHost, vlan=200 )
- #VPN-1 and VPN-2 Hosts
- host14=self.addHost( 'h14', ip='11.1.0.3/24' )
- host15=self.addHost( 'h15', ip='12.1.0.3/24' )
- #Multicast Receiver
- host16=self.addHost( 'h16', ip='10.1.0.7/24' )
+ host9 = self.addHost( 'h9', ip='10.1.0.5/24' )
+ host10 = self.addHost( 'h10', cls=IPv6Host, v6Addr='1000::3/64' )
+ host11 = self.addHost( 'h11', ip='10.1.0.6/24', cls=dualStackHost, v6Addr='2000::3/64' )
+ # VLAN hosts
+ host12 = self.addHost( 'h12', ip='100.1.0.3/24', cls=VLANHost, vlan=100 )
+ host13 = self.addHost( 'h13', ip='200.1.0.3/24', cls=VLANHost, vlan=200 )
+ # VPN-1 and VPN-2 Hosts
+ host14 = self.addHost( 'h14', ip='11.1.0.3/24' )
+ host15 = self.addHost( 'h15', ip='12.1.0.3/24' )
+ # Multicast Receiver
+ host16 = self.addHost( 'h16', ip='10.1.0.7/24' )
# Switch S7 Hosts
- host17=self.addHost( 'h17', ip='10.1.0.8/24' )
- host18=self.addHost( 'h18', cls=IPv6Host, v6Addr='1000::4/64' )
- host19=self.addHost( 'h19', ip='10.1.0.9/24', cls=dualStackHost, v6Addr='2000::4/64' )
- #VLAN hosts
- host20=self.addHost( 'h20', ip='100.1.0.4/24', cls=VLANHost, vlan=100 )
- host21=self.addHost( 'h21', ip='200.1.0.4/24', cls=VLANHost, vlan=200 )
- #VPN-1 and VPN-2 Hosts
- host22=self.addHost( 'h22', ip='11.1.0.4/24' )
- host23=self.addHost( 'h23', ip='12.1.0.4/24' )
- #Multicast Receiver
- host24=self.addHost( 'h24', ip='10.1.0.10/24' )
+ host17 = self.addHost( 'h17', ip='10.1.0.8/24' )
+ host18 = self.addHost( 'h18', cls=IPv6Host, v6Addr='1000::4/64' )
+ host19 = self.addHost( 'h19', ip='10.1.0.9/24', cls=dualStackHost, v6Addr='2000::4/64' )
+ # VLAN hosts
+ host20 = self.addHost( 'h20', ip='100.1.0.4/24', cls=VLANHost, vlan=100 )
+ host21 = self.addHost( 'h21', ip='200.1.0.4/24', cls=VLANHost, vlan=200 )
+ # VPN-1 and VPN-2 Hosts
+ host22 = self.addHost( 'h22', ip='11.1.0.4/24' )
+ host23 = self.addHost( 'h23', ip='12.1.0.4/24' )
+ # Multicast Receiver
+ host24 = self.addHost( 'h24', ip='10.1.0.10/24' )
s1 = self.addSwitch( 's1' )
s2 = self.addSwitch( 's2' )
@@ -114,56 +120,57 @@
s6 = self.addSwitch( 's6' )
s7 = self.addSwitch( 's7' )
- self.addLink(s5,host1)
- self.addLink(s5,host2)
- self.addLink(s5,host3)
- self.addLink(s5,host4)
- self.addLink(s5,host5)
- self.addLink(s5,host6)
- self.addLink(s5,host7)
- self.addLink(s5,host8)
+ self.addLink( s5, host1 )
+ self.addLink( s5, host2 )
+ self.addLink( s5, host3 )
+ self.addLink( s5, host4 )
+ self.addLink( s5, host5 )
+ self.addLink( s5, host6 )
+ self.addLink( s5, host7 )
+ self.addLink( s5, host8 )
- self.addLink(s6,host9)
- self.addLink(s6,host10)
- self.addLink(s6,host11)
- self.addLink(s6,host12)
- self.addLink(s6,host13)
- self.addLink(s6,host14)
- self.addLink(s6,host15)
- self.addLink(s6,host16)
+ self.addLink( s6, host9 )
+ self.addLink( s6, host10 )
+ self.addLink( s6, host11 )
+ self.addLink( s6, host12 )
+ self.addLink( s6, host13 )
+ self.addLink( s6, host14 )
+ self.addLink( s6, host15 )
+ self.addLink( s6, host16 )
- self.addLink(s7,host17)
- self.addLink(s7,host18)
- self.addLink(s7,host19)
- self.addLink(s7,host20)
- self.addLink(s7,host21)
- self.addLink(s7,host22)
- self.addLink(s7,host23)
- self.addLink(s7,host24)
+ self.addLink( s7, host17 )
+ self.addLink( s7, host18 )
+ self.addLink( s7, host19 )
+ self.addLink( s7, host20 )
+ self.addLink( s7, host21 )
+ self.addLink( s7, host22 )
+ self.addLink( s7, host23 )
+ self.addLink( s7, host24 )
- self.addLink(s1,s2)
- self.addLink(s1,s3)
- self.addLink(s1,s4)
- self.addLink(s1,s5)
- self.addLink(s2,s3)
- self.addLink(s2,s5)
- self.addLink(s2,s6)
- self.addLink(s3,s4)
- self.addLink(s3,s6)
- self.addLink(s4,s7)
+ self.addLink( s1, s2 )
+ self.addLink( s1, s3 )
+ self.addLink( s1, s4 )
+ self.addLink( s1, s5 )
+ self.addLink( s2, s3 )
+ self.addLink( s2, s5 )
+ self.addLink( s2, s6 )
+ self.addLink( s3, s4 )
+ self.addLink( s3, s6 )
+ self.addLink( s4, s7 )
topos = { 'mytopo': ( lambda: MyTopo() ) }
# HERE THE CODE DEFINITION OF THE TOPOLOGY ENDS
+
def setupNetwork():
"Create network"
topo = MyTopo()
- network = Mininet(topo=topo, autoSetMacs=True, controller=None)
+ network = Mininet( topo=topo, autoSetMacs=True, controller=None )
network.start()
CLI( network )
network.stop()
if __name__ == '__main__':
- setLogLevel('info')
- #setLogLevel('debug')
+ setLogLevel( 'info' )
+ # setLogLevel( 'debug' )
setupNetwork()
diff --git a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/scaleTopoFunction.py b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/scaleTopoFunction.py
index ae30723..7620354 100644
--- a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/scaleTopoFunction.py
+++ b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/scaleTopoFunction.py
@@ -1,5 +1,5 @@
"""
-Copyright 2015 Open Networking Foundation (ONF)
+Copyright 2015 Open Networking Foundation ( ONF )
Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -8,7 +8,7 @@
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,6 @@
You should have received a copy of the GNU General Public License
along with TestON. If not, see <http://www.gnu.org/licenses/>.
"""
-
"""
Wrapper function for FuncTopo
Includes onosclidriver and mininetclidriver functions
@@ -27,13 +26,15 @@
import json
import re
+
def __init__( self ):
self.default = ''
+
def getTimestampFromString( main, targetString ):
- #Get time string from the target string
+ # Get time string from the target string
try:
- assert type( targetString ) is str
+ assert isinstance( targetString, str )
timeString = targetString.split( ' | ' )
timeString = timeString[ 0 ]
from datetime import datetime
@@ -53,10 +54,11 @@
main.log.error( "Got wrong string from log" )
return -1
+
def getRoleRequestTimeFromTshark( main ):
try:
main.log.info( "Get role request time" )
- with open(main.tsharkResultPath, "r" ) as resultFile:
+ with open( main.tsharkResultPath, "r" ) as resultFile:
resultText = resultFile.readlines()
# select the last role request string
roleRequestString = resultText[ len( resultText ) - 1 ]
@@ -64,18 +66,19 @@
# get timestamp from role request string
roleRequestTime = roleRequestString.split( " " )
resultFile.close()
- return float(roleRequestTime[1])
+ return float( roleRequestTime[ 1 ] )
except IndexError:
- main.log.error("Got wrong role request string from Tshark file")
+ main.log.error( "Got wrong role request string from Tshark file" )
return -1
-def compareTimeDiffWithRoleRequest(main, term, Mode, index=0 ):
- '''
+
+def compareTimeDiffWithRoleRequest( main, term, Mode, index=0 ):
+ """
Description:
Compare the time difference between the time of target term and the time of role request
Inclides onosclidriver functions
- '''
+ """
try:
termInfo = main.Cluster.active( index ).CLI.logSearch( mode=Mode, searchTerm=term )
termTime = getTimestampFromString( main, termInfo[ 0 ] )
@@ -91,37 +94,38 @@
main.writeData = -1
return -1
+
def getInfoFromLog( main, term1, mode1, term2, mode2, index=0, funcMode='TD' ):
- '''
+ """
Description:
Get needed informations of the search term from karaf.log
Includes onosclidriver functions
Function mode:
- TD (time difference):
+ TD ( time difference ):
Get time difference between start and end
Term1: startTerm
Term2: endTerm
- DR (disconnect rate):
+ DR ( disconnect rate ):
Get switch disconnect rate
Term1: disconnectTerm
Term2: connectTerm
- '''
+ """
try:
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] )
+ startTime = getTimestampFromString( main, termInfo1[ 0 ] )
+ endTime = getTimestampFromString( main, termInfo2[ 0 ] )
if startTime == -1 or endTime == -1:
main.log.error( "Wrong Time!" )
main.writeData = -1
return -1
return endTime - startTime
if funcMode == 'DR':
- #In this mode, termInfo1 means the total number of switch disconnection and
- #termInfo2 means the total number of new switch connection
- #termInfo2 - termInfo1 means the actual real number of switch connection.
+ # In this mode, termInfo1 means the total number of switch disconnection and
+ # termInfo2 means the total number of new switch connection
+ # termInfo2 - termInfo1 means the actual real number of switch connection.
disconnection = int( termInfo1 ) * 1.0
expectConnection = int( main.currScale ) ** 2
realConnection = int( termInfo2 ) - int( termInfo1 )
@@ -136,6 +140,7 @@
main.writeData = -1
return -1
+
def testTopology( main, topoFile='', args='', mnCmd='', timeout=300, clean=True ):
"""
Description:
@@ -173,16 +178,16 @@
# Starts topology
startResult = startNewTopology( main, topoFile, args, mnCmd, timeout=timeout )
# onos needs time to see the links
- time.sleep(15)
+ time.sleep( 15 )
# Gets list of switches in mininet
- #assignSwitch( main )
+ # assignSwitch( main )
testTopoResult = startResult and topoObjectResult
-
return testTopoResult
+
def startNewTopology( main, topoFile='', args='', mnCmd='', timeout=900 ):
"""
Description:
@@ -215,14 +220,14 @@
main.log.info( main.topoName + ": Starting topology with '" +
mnCmd + "' Mininet command" )
-
result = main.Mininet1.startNet( topoFile=topoFile,
args=args,
mnCmd=mnCmd,
- timeout=timeout)
+ timeout=timeout )
return result
+
def stopMininet( main ):
"""
Stops current topology and execute mn -c basically triggers
@@ -235,9 +240,10 @@
stopResult = main.Mininet1.stopNet()
time.sleep( 30 )
if not stopResult:
- main.log.info( main.topoName + ": Did not stop Mininet topology" )
+ main.log.info( main.topoName + ": Did not stop Mininet topology" )
return stopResult
+
def compareTopo( main ):
"""
Compare topology( devices, links, ports, hosts ) between ONOS and
@@ -254,13 +260,14 @@
main.topoRelated = Topology()
return main.topoRelated.compareTopos( main.Mininet1 )
+
def assignSwitch( main ):
"""
Returns switch list using getSwitch in Mininet driver
"""
switchList = []
assignResult = main.TRUE
- switchList = main.Mininet1.getSwitch()
+ switchList = main.Mininet1.getSwitch()
assignResult = main.Mininet1.assignSwController( sw=switchList,
ip=main.Cluster.active( 0 ).ipAddress,
port=6633 )
@@ -274,6 +281,7 @@
return switchList
+
def connectivity( main, timeout=900, shortCircuit=True, acceptableFailed=20 ):
"""
Use fwd app and pingall to discover all the hosts
@@ -309,6 +317,7 @@
return pingResult
+
def getHostsData( main ):
"""
Use fwd app and pingall to discover all the hosts
@@ -369,6 +378,7 @@
return getDataResult
+
def reinstallOnos( main ):
"""
Description:
@@ -422,8 +432,4 @@
if cliResult != main.TRUE:
restartResult = main.FALSE
-
return restartResult
-
-
-
diff --git a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/spine.py b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/spine.py
index 973385a..32c8419 100644
--- a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/spine.py
+++ b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/spine.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
"""
-Copyright 2015 Open Networking Foundation (ONF)
+Copyright 2015 Open Networking Foundation ( ONF )
Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -10,7 +10,7 @@
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -20,7 +20,6 @@
You should have received a copy of the GNU General Public License
along with TestON. If not, see <http://www.gnu.org/licenses/>.
"""
-
"""
Custom topology for Mininet
Author: kelvin@onlab.us
@@ -45,7 +44,9 @@
totalSwitches = 0
totalEndSwitches = 0
totalHosts = 0
-endSwitchCount = 0 # total count of end switch in each row in gui
+endSwitchCount = 0 # total count of end switch in each row in gui
+
+
class spineTopo( Topo ):
def __init__( self, **opts ):
@@ -71,8 +72,8 @@
global endSwitchCount
endSwitchCount = e
- print "Creating topology with", s,"spine", l,"leaf", c,"core",\
- e,"end switches and",h,"host for each end switches"
+ print "Creating topology with", s, "spine", l, "leaf", c, "core",\
+ e, "end switches and", h, "host for each end switches"
self.addCore( c )
self.addSpine( s )
@@ -89,7 +90,6 @@
deviceData = self.createSwitchDict()
self.genCfgJson( deviceData )
-
def addCore( self, numSwitch ):
global totalSwitches
global coreSwitches
@@ -134,7 +134,6 @@
return host
-
def linkHosts( self, numHosts ):
global endSwitches
switches = sorted( endSwitches.values() )
@@ -143,7 +142,6 @@
for i in xrange( numHosts ):
self.addLink( sw, self.addEndHosts() )
-
def linkLayer( self, topLayer, botLayer ):
"""
Description:
@@ -156,7 +154,6 @@
layer below
botLater - Layer that is below the upper layer to be linked at
"""
-
topSwitches = sorted( topLayer.keys() )
botSwitches = sorted( botLayer.keys() )
@@ -164,7 +161,6 @@
for botSw in botSwitches:
self.addLink( topLayer.get( topSw ), botLayer.get( botSw ) )
-
def linkEndSwitch( self, numSwitch, leafLayer ):
global totalSwitches
global totalEndSwitches
@@ -182,7 +178,7 @@
self.addLink( leaf[ i ], endSw )
self.addLink( leaf[ i + 1 ], endSw )
break
- if i == ( len( leafSwitches ) - 1 ) and len( leafSwitches )%2:
+ if i == ( len( leafSwitches ) - 1 ) and len( leafSwitches ) % 2:
for j in xrange( numSwitch ):
self.addLink( leaf[ i ], self.addEnd() )
break
@@ -194,7 +190,7 @@
continue
if i == 1:
continue
- if i%2 == 0:
+ if i % 2 == 0:
for j in xrange( numSwitch ):
endSw = self.addEnd()
self.addLink( leaf[ i ], endSw )
@@ -206,11 +202,9 @@
configJson[ "devices" ] = deviceData
with open( 'spine.json', 'w+' ) as outfile:
json.dump( configJson, outfile )
- #cfgFile = open( "spine.json" , 'w+' )
- #cfgFile.write( configJson )
- #cfgFile.close()
-
-
+ # cfgFile = open( "spine.json" , 'w+' )
+ # cfgFile.write( configJson )
+ # cfgFile.close()
def createSwitchDict( self ):
global allSwitches
@@ -222,18 +216,18 @@
spineLong = -80
leafLong = -90
endLat = 30
- rowCount = 0 # count of end switches or rows
- colOffSet = 0 # off set for end switches; longitude
+ rowCount = 0 # count of end switches or rows
+ colOffSet = 0 # off set for end switches; longitude
- #for i in xrange( len( allSwitches ) ):
+ # for i in xrange( len( allSwitches ) ):
deviceList = []
deviceDict = {}
for sw in allSwitches:
tempSw = allSwitches.get( sw )
- uri = str( "{0:0>16}".format( str( hex( int( tempSw[ 1: ] ) )\
- ).split( "x" )[ 1 ] ) )
- mac = str( "{0:0>12}".format( str( hex( int( tempSw[ 1: ] ) )\
- ).split( "x" )[ 1 ] ) )
+ uri = str( "{0:0>16}".format( str( hex( int( tempSw[ 1: ] ) )
+ ).split( "x" )[ 1 ] ) )
+ mac = str( "{0:0>12}".format( str( hex( int( tempSw[ 1: ] ) )
+ ).split( "x" )[ 1 ] ) )
if "core" in sw:
latitude = 45
@@ -259,7 +253,7 @@
endLat -= 1
rowCount += 1
- tempItem = { "alias": allSwitches.get( sw ) ,
+ tempItem = { "alias": allSwitches.get( sw ),
"uri": "of:" + uri,
"mac": mac,
"annotations": { "name": sw,
@@ -269,21 +263,22 @@
deviceList.append( tempItem )
return deviceList
- #def createHostsJson( hostDict ):
+ # def createHostsJson( hostDict ):
topos = { 'spine': ( lambda s=2, l=3, c=1, e=5, h=1: spineTopo( s=s,
l=l,
c=c,
e=e,
- h=h) ) }
+ h=h ) ) }
# HERE THE CODE DEFINITION OF THE TOPOLOGY ENDS
+
def setupNetwork():
"Create network"
topo = spineTopo()
- #if controller_ip == '':
- #controller_ip = '10.0.2.2';
+ # if controller_ip == '':
+ # controller_ip = '10.0.2.2';
# controller_ip = '127.0.0.1';
network = Mininet( topo=topo,
autoSetMacs=True,
@@ -294,5 +289,5 @@
if __name__ == '__main__':
setLogLevel( 'info' )
- #setLogLevel('debug')
+ # setLogLevel( 'debug' )
setupNetwork()
diff --git a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/topo.py b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/topo.py
index c5c1f88..373ed2b 100644
--- a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/topo.py
+++ b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/topo.py
@@ -1,5 +1,5 @@
"""
-Copyright 2015 Open Networking Foundation (ONF)
+Copyright 2015 Open Networking Foundation ( ONF )
Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -8,7 +8,7 @@
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,15 +18,14 @@
You should have received a copy of the GNU General Public License
along with TestON. If not, see <http://www.gnu.org/licenses/>.
"""
-
"""
These functions can be used for topology comparisons
"""
-
import time
import os
import json
+
def sendArpPackage( main, hostList ):
import json
import time
@@ -35,10 +34,10 @@
return the total hosts number from Onos
"""
main.log.info( "Sending Arping package..." )
- if isinstance(hostList, list):
+ if isinstance( hostList, list ):
for h in hostList:
main.Mininet1.arping( srcHost=h, dstHost="10.0.0.1", output=main.FALSE, noResult=True )
- time.sleep(0.5)
+ time.sleep( 0.5 )
else:
main.Mininet1.arping( srcHost=hostList, dstHost="10.0.0.1", output=main.FALSE, noResult=True )
try:
@@ -46,8 +45,8 @@
summaryStr = json.loads( main.Cluster.active( 0 ).CLI.summary().encode() )
hostNum = summaryStr.get( 'hosts' )
- except (TypeError, ValueError):
- main.log.exception( " Object not as expected: {!r}".format( summaryStr) )
+ except ( TypeError, ValueError ):
+ main.log.exception( " Object not as expected: {!r}".format( summaryStr ) )
return -1
except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
diff --git a/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py b/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py
index 9ee512c..1633c44 100644
--- a/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py
+++ b/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py
@@ -1,5 +1,5 @@
"""
-Copyright 2016 Open Networking Foundation (ONF)
+Copyright 2016 Open Networking Foundation ( ONF )
Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -8,7 +8,7 @@
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,12 +18,11 @@
You should have received a copy of the GNU General Public License
along with TestON. If not, see <http://www.gnu.org/licenses/>.
"""
-
import sys
import json
import time
import os
-'''
+"""
SCPFscalingMaxIntents
Push test Intents to onos
CASE10: set up Null Provider
@@ -31,8 +30,9 @@
Check flows number, if flows number is not as except, finished this test iteration
Scale up when reach the Limited
Start from 1 nodes, 8 devices. Then Scale up to 3,5,7 nodes
-'''
+"""
class SCPFscalingMaxIntents:
+
def __init__( self ):
self.default = ''
@@ -63,7 +63,7 @@
main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
main.installSleep = int( main.params[ 'SLEEP' ][ 'install' ] )
main.verifySleep = int( main.params[ 'SLEEP' ][ 'verify' ] )
- main.rerouteSleep = int ( main.params[ 'SLEEP' ][ 'reroute' ] )
+ main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] )
main.intentConfigRegiCfg = main.params[ 'CFG' ][ 'intentConfigRegi' ]
main.nullProviderCfg = main.params[ 'CFG' ][ 'nullProvider' ]
main.linkCollectionIntentCfg = main.params[ 'CFG' ][ 'linkCollectionIntent' ]
@@ -97,6 +97,7 @@
main.testSetUp.envSetupException( e )
main.testSetUp.evnSetupConclusion( stepResult )
main.commit = main.commit.split( " " )[ 1 ]
+
def CASE1( self ):
copyResult = main.ONOSbench.copyMininetFile( main.topology,
main.dependencyPath,
@@ -133,25 +134,24 @@
# Setup the null-provider
main.step( "Configuring null-provider" )
cfgStatus = utilities.retry( main.ONOSbench.onosCfgSet,
- main.FALSE,
- [ main.Cluster.active( 0 ).ipAddress,
- main.nullProviderCfg, 'deviceCount 8' ],
- sleep=main.verifySleep,
- attempts = main.verifyAttempts )
+ main.FALSE,
+ [ main.Cluster.active( 0 ).ipAddress,
+ main.nullProviderCfg, 'deviceCount 8' ],
+ sleep=main.verifySleep,
+ attempts=main.verifyAttempts )
cfgStatus = cfgStatus and utilities.retry( main.ONOSbench.onosCfgSet,
main.FALSE,
[ main.Cluster.active( 0 ).ipAddress,
main.nullProviderCfg, 'topoShape reroute' ],
sleep=main.verifySleep,
- attempts = main.verifyAttempts )
+ attempts=main.verifyAttempts )
cfgStatus = cfgStatus and utilities.retry( main.ONOSbench.onosCfgSet,
main.FALSE,
[ main.Cluster.active( 0 ).ipAddress,
main.nullProviderCfg, 'enabled true' ],
sleep=main.verifySleep,
- attempts = main.verifyAttempts )
-
+ attempts=main.verifyAttempts )
utilities.assert_equals( expect=main.TRUE,
actual=cfgStatus,
@@ -197,9 +197,9 @@
main.setupSkipped = True
def CASE11( self, main ):
- '''
+ """
Setting up mininet
- '''
+ """
import json
import time
devices = []
@@ -210,10 +210,10 @@
time.sleep( main.startUpSleep )
if main.flowObj:
main.Cluster.active( 0 ).CLI.setCfg( main.intentConfigRegiCfg,
- "useFlowObjectives", value="true" )
+ "useFlowObjectives", value="true" )
main.Cluster.active( 0 ).CLI.setCfg( main.intentConfigRegiCfg,
- "defaultFlowObjectiveCompiler",
- value=main.linkCollectionIntentCfg )
+ "defaultFlowObjectiveCompiler",
+ value=main.linkCollectionIntentCfg )
main.step( 'Starting mininet topology' )
mnStatus = main.Mininet1.startNet( topoFile='~/mininet/custom/rerouteTopo.py' )
utilities.assert_equals( expect=main.TRUE,
@@ -277,8 +277,6 @@
if not caseResult:
main.setupSkipped = True
-
-
def CASE20( self, main ):
try:
from tests.dependencies.utils import Utils
@@ -330,9 +328,9 @@
# make sure the checkInterval divisible batchSize
main.checkInterval = int( int( main.checkInterval / main.batchSize ) * main.batchSize )
- flowTemp=0
+ flowTemp = 0
intentVerifyTemp = 0
- totalFlows=0
+ totalFlows = 0
for i in range( limit ):
# Threads pool
@@ -352,8 +350,8 @@
kwargs={ "offset": offtmp,
"options": "-i",
"timeout": main.timeout,
- "background":False,
- "noExit":True } )
+ "background": False,
+ "noExit": True } )
pool.append( t )
t.start()
main.threadID = main.threadID + 1
@@ -420,10 +418,10 @@
main.log.info( "Total Intents: {}".format( verifyTotalIntents ) )
break
- utilities.assert_equals( expect = main.TRUE,
- actual = intentsState,
- onpass = "Successfully pushed and verified intents",
- onfail = "Failed to push and verify intents" )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=intentsState,
+ onpass="Successfully pushed and verified intents",
+ onfail="Failed to push and verify intents" )
main.log.info( "Total Intents Installed before crash: {}".format( totalIntents ) )
main.log.info( "Total Flows ADDED before crash: {}".format( totalFlows ) )
diff --git a/TestON/tests/SCPF/SCPFscalingMaxIntents/dependencies/rerouteTopo.py b/TestON/tests/SCPF/SCPFscalingMaxIntents/dependencies/rerouteTopo.py
old mode 100755
new mode 100644
index dace730..a5336f0
--- a/TestON/tests/SCPF/SCPFscalingMaxIntents/dependencies/rerouteTopo.py
+++ b/TestON/tests/SCPF/SCPFscalingMaxIntents/dependencies/rerouteTopo.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
"""
-Copyright 2015 Open Networking Foundation (ONF)
+Copyright 2015 Open Networking Foundation ( ONF )
Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -10,7 +10,7 @@
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -20,7 +20,6 @@
You should have received a copy of the GNU General Public License
along with TestON. If not, see <http://www.gnu.org/licenses/>.
"""
-
"""
Custom topology for Mininet
"""
@@ -34,19 +33,20 @@
from mininet.util import dumpNodeConnections
from mininet.node import ( UserSwitch, OVSSwitch, IVSSwitch )
+
class MyTopo( Topo ):
def __init__( self ):
# Initialize topology
Topo.__init__( self )
- host1 = self.addHost('h1', ip='10.1.0.1/24')
- host2 = self.addHost('h2', ip='10.1.0.2/24')
- host3 = self.addHost('h3', ip='10.1.0.3/24')
- host4 = self.addHost('h4', ip='10.1.0.4/24')
- host5 = self.addHost('h5', ip='10.1.0.5/24')
- host6 = self.addHost('h6', ip='10.1.0.6/24')
- host7 = self.addHost('h7', ip='10.1.0.7/24')
+ host1 = self.addHost( 'h1', ip='10.1.0.1/24' )
+ host2 = self.addHost( 'h2', ip='10.1.0.2/24' )
+ host3 = self.addHost( 'h3', ip='10.1.0.3/24' )
+ host4 = self.addHost( 'h4', ip='10.1.0.4/24' )
+ host5 = self.addHost( 'h5', ip='10.1.0.5/24' )
+ host6 = self.addHost( 'h6', ip='10.1.0.6/24' )
+ host7 = self.addHost( 'h7', ip='10.1.0.7/24' )
s1 = self.addSwitch( 's1' )
s2 = self.addSwitch( 's2' )
@@ -57,39 +57,37 @@
s7 = self.addSwitch( 's7' )
s8 = self.addSwitch( 's8' )
+ self.addLink( s1, host1 )
+ self.addLink( s2, host2 )
+ self.addLink( s3, host3 )
+ self.addLink( s4, host4 )
+ self.addLink( s5, host5 )
+ self.addLink( s6, host6 )
+ self.addLink( s7, host7 )
- self.addLink(s1, host1)
- self.addLink(s2, host2)
- self.addLink(s3, host3)
- self.addLink(s4, host4)
- self.addLink(s5, host5)
- self.addLink(s6, host6)
- self.addLink(s7, host7)
-
-
-
- self.addLink(s1,s2)
- self.addLink(s2,s3)
- self.addLink(s3,s4)
- self.addLink(s4,s5)
- self.addLink(s5,s6)
- self.addLink(s6,s7)
- self.addLink(s4,s8)
- self.addLink(s8,s5)
+ self.addLink( s1, s2 )
+ self.addLink( s2, s3 )
+ self.addLink( s3, s4 )
+ self.addLink( s4, s5 )
+ self.addLink( s5, s6 )
+ self.addLink( s6, s7 )
+ self.addLink( s4, s8 )
+ self.addLink( s8, s5 )
topos = { 'mytopo': ( lambda: MyTopo() ) }
# HERE THE CODE DEFINITION OF THE TOPOLOGY ENDS
+
def setupNetwork():
"Create network"
topo = MyTopo()
- network = Mininet(topo=topo, autoSetMacs=True, controller=None)
+ network = Mininet( topo=topo, autoSetMacs=True, controller=None )
network.start()
CLI( network )
network.stop()
if __name__ == '__main__':
- setLogLevel('info')
- #setLogLevel('debug')
+ setLogLevel( 'info' )
+ # setLogLevel( 'debug' )
setupNetwork()
diff --git a/TestON/tests/SCPF/SCPFswitchLat/SCPFswitchLat.py b/TestON/tests/SCPF/SCPFswitchLat/SCPFswitchLat.py
index 66b3dc0..fa168f6 100644
--- a/TestON/tests/SCPF/SCPFswitchLat/SCPFswitchLat.py
+++ b/TestON/tests/SCPF/SCPFswitchLat/SCPFswitchLat.py
@@ -1,5 +1,5 @@
"""
-Copyright 2015 Open Networking Foundation (ONF)
+Copyright 2015 Open Networking Foundation ( ONF )
Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -8,7 +8,7 @@
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,8 +18,7 @@
You should have received a copy of the GNU General Public License
along with TestON. If not, see <http://www.gnu.org/licenses/>.
"""
-
-'''
+"""
SCPFswitchLat
Test Switch add/remove latency
calculate package latency between switch and ONOS
@@ -27,8 +26,7 @@
TCP -- Feature Reply -- Role Request -- Role Reply -- Device -- Graph
Siwtch Down:
Openflow FIN/ACK -- ACK -- Device -- Graph
-'''
-
+"""
class SCPFswitchLat:
def __init__( self ):
@@ -37,7 +35,7 @@
def CASE0( self, main ):
import os
import imp
- '''
+ """
- GIT
- BUILDING ONOS
Pull specific ONOS branch, then Build ONOS ono ONOS Bench.
@@ -45,7 +43,7 @@
test env. We want Jenkins jobs to pull&build for flexibility to handle
different versions of ONOS.
- Construct tests variables
- '''
+ """
try:
from tests.dependencies.ONOSSetup import ONOSSetup
main.testSetUp = ONOSSetup()
@@ -56,10 +54,10 @@
stepResult = main.FALSE
try:
# The dictionary to record different type of wrongs
- main.wrong = { 'totalWrong': 0, 'skipDown' : 0, 'TsharkValueIncorrect': 0,
- 'TypeError' : 0, 'decodeJasonError': 0,
- 'checkResultIncorrect': 0 }
- main.maxWrong = int( main.params[ 'TEST' ] [ 'MaxWrong' ] )
+ main.wrong = { 'totalWrong': 0, 'skipDown': 0, 'TsharkValueIncorrect': 0,
+ 'TypeError': 0, 'decodeJasonError': 0,
+ 'checkResultIncorrect': 0 }
+ main.maxWrong = int( main.params[ 'TEST' ][ 'MaxWrong' ] )
main.resultRange = main.params[ 'TEST' ][ 'ResultRange' ]
main.searchTerm = main.params[ 'TEST' ][ 'SearchTerm' ]
main.MN1Ip = main.params[ 'MN' ][ 'ip1' ]
@@ -72,7 +70,7 @@
main.scale = ( main.params[ 'SCALE' ] ).split( "," )
main.ofPackage = main.params[ 'TSHARK' ]
- main.defaultTopoCfg = main.params [ 'CFG' ][ 'defaultTopo' ]
+ main.defaultTopoCfg = main.params[ 'CFG' ][ 'defaultTopo' ]
main.tsharkResultPath = main.params[ 'TEST' ][ 'tsharkResultPath' ]
main.sampleSize = int( main.params[ 'TEST' ][ 'sampleSize' ] )
main.warmUp = int( main.params[ 'TEST' ][ 'warmUp' ] )
@@ -90,9 +88,9 @@
resultsDB.close()
main.switchFunc = imp.load_source( main.dependencyFunc,
- main.dependencyPath +
- main.dependencyFunc +
- ".py" )
+ main.dependencyPath +
+ main.dependencyFunc +
+ ".py" )
except Exception as e:
main.testSetUp.envSetupException( e )
main.testSetUp.evnSetupConclusion( stepResult )
@@ -144,26 +142,26 @@
import json
import numpy
- resultDict = { 'up' : {}, 'down' : {} }
+ resultDict = { 'up': {}, 'down': {} }
for i in range( 1, main.Cluster.numCtrls + 1 ):
resultDict[ 'up' ][ 'node' + str( i ) ] = {}
resultDict[ 'up' ][ 'node' + str( i ) ][ 'Ave' ] = {}
resultDict[ 'up' ][ 'node' + str( i ) ][ 'Std' ] = {}
- resultDict[ 'up' ][ 'node' + str( i ) ][ 'T_F' ] = []#TCP to Feature
- resultDict[ 'up' ][ 'node' + str( i ) ][ 'F_R' ] = []#Feature to Role
- resultDict[ 'up' ][ 'node' + str( i ) ][ 'RQ_RR' ] = []#role request to role reply
- resultDict[ 'up' ][ 'node' + str( i ) ][ 'RR_D' ] = []#role reply to Device
- resultDict[ 'up' ][ 'node' + str( i ) ][ 'D_G' ] = []#Device to Graph
- resultDict[ 'up' ][ 'node' + str( i ) ][ 'E_E' ] = []#TCP to Graph
+ resultDict[ 'up' ][ 'node' + str( i ) ][ 'T_F' ] = [] # TCP to Feature
+ resultDict[ 'up' ][ 'node' + str( i ) ][ 'F_R' ] = [] # Feature to Role
+ resultDict[ 'up' ][ 'node' + str( i ) ][ 'RQ_RR' ] = [] # role request to role reply
+ resultDict[ 'up' ][ 'node' + str( i ) ][ 'RR_D' ] = [] # role reply to Device
+ resultDict[ 'up' ][ 'node' + str( i ) ][ 'D_G' ] = [] # Device to Graph
+ resultDict[ 'up' ][ 'node' + str( i ) ][ 'E_E' ] = [] # TCP to Graph
for i in range( 1, main.Cluster.numCtrls + 1 ):
resultDict[ 'down' ][ 'node' + str( i ) ] = {}
resultDict[ 'down' ][ 'node' + str( i ) ][ 'Ave' ] = {}
resultDict[ 'down' ][ 'node' + str( i ) ][ 'Std' ] = {}
- resultDict[ 'down' ][ 'node' + str( i ) ][ 'FA_A' ] = []#Fin_ack to ACK
- resultDict[ 'down' ][ 'node' + str( i ) ][ 'A_D' ] = []#Ack to Device
- resultDict[ 'down' ][ 'node' + str( i ) ][ 'D_G' ] = []#Device to Graph
- resultDict[ 'down' ][ 'node' + str( i ) ][ 'E_E' ] = []#fin_ack to Graph
+ resultDict[ 'down' ][ 'node' + str( i ) ][ 'FA_A' ] = [] # Fin_ack to ACK
+ resultDict[ 'down' ][ 'node' + str( i ) ][ 'A_D' ] = [] # Ack to Device
+ resultDict[ 'down' ][ 'node' + str( i ) ][ 'D_G' ] = [] # Device to Graph
+ resultDict[ 'down' ][ 'node' + str( i ) ][ 'E_E' ] = [] # fin_ack to Graph
for i in range( 0, main.sampleSize + main.warmUp ):
main.log.info( "************************************************************" )
main.log.info( "************************ Iteration: {} **********************" .format( str( i + 1 ) ) )
@@ -176,12 +174,12 @@
else:
main.switchFunc.captureOfPack( main, main.device, main.ofPackage,
"up", resultDict, False )
- main.switchFunc.captureOfPack ( main, main.device, main.ofPackage,
- "down", resultDict, False )
+ main.switchFunc.captureOfPack( main, main.device, main.ofPackage,
+ "down", resultDict, False )
main.Cluster.active( 0 ).CLI.removeDevice( "of:0000000000000001" )
# Dictionary for result
- maxDict = {}
+ maxDict = {}
maxDict[ 'down' ] = {}
maxDict[ 'up' ] = {}
maxDict[ 'down' ][ 'max' ] = 0
diff --git a/TestON/tests/SCPF/SCPFswitchLat/dependencies/switchFunc.py b/TestON/tests/SCPF/SCPFswitchLat/dependencies/switchFunc.py
index cde275e..7a159ba 100644
--- a/TestON/tests/SCPF/SCPFswitchLat/dependencies/switchFunc.py
+++ b/TestON/tests/SCPF/SCPFswitchLat/dependencies/switchFunc.py
@@ -1,5 +1,5 @@
"""
-Copyright 2016 Open Networking Foundation (ONF)
+Copyright 2016 Open Networking Foundation ( ONF )
Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -8,7 +8,7 @@
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,29 +18,29 @@
You should have received a copy of the GNU General Public License
along with TestON. If not, see <http://www.gnu.org/licenses/>.
"""
-
-'''
+"""
Wrapper function for SCPFswitchLat test
Assign switch and capture openflow package
remove switch and caputer openflow package
calculate latency
-'''
+"""
import time
import json
+
def getTimestampFromLog( index, searchTerm ):
- '''
+ """
Get timestamp value of the search term from log.
Args:
index: the index of cli
searchTerm: the key term of timestamp
- '''
+ """
lines = main.Cluster.active( index ).CLI.logSearch( mode='last', searchTerm=searchTerm )
try:
- assert lines != None
- logString = lines[ len ( lines ) - 1 ]
- #get the target value
+ assert lines is not None
+ logString = lines[ len( lines ) - 1 ]
+ # get the target value
line = logString.split( "time = " )
key = line[ 1 ].split( " " )
return int( key[ 0 ] )
@@ -51,13 +51,14 @@
main.log.warn( "Search Term Not Found" )
return 0
+
def processPackage( package ):
- '''
+ """
split package information to dictionary
Args:
package: Package String
- '''
+ """
pacakge = package.split( " " )
dic = {}
for s in pacakge:
@@ -68,28 +69,30 @@
continue
return dic
+
def findSeqBySeqAck( seq, packageList ):
- '''
+ """
Find specific Seq of package in packageList
Args:
seq: seq from last TCP package
packageList: find package in packageList
- '''
+ """
for l in packageList:
temp = processPackage( l )
tA = temp[ 'Ack' ]
if int( seq ) + 1 == int( tA ):
return temp[ 'Seq' ]
+
def arrangeTsharkFile( switchStatus, keyTerm ):
- '''
+ """
Arrange different tshark messeage from overall file to different specific files
Args:
switchStatus: switch up or down
keyTerm: A dictionary that store the path name as value and the searchTerm as key
- '''
+ """
with open( main.tsharkResultPath[ switchStatus ][ 'ALL' ], 'r' ) as resultFile:
resultText = resultFile.readlines()
resultFile.close()
@@ -102,13 +105,14 @@
outputfile.write( line )
outputfile.close()
+
def checkResult( result1, result2, result3 ):
- '''
+ """
Check if the inputs meet the requirement
Returns:
1 means the results are right, 0 means the results are wrong
- '''
+ """
result = check( result1 ) + check( result2 ) + check( result3 )
if result < 3:
# if any result is wrong, increase the main wrong number
@@ -118,32 +122,34 @@
return 0
return 1
+
def check( result ):
- '''
+ """
Check the single input.
Returns:
1 means the input is good, 0 means the input is wrong
- '''
+ """
if result < int( main.resultRange[ 'Min' ] ) or result > int( main.resultRange[ 'Max' ] ):
main.log.debug( str( result ) + " is not meet the requirement" )
return 0
return 1
+
def checkTotalWrongNum():
- '''
+ """
Check if the total wrong number is bigger than the max wrong number. If it is, then exit the
test.
- '''
+ """
# if there are too many wrongs in this test, then exit
- if main.wrong['totalWrong'] > main.maxWrong:
+ if main.wrong[ 'totalWrong' ] > main.maxWrong:
main.log.error( "The total wrong number exceeds %d, test terminated" % main.maxWrong )
main.cleanAndExit()
-def captureOfPack( main, deviceName, ofPack, switchStatus, resultDict, warmup ):
- '''
+def captureOfPack( main, deviceName, ofPack, switchStatus, resultDict, warmup ):
+ """
Args:
main: TestON class
deviceName: device name
@@ -152,7 +158,7 @@
resultDict: dictionary to contain result
warmup: warm up boolean
- '''
+ """
main.log.debug( "TOTAL WRONG: " + str( main.wrong ) )
for d in ofPack[ switchStatus ]:
main.log.info( "Clean up Tshark" )
@@ -168,14 +174,14 @@
cleanTerm = ofPack[ switchStatus ][ d ].replace( '\\', '' )
keyTerm[ cleanTerm ] = d
# Delete the last '|'
- grepString = grepString[:-1]
+ grepString = grepString[ :-1 ]
# open tshark
main.log.info( "starting tshark capture" )
main.ONOSbench.tsharkGrep( grepString, main.tsharkResultPath[ switchStatus ][ 'ALL' ], grepOptions='-E' )
if switchStatus == 'up':
# if up, assign switch to controller
time.sleep( main.measurementSleep )
- main.log.info( 'Assigning {} to controller'.format( deviceName ))
+ main.log.info( 'Assigning {} to controller'.format( deviceName ) )
main.Mininet1.assignSwController( sw=deviceName, ip=main.Cluster.active( 0 ).ipAddress )
time.sleep( main.measurementSleep )
if switchStatus == 'down':
@@ -208,8 +214,8 @@
main.log.info( "Capture result:" + resultText )
resultText = resultText.strip()
resultText = resultText.split( " " )
- if len(resultText) > 1:
- tempResultDict[d]= int( ( float( resultText[ 1 ] ) * 1000 ) )
+ if len( resultText ) > 1:
+ tempResultDict[ d ] = int( ( float( resultText[ 1 ] ) * 1000 ) )
resultFile.close()
elif switchStatus == 'down':
# if state is down, we should capture Fin/Ack and ACK package
@@ -220,7 +226,7 @@
resultFile.close()
FinAckSeq = processPackage( FinAckText )[ 'Seq' ]
FinAckOFseq = findSeqBySeqAck( FinAckSeq, resultText )
- if FinAckOFseq == None:
+ if FinAckOFseq is None:
main.log.warn( "Tshark Result was incorrect!" )
main.log.warn( resultText )
main.wrong[ 'TsharkValueIncorrect' ] += 1
@@ -269,7 +275,7 @@
return
if not warmup:
resultDict[ switchStatus ][ d ][ 'T_F' ].append( T_Ftemp )
- resultDict[ switchStatus ][ d ][ 'F_R' ].append( F_Rtemp )
+ resultDict[ switchStatus ][ d ][ 'F_R' ].append( F_Rtemp )
resultDict[ switchStatus ][ d ][ 'RQ_RR' ].append( RQ_RRtemp )
main.log.info( "{} TCP to Feature: {}".format( d, str( T_Ftemp ) ) )
@@ -284,7 +290,7 @@
# get onos metrics timestamps
try:
response = json.loads( main.Cluster.active( i - 1 ).CLI.topologyEventsMetrics() )
- DeviceTime = getTimestampFromLog( i - 1, searchTerm=main.searchTerm[switchStatus] )
+ DeviceTime = getTimestampFromLog( i - 1, searchTerm=main.searchTerm[ switchStatus ] )
main.log.info( "ONOS{} device Event timestamp: {}".format( i, "%.2f" % DeviceTime ) )
GraphTime = int( response.get( "topologyGraphEventTimestamp" ).get( "value" ) )
main.log.info( "ONOS{} Graph Event timestamp: {}".format( i, GraphTime ) )
@@ -331,14 +337,14 @@
checkTotalWrongNum()
break
if not warmup and check == 1:
- resultDict[ switchStatus ][ 'node' + str( i )][ 'RR_D' ].append( RR_Dtemp )
- resultDict[ switchStatus ][ 'node' + str( i )][ 'D_G' ].append( D_Gtemp )
- resultDict[ switchStatus ][ 'node' + str( i )][ 'E_E' ].append( E_Etemp )
+ resultDict[ switchStatus ][ 'node' + str( i ) ][ 'RR_D' ].append( RR_Dtemp )
+ resultDict[ switchStatus ][ 'node' + str( i ) ][ 'D_G' ].append( D_Gtemp )
+ resultDict[ switchStatus ][ 'node' + str( i ) ][ 'E_E' ].append( E_Etemp )
else:
- main.wrong['checkResultIncorrect'] += 1
+ main.wrong[ 'checkResultIncorrect' ] += 1
main.wrong[ 'totalWrong' ] += 1
checkTotalWrongNum()
- main.log.debug("Skip this iteration due to the None Devicetime")
+ main.log.debug( "Skip this iteration due to the None Devicetime" )
if switchStatus == "down":
# down Latency
@@ -389,7 +395,7 @@
check = checkResult( A_Dtemp, D_Gtemp, E_Etemp )
if check == 1:
main.log.info( "ACK to device: {}".format( A_Dtemp ) )
- main.log.info( "Device to Graph: {}".format( D_Gtemp ) )
+ main.log.info( "Device to Graph: {}".format( D_Gtemp ) )
main.log.info( "End to End: {}".format( E_Etemp ) )
main.log.info( "================================================" )
except KeyError:
@@ -417,8 +423,7 @@
resultDict[ switchStatus ][ 'node' + str( i ) ][ 'E_E' ].append( E_Etemp )
else:
- main.wrong['checkResultIncorrect'] += 1
- main.wrong['totalWrong'] += 1
+ main.wrong[ 'checkResultIncorrect' ] += 1
+ main.wrong[ 'totalWrong' ] += 1
checkTotalWrongNum()
- main.log.debug("Skip this iteration due to the None Devicetime")
-
+ main.log.debug( "Skip this iteration due to the None Devicetime" )
diff --git a/TestON/tests/SCPF/SCPFswitchLat/dependencies/topo-perf-1sw.py b/TestON/tests/SCPF/SCPFswitchLat/dependencies/topo-perf-1sw.py
index 1793e2b..3652c82 100644
--- a/TestON/tests/SCPF/SCPFswitchLat/dependencies/topo-perf-1sw.py
+++ b/TestON/tests/SCPF/SCPFswitchLat/dependencies/topo-perf-1sw.py
@@ -1,5 +1,5 @@
"""
-Copyright 2015 Open Networking Foundation (ONF)
+Copyright 2015 Open Networking Foundation ( ONF )
Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -8,7 +8,7 @@
TestON is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ ( at your option ) any later version.
TestON is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,17 +18,17 @@
You should have received a copy of the GNU General Public License
along with TestON. If not, see <http://www.gnu.org/licenses/>.
"""
-
-'''
+"""
Simple 1 switch topology for topologoy performance test
-'''
-
+"""
from mininet.topo import Topo
-class MyTopo( Topo ):
- def __init__(self):
- Topo.__init__(self)
- s3 = self.addSwitch( "s3", dpid="0000000000000001")
+class MyTopo( Topo ):
+
+ def __init__( self ):
+ Topo.__init__( self )
+
+ s3 = self.addSwitch( "s3", dpid="0000000000000001" )
topos = { 'mytopo': ( lambda: MyTopo() ) }