blob: 6bfbb3fe0be1f6e7e0f526acbbb06d6c842fb635 [file] [log] [blame]
Jon Hallca319892017-06-15 15:25:22 -07001"""
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07002Copyright 2017 Open Networking Foundation ( ONF )
Jon Hallca319892017-06-15 15:25:22 -07003
4Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
5the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
6or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
7
8 TestON is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 2 of the License, or
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070011 ( at your option ) any later version.
Jon Hallca319892017-06-15 15:25:22 -070012
13 TestON is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with TestON. If not, see <http://www.gnu.org/licenses/>.
20"""
Devin Lim3ebd5e72017-11-14 10:38:00 -080021import json
Jon Hallca319892017-06-15 15:25:22 -070022class Cluster():
23
24 def __str__( self ):
25 return self.name
Jon Hall4173b242017-09-12 17:04:38 -070026
Jon Hallca319892017-06-15 15:25:22 -070027 def __repr__( self ):
Jon Hallca319892017-06-15 15:25:22 -070028 controllers = []
Devin Lim142b5342017-07-20 15:22:39 -070029 runningNodes = []
Jon Hallca319892017-06-15 15:25:22 -070030 for ctrl in self.controllers:
31 controllers.append( str( ctrl ) )
32 return "%s[%s]" % ( self.name, ", ".join( controllers ) )
33
Jon Hallca319892017-06-15 15:25:22 -070034 def __init__( self, ctrlList=[], name="Cluster" ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070035 """
Devin Lim142b5342017-07-20 15:22:39 -070036 controllers : All the nodes
37 runningNodes : Node that are specifically running from the test.
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070038 ie ) When the test is testing different number of nodes on each
Devin Lim142b5342017-07-20 15:22:39 -070039 run.
40 numCtrls : number of runningNodes
41 maxCtrls : number of controllers
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070042 """
Jon Hallca319892017-06-15 15:25:22 -070043 self.controllers = ctrlList
Devin Lim142b5342017-07-20 15:22:39 -070044 self.runningNodes = ctrlList
45 self.numCtrls = len( self.runningNodes )
46 self.maxCtrls = len( self.controllers )
Jon Hallca319892017-06-15 15:25:22 -070047 self.name = str( name )
48 self.iterator = iter( self.active() )
49
Devin Lim142b5342017-07-20 15:22:39 -070050 def getIps( self, activeOnly=False, allNode=False ):
51 """
52 Description:
53 get the list of the ip. Default to get ips of running nodes.
54 Required:
55 * activeOnly - True for getting ips of active nodes
56 * allNode - True for getting ips of all nodes
57 Returns:
58 Retruns ips of active nodes if activeOnly is True.
59 Returns ips of all nodes if allNode is True.
60 """
Jon Hallca319892017-06-15 15:25:22 -070061 ips = []
Devin Lim142b5342017-07-20 15:22:39 -070062 if allNode:
Jon Hallca319892017-06-15 15:25:22 -070063 nodeList = self.controllers
Devin Lim142b5342017-07-20 15:22:39 -070064 else:
65 if activeOnly:
66 nodeList = self.active()
67 else:
68 nodeList = self.runningNodes
69
Jon Hallca319892017-06-15 15:25:22 -070070 for ctrl in nodeList:
71 ips.append( ctrl.ipAddress )
Devin Lim142b5342017-07-20 15:22:39 -070072
Jon Hallca319892017-06-15 15:25:22 -070073 return ips
74
Jon Halla1e8e512018-05-11 13:30:57 -070075 def clearActive( self ):
Jon Hallca319892017-06-15 15:25:22 -070076 """
Devin Lim142b5342017-07-20 15:22:39 -070077 Description:
Jon Halla1e8e512018-05-11 13:30:57 -070078 Sets the activeness of each cluster node to be False
Jon Hallca319892017-06-15 15:25:22 -070079 """
Jon Hallab611372018-02-21 15:26:05 -080080 for ctrl in self.controllers:
Devin Lim142b5342017-07-20 15:22:39 -070081 ctrl.active = False
82
83 def getRunningPos( self ):
84 """
85 Description:
86 get the position of the active running nodes.
87 Required:
88 Returns:
89 Retruns the list of the position of the active
90 running nodes.
91 """
92 return [ ctrl.pos for ctrl in self.runningNodes
93 if ctrl.active ]
94
95 def setRunningNode( self, numCtrls ):
96 """
97 Description:
98 Set running nodes of n number of nodes.
99 It will create new list of runningNodes.
100 If numCtrls is a list, it will add the nodes of the
101 list.
102 Required:
103 * numCtrls - number of nodes to be set.
104 Returns:
105 """
106 self.runningNodes = []
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700107 for i in numCtrls if isinstance( numCtrls, list ) else range( numCtrls ):
Devin Lim142b5342017-07-20 15:22:39 -0700108 self.runningNodes.append( self.controllers[ i ] )
109 self.numCtrls = len( numCtrls ) if isinstance( numCtrls, list ) else numCtrls
110
111 def active( self, node=None ):
112 """
113 Description:
114 get the list/controller of the active controller.
115 Required:
116 * node - position of the node to get from the active controller.
117 Returns:
118 Return a list of active controllers in the cluster if node is None
119 if not, it will return the nth controller.
120 """
121 result = [ ctrl for ctrl in self.runningNodes
Jon Hallca319892017-06-15 15:25:22 -0700122 if ctrl.active ]
Devin Lim142b5342017-07-20 15:22:39 -0700123 return result if node is None else result[ node % len( result ) ]
Jon Hallca319892017-06-15 15:25:22 -0700124
125 def next( self ):
126 """
Jon Halla1e8e512018-05-11 13:30:57 -0700127 An iterator for the cluster's active controllers that
Jon Hallca319892017-06-15 15:25:22 -0700128 resets when there are no more elements.
129
130 Returns the next controller in the cluster
131 """
132 try:
Jon Halla1e8e512018-05-11 13:30:57 -0700133 node = self.iterator.next()
134 assert node.active
135 return node
136 except ( StopIteration, AssertionError ):
Jon Hallca319892017-06-15 15:25:22 -0700137 self.reset()
138 try:
139 return self.iterator.next()
140 except StopIteration:
141 raise RuntimeError( "There are no active nodes in the cluster" )
142
143 def reset( self ):
144 """
145 Resets the cluster iterator.
146
147 This should be used whenever a node's active state is changed
148 and is also used internally when the iterator has been exhausted.
149 """
150 self.iterator = iter( self.active() )
151
You Wanga0f6ff62018-01-11 15:46:30 -0800152 def createCell( self, cellName, cellApps, mininetIp, useSSH, ips, installMax=False ):
Jon Hallca319892017-06-15 15:25:22 -0700153 """
Devin Lim142b5342017-07-20 15:22:39 -0700154 Description:
155 create a new cell
156 Required:
157 * cellName - The name of the cell.
You Wang09b596b2018-01-10 10:42:38 -0800158 * cellApps - The ONOS apps string.
You Wanga0f6ff62018-01-11 15:46:30 -0800159 * mininetIp - Mininet IP address.
Devin Lim142b5342017-07-20 15:22:39 -0700160 * useSSH - True for using ssh when creating a cell
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700161 * ips - ip( s ) of the node( s ).
Devin Lim142b5342017-07-20 15:22:39 -0700162 Returns:
163 """
You Wang09b596b2018-01-10 10:42:38 -0800164 try:
165 apps = main.apps
166 except ( NameError, AttributeError ):
167 apps = cellApps
Devin Lime9f0ccf2017-08-11 17:25:12 -0700168 self.command( "createCellFile",
169 args=[ main.ONOSbench.ip_address,
Devin Lim40a19092017-08-15 14:54:22 -0700170 cellName,
You Wanga0f6ff62018-01-11 15:46:30 -0800171 mininetIp,
You Wang09b596b2018-01-10 10:42:38 -0800172 apps,
Devin Lim40a19092017-08-15 14:54:22 -0700173 ips,
174 main.ONOScell.karafUser,
175 useSSH ],
Devin Lime9f0ccf2017-08-11 17:25:12 -0700176 specificDriver=1,
177 getFrom=0 if installMax else 1 )
Devin Lim40a19092017-08-15 14:54:22 -0700178
You Wangf9d95be2018-08-01 14:35:37 -0700179 def uninstallAtomix( self, uninstallMax ):
180 """
181 Description:
182 uninstalling atomix
183 Required:
184 * uninstallMax - True for uninstalling max number of nodes
185 False for uninstalling the current running nodes.
186 Returns:
187 Returns main.TRUE if it successfully uninstalled.
188 """
189 result = main.TRUE
190 uninstallResult = self.command( "atomixUninstall",
191 kwargs={ "nodeIp": "ipAddress" },
192 specificDriver=1,
193 getFrom=0 if uninstallMax else 1,
194 funcFromCtrl=True )
195 for uninstallR in uninstallResult:
196 result = result and uninstallR
197 return result
198
199 def uninstallOnos( self, uninstallMax ):
Devin Lim142b5342017-07-20 15:22:39 -0700200 """
201 Description:
202 uninstalling onos
203 Required:
204 * uninstallMax - True for uninstalling max number of nodes
205 False for uninstalling the current running nodes.
206 Returns:
207 Returns main.TRUE if it successfully uninstalled.
208 """
Devin Lim40a19092017-08-15 14:54:22 -0700209 result = main.TRUE
210 uninstallResult = self.command( "onosUninstall",
Jon Hall4173b242017-09-12 17:04:38 -0700211 kwargs={ "nodeIp": "ipAddress" },
Devin Lim40a19092017-08-15 14:54:22 -0700212 specificDriver=1,
213 getFrom=0 if uninstallMax else 1,
214 funcFromCtrl=True )
215 for uninstallR in uninstallResult:
216 result = result and uninstallR
217 return result
Devin Lim142b5342017-07-20 15:22:39 -0700218
Devin Lime9f0ccf2017-08-11 17:25:12 -0700219 def applyCell( self, cellName, installMax=False ):
Devin Lim142b5342017-07-20 15:22:39 -0700220 """
221 Description:
222 apply the cell with cellName. It will also verify the
223 cell.
224 Required:
225 * cellName - The name of the cell.
226 Returns:
227 Returns main.TRUE if it successfully set and verify cell.
228 """
Devin Lime9f0ccf2017-08-11 17:25:12 -0700229 setCellResult = self.command( "setCell",
Jon Hall4173b242017-09-12 17:04:38 -0700230 args=[ cellName ],
231 specificDriver=1,
232 getFrom=0 if installMax else 1 )
Devin Lime9f0ccf2017-08-11 17:25:12 -0700233 verifyResult = self.command( "verifyCell",
Jon Hall4173b242017-09-12 17:04:38 -0700234 specificDriver=1,
235 getFrom=0 if installMax else 1 )
Devin Lime9f0ccf2017-08-11 17:25:12 -0700236 result = main.TRUE
237 for i in range( len( setCellResult ) ):
238 result = result and setCellResult[ i ] and verifyResult[ i ]
239 return result
Devin Lim142b5342017-07-20 15:22:39 -0700240
241 def checkService( self ):
242 """
243 Description:
244 Checking if the onos service is up. If not, it will
245 start the onos service manually.
246 Required:
247 Returns:
248 Returns main.TRUE if it successfully checked
249 """
250 stopResult = main.TRUE
251 startResult = main.TRUE
252 onosIsUp = main.TRUE
Devin Lim40a19092017-08-15 14:54:22 -0700253 onosUp = self.command( "isup",
254 args=[ "ipAddress" ],
255 specificDriver=1,
256 getFrom=1,
257 funcFromCtrl=True )
258 for i in range( len( onosUp ) ):
259 ctrl = self.controllers[ i ]
260 onosIsUp = onosIsUp and onosUp[ i ]
261 if onosUp[ i ] == main.TRUE:
Jon Hall9655dcb2018-02-02 11:19:06 -0800262 main.log.info( ctrl.name + " is up and ready" )
Devin Lim142b5342017-07-20 15:22:39 -0700263 else:
Jon Hall9655dcb2018-02-02 11:19:06 -0800264 main.log.warn( ctrl.name + " may not be up." )
265 return onosIsUp
Devin Lim142b5342017-07-20 15:22:39 -0700266
You Wangf9d95be2018-08-01 14:35:37 -0700267 def killAtomix( self, killMax, stopAtomix ):
268 """
269 Description:
270 killing atomix. It will either kill the current runningnodes or
271 max number of the nodes.
272 Required:
273 * killRemoveMax - The boolean that will decide either to kill
274 only running nodes ( False ) or max number of nodes ( True ).
275 * stopAtomix - If wish to atomix onos before killing it. True for
276 enable stop, False for disable stop.
277 Returns:
278 Returns main.TRUE if successfully killing it.
279 """
280 result = main.TRUE
281 killResult = self.command( "atomixKill",
282 args=[ "ipAddress" ],
283 specificDriver=1,
284 getFrom=0 if killMax else 1,
285 funcFromCtrl=True )
286 for i in range( len( killResult ) ):
287 result = result and killResult[ i ]
288 self.controllers[ i ].active = False
289 return result
290
291 def killOnos( self, killMax, stopOnos ):
Devin Lim142b5342017-07-20 15:22:39 -0700292 """
293 Description:
294 killing the onos. It will either kill the current runningnodes or
295 max number of the nodes.
296 Required:
297 * killRemoveMax - The boolean that will decide either to kill
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700298 only running nodes ( False ) or max number of nodes ( True ).
Devin Lim142b5342017-07-20 15:22:39 -0700299 * stopOnos - If wish to stop onos before killing it. True for
300 enable stop , False for disable stop.
301 Returns:
302 Returns main.TRUE if successfully killing it.
Jon Hallca319892017-06-15 15:25:22 -0700303 """
304 result = main.TRUE
Devin Lim40a19092017-08-15 14:54:22 -0700305 killResult = self.command( "onosKill",
306 args=[ "ipAddress" ],
307 specificDriver=1,
308 getFrom=0 if killMax else 1,
309 funcFromCtrl=True )
Jon Hall4173b242017-09-12 17:04:38 -0700310 for i in range( len( killResult ) ):
Devin Lim40a19092017-08-15 14:54:22 -0700311 result = result and killResult[ i ]
312 self.controllers[ i ].active = False
Devin Lim142b5342017-07-20 15:22:39 -0700313 return result
314
315 def ssh( self ):
316 """
317 Description:
318 set up ssh to the onos
319 Required:
320 Returns:
321 Returns main.TRUE if it successfully setup the ssh to
322 the onos.
323 """
Devin Lim40a19092017-08-15 14:54:22 -0700324 result = main.TRUE
325 sshResult = self.command( "onosSecureSSH",
Jon Hall4173b242017-09-12 17:04:38 -0700326 kwargs={ "node": "ipAddress" },
Devin Lim40a19092017-08-15 14:54:22 -0700327 specificDriver=1,
328 getFrom=1,
329 funcFromCtrl=True )
330 for sshR in sshResult:
331 result = result and sshR
332 return result
Devin Lim142b5342017-07-20 15:22:39 -0700333
You Wangf9d95be2018-08-01 14:35:37 -0700334 def installAtomix( self, installMax=True, installParallel=True ):
335 """
336 Description:
337 Installing onos.
338 Required:
339 * installMax - True for installing max number of nodes
340 False for installing current running nodes only.
341 Returns:
342 Returns main.TRUE if it successfully installed
343 """
344 result = main.TRUE
345 threads = []
346 i = 0
347 for ctrl in self.controllers if installMax else self.runningNodes:
348 options = ""
349 if installMax and i >= self.numCtrls:
350 # TODO: is installMax supported here?
351 pass
352 if installParallel:
353 t = main.Thread( target=ctrl.Bench.atomixInstall,
354 name="atomix-install-" + ctrl.name,
355 kwargs={ "node" : ctrl.ipAddress,
356 "options" : options } )
357 threads.append( t )
358 t.start()
359 else:
360 result = result and \
361 main.ONOSbench.atomixInstall( node=ctrl.ipAddress, options=options )
362 i += 1
363 if installParallel:
364 for t in threads:
365 t.join()
366 result = result and t.result
367 return result
368
369 def installOnos( self, installMax=True, installParallel=True ):
Devin Lim142b5342017-07-20 15:22:39 -0700370 """
371 Description:
372 Installing onos.
373 Required:
374 * installMax - True for installing max number of nodes
375 False for installing current running nodes only.
376 Returns:
377 Returns main.TRUE if it successfully installed
378 """
379 result = main.TRUE
380 threads = []
381 i = 0
382 for ctrl in self.controllers if installMax else self.runningNodes:
383 options = "-f"
384 if installMax and i >= self.numCtrls:
385 options = "-nf"
Devin Lime9f0ccf2017-08-11 17:25:12 -0700386 if installParallel:
Jon Hall4173b242017-09-12 17:04:38 -0700387 t = main.Thread( target=ctrl.Bench.onosInstall,
You Wangf9d95be2018-08-01 14:35:37 -0700388 name="onos-install-" + ctrl.name,
Jon Hall4173b242017-09-12 17:04:38 -0700389 kwargs={ "node" : ctrl.ipAddress,
390 "options" : options } )
Devin Lime9f0ccf2017-08-11 17:25:12 -0700391 threads.append( t )
392 t.start()
393 else:
394 result = result and \
Devin Lim142b5342017-07-20 15:22:39 -0700395 main.ONOSbench.onosInstall( node=ctrl.ipAddress, options=options )
Jon Halla6771b32018-01-26 16:07:28 -0800396 i += 1
Devin Lime9f0ccf2017-08-11 17:25:12 -0700397 if installParallel:
398 for t in threads:
399 t.join()
400 result = result and t.result
Jon Hallca319892017-06-15 15:25:22 -0700401 return result
402
403 def startCLIs( self ):
404 """
Devin Lim142b5342017-07-20 15:22:39 -0700405 Description:
406 starting Onos using onosCli driver
407 Required:
408 Returns:
409 Returns main.TRUE if it successfully started.
Jon Hallca319892017-06-15 15:25:22 -0700410 """
Devin Lim40a19092017-08-15 14:54:22 -0700411 result = main.TRUE
412 cliResults = self.command( "startOnosCli",
413 args=[ "ipAddress" ],
414 specificDriver=2,
415 getFrom=1,
416 funcFromCtrl=True )
Jon Hall4173b242017-09-12 17:04:38 -0700417 for i in range( len( cliResults ) ):
Devin Lim40a19092017-08-15 14:54:22 -0700418 result = result and cliResults[ i ]
419 self.controllers[ i ].active = True
420 return result
Jon Hallca319892017-06-15 15:25:22 -0700421
Devin Lim3ebd5e72017-11-14 10:38:00 -0800422 def nodesCheck( self ):
423 results = True
424 nodesOutput = self.command( "nodes", specificDriver=2 )
425 ips = sorted( self.getIps( activeOnly=True ) )
426 for i in nodesOutput:
427 try:
428 current = json.loads( i )
429 activeIps = []
430 currentResult = False
431 for node in current:
432 if node[ 'state' ] == 'READY':
433 activeIps.append( node[ 'ip' ] )
434 activeIps.sort()
435 if ips == activeIps:
436 currentResult = True
437 except ( ValueError, TypeError ):
438 main.log.error( "Error parsing nodes output" )
439 main.log.warn( repr( i ) )
440 currentResult = False
441 results = results and currentResult
442 return results
443
Devin Lim142b5342017-07-20 15:22:39 -0700444 def printResult( self, results, activeList, logLevel="debug" ):
445 """
446 Description:
447 Print the value of the list.
448 Required:
449 * results - list of the result
450 * activeList - list of the acitve nodes.
451 * logLevel - Type of log level you want it to be printed.
452 Returns:
453 """
454 f = getattr( main.log, logLevel )
Jon Hall4173b242017-09-12 17:04:38 -0700455 for i in range( len( results ) ):
456 f( activeList[ i ].name + "'s result : " + str( results[ i ] ) )
Devin Lim142b5342017-07-20 15:22:39 -0700457
458 def allTrueResultCheck( self, results, activeList ):
459 """
460 Description:
461 check if all the result has main.TRUE.
462 Required:
463 * results - list of the result
464 * activeList - list of the acitve nodes.
465 Returns:
466 Returns True if all == main.TRUE else
467 returns False
468 """
469 self.printResult( results, activeList )
470 return all( result == main.TRUE for result in results )
471
472 def notEmptyResultCheck( self, results, activeList ):
473 """
474 Description:
475 check if all the result has any contents
476 Required:
477 * results - list of the result
478 * activeList - list of the acitve nodes.
479 Returns:
480 Returns True if all the results has
481 something else returns False
482 """
483 self.printResult( results, activeList )
484 return all( result for result in results )
485
486 def identicalResultsCheck( self, results, activeList ):
487 """
488 Description:
489 check if all the results has same output.
490 Required:
491 * results - list of the result
492 * activeList - list of the acitve nodes.
493 Returns:
494 Returns True if all the results has
495 same result else returns False
496 """
497 self.printResult( results, activeList )
498 resultOne = results[ 0 ]
499 return all( resultOne == result for result in results )
500
Devin Lime9f0ccf2017-08-11 17:25:12 -0700501 def command( self, function, args=(), kwargs={}, returnBool=False,
Devin Lim40a19092017-08-15 14:54:22 -0700502 specificDriver=0, contentCheck=False, getFrom=2,
503 funcFromCtrl=False ):
Devin Lim142b5342017-07-20 15:22:39 -0700504 """
505 Description:
506 execute some function of the active nodes.
507 Required:
508 * function - name of the function
509 * args - argument of the function
510 * kwargs - kwargs of the funciton
511 * returnBool - True if wish to check all the result has main.TRUE
512 * specificDriver - specific driver to execute the function. Since
513 some of the function can be used in different drivers, it is important
514 to specify which driver it will be executed from.
515 0 - any type of driver
516 1 - from bench
517 2 - from cli
518 3 - from rest
519 * contentCheck - If this is True, it will check if the result has some
520 contents.
Devin Lime9f0ccf2017-08-11 17:25:12 -0700521 * getFrom - from which nodes
522 2 - active nodes
523 1 - current running nodes
524 0 - all nodes
Devin Lim40a19092017-08-15 14:54:22 -0700525 * funcFromCtrl - specific function of the args/kwargs
526 from each controller from the list of the controllers
Devin Lim142b5342017-07-20 15:22:39 -0700527 Returns:
528 Returns results if not returnBool and not contentCheck
529 Returns checkTruthValue of the result if returnBool
530 Returns resultContent of the result if contentCheck
531 """
Jon Hallca319892017-06-15 15:25:22 -0700532 threads = []
Devin Lim142b5342017-07-20 15:22:39 -0700533 drivers = [ None, "Bench", "CLI", "REST" ]
Devin Lime9f0ccf2017-08-11 17:25:12 -0700534 fromNode = [ self.controllers, self.runningNodes, self.active() ]
Jon Hallca319892017-06-15 15:25:22 -0700535 results = []
Devin Lime9f0ccf2017-08-11 17:25:12 -0700536 for ctrl in fromNode[ getFrom ]:
Devin Lim142b5342017-07-20 15:22:39 -0700537 try:
Devin Lim40a19092017-08-15 14:54:22 -0700538 funcArgs = []
539 funcKwargs = {}
Devin Lim142b5342017-07-20 15:22:39 -0700540 f = getattr( ( ctrl if not specificDriver else
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700541 getattr( ctrl, drivers[ specificDriver ] ) ), function )
Devin Lim40a19092017-08-15 14:54:22 -0700542 if funcFromCtrl:
543 if args:
544 for i in range( len( args ) ):
545 funcArgs.append( getattr( ctrl, args[ i ] ) )
546 if kwargs:
547 for k in kwargs:
Jon Hall4173b242017-09-12 17:04:38 -0700548 funcKwargs.update( { k: getattr( ctrl, kwargs[ k ] ) } )
Devin Lim142b5342017-07-20 15:22:39 -0700549 except AttributeError:
550 main.log.error( "Function " + function + " not found. Exiting the Test." )
Devin Lim44075962017-08-11 10:56:37 -0700551 main.cleanAndExit()
Jon Hallca319892017-06-15 15:25:22 -0700552 t = main.Thread( target=f,
553 name=function + "-" + ctrl.name,
Devin Lim40a19092017-08-15 14:54:22 -0700554 args=funcArgs if funcFromCtrl else args,
555 kwargs=funcKwargs if funcFromCtrl else kwargs )
Jon Hallca319892017-06-15 15:25:22 -0700556 threads.append( t )
557 t.start()
558
559 for t in threads:
560 t.join()
561 results.append( t.result )
Devin Lim142b5342017-07-20 15:22:39 -0700562 if returnBool:
Devin Lime9f0ccf2017-08-11 17:25:12 -0700563 return self.allTrueResultCheck( results, fromNode[ getFrom ] )
Devin Lim142b5342017-07-20 15:22:39 -0700564 elif contentCheck:
Devin Lime9f0ccf2017-08-11 17:25:12 -0700565 return self.notEmptyResultCheck( results, fromNode[ getFrom ] )
Jon Hall4173b242017-09-12 17:04:38 -0700566 return results
567
568 def checkPartitionSize( self, segmentSize='64', units='M', multiplier='3' ):
569 # max segment size in bytes: 1024 * 1024 * 64
570 # multiplier is somewhat arbitrary, but the idea is the logs would have
571 # been compacted before this many segments are written
572
573 maxSize = float( segmentSize ) * float( multiplier )
574 ret = True
575 for n in self.runningNodes:
Jon Hall5d5876e2017-11-30 09:33:16 -0800576 # Partition logs
577 ret = ret and n.server.folderSize( "/opt/onos/apache-karaf-*/data/db/partitions/*/*.log",
Jon Hall4173b242017-09-12 17:04:38 -0700578 size=maxSize, unit=units, ignoreRoot=False )
579 return ret