[ONOS-7039] [ONOS-7044] Fix PEP8 Warnings in TestON
Change-Id: Ied79ff9caff5487a6df50466307f757468d7ca3a
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 = {}