Run codestyle script on HA test suite
Change-Id: Ib59ce54b5f5596a1d33845f05b86a117d42a4d32
diff --git a/TestON/tests/HA/HAclusterRestart/HAclusterRestart.py b/TestON/tests/HA/HAclusterRestart/HAclusterRestart.py
index 134ac76..a7ecb53 100644
--- a/TestON/tests/HA/HAclusterRestart/HAclusterRestart.py
+++ b/TestON/tests/HA/HAclusterRestart/HAclusterRestart.py
@@ -22,8 +22,6 @@
CASE16: Install Distributed Primitives app
CASE17: Check for basic functionality with distributed primitives
"""
-
-
class HAclusterRestart:
def __init__( self ):
@@ -147,7 +145,7 @@
filePath + topoName,
main.Mininet1.home,
direction="to" )
- mnResult = main.Mininet1.startNet( )
+ mnResult = main.Mininet1.startNet()
utilities.assert_equals( expect=main.TRUE, actual=mnResult,
onpass="Mininet Started",
onfail="Error starting Mininet" )
@@ -190,7 +188,7 @@
'seamless="seamless"></iframe>\n'
graphs += ']]></ac:plain-text-body>\n'
graphs += '</ac:structured-macro>\n'
- main.log.wiki(graphs)
+ main.log.wiki( graphs )
main.step( "Creating ONOS package" )
packageResult = main.ONOSbench.buckBuild()
@@ -234,9 +232,9 @@
cliResults = main.TRUE
threads = []
for i in range( main.numCtrls ):
- t = main.Thread( target=main.CLIs[i].startOnosCli,
+ t = main.Thread( target=main.CLIs[ i ].startOnosCli,
name="startOnosCli-" + str( i ),
- args=[main.nodes[i].ip_address] )
+ args=[ main.nodes[ i ].ip_address ] )
threads.append( t )
t.start()
@@ -261,7 +259,7 @@
main.step( "Checking ONOS nodes" )
nodeResults = utilities.retry( main.HA.nodesCheck,
False,
- args=[main.activeNodes],
+ args=[ main.activeNodes ],
attempts=5 )
utilities.assert_equals( expect=True, actual=nodeResults,
@@ -270,7 +268,7 @@
if not nodeResults:
for i in main.activeNodes:
- cli = main.CLIs[i]
+ cli = main.CLIs[ i ]
main.log.debug( "{} components not ACTIVE: \n{}".format(
cli.name,
cli.sendline( "scr:list | grep -v ACTIVE" ) ) )
@@ -282,7 +280,7 @@
# get data from the params
apps = main.params.get( 'apps' )
if apps:
- apps = apps.split(',')
+ apps = apps.split( ',' )
main.log.warn( apps )
activateResult = True
for app in apps:
@@ -309,8 +307,8 @@
main.log.debug( config )
checkResult = main.TRUE
for component in config:
- for setting in config[component]:
- value = config[component][setting]
+ for setting in config[ component ]:
+ value = config[ component ][ setting ]
check = main.CLIs[ 0 ].setCfg( component, setting, value )
main.log.info( "Value was changed? {}".format( main.TRUE == check ) )
checkResult = check and checkResult
@@ -325,7 +323,7 @@
appCheck = main.TRUE
threads = []
for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].appToIDCheck,
+ t = main.Thread( target=main.CLIs[ i ].appToIDCheck,
name="appToIDCheck-" + str( i ),
args=[] )
threads.append( t )
@@ -335,9 +333,9 @@
t.join()
appCheck = appCheck and t.result
if appCheck != main.TRUE:
- node = main.activeNodes[0]
- main.log.warn( main.CLIs[node].apps() )
- main.log.warn( main.CLIs[node].appIDs() )
+ node = main.activeNodes[ 0 ]
+ main.log.warn( main.CLIs[ node ].apps() )
+ main.log.warn( main.CLIs[ node ].appIDs() )
utilities.assert_equals( expect=main.TRUE, actual=appCheck,
onpass="App Ids seem to be correct",
onfail="Something is wrong with app Ids" )
@@ -422,9 +420,9 @@
# Manually assign mastership to the controller we want
roleCall = main.TRUE
- ipList = [ ]
+ ipList = []
deviceList = []
- onosCli = main.CLIs[ main.activeNodes[0] ]
+ onosCli = main.CLIs[ main.activeNodes[ 0 ] ]
try:
# Assign mastership to specific controllers. This assignment was
# determined for a 7 node cluser, but will work with any sized
@@ -498,8 +496,8 @@
# atomic and is actually a multi step process
time.sleep( 5 )
for i in range( len( ipList ) ):
- ip = ipList[i]
- deviceId = deviceList[i]
+ ip = ipList[ i ]
+ deviceId = deviceList[ i ]
# Check assignment
master = onosCli.getRole( deviceId ).get( 'master' )
if ip in master:
@@ -549,7 +547,7 @@
# install onos-app-fwd
main.step( "Install reactive forwarding app" )
- onosCli = main.CLIs[ main.activeNodes[0] ]
+ onosCli = main.CLIs[ main.activeNodes[ 0 ] ]
installResults = onosCli.activateApp( "org.onosproject.fwd" )
utilities.assert_equals( expect=main.TRUE, actual=installResults,
onpass="Install fwd successful",
@@ -559,7 +557,7 @@
appCheck = main.TRUE
threads = []
for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].appToIDCheck,
+ t = main.Thread( target=main.CLIs[ i ].appToIDCheck,
name="appToIDCheck-" + str( i ),
args=[] )
threads.append( t )
@@ -584,13 +582,13 @@
pingResult = main.Mininet1.pingall()
time2 = time.time()
if not pingResult:
- main.log.warn("First pingall failed. Trying again...")
+ main.log.warn( "First pingall failed. Trying again..." )
pingResult = main.Mininet1.pingall()
passMsg += " on the second try"
utilities.assert_equals(
expect=main.TRUE,
actual=pingResult,
- onpass= passMsg,
+ onpass=passMsg,
onfail="Reactive Pingall failed, " +
"one or more ping pairs failed" )
main.log.info( "Time for pingall: %2f seconds" %
@@ -599,8 +597,8 @@
time.sleep( 11 )
# uninstall onos-app-fwd
main.step( "Uninstall reactive forwarding app" )
- node = main.activeNodes[0]
- uninstallResult = main.CLIs[node].deactivateApp( "org.onosproject.fwd" )
+ node = main.activeNodes[ 0 ]
+ uninstallResult = main.CLIs[ node ].deactivateApp( "org.onosproject.fwd" )
utilities.assert_equals( expect=main.TRUE, actual=uninstallResult,
onpass="Uninstall fwd successful",
onfail="Uninstall fwd failed" )
@@ -609,7 +607,7 @@
threads = []
appCheck2 = main.TRUE
for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].appToIDCheck,
+ t = main.Thread( target=main.CLIs[ i ].appToIDCheck,
name="appToIDCheck-" + str( i ),
args=[] )
threads.append( t )
@@ -619,9 +617,9 @@
t.join()
appCheck2 = appCheck2 and t.result
if appCheck2 != main.TRUE:
- node = main.activeNodes[0]
- main.log.warn( main.CLIs[node].apps() )
- main.log.warn( main.CLIs[node].appIDs() )
+ node = main.activeNodes[ 0 ]
+ main.log.warn( main.CLIs[ node ].apps() )
+ main.log.warn( main.CLIs[ node ].appIDs() )
utilities.assert_equals( expect=main.TRUE, actual=appCheck2,
onpass="App Ids seem to be correct",
onfail="Something is wrong with app Ids" )
@@ -649,8 +647,8 @@
host2Id = host2Dict.get( 'id', None )
if host1Id and host2Id:
nodeNum = ( i % len( main.activeNodes ) )
- node = main.activeNodes[nodeNum]
- tmpId = main.CLIs[node].addHostIntent( host1Id, host2Id )
+ node = main.activeNodes[ nodeNum ]
+ tmpId = main.CLIs[ node ].addHostIntent( host1Id, host2Id )
if tmpId:
main.log.info( "Added intent with id: " + tmpId )
intentIds.append( tmpId )
@@ -660,8 +658,8 @@
else:
main.log.error( "Error, getHost() failed for h" + str( i ) +
" and/or h" + str( i + 10 ) )
- node = main.activeNodes[0]
- hosts = main.CLIs[node].hosts()
+ node = main.activeNodes[ 0 ]
+ hosts = main.CLIs[ node ].hosts()
main.log.warn( "Hosts output: " )
try:
main.log.warn( json.dumps( json.loads( hosts ),
@@ -729,7 +727,7 @@
for i in range( 14 ):
topics.append( "work-partition-" + str( i ) )
main.log.debug( topics )
- ONOStopics = [ j['topic'] for j in parsedLeaders ]
+ ONOStopics = [ j[ 'topic' ] for j in parsedLeaders ]
for topic in topics:
if topic not in ONOStopics:
main.log.error( "Error: " + topic +
@@ -743,13 +741,13 @@
# Check all nodes
if missing:
for i in main.activeNodes:
- response = main.CLIs[i].leaders( jsonFormat=False)
- main.log.warn( str( main.CLIs[i].name ) + " leaders output: \n" +
+ response = main.CLIs[ i ].leaders( jsonFormat=False )
+ main.log.warn( str( main.CLIs[ i ].name ) + " leaders output: \n" +
str( response ) )
partitions = onosCli.partitions()
try:
- if partitions :
+ if partitions:
parsedPartitions = json.loads( partitions )
main.log.warn( json.dumps( parsedPartitions,
sort_keys=True,
@@ -764,7 +762,7 @@
main.log.error( repr( partitions ) )
pendingMap = onosCli.pendingMap()
try:
- if pendingMap :
+ if pendingMap:
parsedPending = json.loads( pendingMap )
main.log.warn( json.dumps( parsedPending,
sort_keys=True,
@@ -783,21 +781,21 @@
main.log.error( "Error in pushing host intents to ONOS" )
main.step( "Intent Anti-Entropy dispersion" )
- for j in range(100):
+ for j in range( 100 ):
correct = True
main.log.info( "Submitted intents: " + str( sorted( intentIds ) ) )
for i in main.activeNodes:
onosIds = []
- ids = main.CLIs[i].getAllIntentsId()
+ ids = main.CLIs[ i ].getAllIntentsId()
onosIds.append( ids )
- main.log.debug( "Intents in " + main.CLIs[i].name + ": " +
+ main.log.debug( "Intents in " + main.CLIs[ i ].name + ": " +
str( sorted( onosIds ) ) )
if sorted( ids ) != sorted( intentIds ):
main.log.warn( "Set of intent IDs doesn't match" )
correct = False
break
else:
- intents = json.loads( main.CLIs[i].intents() )
+ intents = json.loads( main.CLIs[ i ].intents() )
for intent in intents:
if intent[ 'state' ] != "INSTALLED":
main.log.warn( "Intent " + intent[ 'id' ] +
@@ -807,7 +805,7 @@
if correct:
break
else:
- time.sleep(1)
+ time.sleep( 1 )
if not intentStop:
intentStop = time.time()
global gossipTime
@@ -825,7 +823,7 @@
append = True
else:
count += 1
- gossipPeriod = int( main.params['timers']['gossip'] )
+ gossipPeriod = int( main.params[ 'timers' ][ 'gossip' ] )
maxGossipTime = gossipPeriod * len( main.activeNodes )
utilities.assert_greater_equals(
expect=maxGossipTime, actual=gossipTime,
@@ -887,7 +885,7 @@
# FIXME: this should only be after we start the app
topics.append( "org.onosproject.election" )
main.log.debug( topics )
- ONOStopics = [ j['topic'] for j in parsedLeaders ]
+ ONOStopics = [ j[ 'topic' ] for j in parsedLeaders ]
for topic in topics:
if topic not in ONOStopics:
main.log.error( "Error: " + topic +
@@ -901,14 +899,14 @@
# Check all nodes
if missing:
for i in main.activeNodes:
- node = main.CLIs[i]
- response = node.leaders( jsonFormat=False)
+ node = main.CLIs[ i ]
+ response = node.leaders( jsonFormat=False )
main.log.warn( str( node.name ) + " leaders output: \n" +
str( response ) )
partitions = onosCli.partitions()
try:
- if partitions :
+ if partitions:
parsedPartitions = json.loads( partitions )
main.log.warn( json.dumps( parsedPartitions,
sort_keys=True,
@@ -923,7 +921,7 @@
main.log.error( repr( partitions ) )
pendingMap = onosCli.pendingMap()
try:
- if pendingMap :
+ if pendingMap:
parsedPending = json.loads( pendingMap )
main.log.warn( json.dumps( parsedPending,
sort_keys=True,
@@ -952,7 +950,7 @@
"functionality and check the state of " +\
"the intent"
- onosCli = main.CLIs[ main.activeNodes[0] ]
+ onosCli = main.CLIs[ main.activeNodes[ 0 ] ]
main.step( "Check Intent state" )
installedCheck = False
loopCount = 0
@@ -1038,7 +1036,7 @@
# FIXME: topics.append( "org.onosproject.election" )
# Print leaders output
main.log.debug( topics )
- ONOStopics = [ j['topic'] for j in parsedLeaders ]
+ ONOStopics = [ j[ 'topic' ] for j in parsedLeaders ]
for topic in topics:
if topic not in ONOStopics:
main.log.error( "Error: " + topic +
@@ -1055,8 +1053,8 @@
# Check all nodes
if topicCheck:
for i in main.activeNodes:
- node = main.CLIs[i]
- response = node.leaders( jsonFormat=False)
+ node = main.CLIs[ i ]
+ response = node.leaders( jsonFormat=False )
main.log.warn( str( node.name ) + " leaders output: \n" +
str( response ) )
@@ -1066,7 +1064,7 @@
# Print partitions
partitions = onosCli.partitions()
try:
- if partitions :
+ if partitions:
parsedPartitions = json.loads( partitions )
main.log.warn( json.dumps( parsedPartitions,
sort_keys=True,
@@ -1082,7 +1080,7 @@
# Print Pending Map
pendingMap = onosCli.pendingMap()
try:
- if pendingMap :
+ if pendingMap:
parsedPending = json.loads( pendingMap )
main.log.warn( json.dumps( parsedPending,
sort_keys=True,
@@ -1136,7 +1134,7 @@
# FIXME: this should only be after we start the app
topics.append( "org.onosproject.election" )
main.log.debug( topics )
- ONOStopics = [ j['topic'] for j in parsedLeaders ]
+ ONOStopics = [ j[ 'topic' ] for j in parsedLeaders ]
for topic in topics:
if topic not in ONOStopics:
main.log.error( "Error: " + topic +
@@ -1149,14 +1147,14 @@
main.log.error( repr( leaders ) )
if missing:
for i in main.activeNodes:
- node = main.CLIs[i]
- response = node.leaders( jsonFormat=False)
+ node = main.CLIs[ i ]
+ response = node.leaders( jsonFormat=False )
main.log.warn( str( node.name ) + " leaders output: \n" +
str( response ) )
partitions = onosCli.partitions()
try:
- if partitions :
+ if partitions:
parsedPartitions = json.loads( partitions )
main.log.warn( json.dumps( parsedPartitions,
sort_keys=True,
@@ -1171,7 +1169,7 @@
main.log.error( repr( partitions ) )
pendingMap = onosCli.pendingMap()
try:
- if pendingMap :
+ if pendingMap:
parsedPending = json.loads( pendingMap )
main.log.warn( json.dumps( parsedPending,
sort_keys=True,
@@ -1184,8 +1182,8 @@
main.log.exception( "Error parsing pending map" )
main.log.error( repr( pendingMap ) )
# Print flowrules
- node = main.activeNodes[0]
- main.log.debug( main.CLIs[node].flows( jsonFormat=False ) )
+ node = main.activeNodes[ 0 ]
+ main.log.debug( main.CLIs[ node ].flows( jsonFormat=False ) )
main.step( "Wait a minute then ping again" )
# the wait is above
PingResult = main.TRUE
@@ -1243,7 +1241,7 @@
rolesNotNull = main.TRUE
threads = []
for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].rolesNotNull,
+ t = main.Thread( target=main.CLIs[ i ].rolesNotNull,
name="rolesNotNull-" + str( i ),
args=[] )
threads.append( t )
@@ -1265,7 +1263,7 @@
rolesResults = True
threads = []
for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].roles,
+ t = main.Thread( target=main.CLIs[ i ].roles,
name="roles-" + str( i ),
args=[] )
threads.append( t )
@@ -1276,11 +1274,11 @@
ONOSMastership.append( t.result )
for i in range( len( ONOSMastership ) ):
- node = str( main.activeNodes[i] + 1 )
- if not ONOSMastership[i] or "Error" in ONOSMastership[i]:
+ node = str( main.activeNodes[ i ] + 1 )
+ if not ONOSMastership[ i ] or "Error" in ONOSMastership[ i ]:
main.log.error( "Error in getting ONOS" + node + " roles" )
main.log.warn( "ONOS" + node + " mastership response: " +
- repr( ONOSMastership[i] ) )
+ repr( ONOSMastership[ i ] ) )
rolesResults = False
utilities.assert_equals(
expect=True,
@@ -1289,7 +1287,7 @@
onfail="Error in reading roles from ONOS" )
main.step( "Check for consistency in roles from each controller" )
- if all([ i == ONOSMastership[ 0 ] for i in ONOSMastership ] ):
+ if all( [ i == ONOSMastership[ 0 ] for i in ONOSMastership ] ):
main.log.info(
"Switch roles are consistent across all ONOS nodes" )
else:
@@ -1302,7 +1300,7 @@
if rolesResults and not consistentMastership:
for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
+ node = str( main.activeNodes[ i ] + 1 )
try:
main.log.warn(
"ONOS" + node + " roles: ",
@@ -1326,7 +1324,7 @@
intentsResults = True
threads = []
for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].intents,
+ t = main.Thread( target=main.CLIs[ i ].intents,
name="intents-" + str( i ),
args=[],
kwargs={ 'jsonFormat': True } )
@@ -1338,7 +1336,7 @@
ONOSIntents.append( t.result )
for i in range( len( ONOSIntents ) ):
- node = str( main.activeNodes[i] + 1 )
+ node = str( main.activeNodes[ i ] + 1 )
if not ONOSIntents[ i ] or "Error" in ONOSIntents[ i ]:
main.log.error( "Error in getting ONOS" + node + " intents" )
main.log.warn( "ONOS" + node + " intents response: " +
@@ -1351,7 +1349,7 @@
onfail="Error in reading intents from ONOS" )
main.step( "Check for consistency in Intents from each controller" )
- if all([ sorted( i ) == sorted( ONOSIntents[ 0 ] ) for i in ONOSIntents ] ):
+ if all( [ sorted( i ) == sorted( ONOSIntents[ 0 ] ) for i in ONOSIntents ] ):
main.log.info( "Intents are consistent across all ONOS " +
"nodes" )
else:
@@ -1399,17 +1397,17 @@
if intentsResults and not consistentIntents:
# print the json objects
- n = str( main.activeNodes[-1] + 1 )
+ n = str( main.activeNodes[ -1 ] + 1 )
main.log.debug( "ONOS" + n + " intents: " )
main.log.debug( json.dumps( json.loads( ONOSIntents[ -1 ] ),
sort_keys=True,
indent=4,
separators=( ',', ': ' ) ) )
for i in range( len( ONOSIntents ) ):
- node = str( main.activeNodes[i] + 1 )
+ node = str( main.activeNodes[ i ] + 1 )
if ONOSIntents[ i ] != ONOSIntents[ -1 ]:
main.log.debug( "ONOS" + node + " intents: " )
- main.log.debug( json.dumps( json.loads( ONOSIntents[i] ),
+ main.log.debug( json.dumps( json.loads( ONOSIntents[ i ] ),
sort_keys=True,
indent=4,
separators=( ',', ': ' ) ) )
@@ -1430,7 +1428,7 @@
flowsResults = True
threads = []
for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].flows,
+ t = main.Thread( target=main.CLIs[ i ].flows,
name="flows-" + str( i ),
args=[],
kwargs={ 'jsonFormat': True } )
@@ -1438,14 +1436,14 @@
t.start()
# NOTE: Flows command can take some time to run
- time.sleep(30)
+ time.sleep( 30 )
for t in threads:
t.join()
result = t.result
ONOSFlows.append( result )
for i in range( len( ONOSFlows ) ):
- num = str( main.activeNodes[i] + 1 )
+ num = str( main.activeNodes[ i ] + 1 )
if not ONOSFlows[ i ] or "Error" in ONOSFlows[ i ]:
main.log.error( "Error in getting ONOS" + num + " flows" )
main.log.warn( "ONOS" + num + " flows response: " +
@@ -1482,11 +1480,11 @@
if flowsResults and not consistentFlows:
for i in range( len( ONOSFlows ) ):
- node = str( main.activeNodes[i] + 1 )
+ node = str( main.activeNodes[ i ] + 1 )
try:
main.log.warn(
"ONOS" + node + " flows: " +
- json.dumps( json.loads( ONOSFlows[i] ), sort_keys=True,
+ json.dumps( json.loads( ONOSFlows[ i ] ), sort_keys=True,
indent=4, separators=( ',', ': ' ) ) )
except ( ValueError, TypeError ):
main.log.warn( "ONOS" + node + " flows: " +
@@ -1551,9 +1549,9 @@
devices = []
threads = []
for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].devices,
+ t = main.Thread( target=main.CLIs[ i ].devices,
name="devices-" + str( i ),
- args=[ ] )
+ args=[] )
threads.append( t )
t.start()
@@ -1563,9 +1561,9 @@
hosts = []
threads = []
for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].hosts,
+ t = main.Thread( target=main.CLIs[ i ].hosts,
name="hosts-" + str( i ),
- args=[ ] )
+ args=[] )
threads.append( t )
t.start()
@@ -1583,9 +1581,9 @@
ports = []
threads = []
for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].ports,
+ t = main.Thread( target=main.CLIs[ i ].ports,
name="ports-" + str( i ),
- args=[ ] )
+ args=[] )
threads.append( t )
t.start()
@@ -1595,9 +1593,9 @@
links = []
threads = []
for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].links,
+ t = main.Thread( target=main.CLIs[ i ].links,
name="links-" + str( i ),
- args=[ ] )
+ args=[] )
threads.append( t )
t.start()
@@ -1607,9 +1605,9 @@
clusters = []
threads = []
for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].clusters,
+ t = main.Thread( target=main.CLIs[ i ].clusters,
name="clusters-" + str( i ),
- args=[ ] )
+ args=[] )
threads.append( t )
t.start()
@@ -1622,7 +1620,7 @@
main.step( "Host view is consistent across ONOS nodes" )
consistentHostsResult = main.TRUE
for controller in range( len( hosts ) ):
- controllerStr = str( main.activeNodes[controller] + 1 )
+ controllerStr = str( main.activeNodes[ controller ] + 1 )
if hosts[ controller ] and "Error" not in hosts[ controller ]:
if hosts[ controller ] == hosts[ 0 ]:
continue
@@ -1649,10 +1647,10 @@
main.step( "Each host has an IP address" )
ipResult = main.TRUE
for controller in range( 0, len( hosts ) ):
- controllerStr = str( main.activeNodes[controller] + 1 )
+ controllerStr = str( main.activeNodes[ controller ] + 1 )
if hosts[ controller ]:
for host in hosts[ controller ]:
- if not host.get( 'ipAddresses', [ ] ):
+ if not host.get( 'ipAddresses', [] ):
main.log.error( "Error with host ips on controller" +
controllerStr + ": " + str( host ) )
ipResult = main.FALSE
@@ -1666,7 +1664,7 @@
main.step( "Cluster view is consistent across ONOS nodes" )
consistentClustersResult = main.TRUE
for controller in range( len( clusters ) ):
- controllerStr = str( main.activeNodes[controller] + 1 )
+ controllerStr = str( main.activeNodes[ controller ] + 1 )
if "Error" not in clusters[ controller ]:
if clusters[ controller ] == clusters[ 0 ]:
continue
@@ -1715,14 +1713,14 @@
mnLinks = main.Mininet1.getLinks()
mnHosts = main.Mininet1.getHosts()
for controller in main.activeNodes:
- controllerStr = str( main.activeNodes[controller] + 1 )
+ controllerStr = str( main.activeNodes[ controller ] + 1 )
if devices[ controller ] and ports[ controller ] and\
- "Error" not in devices[ controller ] and\
- "Error" not in ports[ controller ]:
- currentDevicesResult = main.Mininet1.compareSwitches(
- mnSwitches,
- json.loads( devices[ controller ] ),
- json.loads( ports[ controller ] ) )
+ "Error" not in devices[ controller ] and\
+ "Error" not in ports[ controller ]:
+ currentDevicesResult = main.Mininet1.compareSwitches(
+ mnSwitches,
+ json.loads( devices[ controller ] ),
+ json.loads( ports[ controller ] ) )
else:
currentDevicesResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
@@ -1846,9 +1844,9 @@
cliResults = main.TRUE
threads = []
for i in range( main.numCtrls ):
- t = main.Thread( target=main.CLIs[i].startOnosCli,
+ t = main.Thread( target=main.CLIs[ i ].startOnosCli,
name="startOnosCli-" + str( i ),
- args=[main.nodes[i].ip_address] )
+ args=[ main.nodes[ i ].ip_address ] )
threads.append( t )
t.start()
@@ -1862,7 +1860,7 @@
for i in range( 10 ):
ready = True
for i in main.activeNodes:
- cli = main.CLIs[i]
+ cli = main.CLIs[ i ]
output = cli.summary()
if not output:
ready = False
@@ -1886,7 +1884,7 @@
# Rerun for election on restarted nodes
runResults = main.TRUE
for i in main.activeNodes:
- cli = main.CLIs[i]
+ cli = main.CLIs[ i ]
run = cli.electionTestRun()
if run != main.TRUE:
main.log.error( "Error running for election on " + cli.name )
@@ -1897,10 +1895,10 @@
# TODO: Make this configurable
time.sleep( 60 )
- node = main.activeNodes[0]
- main.log.debug( main.CLIs[node].nodes( jsonFormat=False ) )
- main.log.debug( main.CLIs[node].leaders( jsonFormat=False ) )
- main.log.debug( main.CLIs[node].partitions( jsonFormat=False ) )
+ node = main.activeNodes[ 0 ]
+ main.log.debug( main.CLIs[ node ].nodes( jsonFormat=False ) )
+ main.log.debug( main.CLIs[ node ].leaders( jsonFormat=False ) )
+ main.log.debug( main.CLIs[ node ].partitions( jsonFormat=False ) )
def CASE7( self, main ):
"""
@@ -1919,9 +1917,9 @@
rolesNotNull = main.TRUE
threads = []
for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].rolesNotNull,
+ t = main.Thread( target=main.CLIs[ i ].rolesNotNull,
name="rolesNotNull-" + str( i ),
- args=[ ] )
+ args=[] )
threads.append( t )
t.start()
@@ -1941,7 +1939,7 @@
rolesResults = True
threads = []
for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].roles,
+ t = main.Thread( target=main.CLIs[ i ].roles,
name="roles-" + str( i ),
args=[] )
threads.append( t )
@@ -1952,11 +1950,11 @@
ONOSMastership.append( t.result )
for i in range( len( ONOSMastership ) ):
- node = str( main.activeNodes[i] + 1 )
- if not ONOSMastership[i] or "Error" in ONOSMastership[i]:
+ node = str( main.activeNodes[ i ] + 1 )
+ if not ONOSMastership[ i ] or "Error" in ONOSMastership[ i ]:
main.log.error( "Error in getting ONOS" + node + " roles" )
main.log.warn( "ONOS" + node + " mastership response: " +
- repr( ONOSMastership[i] ) )
+ repr( ONOSMastership[ i ] ) )
rolesResults = False
utilities.assert_equals(
expect=True,
@@ -1965,7 +1963,7 @@
onfail="Error in reading roles from ONOS" )
main.step( "Check for consistency in roles from each controller" )
- if all([ i == ONOSMastership[ 0 ] for i in ONOSMastership ] ):
+ if all( [ i == ONOSMastership[ 0 ] for i in ONOSMastership ] ):
main.log.info(
"Switch roles are consistent across all ONOS nodes" )
else:
@@ -1978,7 +1976,7 @@
if rolesResults and not consistentMastership:
for i in range( len( ONOSMastership ) ):
- node = str( main.activeNodes[i] + 1 )
+ node = str( main.activeNodes[ i ] + 1 )
main.log.warn( "ONOS" + node + " roles: ",
json.dumps( json.loads( ONOSMastership[ i ] ),
sort_keys=True,
@@ -1996,7 +1994,7 @@
intentsResults = True
threads = []
for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].intents,
+ t = main.Thread( target=main.CLIs[ i ].intents,
name="intents-" + str( i ),
args=[],
kwargs={ 'jsonFormat': True } )
@@ -2007,8 +2005,8 @@
t.join()
ONOSIntents.append( t.result )
- for i in range( len( ONOSIntents) ):
- node = str( main.activeNodes[i] + 1 )
+ for i in range( len( ONOSIntents ) ):
+ node = str( main.activeNodes[ i ] + 1 )
if not ONOSIntents[ i ] or "Error" in ONOSIntents[ i ]:
main.log.error( "Error in getting ONOS" + node + " intents" )
main.log.warn( "ONOS" + node + " intents response: " +
@@ -2021,7 +2019,7 @@
onfail="Error in reading intents from ONOS" )
main.step( "Check for consistency in Intents from each controller" )
- if all([ sorted( i ) == sorted( ONOSIntents[ 0 ] ) for i in ONOSIntents ] ):
+ if all( [ sorted( i ) == sorted( ONOSIntents[ 0 ] ) for i in ONOSIntents ] ):
main.log.info( "Intents are consistent across all ONOS " +
"nodes" )
else:
@@ -2070,12 +2068,12 @@
main.log.exception( "Error in parsing intents" )
main.log.error( repr( node ) )
intentStates.append( nodeStates )
- out = [ (i, nodeStates.count( i ) ) for i in set( nodeStates ) ]
+ out = [ ( i, nodeStates.count( i ) ) for i in set( nodeStates ) ]
main.log.info( dict( out ) )
if intentsResults and not consistentIntents:
for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
+ node = str( main.activeNodes[ i ] + 1 )
main.log.warn( "ONOS" + node + " intents: " )
main.log.warn( json.dumps(
json.loads( ONOSIntents[ i ] ),
@@ -2115,7 +2113,7 @@
main.log.debug( json.dumps( intent ) )
except ( ValueError, TypeError ):
main.log.exception( "Exception printing intents" )
- main.log.debug( repr( ONOSIntents[0] ) )
+ main.log.debug( repr( ONOSIntents[ 0 ] ) )
main.log.debug( repr( intentState ) )
if sameIntents == main.FALSE:
try:
@@ -2129,7 +2127,7 @@
separators=( ',', ': ' ) ) )
except ( ValueError, TypeError ):
main.log.exception( "Exception printing intents" )
- main.log.debug( repr( ONOSIntents[0] ) )
+ main.log.debug( repr( ONOSIntents[ 0 ] ) )
main.log.debug( repr( intentState ) )
utilities.assert_equals(
expect=main.TRUE,
@@ -2144,7 +2142,7 @@
for i in range( 28 ):
main.log.info( "Checking flow table on s" + str( i + 1 ) )
tmpFlows = main.Mininet1.getFlowTable( "s" + str( i + 1 ), version="1.3", debug=False )
- curSwitch = main.Mininet1.flowTableComp( flows[i], tmpFlows )
+ curSwitch = main.Mininet1.flowTableComp( flows[ i ], tmpFlows )
FlowTables = FlowTables and curSwitch
if curSwitch == main.FALSE:
main.log.warn( "Differences in flow table for switch: s{}".format( i + 1 ) )
@@ -2155,7 +2153,7 @@
onfail="Changes were found in the flow tables" )
main.Mininet2.pingLongKill()
- '''
+ """
# main.step( "Check the continuous pings to ensure that no packets " +
# "were dropped during component failure" )
main.Mininet2.pingKill( main.params[ 'TESTONUSER' ],
@@ -2185,15 +2183,14 @@
# NOTE: Since intents are not persisted with IntnentStore,
# we expect loss in dataplane connectivity
LossInPings = main.FALSE
- '''
-
+ """
main.step( "Leadership Election is still functional" )
# Test of LeadershipElection
leaderList = []
leaderResult = main.TRUE
for i in main.activeNodes:
- cli = main.CLIs[i]
+ cli = main.CLIs[ i ]
leaderN = cli.electionTestLeader()
leaderList.append( leaderN )
if leaderN == main.FALSE:
@@ -2251,8 +2248,8 @@
for i in main.activeNodes:
t = main.Thread( target=utilities.retry,
name="devices-" + str( i ),
- args=[ main.CLIs[i].devices, [ None ] ],
- kwargs= { 'sleep': 5, 'attempts': 5,
+ args=[ main.CLIs[ i ].devices, [ None ] ],
+ kwargs={ 'sleep': 5, 'attempts': 5,
'randomTime': True } )
threads.append( t )
t.start()
@@ -2266,8 +2263,8 @@
for i in main.activeNodes:
t = main.Thread( target=utilities.retry,
name="hosts-" + str( i ),
- args=[ main.CLIs[i].hosts, [ None ] ],
- kwargs= { 'sleep': 5, 'attempts': 5,
+ args=[ main.CLIs[ i ].hosts, [ None ] ],
+ kwargs={ 'sleep': 5, 'attempts': 5,
'randomTime': True } )
threads.append( t )
t.start()
@@ -2281,7 +2278,7 @@
main.log.error( repr( t.result ) )
hosts.append( None )
for controller in range( 0, len( hosts ) ):
- controllerStr = str( main.activeNodes[controller] + 1 )
+ controllerStr = str( main.activeNodes[ controller ] + 1 )
if hosts[ controller ]:
for host in hosts[ controller ]:
if host is None or host.get( 'ipAddresses', [] ) == []:
@@ -2294,8 +2291,8 @@
for i in main.activeNodes:
t = main.Thread( target=utilities.retry,
name="ports-" + str( i ),
- args=[ main.CLIs[i].ports, [ None ] ],
- kwargs= { 'sleep': 5, 'attempts': 5,
+ args=[ main.CLIs[ i ].ports, [ None ] ],
+ kwargs={ 'sleep': 5, 'attempts': 5,
'randomTime': True } )
threads.append( t )
t.start()
@@ -2308,8 +2305,8 @@
for i in main.activeNodes:
t = main.Thread( target=utilities.retry,
name="links-" + str( i ),
- args=[ main.CLIs[i].links, [ None ] ],
- kwargs= { 'sleep': 5, 'attempts': 5,
+ args=[ main.CLIs[ i ].links, [ None ] ],
+ kwargs={ 'sleep': 5, 'attempts': 5,
'randomTime': True } )
threads.append( t )
t.start()
@@ -2322,8 +2319,8 @@
for i in main.activeNodes:
t = main.Thread( target=utilities.retry,
name="clusters-" + str( i ),
- args=[ main.CLIs[i].clusters, [ None ] ],
- kwargs= { 'sleep': 5, 'attempts': 5,
+ args=[ main.CLIs[ i ].clusters, [ None ] ],
+ kwargs={ 'sleep': 5, 'attempts': 5,
'randomTime': True } )
threads.append( t )
t.start()
@@ -2342,18 +2339,18 @@
all( e is None for e in ports ) and\
all( e is None for e in links ) and\
all( e is None for e in clusters ):
- topoFailMsg = "Could not get topology from ONOS"
- main.log.error( topoFailMsg )
- continue # Try again, No use trying to compare
+ topoFailMsg = "Could not get topology from ONOS"
+ main.log.error( topoFailMsg )
+ continue # Try again, No use trying to compare
mnSwitches = main.Mininet1.getSwitches()
mnLinks = main.Mininet1.getLinks()
mnHosts = main.Mininet1.getHosts()
for controller in range( len( main.activeNodes ) ):
- controllerStr = str( main.activeNodes[controller] + 1 )
+ controllerStr = str( main.activeNodes[ controller ] + 1 )
if devices[ controller ] and ports[ controller ] and\
- "Error" not in devices[ controller ] and\
- "Error" not in ports[ controller ]:
+ "Error" not in devices[ controller ] and\
+ "Error" not in ports[ controller ]:
try:
currentDevicesResult = main.Mininet1.compareSwitches(
@@ -2406,29 +2403,29 @@
mappings = {}
for i in range( 1, 29 ): # hosts 1 through 28
# set up correct variables:
- macId = "00:" * 5 + hex( i ).split( "0x" )[1].upper().zfill(2)
+ macId = "00:" * 5 + hex( i ).split( "0x" )[ 1 ].upper().zfill( 2 )
if i == 1:
- deviceId = "1000".zfill(16)
+ deviceId = "1000".zfill( 16 )
elif i == 2:
- deviceId = "2000".zfill(16)
+ deviceId = "2000".zfill( 16 )
elif i == 3:
- deviceId = "3000".zfill(16)
+ deviceId = "3000".zfill( 16 )
elif i == 4:
- deviceId = "3004".zfill(16)
+ deviceId = "3004".zfill( 16 )
elif i == 5:
- deviceId = "5000".zfill(16)
+ deviceId = "5000".zfill( 16 )
elif i == 6:
- deviceId = "6000".zfill(16)
+ deviceId = "6000".zfill( 16 )
elif i == 7:
- deviceId = "6007".zfill(16)
+ deviceId = "6007".zfill( 16 )
elif i >= 8 and i <= 17:
dpid = '3' + str( i ).zfill( 3 )
- deviceId = dpid.zfill(16)
+ deviceId = dpid.zfill( 16 )
elif i >= 18 and i <= 27:
dpid = '6' + str( i ).zfill( 3 )
- deviceId = dpid.zfill(16)
+ deviceId = dpid.zfill( 16 )
elif i == 28:
- deviceId = "2800".zfill(16)
+ deviceId = "2800".zfill( 16 )
mappings[ macId ] = deviceId
if hosts[ controller ] is not None and "Error" not in hosts[ controller ]:
if hosts[ controller ] == []:
@@ -2448,7 +2445,7 @@
assert location, "location field could not be found for this host object"
# Trim the protocol identifier off deviceId
- device = str( location.get( 'elementId' ) ).split(':')[1]
+ device = str( location.get( 'elementId' ) ).split( ':' )[ 1 ]
assert device, "elementId field could not be found for this host location object"
port = location.get( 'port' )
@@ -2459,7 +2456,7 @@
if str( port ) != "1":
main.log.error( "The attachment port is incorrect for " +
"host " + str( mac ) +
- ". Expected: 1 Actual: " + str( port) )
+ ". Expected: 1 Actual: " + str( port ) )
hostAttachment = False
if device != mappings[ str( mac ) ]:
main.log.error( "The attachment device is incorrect for " +
@@ -2503,7 +2500,7 @@
main.step( "Hosts view is consistent across all ONOS nodes" )
consistentHostsResult = main.TRUE
for controller in range( len( hosts ) ):
- controllerStr = str( main.activeNodes[controller] + 1 )
+ controllerStr = str( main.activeNodes[ controller ] + 1 )
if hosts[ controller ] is not None and "Error" not in hosts[ controller ]:
if hosts[ controller ] == hosts[ 0 ]:
continue
@@ -2545,7 +2542,7 @@
main.step( "Clusters view is consistent across all ONOS nodes" )
consistentClustersResult = main.TRUE
for controller in range( len( clusters ) ):
- controllerStr = str( main.activeNodes[controller] + 1 )
+ controllerStr = str( main.activeNodes[ controller ] + 1 )
if "Error" not in clusters[ controller ]:
if clusters[ controller ] == clusters[ 0 ]:
continue
@@ -2575,7 +2572,7 @@
numClusters = len( json.loads( clusters[ 0 ] ) )
except ( ValueError, TypeError ):
main.log.exception( "Error parsing clusters[0]: " +
- repr( clusters[0] ) )
+ repr( clusters[ 0 ] ) )
numClusters = "ERROR"
clusterResults = main.FALSE
if numClusters == 1:
@@ -2625,7 +2622,7 @@
main.step( "Checking ONOS nodes" )
nodeResults = utilities.retry( main.HA.nodesCheck,
False,
- args=[main.activeNodes],
+ args=[ main.activeNodes ],
attempts=5 )
utilities.assert_equals( expect=True, actual=nodeResults,
@@ -2634,8 +2631,8 @@
if not nodeResults:
for i in main.activeNodes:
main.log.debug( "{} components not ACTIVE: \n{}".format(
- main.CLIs[i].name,
- main.CLIs[i].sendline( "scr:list | grep -v ACTIVE" ) ) )
+ main.CLIs[ i ].name,
+ main.CLIs[ i ].sendline( "scr:list | grep -v ACTIVE" ) ) )
if not topoResult:
main.cleanup()
@@ -2712,7 +2709,7 @@
switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
description = "Killing a switch to ensure it is discovered correctly"
- onosCli = main.CLIs[ main.activeNodes[0] ]
+ onosCli = main.CLIs[ main.activeNodes[ 0 ] ]
main.case( description )
switch = main.params[ 'kill' ][ 'switch' ]
switchDPID = main.params[ 'kill' ][ 'dpid' ]
@@ -2757,7 +2754,7 @@
switch = main.params[ 'kill' ][ 'switch' ]
switchDPID = main.params[ 'kill' ][ 'dpid' ]
links = main.params[ 'kill' ][ 'links' ].split()
- onosCli = main.CLIs[ main.activeNodes[0] ]
+ onosCli = main.CLIs[ main.activeNodes[ 0 ] ]
description = "Adding a switch to ensure it is discovered correctly"
main.case( description )
@@ -2844,12 +2841,12 @@
main.log.warn( main.ONOSbench.checkLogs( node.ip_address ) )
try:
- timerLog = open( main.logdir + "/Timers.csv", 'w')
+ timerLog = open( main.logdir + "/Timers.csv", 'w' )
main.log.error( ", ".join( labels ) + "\n" + ", ".join( data ) )
timerLog.write( ", ".join( labels ) + "\n" + ", ".join( data ) )
timerLog.close()
- except NameError, e:
- main.log.exception(e)
+ except NameError as e:
+ main.log.exception( e )
def CASE14( self, main ):
"""
@@ -2861,9 +2858,9 @@
assert main.CLIs, "main.CLIs not defined"
assert main.nodes, "main.nodes not defined"
- main.case("Start Leadership Election app")
+ main.case( "Start Leadership Election app" )
main.step( "Install leadership election app" )
- onosCli = main.CLIs[ main.activeNodes[0] ]
+ onosCli = main.CLIs[ main.activeNodes[ 0 ] ]
appResult = onosCli.activateApp( "org.onosproject.election" )
utilities.assert_equals(
expect=main.TRUE,
@@ -2873,9 +2870,9 @@
main.step( "Run for election on each node" )
for i in main.activeNodes:
- main.CLIs[i].electionTestRun()
- time.sleep(5)
- activeCLIs = [ main.CLIs[i] for i in main.activeNodes ]
+ main.CLIs[ i ].electionTestRun()
+ time.sleep( 5 )
+ activeCLIs = [ main.CLIs[ i ] for i in main.activeNodes ]
sameResult, leaders = main.HA.consistentLeaderboards( activeCLIs )
utilities.assert_equals(
expect=True,
@@ -2885,7 +2882,7 @@
if sameResult:
leader = leaders[ 0 ][ 0 ]
- if main.nodes[main.activeNodes[0]].ip_address in leader:
+ if main.nodes[ main.activeNodes[ 0 ] ].ip_address in leader:
correctLeader = True
else:
correctLeader = False
@@ -2935,7 +2932,7 @@
electionResult = main.TRUE
for i in main.activeNodes: # run test election on each node
- if main.CLIs[i].electionTestRun() == main.FALSE:
+ if main.CLIs[ i ].electionTestRun() == main.FALSE:
electionResult = main.FALSE
utilities.assert_equals(
expect=main.TRUE,
@@ -2950,7 +2947,7 @@
main.step( "Check that each node shows the same leader and candidates" )
failMessage = "Nodes have different leaderboards"
- activeCLIs = [ main.CLIs[i] for i in main.activeNodes ]
+ activeCLIs = [ main.CLIs[ i ] for i in main.activeNodes ]
sameResult, oldLeaders = main.HA.consistentLeaderboards( activeCLIs )
if sameResult:
oldLeader = oldLeaders[ 0 ][ 0 ]
@@ -3000,7 +2997,7 @@
if newLeader == oldLeader:
newLeaderResult = False
main.log.error( "All nodes still see old leader: " + str( oldLeader ) +
- " as the current leader" )
+ " as the current leader" )
utilities.assert_equals(
expect=True,
actual=newLeaderResult,
@@ -3017,7 +3014,7 @@
else:
main.log.info( "Expected no leader, got: " + str( newLeader ) )
correctCandidateResult = main.FALSE
- elif len( oldLeaders[0] ) >= 3:
+ elif len( oldLeaders[ 0 ] ) >= 3:
if newLeader == oldLeaders[ 0 ][ 2 ]:
# correct leader was elected
correctCandidateResult = main.TRUE
@@ -3057,10 +3054,10 @@
positionResult, reRunLeaders = main.HA.consistentLeaderboards( activeCLIs )
# Check that the re-elected node is last on the candidate List
- if not reRunLeaders[0]:
+ if not reRunLeaders[ 0 ]:
positionResult = main.FALSE
elif oldLeader != reRunLeaders[ 0 ][ -1 ]:
- main.log.error( "Old Leader ({}) not in the proper position: {} ".format( str( oldLeader),
+ main.log.error( "Old Leader ({}) not in the proper position: {} ".format( str( oldLeader ),
str( reRunLeaders[ 0 ] ) ) )
positionResult = main.FALSE
utilities.assert_equals(
@@ -3084,15 +3081,15 @@
# Variables for the distributed primitives tests
main.pCounterName = "TestON-Partitions"
main.pCounterValue = 0
- main.onosSet = set([])
+ main.onosSet = set( [] )
main.onosSetName = "TestON-set"
description = "Install Primitives app"
main.case( description )
main.step( "Install Primitives app" )
appName = "org.onosproject.distributedprimitives"
- node = main.activeNodes[0]
- appResults = main.CLIs[node].activateApp( appName )
+ node = main.activeNodes[ 0 ]
+ appResults = main.CLIs[ node ].activateApp( appName )
utilities.assert_equals( expect=main.TRUE,
actual=appResults,
onpass="Primitives app activated",