Run codestyle script on HA test suite
Change-Id: Ib59ce54b5f5596a1d33845f05b86a117d42a4d32
diff --git a/TestON/tests/HA/HAfullNetPartition/HAfullNetPartition.py b/TestON/tests/HA/HAfullNetPartition/HAfullNetPartition.py
index 742e340..14d73b9 100644
--- a/TestON/tests/HA/HAfullNetPartition/HAfullNetPartition.py
+++ b/TestON/tests/HA/HAfullNetPartition/HAfullNetPartition.py
@@ -23,8 +23,6 @@
CASE16: Install Distributed Primitives app
CASE17: Check for basic functionality with distributed primitives
"""
-
-
class HAfullNetPartition:
def __init__( self ):
@@ -149,7 +147,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" )
@@ -192,7 +190,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" )
# copy gen-partions file to ONOS
@@ -259,9 +257,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()
@@ -286,7 +284,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,
@@ -295,7 +293,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" ) ) )
@@ -307,7 +305,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:
@@ -334,8 +332,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
@@ -350,7 +348,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 )
@@ -360,9 +358,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" )
@@ -447,9 +445,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
@@ -523,8 +521,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:
@@ -562,7 +560,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",
@@ -572,7 +570,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 )
@@ -597,13 +595,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" %
@@ -612,8 +610,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" )
@@ -622,7 +620,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 )
@@ -632,9 +630,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" )
@@ -662,8 +660,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 )
@@ -673,8 +671,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 ),
@@ -742,7 +740,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 +
@@ -756,13 +754,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,
@@ -777,7 +775,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,
@@ -796,21 +794,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' ] +
@@ -820,14 +818,14 @@
if correct:
break
else:
- time.sleep(1)
+ time.sleep( 1 )
if not intentStop:
intentStop = time.time()
global gossipTime
gossipTime = intentStop - intentStart
main.log.info( "It took about " + str( gossipTime ) +
" seconds for all intents to appear in each node" )
- 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,
@@ -889,7 +887,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 +
@@ -903,14 +901,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,
@@ -925,7 +923,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,
@@ -954,7 +952,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
@@ -1040,7 +1038,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 +
@@ -1057,8 +1055,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 ) )
@@ -1068,7 +1066,7 @@
# Print partitions
partitions = onosCli.partitions()
try:
- if partitions :
+ if partitions:
parsedPartitions = json.loads( partitions )
main.log.warn( json.dumps( parsedPartitions,
sort_keys=True,
@@ -1084,7 +1082,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,
@@ -1138,7 +1136,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 +
@@ -1151,14 +1149,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,
@@ -1173,7 +1171,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,
@@ -1186,8 +1184,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
@@ -1245,7 +1243,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 )
@@ -1267,7 +1265,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 )
@@ -1278,11 +1276,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,
@@ -1291,7 +1289,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:
@@ -1304,7 +1302,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: ",
@@ -1328,7 +1326,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 } )
@@ -1340,7 +1338,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: " +
@@ -1353,7 +1351,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:
@@ -1401,17 +1399,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=( ',', ': ' ) ) )
@@ -1432,7 +1430,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 } )
@@ -1440,14 +1438,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: " +
@@ -1484,11 +1482,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: " +
@@ -1553,9 +1551,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()
@@ -1565,9 +1563,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()
@@ -1585,9 +1583,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()
@@ -1597,9 +1595,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()
@@ -1609,9 +1607,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()
@@ -1624,7 +1622,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
@@ -1651,10 +1649,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
@@ -1668,7 +1666,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
@@ -1717,14 +1715,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,
@@ -1801,7 +1799,7 @@
main.log.debug( "Checking logs for errors on " + node.name + ":" )
main.log.warn( main.ONOSbench.checkLogs( node.ip_address ) )
- main.log.debug( main.CLIs[0].roles( jsonFormat=False ) )
+ main.log.debug( main.CLIs[ 0 ].roles( jsonFormat=False ) )
n = len( main.nodes ) # Number of nodes
p = ( ( n + 1 ) / 2 ) + 1 # Number of partitions
@@ -1815,10 +1813,10 @@
main.log.info( "Nodes to be partitioned: " + str( nodeList ) )
partitionResults = main.TRUE
for i in range( 0, n ):
- this = main.nodes[i]
+ this = main.nodes[ i ]
if i not in main.partition:
for j in main.partition:
- foe = main.nodes[j]
+ foe = main.nodes[ j ]
main.log.warn( "Setting IP Tables rule from {} to {}. ".format( this.ip_address, foe.ip_address ) )
#CMD HERE
cmdStr = "sudo iptables -A {} -d {} -s {} -j DROP".format( "INPUT", this.ip_address, foe.ip_address )
@@ -1828,7 +1826,7 @@
else:
for j in range( 0, n ):
if j not in main.partition:
- foe = main.nodes[j]
+ foe = main.nodes[ j ]
main.log.warn( "Setting IP Tables rule from {} to {}. ".format( this.ip_address, foe.ip_address ) )
#CMD HERE
cmdStr = "sudo iptables -A {} -d {} -s {} -j DROP".format( "INPUT", this.ip_address, foe.ip_address )
@@ -1883,7 +1881,7 @@
main.step( "Checking ONOS nodes" )
nodeResults = utilities.retry( main.HA.nodesCheck,
False,
- args=[main.activeNodes],
+ args=[ main.activeNodes ],
sleep=15,
attempts=5 )
@@ -1893,7 +1891,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" ) ) )
@@ -1923,9 +1921,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()
@@ -1945,7 +1943,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 )
@@ -1956,11 +1954,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,
@@ -1969,7 +1967,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:
@@ -1982,7 +1980,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,
@@ -1998,7 +1996,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 } )
@@ -2009,8 +2007,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: " +
@@ -2023,7 +2021,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:
@@ -2072,12 +2070,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 ] ),
@@ -2116,7 +2114,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:
@@ -2130,7 +2128,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,
@@ -2145,7 +2143,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 ) )
@@ -2156,7 +2154,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' ],
@@ -2182,19 +2180,18 @@
actual=LossInPings,
onpass="No Loss of connectivity",
onfail="Loss of dataplane connectivity detected" )
- '''
-
+ """
main.step( "Leadership Election is still functional" )
# Test of LeadershipElection
leaderList = []
partitioned = []
for i in main.partition:
- partitioned.append( main.nodes[i].ip_address )
+ partitioned.append( main.nodes[ i ].ip_address )
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:
@@ -2258,8 +2255,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()
@@ -2273,8 +2270,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()
@@ -2288,7 +2285,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', [] ) == []:
@@ -2301,8 +2298,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()
@@ -2315,8 +2312,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()
@@ -2329,8 +2326,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()
@@ -2349,18 +2346,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(
@@ -2413,29 +2410,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 ] == []:
@@ -2455,7 +2452,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' )
@@ -2466,7 +2463,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 " +
@@ -2508,7 +2505,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
@@ -2550,7 +2547,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
@@ -2580,7 +2577,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:
@@ -2630,7 +2627,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,
@@ -2639,8 +2636,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()
@@ -2717,7 +2714,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' ]
@@ -2762,7 +2759,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 )
@@ -2849,14 +2846,14 @@
main.log.warn( main.ONOSbench.checkLogs( node.ip_address ) )
try:
- timerLog = open( main.logdir + "/Timers.csv", 'w')
+ timerLog = open( main.logdir + "/Timers.csv", 'w' )
# Overwrite with empty line and close
labels = "Gossip Intents"
data = str( gossipTime )
timerLog.write( labels + "\n" + data )
timerLog.close()
- except NameError, e:
- main.log.exception(e)
+ except NameError as e:
+ main.log.exception( e )
def CASE14( self, main ):
"""
@@ -2868,9 +2865,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,
@@ -2880,9 +2877,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,
@@ -2892,7 +2889,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
@@ -2942,7 +2939,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,
@@ -2957,7 +2954,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 ]
@@ -3007,7 +3004,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,
@@ -3024,7 +3021,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
@@ -3064,10 +3061,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(
@@ -3091,15 +3088,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",