blob: ac0e8913d567ee552982c396442f1f093f06bfec [file] [log] [blame]
Jon Halla440e872016-03-31 15:15:50 -07001import json
Jon Hall41d39f12016-04-11 22:54:35 -07002import time
Jon Halle1a3b752015-07-22 13:02:46 -07003
Jon Hallf37d44d2017-05-24 10:37:30 -07004
Jon Hall41d39f12016-04-11 22:54:35 -07005class HA():
Jon Hall57b50432015-10-22 10:20:10 -07006
Jon Halla440e872016-03-31 15:15:50 -07007 def __init__( self ):
8 self.default = ''
Jon Hall57b50432015-10-22 10:20:10 -07009
Jon Halla440e872016-03-31 15:15:50 -070010 def consistentCheck( self ):
11 """
12 Checks that TestON counters are consistent across all nodes.
Jon Halle1a3b752015-07-22 13:02:46 -070013
Jon Hallf37d44d2017-05-24 10:37:30 -070014 Returns the tuple ( onosCounters, consistent )
Jon Hall41d39f12016-04-11 22:54:35 -070015 - onosCounters is the parsed json output of the counters command on
16 all nodes
17 - consistent is main.TRUE if all "TestON" counters are consitent across
18 all nodes or main.FALSE
Jon Halla440e872016-03-31 15:15:50 -070019 """
Jon Halle1a3b752015-07-22 13:02:46 -070020 try:
Jon Halla440e872016-03-31 15:15:50 -070021 # Get onos counters results
22 onosCountersRaw = []
23 threads = []
24 for i in main.activeNodes:
25 t = main.Thread( target=utilities.retry,
26 name="counters-" + str( i ),
Jon Hallf37d44d2017-05-24 10:37:30 -070027 args=[ main.CLIs[ i ].counters, [ None ] ],
28 kwargs={ 'sleep': 5, 'attempts': 5,
Jon Halla440e872016-03-31 15:15:50 -070029 'randomTime': True } )
30 threads.append( t )
31 t.start()
32 for t in threads:
33 t.join()
34 onosCountersRaw.append( t.result )
35 onosCounters = []
36 for i in range( len( main.activeNodes ) ):
37 try:
Jon Hallf37d44d2017-05-24 10:37:30 -070038 onosCounters.append( json.loads( onosCountersRaw[ i ] ) )
Jon Halla440e872016-03-31 15:15:50 -070039 except ( ValueError, TypeError ):
40 main.log.error( "Could not parse counters response from ONOS" +
Jon Hallf37d44d2017-05-24 10:37:30 -070041 str( main.activeNodes[ i ] + 1 ) )
Jon Halla440e872016-03-31 15:15:50 -070042 main.log.warn( repr( onosCountersRaw[ i ] ) )
43 onosCounters.append( [] )
44
45 testCounters = {}
46 # make a list of all the "TestON-*" counters in ONOS
Jon Hall41d39f12016-04-11 22:54:35 -070047 # lookes like a dict whose keys are the name of the ONOS node and
48 # values are a list of the counters. I.E.
Jon Hallf37d44d2017-05-24 10:37:30 -070049 # { "ONOS1": [ { "name":"TestON-Partitions","value":56 } ]
Jon Halla440e872016-03-31 15:15:50 -070050 # }
51 # NOTE: There is an assumtion that all nodes are active
52 # based on the above for loops
53 for controller in enumerate( onosCounters ):
Jon Hallf37d44d2017-05-24 10:37:30 -070054 for key, value in controller[ 1 ].iteritems():
Jon Halla440e872016-03-31 15:15:50 -070055 if 'TestON' in key:
Jon Hallf37d44d2017-05-24 10:37:30 -070056 node = 'ONOS' + str( controller[ 0 ] + 1 )
Jon Halla440e872016-03-31 15:15:50 -070057 try:
Jon Hallf37d44d2017-05-24 10:37:30 -070058 testCounters[ node ].append( { key: value } )
Jon Halla440e872016-03-31 15:15:50 -070059 except KeyError:
Jon Hallf37d44d2017-05-24 10:37:30 -070060 testCounters[ node ] = [ { key: value } ]
Jon Halla440e872016-03-31 15:15:50 -070061 # compare the counters on each node
Jon Hallf37d44d2017-05-24 10:37:30 -070062 firstV = testCounters.values()[ 0 ]
Jon Halla440e872016-03-31 15:15:50 -070063 tmp = [ v == firstV for k, v in testCounters.iteritems() ]
64 if all( tmp ):
65 consistent = main.TRUE
66 else:
67 consistent = main.FALSE
68 main.log.error( "ONOS nodes have different values for counters:\n" +
69 testCounters )
70 return ( onosCounters, consistent )
71 except Exception:
72 main.log.exception( "" )
73 main.cleanup()
74 main.exit()
75
76 def counterCheck( self, counterName, counterValue ):
77 """
78 Checks that TestON counters are consistent across all nodes and that
79 specified counter is in ONOS with the given value
80 """
81 try:
82 correctResults = main.TRUE
83 # Get onos counters results and consistentCheck
84 onosCounters, consistent = self.consistentCheck()
85 # Check for correct values
86 for i in range( len( main.activeNodes ) ):
Jon Hallf37d44d2017-05-24 10:37:30 -070087 current = onosCounters[ i ]
Jon Halla440e872016-03-31 15:15:50 -070088 onosValue = None
89 try:
90 onosValue = current.get( counterName )
Jon Hall41d39f12016-04-11 22:54:35 -070091 except AttributeError:
Jon Hallf37d44d2017-05-24 10:37:30 -070092 node = str( main.activeNodes[ i ] + 1 )
Jon Hall41d39f12016-04-11 22:54:35 -070093 main.log.exception( "ONOS" + node + " counters result " +
94 "is not as expected" )
Jon Halla440e872016-03-31 15:15:50 -070095 correctResults = main.FALSE
96 if onosValue == counterValue:
97 main.log.info( counterName + " counter value is correct" )
98 else:
Jon Hall41d39f12016-04-11 22:54:35 -070099 main.log.error( counterName +
100 " counter value is incorrect," +
101 " expected value: " + str( counterValue ) +
102 " current value: " + str( onosValue ) )
Jon Halla440e872016-03-31 15:15:50 -0700103 correctResults = main.FALSE
104 return consistent and correctResults
105 except Exception:
106 main.log.exception( "" )
107 main.cleanup()
108 main.exit()
Jon Hall41d39f12016-04-11 22:54:35 -0700109
110 def consistentLeaderboards( self, nodes ):
111 TOPIC = 'org.onosproject.election'
112 # FIXME: use threads
Jon Halle0f0b342017-04-18 11:43:47 -0700113 # FIXME: should we retry outside the function?
Jon Hall41d39f12016-04-11 22:54:35 -0700114 for n in range( 5 ): # Retry in case election is still happening
115 leaderList = []
116 # Get all leaderboards
117 for cli in nodes:
118 leaderList.append( cli.specificLeaderCandidate( TOPIC ) )
119 # Compare leaderboards
Jon Hallf37d44d2017-05-24 10:37:30 -0700120 result = all( i == leaderList[ 0 ] for i in leaderList ) and\
Jon Hall41d39f12016-04-11 22:54:35 -0700121 leaderList is not None
122 main.log.debug( leaderList )
123 main.log.warn( result )
124 if result:
125 return ( result, leaderList )
Jon Hallf37d44d2017-05-24 10:37:30 -0700126 time.sleep( 5 ) # TODO: paramerterize
Jon Hall41d39f12016-04-11 22:54:35 -0700127 main.log.error( "Inconsistent leaderboards:" + str( leaderList ) )
128 return ( result, leaderList )
129
130 def nodesCheck( self, nodes ):
131 nodesOutput = []
132 results = True
133 threads = []
134 for i in nodes:
Jon Hallf37d44d2017-05-24 10:37:30 -0700135 t = main.Thread( target=main.CLIs[ i ].nodes,
Jon Hall41d39f12016-04-11 22:54:35 -0700136 name="nodes-" + str( i ),
Jon Hallf37d44d2017-05-24 10:37:30 -0700137 args=[] )
Jon Hall41d39f12016-04-11 22:54:35 -0700138 threads.append( t )
139 t.start()
140
141 for t in threads:
142 t.join()
143 nodesOutput.append( t.result )
Jon Hallf37d44d2017-05-24 10:37:30 -0700144 ips = sorted( [ main.nodes[ node ].ip_address for node in nodes ] )
Jon Hall41d39f12016-04-11 22:54:35 -0700145 for i in nodesOutput:
146 try:
147 current = json.loads( i )
148 activeIps = []
149 currentResult = False
150 for node in current:
Jon Hallf37d44d2017-05-24 10:37:30 -0700151 if node[ 'state' ] == 'READY':
152 activeIps.append( node[ 'ip' ] )
Jon Hall41d39f12016-04-11 22:54:35 -0700153 activeIps.sort()
154 if ips == activeIps:
155 currentResult = True
156 except ( ValueError, TypeError ):
157 main.log.error( "Error parsing nodes output" )
158 main.log.warn( repr( i ) )
159 currentResult = False
160 results = results and currentResult
161 return results
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700162
Jon Halle0f0b342017-04-18 11:43:47 -0700163 def workQueueStatsCheck( self, workQueueName, completed, inProgress, pending ):
164 # Completed
165 threads = []
166 completedValues = []
167 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -0700168 t = main.Thread( target=main.CLIs[ i ].workQueueTotalCompleted,
Jon Halle0f0b342017-04-18 11:43:47 -0700169 name="WorkQueueCompleted-" + str( i ),
170 args=[ workQueueName ] )
171 threads.append( t )
172 t.start()
173
174 for t in threads:
175 t.join()
176 completedValues.append( int( t.result ) )
177 # Check the results
178 completedResults = [ x == completed for x in completedValues ]
179 completedResult = all( completedResults )
180 if not completedResult:
181 main.log.warn( "Expected Work Queue {} to have {} completed, found {}".format(
182 workQueueName, completed, completedValues ) )
183
184 # In Progress
185 threads = []
186 inProgressValues = []
187 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -0700188 t = main.Thread( target=main.CLIs[ i ].workQueueTotalInProgress,
Jon Halle0f0b342017-04-18 11:43:47 -0700189 name="WorkQueueInProgress-" + str( i ),
190 args=[ workQueueName ] )
191 threads.append( t )
192 t.start()
193
194 for t in threads:
195 t.join()
196 inProgressValues.append( int( t.result ) )
197 # Check the results
198 inProgressResults = [ x == inProgress for x in inProgressValues ]
199 inProgressResult = all( inProgressResults )
200 if not inProgressResult:
201 main.log.warn( "Expected Work Queue {} to have {} inProgress, found {}".format(
202 workQueueName, inProgress, inProgressValues ) )
203
204 # Pending
205 threads = []
206 pendingValues = []
207 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -0700208 t = main.Thread( target=main.CLIs[ i ].workQueueTotalPending,
Jon Halle0f0b342017-04-18 11:43:47 -0700209 name="WorkQueuePending-" + str( i ),
210 args=[ workQueueName ] )
211 threads.append( t )
212 t.start()
213
214 for t in threads:
215 t.join()
216 pendingValues.append( int( t.result ) )
217 # Check the results
218 pendingResults = [ x == pending for x in pendingValues ]
219 pendingResult = all( pendingResults )
220 if not pendingResult:
221 main.log.warn( "Expected Work Queue {} to have {} pending, found {}".format(
222 workQueueName, pending, pendingValues ) )
223 return completedResult and inProgressResult and pendingResult
224
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700225 def CASE17( self, main ):
226 """
227 Check for basic functionality with distributed primitives
228 """
Jon Halle0f0b342017-04-18 11:43:47 -0700229 # TODO: Clean this up so it's not just a cut/paste from the test
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700230 try:
231 # Make sure variables are defined/set
232 assert main.numCtrls, "main.numCtrls not defined"
233 assert utilities.assert_equals, "utilities.assert_equals not defined"
234 assert main.CLIs, "main.CLIs not defined"
235 assert main.nodes, "main.nodes not defined"
236 assert main.pCounterName, "main.pCounterName not defined"
237 assert main.onosSetName, "main.onosSetName not defined"
238 # NOTE: assert fails if value is 0/None/Empty/False
239 try:
240 main.pCounterValue
241 except NameError:
242 main.log.error( "main.pCounterValue not defined, setting to 0" )
243 main.pCounterValue = 0
244 try:
245 main.onosSet
246 except NameError:
247 main.log.error( "main.onosSet not defined, setting to empty Set" )
Jon Hallf37d44d2017-05-24 10:37:30 -0700248 main.onosSet = set( [] )
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700249 # Variables for the distributed primitives tests. These are local only
250 addValue = "a"
251 addAllValue = "a b c d e f"
252 retainValue = "c d e f"
Jon Halle0f0b342017-04-18 11:43:47 -0700253 valueName = "TestON-Value"
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700254 valueValue = None
Jon Halle0f0b342017-04-18 11:43:47 -0700255 workQueueName = "TestON-Queue"
256 workQueueCompleted = 0
257 workQueueInProgress = 0
258 workQueuePending = 0
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700259
260 description = "Check for basic functionality with distributed " +\
261 "primitives"
262 main.case( description )
263 main.caseExplanation = "Test the methods of the distributed " +\
264 "primitives (counters and sets) throught the cli"
265 # DISTRIBUTED ATOMIC COUNTERS
266 # Partitioned counters
267 main.step( "Increment then get a default counter on each node" )
268 pCounters = []
269 threads = []
270 addedPValues = []
271 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -0700272 t = main.Thread( target=main.CLIs[ i ].counterTestAddAndGet,
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700273 name="counterAddAndGet-" + str( i ),
274 args=[ main.pCounterName ] )
275 main.pCounterValue += 1
276 addedPValues.append( main.pCounterValue )
277 threads.append( t )
278 t.start()
279
280 for t in threads:
281 t.join()
282 pCounters.append( t.result )
283 # Check that counter incremented numController times
284 pCounterResults = True
285 for i in addedPValues:
286 tmpResult = i in pCounters
287 pCounterResults = pCounterResults and tmpResult
288 if not tmpResult:
289 main.log.error( str( i ) + " is not in partitioned "
290 "counter incremented results" )
291 utilities.assert_equals( expect=True,
292 actual=pCounterResults,
293 onpass="Default counter incremented",
294 onfail="Error incrementing default" +
295 " counter" )
296
297 main.step( "Get then Increment a default counter on each node" )
298 pCounters = []
299 threads = []
300 addedPValues = []
301 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -0700302 t = main.Thread( target=main.CLIs[ i ].counterTestGetAndAdd,
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700303 name="counterGetAndAdd-" + str( i ),
304 args=[ main.pCounterName ] )
305 addedPValues.append( main.pCounterValue )
306 main.pCounterValue += 1
307 threads.append( t )
308 t.start()
309
310 for t in threads:
311 t.join()
312 pCounters.append( t.result )
313 # Check that counter incremented numController times
314 pCounterResults = True
315 for i in addedPValues:
316 tmpResult = i in pCounters
317 pCounterResults = pCounterResults and tmpResult
318 if not tmpResult:
319 main.log.error( str( i ) + " is not in partitioned "
320 "counter incremented results" )
321 utilities.assert_equals( expect=True,
322 actual=pCounterResults,
323 onpass="Default counter incremented",
324 onfail="Error incrementing default" +
325 " counter" )
326
327 main.step( "Counters we added have the correct values" )
328 incrementCheck = main.HA.counterCheck( main.pCounterName, main.pCounterValue )
329 utilities.assert_equals( expect=main.TRUE,
330 actual=incrementCheck,
331 onpass="Added counters are correct",
332 onfail="Added counters are incorrect" )
333
334 main.step( "Add -8 to then get a default counter on each node" )
335 pCounters = []
336 threads = []
337 addedPValues = []
338 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -0700339 t = main.Thread( target=main.CLIs[ i ].counterTestAddAndGet,
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700340 name="counterIncrement-" + str( i ),
341 args=[ main.pCounterName ],
342 kwargs={ "delta": -8 } )
343 main.pCounterValue += -8
344 addedPValues.append( main.pCounterValue )
345 threads.append( t )
346 t.start()
347
348 for t in threads:
349 t.join()
350 pCounters.append( t.result )
351 # Check that counter incremented numController times
352 pCounterResults = True
353 for i in addedPValues:
354 tmpResult = i in pCounters
355 pCounterResults = pCounterResults and tmpResult
356 if not tmpResult:
357 main.log.error( str( i ) + " is not in partitioned "
358 "counter incremented results" )
359 utilities.assert_equals( expect=True,
360 actual=pCounterResults,
361 onpass="Default counter incremented",
362 onfail="Error incrementing default" +
363 " counter" )
364
365 main.step( "Add 5 to then get a default counter on each node" )
366 pCounters = []
367 threads = []
368 addedPValues = []
369 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -0700370 t = main.Thread( target=main.CLIs[ i ].counterTestAddAndGet,
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700371 name="counterIncrement-" + str( i ),
372 args=[ main.pCounterName ],
373 kwargs={ "delta": 5 } )
374 main.pCounterValue += 5
375 addedPValues.append( main.pCounterValue )
376 threads.append( t )
377 t.start()
378
379 for t in threads:
380 t.join()
381 pCounters.append( t.result )
382 # Check that counter incremented numController times
383 pCounterResults = True
384 for i in addedPValues:
385 tmpResult = i in pCounters
386 pCounterResults = pCounterResults and tmpResult
387 if not tmpResult:
388 main.log.error( str( i ) + " is not in partitioned "
389 "counter incremented results" )
390 utilities.assert_equals( expect=True,
391 actual=pCounterResults,
392 onpass="Default counter incremented",
393 onfail="Error incrementing default" +
394 " counter" )
395
396 main.step( "Get then add 5 to a default counter on each node" )
397 pCounters = []
398 threads = []
399 addedPValues = []
400 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -0700401 t = main.Thread( target=main.CLIs[ i ].counterTestGetAndAdd,
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700402 name="counterIncrement-" + str( i ),
403 args=[ main.pCounterName ],
404 kwargs={ "delta": 5 } )
405 addedPValues.append( main.pCounterValue )
406 main.pCounterValue += 5
407 threads.append( t )
408 t.start()
409
410 for t in threads:
411 t.join()
412 pCounters.append( t.result )
413 # Check that counter incremented numController times
414 pCounterResults = True
415 for i in addedPValues:
416 tmpResult = i in pCounters
417 pCounterResults = pCounterResults and tmpResult
418 if not tmpResult:
419 main.log.error( str( i ) + " is not in partitioned "
420 "counter incremented results" )
421 utilities.assert_equals( expect=True,
422 actual=pCounterResults,
423 onpass="Default counter incremented",
424 onfail="Error incrementing default" +
425 " counter" )
426
427 main.step( "Counters we added have the correct values" )
428 incrementCheck = main.HA.counterCheck( main.pCounterName, main.pCounterValue )
429 utilities.assert_equals( expect=main.TRUE,
430 actual=incrementCheck,
431 onpass="Added counters are correct",
432 onfail="Added counters are incorrect" )
433
434 # DISTRIBUTED SETS
435 main.step( "Distributed Set get" )
436 size = len( main.onosSet )
437 getResponses = []
438 threads = []
439 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -0700440 t = main.Thread( target=main.CLIs[ i ].setTestGet,
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700441 name="setTestGet-" + str( i ),
442 args=[ main.onosSetName ] )
443 threads.append( t )
444 t.start()
445 for t in threads:
446 t.join()
447 getResponses.append( t.result )
448
449 getResults = main.TRUE
450 for i in range( len( main.activeNodes ) ):
Jon Hallf37d44d2017-05-24 10:37:30 -0700451 node = str( main.activeNodes[ i ] + 1 )
452 if isinstance( getResponses[ i ], list ):
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700453 current = set( getResponses[ i ] )
454 if len( current ) == len( getResponses[ i ] ):
455 # no repeats
456 if main.onosSet != current:
457 main.log.error( "ONOS" + node +
458 " has incorrect view" +
459 " of set " + main.onosSetName + ":\n" +
460 str( getResponses[ i ] ) )
461 main.log.debug( "Expected: " + str( main.onosSet ) )
462 main.log.debug( "Actual: " + str( current ) )
463 getResults = main.FALSE
464 else:
465 # error, set is not a set
466 main.log.error( "ONOS" + node +
467 " has repeat elements in" +
468 " set " + main.onosSetName + ":\n" +
469 str( getResponses[ i ] ) )
470 getResults = main.FALSE
471 elif getResponses[ i ] == main.ERROR:
472 getResults = main.FALSE
473 utilities.assert_equals( expect=main.TRUE,
474 actual=getResults,
475 onpass="Set elements are correct",
476 onfail="Set elements are incorrect" )
477
478 main.step( "Distributed Set size" )
479 sizeResponses = []
480 threads = []
481 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -0700482 t = main.Thread( target=main.CLIs[ i ].setTestSize,
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700483 name="setTestSize-" + str( i ),
484 args=[ main.onosSetName ] )
485 threads.append( t )
486 t.start()
487 for t in threads:
488 t.join()
489 sizeResponses.append( t.result )
490
491 sizeResults = main.TRUE
492 for i in range( len( main.activeNodes ) ):
Jon Hallf37d44d2017-05-24 10:37:30 -0700493 node = str( main.activeNodes[ i ] + 1 )
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700494 if size != sizeResponses[ i ]:
495 sizeResults = main.FALSE
496 main.log.error( "ONOS" + node +
497 " expected a size of " + str( size ) +
498 " for set " + main.onosSetName +
499 " but got " + str( sizeResponses[ i ] ) )
500 utilities.assert_equals( expect=main.TRUE,
501 actual=sizeResults,
502 onpass="Set sizes are correct",
503 onfail="Set sizes are incorrect" )
504
505 main.step( "Distributed Set add()" )
506 main.onosSet.add( addValue )
507 addResponses = []
508 threads = []
509 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -0700510 t = main.Thread( target=main.CLIs[ i ].setTestAdd,
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700511 name="setTestAdd-" + str( i ),
512 args=[ main.onosSetName, addValue ] )
513 threads.append( t )
514 t.start()
515 for t in threads:
516 t.join()
517 addResponses.append( t.result )
518
519 # main.TRUE = successfully changed the set
520 # main.FALSE = action resulted in no change in set
521 # main.ERROR - Some error in executing the function
522 addResults = main.TRUE
523 for i in range( len( main.activeNodes ) ):
524 if addResponses[ i ] == main.TRUE:
525 # All is well
526 pass
527 elif addResponses[ i ] == main.FALSE:
528 # Already in set, probably fine
529 pass
530 elif addResponses[ i ] == main.ERROR:
531 # Error in execution
532 addResults = main.FALSE
533 else:
534 # unexpected result
535 addResults = main.FALSE
536 if addResults != main.TRUE:
537 main.log.error( "Error executing set add" )
538
539 # Check if set is still correct
540 size = len( main.onosSet )
541 getResponses = []
542 threads = []
543 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -0700544 t = main.Thread( target=main.CLIs[ i ].setTestGet,
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700545 name="setTestGet-" + str( i ),
546 args=[ main.onosSetName ] )
547 threads.append( t )
548 t.start()
549 for t in threads:
550 t.join()
551 getResponses.append( t.result )
552 getResults = main.TRUE
553 for i in range( len( main.activeNodes ) ):
Jon Hallf37d44d2017-05-24 10:37:30 -0700554 node = str( main.activeNodes[ i ] + 1 )
555 if isinstance( getResponses[ i ], list ):
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700556 current = set( getResponses[ i ] )
557 if len( current ) == len( getResponses[ i ] ):
558 # no repeats
559 if main.onosSet != current:
560 main.log.error( "ONOS" + node + " has incorrect view" +
561 " of set " + main.onosSetName + ":\n" +
562 str( getResponses[ i ] ) )
563 main.log.debug( "Expected: " + str( main.onosSet ) )
564 main.log.debug( "Actual: " + str( current ) )
565 getResults = main.FALSE
566 else:
567 # error, set is not a set
568 main.log.error( "ONOS" + node + " has repeat elements in" +
569 " set " + main.onosSetName + ":\n" +
570 str( getResponses[ i ] ) )
571 getResults = main.FALSE
572 elif getResponses[ i ] == main.ERROR:
573 getResults = main.FALSE
574 sizeResponses = []
575 threads = []
576 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -0700577 t = main.Thread( target=main.CLIs[ i ].setTestSize,
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700578 name="setTestSize-" + str( i ),
579 args=[ main.onosSetName ] )
580 threads.append( t )
581 t.start()
582 for t in threads:
583 t.join()
584 sizeResponses.append( t.result )
585 sizeResults = main.TRUE
586 for i in range( len( main.activeNodes ) ):
Jon Hallf37d44d2017-05-24 10:37:30 -0700587 node = str( main.activeNodes[ i ] + 1 )
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700588 if size != sizeResponses[ i ]:
589 sizeResults = main.FALSE
590 main.log.error( "ONOS" + node +
591 " expected a size of " + str( size ) +
592 " for set " + main.onosSetName +
593 " but got " + str( sizeResponses[ i ] ) )
594 addResults = addResults and getResults and sizeResults
595 utilities.assert_equals( expect=main.TRUE,
596 actual=addResults,
597 onpass="Set add correct",
598 onfail="Set add was incorrect" )
599
600 main.step( "Distributed Set addAll()" )
601 main.onosSet.update( addAllValue.split() )
602 addResponses = []
603 threads = []
604 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -0700605 t = main.Thread( target=main.CLIs[ i ].setTestAdd,
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700606 name="setTestAddAll-" + str( i ),
607 args=[ main.onosSetName, addAllValue ] )
608 threads.append( t )
609 t.start()
610 for t in threads:
611 t.join()
612 addResponses.append( t.result )
613
614 # main.TRUE = successfully changed the set
615 # main.FALSE = action resulted in no change in set
616 # main.ERROR - Some error in executing the function
617 addAllResults = main.TRUE
618 for i in range( len( main.activeNodes ) ):
619 if addResponses[ i ] == main.TRUE:
620 # All is well
621 pass
622 elif addResponses[ i ] == main.FALSE:
623 # Already in set, probably fine
624 pass
625 elif addResponses[ i ] == main.ERROR:
626 # Error in execution
627 addAllResults = main.FALSE
628 else:
629 # unexpected result
630 addAllResults = main.FALSE
631 if addAllResults != main.TRUE:
632 main.log.error( "Error executing set addAll" )
633
634 # Check if set is still correct
635 size = len( main.onosSet )
636 getResponses = []
637 threads = []
638 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -0700639 t = main.Thread( target=main.CLIs[ i ].setTestGet,
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700640 name="setTestGet-" + str( i ),
641 args=[ main.onosSetName ] )
642 threads.append( t )
643 t.start()
644 for t in threads:
645 t.join()
646 getResponses.append( t.result )
647 getResults = main.TRUE
648 for i in range( len( main.activeNodes ) ):
Jon Hallf37d44d2017-05-24 10:37:30 -0700649 node = str( main.activeNodes[ i ] + 1 )
650 if isinstance( getResponses[ i ], list ):
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700651 current = set( getResponses[ i ] )
652 if len( current ) == len( getResponses[ i ] ):
653 # no repeats
654 if main.onosSet != current:
655 main.log.error( "ONOS" + node +
656 " has incorrect view" +
657 " of set " + main.onosSetName + ":\n" +
658 str( getResponses[ i ] ) )
659 main.log.debug( "Expected: " + str( main.onosSet ) )
660 main.log.debug( "Actual: " + str( current ) )
661 getResults = main.FALSE
662 else:
663 # error, set is not a set
664 main.log.error( "ONOS" + node +
665 " has repeat elements in" +
666 " set " + main.onosSetName + ":\n" +
667 str( getResponses[ i ] ) )
668 getResults = main.FALSE
669 elif getResponses[ i ] == main.ERROR:
670 getResults = main.FALSE
671 sizeResponses = []
672 threads = []
673 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -0700674 t = main.Thread( target=main.CLIs[ i ].setTestSize,
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700675 name="setTestSize-" + str( i ),
676 args=[ main.onosSetName ] )
677 threads.append( t )
678 t.start()
679 for t in threads:
680 t.join()
681 sizeResponses.append( t.result )
682 sizeResults = main.TRUE
683 for i in range( len( main.activeNodes ) ):
Jon Hallf37d44d2017-05-24 10:37:30 -0700684 node = str( main.activeNodes[ i ] + 1 )
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700685 if size != sizeResponses[ i ]:
686 sizeResults = main.FALSE
687 main.log.error( "ONOS" + node +
688 " expected a size of " + str( size ) +
689 " for set " + main.onosSetName +
690 " but got " + str( sizeResponses[ i ] ) )
691 addAllResults = addAllResults and getResults and sizeResults
692 utilities.assert_equals( expect=main.TRUE,
693 actual=addAllResults,
694 onpass="Set addAll correct",
695 onfail="Set addAll was incorrect" )
696
697 main.step( "Distributed Set contains()" )
698 containsResponses = []
699 threads = []
700 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -0700701 t = main.Thread( target=main.CLIs[ i ].setTestGet,
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700702 name="setContains-" + str( i ),
703 args=[ main.onosSetName ],
704 kwargs={ "values": addValue } )
705 threads.append( t )
706 t.start()
707 for t in threads:
708 t.join()
709 # NOTE: This is the tuple
710 containsResponses.append( t.result )
711
712 containsResults = main.TRUE
713 for i in range( len( main.activeNodes ) ):
714 if containsResponses[ i ] == main.ERROR:
715 containsResults = main.FALSE
716 else:
717 containsResults = containsResults and\
718 containsResponses[ i ][ 1 ]
719 utilities.assert_equals( expect=main.TRUE,
720 actual=containsResults,
721 onpass="Set contains is functional",
722 onfail="Set contains failed" )
723
724 main.step( "Distributed Set containsAll()" )
725 containsAllResponses = []
726 threads = []
727 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -0700728 t = main.Thread( target=main.CLIs[ i ].setTestGet,
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700729 name="setContainsAll-" + str( i ),
730 args=[ main.onosSetName ],
731 kwargs={ "values": addAllValue } )
732 threads.append( t )
733 t.start()
734 for t in threads:
735 t.join()
736 # NOTE: This is the tuple
737 containsAllResponses.append( t.result )
738
739 containsAllResults = main.TRUE
740 for i in range( len( main.activeNodes ) ):
741 if containsResponses[ i ] == main.ERROR:
742 containsResults = main.FALSE
743 else:
744 containsResults = containsResults and\
745 containsResponses[ i ][ 1 ]
746 utilities.assert_equals( expect=main.TRUE,
747 actual=containsAllResults,
748 onpass="Set containsAll is functional",
749 onfail="Set containsAll failed" )
750
751 main.step( "Distributed Set remove()" )
752 main.onosSet.remove( addValue )
753 removeResponses = []
754 threads = []
755 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -0700756 t = main.Thread( target=main.CLIs[ i ].setTestRemove,
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700757 name="setTestRemove-" + str( i ),
758 args=[ main.onosSetName, addValue ] )
759 threads.append( t )
760 t.start()
761 for t in threads:
762 t.join()
763 removeResponses.append( t.result )
764
765 # main.TRUE = successfully changed the set
766 # main.FALSE = action resulted in no change in set
767 # main.ERROR - Some error in executing the function
768 removeResults = main.TRUE
769 for i in range( len( main.activeNodes ) ):
770 if removeResponses[ i ] == main.TRUE:
771 # All is well
772 pass
773 elif removeResponses[ i ] == main.FALSE:
774 # not in set, probably fine
775 pass
776 elif removeResponses[ i ] == main.ERROR:
777 # Error in execution
778 removeResults = main.FALSE
779 else:
780 # unexpected result
781 removeResults = main.FALSE
782 if removeResults != main.TRUE:
783 main.log.error( "Error executing set remove" )
784
785 # Check if set is still correct
786 size = len( main.onosSet )
787 getResponses = []
788 threads = []
789 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -0700790 t = main.Thread( target=main.CLIs[ i ].setTestGet,
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700791 name="setTestGet-" + str( i ),
792 args=[ main.onosSetName ] )
793 threads.append( t )
794 t.start()
795 for t in threads:
796 t.join()
797 getResponses.append( t.result )
798 getResults = main.TRUE
799 for i in range( len( main.activeNodes ) ):
Jon Hallf37d44d2017-05-24 10:37:30 -0700800 node = str( main.activeNodes[ i ] + 1 )
801 if isinstance( getResponses[ i ], list ):
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700802 current = set( getResponses[ i ] )
803 if len( current ) == len( getResponses[ i ] ):
804 # no repeats
805 if main.onosSet != current:
806 main.log.error( "ONOS" + node +
807 " has incorrect view" +
808 " of set " + main.onosSetName + ":\n" +
809 str( getResponses[ i ] ) )
810 main.log.debug( "Expected: " + str( main.onosSet ) )
811 main.log.debug( "Actual: " + str( current ) )
812 getResults = main.FALSE
813 else:
814 # error, set is not a set
815 main.log.error( "ONOS" + node +
816 " has repeat elements in" +
817 " set " + main.onosSetName + ":\n" +
818 str( getResponses[ i ] ) )
819 getResults = main.FALSE
820 elif getResponses[ i ] == main.ERROR:
821 getResults = main.FALSE
822 sizeResponses = []
823 threads = []
824 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -0700825 t = main.Thread( target=main.CLIs[ i ].setTestSize,
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700826 name="setTestSize-" + str( i ),
827 args=[ main.onosSetName ] )
828 threads.append( t )
829 t.start()
830 for t in threads:
831 t.join()
832 sizeResponses.append( t.result )
833 sizeResults = main.TRUE
834 for i in range( len( main.activeNodes ) ):
Jon Hallf37d44d2017-05-24 10:37:30 -0700835 node = str( main.activeNodes[ i ] + 1 )
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700836 if size != sizeResponses[ i ]:
837 sizeResults = main.FALSE
838 main.log.error( "ONOS" + node +
839 " expected a size of " + str( size ) +
840 " for set " + main.onosSetName +
841 " but got " + str( sizeResponses[ i ] ) )
842 removeResults = removeResults and getResults and sizeResults
843 utilities.assert_equals( expect=main.TRUE,
844 actual=removeResults,
845 onpass="Set remove correct",
846 onfail="Set remove was incorrect" )
847
848 main.step( "Distributed Set removeAll()" )
849 main.onosSet.difference_update( addAllValue.split() )
850 removeAllResponses = []
851 threads = []
852 try:
853 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -0700854 t = main.Thread( target=main.CLIs[ i ].setTestRemove,
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700855 name="setTestRemoveAll-" + str( i ),
856 args=[ main.onosSetName, addAllValue ] )
857 threads.append( t )
858 t.start()
859 for t in threads:
860 t.join()
861 removeAllResponses.append( t.result )
Jon Hallf37d44d2017-05-24 10:37:30 -0700862 except Exception as e:
863 main.log.exception( e )
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700864
865 # main.TRUE = successfully changed the set
866 # main.FALSE = action resulted in no change in set
867 # main.ERROR - Some error in executing the function
868 removeAllResults = main.TRUE
869 for i in range( len( main.activeNodes ) ):
870 if removeAllResponses[ i ] == main.TRUE:
871 # All is well
872 pass
873 elif removeAllResponses[ i ] == main.FALSE:
874 # not in set, probably fine
875 pass
876 elif removeAllResponses[ i ] == main.ERROR:
877 # Error in execution
878 removeAllResults = main.FALSE
879 else:
880 # unexpected result
881 removeAllResults = main.FALSE
882 if removeAllResults != main.TRUE:
883 main.log.error( "Error executing set removeAll" )
884
885 # Check if set is still correct
886 size = len( main.onosSet )
887 getResponses = []
888 threads = []
889 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -0700890 t = main.Thread( target=main.CLIs[ i ].setTestGet,
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700891 name="setTestGet-" + str( i ),
892 args=[ main.onosSetName ] )
893 threads.append( t )
894 t.start()
895 for t in threads:
896 t.join()
897 getResponses.append( t.result )
898 getResults = main.TRUE
899 for i in range( len( main.activeNodes ) ):
Jon Hallf37d44d2017-05-24 10:37:30 -0700900 node = str( main.activeNodes[ i ] + 1 )
901 if isinstance( getResponses[ i ], list ):
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700902 current = set( getResponses[ i ] )
903 if len( current ) == len( getResponses[ i ] ):
904 # no repeats
905 if main.onosSet != current:
906 main.log.error( "ONOS" + node +
907 " has incorrect view" +
908 " of set " + main.onosSetName + ":\n" +
909 str( getResponses[ i ] ) )
910 main.log.debug( "Expected: " + str( main.onosSet ) )
911 main.log.debug( "Actual: " + str( current ) )
912 getResults = main.FALSE
913 else:
914 # error, set is not a set
915 main.log.error( "ONOS" + node +
916 " has repeat elements in" +
917 " set " + main.onosSetName + ":\n" +
918 str( getResponses[ i ] ) )
919 getResults = main.FALSE
920 elif getResponses[ i ] == main.ERROR:
921 getResults = main.FALSE
922 sizeResponses = []
923 threads = []
924 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -0700925 t = main.Thread( target=main.CLIs[ i ].setTestSize,
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700926 name="setTestSize-" + str( i ),
927 args=[ main.onosSetName ] )
928 threads.append( t )
929 t.start()
930 for t in threads:
931 t.join()
932 sizeResponses.append( t.result )
933 sizeResults = main.TRUE
934 for i in range( len( main.activeNodes ) ):
Jon Hallf37d44d2017-05-24 10:37:30 -0700935 node = str( main.activeNodes[ i ] + 1 )
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700936 if size != sizeResponses[ i ]:
937 sizeResults = main.FALSE
938 main.log.error( "ONOS" + node +
939 " expected a size of " + str( size ) +
940 " for set " + main.onosSetName +
941 " but got " + str( sizeResponses[ i ] ) )
942 removeAllResults = removeAllResults and getResults and sizeResults
943 utilities.assert_equals( expect=main.TRUE,
944 actual=removeAllResults,
945 onpass="Set removeAll correct",
946 onfail="Set removeAll was incorrect" )
947
948 main.step( "Distributed Set addAll()" )
949 main.onosSet.update( addAllValue.split() )
950 addResponses = []
951 threads = []
952 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -0700953 t = main.Thread( target=main.CLIs[ i ].setTestAdd,
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700954 name="setTestAddAll-" + str( i ),
955 args=[ main.onosSetName, addAllValue ] )
956 threads.append( t )
957 t.start()
958 for t in threads:
959 t.join()
960 addResponses.append( t.result )
961
962 # main.TRUE = successfully changed the set
963 # main.FALSE = action resulted in no change in set
964 # main.ERROR - Some error in executing the function
965 addAllResults = main.TRUE
966 for i in range( len( main.activeNodes ) ):
967 if addResponses[ i ] == main.TRUE:
968 # All is well
969 pass
970 elif addResponses[ i ] == main.FALSE:
971 # Already in set, probably fine
972 pass
973 elif addResponses[ i ] == main.ERROR:
974 # Error in execution
975 addAllResults = main.FALSE
976 else:
977 # unexpected result
978 addAllResults = main.FALSE
979 if addAllResults != main.TRUE:
980 main.log.error( "Error executing set addAll" )
981
982 # Check if set is still correct
983 size = len( main.onosSet )
984 getResponses = []
985 threads = []
986 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -0700987 t = main.Thread( target=main.CLIs[ i ].setTestGet,
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700988 name="setTestGet-" + str( i ),
989 args=[ main.onosSetName ] )
990 threads.append( t )
991 t.start()
992 for t in threads:
993 t.join()
994 getResponses.append( t.result )
995 getResults = main.TRUE
996 for i in range( len( main.activeNodes ) ):
Jon Hallf37d44d2017-05-24 10:37:30 -0700997 node = str( main.activeNodes[ i ] + 1 )
998 if isinstance( getResponses[ i ], list ):
Jon Hall7a6ebfd2017-03-13 10:58:58 -0700999 current = set( getResponses[ i ] )
1000 if len( current ) == len( getResponses[ i ] ):
1001 # no repeats
1002 if main.onosSet != current:
1003 main.log.error( "ONOS" + node +
1004 " has incorrect view" +
1005 " of set " + main.onosSetName + ":\n" +
1006 str( getResponses[ i ] ) )
1007 main.log.debug( "Expected: " + str( main.onosSet ) )
1008 main.log.debug( "Actual: " + str( current ) )
1009 getResults = main.FALSE
1010 else:
1011 # error, set is not a set
1012 main.log.error( "ONOS" + node +
1013 " has repeat elements in" +
1014 " set " + main.onosSetName + ":\n" +
1015 str( getResponses[ i ] ) )
1016 getResults = main.FALSE
1017 elif getResponses[ i ] == main.ERROR:
1018 getResults = main.FALSE
1019 sizeResponses = []
1020 threads = []
1021 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -07001022 t = main.Thread( target=main.CLIs[ i ].setTestSize,
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001023 name="setTestSize-" + str( i ),
1024 args=[ main.onosSetName ] )
1025 threads.append( t )
1026 t.start()
1027 for t in threads:
1028 t.join()
1029 sizeResponses.append( t.result )
1030 sizeResults = main.TRUE
1031 for i in range( len( main.activeNodes ) ):
Jon Hallf37d44d2017-05-24 10:37:30 -07001032 node = str( main.activeNodes[ i ] + 1 )
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001033 if size != sizeResponses[ i ]:
1034 sizeResults = main.FALSE
1035 main.log.error( "ONOS" + node +
1036 " expected a size of " + str( size ) +
1037 " for set " + main.onosSetName +
1038 " but got " + str( sizeResponses[ i ] ) )
1039 addAllResults = addAllResults and getResults and sizeResults
1040 utilities.assert_equals( expect=main.TRUE,
1041 actual=addAllResults,
1042 onpass="Set addAll correct",
1043 onfail="Set addAll was incorrect" )
1044
1045 main.step( "Distributed Set clear()" )
1046 main.onosSet.clear()
1047 clearResponses = []
1048 threads = []
1049 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -07001050 t = main.Thread( target=main.CLIs[ i ].setTestRemove,
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001051 name="setTestClear-" + str( i ),
Jon Hallf37d44d2017-05-24 10:37:30 -07001052 args=[ main.onosSetName, " " ], # Values doesn't matter
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001053 kwargs={ "clear": True } )
1054 threads.append( t )
1055 t.start()
1056 for t in threads:
1057 t.join()
1058 clearResponses.append( t.result )
1059
1060 # main.TRUE = successfully changed the set
1061 # main.FALSE = action resulted in no change in set
1062 # main.ERROR - Some error in executing the function
1063 clearResults = main.TRUE
1064 for i in range( len( main.activeNodes ) ):
1065 if clearResponses[ i ] == main.TRUE:
1066 # All is well
1067 pass
1068 elif clearResponses[ i ] == main.FALSE:
1069 # Nothing set, probably fine
1070 pass
1071 elif clearResponses[ i ] == main.ERROR:
1072 # Error in execution
1073 clearResults = main.FALSE
1074 else:
1075 # unexpected result
1076 clearResults = main.FALSE
1077 if clearResults != main.TRUE:
1078 main.log.error( "Error executing set clear" )
1079
1080 # Check if set is still correct
1081 size = len( main.onosSet )
1082 getResponses = []
1083 threads = []
1084 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -07001085 t = main.Thread( target=main.CLIs[ i ].setTestGet,
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001086 name="setTestGet-" + str( i ),
1087 args=[ main.onosSetName ] )
1088 threads.append( t )
1089 t.start()
1090 for t in threads:
1091 t.join()
1092 getResponses.append( t.result )
1093 getResults = main.TRUE
1094 for i in range( len( main.activeNodes ) ):
Jon Hallf37d44d2017-05-24 10:37:30 -07001095 node = str( main.activeNodes[ i ] + 1 )
1096 if isinstance( getResponses[ i ], list ):
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001097 current = set( getResponses[ i ] )
1098 if len( current ) == len( getResponses[ i ] ):
1099 # no repeats
1100 if main.onosSet != current:
1101 main.log.error( "ONOS" + node +
1102 " has incorrect view" +
1103 " of set " + main.onosSetName + ":\n" +
1104 str( getResponses[ i ] ) )
1105 main.log.debug( "Expected: " + str( main.onosSet ) )
1106 main.log.debug( "Actual: " + str( current ) )
1107 getResults = main.FALSE
1108 else:
1109 # error, set is not a set
1110 main.log.error( "ONOS" + node +
1111 " has repeat elements in" +
1112 " set " + main.onosSetName + ":\n" +
1113 str( getResponses[ i ] ) )
1114 getResults = main.FALSE
1115 elif getResponses[ i ] == main.ERROR:
1116 getResults = main.FALSE
1117 sizeResponses = []
1118 threads = []
1119 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -07001120 t = main.Thread( target=main.CLIs[ i ].setTestSize,
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001121 name="setTestSize-" + str( i ),
1122 args=[ main.onosSetName ] )
1123 threads.append( t )
1124 t.start()
1125 for t in threads:
1126 t.join()
1127 sizeResponses.append( t.result )
1128 sizeResults = main.TRUE
1129 for i in range( len( main.activeNodes ) ):
Jon Hallf37d44d2017-05-24 10:37:30 -07001130 node = str( main.activeNodes[ i ] + 1 )
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001131 if size != sizeResponses[ i ]:
1132 sizeResults = main.FALSE
1133 main.log.error( "ONOS" + node +
1134 " expected a size of " + str( size ) +
1135 " for set " + main.onosSetName +
1136 " but got " + str( sizeResponses[ i ] ) )
1137 clearResults = clearResults and getResults and sizeResults
1138 utilities.assert_equals( expect=main.TRUE,
1139 actual=clearResults,
1140 onpass="Set clear correct",
1141 onfail="Set clear was incorrect" )
1142
1143 main.step( "Distributed Set addAll()" )
1144 main.onosSet.update( addAllValue.split() )
1145 addResponses = []
1146 threads = []
1147 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -07001148 t = main.Thread( target=main.CLIs[ i ].setTestAdd,
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001149 name="setTestAddAll-" + str( i ),
1150 args=[ main.onosSetName, addAllValue ] )
1151 threads.append( t )
1152 t.start()
1153 for t in threads:
1154 t.join()
1155 addResponses.append( t.result )
1156
1157 # main.TRUE = successfully changed the set
1158 # main.FALSE = action resulted in no change in set
1159 # main.ERROR - Some error in executing the function
1160 addAllResults = main.TRUE
1161 for i in range( len( main.activeNodes ) ):
1162 if addResponses[ i ] == main.TRUE:
1163 # All is well
1164 pass
1165 elif addResponses[ i ] == main.FALSE:
1166 # Already in set, probably fine
1167 pass
1168 elif addResponses[ i ] == main.ERROR:
1169 # Error in execution
1170 addAllResults = main.FALSE
1171 else:
1172 # unexpected result
1173 addAllResults = main.FALSE
1174 if addAllResults != main.TRUE:
1175 main.log.error( "Error executing set addAll" )
1176
1177 # Check if set is still correct
1178 size = len( main.onosSet )
1179 getResponses = []
1180 threads = []
1181 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -07001182 t = main.Thread( target=main.CLIs[ i ].setTestGet,
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001183 name="setTestGet-" + str( i ),
1184 args=[ main.onosSetName ] )
1185 threads.append( t )
1186 t.start()
1187 for t in threads:
1188 t.join()
1189 getResponses.append( t.result )
1190 getResults = main.TRUE
1191 for i in range( len( main.activeNodes ) ):
Jon Hallf37d44d2017-05-24 10:37:30 -07001192 node = str( main.activeNodes[ i ] + 1 )
1193 if isinstance( getResponses[ i ], list ):
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001194 current = set( getResponses[ i ] )
1195 if len( current ) == len( getResponses[ i ] ):
1196 # no repeats
1197 if main.onosSet != current:
1198 main.log.error( "ONOS" + node +
1199 " has incorrect view" +
1200 " of set " + main.onosSetName + ":\n" +
1201 str( getResponses[ i ] ) )
1202 main.log.debug( "Expected: " + str( main.onosSet ) )
1203 main.log.debug( "Actual: " + str( current ) )
1204 getResults = main.FALSE
1205 else:
1206 # error, set is not a set
1207 main.log.error( "ONOS" + node +
1208 " has repeat elements in" +
1209 " set " + main.onosSetName + ":\n" +
1210 str( getResponses[ i ] ) )
1211 getResults = main.FALSE
1212 elif getResponses[ i ] == main.ERROR:
1213 getResults = main.FALSE
1214 sizeResponses = []
1215 threads = []
1216 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -07001217 t = main.Thread( target=main.CLIs[ i ].setTestSize,
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001218 name="setTestSize-" + str( i ),
1219 args=[ main.onosSetName ] )
1220 threads.append( t )
1221 t.start()
1222 for t in threads:
1223 t.join()
1224 sizeResponses.append( t.result )
1225 sizeResults = main.TRUE
1226 for i in range( len( main.activeNodes ) ):
Jon Hallf37d44d2017-05-24 10:37:30 -07001227 node = str( main.activeNodes[ i ] + 1 )
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001228 if size != sizeResponses[ i ]:
1229 sizeResults = main.FALSE
1230 main.log.error( "ONOS" + node +
1231 " expected a size of " + str( size ) +
1232 " for set " + main.onosSetName +
1233 " but got " + str( sizeResponses[ i ] ) )
1234 addAllResults = addAllResults and getResults and sizeResults
1235 utilities.assert_equals( expect=main.TRUE,
1236 actual=addAllResults,
1237 onpass="Set addAll correct",
1238 onfail="Set addAll was incorrect" )
1239
1240 main.step( "Distributed Set retain()" )
1241 main.onosSet.intersection_update( retainValue.split() )
1242 retainResponses = []
1243 threads = []
1244 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -07001245 t = main.Thread( target=main.CLIs[ i ].setTestRemove,
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001246 name="setTestRetain-" + str( i ),
1247 args=[ main.onosSetName, retainValue ],
1248 kwargs={ "retain": True } )
1249 threads.append( t )
1250 t.start()
1251 for t in threads:
1252 t.join()
1253 retainResponses.append( t.result )
1254
1255 # main.TRUE = successfully changed the set
1256 # main.FALSE = action resulted in no change in set
1257 # main.ERROR - Some error in executing the function
1258 retainResults = main.TRUE
1259 for i in range( len( main.activeNodes ) ):
1260 if retainResponses[ i ] == main.TRUE:
1261 # All is well
1262 pass
1263 elif retainResponses[ i ] == main.FALSE:
1264 # Already in set, probably fine
1265 pass
1266 elif retainResponses[ i ] == main.ERROR:
1267 # Error in execution
1268 retainResults = main.FALSE
1269 else:
1270 # unexpected result
1271 retainResults = main.FALSE
1272 if retainResults != main.TRUE:
1273 main.log.error( "Error executing set retain" )
1274
1275 # Check if set is still correct
1276 size = len( main.onosSet )
1277 getResponses = []
1278 threads = []
1279 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -07001280 t = main.Thread( target=main.CLIs[ i ].setTestGet,
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001281 name="setTestGet-" + str( i ),
1282 args=[ main.onosSetName ] )
1283 threads.append( t )
1284 t.start()
1285 for t in threads:
1286 t.join()
1287 getResponses.append( t.result )
1288 getResults = main.TRUE
1289 for i in range( len( main.activeNodes ) ):
Jon Hallf37d44d2017-05-24 10:37:30 -07001290 node = str( main.activeNodes[ i ] + 1 )
1291 if isinstance( getResponses[ i ], list ):
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001292 current = set( getResponses[ i ] )
1293 if len( current ) == len( getResponses[ i ] ):
1294 # no repeats
1295 if main.onosSet != current:
1296 main.log.error( "ONOS" + node +
1297 " has incorrect view" +
1298 " of set " + main.onosSetName + ":\n" +
1299 str( getResponses[ i ] ) )
1300 main.log.debug( "Expected: " + str( main.onosSet ) )
1301 main.log.debug( "Actual: " + str( current ) )
1302 getResults = main.FALSE
1303 else:
1304 # error, set is not a set
1305 main.log.error( "ONOS" + node +
1306 " has repeat elements in" +
1307 " set " + main.onosSetName + ":\n" +
1308 str( getResponses[ i ] ) )
1309 getResults = main.FALSE
1310 elif getResponses[ i ] == main.ERROR:
1311 getResults = main.FALSE
1312 sizeResponses = []
1313 threads = []
1314 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -07001315 t = main.Thread( target=main.CLIs[ i ].setTestSize,
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001316 name="setTestSize-" + str( i ),
1317 args=[ main.onosSetName ] )
1318 threads.append( t )
1319 t.start()
1320 for t in threads:
1321 t.join()
1322 sizeResponses.append( t.result )
1323 sizeResults = main.TRUE
1324 for i in range( len( main.activeNodes ) ):
Jon Hallf37d44d2017-05-24 10:37:30 -07001325 node = str( main.activeNodes[ i ] + 1 )
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001326 if size != sizeResponses[ i ]:
1327 sizeResults = main.FALSE
1328 main.log.error( "ONOS" + node + " expected a size of " +
1329 str( size ) + " for set " + main.onosSetName +
1330 " but got " + str( sizeResponses[ i ] ) )
1331 retainResults = retainResults and getResults and sizeResults
1332 utilities.assert_equals( expect=main.TRUE,
1333 actual=retainResults,
1334 onpass="Set retain correct",
1335 onfail="Set retain was incorrect" )
1336
1337 # Transactional maps
1338 main.step( "Partitioned Transactional maps put" )
1339 tMapValue = "Testing"
1340 numKeys = 100
1341 putResult = True
Jon Hallf37d44d2017-05-24 10:37:30 -07001342 node = main.activeNodes[ 0 ]
1343 putResponses = main.CLIs[ node ].transactionalMapPut( numKeys, tMapValue )
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001344 if putResponses and len( putResponses ) == 100:
1345 for i in putResponses:
1346 if putResponses[ i ][ 'value' ] != tMapValue:
1347 putResult = False
1348 else:
1349 putResult = False
1350 if not putResult:
1351 main.log.debug( "Put response values: " + str( putResponses ) )
1352 utilities.assert_equals( expect=True,
1353 actual=putResult,
1354 onpass="Partitioned Transactional Map put successful",
1355 onfail="Partitioned Transactional Map put values are incorrect" )
1356
1357 main.step( "Partitioned Transactional maps get" )
1358 # FIXME: is this sleep needed?
1359 time.sleep( 5 )
1360
1361 getCheck = True
1362 for n in range( 1, numKeys + 1 ):
1363 getResponses = []
1364 threads = []
1365 valueCheck = True
1366 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -07001367 t = main.Thread( target=main.CLIs[ i ].transactionalMapGet,
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001368 name="TMap-get-" + str( i ),
1369 args=[ "Key" + str( n ) ] )
1370 threads.append( t )
1371 t.start()
1372 for t in threads:
1373 t.join()
1374 getResponses.append( t.result )
1375 for node in getResponses:
1376 if node != tMapValue:
1377 valueCheck = False
1378 if not valueCheck:
Jon Hallf37d44d2017-05-24 10:37:30 -07001379 main.log.warn( "Values for key 'Key" + str(n) + "' do not match:" )
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001380 main.log.warn( getResponses )
1381 getCheck = getCheck and valueCheck
1382 utilities.assert_equals( expect=True,
1383 actual=getCheck,
1384 onpass="Partitioned Transactional Map get values were correct",
1385 onfail="Partitioned Transactional Map values incorrect" )
1386
1387 # DISTRIBUTED ATOMIC VALUE
1388 main.step( "Get the value of a new value" )
1389 threads = []
1390 getValues = []
1391 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -07001392 t = main.Thread( target=main.CLIs[ i ].valueTestGet,
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001393 name="ValueGet-" + str( i ),
1394 args=[ valueName ] )
1395 threads.append( t )
1396 t.start()
1397
1398 for t in threads:
1399 t.join()
1400 getValues.append( t.result )
1401 main.log.debug( getValues )
1402 # Check the results
1403 atomicValueGetResult = True
1404 expected = valueValue if valueValue is not None else "null"
1405 main.log.debug( "Checking for value of " + expected )
1406 for i in getValues:
1407 if i != expected:
1408 atomicValueGetResult = False
1409 utilities.assert_equals( expect=True,
1410 actual=atomicValueGetResult,
1411 onpass="Atomic Value get successful",
1412 onfail="Error getting atomic Value " +
1413 str( valueValue ) + ", found: " +
1414 str( getValues ) )
1415
1416 main.step( "Atomic Value set()" )
1417 valueValue = "foo"
1418 threads = []
1419 setValues = []
1420 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -07001421 t = main.Thread( target=main.CLIs[ i ].valueTestSet,
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001422 name="ValueSet-" + str( i ),
1423 args=[ valueName, valueValue ] )
1424 threads.append( t )
1425 t.start()
1426
1427 for t in threads:
1428 t.join()
1429 setValues.append( t.result )
1430 main.log.debug( setValues )
1431 # Check the results
1432 atomicValueSetResults = True
1433 for i in setValues:
1434 if i != main.TRUE:
1435 atomicValueSetResults = False
1436 utilities.assert_equals( expect=True,
1437 actual=atomicValueSetResults,
1438 onpass="Atomic Value set successful",
1439 onfail="Error setting atomic Value" +
1440 str( setValues ) )
1441
1442 main.step( "Get the value after set()" )
1443 threads = []
1444 getValues = []
1445 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -07001446 t = main.Thread( target=main.CLIs[ i ].valueTestGet,
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001447 name="ValueGet-" + str( i ),
1448 args=[ valueName ] )
1449 threads.append( t )
1450 t.start()
1451
1452 for t in threads:
1453 t.join()
1454 getValues.append( t.result )
1455 main.log.debug( getValues )
1456 # Check the results
1457 atomicValueGetResult = True
1458 expected = valueValue if valueValue is not None else "null"
1459 main.log.debug( "Checking for value of " + expected )
1460 for i in getValues:
1461 if i != expected:
1462 atomicValueGetResult = False
1463 utilities.assert_equals( expect=True,
1464 actual=atomicValueGetResult,
1465 onpass="Atomic Value get successful",
1466 onfail="Error getting atomic Value " +
1467 str( valueValue ) + ", found: " +
1468 str( getValues ) )
1469
1470 main.step( "Atomic Value compareAndSet()" )
1471 oldValue = valueValue
1472 valueValue = "bar"
Jon Hallf37d44d2017-05-24 10:37:30 -07001473 i = main.activeNodes[ 0 ]
1474 CASValue = main.CLIs[ i ].valueTestCompareAndSet( valueName, oldValue, valueValue )
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001475 main.log.debug( CASValue )
1476 utilities.assert_equals( expect=main.TRUE,
1477 actual=CASValue,
1478 onpass="Atomic Value comapreAndSet successful",
1479 onfail="Error setting atomic Value:" +
1480 str( CASValue ) )
1481
1482 main.step( "Get the value after compareAndSet()" )
1483 threads = []
1484 getValues = []
1485 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -07001486 t = main.Thread( target=main.CLIs[ i ].valueTestGet,
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001487 name="ValueGet-" + str( i ),
1488 args=[ valueName ] )
1489 threads.append( t )
1490 t.start()
1491
1492 for t in threads:
1493 t.join()
1494 getValues.append( t.result )
1495 main.log.debug( getValues )
1496 # Check the results
1497 atomicValueGetResult = True
1498 expected = valueValue if valueValue is not None else "null"
1499 main.log.debug( "Checking for value of " + expected )
1500 for i in getValues:
1501 if i != expected:
1502 atomicValueGetResult = False
1503 utilities.assert_equals( expect=True,
1504 actual=atomicValueGetResult,
1505 onpass="Atomic Value get successful",
1506 onfail="Error getting atomic Value " +
1507 str( valueValue ) + ", found: " +
1508 str( getValues ) )
1509
1510 main.step( "Atomic Value getAndSet()" )
1511 oldValue = valueValue
1512 valueValue = "baz"
Jon Hallf37d44d2017-05-24 10:37:30 -07001513 i = main.activeNodes[ 0 ]
1514 GASValue = main.CLIs[ i ].valueTestGetAndSet( valueName, valueValue )
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001515 main.log.debug( GASValue )
1516 expected = oldValue if oldValue is not None else "null"
1517 utilities.assert_equals( expect=expected,
1518 actual=GASValue,
1519 onpass="Atomic Value GAS successful",
1520 onfail="Error with GetAndSet atomic Value: expected " +
1521 str( expected ) + ", found: " +
1522 str( GASValue ) )
1523
1524 main.step( "Get the value after getAndSet()" )
1525 threads = []
1526 getValues = []
1527 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -07001528 t = main.Thread( target=main.CLIs[ i ].valueTestGet,
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001529 name="ValueGet-" + str( i ),
1530 args=[ valueName ] )
1531 threads.append( t )
1532 t.start()
1533
1534 for t in threads:
1535 t.join()
1536 getValues.append( t.result )
1537 main.log.debug( getValues )
1538 # Check the results
1539 atomicValueGetResult = True
1540 expected = valueValue if valueValue is not None else "null"
1541 main.log.debug( "Checking for value of " + expected )
1542 for i in getValues:
1543 if i != expected:
1544 atomicValueGetResult = False
1545 utilities.assert_equals( expect=True,
1546 actual=atomicValueGetResult,
1547 onpass="Atomic Value get successful",
1548 onfail="Error getting atomic Value: expected " +
1549 str( valueValue ) + ", found: " +
1550 str( getValues ) )
1551
1552 main.step( "Atomic Value destory()" )
1553 valueValue = None
1554 threads = []
Jon Hallf37d44d2017-05-24 10:37:30 -07001555 i = main.activeNodes[ 0 ]
1556 destroyResult = main.CLIs[ i ].valueTestDestroy( valueName )
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001557 main.log.debug( destroyResult )
1558 # Check the results
1559 utilities.assert_equals( expect=main.TRUE,
1560 actual=destroyResult,
1561 onpass="Atomic Value destroy successful",
1562 onfail="Error destroying atomic Value" )
1563
1564 main.step( "Get the value after destroy()" )
1565 threads = []
1566 getValues = []
1567 for i in main.activeNodes:
Jon Hallf37d44d2017-05-24 10:37:30 -07001568 t = main.Thread( target=main.CLIs[ i ].valueTestGet,
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001569 name="ValueGet-" + str( i ),
1570 args=[ valueName ] )
1571 threads.append( t )
1572 t.start()
1573
1574 for t in threads:
1575 t.join()
1576 getValues.append( t.result )
1577 main.log.debug( getValues )
1578 # Check the results
1579 atomicValueGetResult = True
1580 expected = valueValue if valueValue is not None else "null"
1581 main.log.debug( "Checking for value of " + expected )
1582 for i in getValues:
1583 if i != expected:
1584 atomicValueGetResult = False
1585 utilities.assert_equals( expect=True,
1586 actual=atomicValueGetResult,
1587 onpass="Atomic Value get successful",
1588 onfail="Error getting atomic Value " +
1589 str( valueValue ) + ", found: " +
1590 str( getValues ) )
Jon Halle0f0b342017-04-18 11:43:47 -07001591
1592 # WORK QUEUES
1593 main.step( "Work Queue add()" )
1594 threads = []
Jon Hallf37d44d2017-05-24 10:37:30 -07001595 i = main.activeNodes[ 0 ]
1596 addResult = main.CLIs[ i ].workQueueAdd( workQueueName, 'foo' )
Jon Halle0f0b342017-04-18 11:43:47 -07001597 workQueuePending += 1
1598 main.log.debug( addResult )
1599 # Check the results
1600 utilities.assert_equals( expect=main.TRUE,
1601 actual=addResult,
1602 onpass="Work Queue add successful",
1603 onfail="Error adding to Work Queue" )
1604
1605 main.step( "Check the work queue stats" )
1606 statsResults = self.workQueueStatsCheck( workQueueName,
1607 workQueueCompleted,
1608 workQueueInProgress,
1609 workQueuePending )
1610 utilities.assert_equals( expect=True,
1611 actual=statsResults,
1612 onpass="Work Queue stats correct",
1613 onfail="Work Queue stats incorrect " )
1614
1615 main.step( "Work Queue addMultiple()" )
1616 threads = []
Jon Hallf37d44d2017-05-24 10:37:30 -07001617 i = main.activeNodes[ 0 ]
1618 addMultipleResult = main.CLIs[ i ].workQueueAddMultiple( workQueueName, 'bar', 'baz' )
Jon Halle0f0b342017-04-18 11:43:47 -07001619 workQueuePending += 2
1620 main.log.debug( addMultipleResult )
1621 # Check the results
1622 utilities.assert_equals( expect=main.TRUE,
1623 actual=addMultipleResult,
1624 onpass="Work Queue add multiple successful",
1625 onfail="Error adding multiple items to Work Queue" )
1626
1627 main.step( "Check the work queue stats" )
1628 statsResults = self.workQueueStatsCheck( workQueueName,
1629 workQueueCompleted,
1630 workQueueInProgress,
1631 workQueuePending )
1632 utilities.assert_equals( expect=True,
1633 actual=statsResults,
1634 onpass="Work Queue stats correct",
1635 onfail="Work Queue stats incorrect " )
1636
1637 main.step( "Work Queue takeAndComplete() 1" )
1638 threads = []
Jon Hallf37d44d2017-05-24 10:37:30 -07001639 i = main.activeNodes[ 0 ]
Jon Halle0f0b342017-04-18 11:43:47 -07001640 number = 1
Jon Hallf37d44d2017-05-24 10:37:30 -07001641 take1Result = main.CLIs[ i ].workQueueTakeAndComplete( workQueueName, number )
Jon Halle0f0b342017-04-18 11:43:47 -07001642 workQueuePending -= number
1643 workQueueCompleted += number
1644 main.log.debug( take1Result )
1645 # Check the results
1646 utilities.assert_equals( expect=main.TRUE,
1647 actual=take1Result,
1648 onpass="Work Queue takeAndComplete 1 successful",
1649 onfail="Error taking 1 from Work Queue" )
1650
1651 main.step( "Check the work queue stats" )
1652 statsResults = self.workQueueStatsCheck( workQueueName,
1653 workQueueCompleted,
1654 workQueueInProgress,
1655 workQueuePending )
1656 utilities.assert_equals( expect=True,
1657 actual=statsResults,
1658 onpass="Work Queue stats correct",
1659 onfail="Work Queue stats incorrect " )
1660
1661 main.step( "Work Queue takeAndComplete() 2" )
1662 threads = []
Jon Hallf37d44d2017-05-24 10:37:30 -07001663 i = main.activeNodes[ 0 ]
Jon Halle0f0b342017-04-18 11:43:47 -07001664 number = 2
Jon Hallf37d44d2017-05-24 10:37:30 -07001665 take2Result = main.CLIs[ i ].workQueueTakeAndComplete( workQueueName, number )
Jon Halle0f0b342017-04-18 11:43:47 -07001666 workQueuePending -= number
1667 workQueueCompleted += number
1668 main.log.debug( take2Result )
1669 # Check the results
1670 utilities.assert_equals( expect=main.TRUE,
1671 actual=take2Result,
1672 onpass="Work Queue takeAndComplete 2 successful",
1673 onfail="Error taking 2 from Work Queue" )
1674
1675 main.step( "Check the work queue stats" )
1676 statsResults = self.workQueueStatsCheck( workQueueName,
1677 workQueueCompleted,
1678 workQueueInProgress,
1679 workQueuePending )
1680 utilities.assert_equals( expect=True,
1681 actual=statsResults,
1682 onpass="Work Queue stats correct",
1683 onfail="Work Queue stats incorrect " )
1684
1685 main.step( "Work Queue destroy()" )
1686 valueValue = None
1687 threads = []
Jon Hallf37d44d2017-05-24 10:37:30 -07001688 i = main.activeNodes[ 0 ]
1689 destroyResult = main.CLIs[ i ].workQueueDestroy( workQueueName )
Jon Halle0f0b342017-04-18 11:43:47 -07001690 workQueueCompleted = 0
1691 workQueueInProgress = 0
1692 workQueuePending = 0
1693 main.log.debug( destroyResult )
1694 # Check the results
1695 utilities.assert_equals( expect=main.TRUE,
1696 actual=destroyResult,
1697 onpass="Work Queue destroy successful",
1698 onfail="Error destroying Work Queue" )
1699
1700 main.step( "Check the work queue stats" )
1701 statsResults = self.workQueueStatsCheck( workQueueName,
1702 workQueueCompleted,
1703 workQueueInProgress,
1704 workQueuePending )
1705 utilities.assert_equals( expect=True,
1706 actual=statsResults,
1707 onpass="Work Queue stats correct",
1708 onfail="Work Queue stats incorrect " )
Jon Hall7a6ebfd2017-03-13 10:58:58 -07001709 except Exception as e:
1710 main.log.error( "Exception: " + str( e ) )