Merge "Add tests for atomic value to HA suite"
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 4052db2..93152ea 100755
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -480,7 +480,9 @@
main.cleanup()
main.exit()
if i == 2:
- self.handle.sendline( "" )
+ main.log.warn( "Timeout when testing cli responsiveness" )
+ main.log.debug( self.handle.before )
+ self.handle.send( "\x03" ) # Send ctrl-c to clear previous output
self.handle.expect( "onos>" )
if debug:
@@ -2666,6 +2668,8 @@
try:
# Obtain output of intents function
intentsStr = self.intents(jsonFormat=True)
+ if intentsStr is None:
+ raise TypeError
# Convert to a dictionary
intents = json.loads( intentsStr )
intentIdList = []
@@ -3960,6 +3964,57 @@
main.cleanup()
main.exit()
+ def distPrimitivesSend( self, cmd ):
+ """
+ Function to handle sending cli commands for the distributed primitives test app
+
+ This command will catch some exceptions and retry the command on some
+ specific store exceptions.
+
+ Required arguments:
+ cmd - The command to send to the cli
+ returns:
+ string containing the cli output
+ None on Error
+ """
+ try:
+ output = self.sendline( cmd )
+ try:
+ assert output is not None, "Error in sendline"
+ # 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 '" + cmd + "' " +
+ "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( cmd )
+ assert output is not None, "Error in sendline"
+ assert "Command not found:" not in output, output
+ assert "Error executing command" not in output, output
+ main.log.info( self.name + ": " + output )
+ return output
+ except AssertionError:
+ main.log.exception( "Error in processing '" + cmd + "' command." )
+ 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 setTestAdd( self, setName, values ):
"""
CLI command to add elements to a distributed set.
@@ -3976,28 +4031,9 @@
"""
try:
cmdStr = "set-test-add " + str( setName ) + " " + str( values )
- output = self.sendline( cmdStr )
- assert output is not None, "Error in sendline"
- assert "Command not found:" not in output, output
- 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 output is not None, "Error in sendline"
- assert "Error executing command" not in output
+ output = self.distPrimitivesSend( cmdStr )
positiveMatch = "\[(.*)\] was added to the set " + str( setName )
negativeMatch = "\[(.*)\] was already in set " + str( setName )
- main.log.info( self.name + ": " + output )
if re.search( positiveMatch, output):
return main.TRUE
elif re.search( negativeMatch, output):
@@ -4007,17 +4043,9 @@
" match expected output" )
main.log.debug( self.name + " actual: " + repr( output ) )
return main.ERROR
- except AssertionError:
- main.log.exception( "Error in processing '" + cmdStr + "' command. " )
- return main.ERROR
except TypeError:
main.log.exception( self.name + ": Object not as expected" )
return main.ERROR
- 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()
@@ -4046,26 +4074,7 @@
cmdStr += "-r " + str( setName ) + " " + str( values )
else:
cmdStr += str( setName ) + " " + str( values )
- output = self.sendline( cmdStr )
- try:
- assert output is not None, "Error in sendline"
- # 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 output is not None, "Error in sendline"
- assert "Command not found:" not in output, output
- assert "Error executing command" not in output, output
- main.log.info( self.name + ": " + output )
+ output = self.distPrimitivesSend( cmdStr )
if clear:
pattern = "Set " + str( setName ) + " cleared"
if re.search( pattern, output ):
@@ -4098,17 +4107,9 @@
main.log.debug( self.name + " expected: " + pattern )
main.log.debug( self.name + " actual: " + repr( output ) )
return main.ERROR
- except AssertionError:
- main.log.exception( "Error in processing '" + cmdStr + "' commandr. " )
- return main.ERROR
except TypeError:
main.log.exception( self.name + ": Object not as expected" )
return main.ERROR
- 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()
@@ -4147,27 +4148,7 @@
cmdStr = "set-test-get "
cmdStr += setName + " " + values
- output = self.sendline( cmdStr )
- try:
- assert output is not None, "Error in sendline"
- # 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 output is not None, "Error in sendline"
- assert "Command not found:" not in output, output
- assert "Error executing command" not in output, output
- main.log.info( self.name + ": " + output )
-
+ output = self.distPrimitivesSend( cmdStr )
if length == 0:
match = re.search( pattern, output )
else: # if given values
@@ -4207,17 +4188,9 @@
main.log.debug( self.name + " expected: " + pattern )
main.log.debug( self.name + " actual: " + repr( output ) )
return main.ERROR
- except AssertionError:
- main.log.exception( "Error in processing '" + cmdStr + "' command." )
- return main.ERROR
except TypeError:
main.log.exception( self.name + ": Object not as expected" )
return main.ERROR
- 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()
@@ -4242,26 +4215,7 @@
setPattern
cmdStr = "set-test-get -s "
cmdStr += setName
- output = self.sendline( cmdStr )
- try:
- assert output is not None, "Error in sendline"
- # 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 output is not None, "Error in sendline"
- assert "Command not found:" not in output, output
- assert "Error executing command" not in output, output
- main.log.info( self.name + ": " + output )
+ output = self.distPrimitivesSend( cmdStr )
match = re.search( pattern, output )
if match:
setSize = int( match.group( 1 ) )
@@ -4281,17 +4235,9 @@
main.log.debug( self.name + " expected: " + pattern )
main.log.debug( self.name + " actual: " + repr( output ) )
return None
- except AssertionError:
- main.log.exception( "Error in processing '" + cmdStr + "' command." )
- 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()
@@ -4351,26 +4297,7 @@
cmdStr += counter
if delta != 1:
cmdStr += " " + str( delta )
- output = self.sendline( cmdStr )
- try:
- assert output is not None, "Error in sendline"
- # 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 output is not None, "Error in sendline"
- assert "Command not found:" not in output, output
- assert "Error executing command" not in output, output
- main.log.info( self.name + ": " + output )
+ output = self.distPrimitivesSend( cmdStr )
pattern = counter + " was updated to (-?\d+)"
match = re.search( pattern, output )
if match:
@@ -4381,17 +4308,9 @@
main.log.debug( self.name + " expected: " + pattern )
main.log.debug( self.name + " actual: " + repr( output ) )
return None
- except AssertionError:
- main.log.exception( "Error in processing '" + cmdStr + "' command." )
- 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()
@@ -4415,26 +4334,7 @@
cmdStr += counter
if delta != 1:
cmdStr += " " + str( delta )
- output = self.sendline( cmdStr )
- try:
- assert output is not None, "Error in sendline"
- # 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 output is not None, "Error in sendline"
- assert "Command not found:" not in output, output
- assert "Error executing command" not in output, output
- main.log.info( self.name + ": " + output )
+ output = self.distPrimitivesSend( cmdStr )
pattern = counter + " was updated to (-?\d+)"
match = re.search( pattern, output )
if match:
@@ -4445,17 +4345,181 @@
main.log.debug( self.name + " expected: " + pattern )
main.log.debug( self.name + " actual: " + repr( output ) )
return None
- except AssertionError:
- main.log.exception( "Error in processing '" + cmdStr + "' command." )
- 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 )
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
main.exit()
+
+ def valueTestGet( self, valueName ):
+ """
+ CLI command to get the value of an atomic value.
+ Required arguments:
+ valueName - The name of the value to get.
+ returns:
+ string value of the value or
+ None on Error
+ """
+ try:
+ valueName = str( valueName )
+ cmdStr = "value-test "
+ operation = "get"
+ cmdStr = "value-test {} {}".format( valueName,
+ operation )
+ output = self.distPrimitivesSend( cmdStr )
+ pattern = "(\w+)"
+ match = re.search( pattern, output )
+ if match:
+ return match.group( 1 )
+ else:
+ main.log.error( self.name + ": valueTestGet did not" +
+ " match expected output." )
+ main.log.debug( self.name + " expected: " + pattern )
+ main.log.debug( self.name + " actual: " + repr( output ) )
+ return None
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ return None
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def valueTestSet( self, valueName, newValue ):
+ """
+ CLI command to set the value of an atomic value.
+ Required arguments:
+ valueName - The name of the value to set.
+ newValue - The value to assign to the given value.
+ returns:
+ main.TRUE on success or
+ main.ERROR on Error
+ """
+ try:
+ valueName = str( valueName )
+ newValue = str( newValue )
+ operation = "set"
+ cmdStr = "value-test {} {} {}".format( valueName,
+ operation,
+ newValue )
+ output = self.distPrimitivesSend( cmdStr )
+ if output is not None:
+ return main.TRUE
+ else:
+ return main.ERROR
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ return main.ERROR
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def valueTestCompareAndSet( self, valueName, oldValue, newValue ):
+ """
+ CLI command to compareAndSet the value of an atomic value.
+ Required arguments:
+ valueName - The name of the value.
+ oldValue - Compare the current value of the atomic value to this
+ newValue - If the value equals oldValue, set the value to newValue
+ returns:
+ main.TRUE on success or
+ main.FALSE on failure or
+ main.ERROR on Error
+ """
+ try:
+ valueName = str( valueName )
+ oldValue = str( oldValue )
+ newValue = str( newValue )
+ operation = "compareAndSet"
+ cmdStr = "value-test {} {} {} {}".format( valueName,
+ operation,
+ oldValue,
+ newValue )
+ output = self.distPrimitivesSend( cmdStr )
+ pattern = "(\w+)"
+ match = re.search( pattern, output )
+ if match:
+ result = match.group( 1 )
+ if result == "true":
+ return main.TRUE
+ elif result == "false":
+ return main.FALSE
+ else:
+ main.log.error( self.name + ": valueTestCompareAndSet did not" +
+ " match expected output." )
+ main.log.debug( self.name + " expected: " + pattern )
+ main.log.debug( self.name + " actual: " + repr( output ) )
+ return main.ERROR
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ return main.ERROR
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def valueTestGetAndSet( self, valueName, newValue ):
+ """
+ CLI command to getAndSet the value of an atomic value.
+ Required arguments:
+ valueName - The name of the value to get.
+ newValue - The value to assign to the given value
+ returns:
+ string value of the value or
+ None on Error
+ """
+ try:
+ valueName = str( valueName )
+ cmdStr = "value-test "
+ operation = "getAndSet"
+ cmdStr += valueName + " " + operation
+ cmdStr = "value-test {} {} {}".format( valueName,
+ operation,
+ newValue )
+ output = self.distPrimitivesSend( cmdStr )
+ pattern = "(\w+)"
+ match = re.search( pattern, output )
+ if match:
+ return match.group( 1 )
+ else:
+ main.log.error( self.name + ": valueTestGetAndSet did not" +
+ " match expected output." )
+ main.log.debug( self.name + " expected: " + pattern )
+ main.log.debug( self.name + " actual: " + repr( output ) )
+ return None
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ return None
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanup()
+ main.exit()
+
+ def valueTestDestroy( self, valueName ):
+ """
+ CLI command to destroy an atomic value.
+ Required arguments:
+ valueName - The name of the value to destroy.
+ returns:
+ main.TRUE on success or
+ main.ERROR on Error
+ """
+ try:
+ valueName = str( valueName )
+ cmdStr = "value-test "
+ operation = "destroy"
+ cmdStr += valueName + " " + operation
+ output = self.distPrimitivesSend( cmdStr )
+ if output is not None:
+ return main.TRUE
+ else:
+ return main.ERROR
+ except TypeError:
+ main.log.exception( self.name + ": Object not as expected" )
+ return main.ERROR
except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanup()
@@ -4512,19 +4576,7 @@
keyName = str( keyName )
cmdStr = "transactional-map-test-get "
cmdStr += keyName
- output = self.sendline( cmdStr )
- assert output is not None, "Error in sendline"
- assert "Command not found:" not in output, output
- 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 ) )
- return None
+ output = self.distPrimitivesSend( cmdStr )
pattern = "Key-value pair \(" + keyName + ", (?P<value>.+)\) found."
if "Key " + keyName + " not found." in output:
main.log.warn( output )
@@ -4539,17 +4591,9 @@
main.log.debug( self.name + " expected: " + pattern )
main.log.debug( self.name + " actual: " + repr( output ) )
return None
- except AssertionError:
- main.log.exception( "" )
- 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()
@@ -4579,19 +4623,7 @@
value = str( value )
cmdStr = "transactional-map-test-put "
cmdStr += numKeys + " " + value
- output = self.sendline( cmdStr )
- assert output is not None, "Error in sendline"
- assert "Command not found:" not in output, output
- 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 ) )
- return None
+ output = self.distPrimitivesSend( cmdStr )
newPattern = 'Created Key (?P<key>(\w)+) with value (?P<value>(.)+)\.'
updatedPattern = "Put (?P<value>(.)+) into key (?P<key>(\w)+)\. The old value was (?P<oldValue>(.)+)\."
results = {}
@@ -4611,17 +4643,9 @@
updatedPattern ) )
main.log.debug( self.name + " actual: " + repr( output ) )
return results
- except AssertionError:
- main.log.exception( "" )
- 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()
diff --git a/TestON/tests/HA/HAclusterRestart/HAclusterRestart.py b/TestON/tests/HA/HAclusterRestart/HAclusterRestart.py
index 1112aa8..134ac76 100644
--- a/TestON/tests/HA/HAclusterRestart/HAclusterRestart.py
+++ b/TestON/tests/HA/HAclusterRestart/HAclusterRestart.py
@@ -3053,7 +3053,7 @@
# verify leader didn't just change
# Get new leaders and candidates
reRunLeaders = []
- time.sleep( 5 ) # Paremterize
+ time.sleep( 5 ) # Paremterize
positionResult, reRunLeaders = main.HA.consistentLeaderboards( activeCLIs )
# Check that the re-elected node is last on the candidate List
@@ -3082,14 +3082,10 @@
assert main.nodes, "main.nodes not defined"
# Variables for the distributed primitives tests
- global pCounterName
- global pCounterValue
- global onosSet
- global onosSetName
- pCounterName = "TestON-Partitions"
- pCounterValue = 0
- onosSet = set([])
- onosSetName = "TestON-set"
+ main.pCounterName = "TestON-Partitions"
+ main.pCounterValue = 0
+ main.onosSet = set([])
+ main.onosSetName = "TestON-set"
description = "Install Primitives app"
main.case( description )
@@ -3107,1153 +3103,4 @@
"""
Check for basic functionality with distributed primitives
"""
- # Make sure variables are defined/set
- assert main.numCtrls, "main.numCtrls not defined"
- assert main, "main not defined"
- assert utilities.assert_equals, "utilities.assert_equals not defined"
- assert main.CLIs, "main.CLIs not defined"
- assert main.nodes, "main.nodes not defined"
- assert pCounterName, "pCounterName not defined"
- assert onosSetName, "onosSetName not defined"
- # NOTE: assert fails if value is 0/None/Empty/False
- try:
- pCounterValue
- except NameError:
- main.log.error( "pCounterValue not defined, setting to 0" )
- pCounterValue = 0
- try:
- onosSet
- except NameError:
- main.log.error( "onosSet not defined, setting to empty Set" )
- onosSet = set([])
- # Variables for the distributed primitives tests. These are local only
- addValue = "a"
- addAllValue = "a b c d e f"
- retainValue = "c d e f"
-
- 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"
- # DISTRIBUTED ATOMIC COUNTERS
- # Partitioned counters
- main.step( "Increment then get a default counter on each node" )
- pCounters = []
- threads = []
- addedPValues = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].counterTestAddAndGet,
- name="counterAddAndGet-" + str( i ),
- args=[ pCounterName ] )
- pCounterValue += 1
- 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 Increment a default counter on each node" )
- pCounters = []
- threads = []
- addedPValues = []
- for i in main.activeNodes:
- 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.HA.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 main.activeNodes:
- 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 main.activeNodes:
- 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 main.activeNodes:
- 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.HA.counterCheck( pCounterName, pCounterValue )
- utilities.assert_equals( expect=main.TRUE,
- 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 main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
-
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- utilities.assert_equals( expect=main.TRUE,
- actual=getResults,
- onpass="Set elements are correct",
- onfail="Set elements are incorrect" )
-
- main.step( "Distributed Set size" )
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
-
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- utilities.assert_equals( expect=main.TRUE,
- actual=sizeResults,
- onpass="Set sizes are correct",
- onfail="Set sizes are incorrect" )
-
- main.step( "Distributed Set add()" )
- onosSet.add( addValue )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAdd-" + str( i ),
- args=[ onosSetName, addValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addResults = main.FALSE
- else:
- # unexpected result
- addResults = main.FALSE
- if addResults != main.TRUE:
- main.log.error( "Error executing set add" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node + " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node + " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addResults = addResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addResults,
- onpass="Set add correct",
- onfail="Set add was incorrect" )
-
- main.step( "Distributed Set addAll()" )
- onosSet.update( addAllValue.split() )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAddAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addAllResults = main.FALSE
- else:
- # unexpected result
- addAllResults = main.FALSE
- if addAllResults != main.TRUE:
- main.log.error( "Error executing set addAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addAllResults = addAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addAllResults,
- onpass="Set addAll correct",
- onfail="Set addAll was incorrect" )
-
- main.step( "Distributed Set contains()" )
- containsResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setContains-" + str( i ),
- args=[ onosSetName ],
- kwargs={ "values": addValue } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- # NOTE: This is the tuple
- containsResponses.append( t.result )
-
- containsResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if containsResponses[ i ] == main.ERROR:
- containsResults = main.FALSE
- else:
- containsResults = containsResults and\
- containsResponses[ i ][ 1 ]
- utilities.assert_equals( expect=main.TRUE,
- actual=containsResults,
- onpass="Set contains is functional",
- onfail="Set contains failed" )
-
- main.step( "Distributed Set containsAll()" )
- containsAllResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setContainsAll-" + str( i ),
- args=[ onosSetName ],
- kwargs={ "values": addAllValue } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- # NOTE: This is the tuple
- containsAllResponses.append( t.result )
-
- containsAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if containsResponses[ i ] == main.ERROR:
- containsResults = main.FALSE
- else:
- containsResults = containsResults and\
- containsResponses[ i ][ 1 ]
- utilities.assert_equals( expect=main.TRUE,
- actual=containsAllResults,
- onpass="Set containsAll is functional",
- onfail="Set containsAll failed" )
-
- main.step( "Distributed Set remove()" )
- onosSet.remove( addValue )
- removeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestRemove-" + str( i ),
- args=[ onosSetName, addValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- removeResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- removeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if removeResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif removeResponses[ i ] == main.FALSE:
- # not in set, probably fine
- pass
- elif removeResponses[ i ] == main.ERROR:
- # Error in execution
- removeResults = main.FALSE
- else:
- # unexpected result
- removeResults = main.FALSE
- if removeResults != main.TRUE:
- main.log.error( "Error executing set remove" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- removeResults = removeResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=removeResults,
- onpass="Set remove correct",
- onfail="Set remove was incorrect" )
-
- main.step( "Distributed Set removeAll()" )
- onosSet.difference_update( addAllValue.split() )
- removeAllResponses = []
- threads = []
- try:
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestRemoveAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- removeAllResponses.append( t.result )
- except Exception, e:
- main.log.exception(e)
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- removeAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if removeAllResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif removeAllResponses[ i ] == main.FALSE:
- # not in set, probably fine
- pass
- elif removeAllResponses[ i ] == main.ERROR:
- # Error in execution
- removeAllResults = main.FALSE
- else:
- # unexpected result
- removeAllResults = main.FALSE
- if removeAllResults != main.TRUE:
- main.log.error( "Error executing set removeAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- removeAllResults = removeAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=removeAllResults,
- onpass="Set removeAll correct",
- onfail="Set removeAll was incorrect" )
-
- main.step( "Distributed Set addAll()" )
- onosSet.update( addAllValue.split() )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAddAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addAllResults = main.FALSE
- else:
- # unexpected result
- addAllResults = main.FALSE
- if addAllResults != main.TRUE:
- main.log.error( "Error executing set addAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addAllResults = addAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addAllResults,
- onpass="Set addAll correct",
- onfail="Set addAll was incorrect" )
-
- main.step( "Distributed Set clear()" )
- onosSet.clear()
- clearResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestClear-" + str( i ),
- args=[ onosSetName, " "], # Values doesn't matter
- kwargs={ "clear": True } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- clearResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- clearResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if clearResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif clearResponses[ i ] == main.FALSE:
- # Nothing set, probably fine
- pass
- elif clearResponses[ i ] == main.ERROR:
- # Error in execution
- clearResults = main.FALSE
- else:
- # unexpected result
- clearResults = main.FALSE
- if clearResults != main.TRUE:
- main.log.error( "Error executing set clear" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- clearResults = clearResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=clearResults,
- onpass="Set clear correct",
- onfail="Set clear was incorrect" )
-
- main.step( "Distributed Set addAll()" )
- onosSet.update( addAllValue.split() )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAddAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addAllResults = main.FALSE
- else:
- # unexpected result
- addAllResults = main.FALSE
- if addAllResults != main.TRUE:
- main.log.error( "Error executing set addAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addAllResults = addAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addAllResults,
- onpass="Set addAll correct",
- onfail="Set addAll was incorrect" )
-
- main.step( "Distributed Set retain()" )
- onosSet.intersection_update( retainValue.split() )
- retainResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestRetain-" + str( i ),
- args=[ onosSetName, retainValue ],
- kwargs={ "retain": True } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- retainResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- retainResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if retainResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif retainResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif retainResponses[ i ] == main.ERROR:
- # Error in execution
- retainResults = main.FALSE
- else:
- # unexpected result
- retainResults = main.FALSE
- if retainResults != main.TRUE:
- main.log.error( "Error executing set retain" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node + " expected a size of " +
- str( size ) + " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- retainResults = retainResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=retainResults,
- onpass="Set retain correct",
- onfail="Set retain was incorrect" )
-
- # Transactional maps
- main.step( "Partitioned Transactional maps put" )
- tMapValue = "Testing"
- numKeys = 100
- putResult = True
- node = main.activeNodes[0]
- putResponses = main.CLIs[node].transactionalMapPut( numKeys, tMapValue )
- if putResponses and len( putResponses ) == 100:
- for i in putResponses:
- if putResponses[ i ][ 'value' ] != tMapValue:
- putResult = False
- else:
- putResult = False
- if not putResult:
- main.log.debug( "Put response values: " + str( putResponses ) )
- utilities.assert_equals( expect=True,
- actual=putResult,
- onpass="Partitioned Transactional Map put successful",
- onfail="Partitioned Transactional Map put values are incorrect" )
-
- main.step( "Partitioned Transactional maps get" )
- # FIXME: is this sleep needed?
- time.sleep( 5 )
-
- getCheck = True
- for n in range( 1, numKeys + 1 ):
- getResponses = []
- threads = []
- valueCheck = True
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].transactionalMapGet,
- name="TMap-get-" + str( i ),
- args=[ "Key" + str( n ) ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- for node in getResponses:
- if node != tMapValue:
- valueCheck = False
- if not valueCheck:
- main.log.warn( "Values for key 'Key" + str( n ) + "' do not match:" )
- main.log.warn( getResponses )
- getCheck = getCheck and valueCheck
- utilities.assert_equals( expect=True,
- actual=getCheck,
- onpass="Partitioned Transactional Map get values were correct",
- onfail="Partitioned Transactional Map values incorrect" )
+ main.HA.CASE17( main )
diff --git a/TestON/tests/HA/HAfullNetPartition/HAfullNetPartition.py b/TestON/tests/HA/HAfullNetPartition/HAfullNetPartition.py
index f7aec3b..742e340 100644
--- a/TestON/tests/HA/HAfullNetPartition/HAfullNetPartition.py
+++ b/TestON/tests/HA/HAfullNetPartition/HAfullNetPartition.py
@@ -3060,7 +3060,7 @@
# verify leader didn't just change
# Get new leaders and candidates
reRunLeaders = []
- time.sleep( 5 ) # Paremterize
+ time.sleep( 5 ) # Paremterize
positionResult, reRunLeaders = main.HA.consistentLeaderboards( activeCLIs )
# Check that the re-elected node is last on the candidate List
@@ -3089,14 +3089,10 @@
assert main.nodes, "main.nodes not defined"
# Variables for the distributed primitives tests
- global pCounterName
- global pCounterValue
- global onosSet
- global onosSetName
- pCounterName = "TestON-Partitions"
- pCounterValue = 0
- onosSet = set([])
- onosSetName = "TestON-set"
+ main.pCounterName = "TestON-Partitions"
+ main.pCounterValue = 0
+ main.onosSet = set([])
+ main.onosSetName = "TestON-set"
description = "Install Primitives app"
main.case( description )
@@ -3114,1153 +3110,4 @@
"""
Check for basic functionality with distributed primitives
"""
- # Make sure variables are defined/set
- assert main.numCtrls, "main.numCtrls not defined"
- assert main, "main not defined"
- assert utilities.assert_equals, "utilities.assert_equals not defined"
- assert main.CLIs, "main.CLIs not defined"
- assert main.nodes, "main.nodes not defined"
- assert pCounterName, "pCounterName not defined"
- assert onosSetName, "onosSetName not defined"
- # NOTE: assert fails if value is 0/None/Empty/False
- try:
- pCounterValue
- except NameError:
- main.log.error( "pCounterValue not defined, setting to 0" )
- pCounterValue = 0
- try:
- onosSet
- except NameError:
- main.log.error( "onosSet not defined, setting to empty Set" )
- onosSet = set([])
- # Variables for the distributed primitives tests. These are local only
- addValue = "a"
- addAllValue = "a b c d e f"
- retainValue = "c d e f"
-
- 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"
- # DISTRIBUTED ATOMIC COUNTERS
- # Partitioned counters
- main.step( "Increment then get a default counter on each node" )
- pCounters = []
- threads = []
- addedPValues = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].counterTestAddAndGet,
- name="counterAddAndGet-" + str( i ),
- args=[ pCounterName ] )
- pCounterValue += 1
- 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 Increment a default counter on each node" )
- pCounters = []
- threads = []
- addedPValues = []
- for i in main.activeNodes:
- 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.HA.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 main.activeNodes:
- 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 main.activeNodes:
- 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 main.activeNodes:
- 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.HA.counterCheck( pCounterName, pCounterValue )
- utilities.assert_equals( expect=main.TRUE,
- 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 main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
-
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- utilities.assert_equals( expect=main.TRUE,
- actual=getResults,
- onpass="Set elements are correct",
- onfail="Set elements are incorrect" )
-
- main.step( "Distributed Set size" )
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
-
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- utilities.assert_equals( expect=main.TRUE,
- actual=sizeResults,
- onpass="Set sizes are correct",
- onfail="Set sizes are incorrect" )
-
- main.step( "Distributed Set add()" )
- onosSet.add( addValue )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAdd-" + str( i ),
- args=[ onosSetName, addValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addResults = main.FALSE
- else:
- # unexpected result
- addResults = main.FALSE
- if addResults != main.TRUE:
- main.log.error( "Error executing set add" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node + " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node + " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addResults = addResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addResults,
- onpass="Set add correct",
- onfail="Set add was incorrect" )
-
- main.step( "Distributed Set addAll()" )
- onosSet.update( addAllValue.split() )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAddAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addAllResults = main.FALSE
- else:
- # unexpected result
- addAllResults = main.FALSE
- if addAllResults != main.TRUE:
- main.log.error( "Error executing set addAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addAllResults = addAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addAllResults,
- onpass="Set addAll correct",
- onfail="Set addAll was incorrect" )
-
- main.step( "Distributed Set contains()" )
- containsResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setContains-" + str( i ),
- args=[ onosSetName ],
- kwargs={ "values": addValue } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- # NOTE: This is the tuple
- containsResponses.append( t.result )
-
- containsResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if containsResponses[ i ] == main.ERROR:
- containsResults = main.FALSE
- else:
- containsResults = containsResults and\
- containsResponses[ i ][ 1 ]
- utilities.assert_equals( expect=main.TRUE,
- actual=containsResults,
- onpass="Set contains is functional",
- onfail="Set contains failed" )
-
- main.step( "Distributed Set containsAll()" )
- containsAllResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setContainsAll-" + str( i ),
- args=[ onosSetName ],
- kwargs={ "values": addAllValue } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- # NOTE: This is the tuple
- containsAllResponses.append( t.result )
-
- containsAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if containsResponses[ i ] == main.ERROR:
- containsResults = main.FALSE
- else:
- containsResults = containsResults and\
- containsResponses[ i ][ 1 ]
- utilities.assert_equals( expect=main.TRUE,
- actual=containsAllResults,
- onpass="Set containsAll is functional",
- onfail="Set containsAll failed" )
-
- main.step( "Distributed Set remove()" )
- onosSet.remove( addValue )
- removeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestRemove-" + str( i ),
- args=[ onosSetName, addValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- removeResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- removeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if removeResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif removeResponses[ i ] == main.FALSE:
- # not in set, probably fine
- pass
- elif removeResponses[ i ] == main.ERROR:
- # Error in execution
- removeResults = main.FALSE
- else:
- # unexpected result
- removeResults = main.FALSE
- if removeResults != main.TRUE:
- main.log.error( "Error executing set remove" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- removeResults = removeResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=removeResults,
- onpass="Set remove correct",
- onfail="Set remove was incorrect" )
-
- main.step( "Distributed Set removeAll()" )
- onosSet.difference_update( addAllValue.split() )
- removeAllResponses = []
- threads = []
- try:
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestRemoveAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- removeAllResponses.append( t.result )
- except Exception, e:
- main.log.exception(e)
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- removeAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if removeAllResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif removeAllResponses[ i ] == main.FALSE:
- # not in set, probably fine
- pass
- elif removeAllResponses[ i ] == main.ERROR:
- # Error in execution
- removeAllResults = main.FALSE
- else:
- # unexpected result
- removeAllResults = main.FALSE
- if removeAllResults != main.TRUE:
- main.log.error( "Error executing set removeAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- removeAllResults = removeAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=removeAllResults,
- onpass="Set removeAll correct",
- onfail="Set removeAll was incorrect" )
-
- main.step( "Distributed Set addAll()" )
- onosSet.update( addAllValue.split() )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAddAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addAllResults = main.FALSE
- else:
- # unexpected result
- addAllResults = main.FALSE
- if addAllResults != main.TRUE:
- main.log.error( "Error executing set addAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addAllResults = addAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addAllResults,
- onpass="Set addAll correct",
- onfail="Set addAll was incorrect" )
-
- main.step( "Distributed Set clear()" )
- onosSet.clear()
- clearResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestClear-" + str( i ),
- args=[ onosSetName, " "], # Values doesn't matter
- kwargs={ "clear": True } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- clearResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- clearResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if clearResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif clearResponses[ i ] == main.FALSE:
- # Nothing set, probably fine
- pass
- elif clearResponses[ i ] == main.ERROR:
- # Error in execution
- clearResults = main.FALSE
- else:
- # unexpected result
- clearResults = main.FALSE
- if clearResults != main.TRUE:
- main.log.error( "Error executing set clear" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- clearResults = clearResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=clearResults,
- onpass="Set clear correct",
- onfail="Set clear was incorrect" )
-
- main.step( "Distributed Set addAll()" )
- onosSet.update( addAllValue.split() )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAddAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addAllResults = main.FALSE
- else:
- # unexpected result
- addAllResults = main.FALSE
- if addAllResults != main.TRUE:
- main.log.error( "Error executing set addAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addAllResults = addAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addAllResults,
- onpass="Set addAll correct",
- onfail="Set addAll was incorrect" )
-
- main.step( "Distributed Set retain()" )
- onosSet.intersection_update( retainValue.split() )
- retainResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestRetain-" + str( i ),
- args=[ onosSetName, retainValue ],
- kwargs={ "retain": True } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- retainResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- retainResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if retainResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif retainResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif retainResponses[ i ] == main.ERROR:
- # Error in execution
- retainResults = main.FALSE
- else:
- # unexpected result
- retainResults = main.FALSE
- if retainResults != main.TRUE:
- main.log.error( "Error executing set retain" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node + " expected a size of " +
- str( size ) + " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- retainResults = retainResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=retainResults,
- onpass="Set retain correct",
- onfail="Set retain was incorrect" )
-
- # Transactional maps
- main.step( "Partitioned Transactional maps put" )
- tMapValue = "Testing"
- numKeys = 100
- putResult = True
- node = main.activeNodes[0]
- putResponses = main.CLIs[node].transactionalMapPut( numKeys, tMapValue )
- if putResponses and len( putResponses ) == 100:
- for i in putResponses:
- if putResponses[ i ][ 'value' ] != tMapValue:
- putResult = False
- else:
- putResult = False
- if not putResult:
- main.log.debug( "Put response values: " + str( putResponses ) )
- utilities.assert_equals( expect=True,
- actual=putResult,
- onpass="Partitioned Transactional Map put successful",
- onfail="Partitioned Transactional Map put values are incorrect" )
-
- main.step( "Partitioned Transactional maps get" )
- # FIXME: is this sleep needed?
- time.sleep( 5 )
-
- getCheck = True
- for n in range( 1, numKeys + 1 ):
- getResponses = []
- threads = []
- valueCheck = True
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].transactionalMapGet,
- name="TMap-get-" + str( i ),
- args=[ "Key" + str( n ) ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- for node in getResponses:
- if node != tMapValue:
- valueCheck = False
- if not valueCheck:
- main.log.warn( "Values for key 'Key" + str( n ) + "' do not match:" )
- main.log.warn( getResponses )
- getCheck = getCheck and valueCheck
- utilities.assert_equals( expect=True,
- actual=getCheck,
- onpass="Partitioned Transactional Map get values were correct",
- onfail="Partitioned Transactional Map values incorrect" )
+ main.HA.CASE17( main )
diff --git a/TestON/tests/HA/HAkillNodes/HAkillNodes.py b/TestON/tests/HA/HAkillNodes/HAkillNodes.py
index 336f0f1..560cb71 100644
--- a/TestON/tests/HA/HAkillNodes/HAkillNodes.py
+++ b/TestON/tests/HA/HAkillNodes/HAkillNodes.py
@@ -3116,7 +3116,7 @@
# verify leader didn't just change
# Get new leaders and candidates
reRunLeaders = []
- time.sleep( 5 ) # Paremterize
+ time.sleep( 5 ) # Paremterize
positionResult, reRunLeaders = main.HA.consistentLeaderboards( activeCLIs )
# Check that the re-elected node is last on the candidate List
@@ -3145,14 +3145,10 @@
assert main.nodes, "main.nodes not defined"
# Variables for the distributed primitives tests
- global pCounterName
- global pCounterValue
- global onosSet
- global onosSetName
- pCounterName = "TestON-Partitions"
- pCounterValue = 0
- onosSet = set([])
- onosSetName = "TestON-set"
+ main.pCounterName = "TestON-Partitions"
+ main.pCounterValue = 0
+ main.onosSet = set([])
+ main.onosSetName = "TestON-set"
description = "Install Primitives app"
main.case( description )
@@ -3170,1153 +3166,4 @@
"""
Check for basic functionality with distributed primitives
"""
- # Make sure variables are defined/set
- assert main.numCtrls, "main.numCtrls not defined"
- assert main, "main not defined"
- assert utilities.assert_equals, "utilities.assert_equals not defined"
- assert main.CLIs, "main.CLIs not defined"
- assert main.nodes, "main.nodes not defined"
- assert pCounterName, "pCounterName not defined"
- assert onosSetName, "onosSetName not defined"
- # NOTE: assert fails if value is 0/None/Empty/False
- try:
- pCounterValue
- except NameError:
- main.log.error( "pCounterValue not defined, setting to 0" )
- pCounterValue = 0
- try:
- onosSet
- except NameError:
- main.log.error( "onosSet not defined, setting to empty Set" )
- onosSet = set([])
- # Variables for the distributed primitives tests. These are local only
- addValue = "a"
- addAllValue = "a b c d e f"
- retainValue = "c d e f"
-
- 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"
- # DISTRIBUTED ATOMIC COUNTERS
- # Partitioned counters
- main.step( "Increment then get a default counter on each node" )
- pCounters = []
- threads = []
- addedPValues = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].counterTestAddAndGet,
- name="counterAddAndGet-" + str( i ),
- args=[ pCounterName ] )
- pCounterValue += 1
- 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 Increment a default counter on each node" )
- pCounters = []
- threads = []
- addedPValues = []
- for i in main.activeNodes:
- 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.HA.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 main.activeNodes:
- 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 main.activeNodes:
- 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 main.activeNodes:
- 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.HA.counterCheck( pCounterName, pCounterValue )
- utilities.assert_equals( expect=main.TRUE,
- 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 main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
-
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- utilities.assert_equals( expect=main.TRUE,
- actual=getResults,
- onpass="Set elements are correct",
- onfail="Set elements are incorrect" )
-
- main.step( "Distributed Set size" )
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
-
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- utilities.assert_equals( expect=main.TRUE,
- actual=sizeResults,
- onpass="Set sizes are correct",
- onfail="Set sizes are incorrect" )
-
- main.step( "Distributed Set add()" )
- onosSet.add( addValue )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAdd-" + str( i ),
- args=[ onosSetName, addValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addResults = main.FALSE
- else:
- # unexpected result
- addResults = main.FALSE
- if addResults != main.TRUE:
- main.log.error( "Error executing set add" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node + " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node + " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addResults = addResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addResults,
- onpass="Set add correct",
- onfail="Set add was incorrect" )
-
- main.step( "Distributed Set addAll()" )
- onosSet.update( addAllValue.split() )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAddAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addAllResults = main.FALSE
- else:
- # unexpected result
- addAllResults = main.FALSE
- if addAllResults != main.TRUE:
- main.log.error( "Error executing set addAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addAllResults = addAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addAllResults,
- onpass="Set addAll correct",
- onfail="Set addAll was incorrect" )
-
- main.step( "Distributed Set contains()" )
- containsResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setContains-" + str( i ),
- args=[ onosSetName ],
- kwargs={ "values": addValue } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- # NOTE: This is the tuple
- containsResponses.append( t.result )
-
- containsResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if containsResponses[ i ] == main.ERROR:
- containsResults = main.FALSE
- else:
- containsResults = containsResults and\
- containsResponses[ i ][ 1 ]
- utilities.assert_equals( expect=main.TRUE,
- actual=containsResults,
- onpass="Set contains is functional",
- onfail="Set contains failed" )
-
- main.step( "Distributed Set containsAll()" )
- containsAllResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setContainsAll-" + str( i ),
- args=[ onosSetName ],
- kwargs={ "values": addAllValue } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- # NOTE: This is the tuple
- containsAllResponses.append( t.result )
-
- containsAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if containsResponses[ i ] == main.ERROR:
- containsResults = main.FALSE
- else:
- containsResults = containsResults and\
- containsResponses[ i ][ 1 ]
- utilities.assert_equals( expect=main.TRUE,
- actual=containsAllResults,
- onpass="Set containsAll is functional",
- onfail="Set containsAll failed" )
-
- main.step( "Distributed Set remove()" )
- onosSet.remove( addValue )
- removeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestRemove-" + str( i ),
- args=[ onosSetName, addValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- removeResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- removeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if removeResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif removeResponses[ i ] == main.FALSE:
- # not in set, probably fine
- pass
- elif removeResponses[ i ] == main.ERROR:
- # Error in execution
- removeResults = main.FALSE
- else:
- # unexpected result
- removeResults = main.FALSE
- if removeResults != main.TRUE:
- main.log.error( "Error executing set remove" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- removeResults = removeResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=removeResults,
- onpass="Set remove correct",
- onfail="Set remove was incorrect" )
-
- main.step( "Distributed Set removeAll()" )
- onosSet.difference_update( addAllValue.split() )
- removeAllResponses = []
- threads = []
- try:
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestRemoveAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- removeAllResponses.append( t.result )
- except Exception, e:
- main.log.exception(e)
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- removeAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if removeAllResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif removeAllResponses[ i ] == main.FALSE:
- # not in set, probably fine
- pass
- elif removeAllResponses[ i ] == main.ERROR:
- # Error in execution
- removeAllResults = main.FALSE
- else:
- # unexpected result
- removeAllResults = main.FALSE
- if removeAllResults != main.TRUE:
- main.log.error( "Error executing set removeAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- removeAllResults = removeAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=removeAllResults,
- onpass="Set removeAll correct",
- onfail="Set removeAll was incorrect" )
-
- main.step( "Distributed Set addAll()" )
- onosSet.update( addAllValue.split() )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAddAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addAllResults = main.FALSE
- else:
- # unexpected result
- addAllResults = main.FALSE
- if addAllResults != main.TRUE:
- main.log.error( "Error executing set addAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addAllResults = addAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addAllResults,
- onpass="Set addAll correct",
- onfail="Set addAll was incorrect" )
-
- main.step( "Distributed Set clear()" )
- onosSet.clear()
- clearResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestClear-" + str( i ),
- args=[ onosSetName, " "], # Values doesn't matter
- kwargs={ "clear": True } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- clearResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- clearResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if clearResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif clearResponses[ i ] == main.FALSE:
- # Nothing set, probably fine
- pass
- elif clearResponses[ i ] == main.ERROR:
- # Error in execution
- clearResults = main.FALSE
- else:
- # unexpected result
- clearResults = main.FALSE
- if clearResults != main.TRUE:
- main.log.error( "Error executing set clear" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- clearResults = clearResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=clearResults,
- onpass="Set clear correct",
- onfail="Set clear was incorrect" )
-
- main.step( "Distributed Set addAll()" )
- onosSet.update( addAllValue.split() )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAddAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addAllResults = main.FALSE
- else:
- # unexpected result
- addAllResults = main.FALSE
- if addAllResults != main.TRUE:
- main.log.error( "Error executing set addAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addAllResults = addAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addAllResults,
- onpass="Set addAll correct",
- onfail="Set addAll was incorrect" )
-
- main.step( "Distributed Set retain()" )
- onosSet.intersection_update( retainValue.split() )
- retainResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestRetain-" + str( i ),
- args=[ onosSetName, retainValue ],
- kwargs={ "retain": True } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- retainResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- retainResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if retainResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif retainResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif retainResponses[ i ] == main.ERROR:
- # Error in execution
- retainResults = main.FALSE
- else:
- # unexpected result
- retainResults = main.FALSE
- if retainResults != main.TRUE:
- main.log.error( "Error executing set retain" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node + " expected a size of " +
- str( size ) + " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- retainResults = retainResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=retainResults,
- onpass="Set retain correct",
- onfail="Set retain was incorrect" )
-
- # Transactional maps
- main.step( "Partitioned Transactional maps put" )
- tMapValue = "Testing"
- numKeys = 100
- putResult = True
- node = main.activeNodes[0]
- putResponses = main.CLIs[node].transactionalMapPut( numKeys, tMapValue )
- if putResponses and len( putResponses ) == 100:
- for i in putResponses:
- if putResponses[ i ][ 'value' ] != tMapValue:
- putResult = False
- else:
- putResult = False
- if not putResult:
- main.log.debug( "Put response values: " + str( putResponses ) )
- utilities.assert_equals( expect=True,
- actual=putResult,
- onpass="Partitioned Transactional Map put successful",
- onfail="Partitioned Transactional Map put values are incorrect" )
-
- main.step( "Partitioned Transactional maps get" )
- # FIXME: is this sleep needed?
- time.sleep( 5 )
-
- getCheck = True
- for n in range( 1, numKeys + 1 ):
- getResponses = []
- threads = []
- valueCheck = True
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].transactionalMapGet,
- name="TMap-get-" + str( i ),
- args=[ "Key" + str( n ) ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- for node in getResponses:
- if node != tMapValue:
- valueCheck = False
- if not valueCheck:
- main.log.warn( "Values for key 'Key" + str( n ) + "' do not match:" )
- main.log.warn( getResponses )
- getCheck = getCheck and valueCheck
- utilities.assert_equals( expect=True,
- actual=getCheck,
- onpass="Partitioned Transactional Map get values were correct",
- onfail="Partitioned Transactional Map values incorrect" )
+ main.HA.CASE17( main )
diff --git a/TestON/tests/HA/HAsanity/HAsanity.py b/TestON/tests/HA/HAsanity/HAsanity.py
index 32b7e14..2b2ea08 100644
--- a/TestON/tests/HA/HAsanity/HAsanity.py
+++ b/TestON/tests/HA/HAsanity/HAsanity.py
@@ -2976,7 +2976,7 @@
# verify leader didn't just change
# Get new leaders and candidates
reRunLeaders = []
- time.sleep( 5 ) # Paremterize
+ time.sleep( 5 ) # Paremterize
positionResult, reRunLeaders = main.HA.consistentLeaderboards( activeCLIs )
# Check that the re-elected node is last on the candidate List
@@ -3005,14 +3005,10 @@
assert main.nodes, "main.nodes not defined"
# Variables for the distributed primitives tests
- global pCounterName
- global pCounterValue
- global onosSet
- global onosSetName
- pCounterName = "TestON-Partitions"
- pCounterValue = 0
- onosSet = set([])
- onosSetName = "TestON-set"
+ main.pCounterName = "TestON-Partitions"
+ main.pCounterValue = 0
+ main.onosSet = set([])
+ main.onosSetName = "TestON-set"
description = "Install Primitives app"
main.case( description )
@@ -3030,1153 +3026,4 @@
"""
Check for basic functionality with distributed primitives
"""
- # Make sure variables are defined/set
- assert main.numCtrls, "main.numCtrls not defined"
- assert main, "main not defined"
- assert utilities.assert_equals, "utilities.assert_equals not defined"
- assert main.CLIs, "main.CLIs not defined"
- assert main.nodes, "main.nodes not defined"
- assert pCounterName, "pCounterName not defined"
- assert onosSetName, "onosSetName not defined"
- # NOTE: assert fails if value is 0/None/Empty/False
- try:
- pCounterValue
- except NameError:
- main.log.error( "pCounterValue not defined, setting to 0" )
- pCounterValue = 0
- try:
- onosSet
- except NameError:
- main.log.error( "onosSet not defined, setting to empty Set" )
- onosSet = set([])
- # Variables for the distributed primitives tests. These are local only
- addValue = "a"
- addAllValue = "a b c d e f"
- retainValue = "c d e f"
-
- 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"
- # DISTRIBUTED ATOMIC COUNTERS
- # Partitioned counters
- main.step( "Increment then get a default counter on each node" )
- pCounters = []
- threads = []
- addedPValues = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].counterTestAddAndGet,
- name="counterAddAndGet-" + str( i ),
- args=[ pCounterName ] )
- pCounterValue += 1
- 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 Increment a default counter on each node" )
- pCounters = []
- threads = []
- addedPValues = []
- for i in main.activeNodes:
- 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.HA.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 main.activeNodes:
- 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 main.activeNodes:
- 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 main.activeNodes:
- 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.HA.counterCheck( pCounterName, pCounterValue )
- utilities.assert_equals( expect=main.TRUE,
- 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 main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
-
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- utilities.assert_equals( expect=main.TRUE,
- actual=getResults,
- onpass="Set elements are correct",
- onfail="Set elements are incorrect" )
-
- main.step( "Distributed Set size" )
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
-
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- utilities.assert_equals( expect=main.TRUE,
- actual=sizeResults,
- onpass="Set sizes are correct",
- onfail="Set sizes are incorrect" )
-
- main.step( "Distributed Set add()" )
- onosSet.add( addValue )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAdd-" + str( i ),
- args=[ onosSetName, addValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addResults = main.FALSE
- else:
- # unexpected result
- addResults = main.FALSE
- if addResults != main.TRUE:
- main.log.error( "Error executing set add" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node + " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node + " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addResults = addResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addResults,
- onpass="Set add correct",
- onfail="Set add was incorrect" )
-
- main.step( "Distributed Set addAll()" )
- onosSet.update( addAllValue.split() )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAddAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addAllResults = main.FALSE
- else:
- # unexpected result
- addAllResults = main.FALSE
- if addAllResults != main.TRUE:
- main.log.error( "Error executing set addAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addAllResults = addAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addAllResults,
- onpass="Set addAll correct",
- onfail="Set addAll was incorrect" )
-
- main.step( "Distributed Set contains()" )
- containsResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setContains-" + str( i ),
- args=[ onosSetName ],
- kwargs={ "values": addValue } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- # NOTE: This is the tuple
- containsResponses.append( t.result )
-
- containsResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if containsResponses[ i ] == main.ERROR:
- containsResults = main.FALSE
- else:
- containsResults = containsResults and\
- containsResponses[ i ][ 1 ]
- utilities.assert_equals( expect=main.TRUE,
- actual=containsResults,
- onpass="Set contains is functional",
- onfail="Set contains failed" )
-
- main.step( "Distributed Set containsAll()" )
- containsAllResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setContainsAll-" + str( i ),
- args=[ onosSetName ],
- kwargs={ "values": addAllValue } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- # NOTE: This is the tuple
- containsAllResponses.append( t.result )
-
- containsAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if containsResponses[ i ] == main.ERROR:
- containsResults = main.FALSE
- else:
- containsResults = containsResults and\
- containsResponses[ i ][ 1 ]
- utilities.assert_equals( expect=main.TRUE,
- actual=containsAllResults,
- onpass="Set containsAll is functional",
- onfail="Set containsAll failed" )
-
- main.step( "Distributed Set remove()" )
- onosSet.remove( addValue )
- removeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestRemove-" + str( i ),
- args=[ onosSetName, addValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- removeResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- removeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if removeResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif removeResponses[ i ] == main.FALSE:
- # not in set, probably fine
- pass
- elif removeResponses[ i ] == main.ERROR:
- # Error in execution
- removeResults = main.FALSE
- else:
- # unexpected result
- removeResults = main.FALSE
- if removeResults != main.TRUE:
- main.log.error( "Error executing set remove" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- removeResults = removeResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=removeResults,
- onpass="Set remove correct",
- onfail="Set remove was incorrect" )
-
- main.step( "Distributed Set removeAll()" )
- onosSet.difference_update( addAllValue.split() )
- removeAllResponses = []
- threads = []
- try:
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestRemoveAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- removeAllResponses.append( t.result )
- except Exception, e:
- main.log.exception(e)
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- removeAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if removeAllResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif removeAllResponses[ i ] == main.FALSE:
- # not in set, probably fine
- pass
- elif removeAllResponses[ i ] == main.ERROR:
- # Error in execution
- removeAllResults = main.FALSE
- else:
- # unexpected result
- removeAllResults = main.FALSE
- if removeAllResults != main.TRUE:
- main.log.error( "Error executing set removeAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- removeAllResults = removeAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=removeAllResults,
- onpass="Set removeAll correct",
- onfail="Set removeAll was incorrect" )
-
- main.step( "Distributed Set addAll()" )
- onosSet.update( addAllValue.split() )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAddAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addAllResults = main.FALSE
- else:
- # unexpected result
- addAllResults = main.FALSE
- if addAllResults != main.TRUE:
- main.log.error( "Error executing set addAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addAllResults = addAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addAllResults,
- onpass="Set addAll correct",
- onfail="Set addAll was incorrect" )
-
- main.step( "Distributed Set clear()" )
- onosSet.clear()
- clearResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestClear-" + str( i ),
- args=[ onosSetName, " "], # Values doesn't matter
- kwargs={ "clear": True } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- clearResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- clearResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if clearResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif clearResponses[ i ] == main.FALSE:
- # Nothing set, probably fine
- pass
- elif clearResponses[ i ] == main.ERROR:
- # Error in execution
- clearResults = main.FALSE
- else:
- # unexpected result
- clearResults = main.FALSE
- if clearResults != main.TRUE:
- main.log.error( "Error executing set clear" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- clearResults = clearResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=clearResults,
- onpass="Set clear correct",
- onfail="Set clear was incorrect" )
-
- main.step( "Distributed Set addAll()" )
- onosSet.update( addAllValue.split() )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAddAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addAllResults = main.FALSE
- else:
- # unexpected result
- addAllResults = main.FALSE
- if addAllResults != main.TRUE:
- main.log.error( "Error executing set addAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addAllResults = addAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addAllResults,
- onpass="Set addAll correct",
- onfail="Set addAll was incorrect" )
-
- main.step( "Distributed Set retain()" )
- onosSet.intersection_update( retainValue.split() )
- retainResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestRetain-" + str( i ),
- args=[ onosSetName, retainValue ],
- kwargs={ "retain": True } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- retainResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- retainResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if retainResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif retainResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif retainResponses[ i ] == main.ERROR:
- # Error in execution
- retainResults = main.FALSE
- else:
- # unexpected result
- retainResults = main.FALSE
- if retainResults != main.TRUE:
- main.log.error( "Error executing set retain" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node + " expected a size of " +
- str( size ) + " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- retainResults = retainResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=retainResults,
- onpass="Set retain correct",
- onfail="Set retain was incorrect" )
-
- # Transactional maps
- main.step( "Partitioned Transactional maps put" )
- tMapValue = "Testing"
- numKeys = 100
- putResult = True
- node = main.activeNodes[0]
- putResponses = main.CLIs[node].transactionalMapPut( numKeys, tMapValue )
- if putResponses and len( putResponses ) == 100:
- for i in putResponses:
- if putResponses[ i ][ 'value' ] != tMapValue:
- putResult = False
- else:
- putResult = False
- if not putResult:
- main.log.debug( "Put response values: " + str( putResponses ) )
- utilities.assert_equals( expect=True,
- actual=putResult,
- onpass="Partitioned Transactional Map put successful",
- onfail="Partitioned Transactional Map put values are incorrect" )
-
- main.step( "Partitioned Transactional maps get" )
- # FIXME: is this sleep needed?
- time.sleep( 5 )
-
- getCheck = True
- for n in range( 1, numKeys + 1 ):
- getResponses = []
- threads = []
- valueCheck = True
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].transactionalMapGet,
- name="TMap-get-" + str( i ),
- args=[ "Key" + str( n ) ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- for node in getResponses:
- if node != tMapValue:
- valueCheck = False
- if not valueCheck:
- main.log.warn( "Values for key 'Key" + str( n ) + "' do not match:" )
- main.log.warn( getResponses )
- getCheck = getCheck and valueCheck
- utilities.assert_equals( expect=True,
- actual=getCheck,
- onpass="Partitioned Transactional Map get values were correct",
- onfail="Partitioned Transactional Map values incorrect" )
+ main.HA.CASE17( main )
diff --git a/TestON/tests/HA/HAscaling/HAscaling.py b/TestON/tests/HA/HAscaling/HAscaling.py
index 112306a..c58ad41 100644
--- a/TestON/tests/HA/HAscaling/HAscaling.py
+++ b/TestON/tests/HA/HAscaling/HAscaling.py
@@ -3139,14 +3139,10 @@
assert main.nodes, "main.nodes not defined"
# Variables for the distributed primitives tests
- global pCounterName
- global pCounterValue
- global onosSet
- global onosSetName
- pCounterName = "TestON-Partitions"
- pCounterValue = 0
- onosSet = set([])
- onosSetName = "TestON-set"
+ main.pCounterName = "TestON-Partitions"
+ main.pCounterValue = 0
+ main.onosSet = set([])
+ main.onosSetName = "TestON-set"
description = "Install Primitives app"
main.case( description )
@@ -3164,1153 +3160,4 @@
"""
Check for basic functionality with distributed primitives
"""
- # Make sure variables are defined/set
- assert main.numCtrls, "main.numCtrls not defined"
- assert main, "main not defined"
- assert utilities.assert_equals, "utilities.assert_equals not defined"
- assert main.CLIs, "main.CLIs not defined"
- assert main.nodes, "main.nodes not defined"
- assert pCounterName, "pCounterName not defined"
- assert onosSetName, "onosSetName not defined"
- # NOTE: assert fails if value is 0/None/Empty/False
- try:
- pCounterValue
- except NameError:
- main.log.error( "pCounterValue not defined, setting to 0" )
- pCounterValue = 0
- try:
- onosSet
- except NameError:
- main.log.error( "onosSet not defined, setting to empty Set" )
- onosSet = set([])
- # Variables for the distributed primitives tests. These are local only
- addValue = "a"
- addAllValue = "a b c d e f"
- retainValue = "c d e f"
-
- 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"
- # DISTRIBUTED ATOMIC COUNTERS
- # Partitioned counters
- main.step( "Increment then get a default counter on each node" )
- pCounters = []
- threads = []
- addedPValues = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].counterTestAddAndGet,
- name="counterAddAndGet-" + str( i ),
- args=[ pCounterName ] )
- pCounterValue += 1
- 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 Increment a default counter on each node" )
- pCounters = []
- threads = []
- addedPValues = []
- for i in main.activeNodes:
- 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.HA.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 main.activeNodes:
- 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 main.activeNodes:
- 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 main.activeNodes:
- 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.HA.counterCheck( pCounterName, pCounterValue )
- utilities.assert_equals( expect=main.TRUE,
- 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 main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
-
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- utilities.assert_equals( expect=main.TRUE,
- actual=getResults,
- onpass="Set elements are correct",
- onfail="Set elements are incorrect" )
-
- main.step( "Distributed Set size" )
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
-
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- utilities.assert_equals( expect=main.TRUE,
- actual=sizeResults,
- onpass="Set sizes are correct",
- onfail="Set sizes are incorrect" )
-
- main.step( "Distributed Set add()" )
- onosSet.add( addValue )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAdd-" + str( i ),
- args=[ onosSetName, addValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addResults = main.FALSE
- else:
- # unexpected result
- addResults = main.FALSE
- if addResults != main.TRUE:
- main.log.error( "Error executing set add" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node + " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node + " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addResults = addResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addResults,
- onpass="Set add correct",
- onfail="Set add was incorrect" )
-
- main.step( "Distributed Set addAll()" )
- onosSet.update( addAllValue.split() )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAddAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addAllResults = main.FALSE
- else:
- # unexpected result
- addAllResults = main.FALSE
- if addAllResults != main.TRUE:
- main.log.error( "Error executing set addAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addAllResults = addAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addAllResults,
- onpass="Set addAll correct",
- onfail="Set addAll was incorrect" )
-
- main.step( "Distributed Set contains()" )
- containsResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setContains-" + str( i ),
- args=[ onosSetName ],
- kwargs={ "values": addValue } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- # NOTE: This is the tuple
- containsResponses.append( t.result )
-
- containsResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if containsResponses[ i ] == main.ERROR:
- containsResults = main.FALSE
- else:
- containsResults = containsResults and\
- containsResponses[ i ][ 1 ]
- utilities.assert_equals( expect=main.TRUE,
- actual=containsResults,
- onpass="Set contains is functional",
- onfail="Set contains failed" )
-
- main.step( "Distributed Set containsAll()" )
- containsAllResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setContainsAll-" + str( i ),
- args=[ onosSetName ],
- kwargs={ "values": addAllValue } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- # NOTE: This is the tuple
- containsAllResponses.append( t.result )
-
- containsAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if containsResponses[ i ] == main.ERROR:
- containsResults = main.FALSE
- else:
- containsResults = containsResults and\
- containsResponses[ i ][ 1 ]
- utilities.assert_equals( expect=main.TRUE,
- actual=containsAllResults,
- onpass="Set containsAll is functional",
- onfail="Set containsAll failed" )
-
- main.step( "Distributed Set remove()" )
- onosSet.remove( addValue )
- removeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestRemove-" + str( i ),
- args=[ onosSetName, addValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- removeResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- removeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if removeResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif removeResponses[ i ] == main.FALSE:
- # not in set, probably fine
- pass
- elif removeResponses[ i ] == main.ERROR:
- # Error in execution
- removeResults = main.FALSE
- else:
- # unexpected result
- removeResults = main.FALSE
- if removeResults != main.TRUE:
- main.log.error( "Error executing set remove" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- removeResults = removeResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=removeResults,
- onpass="Set remove correct",
- onfail="Set remove was incorrect" )
-
- main.step( "Distributed Set removeAll()" )
- onosSet.difference_update( addAllValue.split() )
- removeAllResponses = []
- threads = []
- try:
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestRemoveAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- removeAllResponses.append( t.result )
- except Exception, e:
- main.log.exception(e)
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- removeAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if removeAllResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif removeAllResponses[ i ] == main.FALSE:
- # not in set, probably fine
- pass
- elif removeAllResponses[ i ] == main.ERROR:
- # Error in execution
- removeAllResults = main.FALSE
- else:
- # unexpected result
- removeAllResults = main.FALSE
- if removeAllResults != main.TRUE:
- main.log.error( "Error executing set removeAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- removeAllResults = removeAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=removeAllResults,
- onpass="Set removeAll correct",
- onfail="Set removeAll was incorrect" )
-
- main.step( "Distributed Set addAll()" )
- onosSet.update( addAllValue.split() )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAddAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addAllResults = main.FALSE
- else:
- # unexpected result
- addAllResults = main.FALSE
- if addAllResults != main.TRUE:
- main.log.error( "Error executing set addAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addAllResults = addAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addAllResults,
- onpass="Set addAll correct",
- onfail="Set addAll was incorrect" )
-
- main.step( "Distributed Set clear()" )
- onosSet.clear()
- clearResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestClear-" + str( i ),
- args=[ onosSetName, " "], # Values doesn't matter
- kwargs={ "clear": True } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- clearResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- clearResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if clearResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif clearResponses[ i ] == main.FALSE:
- # Nothing set, probably fine
- pass
- elif clearResponses[ i ] == main.ERROR:
- # Error in execution
- clearResults = main.FALSE
- else:
- # unexpected result
- clearResults = main.FALSE
- if clearResults != main.TRUE:
- main.log.error( "Error executing set clear" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- clearResults = clearResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=clearResults,
- onpass="Set clear correct",
- onfail="Set clear was incorrect" )
-
- main.step( "Distributed Set addAll()" )
- onosSet.update( addAllValue.split() )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAddAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addAllResults = main.FALSE
- else:
- # unexpected result
- addAllResults = main.FALSE
- if addAllResults != main.TRUE:
- main.log.error( "Error executing set addAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addAllResults = addAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addAllResults,
- onpass="Set addAll correct",
- onfail="Set addAll was incorrect" )
-
- main.step( "Distributed Set retain()" )
- onosSet.intersection_update( retainValue.split() )
- retainResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestRetain-" + str( i ),
- args=[ onosSetName, retainValue ],
- kwargs={ "retain": True } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- retainResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- retainResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if retainResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif retainResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif retainResponses[ i ] == main.ERROR:
- # Error in execution
- retainResults = main.FALSE
- else:
- # unexpected result
- retainResults = main.FALSE
- if retainResults != main.TRUE:
- main.log.error( "Error executing set retain" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node + " expected a size of " +
- str( size ) + " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- retainResults = retainResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=retainResults,
- onpass="Set retain correct",
- onfail="Set retain was incorrect" )
-
- # Transactional maps
- main.step( "Partitioned Transactional maps put" )
- tMapValue = "Testing"
- numKeys = 100
- putResult = True
- node = main.activeNodes[0]
- putResponses = main.CLIs[node].transactionalMapPut( numKeys, tMapValue )
- if putResponses and len( putResponses ) == 100:
- for i in putResponses:
- if putResponses[ i ][ 'value' ] != tMapValue:
- putResult = False
- else:
- putResult = False
- if not putResult:
- main.log.debug( "Put response values: " + str( putResponses ) )
- utilities.assert_equals( expect=True,
- actual=putResult,
- onpass="Partitioned Transactional Map put successful",
- onfail="Partitioned Transactional Map put values are incorrect" )
-
- main.step( "Partitioned Transactional maps get" )
- # FIXME: is this sleep needed?
- time.sleep( 5 )
-
- getCheck = True
- for n in range( 1, numKeys + 1 ):
- getResponses = []
- threads = []
- valueCheck = True
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].transactionalMapGet,
- name="TMap-get-" + str( i ),
- args=[ "Key" + str( n ) ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- for node in getResponses:
- if node != tMapValue:
- valueCheck = False
- if not valueCheck:
- main.log.warn( "Values for key 'Key" + str( n ) + "' do not match:" )
- main.log.warn( getResponses )
- getCheck = getCheck and valueCheck
- utilities.assert_equals( expect=True,
- actual=getCheck,
- onpass="Partitioned Transactional Map get values were correct",
- onfail="Partitioned Transactional Map values incorrect" )
+ main.HA.CASE17( main )
diff --git a/TestON/tests/HA/HAsingleInstanceRestart/HAsingleInstanceRestart.params b/TestON/tests/HA/HAsingleInstanceRestart/HAsingleInstanceRestart.params
index d7ac493..f781c0c 100644
--- a/TestON/tests/HA/HAsingleInstanceRestart/HAsingleInstanceRestart.params
+++ b/TestON/tests/HA/HAsingleInstanceRestart/HAsingleInstanceRestart.params
@@ -14,6 +14,8 @@
#CASE13: Clean up
#CASE14: start election app on all onos nodes
#CASE15: Check that Leadership Election is still functional
+ #CASE16: Install Distributed Primitives app
+ #CASE17: Check for basic functionality with distributed primitives
<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>
<apps></apps>
diff --git a/TestON/tests/HA/HAsingleInstanceRestart/HAsingleInstanceRestart.py b/TestON/tests/HA/HAsingleInstanceRestart/HAsingleInstanceRestart.py
index 4d8eedc..4f15a60 100644
--- a/TestON/tests/HA/HAsingleInstanceRestart/HAsingleInstanceRestart.py
+++ b/TestON/tests/HA/HAsingleInstanceRestart/HAsingleInstanceRestart.py
@@ -2260,7 +2260,7 @@
# verify leader didn't just change
# Get new leaders and candidates
reRunLeaders = []
- time.sleep( 5 ) # Paremterize
+ time.sleep( 5 ) # Paremterize
positionResult, reRunLeaders = main.HA.consistentLeaderboards( activeCLIs )
# Check that the re-elected node is last on the candidate List
@@ -2289,14 +2289,10 @@
assert main.nodes, "main.nodes not defined"
# Variables for the distributed primitives tests
- global pCounterName
- global pCounterValue
- global onosSet
- global onosSetName
- pCounterName = "TestON-Partitions"
- pCounterValue = 0
- onosSet = set([])
- onosSetName = "TestON-set"
+ main.pCounterName = "TestON-Partitions"
+ main.pCounterValue = 0
+ main.onosSet = set([])
+ main.onosSetName = "TestON-set"
description = "Install Primitives app"
main.case( description )
@@ -2308,1159 +2304,11 @@
actual=appResults,
onpass="Primitives app activated",
onfail="Primitives app not activated" )
+ # TODO check on all nodes instead of sleeping
time.sleep( 5 ) # To allow all nodes to activate
def CASE17( self, main ):
"""
Check for basic functionality with distributed primitives
"""
- # Make sure variables are defined/set
- assert main.numCtrls, "main.numCtrls not defined"
- assert main, "main not defined"
- assert utilities.assert_equals, "utilities.assert_equals not defined"
- assert main.CLIs, "main.CLIs not defined"
- assert main.nodes, "main.nodes not defined"
- assert pCounterName, "pCounterName not defined"
- assert onosSetName, "onosSetName not defined"
- # NOTE: assert fails if value is 0/None/Empty/False
- try:
- pCounterValue
- except NameError:
- main.log.error( "pCounterValue not defined, setting to 0" )
- pCounterValue = 0
- try:
- onosSet
- except NameError:
- main.log.error( "onosSet not defined, setting to empty Set" )
- onosSet = set([])
- # Variables for the distributed primitives tests. These are local only
- addValue = "a"
- addAllValue = "a b c d e f"
- retainValue = "c d e f"
-
- 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"
- # DISTRIBUTED ATOMIC COUNTERS
- # Partitioned counters
- main.step( "Increment then get a default counter on each node" )
- pCounters = []
- threads = []
- addedPValues = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].counterTestAddAndGet,
- name="counterAddAndGet-" + str( i ),
- args=[ pCounterName ] )
- pCounterValue += 1
- 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 Increment a default counter on each node" )
- pCounters = []
- threads = []
- addedPValues = []
- for i in main.activeNodes:
- 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.HA.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 main.activeNodes:
- 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 main.activeNodes:
- 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 main.activeNodes:
- 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.HA.counterCheck( pCounterName, pCounterValue )
- utilities.assert_equals( expect=main.TRUE,
- 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 main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
-
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- utilities.assert_equals( expect=main.TRUE,
- actual=getResults,
- onpass="Set elements are correct",
- onfail="Set elements are incorrect" )
-
- main.step( "Distributed Set size" )
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
-
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- utilities.assert_equals( expect=main.TRUE,
- actual=sizeResults,
- onpass="Set sizes are correct",
- onfail="Set sizes are incorrect" )
-
- main.step( "Distributed Set add()" )
- onosSet.add( addValue )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAdd-" + str( i ),
- args=[ onosSetName, addValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addResults = main.FALSE
- else:
- # unexpected result
- addResults = main.FALSE
- if addResults != main.TRUE:
- main.log.error( "Error executing set add" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node + " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node + " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addResults = addResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addResults,
- onpass="Set add correct",
- onfail="Set add was incorrect" )
-
- main.step( "Distributed Set addAll()" )
- onosSet.update( addAllValue.split() )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAddAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addAllResults = main.FALSE
- else:
- # unexpected result
- addAllResults = main.FALSE
- if addAllResults != main.TRUE:
- main.log.error( "Error executing set addAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addAllResults = addAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addAllResults,
- onpass="Set addAll correct",
- onfail="Set addAll was incorrect" )
-
- main.step( "Distributed Set contains()" )
- containsResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setContains-" + str( i ),
- args=[ onosSetName ],
- kwargs={ "values": addValue } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- # NOTE: This is the tuple
- containsResponses.append( t.result )
-
- containsResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if containsResponses[ i ] == main.ERROR:
- containsResults = main.FALSE
- else:
- containsResults = containsResults and\
- containsResponses[ i ][ 1 ]
- utilities.assert_equals( expect=main.TRUE,
- actual=containsResults,
- onpass="Set contains is functional",
- onfail="Set contains failed" )
-
- main.step( "Distributed Set containsAll()" )
- containsAllResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setContainsAll-" + str( i ),
- args=[ onosSetName ],
- kwargs={ "values": addAllValue } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- # NOTE: This is the tuple
- containsAllResponses.append( t.result )
-
- containsAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if containsResponses[ i ] == main.ERROR:
- containsResults = main.FALSE
- else:
- containsResults = containsResults and\
- containsResponses[ i ][ 1 ]
- utilities.assert_equals( expect=main.TRUE,
- actual=containsAllResults,
- onpass="Set containsAll is functional",
- onfail="Set containsAll failed" )
-
- main.step( "Distributed Set remove()" )
- onosSet.remove( addValue )
- removeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestRemove-" + str( i ),
- args=[ onosSetName, addValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- removeResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- removeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if removeResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif removeResponses[ i ] == main.FALSE:
- # not in set, probably fine
- pass
- elif removeResponses[ i ] == main.ERROR:
- # Error in execution
- removeResults = main.FALSE
- else:
- # unexpected result
- removeResults = main.FALSE
- if removeResults != main.TRUE:
- main.log.error( "Error executing set remove" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- removeResults = removeResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=removeResults,
- onpass="Set remove correct",
- onfail="Set remove was incorrect" )
-
- main.step( "Distributed Set removeAll()" )
- onosSet.difference_update( addAllValue.split() )
- removeAllResponses = []
- threads = []
- try:
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestRemoveAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- removeAllResponses.append( t.result )
- except Exception, e:
- main.log.exception(e)
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- removeAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if removeAllResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif removeAllResponses[ i ] == main.FALSE:
- # not in set, probably fine
- pass
- elif removeAllResponses[ i ] == main.ERROR:
- # Error in execution
- removeAllResults = main.FALSE
- else:
- # unexpected result
- removeAllResults = main.FALSE
- if removeAllResults != main.TRUE:
- main.log.error( "Error executing set removeAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- removeAllResults = removeAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=removeAllResults,
- onpass="Set removeAll correct",
- onfail="Set removeAll was incorrect" )
-
- main.step( "Distributed Set addAll()" )
- onosSet.update( addAllValue.split() )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAddAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addAllResults = main.FALSE
- else:
- # unexpected result
- addAllResults = main.FALSE
- if addAllResults != main.TRUE:
- main.log.error( "Error executing set addAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addAllResults = addAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addAllResults,
- onpass="Set addAll correct",
- onfail="Set addAll was incorrect" )
-
- main.step( "Distributed Set clear()" )
- onosSet.clear()
- clearResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestClear-" + str( i ),
- args=[ onosSetName, " "], # Values doesn't matter
- kwargs={ "clear": True } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- clearResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- clearResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if clearResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif clearResponses[ i ] == main.FALSE:
- # Nothing set, probably fine
- pass
- elif clearResponses[ i ] == main.ERROR:
- # Error in execution
- clearResults = main.FALSE
- else:
- # unexpected result
- clearResults = main.FALSE
- if clearResults != main.TRUE:
- main.log.error( "Error executing set clear" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- clearResults = clearResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=clearResults,
- onpass="Set clear correct",
- onfail="Set clear was incorrect" )
-
- main.step( "Distributed Set addAll()" )
- onosSet.update( addAllValue.split() )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAddAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addAllResults = main.FALSE
- else:
- # unexpected result
- addAllResults = main.FALSE
- if addAllResults != main.TRUE:
- main.log.error( "Error executing set addAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addAllResults = addAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addAllResults,
- onpass="Set addAll correct",
- onfail="Set addAll was incorrect" )
-
- main.step( "Distributed Set retain()" )
- onosSet.intersection_update( retainValue.split() )
- retainResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestRetain-" + str( i ),
- args=[ onosSetName, retainValue ],
- kwargs={ "retain": True } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- retainResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- retainResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if retainResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif retainResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif retainResponses[ i ] == main.ERROR:
- # Error in execution
- retainResults = main.FALSE
- else:
- # unexpected result
- retainResults = main.FALSE
- if retainResults != main.TRUE:
- main.log.error( "Error executing set retain" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node + " expected a size of " +
- str( size ) + " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- retainResults = retainResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=retainResults,
- onpass="Set retain correct",
- onfail="Set retain was incorrect" )
-
- # Transactional maps
- main.step( "Partitioned Transactional maps put" )
- tMapValue = "Testing"
- numKeys = 100
- putResult = True
- node = main.activeNodes[0]
- putResponses = main.CLIs[node].transactionalMapPut( numKeys, tMapValue )
- if putResponses and len( putResponses ) == 100:
- for i in putResponses:
- if putResponses[ i ][ 'value' ] != tMapValue:
- putResult = False
- else:
- putResult = False
- if not putResult:
- main.log.debug( "Put response values: " + str( putResponses ) )
- utilities.assert_equals( expect=True,
- actual=putResult,
- onpass="Partitioned Transactional Map put successful",
- onfail="Partitioned Transactional Map put values are incorrect" )
-
- main.step( "Partitioned Transactional maps get" )
- # FIXME: is this sleep needed?
- time.sleep( 5 )
-
- getCheck = True
- for n in range( 1, numKeys + 1 ):
- getResponses = []
- threads = []
- valueCheck = True
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].transactionalMapGet,
- name="TMap-get-" + str( i ),
- args=[ "Key" + str( n ) ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- for node in getResponses:
- if node != tMapValue:
- valueCheck = False
- if not valueCheck:
- main.log.warn( "Values for key 'Key" + str( n ) + "' do not match:" )
- main.log.warn( getResponses )
- getCheck = getCheck and valueCheck
- utilities.assert_equals( expect=True,
- actual=getCheck,
- onpass="Partitioned Transactional Map get values were correct",
- onfail="Partitioned Transactional Map values incorrect" )
+ main.HA.CASE17( main )
diff --git a/TestON/tests/HA/HAstopNodes/HAstopNodes.py b/TestON/tests/HA/HAstopNodes/HAstopNodes.py
index b6a74e5..6c32b16 100644
--- a/TestON/tests/HA/HAstopNodes/HAstopNodes.py
+++ b/TestON/tests/HA/HAstopNodes/HAstopNodes.py
@@ -3089,7 +3089,7 @@
# verify leader didn't just change
# Get new leaders and candidates
reRunLeaders = []
- time.sleep( 5 ) # Paremterize
+ time.sleep( 5 ) # Paremterize
positionResult, reRunLeaders = main.HA.consistentLeaderboards( activeCLIs )
# Check that the re-elected node is last on the candidate List
@@ -3118,14 +3118,10 @@
assert main.nodes, "main.nodes not defined"
# Variables for the distributed primitives tests
- global pCounterName
- global pCounterValue
- global onosSet
- global onosSetName
- pCounterName = "TestON-Partitions"
- pCounterValue = 0
- onosSet = set([])
- onosSetName = "TestON-set"
+ main.pCounterName = "TestON-Partitions"
+ main.pCounterValue = 0
+ main.onosSet = set([])
+ main.onosSetName = "TestON-set"
description = "Install Primitives app"
main.case( description )
@@ -3143,1153 +3139,4 @@
"""
Check for basic functionality with distributed primitives
"""
- # Make sure variables are defined/set
- assert main.numCtrls, "main.numCtrls not defined"
- assert main, "main not defined"
- assert utilities.assert_equals, "utilities.assert_equals not defined"
- assert main.CLIs, "main.CLIs not defined"
- assert main.nodes, "main.nodes not defined"
- assert pCounterName, "pCounterName not defined"
- assert onosSetName, "onosSetName not defined"
- # NOTE: assert fails if value is 0/None/Empty/False
- try:
- pCounterValue
- except NameError:
- main.log.error( "pCounterValue not defined, setting to 0" )
- pCounterValue = 0
- try:
- onosSet
- except NameError:
- main.log.error( "onosSet not defined, setting to empty Set" )
- onosSet = set([])
- # Variables for the distributed primitives tests. These are local only
- addValue = "a"
- addAllValue = "a b c d e f"
- retainValue = "c d e f"
-
- 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"
- # DISTRIBUTED ATOMIC COUNTERS
- # Partitioned counters
- main.step( "Increment then get a default counter on each node" )
- pCounters = []
- threads = []
- addedPValues = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].counterTestAddAndGet,
- name="counterAddAndGet-" + str( i ),
- args=[ pCounterName ] )
- pCounterValue += 1
- 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 Increment a default counter on each node" )
- pCounters = []
- threads = []
- addedPValues = []
- for i in main.activeNodes:
- 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.HA.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 main.activeNodes:
- 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 main.activeNodes:
- 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 main.activeNodes:
- 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.HA.counterCheck( pCounterName, pCounterValue )
- utilities.assert_equals( expect=main.TRUE,
- 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 main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
-
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- utilities.assert_equals( expect=main.TRUE,
- actual=getResults,
- onpass="Set elements are correct",
- onfail="Set elements are incorrect" )
-
- main.step( "Distributed Set size" )
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
-
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- utilities.assert_equals( expect=main.TRUE,
- actual=sizeResults,
- onpass="Set sizes are correct",
- onfail="Set sizes are incorrect" )
-
- main.step( "Distributed Set add()" )
- onosSet.add( addValue )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAdd-" + str( i ),
- args=[ onosSetName, addValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addResults = main.FALSE
- else:
- # unexpected result
- addResults = main.FALSE
- if addResults != main.TRUE:
- main.log.error( "Error executing set add" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node + " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node + " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addResults = addResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addResults,
- onpass="Set add correct",
- onfail="Set add was incorrect" )
-
- main.step( "Distributed Set addAll()" )
- onosSet.update( addAllValue.split() )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAddAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addAllResults = main.FALSE
- else:
- # unexpected result
- addAllResults = main.FALSE
- if addAllResults != main.TRUE:
- main.log.error( "Error executing set addAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addAllResults = addAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addAllResults,
- onpass="Set addAll correct",
- onfail="Set addAll was incorrect" )
-
- main.step( "Distributed Set contains()" )
- containsResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setContains-" + str( i ),
- args=[ onosSetName ],
- kwargs={ "values": addValue } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- # NOTE: This is the tuple
- containsResponses.append( t.result )
-
- containsResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if containsResponses[ i ] == main.ERROR:
- containsResults = main.FALSE
- else:
- containsResults = containsResults and\
- containsResponses[ i ][ 1 ]
- utilities.assert_equals( expect=main.TRUE,
- actual=containsResults,
- onpass="Set contains is functional",
- onfail="Set contains failed" )
-
- main.step( "Distributed Set containsAll()" )
- containsAllResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setContainsAll-" + str( i ),
- args=[ onosSetName ],
- kwargs={ "values": addAllValue } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- # NOTE: This is the tuple
- containsAllResponses.append( t.result )
-
- containsAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if containsResponses[ i ] == main.ERROR:
- containsResults = main.FALSE
- else:
- containsResults = containsResults and\
- containsResponses[ i ][ 1 ]
- utilities.assert_equals( expect=main.TRUE,
- actual=containsAllResults,
- onpass="Set containsAll is functional",
- onfail="Set containsAll failed" )
-
- main.step( "Distributed Set remove()" )
- onosSet.remove( addValue )
- removeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestRemove-" + str( i ),
- args=[ onosSetName, addValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- removeResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- removeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if removeResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif removeResponses[ i ] == main.FALSE:
- # not in set, probably fine
- pass
- elif removeResponses[ i ] == main.ERROR:
- # Error in execution
- removeResults = main.FALSE
- else:
- # unexpected result
- removeResults = main.FALSE
- if removeResults != main.TRUE:
- main.log.error( "Error executing set remove" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- removeResults = removeResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=removeResults,
- onpass="Set remove correct",
- onfail="Set remove was incorrect" )
-
- main.step( "Distributed Set removeAll()" )
- onosSet.difference_update( addAllValue.split() )
- removeAllResponses = []
- threads = []
- try:
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestRemoveAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- removeAllResponses.append( t.result )
- except Exception, e:
- main.log.exception(e)
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- removeAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if removeAllResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif removeAllResponses[ i ] == main.FALSE:
- # not in set, probably fine
- pass
- elif removeAllResponses[ i ] == main.ERROR:
- # Error in execution
- removeAllResults = main.FALSE
- else:
- # unexpected result
- removeAllResults = main.FALSE
- if removeAllResults != main.TRUE:
- main.log.error( "Error executing set removeAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- removeAllResults = removeAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=removeAllResults,
- onpass="Set removeAll correct",
- onfail="Set removeAll was incorrect" )
-
- main.step( "Distributed Set addAll()" )
- onosSet.update( addAllValue.split() )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAddAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addAllResults = main.FALSE
- else:
- # unexpected result
- addAllResults = main.FALSE
- if addAllResults != main.TRUE:
- main.log.error( "Error executing set addAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addAllResults = addAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addAllResults,
- onpass="Set addAll correct",
- onfail="Set addAll was incorrect" )
-
- main.step( "Distributed Set clear()" )
- onosSet.clear()
- clearResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestClear-" + str( i ),
- args=[ onosSetName, " "], # Values doesn't matter
- kwargs={ "clear": True } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- clearResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- clearResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if clearResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif clearResponses[ i ] == main.FALSE:
- # Nothing set, probably fine
- pass
- elif clearResponses[ i ] == main.ERROR:
- # Error in execution
- clearResults = main.FALSE
- else:
- # unexpected result
- clearResults = main.FALSE
- if clearResults != main.TRUE:
- main.log.error( "Error executing set clear" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- clearResults = clearResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=clearResults,
- onpass="Set clear correct",
- onfail="Set clear was incorrect" )
-
- main.step( "Distributed Set addAll()" )
- onosSet.update( addAllValue.split() )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAddAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addAllResults = main.FALSE
- else:
- # unexpected result
- addAllResults = main.FALSE
- if addAllResults != main.TRUE:
- main.log.error( "Error executing set addAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addAllResults = addAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addAllResults,
- onpass="Set addAll correct",
- onfail="Set addAll was incorrect" )
-
- main.step( "Distributed Set retain()" )
- onosSet.intersection_update( retainValue.split() )
- retainResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestRetain-" + str( i ),
- args=[ onosSetName, retainValue ],
- kwargs={ "retain": True } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- retainResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- retainResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if retainResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif retainResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif retainResponses[ i ] == main.ERROR:
- # Error in execution
- retainResults = main.FALSE
- else:
- # unexpected result
- retainResults = main.FALSE
- if retainResults != main.TRUE:
- main.log.error( "Error executing set retain" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node + " expected a size of " +
- str( size ) + " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- retainResults = retainResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=retainResults,
- onpass="Set retain correct",
- onfail="Set retain was incorrect" )
-
- # Transactional maps
- main.step( "Partitioned Transactional maps put" )
- tMapValue = "Testing"
- numKeys = 100
- putResult = True
- node = main.activeNodes[0]
- putResponses = main.CLIs[node].transactionalMapPut( numKeys, tMapValue )
- if putResponses and len( putResponses ) == 100:
- for i in putResponses:
- if putResponses[ i ][ 'value' ] != tMapValue:
- putResult = False
- else:
- putResult = False
- if not putResult:
- main.log.debug( "Put response values: " + str( putResponses ) )
- utilities.assert_equals( expect=True,
- actual=putResult,
- onpass="Partitioned Transactional Map put successful",
- onfail="Partitioned Transactional Map put values are incorrect" )
-
- main.step( "Partitioned Transactional maps get" )
- # FIXME: is this sleep needed?
- time.sleep( 5 )
-
- getCheck = True
- for n in range( 1, numKeys + 1 ):
- getResponses = []
- threads = []
- valueCheck = True
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].transactionalMapGet,
- name="TMap-get-" + str( i ),
- args=[ "Key" + str( n ) ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- for node in getResponses:
- if node != tMapValue:
- valueCheck = False
- if not valueCheck:
- main.log.warn( "Values for key 'Key" + str( n ) + "' do not match:" )
- main.log.warn( getResponses )
- getCheck = getCheck and valueCheck
- utilities.assert_equals( expect=True,
- actual=getCheck,
- onpass="Partitioned Transactional Map get values were correct",
- onfail="Partitioned Transactional Map values incorrect" )
+ main.HA.CASE17( main )
diff --git a/TestON/tests/HA/HAswapNodes/HAswapNodes.py b/TestON/tests/HA/HAswapNodes/HAswapNodes.py
index 1be977a..8f2b58c 100644
--- a/TestON/tests/HA/HAswapNodes/HAswapNodes.py
+++ b/TestON/tests/HA/HAswapNodes/HAswapNodes.py
@@ -3053,7 +3053,7 @@
if newLeader == oldLeader:
newLeaderResult = False
main.log.error( "All nodes still see old leader: " + str( oldLeader ) +
- " as the current leader" )
+ " as the current leader" )
utilities.assert_equals(
expect=True,
actual=newLeaderResult,
@@ -3135,14 +3135,10 @@
assert main.nodes, "main.nodes not defined"
# Variables for the distributed primitives tests
- global pCounterName
- global pCounterValue
- global onosSet
- global onosSetName
- pCounterName = "TestON-Partitions"
- pCounterValue = 0
- onosSet = set([])
- onosSetName = "TestON-set"
+ main.pCounterName = "TestON-Partitions"
+ main.pCounterValue = 0
+ main.onosSet = set([])
+ main.onosSetName = "TestON-set"
description = "Install Primitives app"
main.case( description )
@@ -3160,1150 +3156,4 @@
"""
Check for basic functionality with distributed primitives
"""
- # Make sure variables are defined/set
- assert main.numCtrls, "main.numCtrls not defined"
- assert main, "main not defined"
- assert utilities.assert_equals, "utilities.assert_equals not defined"
- assert main.CLIs, "main.CLIs not defined"
- assert main.nodes, "main.nodes not defined"
- assert pCounterName, "pCounterName not defined"
- assert onosSetName, "onosSetName not defined"
- # NOTE: assert fails if value is 0/None/Empty/False
- try:
- pCounterValue
- except NameError:
- main.log.error( "pCounterValue not defined, setting to 0" )
- pCounterValue = 0
- try:
- onosSet
- except NameError:
- main.log.error( "onosSet not defined, setting to empty Set" )
- onosSet = set([])
- # Variables for the distributed primitives tests. These are local only
- addValue = "a"
- addAllValue = "a b c d e f"
- retainValue = "c d e f"
-
- 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"
- # DISTRIBUTED ATOMIC COUNTERS
- # Partitioned counters
- main.step( "Increment then get a default counter on each node" )
- pCounters = []
- threads = []
- addedPValues = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].counterTestAddAndGet,
- name="counterAddAndGet-" + str( i ),
- args=[ pCounterName ] )
- pCounterValue += 1
- 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 Increment a default counter on each node" )
- pCounters = []
- threads = []
- addedPValues = []
- for i in main.activeNodes:
- 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.HA.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 main.activeNodes:
- 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 main.activeNodes:
- 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 main.activeNodes:
- 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.HA.counterCheck( pCounterName, pCounterValue )
- utilities.assert_equals( expect=main.TRUE,
- 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 main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
-
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- utilities.assert_equals( expect=main.TRUE,
- actual=getResults,
- onpass="Set elements are correct",
- onfail="Set elements are incorrect" )
-
- main.step( "Distributed Set size" )
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
-
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- utilities.assert_equals( expect=main.TRUE,
- actual=sizeResults,
- onpass="Set sizes are correct",
- onfail="Set sizes are incorrect" )
-
- main.step( "Distributed Set add()" )
- onosSet.add( addValue )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAdd-" + str( i ),
- args=[ onosSetName, addValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addResults = main.FALSE
- else:
- # unexpected result
- addResults = main.FALSE
- if addResults != main.TRUE:
- main.log.error( "Error executing set add" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node + " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node + " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addResults = addResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addResults,
- onpass="Set add correct",
- onfail="Set add was incorrect" )
-
- main.step( "Distributed Set addAll()" )
- onosSet.update( addAllValue.split() )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAddAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addAllResults = main.FALSE
- else:
- # unexpected result
- addAllResults = main.FALSE
- if addAllResults != main.TRUE:
- main.log.error( "Error executing set addAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addAllResults = addAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addAllResults,
- onpass="Set addAll correct",
- onfail="Set addAll was incorrect" )
-
- main.step( "Distributed Set contains()" )
- containsResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setContains-" + str( i ),
- args=[ onosSetName ],
- kwargs={ "values": addValue } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- # NOTE: This is the tuple
- containsResponses.append( t.result )
-
- containsResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if containsResponses[ i ] == main.ERROR:
- containsResults = main.FALSE
- else:
- containsResults = containsResults and\
- containsResponses[ i ][ 1 ]
- utilities.assert_equals( expect=main.TRUE,
- actual=containsResults,
- onpass="Set contains is functional",
- onfail="Set contains failed" )
-
- main.step( "Distributed Set containsAll()" )
- containsAllResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setContainsAll-" + str( i ),
- args=[ onosSetName ],
- kwargs={ "values": addAllValue } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- # NOTE: This is the tuple
- containsAllResponses.append( t.result )
-
- containsAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if containsResponses[ i ] == main.ERROR:
- containsResults = main.FALSE
- else:
- containsResults = containsResults and\
- containsResponses[ i ][ 1 ]
- utilities.assert_equals( expect=main.TRUE,
- actual=containsAllResults,
- onpass="Set containsAll is functional",
- onfail="Set containsAll failed" )
-
- main.step( "Distributed Set remove()" )
- onosSet.remove( addValue )
- removeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestRemove-" + str( i ),
- args=[ onosSetName, addValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- removeResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- removeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if removeResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif removeResponses[ i ] == main.FALSE:
- # not in set, probably fine
- pass
- elif removeResponses[ i ] == main.ERROR:
- # Error in execution
- removeResults = main.FALSE
- else:
- # unexpected result
- removeResults = main.FALSE
- if removeResults != main.TRUE:
- main.log.error( "Error executing set remove" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- removeResults = removeResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=removeResults,
- onpass="Set remove correct",
- onfail="Set remove was incorrect" )
-
- main.step( "Distributed Set removeAll()" )
- onosSet.difference_update( addAllValue.split() )
- removeAllResponses = []
- threads = []
- try:
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestRemoveAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- removeAllResponses.append( t.result )
- except Exception, e:
- main.log.exception(e)
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- removeAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if removeAllResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif removeAllResponses[ i ] == main.FALSE:
- # not in set, probably fine
- pass
- elif removeAllResponses[ i ] == main.ERROR:
- # Error in execution
- removeAllResults = main.FALSE
- else:
- # unexpected result
- removeAllResults = main.FALSE
- if removeAllResults != main.TRUE:
- main.log.error( "Error executing set removeAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- removeAllResults = removeAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=removeAllResults,
- onpass="Set removeAll correct",
- onfail="Set removeAll was incorrect" )
-
- main.step( "Distributed Set addAll()" )
- onosSet.update( addAllValue.split() )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAddAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addAllResults = main.FALSE
- else:
- # unexpected result
- addAllResults = main.FALSE
- if addAllResults != main.TRUE:
- main.log.error( "Error executing set addAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addAllResults = addAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addAllResults,
- onpass="Set addAll correct",
- onfail="Set addAll was incorrect" )
-
- main.step( "Distributed Set clear()" )
- onosSet.clear()
- clearResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestClear-" + str( i ),
- args=[ onosSetName, " "], # Values doesn't matter
- kwargs={ "clear": True } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- clearResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- clearResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if clearResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif clearResponses[ i ] == main.FALSE:
- # Nothing set, probably fine
- pass
- elif clearResponses[ i ] == main.ERROR:
- # Error in execution
- clearResults = main.FALSE
- else:
- # unexpected result
- clearResults = main.FALSE
- if clearResults != main.TRUE:
- main.log.error( "Error executing set clear" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- clearResults = clearResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=clearResults,
- onpass="Set clear correct",
- onfail="Set clear was incorrect" )
-
- main.step( "Distributed Set addAll()" )
- onosSet.update( addAllValue.split() )
- addResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestAdd,
- name="setTestAddAll-" + str( i ),
- args=[ onosSetName, addAllValue ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- addResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- addAllResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if addResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif addResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif addResponses[ i ] == main.ERROR:
- # Error in execution
- addAllResults = main.FALSE
- else:
- # unexpected result
- addAllResults = main.FALSE
- if addAllResults != main.TRUE:
- main.log.error( "Error executing set addAll" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node +
- " expected a size of " + str( size ) +
- " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- addAllResults = addAllResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=addAllResults,
- onpass="Set addAll correct",
- onfail="Set addAll was incorrect" )
-
- main.step( "Distributed Set retain()" )
- onosSet.intersection_update( retainValue.split() )
- retainResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestRemove,
- name="setTestRetain-" + str( i ),
- args=[ onosSetName, retainValue ],
- kwargs={ "retain": True } )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- retainResponses.append( t.result )
-
- # main.TRUE = successfully changed the set
- # main.FALSE = action resulted in no change in set
- # main.ERROR - Some error in executing the function
- retainResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- if retainResponses[ i ] == main.TRUE:
- # All is well
- pass
- elif retainResponses[ i ] == main.FALSE:
- # Already in set, probably fine
- pass
- elif retainResponses[ i ] == main.ERROR:
- # Error in execution
- retainResults = main.FALSE
- else:
- # unexpected result
- retainResults = main.FALSE
- if retainResults != main.TRUE:
- main.log.error( "Error executing set retain" )
-
- # Check if set is still correct
- size = len( onosSet )
- getResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestGet,
- name="setTestGet-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- getResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if isinstance( getResponses[ i ], list):
- current = set( getResponses[ i ] )
- if len( current ) == len( getResponses[ i ] ):
- # no repeats
- if onosSet != current:
- main.log.error( "ONOS" + node +
- " has incorrect view" +
- " of set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- main.log.debug( "Expected: " + str( onosSet ) )
- main.log.debug( "Actual: " + str( current ) )
- getResults = main.FALSE
- else:
- # error, set is not a set
- main.log.error( "ONOS" + node +
- " has repeat elements in" +
- " set " + onosSetName + ":\n" +
- str( getResponses[ i ] ) )
- getResults = main.FALSE
- elif getResponses[ i ] == main.ERROR:
- getResults = main.FALSE
- sizeResponses = []
- threads = []
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].setTestSize,
- name="setTestSize-" + str( i ),
- args=[ onosSetName ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- sizeResponses.append( t.result )
- sizeResults = main.TRUE
- for i in range( len( main.activeNodes ) ):
- node = str( main.activeNodes[i] + 1 )
- if size != sizeResponses[ i ]:
- sizeResults = main.FALSE
- main.log.error( "ONOS" + node + " expected a size of " +
- str( size ) + " for set " + onosSetName +
- " but got " + str( sizeResponses[ i ] ) )
- retainResults = retainResults and getResults and sizeResults
- utilities.assert_equals( expect=main.TRUE,
- actual=retainResults,
- onpass="Set retain correct",
- onfail="Set retain was incorrect" )
-
- # Transactional maps
- main.step( "Partitioned Transactional maps put" )
- tMapValue = "Testing"
- numKeys = 100
- putResult = True
- node = main.activeNodes[0]
- putResponses = main.CLIs[node].transactionalMapPut( numKeys, tMapValue )
- if putResponses and len( putResponses ) == 100:
- for i in putResponses:
- if putResponses[ i ][ 'value' ] != tMapValue:
- putResult = False
- else:
- putResult = False
- if not putResult:
- main.log.debug( "Put response values: " + str( putResponses ) )
- utilities.assert_equals( expect=True,
- actual=putResult,
- onpass="Partitioned Transactional Map put successful",
- onfail="Partitioned Transactional Map put values are incorrect" )
-
- main.step( "Partitioned Transactional maps get" )
- getCheck = True
- for n in range( 1, numKeys + 1 ):
- getResponses = []
- threads = []
- valueCheck = True
- for i in main.activeNodes:
- t = main.Thread( target=main.CLIs[i].transactionalMapGet,
- name="TMap-get-" + str( i ),
- args=[ "Key" + str( n ) ] )
- threads.append( t )
- t.start()
- for t in threads:
- t.join()
- getResponses.append( t.result )
- for node in getResponses:
- if node != tMapValue:
- valueCheck = False
- if not valueCheck:
- main.log.warn( "Values for key 'Key" + str( n ) + "' do not match:" )
- main.log.warn( getResponses )
- getCheck = getCheck and valueCheck
- utilities.assert_equals( expect=True,
- actual=getCheck,
- onpass="Partitioned Transactional Map get values were correct",
- onfail="Partitioned Transactional Map values incorrect" )
+ main.HA.CASE17( main )
diff --git a/TestON/tests/HA/dependencies/HA.py b/TestON/tests/HA/dependencies/HA.py
index e00d290..b6c6f26 100644
--- a/TestON/tests/HA/dependencies/HA.py
+++ b/TestON/tests/HA/dependencies/HA.py
@@ -159,3 +159,1368 @@
currentResult = False
results = results and currentResult
return results
+
+ def CASE17( self, main ):
+ """
+ Check for basic functionality with distributed primitives
+ """
+ #TODO: Clean this up so it's not just a cut/paste from the test
+ try:
+ # Make sure variables are defined/set
+ assert main.numCtrls, "main.numCtrls not defined"
+ assert utilities.assert_equals, "utilities.assert_equals not defined"
+ assert main.CLIs, "main.CLIs not defined"
+ assert main.nodes, "main.nodes not defined"
+ assert main.pCounterName, "main.pCounterName not defined"
+ assert main.onosSetName, "main.onosSetName not defined"
+ # NOTE: assert fails if value is 0/None/Empty/False
+ try:
+ main.pCounterValue
+ except NameError:
+ main.log.error( "main.pCounterValue not defined, setting to 0" )
+ main.pCounterValue = 0
+ try:
+ main.onosSet
+ except NameError:
+ main.log.error( "main.onosSet not defined, setting to empty Set" )
+ main.onosSet = set([])
+ # Variables for the distributed primitives tests. These are local only
+ addValue = "a"
+ addAllValue = "a b c d e f"
+ retainValue = "c d e f"
+ valueName = "TestOn-Value"
+ valueValue = None
+
+ 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"
+ # DISTRIBUTED ATOMIC COUNTERS
+ # Partitioned counters
+ main.step( "Increment then get a default counter on each node" )
+ pCounters = []
+ threads = []
+ addedPValues = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].counterTestAddAndGet,
+ name="counterAddAndGet-" + str( i ),
+ args=[ main.pCounterName ] )
+ main.pCounterValue += 1
+ addedPValues.append( main.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 Increment a default counter on each node" )
+ pCounters = []
+ threads = []
+ addedPValues = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].counterTestGetAndAdd,
+ name="counterGetAndAdd-" + str( i ),
+ args=[ main.pCounterName ] )
+ addedPValues.append( main.pCounterValue )
+ main.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.HA.counterCheck( main.pCounterName, main.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 main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].counterTestAddAndGet,
+ name="counterIncrement-" + str( i ),
+ args=[ main.pCounterName ],
+ kwargs={ "delta": -8 } )
+ main.pCounterValue += -8
+ addedPValues.append( main.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 main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].counterTestAddAndGet,
+ name="counterIncrement-" + str( i ),
+ args=[ main.pCounterName ],
+ kwargs={ "delta": 5 } )
+ main.pCounterValue += 5
+ addedPValues.append( main.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 main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].counterTestGetAndAdd,
+ name="counterIncrement-" + str( i ),
+ args=[ main.pCounterName ],
+ kwargs={ "delta": 5 } )
+ addedPValues.append( main.pCounterValue )
+ main.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.HA.counterCheck( main.pCounterName, main.pCounterValue )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=incrementCheck,
+ onpass="Added counters are correct",
+ onfail="Added counters are incorrect" )
+
+ # DISTRIBUTED SETS
+ main.step( "Distributed Set get" )
+ size = len( main.onosSet )
+ getResponses = []
+ threads = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ main.onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+
+ getResults = main.TRUE
+ for i in range( len( main.activeNodes ) ):
+ node = str( main.activeNodes[i] + 1 )
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if main.onosSet != current:
+ main.log.error( "ONOS" + node +
+ " has incorrect view" +
+ " of set " + main.onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( main.onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + node +
+ " has repeat elements in" +
+ " set " + main.onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ utilities.assert_equals( expect=main.TRUE,
+ actual=getResults,
+ onpass="Set elements are correct",
+ onfail="Set elements are incorrect" )
+
+ main.step( "Distributed Set size" )
+ sizeResponses = []
+ threads = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ main.onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+
+ sizeResults = main.TRUE
+ for i in range( len( main.activeNodes ) ):
+ node = str( main.activeNodes[i] + 1 )
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + node +
+ " expected a size of " + str( size ) +
+ " for set " + main.onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=sizeResults,
+ onpass="Set sizes are correct",
+ onfail="Set sizes are incorrect" )
+
+ main.step( "Distributed Set add()" )
+ main.onosSet.add( addValue )
+ addResponses = []
+ threads = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].setTestAdd,
+ name="setTestAdd-" + str( i ),
+ args=[ main.onosSetName, addValue ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ addResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ addResults = main.TRUE
+ for i in range( len( main.activeNodes ) ):
+ if addResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif addResponses[ i ] == main.FALSE:
+ # Already in set, probably fine
+ pass
+ elif addResponses[ i ] == main.ERROR:
+ # Error in execution
+ addResults = main.FALSE
+ else:
+ # unexpected result
+ addResults = main.FALSE
+ if addResults != main.TRUE:
+ main.log.error( "Error executing set add" )
+
+ # Check if set is still correct
+ size = len( main.onosSet )
+ getResponses = []
+ threads = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ main.onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( len( main.activeNodes ) ):
+ node = str( main.activeNodes[i] + 1 )
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if main.onosSet != current:
+ main.log.error( "ONOS" + node + " has incorrect view" +
+ " of set " + main.onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( main.onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + node + " has repeat elements in" +
+ " set " + main.onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ main.onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( len( main.activeNodes ) ):
+ node = str( main.activeNodes[i] + 1 )
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + node +
+ " expected a size of " + str( size ) +
+ " for set " + main.onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ addResults = addResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=addResults,
+ onpass="Set add correct",
+ onfail="Set add was incorrect" )
+
+ main.step( "Distributed Set addAll()" )
+ main.onosSet.update( addAllValue.split() )
+ addResponses = []
+ threads = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].setTestAdd,
+ name="setTestAddAll-" + str( i ),
+ args=[ main.onosSetName, addAllValue ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ addResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ addAllResults = main.TRUE
+ for i in range( len( main.activeNodes ) ):
+ if addResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif addResponses[ i ] == main.FALSE:
+ # Already in set, probably fine
+ pass
+ elif addResponses[ i ] == main.ERROR:
+ # Error in execution
+ addAllResults = main.FALSE
+ else:
+ # unexpected result
+ addAllResults = main.FALSE
+ if addAllResults != main.TRUE:
+ main.log.error( "Error executing set addAll" )
+
+ # Check if set is still correct
+ size = len( main.onosSet )
+ getResponses = []
+ threads = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ main.onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( len( main.activeNodes ) ):
+ node = str( main.activeNodes[i] + 1 )
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if main.onosSet != current:
+ main.log.error( "ONOS" + node +
+ " has incorrect view" +
+ " of set " + main.onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( main.onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + node +
+ " has repeat elements in" +
+ " set " + main.onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ main.onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( len( main.activeNodes ) ):
+ node = str( main.activeNodes[i] + 1 )
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + node +
+ " expected a size of " + str( size ) +
+ " for set " + main.onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ addAllResults = addAllResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=addAllResults,
+ onpass="Set addAll correct",
+ onfail="Set addAll was incorrect" )
+
+ main.step( "Distributed Set contains()" )
+ containsResponses = []
+ threads = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].setTestGet,
+ name="setContains-" + str( i ),
+ args=[ main.onosSetName ],
+ kwargs={ "values": addValue } )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ # NOTE: This is the tuple
+ containsResponses.append( t.result )
+
+ containsResults = main.TRUE
+ for i in range( len( main.activeNodes ) ):
+ if containsResponses[ i ] == main.ERROR:
+ containsResults = main.FALSE
+ else:
+ containsResults = containsResults and\
+ containsResponses[ i ][ 1 ]
+ utilities.assert_equals( expect=main.TRUE,
+ actual=containsResults,
+ onpass="Set contains is functional",
+ onfail="Set contains failed" )
+
+ main.step( "Distributed Set containsAll()" )
+ containsAllResponses = []
+ threads = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].setTestGet,
+ name="setContainsAll-" + str( i ),
+ args=[ main.onosSetName ],
+ kwargs={ "values": addAllValue } )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ # NOTE: This is the tuple
+ containsAllResponses.append( t.result )
+
+ containsAllResults = main.TRUE
+ for i in range( len( main.activeNodes ) ):
+ if containsResponses[ i ] == main.ERROR:
+ containsResults = main.FALSE
+ else:
+ containsResults = containsResults and\
+ containsResponses[ i ][ 1 ]
+ utilities.assert_equals( expect=main.TRUE,
+ actual=containsAllResults,
+ onpass="Set containsAll is functional",
+ onfail="Set containsAll failed" )
+
+ main.step( "Distributed Set remove()" )
+ main.onosSet.remove( addValue )
+ removeResponses = []
+ threads = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].setTestRemove,
+ name="setTestRemove-" + str( i ),
+ args=[ main.onosSetName, addValue ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ removeResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ removeResults = main.TRUE
+ for i in range( len( main.activeNodes ) ):
+ if removeResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif removeResponses[ i ] == main.FALSE:
+ # not in set, probably fine
+ pass
+ elif removeResponses[ i ] == main.ERROR:
+ # Error in execution
+ removeResults = main.FALSE
+ else:
+ # unexpected result
+ removeResults = main.FALSE
+ if removeResults != main.TRUE:
+ main.log.error( "Error executing set remove" )
+
+ # Check if set is still correct
+ size = len( main.onosSet )
+ getResponses = []
+ threads = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ main.onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( len( main.activeNodes ) ):
+ node = str( main.activeNodes[i] + 1 )
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if main.onosSet != current:
+ main.log.error( "ONOS" + node +
+ " has incorrect view" +
+ " of set " + main.onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( main.onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + node +
+ " has repeat elements in" +
+ " set " + main.onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ main.onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( len( main.activeNodes ) ):
+ node = str( main.activeNodes[i] + 1 )
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + node +
+ " expected a size of " + str( size ) +
+ " for set " + main.onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ removeResults = removeResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=removeResults,
+ onpass="Set remove correct",
+ onfail="Set remove was incorrect" )
+
+ main.step( "Distributed Set removeAll()" )
+ main.onosSet.difference_update( addAllValue.split() )
+ removeAllResponses = []
+ threads = []
+ try:
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].setTestRemove,
+ name="setTestRemoveAll-" + str( i ),
+ args=[ main.onosSetName, addAllValue ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ removeAllResponses.append( t.result )
+ except Exception, e:
+ main.log.exception(e)
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ removeAllResults = main.TRUE
+ for i in range( len( main.activeNodes ) ):
+ if removeAllResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif removeAllResponses[ i ] == main.FALSE:
+ # not in set, probably fine
+ pass
+ elif removeAllResponses[ i ] == main.ERROR:
+ # Error in execution
+ removeAllResults = main.FALSE
+ else:
+ # unexpected result
+ removeAllResults = main.FALSE
+ if removeAllResults != main.TRUE:
+ main.log.error( "Error executing set removeAll" )
+
+ # Check if set is still correct
+ size = len( main.onosSet )
+ getResponses = []
+ threads = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ main.onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( len( main.activeNodes ) ):
+ node = str( main.activeNodes[i] + 1 )
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if main.onosSet != current:
+ main.log.error( "ONOS" + node +
+ " has incorrect view" +
+ " of set " + main.onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( main.onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + node +
+ " has repeat elements in" +
+ " set " + main.onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ main.onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( len( main.activeNodes ) ):
+ node = str( main.activeNodes[i] + 1 )
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + node +
+ " expected a size of " + str( size ) +
+ " for set " + main.onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ removeAllResults = removeAllResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=removeAllResults,
+ onpass="Set removeAll correct",
+ onfail="Set removeAll was incorrect" )
+
+ main.step( "Distributed Set addAll()" )
+ main.onosSet.update( addAllValue.split() )
+ addResponses = []
+ threads = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].setTestAdd,
+ name="setTestAddAll-" + str( i ),
+ args=[ main.onosSetName, addAllValue ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ addResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ addAllResults = main.TRUE
+ for i in range( len( main.activeNodes ) ):
+ if addResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif addResponses[ i ] == main.FALSE:
+ # Already in set, probably fine
+ pass
+ elif addResponses[ i ] == main.ERROR:
+ # Error in execution
+ addAllResults = main.FALSE
+ else:
+ # unexpected result
+ addAllResults = main.FALSE
+ if addAllResults != main.TRUE:
+ main.log.error( "Error executing set addAll" )
+
+ # Check if set is still correct
+ size = len( main.onosSet )
+ getResponses = []
+ threads = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ main.onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( len( main.activeNodes ) ):
+ node = str( main.activeNodes[i] + 1 )
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if main.onosSet != current:
+ main.log.error( "ONOS" + node +
+ " has incorrect view" +
+ " of set " + main.onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( main.onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + node +
+ " has repeat elements in" +
+ " set " + main.onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ main.onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( len( main.activeNodes ) ):
+ node = str( main.activeNodes[i] + 1 )
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + node +
+ " expected a size of " + str( size ) +
+ " for set " + main.onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ addAllResults = addAllResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=addAllResults,
+ onpass="Set addAll correct",
+ onfail="Set addAll was incorrect" )
+
+ main.step( "Distributed Set clear()" )
+ main.onosSet.clear()
+ clearResponses = []
+ threads = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].setTestRemove,
+ name="setTestClear-" + str( i ),
+ args=[ main.onosSetName, " "], # Values doesn't matter
+ kwargs={ "clear": True } )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ clearResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ clearResults = main.TRUE
+ for i in range( len( main.activeNodes ) ):
+ if clearResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif clearResponses[ i ] == main.FALSE:
+ # Nothing set, probably fine
+ pass
+ elif clearResponses[ i ] == main.ERROR:
+ # Error in execution
+ clearResults = main.FALSE
+ else:
+ # unexpected result
+ clearResults = main.FALSE
+ if clearResults != main.TRUE:
+ main.log.error( "Error executing set clear" )
+
+ # Check if set is still correct
+ size = len( main.onosSet )
+ getResponses = []
+ threads = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ main.onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( len( main.activeNodes ) ):
+ node = str( main.activeNodes[i] + 1 )
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if main.onosSet != current:
+ main.log.error( "ONOS" + node +
+ " has incorrect view" +
+ " of set " + main.onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( main.onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + node +
+ " has repeat elements in" +
+ " set " + main.onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ main.onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( len( main.activeNodes ) ):
+ node = str( main.activeNodes[i] + 1 )
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + node +
+ " expected a size of " + str( size ) +
+ " for set " + main.onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ clearResults = clearResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=clearResults,
+ onpass="Set clear correct",
+ onfail="Set clear was incorrect" )
+
+ main.step( "Distributed Set addAll()" )
+ main.onosSet.update( addAllValue.split() )
+ addResponses = []
+ threads = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].setTestAdd,
+ name="setTestAddAll-" + str( i ),
+ args=[ main.onosSetName, addAllValue ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ addResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ addAllResults = main.TRUE
+ for i in range( len( main.activeNodes ) ):
+ if addResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif addResponses[ i ] == main.FALSE:
+ # Already in set, probably fine
+ pass
+ elif addResponses[ i ] == main.ERROR:
+ # Error in execution
+ addAllResults = main.FALSE
+ else:
+ # unexpected result
+ addAllResults = main.FALSE
+ if addAllResults != main.TRUE:
+ main.log.error( "Error executing set addAll" )
+
+ # Check if set is still correct
+ size = len( main.onosSet )
+ getResponses = []
+ threads = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ main.onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( len( main.activeNodes ) ):
+ node = str( main.activeNodes[i] + 1 )
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if main.onosSet != current:
+ main.log.error( "ONOS" + node +
+ " has incorrect view" +
+ " of set " + main.onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( main.onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + node +
+ " has repeat elements in" +
+ " set " + main.onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ main.onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( len( main.activeNodes ) ):
+ node = str( main.activeNodes[i] + 1 )
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + node +
+ " expected a size of " + str( size ) +
+ " for set " + main.onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ addAllResults = addAllResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=addAllResults,
+ onpass="Set addAll correct",
+ onfail="Set addAll was incorrect" )
+
+ main.step( "Distributed Set retain()" )
+ main.onosSet.intersection_update( retainValue.split() )
+ retainResponses = []
+ threads = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].setTestRemove,
+ name="setTestRetain-" + str( i ),
+ args=[ main.onosSetName, retainValue ],
+ kwargs={ "retain": True } )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ retainResponses.append( t.result )
+
+ # main.TRUE = successfully changed the set
+ # main.FALSE = action resulted in no change in set
+ # main.ERROR - Some error in executing the function
+ retainResults = main.TRUE
+ for i in range( len( main.activeNodes ) ):
+ if retainResponses[ i ] == main.TRUE:
+ # All is well
+ pass
+ elif retainResponses[ i ] == main.FALSE:
+ # Already in set, probably fine
+ pass
+ elif retainResponses[ i ] == main.ERROR:
+ # Error in execution
+ retainResults = main.FALSE
+ else:
+ # unexpected result
+ retainResults = main.FALSE
+ if retainResults != main.TRUE:
+ main.log.error( "Error executing set retain" )
+
+ # Check if set is still correct
+ size = len( main.onosSet )
+ getResponses = []
+ threads = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].setTestGet,
+ name="setTestGet-" + str( i ),
+ args=[ main.onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ getResults = main.TRUE
+ for i in range( len( main.activeNodes ) ):
+ node = str( main.activeNodes[i] + 1 )
+ if isinstance( getResponses[ i ], list):
+ current = set( getResponses[ i ] )
+ if len( current ) == len( getResponses[ i ] ):
+ # no repeats
+ if main.onosSet != current:
+ main.log.error( "ONOS" + node +
+ " has incorrect view" +
+ " of set " + main.onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ main.log.debug( "Expected: " + str( main.onosSet ) )
+ main.log.debug( "Actual: " + str( current ) )
+ getResults = main.FALSE
+ else:
+ # error, set is not a set
+ main.log.error( "ONOS" + node +
+ " has repeat elements in" +
+ " set " + main.onosSetName + ":\n" +
+ str( getResponses[ i ] ) )
+ getResults = main.FALSE
+ elif getResponses[ i ] == main.ERROR:
+ getResults = main.FALSE
+ sizeResponses = []
+ threads = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].setTestSize,
+ name="setTestSize-" + str( i ),
+ args=[ main.onosSetName ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ sizeResponses.append( t.result )
+ sizeResults = main.TRUE
+ for i in range( len( main.activeNodes ) ):
+ node = str( main.activeNodes[i] + 1 )
+ if size != sizeResponses[ i ]:
+ sizeResults = main.FALSE
+ main.log.error( "ONOS" + node + " expected a size of " +
+ str( size ) + " for set " + main.onosSetName +
+ " but got " + str( sizeResponses[ i ] ) )
+ retainResults = retainResults and getResults and sizeResults
+ utilities.assert_equals( expect=main.TRUE,
+ actual=retainResults,
+ onpass="Set retain correct",
+ onfail="Set retain was incorrect" )
+
+ # Transactional maps
+ main.step( "Partitioned Transactional maps put" )
+ tMapValue = "Testing"
+ numKeys = 100
+ putResult = True
+ node = main.activeNodes[0]
+ putResponses = main.CLIs[node].transactionalMapPut( numKeys, tMapValue )
+ if putResponses and len( putResponses ) == 100:
+ for i in putResponses:
+ if putResponses[ i ][ 'value' ] != tMapValue:
+ putResult = False
+ else:
+ putResult = False
+ if not putResult:
+ main.log.debug( "Put response values: " + str( putResponses ) )
+ utilities.assert_equals( expect=True,
+ actual=putResult,
+ onpass="Partitioned Transactional Map put successful",
+ onfail="Partitioned Transactional Map put values are incorrect" )
+
+ main.step( "Partitioned Transactional maps get" )
+ # FIXME: is this sleep needed?
+ time.sleep( 5 )
+
+ getCheck = True
+ for n in range( 1, numKeys + 1 ):
+ getResponses = []
+ threads = []
+ valueCheck = True
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].transactionalMapGet,
+ name="TMap-get-" + str( i ),
+ args=[ "Key" + str( n ) ] )
+ threads.append( t )
+ t.start()
+ for t in threads:
+ t.join()
+ getResponses.append( t.result )
+ for node in getResponses:
+ if node != tMapValue:
+ valueCheck = False
+ if not valueCheck:
+ main.log.warn( "Values for key 'Key" + str( n ) + "' do not match:" )
+ main.log.warn( getResponses )
+ getCheck = getCheck and valueCheck
+ utilities.assert_equals( expect=True,
+ actual=getCheck,
+ onpass="Partitioned Transactional Map get values were correct",
+ onfail="Partitioned Transactional Map values incorrect" )
+
+ # DISTRIBUTED ATOMIC VALUE
+ main.step( "Get the value of a new value" )
+ threads = []
+ getValues = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].valueTestGet,
+ name="ValueGet-" + str( i ),
+ args=[ valueName ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ getValues.append( t.result )
+ main.log.debug( getValues )
+ # Check the results
+ atomicValueGetResult = True
+ expected = valueValue if valueValue is not None else "null"
+ main.log.debug( "Checking for value of " + expected )
+ for i in getValues:
+ if i != expected:
+ atomicValueGetResult = False
+ utilities.assert_equals( expect=True,
+ actual=atomicValueGetResult,
+ onpass="Atomic Value get successful",
+ onfail="Error getting atomic Value " +
+ str( valueValue ) + ", found: " +
+ str( getValues ) )
+
+ main.step( "Atomic Value set()" )
+ valueValue = "foo"
+ threads = []
+ setValues = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].valueTestSet,
+ name="ValueSet-" + str( i ),
+ args=[ valueName, valueValue ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ setValues.append( t.result )
+ main.log.debug( setValues )
+ # Check the results
+ atomicValueSetResults = True
+ for i in setValues:
+ if i != main.TRUE:
+ atomicValueSetResults = False
+ utilities.assert_equals( expect=True,
+ actual=atomicValueSetResults,
+ onpass="Atomic Value set successful",
+ onfail="Error setting atomic Value" +
+ str( setValues ) )
+
+ main.step( "Get the value after set()" )
+ threads = []
+ getValues = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].valueTestGet,
+ name="ValueGet-" + str( i ),
+ args=[ valueName ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ getValues.append( t.result )
+ main.log.debug( getValues )
+ # Check the results
+ atomicValueGetResult = True
+ expected = valueValue if valueValue is not None else "null"
+ main.log.debug( "Checking for value of " + expected )
+ for i in getValues:
+ if i != expected:
+ atomicValueGetResult = False
+ utilities.assert_equals( expect=True,
+ actual=atomicValueGetResult,
+ onpass="Atomic Value get successful",
+ onfail="Error getting atomic Value " +
+ str( valueValue ) + ", found: " +
+ str( getValues ) )
+
+ main.step( "Atomic Value compareAndSet()" )
+ oldValue = valueValue
+ valueValue = "bar"
+ i = main.activeNodes[0]
+ CASValue = main.CLIs[i].valueTestCompareAndSet( valueName, oldValue, valueValue )
+ main.log.debug( CASValue )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=CASValue,
+ onpass="Atomic Value comapreAndSet successful",
+ onfail="Error setting atomic Value:" +
+ str( CASValue ) )
+
+ main.step( "Get the value after compareAndSet()" )
+ threads = []
+ getValues = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].valueTestGet,
+ name="ValueGet-" + str( i ),
+ args=[ valueName ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ getValues.append( t.result )
+ main.log.debug( getValues )
+ # Check the results
+ atomicValueGetResult = True
+ expected = valueValue if valueValue is not None else "null"
+ main.log.debug( "Checking for value of " + expected )
+ for i in getValues:
+ if i != expected:
+ atomicValueGetResult = False
+ utilities.assert_equals( expect=True,
+ actual=atomicValueGetResult,
+ onpass="Atomic Value get successful",
+ onfail="Error getting atomic Value " +
+ str( valueValue ) + ", found: " +
+ str( getValues ) )
+
+ main.step( "Atomic Value getAndSet()" )
+ oldValue = valueValue
+ valueValue = "baz"
+ i = main.activeNodes[0]
+ GASValue = main.CLIs[i].valueTestGetAndSet( valueName, valueValue )
+ main.log.debug( GASValue )
+ expected = oldValue if oldValue is not None else "null"
+ utilities.assert_equals( expect=expected,
+ actual=GASValue,
+ onpass="Atomic Value GAS successful",
+ onfail="Error with GetAndSet atomic Value: expected " +
+ str( expected ) + ", found: " +
+ str( GASValue ) )
+
+ main.step( "Get the value after getAndSet()" )
+ threads = []
+ getValues = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].valueTestGet,
+ name="ValueGet-" + str( i ),
+ args=[ valueName ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ getValues.append( t.result )
+ main.log.debug( getValues )
+ # Check the results
+ atomicValueGetResult = True
+ expected = valueValue if valueValue is not None else "null"
+ main.log.debug( "Checking for value of " + expected )
+ for i in getValues:
+ if i != expected:
+ atomicValueGetResult = False
+ utilities.assert_equals( expect=True,
+ actual=atomicValueGetResult,
+ onpass="Atomic Value get successful",
+ onfail="Error getting atomic Value: expected " +
+ str( valueValue ) + ", found: " +
+ str( getValues ) )
+
+ main.step( "Atomic Value destory()" )
+ valueValue = None
+ threads = []
+ i = main.activeNodes[0]
+ destroyResult = main.CLIs[i].valueTestDestroy( valueName )
+ main.log.debug( destroyResult )
+ # Check the results
+ utilities.assert_equals( expect=main.TRUE,
+ actual=destroyResult,
+ onpass="Atomic Value destroy successful",
+ onfail="Error destroying atomic Value" )
+
+ main.step( "Get the value after destroy()" )
+ threads = []
+ getValues = []
+ for i in main.activeNodes:
+ t = main.Thread( target=main.CLIs[i].valueTestGet,
+ name="ValueGet-" + str( i ),
+ args=[ valueName ] )
+ threads.append( t )
+ t.start()
+
+ for t in threads:
+ t.join()
+ getValues.append( t.result )
+ main.log.debug( getValues )
+ # Check the results
+ atomicValueGetResult = True
+ expected = valueValue if valueValue is not None else "null"
+ main.log.debug( "Checking for value of " + expected )
+ for i in getValues:
+ if i != expected:
+ atomicValueGetResult = False
+ utilities.assert_equals( expect=True,
+ actual=atomicValueGetResult,
+ onpass="Atomic Value get successful",
+ onfail="Error getting atomic Value " +
+ str( valueValue ) + ", found: " +
+ str( getValues ) )
+ except Exception as e:
+ main.log.error( "Exception: " + str( e ) )