Merge "Changes made to detect duplicate image tags on docker hub"
diff --git a/TestON/core/utilities.py b/TestON/core/utilities.py
index 43d56dc..930ce2d 100644
--- a/TestON/core/utilities.py
+++ b/TestON/core/utilities.py
@@ -331,6 +331,7 @@
else:
sleeptime = sleep
time.sleep( sleeptime )
+ main.log.debug( str( i ) + " Attempts needed to pass this test" )
return ret
except AssertionError:
main.log.exception( "Invalid arguements for retry: " )
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/FUNC/FUNCintent/FUNCintent.params b/TestON/tests/FUNC/FUNCintent/FUNCintent.params
index 88e8956..e579b8b 100644
--- a/TestON/tests/FUNC/FUNCintent/FUNCintent.params
+++ b/TestON/tests/FUNC/FUNCintent/FUNCintent.params
@@ -51,6 +51,10 @@
<fwd>10</fwd>
<topoAttempts>3</topoAttempts>
<flowDuration>10</flowDuration>
+ <checkConnection>50</checkConnection>
+ <checkFlowCount>200</checkFlowCount>
+ <checkIntentHost>100</checkIntentHost>
+ <checkIntentPoint>200</checkIntentPoint>
</SLEEP>
<MININET>
diff --git a/TestON/tests/FUNC/FUNCintent/FUNCintent.py b/TestON/tests/FUNC/FUNCintent/FUNCintent.py
index 6297464..f96ef73 100644
--- a/TestON/tests/FUNC/FUNCintent/FUNCintent.py
+++ b/TestON/tests/FUNC/FUNCintent/FUNCintent.py
@@ -47,6 +47,10 @@
main.removeIntentSleep = int( main.params[ 'SLEEP' ][ 'removeintent' ] )
main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] )
main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
+ main.checkConnectionSleep = int( main.params[ 'SLEEP' ][ 'checkConnection' ] )
+ main.checkFlowCountSleep = int( main.params[ 'SLEEP' ][ 'checkFlowCount' ] )
+ main.checkIntentHostSleep = int( main.params[ 'SLEEP' ][ 'checkIntentHost' ] )
+ main.checkIntentPointSleep = int( main.params[ 'SLEEP' ][ 'checkIntentPoint' ] )
main.checkTopoAttempts = int( main.params[ 'SLEEP' ][ 'topoAttempts' ] )
main.flowDurationSleep = int( main.params[ 'SLEEP' ][ 'flowDuration' ] )
gitPull = main.params[ 'GIT' ][ 'pull' ]
@@ -953,7 +957,7 @@
onpass=main.assertReturnString,
onfail=main.assertReturnString )
- # Testing MPLS would need to update kernel version (Right now is 3.16)
+ # Testing MPLS would require kernel version of 4.1 or higher (Current version is 3.13)
# main.step( "Encapsulation: Add host intents between h1 and h9" )
# main.assertReturnString = "Assertion Result for MPLS Encapsulated host intent\n"
# host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
@@ -1429,7 +1433,7 @@
onpass=main.assertReturnString,
onfail=main.assertReturnString )
- # Testing MPLS would need to update kernel version (Right now is 3.16)
+ # Testing MPLS would require kernel version of 4.1 or higher (Current version is 3.13)
# main.step( "Add point to point intents using MPLS Encapsulation" )
# main.assertReturnString = "Assertion Result for MPLS Encapsulation Point Intent"
# senders = [
@@ -2068,47 +2072,47 @@
onpass=main.assertReturnString,
onfail=main.assertReturnString )
- # Testing MPLS would need to update kernel version (Right now is 3.16)
- # main.step( "ENCAPSULATION: Add multi point to single point intents" )
- # main.assertReturnString = "Assertion results for MPLS Encapsulation multi to single point intent\n"
- # senders = [
- # { "name": "h16", "device": "of:0000000000000006/8" },
- # { "name": "h24", "device": "of:0000000000000007/8" }
- # ]
- # recipients = [
- # { "name": "h8", "device": "of:0000000000000005/8" }
- # ]
- # badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
- # badRecipients = [ {"name": "h9" } ] # Recipients that are not in the intent
- # testResult = main.FALSE
- # installResult = main.intentFunction.installMultiToSingleIntent(
- # main,
- # name="ENCAPSULATION",
- # senders=senders,
- # recipients=recipients,
- # sw1="s5",
- # sw2="s2",
- # encap="MPLS" )
+ #Testing MPLS would require kernel version of 4.1 or higher (Current version is 3.13)
+ #main.step( "ENCAPSULATION: Add multi point to single point intents" )
+ #main.assertReturnString = "Assertion results for MPLS Encapsulation multi to single point intent\n"
+ #senders = [
+ # { "name": "h16", "device": "of:0000000000000006/8" },
+ # { "name": "h24", "device": "of:0000000000000007/8" }
+ #]
+ #recipients = [
+ # { "name": "h8", "device": "of:0000000000000005/8" }
+ #]
+ #badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
+ #badRecipients = [ {"name": "h9" } ] # Recipients that are not in the intent
+ #testResult = main.FALSE
+ #installResult = main.intentFunction.installMultiToSingleIntent(
+ # main,
+ # name="ENCAPSULATION",
+ # senders=senders,
+ # recipients=recipients,
+ # sw1="s5",
+ # sw2="s2",
+ # encap="MPLS" )
#
- # if installResult:
- # testResult = main.intentFunction.testPointIntent(
- # main,
- # intentId=installResult,
- # name="ENCAPSULATION",
- # senders=senders,
- # recipients=recipients,
- # badSenders=badSenders,
- # badRecipients=badRecipients,
- # sw1="s5",
- # sw2="s2",
- # expectedLink=18 )
- # else:
- # main.CLIs[ 0 ].removeAllIntents( purge=True )
+ #if installResult:
+ # testResult = main.intentFunction.testPointIntent(
+ # main,
+ # intentId=installResult,
+ # name="ENCAPSULATION",
+ # senders=senders,
+ # recipients=recipients,
+ # badSenders=badSenders,
+ # badRecipients=badRecipients,
+ # sw1="s5",
+ # sw2="s2",
+ # expectedLink=18 )
+ #else:
+ # main.CLIs[ 0 ].removeAllIntents( purge=True )
#
- # utilities.assert_equals( expect=main.TRUE,
- # actual=testResult,
- # onpass=main.assertReturnString,
- # onfail=main.assertReturnString )
+ #utilities.assert_equals( expect=main.TRUE,
+ # actual=testResult,
+ # onpass=main.assertReturnString,
+ # onfail=main.assertReturnString )
main.intentFunction.report( main )
diff --git a/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py b/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
index d8a0e36..48c0f27 100755
--- a/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
+++ b/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
@@ -91,7 +91,7 @@
# Check intents state
if utilities.retry( f=checkIntentState, retValue=main.FALSE,
- args=( main, [ intentId ] ), sleep=main.checkIntentSleep, attempts=5 ):
+ args=( main, [ intentId ] ), sleep=main.checkIntentSleep, attempts=50 ):
main.assertReturnString += 'Install Intent State Passed\n'
#Check VLAN if test encapsulation
@@ -197,21 +197,26 @@
main.log.info( itemName + ": Testing Host to Host intents" )
# Check intent state
- if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
+ if utilities.retry( f=checkIntentState, retValue=main.FALSE,
+ args=( main, [ intentId ] ), sleep=main.checkIntentSleep, attempts=50 ):
main.assertReturnString += 'Initial Intent State Passed\n'
else:
main.assertReturnString += 'Initial Intent State Failed\n'
testResult = main.FALSE
# Check flows count in each node
- if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ) and utilities.retry( f=checkFlowsState, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ):
+ if utilities.retry( f=checkFlowsCount, retValue=main.FALSE,
+ args=[ main ], sleep=20, attempts=3 ) and utilities.retry( f=checkFlowsState,
+ retValue=main.FALSE,
+ args=[ main ], sleep=20, attempts=3 ):
main.assertReturnString += 'Initial Flow State Passed\n'
else:
main.assertReturnString += 'Intial Flow State Failed\n'
testResult = main.FALSE
# Check Connectivity
- if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId ) ):
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, attempts=50, sleep=main.checkConnectionSleep,
+ args=( main, senderNames, recipientNames, vlanId ) ):
main.assertReturnString += 'Initial Ping Passed\n'
else:
main.assertReturnString += 'Initial Ping Failed\n'
@@ -227,14 +232,17 @@
testResult = main.FALSE
# Check intent state
- if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
+ if utilities.retry( f=checkIntentState, retValue=main.FALSE,
+ args=( main, [ intentId ] ), sleep=main.checkIntentHostSleep, attempts=5 * 20 ):
main.assertReturnString += 'Link Down Intent State Passed\n'
else:
main.assertReturnString += 'Link Down Intent State Failed\n'
testResult = main.FALSE
# Check flows count in each node
- if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ) and utilities.retry( f=checkFlowsState, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ):
+ if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, args=[ main ], sleep=main.checkFlowCountSleep,
+ attempts=200 ) and utilities.retry( f=checkFlowsState, retValue=main.FALSE, args=[ main ],
+ sleep=main.checkFlowCountSleep, attempts=200 ):
main.assertReturnString += 'Link Down Flow State Passed\n'
else:
main.assertReturnString += 'Link Down Flow State Failed\n'
@@ -248,7 +256,9 @@
testResult = main.FALSE
# Check Connection
- if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId ), sleep=5, attempts=5 ):
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE,
+ args=( main, senderNames, recipientNames, vlanId ),
+ sleep=main.checkConnectionSleep, attempts=5 * 20 ):
main.assertReturnString += 'Link Down Pingall Passed\n'
else:
main.assertReturnString += 'Link Down Pingall Failed\n'
@@ -265,14 +275,17 @@
time.sleep( main.rerouteSleep )
# Check Intents
- if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
+ if utilities.retry( f=checkIntentState, retValue=main.FALSE, attempts=100,
+ args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
main.assertReturnString += 'Link Up Intent State Passed\n'
else:
main.assertReturnString += 'Link Up Intent State Failed\n'
testResult = main.FALSE
# Check flows count in each node
- if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ) and utilities.retry( f=checkFlowsState, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ):
+ if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, args=[ main ],
+ sleep=20, attempts=3 ) and utilities.retry( f=checkFlowsState, retValue=main.FALSE,
+ args=[ main ], sleep=20, attempts=3 ):
main.assertReturnString += 'Link Up Flow State Passed\n'
else:
main.assertReturnString += 'Link Up Flow State Failed\n'
@@ -293,7 +306,7 @@
testResult = main.FALSE
# Remove all intents
- if utilities.retry( f=removeAllIntents, retValue=main.FALSE, args=( main, [ intentId ] ) ):
+ if utilities.retry( f=removeAllIntents, retValue=main.FALSE, attempts=10, args=( main, [ intentId ] ) ):
main.assertReturnString += 'Remove Intents Passed'
else:
main.assertReturnString += 'Remove Intents Failed'
@@ -416,7 +429,7 @@
# Check intents state
if utilities.retry( f=checkIntentState, retValue=main.FALSE,
- args=( main, [ intentId ] ), sleep=main.checkIntentSleep, attempts=5 ):
+ args=( main, [ intentId ] ), sleep=main.checkIntentSleep*2, attempts=50 ):
main.assertReturnString += 'Install Intent State Passed\n'
# Check VLAN if test encapsulation
@@ -591,13 +604,15 @@
# Check intents state
time.sleep( main.checkIntentSleep )
- intentResult = checkIntentState( main, intentsId )
+ intentResult = utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [intentsId ] ),
+ sleep=1, attempts=50 )
# Check flows count in each node
checkFlowsCount( main )
# Check intents state again if first check fails...
if not intentResult:
- intentResult = checkIntentState( main, intentsId )
+ intentResult = utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [intentsId ] ),
+ sleep=1, attempts=50 )
# Check flows count in each node
checkFlowsCount( main )
@@ -644,7 +659,8 @@
main.assertReturnString += 'Link Down Iperf Failed\n'
# Check intent state
- intentTemp = checkIntentState( main, intentsId )
+ intentTemp = utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [intentsId ] ),
+ sleep=1, attempts=50 )
intentResult = intentResult and intentTemp
if intentTemp:
main.assertReturnString += 'Link Down Intent State Passed\n'
@@ -688,7 +704,8 @@
main.assertReturnString += 'Link Up Iperf Failed\n'
# Check intent state
- intentTemp = checkIntentState( main, intentsId )
+ intentTemp = utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [intentsId ] ),
+ sleep=1, attempts=50 )
intentResult = intentResult and intentTemp
if intentTemp:
main.assertReturnString += 'Link Down Intent State Passed\n'
@@ -827,7 +844,7 @@
# Check intents state
if utilities.retry( f=checkIntentState, retValue=main.FALSE,
- args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
+ args=( main, [ intentId ] ), sleep=main.checkIntentSleep, attempts=50 ):
main.assertReturnString += 'Install Intent State Passed\n'
if flowDuration( main ):
main.assertReturnString += 'Flow duration check Passed\n'
@@ -952,7 +969,7 @@
# Check intents state
if utilities.retry( f=checkIntentState, retValue=main.FALSE,
- args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
+ args=( main, [ intentId ] ), sleep=main.checkIntentSleep, attempts=50 ):
main.assertReturnString += 'Install Intent State Passed\n'
if flowDuration( main ):
main.assertReturnString += 'Flow duration check Passed\n'
@@ -1067,21 +1084,26 @@
main.log.info( itemName + ": Adding single point to multi point intents" )
# Check intent state
- if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
+ if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [ intentId ] ),
+ sleep=main.checkIntentSleep, attempts=50 ):
main.assertReturnString += 'Initial Intent State Passed\n'
else:
main.assertReturnString += 'Initial Intent State Failed\n'
testResult = main.FALSE
# Check flows count in each node
- if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ) and utilities.retry( f=checkFlowsState, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ):
+ if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, args=[ main ],
+ sleep=20, attempts=3 ) and utilities.retry( f=checkFlowsState, retValue=main.FALSE,
+ args=[ main ], sleep=20, attempts=3 ):
main.assertReturnString += 'Initial Flow State Passed\n'
else:
main.assertReturnString += 'Intial Flow State Failed\n'
testResult = main.FALSE
# Check Connectivity
- if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId, useTCP ), attempts=3, sleep=5 ):
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE,
+ args=( main, senderNames, recipientNames, vlanId, useTCP ),
+ attempts=50, sleep=main.checkConnectionSleep ):
main.assertReturnString += 'Initial Ping Passed\n'
else:
main.assertReturnString += 'Initial Ping Failed\n'
@@ -1129,14 +1151,17 @@
testResult = main.FALSE
# Check intent state
- if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
+ if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [ intentId ] ),
+ sleep=main.checkIntentPointSleep, attempts=5 * 20 ):
main.assertReturnString += 'Link Down Intent State Passed\n'
else:
main.assertReturnString += 'Link Down Intent State Failed\n'
testResult = main.FALSE
# Check flows count in each node
- if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, args=[ main ], sleep=20, attempts=5 ) and utilities.retry( f=checkFlowsState, retValue=main.FALSE, args=[ main ], sleep=20, attempts=5 ):
+ if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, args=[ main ], sleep=main.checkFlowCountSleep,
+ attempts=200 ) and utilities.retry( f=checkFlowsState, retValue=main.FALSE, args=[ main ],
+ sleep=main.checkFlowCountSleep, attempts=200 ):
main.assertReturnString += 'Link Down Flow State Passed\n'
else:
main.assertReturnString += 'Link Down Flow State Failed\n'
@@ -1150,7 +1175,9 @@
testResult = main.FALSE
# Check Connection
- if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId, useTCP ), sleep=5, attempts=5 ):
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE,
+ args=( main, senderNames, recipientNames, vlanId, useTCP ),
+ sleep=main.checkConnectionSleep, attempts=5 * 10 ):
main.assertReturnString += 'Link Down Pingall Passed\n'
else:
main.assertReturnString += 'Link Down Pingall Failed\n'
@@ -1167,14 +1194,17 @@
time.sleep( main.rerouteSleep )
# Check Intents
- if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
+ if utilities.retry( f=checkIntentState, retValue=main.FALSE, attempts=100, args=( main, [ intentId ] ),
+ sleep=main.checkIntentSleep ):
main.assertReturnString += 'Link Up Intent State Passed\n'
else:
main.assertReturnString += 'Link Up Intent State Failed\n'
testResult = main.FALSE
# Check flows count in each node
- if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ) and utilities.retry( f=checkFlowsState, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ):
+ if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, args=[ main ],
+ sleep=20, attempts=3 ) and utilities.retry( f=checkFlowsState, retValue=main.FALSE,
+ args=[ main ], sleep=20, attempts=3 ):
main.assertReturnString += 'Link Up Flow State Passed\n'
else:
main.assertReturnString += 'Link Up Flow State Failed\n'
@@ -1188,14 +1218,15 @@
testResult = main.FALSE
# Check Connection
- if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId, useTCP ) ):
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, sleep=main.checkConnectionSleep, attempts=100,
+ args=( main, senderNames, recipientNames, vlanId, useTCP ) ):
main.assertReturnString += 'Link Up Scapy Packet Received Passed\n'
else:
main.assertReturnString += 'Link Up Scapy Packet Recieved Failed\n'
testResult = main.FALSE
# Remove all intents
- if utilities.retry( f=removeAllIntents, retValue=main.FALSE, args=( main, [ intentId ] ) ):
+ if utilities.retry( f=removeAllIntents, retValue=main.FALSE, attempts=10, args=( main, [ intentId ] ) ):
main.assertReturnString += 'Remove Intents Passed'
else:
main.assertReturnString += 'Remove Intents Failed'
@@ -1226,7 +1257,7 @@
expectedLink2=0,
partial=False ):
"""
- Test Single to Multipoint Topology for Endpoint failures
+ Test Multi point to single point intent Topology for Endpoint failures
"""
# Parameter Validity Check
@@ -1267,7 +1298,7 @@
# Check intent state
if utilities.retry( f=checkIntentState, retValue=main.FALSE,
- args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
+ args=( main, [ intentId ] ), sleep=main.checkIntentSleep, attempts=50 ):
main.assertReturnString += 'Initial Intent State Passed\n'
else:
main.assertReturnString += 'Initial Intent State Failed\n'
@@ -1307,7 +1338,7 @@
testResult = main.FALSE
# Check intent state
- if utilities.retry( f=checkIntentState, retValue=main.FALSE,
+ if utilities.retry( f=checkIntentState, retValue=main.FALSE, attempts=100,
args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
main.assertReturnString += 'Link Down Intent State Passed\n'
else:
@@ -1315,9 +1346,9 @@
testResult = main.FALSE
# Check flows count in each node
- if utilities.retry( f=checkFlowsCount, retValue=main.FALSE,
+ if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, sleep=1, attempts=30,
args=[ main ] ) and utilities.retry( f=checkFlowsState,
- retValue=main.FALSE, args=[ main ] ):
+ retValue=main.FALSE, sleep=1, attempts=30, args=[ main ] ):
main.assertReturnString += 'Link Down Flow State Passed\n'
else:
main.assertReturnString += 'Link Down Flow State Failed\n'
@@ -1348,7 +1379,7 @@
if partial:
# Check intent state
if utilities.retry( f=checkIntentState, retValue=main.FALSE,
- args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
+ args=( main, [ intentId ] ), sleep=main.checkIntentSleep, attempts=50 ):
main.assertReturnString += 'Partial failure isolation link Down Intent State Passed\n'
else:
main.assertReturnString += 'Partial failure isolation link Down Intent State Failed\n'
@@ -1389,7 +1420,7 @@
testResult = main.FALSE
# Next check connectivity of connected senders and recipients
- if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE,
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, attempts=50,
args=( main, connectedSenderNames , connectedRecipientNames ) ):
main.assertReturnString += 'Partial failure isolation link Down Connectivity Check Passed\n'
else:
@@ -1398,7 +1429,7 @@
else:
# Check intent state
if not utilities.retry( f=checkIntentState, retValue=main.TRUE,
- args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
+ args=( main, [ intentId ] ), sleep=main.checkIntentSleep, attempts=50 ):
main.assertReturnString += 'Isolation link Down Intent State Passed\n'
else:
main.assertReturnString += 'Isolation link Down Intent State Failed\n'
@@ -1472,8 +1503,8 @@
time.sleep( main.rerouteSleep )
# Check Intents
- if utilities.retry( f=checkIntentState, retValue=main.FALSE,
- args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
+ if utilities.retry( f=checkIntentState, retValue=main.FALSE, attempts=5 * 20,
+ args=( main, [ intentId ] ), sleep=main.checkIntentHostSleep ):
main.assertReturnString += 'Link Up Intent State Passed\n'
else:
main.assertReturnString += 'Link Up Intent State Failed\n'
@@ -1481,9 +1512,9 @@
# Check flows count in each node
if utilities.retry( f=checkFlowsCount, retValue=main.FALSE,
- args=[ main ], sleep=5, attempts=5 ) and utilities.retry( f=checkFlowsState,
+ args=[ main ], sleep=5, attempts=5*20 ) and utilities.retry( f=checkFlowsState,
retValue=main.FALSE,
- args=[ main ], sleep=5, attempts=5 ):
+ args=[ main ], sleep=5, attempts=5*20 ):
main.assertReturnString += 'Link Up Flow State Passed\n'
else:
main.assertReturnString += 'Link Up Flow State Failed\n'
@@ -1497,7 +1528,7 @@
testResult = main.FALSE
# Check Connection
- if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE,
+ if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, sleep=main.checkConnectionSleep, attempts= 100,
args=( main, senderNames, recipientNames ) ):
main.assertReturnString += 'Link Up Scapy Packet Received Passed\n'
else:
@@ -1505,7 +1536,7 @@
testResult = main.FALSE
# Remove all intents
- if utilities.retry( f=removeAllIntents, retValue=main.FALSE, args=( main, [ intentId ] ) ):
+ if utilities.retry( f=removeAllIntents, retValue=main.FALSE, attempts=10, args=( main, [ intentId ] ) ):
main.assertReturnString += 'Remove Intents Passed'
else:
main.assertReturnString += 'Remove Intents Failed'
@@ -1677,8 +1708,6 @@
intentResult = main.TRUE
results = []
- main.log.info( itemName + ": Checking intents state" )
- # First check of intents
for i in range( main.numCtrls ):
tempResult = main.CLIs[ i ].checkIntentState( intentsId=intentsId )
results.append( tempResult )
@@ -1686,21 +1715,8 @@
if all( result == main.TRUE for result in results ):
main.log.info( itemName + ": Intents are installed correctly" )
else:
- # Wait for at least 5 second before checking the intents again
- main.log.error( "Intents are not installed correctly. Waiting 5 sec" )
- time.sleep( 5 )
- results = []
- # Second check of intents since some of the intents may be in
- # INSTALLING state, they should be in INSTALLED at this time
- for i in range( main.numCtrls ):
- tempResult = main.CLIs[ i ].checkIntentState( intentsId=intentsId )
- results.append( tempResult )
- if all( result == main.TRUE for result in results ):
- main.log.info( itemName + ": Intents are installed correctly" )
- intentResult = main.TRUE
- else:
- main.log.error( itemName + ": Intents are NOT installed correctly" )
- intentResult = main.FALSE
+ main.log.warn( "Intents are not installed correctly" )
+ intentResult = main.FALSE
return intentResult
@@ -2022,4 +2038,4 @@
intent = main.CLIs[ 0 ].intents( jsonFormat=False )
if "Protection" in intent:
return main.TRUE
- return main.FALSE
\ No newline at end of file
+ return main.FALSE
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 ) )