Add HA testcases for new counter methods
Minor refactoring to allow a library file to be used
Change-Id: Ic634dfe26bf46d618dc703fa6fa8b5d234997dcf
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index bb57b9e..f991b09 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -3267,7 +3267,7 @@
# Node not leader
assert "java.lang.IllegalStateException" not in output
except AssertionError:
- main.log.error( "Error in processing 'set-test-add' " +
+ main.log.error( "Error in processing '" + cmdStr + "' " +
"command: " + str( output ) )
retryTime = 30 # Conservative time, given by Madan
main.log.info( "Waiting " + str( retryTime ) +
@@ -3288,7 +3288,7 @@
main.log.debug( self.name + " actual: " + repr( output ) )
return main.ERROR
except AssertionError:
- main.log.error( "Error in processing 'set-test-add' command: " +
+ main.log.error( "Error in processing '" + cmdStr + "' command: " +
str( output ) )
return main.ERROR
except TypeError:
@@ -3335,7 +3335,7 @@
# Node not leader
assert "java.lang.IllegalStateException" not in output
except AssertionError:
- main.log.error( "Error in processing 'set-test-add' " +
+ main.log.error( "Error in processing '" + cmdStr + "' " +
"command: " + str( output ) )
retryTime = 30 # Conservative time, given by Madan
main.log.info( "Waiting " + str( retryTime ) +
@@ -3377,7 +3377,7 @@
main.log.debug( self.name + " actual: " + repr( output ) )
return main.ERROR
except AssertionError:
- main.log.error( "Error in processing 'set-test-remove' command: " +
+ main.log.error( "Error in processing '" + cmdStr + "' command: " +
str( output ) )
return main.ERROR
except TypeError:
@@ -3434,7 +3434,7 @@
# Node not leader
assert "java.lang.IllegalStateException" not in output
except AssertionError:
- main.log.error( "Error in processing 'set-test-add' " +
+ main.log.error( "Error in processing '" + cmdStr + "' " +
"command: " + str( output ) )
retryTime = 30 # Conservative time, given by Madan
main.log.info( "Waiting " + str( retryTime ) +
@@ -3484,7 +3484,7 @@
main.log.debug( self.name + " actual: " + repr( output ) )
return main.ERROR
except AssertionError:
- main.log.error( "Error in processing 'set-test-get' command: " +
+ main.log.error( "Error in processing '" + cmdStr + "' command: " +
str( output ) )
return main.ERROR
except TypeError:
@@ -3527,7 +3527,7 @@
# Node not leader
assert "java.lang.IllegalStateException" not in output
except AssertionError:
- main.log.error( "Error in processing 'set-test-add' " +
+ main.log.error( "Error in processing '" + cmdStr + "' " +
"command: " + str( output ) )
retryTime = 30 # Conservative time, given by Madan
main.log.info( "Waiting " + str( retryTime ) +
@@ -3556,7 +3556,7 @@
main.log.debug( self.name + " actual: " + repr( output ) )
return None
except AssertionError:
- main.log.error( "Error in processing 'set-test-get' command: " +
+ main.log.error( "Error in processing '" + cmdStr + "' command: " +
str( output ) )
return None
except TypeError:
@@ -3607,12 +3607,13 @@
main.cleanup()
main.exit()
- def counterTestIncrement( self, counter, inMemory=False ):
+ def counterTestAddAndGet( self, counter, delta=1, inMemory=False ):
"""
- CLI command to increment and get a distributed counter.
+ CLI command to add a delta to then get a distributed counter.
Required arguments:
counter - The name of the counter to increment.
Optional arguments:
+ delta - The long to add to the counter
inMemory - use in memory map for the counter
returns:
integer value of the counter or
@@ -3620,10 +3621,13 @@
"""
try:
counter = str( counter )
+ delta = int( delta )
cmdStr = "counter-test-increment "
if inMemory:
cmdStr += "-i "
cmdStr += counter
+ if delta != 1:
+ cmdStr += " " + str( delta )
output = self.sendline( cmdStr )
try:
# TODO: Maybe make this less hardcoded
@@ -3632,7 +3636,7 @@
# Node not leader
assert "java.lang.IllegalStateException" not in output
except AssertionError:
- main.log.error( "Error in processing 'set-test-add' " +
+ main.log.error( "Error in processing '" + cmdStr + "' " +
"command: " + str( output ) )
retryTime = 30 # Conservative time, given by Madan
main.log.info( "Waiting " + str( retryTime ) +
@@ -3641,18 +3645,18 @@
output = self.sendline( cmdStr )
assert "Error executing command" not in output
main.log.info( self.name + ": " + output )
- pattern = counter + " was updated to (\d+)"
+ pattern = counter + " was updated to (-?\d+)"
match = re.search( pattern, output )
if match:
return int( match.group( 1 ) )
else:
- main.log.error( self.name + ": counterTestIncrement did not" +
+ main.log.error( self.name + ": counterTestAddAndGet did not" +
" match expected output." )
main.log.debug( self.name + " expected: " + pattern )
main.log.debug( self.name + " actual: " + repr( output ) )
return None
except AssertionError:
- main.log.error( "Error in processing 'counter-test-increment'" +
+ main.log.error( "Error in processing '" + cmdStr + "'" +
" command: " + str( output ) )
return None
except TypeError:
@@ -3668,6 +3672,72 @@
main.cleanup()
main.exit()
+ def counterTestGetAndAdd( self, counter, delta=1, inMemory=False ):
+ """
+ CLI command to get a distributed counter then add a delta to it.
+ Required arguments:
+ counter - The name of the counter to increment.
+ Optional arguments:
+ delta - The long to add to the counter
+ inMemory - use in memory map for the counter
+ returns:
+ integer value of the counter or
+ None on Error
+ """
+ try:
+ counter = str( counter )
+ delta = int( delta )
+ cmdStr = "counter-test-increment -g "
+ if inMemory:
+ cmdStr += "-i "
+ cmdStr += counter
+ if delta != 1:
+ cmdStr += " " + str( delta )
+ output = self.sendline( cmdStr )
+ try:
+ # TODO: Maybe make this less hardcoded
+ # ConsistentMap Exceptions
+ assert "org.onosproject.store.service" not in output
+ # Node not leader
+ assert "java.lang.IllegalStateException" not in output
+ except AssertionError:
+ main.log.error( "Error in processing '" + cmdStr + "' " +
+ "command: " + str( output ) )
+ retryTime = 30 # Conservative time, given by Madan
+ main.log.info( "Waiting " + str( retryTime ) +
+ "seconds before retrying." )
+ time.sleep( retryTime ) # Due to change in mastership
+ output = self.sendline( cmdStr )
+ assert "Error executing command" not in output
+ main.log.info( self.name + ": " + output )
+ pattern = counter + " was updated to (-?\d+)"
+ match = re.search( pattern, output )
+ if match:
+ return int( match.group( 1 ) )
+ else:
+ main.log.error( self.name + ": counterTestGetAndAdd did not" +
+ " match expected output." )
+ main.log.debug( self.name + " expected: " + pattern )
+ main.log.debug( self.name + " actual: " + repr( output ) )
+ return None
+ except AssertionError:
+ main.log.error( "Error in processing '" + cmdStr + "'" +
+ " command: " + str( output ) )
+ return None
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ return None
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+
def summary( self, jsonFormat=True ):
"""
Description: Execute summary command in onos
diff --git a/TestON/tests/HAclusterRestart/HAclusterRestart.params b/TestON/tests/HAclusterRestart/HAclusterRestart.params
index 0435e0b..213fc0d 100644
--- a/TestON/tests/HAclusterRestart/HAclusterRestart.params
+++ b/TestON/tests/HAclusterRestart/HAclusterRestart.params
@@ -1,5 +1,8 @@
<PARAMS>
<testcases>1,2,8,3,8,4,5,14,16,17,[6],8,3,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/HAclusterRestart/dependencies/ </path>
+ </imports>
<ENV>
<cellName>HA</cellName>
<appString>drivers,openflow,proxyarp,mobility</appString>
diff --git a/TestON/tests/HAclusterRestart/HAclusterRestart.py b/TestON/tests/HAclusterRestart/HAclusterRestart.py
index ce2f27e..8205ac9 100644
--- a/TestON/tests/HAclusterRestart/HAclusterRestart.py
+++ b/TestON/tests/HAclusterRestart/HAclusterRestart.py
@@ -47,6 +47,7 @@
start cli sessions
start tcpdump
"""
+ import imp
main.log.info( "ONOS HA test: Restart all ONOS nodes - " +
"initialization" )
main.case( "Setting up test environment" )
@@ -62,12 +63,11 @@
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 )
+ # set global variables
global ONOS1Port
global ONOS2Port
global ONOS3Port
@@ -91,15 +91,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' ]
@@ -115,13 +126,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
@@ -188,7 +199,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
@@ -199,7 +210,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!" )
@@ -215,10 +226,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()
@@ -240,8 +251,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 )
@@ -251,8 +262,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" )
@@ -267,12 +278,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"
@@ -288,8 +298,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 ) )
@@ -302,7 +312,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:
@@ -320,13 +330,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"
@@ -354,45 +363,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 " +
@@ -445,11 +454,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"
try:
labels
except NameError:
@@ -471,7 +480,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" )
@@ -479,8 +488,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 )
@@ -490,8 +499,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" )
@@ -517,7 +526,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" )
@@ -525,8 +534,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 )
@@ -536,8 +545,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" )
@@ -564,8 +573,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 )
@@ -575,7 +584,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 ),
@@ -656,7 +665,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 ) )
@@ -700,7 +709,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 )
@@ -812,7 +821,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 ) )
@@ -853,11 +862,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 " +\
@@ -902,6 +911,7 @@
intents = main.ONOScli1.intents()
intentStates = []
main.log.info( "%-6s%-15s%-15s" % ( 'Count', 'ID', 'State' ) )
+ count = 0
# Iter through intents of a node
try:
for intent in json.loads( intents ):
@@ -962,7 +972,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 ) )
@@ -1055,7 +1065,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 ) )
@@ -1090,7 +1100,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
@@ -1129,11 +1139,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
@@ -1147,8 +1157,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 )
@@ -1169,8 +1179,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 )
@@ -1180,7 +1190,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" )
@@ -1207,7 +1217,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: ",
@@ -1230,8 +1240,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 } )
@@ -1242,7 +1252,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" )
@@ -1276,7 +1286,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
@@ -1304,7 +1314,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] ),
@@ -1312,7 +1322,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
@@ -1327,8 +1337,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 } )
@@ -1342,7 +1352,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" )
@@ -1379,7 +1389,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: " +
@@ -1448,8 +1458,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 )
@@ -1460,8 +1470,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 )
@@ -1480,8 +1490,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 )
@@ -1492,8 +1502,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 )
@@ -1504,8 +1514,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 )
@@ -1607,16 +1617,15 @@
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\
"Error" not in ports[ controller ]:
-
- currentDevicesResult = main.Mininet1.compareSwitches(
- mnSwitches,
- json.loads( devices[ controller ] ),
- json.loads( 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,
@@ -1681,11 +1690,11 @@
The Failure case.
"""
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"
try:
labels
except NameError:
@@ -1710,7 +1719,7 @@
main.step( "Killing ONOS nodes" )
killResults = main.TRUE
killTime = time.time()
- for node in nodes:
+ for node in main.nodes:
killed = main.ONOSbench.onosKill( node.ip_address )
killResults = killResults and killed
utilities.assert_equals( expect=main.TRUE, actual=killResults,
@@ -1720,7 +1729,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!" )
@@ -1734,10 +1743,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()
@@ -1758,8 +1767,8 @@
# FIXME: revisit test plan for election with madan
# Rerun for election on restarted nodes
runResults = main.TRUE
- for cli in CLIs:
- run = CLIs[0].electionTestRun()
+ for cli in main.CLIs:
+ run = main.CLIs[0].electionTestRun()
if run != main.TRUE:
main.log.error( "Error running for election on " + cli.name )
runResults = runResults and run
@@ -1769,28 +1778,28 @@
# TODO: Make this configurable
time.sleep( 60 )
- main.log.debug( CLIs[0].nodes( jsonFormat=False ) )
- main.log.debug( CLIs[0].leaders( jsonFormat=False ) )
- main.log.debug( CLIs[0].partitions( jsonFormat=False ) )
+ main.log.debug( main.CLIs[0].nodes( jsonFormat=False ) )
+ main.log.debug( main.CLIs[0].leaders( jsonFormat=False ) )
+ main.log.debug( main.CLIs[0].partitions( jsonFormat=False ) )
def CASE7( self, main ):
"""
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 )
@@ -1811,8 +1820,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 )
@@ -1822,7 +1831,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" )
@@ -1849,7 +1858,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(
@@ -1900,8 +1909,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 } )
@@ -1912,7 +1921,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" )
@@ -1939,7 +1948,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
@@ -1979,7 +1988,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 ] ),
@@ -2095,7 +2104,7 @@
# Test of LeadershipElection
leaderList = []
leaderResult = main.TRUE
- for cli in CLIs:
+ for cli in main.CLIs:
leaderN = cli.electionTestLeader()
leaderList.append( leaderN )
if leaderN == main.FALSE:
@@ -2125,11 +2134,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" +\
@@ -2151,8 +2160,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 )
@@ -2164,8 +2173,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 )
@@ -2188,8 +2197,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 )
@@ -2200,8 +2209,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 )
@@ -2212,8 +2221,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 )
@@ -2231,7 +2240,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\
@@ -2489,8 +2498,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 )
@@ -2499,7 +2508,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 )
@@ -2529,11 +2538,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' ] )
@@ -2557,11 +2566,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' ] )
@@ -2586,11 +2595,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' ] )
@@ -2622,11 +2631,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"
@@ -2647,8 +2656,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" )
@@ -2669,11 +2678,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',
@@ -2699,7 +2708,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 + "@" +
@@ -2715,7 +2724,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 + "@" +
@@ -2735,7 +2744,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, restart=True )
@@ -2752,11 +2761,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" )
@@ -2770,9 +2779,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 " +
@@ -2803,11 +2812,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"
@@ -2816,9 +2825,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 " +
@@ -2836,7 +2845,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,
@@ -2854,9 +2863,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" )
@@ -2871,7 +2880,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:
@@ -2943,11 +2952,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
@@ -2967,7 +2976,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",
@@ -2978,13 +2987,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"
@@ -3012,15 +3020,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 )
@@ -3044,12 +3054,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 } )
@@ -3071,15 +3219,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()
@@ -3101,59 +3387,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 )
@@ -3163,7 +3411,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 ] ):
@@ -3193,8 +3441,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 )
@@ -3204,7 +3452,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 ) +
@@ -3220,8 +3468,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 )
@@ -3234,7 +3482,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
@@ -3254,8 +3502,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 )
@@ -3264,7 +3512,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 ] ):
@@ -3288,8 +3536,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 )
@@ -3298,7 +3546,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 ) +
@@ -3315,8 +3563,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 )
@@ -3329,7 +3577,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
@@ -3349,8 +3597,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 )
@@ -3359,7 +3607,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 ] ):
@@ -3383,8 +3631,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 )
@@ -3393,7 +3641,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 ) +
@@ -3409,8 +3657,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 } )
@@ -3422,7 +3670,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:
@@ -3436,8 +3684,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 } )
@@ -3449,7 +3697,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:
@@ -3464,8 +3712,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 )
@@ -3478,7 +3726,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
@@ -3498,8 +3746,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 )
@@ -3508,7 +3756,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 ] ):
@@ -3532,8 +3780,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 )
@@ -3542,7 +3790,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 ) +
@@ -3560,8 +3808,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 )
@@ -3576,7 +3824,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
@@ -3596,8 +3844,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 )
@@ -3606,7 +3854,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 ] ):
@@ -3630,8 +3878,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 )
@@ -3640,7 +3888,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 ) +
@@ -3657,8 +3905,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 )
@@ -3671,7 +3919,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
@@ -3691,8 +3939,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 )
@@ -3701,7 +3949,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 ] ):
@@ -3725,8 +3973,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 )
@@ -3735,7 +3983,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 ) +
@@ -3752,8 +4000,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 } )
@@ -3767,7 +4015,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
@@ -3787,8 +4035,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 )
@@ -3797,7 +4045,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 ] ):
@@ -3821,8 +4069,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 )
@@ -3831,7 +4079,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 ) +
@@ -3848,8 +4096,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 )
@@ -3862,7 +4110,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
@@ -3882,8 +4130,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 )
@@ -3892,7 +4140,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 ] ):
@@ -3916,8 +4164,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 )
@@ -3926,7 +4174,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 ) +
@@ -3943,8 +4191,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 } )
@@ -3958,7 +4206,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
@@ -3978,8 +4226,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 )
@@ -3988,7 +4236,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 ] ):
@@ -4012,8 +4260,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 )
@@ -4022,7 +4270,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/HAclusterRestart/dependencies/Counters.py b/TestON/tests/HAclusterRestart/dependencies/Counters.py
new file mode 100644
index 0000000..7abd73a
--- /dev/null
+++ b/TestON/tests/HAclusterRestart/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/HAclusterRestart/dependencies/__init__.py b/TestON/tests/HAclusterRestart/dependencies/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/HAclusterRestart/dependencies/__init__.py
diff --git a/TestON/tests/HAminorityRestart/HAminorityRestart.params b/TestON/tests/HAminorityRestart/HAminorityRestart.params
index f983129..87d1cea 100644
--- a/TestON/tests/HAminorityRestart/HAminorityRestart.params
+++ b/TestON/tests/HAminorityRestart/HAminorityRestart.params
@@ -1,5 +1,8 @@
<PARAMS>
<testcases>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</testcases>
+ <imports>
+ <path> /home/admin/OnosSystemTest/TestON/tests/HAminorityRestart/dependencies/ </path>
+ </imports>
<ENV>
<cellName>HA</cellName>
<appString>drivers,openflow,proxyarp,mobility</appString>
diff --git a/TestON/tests/HAminorityRestart/HAminorityRestart.py b/TestON/tests/HAminorityRestart/HAminorityRestart.py
index 8ff185a..94482ea 100644
--- a/TestON/tests/HAminorityRestart/HAminorityRestart.py
+++ b/TestON/tests/HAminorityRestart/HAminorityRestart.py
@@ -47,6 +47,7 @@
start cli sessions
start tcpdump
"""
+ import imp
main.log.info( "ONOS HA test: Restart minority of ONOS nodes - " +
"initialization" )
main.case( "Setting up test environment" )
@@ -62,12 +63,11 @@
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 )
+ # set global variables
global ONOS1Port
global ONOS2Port
global ONOS3Port
@@ -86,15 +86,27 @@
ONOS6Port = main.params[ 'CTRL' ][ 'port6' ]
ONOS7Port = main.params[ 'CTRL' ][ 'port7' ]
- global CLIs
- CLIs = []
- global nodes
- nodes = []
+ try:
+ fileName = "Counters"
+ # TODO: Maybe make a library folder somewhere?
+ 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' ]
@@ -110,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
@@ -183,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
@@ -194,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!" )
@@ -210,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()
@@ -235,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 )
@@ -246,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" )
@@ -262,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"
@@ -283,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 ) )
@@ -297,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:
@@ -315,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"
@@ -349,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 " +
@@ -440,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." +\
@@ -454,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" )
@@ -462,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 )
@@ -473,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" )
@@ -500,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" )
@@ -508,8 +518,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 )
@@ -519,8 +529,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" )
@@ -547,8 +557,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 )
@@ -558,7 +568,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 ),
@@ -639,7 +649,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 ) )
@@ -683,7 +693,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 )
@@ -784,7 +794,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 ) )
@@ -825,11 +835,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 " +\
@@ -935,7 +945,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 ) )
@@ -1028,7 +1038,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 ) )
@@ -1063,7 +1073,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
@@ -1102,11 +1112,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
@@ -1120,8 +1130,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 )
@@ -1142,8 +1152,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 )
@@ -1153,7 +1163,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" )
@@ -1180,7 +1190,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: ",
@@ -1203,8 +1213,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 } )
@@ -1215,7 +1225,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" )
@@ -1249,7 +1259,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
@@ -1277,7 +1287,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] ),
@@ -1285,7 +1295,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
@@ -1300,8 +1310,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 } )
@@ -1315,7 +1325,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" )
@@ -1352,7 +1362,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: " +
@@ -1421,8 +1431,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 )
@@ -1433,8 +1443,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 )
@@ -1453,8 +1463,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 )
@@ -1465,8 +1475,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 )
@@ -1477,8 +1487,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 )
@@ -1580,7 +1590,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\
@@ -1654,23 +1664,23 @@
The Failure case.
"""
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( "Restart minority of ONOS nodes" )
main.step( "Killing 3 ONOS nodes" )
killTime = time.time()
# TODO: Randomize these nodes or base this on partitions
# TODO: use threads in this case
- killResults = main.ONOSbench.onosKill( nodes[0].ip_address )
+ killResults = main.ONOSbench.onosKill( main.nodes[0].ip_address )
time.sleep( 10 )
killResults = killResults and\
- main.ONOSbench.onosKill( nodes[1].ip_address )
+ main.ONOSbench.onosKill( main.nodes[1].ip_address )
time.sleep( 10 )
killResults = killResults and\
- main.ONOSbench.onosKill( nodes[2].ip_address )
+ main.ONOSbench.onosKill( main.nodes[2].ip_address )
utilities.assert_equals( expect=main.TRUE, actual=killResults,
onpass="ONOS Killed successfully",
onfail="ONOS kill NOT successful" )
@@ -1679,9 +1689,9 @@
count = 0
onosIsupResult = main.FALSE
while onosIsupResult == main.FALSE and count < 10:
- onos1Isup = main.ONOSbench.isup( nodes[0].ip_address )
- onos2Isup = main.ONOSbench.isup( nodes[1].ip_address )
- onos3Isup = main.ONOSbench.isup( nodes[2].ip_address )
+ onos1Isup = main.ONOSbench.isup( main.nodes[0].ip_address )
+ onos2Isup = main.ONOSbench.isup( main.nodes[1].ip_address )
+ onos3Isup = main.ONOSbench.isup( main.nodes[2].ip_address )
onosIsupResult = onos1Isup and onos2Isup and onos3Isup
count = count + 1
# TODO: if it becomes an issue, we can retry this step a few times
@@ -1689,10 +1699,10 @@
onpass="ONOS restarted successfully",
onfail="ONOS restart NOT successful" )
- main.step( "Restarting ONOS CLIs" )
- cliResult1 = main.ONOScli1.startOnosCli( nodes[0].ip_address )
- cliResult2 = main.ONOScli2.startOnosCli( nodes[1].ip_address )
- cliResult3 = main.ONOScli3.startOnosCli( nodes[2].ip_address )
+ main.step( "Restarting ONOS main.CLIs" )
+ cliResult1 = main.ONOScli1.startOnosCli( main.nodes[0].ip_address )
+ cliResult2 = main.ONOScli2.startOnosCli( main.nodes[1].ip_address )
+ cliResult3 = main.ONOScli3.startOnosCli( main.nodes[2].ip_address )
cliResults = cliResult1 and cliResult2 and cliResult3
utilities.assert_equals( expect=main.TRUE, actual=cliResults,
onpass="ONOS cli restarted",
@@ -1705,9 +1715,9 @@
'''
# FIXME: revisit test plan for election with madan
# Rerun for election on restarted nodes
- run1 = CLIs[0].electionTestRun()
- run2 = CLIs[1].electionTestRun()
- run3 = CLIs[2].electionTestRun()
+ run1 = main.CLIs[0].electionTestRun()
+ run2 = main.CLIs[1].electionTestRun()
+ run3 = main.CLIs[2].electionTestRun()
runResults = run1 and run2 and run3
utilities.assert_equals( expect=main.TRUE, actual=runResults,
onpass="Reran for election",
@@ -1715,28 +1725,28 @@
'''
# TODO: MAke this configurable. Also, we are breaking the above timer
time.sleep( 60 )
- main.log.debug( CLIs[0].nodes( jsonFormat=False ) )
- main.log.debug( CLIs[0].leaders( jsonFormat=False ) )
- main.log.debug( CLIs[0].partitions( jsonFormat=False ) )
+ main.log.debug( main.CLIs[0].nodes( jsonFormat=False ) )
+ main.log.debug( main.CLIs[0].leaders( jsonFormat=False ) )
+ main.log.debug( main.CLIs[0].partitions( jsonFormat=False ) )
def CASE7( self, main ):
"""
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 )
@@ -1756,8 +1766,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 )
@@ -1767,7 +1777,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" )
@@ -1794,7 +1804,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(
@@ -1843,8 +1853,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 } )
@@ -1855,7 +1865,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" )
@@ -1882,7 +1892,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
@@ -1922,7 +1932,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 ] ),
@@ -2033,11 +2043,11 @@
# Test of LeadershipElection
leaderList = []
# FIXME: make sure this matches nodes that were restarted
- restarted = [ nodes[0].ip_address, nodes[1].ip_address,
- nodes[2].ip_address ]
+ restarted = [ main.nodes[0].ip_address, main.nodes[1].ip_address,
+ main.nodes[2].ip_address ]
leaderResult = main.TRUE
- for cli in CLIs:
+ for cli in main.CLIs:
leaderN = cli.electionTestLeader()
leaderList.append( leaderN )
if leaderN == main.FALSE:
@@ -2073,11 +2083,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" +\
@@ -2099,8 +2109,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 )
@@ -2112,8 +2122,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 )
@@ -2136,8 +2146,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 )
@@ -2148,8 +2158,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 )
@@ -2160,8 +2170,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 )
@@ -2179,7 +2189,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\
@@ -2432,8 +2442,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 )
@@ -2442,7 +2452,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 )
@@ -2472,11 +2482,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' ] )
@@ -2500,11 +2510,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' ] )
@@ -2529,11 +2539,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' ] )
@@ -2565,11 +2575,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"
@@ -2590,8 +2600,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" )
@@ -2612,11 +2622,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',
@@ -2642,7 +2652,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 + "@" +
@@ -2658,7 +2668,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 + "@" +
@@ -2678,7 +2688,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, restart=True )
@@ -2697,11 +2707,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" )
@@ -2715,9 +2725,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 " +
@@ -2735,7 +2745,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,
@@ -2748,11 +2758,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"
@@ -2761,12 +2771,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,
@@ -2784,9 +2794,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" )
@@ -2801,7 +2811,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:
@@ -2873,11 +2883,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
@@ -2897,7 +2907,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",
@@ -2908,13 +2918,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"
@@ -2942,15 +2951,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 )
@@ -2974,12 +2985,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 } )
@@ -3001,15 +3150,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()
@@ -3031,59 +3318,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 )
@@ -3093,7 +3342,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 ] ):
@@ -3123,8 +3372,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 )
@@ -3134,7 +3383,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 ) +
@@ -3150,8 +3399,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 )
@@ -3164,7 +3413,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
@@ -3184,8 +3433,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 )
@@ -3194,7 +3443,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 ] ):
@@ -3218,8 +3467,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 )
@@ -3228,7 +3477,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 ) +
@@ -3245,8 +3494,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 )
@@ -3259,7 +3508,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
@@ -3279,8 +3528,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 )
@@ -3289,7 +3538,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 ] ):
@@ -3313,8 +3562,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 )
@@ -3323,7 +3572,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 ) +
@@ -3339,8 +3588,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 } )
@@ -3352,7 +3601,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:
@@ -3366,8 +3615,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 } )
@@ -3379,7 +3628,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:
@@ -3394,8 +3643,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 )
@@ -3408,7 +3657,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
@@ -3428,8 +3677,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 )
@@ -3438,7 +3687,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 ] ):
@@ -3462,8 +3711,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 )
@@ -3472,7 +3721,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 ) +
@@ -3490,8 +3739,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 )
@@ -3506,7 +3755,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
@@ -3526,8 +3775,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 )
@@ -3536,7 +3785,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 ] ):
@@ -3560,8 +3809,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 )
@@ -3570,7 +3819,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 ) +
@@ -3587,8 +3836,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 )
@@ -3601,7 +3850,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
@@ -3621,8 +3870,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 )
@@ -3631,7 +3880,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 ] ):
@@ -3655,8 +3904,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 )
@@ -3665,7 +3914,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 ) +
@@ -3682,8 +3931,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 } )
@@ -3697,7 +3946,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
@@ -3717,8 +3966,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 )
@@ -3727,7 +3976,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 ] ):
@@ -3751,8 +4000,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 )
@@ -3761,7 +4010,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 ) +
@@ -3778,8 +4027,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 )
@@ -3792,7 +4041,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
@@ -3812,8 +4061,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 )
@@ -3822,7 +4071,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 ] ):
@@ -3846,8 +4095,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 )
@@ -3856,7 +4105,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 ) +
@@ -3873,8 +4122,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 } )
@@ -3888,7 +4137,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
@@ -3908,8 +4157,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 )
@@ -3918,7 +4167,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 ] ):
@@ -3942,8 +4191,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 )
@@ -3952,7 +4201,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/HAminorityRestart/dependencies/Counters.py b/TestON/tests/HAminorityRestart/dependencies/Counters.py
new file mode 100644
index 0000000..7abd73a
--- /dev/null
+++ b/TestON/tests/HAminorityRestart/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/HAminorityRestart/dependencies/__init__.py b/TestON/tests/HAminorityRestart/dependencies/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/HAminorityRestart/dependencies/__init__.py
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
diff --git a/TestON/tests/HAsingleInstanceRestart/HAsingleInstanceRestart.params b/TestON/tests/HAsingleInstanceRestart/HAsingleInstanceRestart.params
index c43bea1..b0b644e 100644
--- a/TestON/tests/HAsingleInstanceRestart/HAsingleInstanceRestart.params
+++ b/TestON/tests/HAsingleInstanceRestart/HAsingleInstanceRestart.params
@@ -15,6 +15,9 @@
#CASE14: start election app on all onos nodes
#CASE15: Check that Leadership Election is still functional
<testcases>1,2,8,3,4,5,14,15,16,17,[6],8,3,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/HAsingleInstanceRestart/dependencies/ </path>
+ </imports>
<ENV>
<cellName>HA</cellName>
<appString>drivers,openflow,proxyarp,mobility</appString>
diff --git a/TestON/tests/HAsingleInstanceRestart/HAsingleInstanceRestart.py b/TestON/tests/HAsingleInstanceRestart/HAsingleInstanceRestart.py
index 8646c33..1fa2e33 100644
--- a/TestON/tests/HAsingleInstanceRestart/HAsingleInstanceRestart.py
+++ b/TestON/tests/HAsingleInstanceRestart/HAsingleInstanceRestart.py
@@ -47,6 +47,7 @@
start cli sessions
start tcpdump
"""
+ import imp
main.log.info( "ONOS Single node cluster restart " +
"HA test - initialization" )
main.case( "Setting up test environment" )
@@ -62,23 +63,29 @@
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 )
- 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, int( main.ONOSbench.maxNodes ) + 1 ):
try:
- CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
- nodes.append( getattr( main, 'ONOS' + str( i ) ) )
- ipList.append( nodes[ -1 ].ip_address )
+ 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
@@ -96,13 +103,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
@@ -161,13 +168,13 @@
graphs += '</ac:structured-macro>\n'
main.log.wiki(graphs)
- CLIs = []
- nodes = []
+ 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 ):
+ main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
+ main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
+ ipList.append( main.nodes[ -1 ].ip_address )
main.ONOSbench.createCellFile( main.ONOSbench.ip_address, "SingleHA",
main.Mininet1.ip_address,
@@ -182,14 +189,14 @@
main.step( "Installing ONOS package" )
onosInstallResult = main.ONOSbench.onosInstall(
- options="-f", node=nodes[0].ip_address )
+ options="-f", node=main.nodes[0].ip_address )
utilities.assert_equals( expect=main.TRUE, actual=onosInstallResult,
onpass="ONOS install successful",
onfail="ONOS install failed" )
main.step( "Checking if ONOS is up yet" )
for i in range( 2 ):
- onos1Isup = main.ONOSbench.isup( nodes[0].ip_address )
+ onos1Isup = main.ONOSbench.isup( main.nodes[0].ip_address )
if onos1Isup:
break
utilities.assert_equals( expect=main.TRUE, actual=onos1Isup,
@@ -197,7 +204,7 @@
onfail="ONOS startup failed" )
main.log.step( "Starting ONOS CLI sessions" )
- cliResults = main.ONOScli1.startOnosCli( nodes[0].ip_address )
+ cliResults = main.ONOScli1.startOnosCli( main.nodes[0].ip_address )
utilities.assert_equals( expect=main.TRUE, actual=cliResults,
onpass="ONOS cli startup successful",
onfail="ONOS cli startup failed" )
@@ -213,8 +220,8 @@
main.step( "App Ids check" )
appCheck = main.ONOScli1.appToIDCheck()
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" )
@@ -229,8 +236,7 @@
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"
@@ -241,8 +247,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 ) )
@@ -255,7 +261,7 @@
main.log.info( str( response ) )
except Exception:
main.log.info( repr( response ) )
- if re.search( "tcp:" + nodes[0].ip_address, response ):
+ if re.search( "tcp:" + main.nodes[0].ip_address, response ):
mastershipCheck = mastershipCheck and main.TRUE
else:
mastershipCheck = main.FALSE
@@ -271,13 +277,11 @@
"""
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"
main.case( "Assigning Controller roles for switches" )
main.caseExplanation = "Check that ONOS is connected to each " +\
@@ -289,7 +293,7 @@
roleCheck = main.TRUE
try:
for i in range( 1, 29 ): # switches 1 through 28
- ip = nodes[ 0 ].ip_address # ONOS1
+ ip = main.nodes[ 0 ].ip_address # ONOS1
# set up correct variables:
if i == 1:
deviceId = main.ONOScli1.getDevice( "1000" ).get( 'id' )
@@ -354,7 +358,7 @@
"""
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"
# NOTE: we must reinstall intents until we have a persistant intent
@@ -368,7 +372,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" )
@@ -376,8 +380,8 @@
main.step( "Check app ids" )
appCheck = main.ONOScli1.appToIDCheck()
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" )
@@ -403,7 +407,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" )
@@ -411,8 +415,8 @@
main.step( "Check app ids" )
appCheck2 = main.ONOScli1.appToIDCheck()
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" )
@@ -573,7 +577,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 )
@@ -713,7 +717,7 @@
"""
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"
main.case( "Verify connectivity by sendind traffic across Intents" )
@@ -934,7 +938,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
@@ -972,7 +976,7 @@
Reading state of ONOS
"""
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"
@@ -1091,7 +1095,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\
@@ -1165,7 +1169,7 @@
The Failure case.
"""
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"
@@ -1180,7 +1184,7 @@
main.caseExplanation = "Killing ONOS process and restart cli " +\
"sessions once onos is up."
main.step( "Killing ONOS processes" )
- killResult = main.ONOSbench.onosKill( nodes[0].ip_address )
+ killResult = main.ONOSbench.onosKill( main.nodes[0].ip_address )
start = time.time()
utilities.assert_equals( expect=main.TRUE, actual=killResult,
onpass="ONOS Killed",
@@ -1189,7 +1193,7 @@
main.step( "Checking if ONOS is up yet" )
count = 0
while count < 10:
- onos1Isup = main.ONOSbench.isup( nodes[0].ip_address )
+ onos1Isup = main.ONOSbench.isup( main.nodes[0].ip_address )
if onos1Isup == main.TRUE:
elapsed = time.time() - start
break
@@ -1200,7 +1204,7 @@
onfail="ONOS failed to start" )
main.log.step( "Starting ONOS CLI sessions" )
- cliResults = main.ONOScli1.startOnosCli( nodes[0].ip_address )
+ cliResults = main.ONOScli1.startOnosCli( main.nodes[0].ip_address )
utilities.assert_equals( expect=main.TRUE, actual=cliResults,
onpass="ONOS cli startup successful",
onfail="ONOS cli startup failed" )
@@ -1220,7 +1224,7 @@
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"
main.case( "Running ONOS Constant State Tests" )
@@ -1373,9 +1377,9 @@
main.step( "Leadership Election is still functional" )
# Test of LeadershipElection
- leader = nodes[0].ip_address
+ leader = main.nodes[0].ip_address
leaderResult = main.TRUE
- for controller in range( 1, numControllers + 1 ):
+ for controller in range( 1, main.numCtrls + 1 ):
# loop through ONOScli handlers
node = getattr( main, ( 'ONOScli' + str( controller ) ) )
leaderN = node.electionTestLeader()
@@ -1409,7 +1413,7 @@
"""
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"
@@ -1458,7 +1462,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\
@@ -1584,7 +1588,6 @@
if zeroHosts is False:
hostAttachment = True
-
devicesResults = devicesResults and currentDevicesResult
linksResults = linksResults and currentLinksResult
hostsResults = hostsResults and currentHostsResult
@@ -1624,7 +1627,7 @@
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"
# NOTE: You should probably run a topology check after this
@@ -1650,7 +1653,7 @@
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"
# NOTE: You should probably run a topology check after this
@@ -1677,7 +1680,7 @@
"""
# 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"
@@ -1711,7 +1714,7 @@
"""
# 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"
@@ -1727,8 +1730,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" )
@@ -1749,7 +1752,7 @@
"""
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"
# printing colors to terminal
@@ -1776,7 +1779,7 @@
# NOTE: must end in /
dstDir = "~/packet_captures/"
for f in logFiles:
- main.ONOSbench.handle.sendline( "scp sdn@" + nodes[0].ip_address + ":" +
+ main.ONOSbench.handle.sendline( "scp sdn@" + main.nodes[0].ip_address + ":" +
logFolder + f + " " +
teststationUser + "@" +
teststationIP + ":" + dstDir +
@@ -1790,7 +1793,7 @@
# NOTE: must end in /
dstDir = "~/packet_captures/"
for f in logFiles:
- main.ONOSbench.handle.sendline( "scp sdn@" + nodes[0].ip_address + ":" +
+ main.ONOSbench.handle.sendline( "scp sdn@" + main.nodes[0].ip_address + ":" +
logFolder + f + " " +
teststationUser + "@" +
teststationIP + ":" + dstDir +
@@ -1810,7 +1813,7 @@
main.step( "Checking ONOS Logs for errors" )
print colors[ 'purple' ] + "Checking logs for errors on ONOS1:" + \
colors[ 'end' ]
- print main.ONOSbench.checkLogs( nodes[0].ip_address, restart=True )
+ print main.ONOSbench.checkLogs( main.nodes[0].ip_address, restart=True )
try:
timerLog = open( main.logdir + "/Timers.csv", 'w')
@@ -1826,7 +1829,7 @@
"""
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"
@@ -1844,7 +1847,7 @@
# check for leader
leader = main.ONOScli1.electionTestLeader()
# verify leader is ONOS1
- if leader == nodes[0].ip_address:
+ if leader == main.nodes[0].ip_address:
# all is well
pass
elif leader is None:
@@ -1875,7 +1878,7 @@
"""
Check that Leadership Election is still functional
"""
- 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"
leaderResult = main.TRUE
@@ -1885,7 +1888,7 @@
leader = main.ONOScli1.electionTestLeader()
# do some sanity checking on leader before using it
withdrawResult = main.FALSE
- if leader == nodes[0].ip_address:
+ if leader == main.nodes[0].ip_address:
oldLeader = getattr( main, "ONOScli1" )
elif leader is None or leader == main.FALSE:
main.log.error(
@@ -1943,7 +1946,7 @@
main.step( "Node became leader when it ran for election" )
afterRun = main.ONOScli1.electionTestLeader()
# verify leader is ONOS1
- if afterRun == nodes[0].ip_address:
+ if afterRun == main.nodes[0].ip_address:
afterResult = main.TRUE
else:
afterResult = main.FALSE
@@ -1959,11 +1962,11 @@
"""
Install Distributed Primitives app
"""
- 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
@@ -1983,7 +1986,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",
@@ -1993,13 +1996,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"
@@ -2027,15 +2029,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 )
@@ -2059,12 +2063,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 } )
@@ -2086,15 +2228,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()
@@ -2116,59 +2396,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 )
@@ -2178,7 +2420,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 ] ):
@@ -2208,8 +2450,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 )
@@ -2219,7 +2461,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 ) +
@@ -2235,8 +2477,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 )
@@ -2249,7 +2491,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
@@ -2269,8 +2511,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 )
@@ -2279,7 +2521,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 ] ):
@@ -2303,8 +2545,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 )
@@ -2313,7 +2555,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 ) +
@@ -2330,8 +2572,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 )
@@ -2344,7 +2586,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
@@ -2364,8 +2606,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 )
@@ -2374,7 +2616,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 ] ):
@@ -2398,8 +2640,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 )
@@ -2408,7 +2650,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 ) +
@@ -2424,8 +2666,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 } )
@@ -2437,7 +2679,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:
@@ -2451,8 +2693,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 } )
@@ -2464,7 +2706,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:
@@ -2479,8 +2721,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 )
@@ -2493,7 +2735,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
@@ -2513,8 +2755,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 )
@@ -2523,7 +2765,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 ] ):
@@ -2547,8 +2789,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 )
@@ -2557,7 +2799,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 ) +
@@ -2575,8 +2817,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 )
@@ -2591,7 +2833,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
@@ -2611,8 +2853,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 )
@@ -2621,7 +2863,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 ] ):
@@ -2645,8 +2887,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 )
@@ -2655,7 +2897,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 ) +
@@ -2672,8 +2914,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 )
@@ -2686,7 +2928,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
@@ -2706,8 +2948,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 )
@@ -2716,7 +2958,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 ] ):
@@ -2740,8 +2982,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 )
@@ -2750,7 +2992,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 ) +
@@ -2767,8 +3009,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 } )
@@ -2782,7 +3024,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
@@ -2802,8 +3044,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 )
@@ -2812,7 +3054,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 ] ):
@@ -2836,8 +3078,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 )
@@ -2846,7 +3088,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 ) +
@@ -2863,8 +3105,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 )
@@ -2877,7 +3119,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
@@ -2897,8 +3139,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 )
@@ -2907,7 +3149,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 ] ):
@@ -2931,8 +3173,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 )
@@ -2941,7 +3183,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 ) +
@@ -2958,8 +3200,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 } )
@@ -2973,7 +3215,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
@@ -2993,8 +3235,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 )
@@ -3003,7 +3245,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 ] ):
@@ -3027,8 +3269,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 )
@@ -3037,7 +3279,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/HAsingleInstanceRestart/dependencies/Counters.py b/TestON/tests/HAsingleInstanceRestart/dependencies/Counters.py
new file mode 100644
index 0000000..7abd73a
--- /dev/null
+++ b/TestON/tests/HAsingleInstanceRestart/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/HAsingleInstanceRestart/dependencies/__init__.py b/TestON/tests/HAsingleInstanceRestart/dependencies/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/HAsingleInstanceRestart/dependencies/__init__.py