Add HA testcases for new counter methods
Minor refactoring to allow a library file to be used
Change-Id: Ic634dfe26bf46d618dc703fa6fa8b5d234997dcf
diff --git a/TestON/tests/HAsanity/HAsanity.params b/TestON/tests/HAsanity/HAsanity.params
index 4ec3ad4..abc5385 100644
--- a/TestON/tests/HAsanity/HAsanity.params
+++ b/TestON/tests/HAsanity/HAsanity.params
@@ -17,8 +17,11 @@
#CASE15: Check that Leadership Election is still functional
#CASE16: Install Distributed Primitives app
#CASE17: Check for basic functionality with distributed primitives
- #1,2,8,3,4,5,14,16,17,[6],8,7,4,15,17,9,8,4,10,8,4,11,8,4,12,8,4,13
+ #1,2,8,21,8,3,4,5,14,16,17,[6],8,7,4,15,17,9,8,4,10,8,4,11,8,4,12,8,4,13
<testcases>1,2,8,21,8,3,4,5,14,16,17,[6],8,7,4,15,17,9,8,4,10,8,4,11,8,4,12,8,4,13</testcases>
+ <imports>
+ <path> /home/admin/OnosSystemTest/TestON/tests/HAsanity/dependencies/ </path>
+ </imports>
<ENV>
<cellName>HA</cellName>
<appString>drivers,openflow,proxyarp,mobility</appString>
diff --git a/TestON/tests/HAsanity/HAsanity.py b/TestON/tests/HAsanity/HAsanity.py
index a8a939c..b52943c 100644
--- a/TestON/tests/HAsanity/HAsanity.py
+++ b/TestON/tests/HAsanity/HAsanity.py
@@ -48,6 +48,7 @@
start cli sessions
start tcpdump
"""
+ import imp
main.log.info( "ONOS HA Sanity test - initialization" )
main.case( "Setting up test environment" )
main.caseExplanation = "Setup the test environment including " +\
@@ -62,13 +63,12 @@
gitBranch = main.params[ 'branch' ]
cellName = main.params[ 'ENV' ][ 'cellName' ]
- # set global variables
- global numControllers
- numControllers = int( main.params[ 'num_controllers' ] )
+ main.numCtrls = int( main.params[ 'num_controllers' ] )
if main.ONOSbench.maxNodes:
- if main.ONOSbench.maxNodes < numControllers:
- numControllers = int( main.ONOSbench.maxNodes )
+ if main.ONOSbench.maxNodes < main.numCtrls:
+ main.numCtrls = int( main.ONOSbench.maxNodes )
# TODO: refactor how to get onos port, maybe put into component tag?
+ # set global variables
global ONOS1Port
global ONOS2Port
global ONOS3Port
@@ -87,15 +87,26 @@
ONOS6Port = main.params[ 'CTRL' ][ 'port6' ]
ONOS7Port = main.params[ 'CTRL' ][ 'port7' ]
- global CLIs
- CLIs = []
- global nodes
- nodes = []
+ try:
+ fileName = "Counters"
+ path = main.params[ 'imports' ][ 'path' ]
+ main.Counters = imp.load_source( fileName,
+ path + fileName + ".py" )
+ except Exception as e:
+ main.log.exception( e )
+ main.cleanup()
+ main.exit()
+
+ main.CLIs = []
+ main.nodes = []
ipList = []
- for i in range( 1, numControllers + 1 ):
- CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
- nodes.append( getattr( main, 'ONOS' + str( i ) ) )
- ipList.append( nodes[ -1 ].ip_address )
+ for i in range( 1, main.numCtrls + 1 ):
+ try:
+ main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
+ main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
+ ipList.append( main.nodes[ -1 ].ip_address )
+ except AttributeError:
+ break
main.step( "Create cell file" )
cellAppString = main.params[ 'ENV' ][ 'appString' ]
@@ -111,13 +122,13 @@
main.ONOSbench.onosRemoveRaftLogs()
main.log.info( "Uninstalling ONOS" )
- for node in nodes:
+ for node in main.nodes:
main.ONOSbench.onosUninstall( node.ip_address )
# Make sure ONOS is DEAD
main.log.info( "Killing any ONOS processes" )
killResults = main.TRUE
- for node in nodes:
+ for node in main.nodes:
killed = main.ONOSbench.onosKill( node.ip_address )
killResults = killResults and killed
@@ -184,7 +195,7 @@
main.step( "Installing ONOS package" )
onosInstallResult = main.TRUE
- for node in nodes:
+ for node in main.nodes:
tmpResult = main.ONOSbench.onosInstall( options="-f",
node=node.ip_address )
onosInstallResult = onosInstallResult and tmpResult
@@ -195,7 +206,7 @@
main.step( "Checking if ONOS is up yet" )
for i in range( 2 ):
onosIsupResult = main.TRUE
- for node in nodes:
+ for node in main.nodes:
started = main.ONOSbench.isup( node.ip_address )
if not started:
main.log.error( node.name + " didn't start!" )
@@ -211,10 +222,10 @@
main.log.step( "Starting ONOS CLI sessions" )
cliResults = main.TRUE
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].startOnosCli,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].startOnosCli,
name="startOnosCli-" + str( i ),
- args=[nodes[i].ip_address] )
+ args=[main.nodes[i].ip_address] )
threads.append( t )
t.start()
@@ -236,8 +247,8 @@
main.step( "App Ids check" )
appCheck = main.TRUE
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].appToIDCheck,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].appToIDCheck,
name="appToIDCheck-" + str( i ),
args=[] )
threads.append( t )
@@ -247,8 +258,8 @@
t.join()
appCheck = appCheck and t.result
if appCheck != main.TRUE:
- main.log.warn( CLIs[0].apps() )
- main.log.warn( CLIs[0].appIDs() )
+ main.log.warn( main.CLIs[0].apps() )
+ main.log.warn( main.CLIs[0].appIDs() )
utilities.assert_equals( expect=main.TRUE, actual=appCheck,
onpass="App Ids seem to be correct",
onfail="Something is wrong with app Ids" )
@@ -263,12 +274,11 @@
Assign devices to controllers
"""
import re
- import time
- assert numControllers, "numControllers not defined"
+ assert main.numCtrls, "main.numCtrls not defined"
assert main, "main not defined"
assert utilities.assert_equals, "utilities.assert_equals not defined"
- assert CLIs, "CLIs not defined"
- assert nodes, "nodes not defined"
+ assert main.CLIs, "main.CLIs not defined"
+ assert main.nodes, "main.nodes not defined"
assert ONOS1Port, "ONOS1Port not defined"
assert ONOS2Port, "ONOS2Port not defined"
assert ONOS3Port, "ONOS3Port not defined"
@@ -284,8 +294,8 @@
main.step( "Assign switches to controllers" )
ipList = []
- for i in range( numControllers ):
- ipList.append( nodes[ i ].ip_address )
+ for i in range( main.numCtrls ):
+ ipList.append( main.nodes[ i ].ip_address )
swList = []
for i in range( 1, 29 ):
swList.append( "s" + str( i ) )
@@ -298,7 +308,7 @@
main.log.info( str( response ) )
except Exception:
main.log.info( repr( response ) )
- for node in nodes:
+ for node in main.nodes:
if re.search( "tcp:" + node.ip_address, response ):
mastershipCheck = mastershipCheck and main.TRUE
else:
@@ -316,13 +326,12 @@
"""
Assign mastership to controllers
"""
- import re
import time
- assert numControllers, "numControllers not defined"
+ assert main.numCtrls, "main.numCtrls not defined"
assert main, "main not defined"
assert utilities.assert_equals, "utilities.assert_equals not defined"
- assert CLIs, "CLIs not defined"
- assert nodes, "nodes not defined"
+ assert main.CLIs, "main.CLIs not defined"
+ assert main.nodes, "main.nodes not defined"
assert ONOS1Port, "ONOS1Port not defined"
assert ONOS2Port, "ONOS2Port not defined"
assert ONOS3Port, "ONOS3Port not defined"
@@ -350,45 +359,45 @@
# set up correct variables:
if i == 1:
c = 0
- ip = nodes[ c ].ip_address # ONOS1
+ ip = main.nodes[ c ].ip_address # ONOS1
deviceId = main.ONOScli1.getDevice( "1000" ).get( 'id' )
elif i == 2:
- c = 1 % numControllers
- ip = nodes[ c ].ip_address # ONOS2
+ c = 1 % main.numCtrls
+ ip = main.nodes[ c ].ip_address # ONOS2
deviceId = main.ONOScli1.getDevice( "2000" ).get( 'id' )
elif i == 3:
- c = 1 % numControllers
- ip = nodes[ c ].ip_address # ONOS2
+ c = 1 % main.numCtrls
+ ip = main.nodes[ c ].ip_address # ONOS2
deviceId = main.ONOScli1.getDevice( "3000" ).get( 'id' )
elif i == 4:
- c = 3 % numControllers
- ip = nodes[ c ].ip_address # ONOS4
+ c = 3 % main.numCtrls
+ ip = main.nodes[ c ].ip_address # ONOS4
deviceId = main.ONOScli1.getDevice( "3004" ).get( 'id' )
elif i == 5:
- c = 2 % numControllers
- ip = nodes[ c ].ip_address # ONOS3
+ c = 2 % main.numCtrls
+ ip = main.nodes[ c ].ip_address # ONOS3
deviceId = main.ONOScli1.getDevice( "5000" ).get( 'id' )
elif i == 6:
- c = 2 % numControllers
- ip = nodes[ c ].ip_address # ONOS3
+ c = 2 % main.numCtrls
+ ip = main.nodes[ c ].ip_address # ONOS3
deviceId = main.ONOScli1.getDevice( "6000" ).get( 'id' )
elif i == 7:
- c = 5 % numControllers
- ip = nodes[ c ].ip_address # ONOS6
+ c = 5 % main.numCtrls
+ ip = main.nodes[ c ].ip_address # ONOS6
deviceId = main.ONOScli1.getDevice( "6007" ).get( 'id' )
elif i >= 8 and i <= 17:
- c = 4 % numControllers
- ip = nodes[ c ].ip_address # ONOS5
+ c = 4 % main.numCtrls
+ ip = main.nodes[ c ].ip_address # ONOS5
dpid = '3' + str( i ).zfill( 3 )
deviceId = main.ONOScli1.getDevice( dpid ).get( 'id' )
elif i >= 18 and i <= 27:
- c = 6 % numControllers
- ip = nodes[ c ].ip_address # ONOS7
+ c = 6 % main.numCtrls
+ ip = main.nodes[ c ].ip_address # ONOS7
dpid = '6' + str( i ).zfill( 3 )
deviceId = main.ONOScli1.getDevice( dpid ).get( 'id' )
elif i == 28:
c = 0
- ip = nodes[ c ].ip_address # ONOS1
+ ip = main.nodes[ c ].ip_address # ONOS1
deviceId = main.ONOScli1.getDevice( "2800" ).get( 'id' )
else:
main.log.error( "You didn't write an else statement for " +
@@ -441,11 +450,11 @@
"""
import time
import json
- assert numControllers, "numControllers not defined"
+ assert main.numCtrls, "main.numCtrls not defined"
assert main, "main not defined"
assert utilities.assert_equals, "utilities.assert_equals not defined"
- assert CLIs, "CLIs not defined"
- assert nodes, "nodes not defined"
+ assert main.CLIs, "main.CLIs not defined"
+ assert main.nodes, "main.nodes not defined"
main.case( "Adding host Intents" )
main.caseExplanation = "Discover hosts by using pingall then " +\
"assign predetermined host-to-host intents." +\
@@ -455,7 +464,7 @@
# install onos-app-fwd
main.step( "Install reactive forwarding app" )
- installResults = CLIs[0].activateApp( "org.onosproject.fwd" )
+ installResults = main.CLIs[0].activateApp( "org.onosproject.fwd" )
utilities.assert_equals( expect=main.TRUE, actual=installResults,
onpass="Install fwd successful",
onfail="Install fwd failed" )
@@ -463,8 +472,8 @@
main.step( "Check app ids" )
appCheck = main.TRUE
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].appToIDCheck,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].appToIDCheck,
name="appToIDCheck-" + str( i ),
args=[] )
threads.append( t )
@@ -474,8 +483,8 @@
t.join()
appCheck = appCheck and t.result
if appCheck != main.TRUE:
- main.log.warn( CLIs[0].apps() )
- main.log.warn( CLIs[0].appIDs() )
+ main.log.warn( main.CLIs[0].apps() )
+ main.log.warn( main.CLIs[0].appIDs() )
utilities.assert_equals( expect=main.TRUE, actual=appCheck,
onpass="App Ids seem to be correct",
onfail="Something is wrong with app Ids" )
@@ -501,7 +510,7 @@
time.sleep( 11 )
# uninstall onos-app-fwd
main.step( "Uninstall reactive forwarding app" )
- uninstallResult = CLIs[0].deactivateApp( "org.onosproject.fwd" )
+ uninstallResult = main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
utilities.assert_equals( expect=main.TRUE, actual=uninstallResult,
onpass="Uninstall fwd successful",
onfail="Uninstall fwd failed" )
@@ -514,8 +523,8 @@
main.step( "Check app ids" )
threads = []
appCheck2 = main.TRUE
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].appToIDCheck,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].appToIDCheck,
name="appToIDCheck-" + str( i ),
args=[] )
threads.append( t )
@@ -525,8 +534,8 @@
t.join()
appCheck2 = appCheck2 and t.result
if appCheck2 != main.TRUE:
- main.log.warn( CLIs[0].apps() )
- main.log.warn( CLIs[0].appIDs() )
+ main.log.warn( main.CLIs[0].apps() )
+ main.log.warn( main.CLIs[0].appIDs() )
utilities.assert_equals( expect=main.TRUE, actual=appCheck2,
onpass="App Ids seem to be correct",
onfail="Something is wrong with app Ids" )
@@ -553,8 +562,8 @@
host1Id = host1Dict.get( 'id', None )
host2Id = host2Dict.get( 'id', None )
if host1Id and host2Id:
- nodeNum = ( i % numControllers )
- tmpId = CLIs[ nodeNum ].addHostIntent( host1Id, host2Id )
+ nodeNum = ( i % main.numCtrls )
+ tmpId = main.CLIs[ nodeNum ].addHostIntent( host1Id, host2Id )
if tmpId:
main.log.info( "Added intent with id: " + tmpId )
intentIds.append( tmpId )
@@ -564,7 +573,7 @@
else:
main.log.error( "Error, getHost() failed for h" + str( i ) +
" and/or h" + str( i + 10 ) )
- hosts = CLIs[ 0 ].hosts()
+ hosts = main.CLIs[ 0 ].hosts()
main.log.warn( "Hosts output: " )
try:
main.log.warn( json.dumps( json.loads( hosts ),
@@ -645,7 +654,7 @@
main.log.error( repr( leaders ) )
# Check all nodes
if missing:
- for node in CLIs:
+ for node in main.CLIs:
response = node.leaders( jsonFormat=False)
main.log.warn( str( node.name ) + " leaders output: \n" +
str( response ) )
@@ -689,7 +698,7 @@
for i in range(100):
correct = True
main.log.info( "Submitted intents: " + str( sorted( intentIds ) ) )
- for cli in CLIs:
+ for cli in main.CLIs:
onosIds = []
ids = cli.getAllIntentsId()
onosIds.append( ids )
@@ -790,7 +799,7 @@
main.log.error( repr( leaders ) )
# Check all nodes
if missing:
- for node in CLIs:
+ for node in main.CLIs:
response = node.leaders( jsonFormat=False)
main.log.warn( str( node.name ) + " leaders output: \n" +
str( response ) )
@@ -831,11 +840,11 @@
"""
import json
import time
- assert numControllers, "numControllers not defined"
+ assert main.numCtrls, "main.numCtrls not defined"
assert main, "main not defined"
assert utilities.assert_equals, "utilities.assert_equals not defined"
- assert CLIs, "CLIs not defined"
- assert nodes, "nodes not defined"
+ assert main.CLIs, "main.CLIs not defined"
+ assert main.nodes, "main.nodes not defined"
main.case( "Verify connectivity by sendind traffic across Intents" )
main.caseExplanation = "Ping across added host intents to check " +\
"functionality and check the state of " +\
@@ -941,7 +950,7 @@
# TODO: Check for a leader of these topics
# Check all nodes
if topicCheck:
- for node in CLIs:
+ for node in main.CLIs:
response = node.leaders( jsonFormat=False)
main.log.warn( str( node.name ) + " leaders output: \n" +
str( response ) )
@@ -1034,7 +1043,7 @@
main.log.exception( "Error parsing leaders" )
main.log.error( repr( leaders ) )
if missing:
- for node in CLIs:
+ for node in main.CLIs:
response = node.leaders( jsonFormat=False)
main.log.warn( str( node.name ) + " leaders output: \n" +
str( response ) )
@@ -1069,7 +1078,7 @@
main.log.exception( "Error parsing pending map" )
main.log.error( repr( pendingMap ) )
# Print flowrules
- main.log.debug( CLIs[0].flows( jsonFormat=False ) )
+ main.log.debug( main.CLIs[0].flows( jsonFormat=False ) )
main.step( "Wait a minute then ping again" )
# the wait is above
PingResult = main.TRUE
@@ -1108,11 +1117,11 @@
"""
import json
import time
- assert numControllers, "numControllers not defined"
+ assert main.numCtrls, "main.numCtrls not defined"
assert main, "main not defined"
assert utilities.assert_equals, "utilities.assert_equals not defined"
- assert CLIs, "CLIs not defined"
- assert nodes, "nodes not defined"
+ assert main.CLIs, "main.CLIs not defined"
+ assert main.nodes, "main.nodes not defined"
main.case( "Setting up and gathering data for current state" )
# The general idea for this test case is to pull the state of
@@ -1126,8 +1135,8 @@
# Assert that each device has a master
rolesNotNull = main.TRUE
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].rolesNotNull,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].rolesNotNull,
name="rolesNotNull-" + str( i ),
args=[] )
threads.append( t )
@@ -1148,8 +1157,8 @@
consistentMastership = True
rolesResults = True
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].roles,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].roles,
name="roles-" + str( i ),
args=[] )
threads.append( t )
@@ -1159,7 +1168,7 @@
t.join()
ONOSMastership.append( t.result )
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if not ONOSMastership[i] or "Error" in ONOSMastership[i]:
main.log.error( "Error in getting ONOS" + str( i + 1 ) +
" roles" )
@@ -1186,7 +1195,7 @@
onfail="ONOS nodes have different views of switch roles" )
if rolesResults and not consistentMastership:
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
try:
main.log.warn(
"ONOS" + str( i + 1 ) + " roles: ",
@@ -1209,8 +1218,8 @@
consistentIntents = True
intentsResults = True
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].intents,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].intents,
name="intents-" + str( i ),
args=[],
kwargs={ 'jsonFormat': True } )
@@ -1221,7 +1230,7 @@
t.join()
ONOSIntents.append( t.result )
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if not ONOSIntents[ i ] or "Error" in ONOSIntents[ i ]:
main.log.error( "Error in getting ONOS" + str( i + 1 ) +
" intents" )
@@ -1255,9 +1264,10 @@
# ... ... ...
# ... ... ...
title = " Id"
- for n in range( numControllers ):
+ for n in range( main.numCtrls ):
title += " " * 10 + "ONOS" + str( n + 1 )
main.log.warn( title )
+ # get all intent keys in the cluster
keys = []
try:
# Get the set of all intent keys
@@ -1288,7 +1298,7 @@
sort_keys=True,
indent=4,
separators=( ',', ': ' ) ) )
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if ONOSIntents[ i ] != ONOSIntents[ -1 ]:
main.log.debug( "ONOS" + str( i + 1 ) + " intents: " )
main.log.debug( json.dumps( json.loads( ONOSIntents[i] ),
@@ -1296,7 +1306,7 @@
indent=4,
separators=( ',', ': ' ) ) )
else:
- main.log.debug( nodes[ i ].name + " intents match ONOS" +
+ main.log.debug( main.nodes[ i ].name + " intents match ONOS" +
str( n ) + " intents" )
elif intentsResults and consistentIntents:
intentCheck = main.TRUE
@@ -1311,8 +1321,8 @@
consistentFlows = True
flowsResults = True
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].flows,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].flows,
name="flows-" + str( i ),
args=[],
kwargs={ 'jsonFormat': True } )
@@ -1326,7 +1336,7 @@
result = t.result
ONOSFlows.append( result )
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
num = str( i + 1 )
if not ONOSFlows[ i ] or "Error" in ONOSFlows[ i ]:
main.log.error( "Error in getting ONOS" + num + " flows" )
@@ -1363,7 +1373,7 @@
onfail="ONOS nodes have different flow counts" )
if flowsResults and not consistentFlows:
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
try:
main.log.warn(
"ONOS" + str( i + 1 ) + " flows: " +
@@ -1432,8 +1442,8 @@
main.step( "Collecting topology information from ONOS" )
devices = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].devices,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].devices,
name="devices-" + str( i ),
args=[ ] )
threads.append( t )
@@ -1444,8 +1454,8 @@
devices.append( t.result )
hosts = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].hosts,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].hosts,
name="hosts-" + str( i ),
args=[ ] )
threads.append( t )
@@ -1464,8 +1474,8 @@
ports = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].ports,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].ports,
name="ports-" + str( i ),
args=[ ] )
threads.append( t )
@@ -1476,8 +1486,8 @@
ports.append( t.result )
links = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].links,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].links,
name="links-" + str( i ),
args=[ ] )
threads.append( t )
@@ -1488,8 +1498,8 @@
links.append( t.result )
clusters = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].clusters,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].clusters,
name="clusters-" + str( i ),
args=[ ] )
threads.append( t )
@@ -1591,7 +1601,7 @@
mnSwitches = main.Mininet1.getSwitches()
mnLinks = main.Mininet1.getLinks()
mnHosts = main.Mininet1.getHosts()
- for controller in range( numControllers ):
+ for controller in range( main.numCtrls ):
controllerStr = str( controller + 1 )
if devices[ controller ] and ports[ controller ] and\
"Error" not in devices[ controller ] and\
@@ -1665,11 +1675,11 @@
The Failure case. Since this is the Sanity test, we do nothing.
"""
import time
- assert numControllers, "numControllers not defined"
+ assert main.numCtrls, "main.numCtrls not defined"
assert main, "main not defined"
assert utilities.assert_equals, "utilities.assert_equals not defined"
- assert CLIs, "CLIs not defined"
- assert nodes, "nodes not defined"
+ assert main.CLIs, "main.CLIs not defined"
+ assert main.nodes, "main.nodes not defined"
main.case( "Wait 60 seconds instead of inducing a failure" )
time.sleep( 60 )
utilities.assert_equals(
@@ -1683,19 +1693,19 @@
Check state after ONOS failure
"""
import json
- assert numControllers, "numControllers not defined"
+ assert main.numCtrls, "main.numCtrls not defined"
assert main, "main not defined"
assert utilities.assert_equals, "utilities.assert_equals not defined"
- assert CLIs, "CLIs not defined"
- assert nodes, "nodes not defined"
+ assert main.CLIs, "main.CLIs not defined"
+ assert main.nodes, "main.nodes not defined"
main.case( "Running ONOS Constant State Tests" )
main.step( "Check that each switch has a master" )
# Assert that each device has a master
rolesNotNull = main.TRUE
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].rolesNotNull,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].rolesNotNull,
name="rolesNotNull-" + str( i ),
args=[ ] )
threads.append( t )
@@ -1716,8 +1726,8 @@
consistentMastership = True
rolesResults = True
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].roles,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].roles,
name="roles-" + str( i ),
args=[] )
threads.append( t )
@@ -1727,7 +1737,7 @@
t.join()
ONOSMastership.append( t.result )
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if not ONOSMastership[i] or "Error" in ONOSMastership[i]:
main.log.error( "Error in getting ONOS" + str( i + 1 ) +
" roles" )
@@ -1754,7 +1764,7 @@
onfail="ONOS nodes have different views of switch roles" )
if rolesResults and not consistentMastership:
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
main.log.warn(
"ONOS" + str( i + 1 ) + " roles: ",
json.dumps(
@@ -1803,8 +1813,8 @@
consistentIntents = True
intentsResults = True
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].intents,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].intents,
name="intents-" + str( i ),
args=[],
kwargs={ 'jsonFormat': True } )
@@ -1815,7 +1825,7 @@
t.join()
ONOSIntents.append( t.result )
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if not ONOSIntents[ i ] or "Error" in ONOSIntents[ i ]:
main.log.error( "Error in getting ONOS" + str( i + 1 ) +
" intents" )
@@ -1842,7 +1852,7 @@
# ... ... ...
# ... ... ...
title = " ID"
- for n in range( numControllers ):
+ for n in range( main.numCtrls ):
title += " " * 10 + "ONOS" + str( n + 1 )
main.log.warn( title )
# get all intent keys in the cluster
@@ -1882,7 +1892,7 @@
main.log.info( dict( out ) )
if intentsResults and not consistentIntents:
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
main.log.warn( "ONOS" + str( i + 1 ) + " intents: " )
main.log.warn( json.dumps(
json.loads( ONOSIntents[ i ] ),
@@ -1993,9 +2003,9 @@
# Test of LeadershipElection
# NOTE: this only works for the sanity test. In case of failures,
# leader will likely change
- leader = nodes[ 0 ].ip_address
+ leader = main.nodes[ 0 ].ip_address
leaderResult = main.TRUE
- for cli in CLIs:
+ for cli in main.CLIs:
leaderN = cli.electionTestLeader()
# verify leader is ONOS1
if leaderN == leader:
@@ -2026,11 +2036,11 @@
"""
import json
import time
- assert numControllers, "numControllers not defined"
+ assert main.numCtrls, "main.numCtrls not defined"
assert main, "main not defined"
assert utilities.assert_equals, "utilities.assert_equals not defined"
- assert CLIs, "CLIs not defined"
- assert nodes, "nodes not defined"
+ assert main.CLIs, "main.CLIs not defined"
+ assert main.nodes, "main.nodes not defined"
main.case( "Compare ONOS Topology view to Mininet topology" )
main.caseExplanation = "Compare topology objects between Mininet" +\
@@ -2052,8 +2062,8 @@
cliStart = time.time()
devices = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].devices,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].devices,
name="devices-" + str( i ),
args=[ ] )
threads.append( t )
@@ -2065,8 +2075,8 @@
hosts = []
ipResult = main.TRUE
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].hosts,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].hosts,
name="hosts-" + str( i ),
args=[ ] )
threads.append( t )
@@ -2089,8 +2099,8 @@
ipResult = main.FALSE
ports = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].ports,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].ports,
name="ports-" + str( i ),
args=[ ] )
threads.append( t )
@@ -2101,8 +2111,8 @@
ports.append( t.result )
links = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].links,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].links,
name="links-" + str( i ),
args=[ ] )
threads.append( t )
@@ -2113,8 +2123,8 @@
links.append( t.result )
clusters = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].clusters,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].clusters,
name="clusters-" + str( i ),
args=[ ] )
threads.append( t )
@@ -2132,7 +2142,7 @@
mnSwitches = main.Mininet1.getSwitches()
mnLinks = main.Mininet1.getLinks()
mnHosts = main.Mininet1.getHosts()
- for controller in range( numControllers ):
+ for controller in range( main.numCtrls ):
controllerStr = str( controller + 1 )
if devices[ controller ] and ports[ controller ] and\
"Error" not in devices[ controller ] and\
@@ -2395,8 +2405,8 @@
nodesOutput = []
nodeResults = main.TRUE
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].nodes,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].nodes,
name="nodes-" + str( i ),
args=[ ] )
threads.append( t )
@@ -2405,7 +2415,7 @@
for t in threads:
t.join()
nodesOutput.append( t.result )
- ips = [ node.ip_address for node in nodes ]
+ ips = [ node.ip_address for node in main.nodes ]
for i in nodesOutput:
try:
current = json.loads( i )
@@ -2435,11 +2445,11 @@
Link s3-s28 down
"""
import time
- assert numControllers, "numControllers not defined"
+ assert main.numCtrls, "main.numCtrls not defined"
assert main, "main not defined"
assert utilities.assert_equals, "utilities.assert_equals not defined"
- assert CLIs, "CLIs not defined"
- assert nodes, "nodes not defined"
+ assert main.CLIs, "main.CLIs not defined"
+ assert main.nodes, "main.nodes not defined"
# NOTE: You should probably run a topology check after this
linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] )
@@ -2463,11 +2473,11 @@
Link s3-s28 up
"""
import time
- assert numControllers, "numControllers not defined"
+ assert main.numCtrls, "main.numCtrls not defined"
assert main, "main not defined"
assert utilities.assert_equals, "utilities.assert_equals not defined"
- assert CLIs, "CLIs not defined"
- assert nodes, "nodes not defined"
+ assert main.CLIs, "main.CLIs not defined"
+ assert main.nodes, "main.nodes not defined"
# NOTE: You should probably run a topology check after this
linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] )
@@ -2492,11 +2502,11 @@
"""
# NOTE: You should probably run a topology check after this
import time
- assert numControllers, "numControllers not defined"
+ assert main.numCtrls, "main.numCtrls not defined"
assert main, "main not defined"
assert utilities.assert_equals, "utilities.assert_equals not defined"
- assert CLIs, "CLIs not defined"
- assert nodes, "nodes not defined"
+ assert main.CLIs, "main.CLIs not defined"
+ assert main.nodes, "main.nodes not defined"
switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
@@ -2528,11 +2538,11 @@
"""
# NOTE: You should probably run a topology check after this
import time
- assert numControllers, "numControllers not defined"
+ assert main.numCtrls, "main.numCtrls not defined"
assert main, "main not defined"
assert utilities.assert_equals, "utilities.assert_equals not defined"
- assert CLIs, "CLIs not defined"
- assert nodes, "nodes not defined"
+ assert main.CLIs, "main.CLIs not defined"
+ assert main.nodes, "main.nodes not defined"
assert ONOS1Port, "ONOS1Port not defined"
assert ONOS2Port, "ONOS2Port not defined"
assert ONOS3Port, "ONOS3Port not defined"
@@ -2553,8 +2563,8 @@
for peer in links:
main.Mininet1.addLink( switch, peer )
ipList = []
- for i in range( numControllers ):
- ipList.append( nodes[ i ].ip_address )
+ for i in range( main.numCtrls ):
+ ipList.append( main.nodes[ i ].ip_address )
main.Mininet1.assignSwController( sw=switch, ip=ipList )
main.log.info( "Waiting " + str( switchSleep ) +
" seconds for switch up to be discovered" )
@@ -2575,11 +2585,11 @@
"""
import os
import time
- assert numControllers, "numControllers not defined"
+ assert main.numCtrls, "main.numCtrls not defined"
assert main, "main not defined"
assert utilities.assert_equals, "utilities.assert_equals not defined"
- assert CLIs, "CLIs not defined"
- assert nodes, "nodes not defined"
+ assert main.CLIs, "main.CLIs not defined"
+ assert main.nodes, "main.nodes not defined"
# printing colors to terminal
colors = { 'cyan': '\033[96m', 'purple': '\033[95m',
@@ -2605,7 +2615,7 @@
# NOTE: must end in /
dstDir = "~/packet_captures/"
for f in logFiles:
- for node in nodes:
+ for node in main.nodes:
main.ONOSbench.handle.sendline( "scp sdn@" + node.ip_address +
":" + logFolder + f + " " +
teststationUser + "@" +
@@ -2621,7 +2631,7 @@
# NOTE: must end in /
dstDir = "~/packet_captures/"
for f in logFiles:
- for node in nodes:
+ for node in main.nodes:
main.ONOSbench.handle.sendline( "scp sdn@" + node.ip_address +
":" + logFolder + f + " " +
teststationUser + "@" +
@@ -2641,7 +2651,7 @@
onfail="MN cleanup NOT successful" )
main.step( "Checking ONOS Logs for errors" )
- for node in nodes:
+ for node in main.nodes:
print colors[ 'purple' ] + "Checking logs for errors on " + \
node.name + ":" + colors[ 'end' ]
print main.ONOSbench.checkLogs( node.ip_address )
@@ -2660,11 +2670,11 @@
"""
start election app on all onos nodes
"""
- assert numControllers, "numControllers not defined"
+ assert main.numCtrls, "main.numCtrls not defined"
assert main, "main not defined"
assert utilities.assert_equals, "utilities.assert_equals not defined"
- assert CLIs, "CLIs not defined"
- assert nodes, "nodes not defined"
+ assert main.CLIs, "main.CLIs not defined"
+ assert main.nodes, "main.nodes not defined"
main.case("Start Leadership Election app")
main.step( "Install leadership election app" )
@@ -2678,9 +2688,9 @@
main.step( "Run for election on each node" )
leaderResult = main.TRUE
leaders = []
- for cli in CLIs:
+ for cli in main.CLIs:
cli.electionTestRun()
- for cli in CLIs:
+ for cli in main.CLIs:
leader = cli.electionTestLeader()
if leader is None or leader == main.FALSE:
main.log.error( cli.name + ": Leader for the election app " +
@@ -2698,7 +2708,7 @@
sameLeader = main.TRUE
if len( set( leaders ) ) != 1:
sameLeader = main.FALSE
- main.log.error( "Results of electionTestLeader is order of CLIs:" +
+ main.log.error( "Results of electionTestLeader is order of main.CLIs:" +
str( leaders ) )
utilities.assert_equals(
expect=main.TRUE,
@@ -2711,11 +2721,11 @@
Check that Leadership Election is still functional
"""
import time
- assert numControllers, "numControllers not defined"
+ assert main.numCtrls, "main.numCtrls not defined"
assert main, "main not defined"
assert utilities.assert_equals, "utilities.assert_equals not defined"
- assert CLIs, "CLIs not defined"
- assert nodes, "nodes not defined"
+ assert main.CLIs, "main.CLIs not defined"
+ assert main.nodes, "main.nodes not defined"
leaderResult = main.TRUE
description = "Check that Leadership Election is still functional"
@@ -2724,12 +2734,12 @@
main.step( "Check that each node shows the same leader" )
sameLeader = main.TRUE
leaders = []
- for cli in CLIs:
+ for cli in main.CLIs:
leader = cli.electionTestLeader()
leaders.append( leader )
if len( set( leaders ) ) != 1:
sameLeader = main.FALSE
- main.log.error( "Results of electionTestLeader is order of CLIs:" +
+ main.log.error( "Results of electionTestLeader is order of main.CLIs:" +
str( leaders ) )
utilities.assert_equals(
expect=main.TRUE,
@@ -2747,9 +2757,9 @@
"instead got '" + str( leader ) + "'" )
leaderResult = main.FALSE
oldLeader = None
- for i in range( len( CLIs ) ):
- if leader == nodes[ i ].ip_address:
- oldLeader = CLIs[ i ]
+ for i in range( len( main.CLIs ) ):
+ if leader == main.nodes[ i ].ip_address:
+ oldLeader = main.CLIs[ i ]
break
else: # FOR/ELSE statement
main.log.error( "Leader election, could not find current leader" )
@@ -2764,7 +2774,7 @@
main.step( "Make sure new leader is elected" )
# FIXME: use threads
leaderList = []
- for cli in CLIs:
+ for cli in main.CLIs:
leaderN = cli.electionTestLeader()
leaderList.append( leaderN )
if leaderN == leader:
@@ -2836,11 +2846,11 @@
Install Distributed Primitives app
"""
import time
- assert numControllers, "numControllers not defined"
+ assert main.numCtrls, "main.numCtrls not defined"
assert main, "main not defined"
assert utilities.assert_equals, "utilities.assert_equals not defined"
- assert CLIs, "CLIs not defined"
- assert nodes, "nodes not defined"
+ assert main.CLIs, "main.CLIs not defined"
+ assert main.nodes, "main.nodes not defined"
# Variables for the distributed primitives tests
global pCounterName
@@ -2860,7 +2870,7 @@
main.case( description )
main.step( "Install Primitives app" )
appName = "org.onosproject.distributedprimitives"
- appResults = CLIs[0].activateApp( appName )
+ appResults = main.CLIs[0].activateApp( appName )
utilities.assert_equals( expect=main.TRUE,
actual=appResults,
onpass="Primitives app activated",
@@ -2871,13 +2881,12 @@
"""
Check for basic functionality with distributed primitives
"""
- import json
# Make sure variables are defined/set
- assert numControllers, "numControllers not defined"
+ assert main.numCtrls, "main.numCtrls not defined"
assert main, "main not defined"
assert utilities.assert_equals, "utilities.assert_equals not defined"
- assert CLIs, "CLIs not defined"
- assert nodes, "nodes not defined"
+ assert main.CLIs, "main.CLIs not defined"
+ assert main.nodes, "main.nodes not defined"
assert pCounterName, "pCounterName not defined"
assert iCounterName, "iCounterName not defined"
assert onosSetName, "onosSetName not defined"
@@ -2905,15 +2914,17 @@
description = "Check for basic functionality with distributed " +\
"primitives"
main.case( description )
- main.caseExplanation = "Test the methods of the distributed primitives (counters and sets) throught the cli"
+ main.caseExplanation = "Test the methods of the distributed " +\
+ "primitives (counters and sets) throught the cli"
# DISTRIBUTED ATOMIC COUNTERS
- main.step( "Increment and get a default counter on each node" )
+ # Partitioned counters
+ main.step( "Increment then get a default counter on each node" )
pCounters = []
threads = []
addedPValues = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].counterTestIncrement,
- name="counterIncrement-" + str( i ),
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].counterTestAddAndGet,
+ name="counterAddAndGet-" + str( i ),
args=[ pCounterName ] )
pCounterValue += 1
addedPValues.append( pCounterValue )
@@ -2937,12 +2948,150 @@
onfail="Error incrementing default" +
" counter" )
- main.step( "Increment and get an in memory counter on each node" )
+ main.step( "Get then Increment a default counter on each node" )
+ pCounters = []
+ threads = []
+ addedPValues = []
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].counterTestGetAndAdd,
+ name="counterGetAndAdd-" + str( i ),
+ args=[ pCounterName ] )
+ addedPValues.append( pCounterValue )
+ pCounterValue += 1
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ pCounters.append( t.result )
+ # Check that counter incremented numController times
+ pCounterResults = True
+ for i in addedPValues:
+ tmpResult = i in pCounters
+ pCounterResults = pCounterResults and tmpResult
+ if not tmpResult:
+ main.log.error( str( i ) + " is not in partitioned "
+ "counter incremented results" )
+ utilities.assert_equals( expect=True,
+ actual=pCounterResults,
+ onpass="Default counter incremented",
+ onfail="Error incrementing default" +
+ " counter" )
+
+ main.step( "Counters we added have the correct values" )
+ incrementCheck = main.Counters.counterCheck( pCounterName, pCounterValue )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=incrementCheck,
+ onpass="Added counters are correct",
+ onfail="Added counters are incorrect" )
+
+ main.step( "Add -8 to then get a default counter on each node" )
+ pCounters = []
+ threads = []
+ addedPValues = []
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].counterTestAddAndGet,
+ name="counterIncrement-" + str( i ),
+ args=[ pCounterName ],
+ kwargs={ "delta": -8 } )
+ pCounterValue += -8
+ addedPValues.append( pCounterValue )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ pCounters.append( t.result )
+ # Check that counter incremented numController times
+ pCounterResults = True
+ for i in addedPValues:
+ tmpResult = i in pCounters
+ pCounterResults = pCounterResults and tmpResult
+ if not tmpResult:
+ main.log.error( str( i ) + " is not in partitioned "
+ "counter incremented results" )
+ utilities.assert_equals( expect=True,
+ actual=pCounterResults,
+ onpass="Default counter incremented",
+ onfail="Error incrementing default" +
+ " counter" )
+
+ main.step( "Add 5 to then get a default counter on each node" )
+ pCounters = []
+ threads = []
+ addedPValues = []
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].counterTestAddAndGet,
+ name="counterIncrement-" + str( i ),
+ args=[ pCounterName ],
+ kwargs={ "delta": 5 } )
+ pCounterValue += 5
+ addedPValues.append( pCounterValue )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ pCounters.append( t.result )
+ # Check that counter incremented numController times
+ pCounterResults = True
+ for i in addedPValues:
+ tmpResult = i in pCounters
+ pCounterResults = pCounterResults and tmpResult
+ if not tmpResult:
+ main.log.error( str( i ) + " is not in partitioned "
+ "counter incremented results" )
+ utilities.assert_equals( expect=True,
+ actual=pCounterResults,
+ onpass="Default counter incremented",
+ onfail="Error incrementing default" +
+ " counter" )
+
+ main.step( "Get then add 5 to a default counter on each node" )
+ pCounters = []
+ threads = []
+ addedPValues = []
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].counterTestGetAndAdd,
+ name="counterIncrement-" + str( i ),
+ args=[ pCounterName ],
+ kwargs={ "delta": 5 } )
+ addedPValues.append( pCounterValue )
+ pCounterValue += 5
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ pCounters.append( t.result )
+ # Check that counter incremented numController times
+ pCounterResults = True
+ for i in addedPValues:
+ tmpResult = i in pCounters
+ pCounterResults = pCounterResults and tmpResult
+ if not tmpResult:
+ main.log.error( str( i ) + " is not in partitioned "
+ "counter incremented results" )
+ utilities.assert_equals( expect=True,
+ actual=pCounterResults,
+ onpass="Default counter incremented",
+ onfail="Error incrementing default" +
+ " counter" )
+
+ main.step( "Counters we added have the correct values" )
+ incrementCheck = main.Counters.counterCheck( pCounterName, pCounterValue )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=incrementCheck,
+ onpass="Added counters are correct",
+ onfail="Added counters are incorrect" )
+
+ # In-Memory counters
+ main.step( "Increment and get an in-memory counter on each node" )
iCounters = []
addedIValues = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].counterTestIncrement,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].counterTestAddAndGet,
name="icounterIncrement-" + str( i ),
args=[ iCounterName ],
kwargs={ "inMemory": True } )
@@ -2964,15 +3113,153 @@
"counter incremented results" )
utilities.assert_equals( expect=True,
actual=iCounterResults,
- onpass="In memory counter incremented",
- onfail="Error incrementing in memory" +
+ onpass="In-memory counter incremented",
+ onfail="Error incrementing in-memory" +
" counter" )
+ main.step( "Get then Increment a in-memory counter on each node" )
+ iCounters = []
+ threads = []
+ addedIValues = []
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].counterTestGetAndAdd,
+ name="counterGetAndAdd-" + str( i ),
+ args=[ iCounterName ],
+ kwargs={ "inMemory": True } )
+ addedIValues.append( iCounterValue )
+ iCounterValue += 1
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ iCounters.append( t.result )
+ # Check that counter incremented numController times
+ iCounterResults = True
+ for i in addedIValues:
+ tmpResult = i in iCounters
+ iCounterResults = iCounterResults and tmpResult
+ if not tmpResult:
+ main.log.error( str( i ) + " is not in in-memory "
+ "counter incremented results" )
+ utilities.assert_equals( expect=True,
+ actual=iCounterResults,
+ onpass="In-memory counter incremented",
+ onfail="Error incrementing in-memory" +
+ " counter" )
+
+ main.step( "Counters we added have the correct values" )
+ incrementCheck = main.Counters.counterCheck( iCounterName, iCounterValue )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=incrementCheck,
+ onpass="Added counters are correct",
+ onfail="Added counters are incorrect" )
+
+ main.step( "Add -8 to then get a in-memory counter on each node" )
+ iCounters = []
+ threads = []
+ addedIValues = []
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].counterTestAddAndGet,
+ name="counterIncrement-" + str( i ),
+ args=[ iCounterName ],
+ kwargs={ "delta": -8, "inMemory": True } )
+ iCounterValue += -8
+ addedIValues.append( iCounterValue )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ iCounters.append( t.result )
+ # Check that counter incremented numController times
+ iCounterResults = True
+ for i in addedIValues:
+ tmpResult = i in iCounters
+ iCounterResults = iCounterResults and tmpResult
+ if not tmpResult:
+ main.log.error( str( i ) + " is not in in-memory "
+ "counter incremented results" )
+ utilities.assert_equals( expect=True,
+ actual=pCounterResults,
+ onpass="In-memory counter incremented",
+ onfail="Error incrementing in-memory" +
+ " counter" )
+
+ main.step( "Add 5 to then get a in-memory counter on each node" )
+ iCounters = []
+ threads = []
+ addedIValues = []
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].counterTestAddAndGet,
+ name="counterIncrement-" + str( i ),
+ args=[ iCounterName ],
+ kwargs={ "delta": 5, "inMemory": True } )
+ iCounterValue += 5
+ addedIValues.append( iCounterValue )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ iCounters.append( t.result )
+ # Check that counter incremented numController times
+ iCounterResults = True
+ for i in addedIValues:
+ tmpResult = i in iCounters
+ iCounterResults = iCounterResults and tmpResult
+ if not tmpResult:
+ main.log.error( str( i ) + " is not in in-memory "
+ "counter incremented results" )
+ utilities.assert_equals( expect=True,
+ actual=pCounterResults,
+ onpass="In-memory counter incremented",
+ onfail="Error incrementing in-memory" +
+ " counter" )
+
+ main.step( "Get then add 5 to a in-memory counter on each node" )
+ iCounters = []
+ threads = []
+ addedIValues = []
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].counterTestGetAndAdd,
+ name="counterIncrement-" + str( i ),
+ args=[ iCounterName ],
+ kwargs={ "delta": 5, "inMemory": True } )
+ addedIValues.append( iCounterValue )
+ iCounterValue += 5
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ iCounters.append( t.result )
+ # Check that counter incremented numController times
+ iCounterResults = True
+ for i in addedIValues:
+ tmpResult = i in iCounters
+ iCounterResults = iCounterResults and tmpResult
+ if not tmpResult:
+ main.log.error( str( i ) + " is not in in-memory "
+ "counter incremented results" )
+ utilities.assert_equals( expect=True,
+ actual=iCounterResults,
+ onpass="In-memory counter incremented",
+ onfail="Error incrementing in-memory" +
+ " counter" )
+
+ main.step( "Counters we added have the correct values" )
+ incrementCheck = main.Counters.counterCheck( iCounterName, iCounterValue )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=incrementCheck,
+ onpass="Added counters are correct",
+ onfail="Added counters are incorrect" )
+
main.step( "Check counters are consistant across nodes" )
onosCounters = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].counters,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].counters,
name="counters-" + str( i ) )
threads.append( t )
t.start()
@@ -2994,59 +3281,21 @@
"across nodes" )
main.step( "Counters we added have the correct values" )
- correctResults = main.TRUE
- for i in range( numControllers ):
- try:
- current = json.loads( onosCounters[i] )
- except ( ValueError, TypeError ):
- main.log.error( "Could not parse counters response from ONOS" +
- str( i + 1 ) )
- main.log.warn( repr( onosCounters[ i ] ) )
- pValue = None
- iValue = None
- try:
- for database in current:
- partitioned = database.get( 'partitionedDatabaseCounters' )
- if partitioned:
- for value in partitioned:
- if value.get( 'name' ) == pCounterName:
- pValue = value.get( 'value' )
- break
- inMemory = database.get( 'inMemoryDatabaseCounters' )
- if inMemory:
- for value in inMemory:
- if value.get( 'name' ) == iCounterName:
- iValue = value.get( 'value' )
- break
- except AttributeError, e:
- main.log.error( "ONOS" + str( i + 1 ) + " counters result " +
- "is not as expected" )
- correctResults = main.FALSE
- if pValue == pCounterValue:
- main.log.info( "Partitioned counter value is correct" )
- else:
- main.log.error( "Partitioned counter value is incorrect," +
- " expected value: " + str( pCounterValue )
- + " current value: " + str( pValue ) )
- correctResults = main.FALSE
- if iValue == iCounterValue:
- main.log.info( "In memory counter value is correct" )
- else:
- main.log.error( "In memory counter value is incorrect, " +
- "expected value: " + str( iCounterValue ) +
- " current value: " + str( iValue ) )
- correctResults = main.FALSE
+ incrementCheck = main.Counters.counterCheck( iCounterName, iCounterValue )
+ incrementCheck = incrementCheck and \
+ main.Counters.counterCheck( iCounterName, iCounterValue )
utilities.assert_equals( expect=main.TRUE,
- actual=correctResults,
+ actual=incrementCheck,
onpass="Added counters are correct",
onfail="Added counters are incorrect" )
+
# DISTRIBUTED SETS
main.step( "Distributed Set get" )
size = len( onosSet )
getResponses = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].setTestGet,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].setTestGet,
name="setTestGet-" + str( i ),
args=[ onosSetName ] )
threads.append( t )
@@ -3056,7 +3305,7 @@
getResponses.append( t.result )
getResults = main.TRUE
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if isinstance( getResponses[ i ], list):
current = set( getResponses[ i ] )
if len( current ) == len( getResponses[ i ] ):
@@ -3086,8 +3335,8 @@
main.step( "Distributed Set size" )
sizeResponses = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].setTestSize,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].setTestSize,
name="setTestSize-" + str( i ),
args=[ onosSetName ] )
threads.append( t )
@@ -3097,7 +3346,7 @@
sizeResponses.append( t.result )
sizeResults = main.TRUE
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if size != sizeResponses[ i ]:
sizeResults = main.FALSE
main.log.error( "ONOS" + str( i + 1 ) +
@@ -3113,8 +3362,8 @@
onosSet.add( addValue )
addResponses = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].setTestAdd,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].setTestAdd,
name="setTestAdd-" + str( i ),
args=[ onosSetName, addValue ] )
threads.append( t )
@@ -3127,7 +3376,7 @@
# main.FALSE = action resulted in no change in set
# main.ERROR - Some error in executing the function
addResults = main.TRUE
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if addResponses[ i ] == main.TRUE:
# All is well
pass
@@ -3147,8 +3396,8 @@
size = len( onosSet )
getResponses = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].setTestGet,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].setTestGet,
name="setTestGet-" + str( i ),
args=[ onosSetName ] )
threads.append( t )
@@ -3157,7 +3406,7 @@
t.join()
getResponses.append( t.result )
getResults = main.TRUE
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if isinstance( getResponses[ i ], list):
current = set( getResponses[ i ] )
if len( current ) == len( getResponses[ i ] ):
@@ -3181,8 +3430,8 @@
getResults = main.FALSE
sizeResponses = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].setTestSize,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].setTestSize,
name="setTestSize-" + str( i ),
args=[ onosSetName ] )
threads.append( t )
@@ -3191,7 +3440,7 @@
t.join()
sizeResponses.append( t.result )
sizeResults = main.TRUE
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if size != sizeResponses[ i ]:
sizeResults = main.FALSE
main.log.error( "ONOS" + str( i + 1 ) +
@@ -3208,8 +3457,8 @@
onosSet.update( addAllValue.split() )
addResponses = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].setTestAdd,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].setTestAdd,
name="setTestAddAll-" + str( i ),
args=[ onosSetName, addAllValue ] )
threads.append( t )
@@ -3222,7 +3471,7 @@
# main.FALSE = action resulted in no change in set
# main.ERROR - Some error in executing the function
addAllResults = main.TRUE
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if addResponses[ i ] == main.TRUE:
# All is well
pass
@@ -3242,8 +3491,8 @@
size = len( onosSet )
getResponses = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].setTestGet,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].setTestGet,
name="setTestGet-" + str( i ),
args=[ onosSetName ] )
threads.append( t )
@@ -3252,7 +3501,7 @@
t.join()
getResponses.append( t.result )
getResults = main.TRUE
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if isinstance( getResponses[ i ], list):
current = set( getResponses[ i ] )
if len( current ) == len( getResponses[ i ] ):
@@ -3276,8 +3525,8 @@
getResults = main.FALSE
sizeResponses = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].setTestSize,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].setTestSize,
name="setTestSize-" + str( i ),
args=[ onosSetName ] )
threads.append( t )
@@ -3286,7 +3535,7 @@
t.join()
sizeResponses.append( t.result )
sizeResults = main.TRUE
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if size != sizeResponses[ i ]:
sizeResults = main.FALSE
main.log.error( "ONOS" + str( i + 1 ) +
@@ -3302,8 +3551,8 @@
main.step( "Distributed Set contains()" )
containsResponses = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].setTestGet,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].setTestGet,
name="setContains-" + str( i ),
args=[ onosSetName ],
kwargs={ "values": addValue } )
@@ -3315,7 +3564,7 @@
containsResponses.append( t.result )
containsResults = main.TRUE
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if containsResponses[ i ] == main.ERROR:
containsResults = main.FALSE
else:
@@ -3329,8 +3578,8 @@
main.step( "Distributed Set containsAll()" )
containsAllResponses = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].setTestGet,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].setTestGet,
name="setContainsAll-" + str( i ),
args=[ onosSetName ],
kwargs={ "values": addAllValue } )
@@ -3342,7 +3591,7 @@
containsAllResponses.append( t.result )
containsAllResults = main.TRUE
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if containsResponses[ i ] == main.ERROR:
containsResults = main.FALSE
else:
@@ -3357,8 +3606,8 @@
onosSet.remove( addValue )
removeResponses = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].setTestRemove,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].setTestRemove,
name="setTestRemove-" + str( i ),
args=[ onosSetName, addValue ] )
threads.append( t )
@@ -3371,7 +3620,7 @@
# main.FALSE = action resulted in no change in set
# main.ERROR - Some error in executing the function
removeResults = main.TRUE
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if removeResponses[ i ] == main.TRUE:
# All is well
pass
@@ -3391,8 +3640,8 @@
size = len( onosSet )
getResponses = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].setTestGet,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].setTestGet,
name="setTestGet-" + str( i ),
args=[ onosSetName ] )
threads.append( t )
@@ -3401,7 +3650,7 @@
t.join()
getResponses.append( t.result )
getResults = main.TRUE
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if isinstance( getResponses[ i ], list):
current = set( getResponses[ i ] )
if len( current ) == len( getResponses[ i ] ):
@@ -3425,8 +3674,8 @@
getResults = main.FALSE
sizeResponses = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].setTestSize,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].setTestSize,
name="setTestSize-" + str( i ),
args=[ onosSetName ] )
threads.append( t )
@@ -3435,7 +3684,7 @@
t.join()
sizeResponses.append( t.result )
sizeResults = main.TRUE
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if size != sizeResponses[ i ]:
sizeResults = main.FALSE
main.log.error( "ONOS" + str( i + 1 ) +
@@ -3453,8 +3702,8 @@
removeAllResponses = []
threads = []
try:
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].setTestRemove,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].setTestRemove,
name="setTestRemoveAll-" + str( i ),
args=[ onosSetName, addAllValue ] )
threads.append( t )
@@ -3469,7 +3718,7 @@
# main.FALSE = action resulted in no change in set
# main.ERROR - Some error in executing the function
removeAllResults = main.TRUE
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if removeAllResponses[ i ] == main.TRUE:
# All is well
pass
@@ -3489,8 +3738,8 @@
size = len( onosSet )
getResponses = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].setTestGet,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].setTestGet,
name="setTestGet-" + str( i ),
args=[ onosSetName ] )
threads.append( t )
@@ -3499,7 +3748,7 @@
t.join()
getResponses.append( t.result )
getResults = main.TRUE
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if isinstance( getResponses[ i ], list):
current = set( getResponses[ i ] )
if len( current ) == len( getResponses[ i ] ):
@@ -3523,8 +3772,8 @@
getResults = main.FALSE
sizeResponses = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].setTestSize,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].setTestSize,
name="setTestSize-" + str( i ),
args=[ onosSetName ] )
threads.append( t )
@@ -3533,7 +3782,7 @@
t.join()
sizeResponses.append( t.result )
sizeResults = main.TRUE
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if size != sizeResponses[ i ]:
sizeResults = main.FALSE
main.log.error( "ONOS" + str( i + 1 ) +
@@ -3550,8 +3799,8 @@
onosSet.update( addAllValue.split() )
addResponses = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].setTestAdd,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].setTestAdd,
name="setTestAddAll-" + str( i ),
args=[ onosSetName, addAllValue ] )
threads.append( t )
@@ -3564,7 +3813,7 @@
# main.FALSE = action resulted in no change in set
# main.ERROR - Some error in executing the function
addAllResults = main.TRUE
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if addResponses[ i ] == main.TRUE:
# All is well
pass
@@ -3584,8 +3833,8 @@
size = len( onosSet )
getResponses = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].setTestGet,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].setTestGet,
name="setTestGet-" + str( i ),
args=[ onosSetName ] )
threads.append( t )
@@ -3594,7 +3843,7 @@
t.join()
getResponses.append( t.result )
getResults = main.TRUE
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if isinstance( getResponses[ i ], list):
current = set( getResponses[ i ] )
if len( current ) == len( getResponses[ i ] ):
@@ -3618,8 +3867,8 @@
getResults = main.FALSE
sizeResponses = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].setTestSize,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].setTestSize,
name="setTestSize-" + str( i ),
args=[ onosSetName ] )
threads.append( t )
@@ -3628,7 +3877,7 @@
t.join()
sizeResponses.append( t.result )
sizeResults = main.TRUE
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if size != sizeResponses[ i ]:
sizeResults = main.FALSE
main.log.error( "ONOS" + str( i + 1 ) +
@@ -3645,8 +3894,8 @@
onosSet.clear()
clearResponses = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].setTestRemove,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].setTestRemove,
name="setTestClear-" + str( i ),
args=[ onosSetName, " "], # Values doesn't matter
kwargs={ "clear": True } )
@@ -3660,7 +3909,7 @@
# main.FALSE = action resulted in no change in set
# main.ERROR - Some error in executing the function
clearResults = main.TRUE
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if clearResponses[ i ] == main.TRUE:
# All is well
pass
@@ -3680,8 +3929,8 @@
size = len( onosSet )
getResponses = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].setTestGet,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].setTestGet,
name="setTestGet-" + str( i ),
args=[ onosSetName ] )
threads.append( t )
@@ -3690,7 +3939,7 @@
t.join()
getResponses.append( t.result )
getResults = main.TRUE
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if isinstance( getResponses[ i ], list):
current = set( getResponses[ i ] )
if len( current ) == len( getResponses[ i ] ):
@@ -3714,8 +3963,8 @@
getResults = main.FALSE
sizeResponses = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].setTestSize,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].setTestSize,
name="setTestSize-" + str( i ),
args=[ onosSetName ] )
threads.append( t )
@@ -3724,7 +3973,7 @@
t.join()
sizeResponses.append( t.result )
sizeResults = main.TRUE
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if size != sizeResponses[ i ]:
sizeResults = main.FALSE
main.log.error( "ONOS" + str( i + 1 ) +
@@ -3741,8 +3990,8 @@
onosSet.update( addAllValue.split() )
addResponses = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].setTestAdd,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].setTestAdd,
name="setTestAddAll-" + str( i ),
args=[ onosSetName, addAllValue ] )
threads.append( t )
@@ -3755,7 +4004,7 @@
# main.FALSE = action resulted in no change in set
# main.ERROR - Some error in executing the function
addAllResults = main.TRUE
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if addResponses[ i ] == main.TRUE:
# All is well
pass
@@ -3775,8 +4024,8 @@
size = len( onosSet )
getResponses = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].setTestGet,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].setTestGet,
name="setTestGet-" + str( i ),
args=[ onosSetName ] )
threads.append( t )
@@ -3785,7 +4034,7 @@
t.join()
getResponses.append( t.result )
getResults = main.TRUE
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if isinstance( getResponses[ i ], list):
current = set( getResponses[ i ] )
if len( current ) == len( getResponses[ i ] ):
@@ -3809,8 +4058,8 @@
getResults = main.FALSE
sizeResponses = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].setTestSize,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].setTestSize,
name="setTestSize-" + str( i ),
args=[ onosSetName ] )
threads.append( t )
@@ -3819,7 +4068,7 @@
t.join()
sizeResponses.append( t.result )
sizeResults = main.TRUE
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if size != sizeResponses[ i ]:
sizeResults = main.FALSE
main.log.error( "ONOS" + str( i + 1 ) +
@@ -3836,8 +4085,8 @@
onosSet.intersection_update( retainValue.split() )
retainResponses = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].setTestRemove,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].setTestRemove,
name="setTestRetain-" + str( i ),
args=[ onosSetName, retainValue ],
kwargs={ "retain": True } )
@@ -3851,7 +4100,7 @@
# main.FALSE = action resulted in no change in set
# main.ERROR - Some error in executing the function
retainResults = main.TRUE
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if retainResponses[ i ] == main.TRUE:
# All is well
pass
@@ -3871,8 +4120,8 @@
size = len( onosSet )
getResponses = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].setTestGet,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].setTestGet,
name="setTestGet-" + str( i ),
args=[ onosSetName ] )
threads.append( t )
@@ -3881,7 +4130,7 @@
t.join()
getResponses.append( t.result )
getResults = main.TRUE
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if isinstance( getResponses[ i ], list):
current = set( getResponses[ i ] )
if len( current ) == len( getResponses[ i ] ):
@@ -3905,8 +4154,8 @@
getResults = main.FALSE
sizeResponses = []
threads = []
- for i in range( numControllers ):
- t = main.Thread( target=CLIs[i].setTestSize,
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].setTestSize,
name="setTestSize-" + str( i ),
args=[ onosSetName ] )
threads.append( t )
@@ -3915,7 +4164,7 @@
t.join()
sizeResponses.append( t.result )
sizeResults = main.TRUE
- for i in range( numControllers ):
+ for i in range( main.numCtrls ):
if size != sizeResponses[ i ]:
sizeResults = main.FALSE
main.log.error( "ONOS" + str( i + 1 ) +
diff --git a/TestON/tests/HAsanity/dependencies/Counters.py b/TestON/tests/HAsanity/dependencies/Counters.py
new file mode 100644
index 0000000..7abd73a
--- /dev/null
+++ b/TestON/tests/HAsanity/dependencies/Counters.py
@@ -0,0 +1,57 @@
+def __init__( self ):
+ self.default = ''
+
+def counterCheck( counterName, counterValue ):
+ """
+ Add Text here
+ """
+ import json
+ correctResults = main.TRUE
+ # Get onos counters results
+ onosCounters = []
+ threads = []
+ for i in range( main.numCtrls ):
+ t = main.Thread( target=main.CLIs[i].counters,
+ name="counters-" + str( i ) )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ onosCounters.append( t.result )
+ tmp = [ i == onosCounters[ 0 ] for i in onosCounters ]
+ if all( tmp ):
+ consistent = main.TRUE
+ else:
+ consistent = main.FALSE
+ main.log.error( "ONOS nodes have different values for counters" )
+ for node in onosCounters:
+ main.log.debug( node )
+
+ # Check for correct values
+ for i in range( main.numCtrls ):
+ try:
+ current = json.loads( onosCounters[i] )
+ except ( ValueError, TypeError ):
+ main.log.error( "Could not parse counters response from ONOS" +
+ str( i + 1 ) )
+ main.log.warn( repr( onosCounters[ i ] ) )
+ onosValue = None
+ try:
+ for database in current:
+ database = database.values()[0]
+ for counter in database:
+ if counter.get( 'name' ) == counterName:
+ onosValue = counter.get( 'value' )
+ break
+ except AttributeError, e:
+ main.log.error( "ONOS" + str( i + 1 ) + " counters result " +
+ "is not as expected" )
+ correctResults = main.FALSE
+ if onosValue == counterValue:
+ main.log.info( counterName + " counter value is correct" )
+ else:
+ main.log.error( counterName + " counter value is incorrect," +
+ " expected value: " + str( counterValue )
+ + " current value: " + str( onosValue ) )
+ correctResults = main.FALSE
+ return consistent and correctResults
diff --git a/TestON/tests/HAsanity/dependencies/__init__.py b/TestON/tests/HAsanity/dependencies/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/HAsanity/dependencies/__init__.py