blob: 29966d6d63c9acb1fc588eadd8d50c4a7ca80048 [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 """
Devin Lime9f0ccf2017-08-11 17:25:12 -0700164 self.command( "createCellFile",
165 args=[ main.ONOSbench.ip_address,
Devin Lim40a19092017-08-15 14:54:22 -0700166 cellName,
You Wanga0f6ff62018-01-11 15:46:30 -0800167 mininetIp,
You Wang0d9f2c02018-08-10 14:56:32 -0700168 cellApps,
Devin Lim40a19092017-08-15 14:54:22 -0700169 ips,
170 main.ONOScell.karafUser,
171 useSSH ],
Devin Lime9f0ccf2017-08-11 17:25:12 -0700172 specificDriver=1,
173 getFrom=0 if installMax else 1 )
Devin Lim40a19092017-08-15 14:54:22 -0700174
You Wangf9d95be2018-08-01 14:35:37 -0700175 def uninstallAtomix( self, uninstallMax ):
176 """
177 Description:
178 uninstalling atomix
179 Required:
180 * uninstallMax - True for uninstalling max number of nodes
181 False for uninstalling the current running nodes.
182 Returns:
183 Returns main.TRUE if it successfully uninstalled.
184 """
185 result = main.TRUE
186 uninstallResult = self.command( "atomixUninstall",
187 kwargs={ "nodeIp": "ipAddress" },
188 specificDriver=1,
189 getFrom=0 if uninstallMax else 1,
190 funcFromCtrl=True )
191 for uninstallR in uninstallResult:
192 result = result and uninstallR
193 return result
194
195 def uninstallOnos( self, uninstallMax ):
Devin Lim142b5342017-07-20 15:22:39 -0700196 """
197 Description:
198 uninstalling onos
199 Required:
200 * uninstallMax - True for uninstalling max number of nodes
201 False for uninstalling the current running nodes.
202 Returns:
203 Returns main.TRUE if it successfully uninstalled.
204 """
Devin Lim40a19092017-08-15 14:54:22 -0700205 result = main.TRUE
206 uninstallResult = self.command( "onosUninstall",
Jon Hall4173b242017-09-12 17:04:38 -0700207 kwargs={ "nodeIp": "ipAddress" },
Devin Lim40a19092017-08-15 14:54:22 -0700208 specificDriver=1,
209 getFrom=0 if uninstallMax else 1,
210 funcFromCtrl=True )
211 for uninstallR in uninstallResult:
212 result = result and uninstallR
213 return result
Devin Lim142b5342017-07-20 15:22:39 -0700214
Devin Lime9f0ccf2017-08-11 17:25:12 -0700215 def applyCell( self, cellName, installMax=False ):
Devin Lim142b5342017-07-20 15:22:39 -0700216 """
217 Description:
218 apply the cell with cellName. It will also verify the
219 cell.
220 Required:
221 * cellName - The name of the cell.
222 Returns:
223 Returns main.TRUE if it successfully set and verify cell.
224 """
Devin Lime9f0ccf2017-08-11 17:25:12 -0700225 setCellResult = self.command( "setCell",
Jon Hall4173b242017-09-12 17:04:38 -0700226 args=[ cellName ],
227 specificDriver=1,
228 getFrom=0 if installMax else 1 )
Devin Lime9f0ccf2017-08-11 17:25:12 -0700229 verifyResult = self.command( "verifyCell",
Jon Hall4173b242017-09-12 17:04:38 -0700230 specificDriver=1,
231 getFrom=0 if installMax else 1 )
Devin Lime9f0ccf2017-08-11 17:25:12 -0700232 result = main.TRUE
233 for i in range( len( setCellResult ) ):
234 result = result and setCellResult[ i ] and verifyResult[ i ]
235 return result
Devin Lim142b5342017-07-20 15:22:39 -0700236
237 def checkService( self ):
238 """
239 Description:
240 Checking if the onos service is up. If not, it will
241 start the onos service manually.
242 Required:
243 Returns:
244 Returns main.TRUE if it successfully checked
245 """
246 stopResult = main.TRUE
247 startResult = main.TRUE
248 onosIsUp = main.TRUE
Devin Lim40a19092017-08-15 14:54:22 -0700249 onosUp = self.command( "isup",
250 args=[ "ipAddress" ],
251 specificDriver=1,
252 getFrom=1,
253 funcFromCtrl=True )
254 for i in range( len( onosUp ) ):
255 ctrl = self.controllers[ i ]
256 onosIsUp = onosIsUp and onosUp[ i ]
257 if onosUp[ i ] == main.TRUE:
Jon Hall9655dcb2018-02-02 11:19:06 -0800258 main.log.info( ctrl.name + " is up and ready" )
Devin Lim142b5342017-07-20 15:22:39 -0700259 else:
Jon Hall9655dcb2018-02-02 11:19:06 -0800260 main.log.warn( ctrl.name + " may not be up." )
261 return onosIsUp
Devin Lim142b5342017-07-20 15:22:39 -0700262
You Wangf9d95be2018-08-01 14:35:37 -0700263 def killAtomix( self, killMax, stopAtomix ):
264 """
265 Description:
266 killing atomix. It will either kill the current runningnodes or
267 max number of the nodes.
268 Required:
269 * killRemoveMax - The boolean that will decide either to kill
270 only running nodes ( False ) or max number of nodes ( True ).
271 * stopAtomix - If wish to atomix onos before killing it. True for
272 enable stop, False for disable stop.
273 Returns:
274 Returns main.TRUE if successfully killing it.
275 """
276 result = main.TRUE
277 killResult = self.command( "atomixKill",
278 args=[ "ipAddress" ],
279 specificDriver=1,
280 getFrom=0 if killMax else 1,
281 funcFromCtrl=True )
282 for i in range( len( killResult ) ):
283 result = result and killResult[ i ]
284 self.controllers[ i ].active = False
285 return result
286
287 def killOnos( self, killMax, stopOnos ):
Devin Lim142b5342017-07-20 15:22:39 -0700288 """
289 Description:
290 killing the onos. It will either kill the current runningnodes or
291 max number of the nodes.
292 Required:
293 * killRemoveMax - The boolean that will decide either to kill
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700294 only running nodes ( False ) or max number of nodes ( True ).
Devin Lim142b5342017-07-20 15:22:39 -0700295 * stopOnos - If wish to stop onos before killing it. True for
296 enable stop , False for disable stop.
297 Returns:
298 Returns main.TRUE if successfully killing it.
Jon Hallca319892017-06-15 15:25:22 -0700299 """
300 result = main.TRUE
Devin Lim40a19092017-08-15 14:54:22 -0700301 killResult = self.command( "onosKill",
302 args=[ "ipAddress" ],
303 specificDriver=1,
304 getFrom=0 if killMax else 1,
305 funcFromCtrl=True )
Jon Hall4173b242017-09-12 17:04:38 -0700306 for i in range( len( killResult ) ):
Devin Lim40a19092017-08-15 14:54:22 -0700307 result = result and killResult[ i ]
308 self.controllers[ i ].active = False
Devin Lim142b5342017-07-20 15:22:39 -0700309 return result
310
311 def ssh( self ):
312 """
313 Description:
314 set up ssh to the onos
315 Required:
316 Returns:
317 Returns main.TRUE if it successfully setup the ssh to
318 the onos.
319 """
Devin Lim40a19092017-08-15 14:54:22 -0700320 result = main.TRUE
321 sshResult = self.command( "onosSecureSSH",
Jon Hall4173b242017-09-12 17:04:38 -0700322 kwargs={ "node": "ipAddress" },
Devin Lim40a19092017-08-15 14:54:22 -0700323 specificDriver=1,
324 getFrom=1,
325 funcFromCtrl=True )
326 for sshR in sshResult:
327 result = result and sshR
328 return result
Devin Lim142b5342017-07-20 15:22:39 -0700329
You Wangf9d95be2018-08-01 14:35:37 -0700330 def installAtomix( self, installMax=True, installParallel=True ):
331 """
332 Description:
333 Installing onos.
334 Required:
335 * installMax - True for installing max number of nodes
336 False for installing current running nodes only.
337 Returns:
338 Returns main.TRUE if it successfully installed
339 """
340 result = main.TRUE
341 threads = []
342 i = 0
343 for ctrl in self.controllers if installMax else self.runningNodes:
344 options = ""
345 if installMax and i >= self.numCtrls:
346 # TODO: is installMax supported here?
347 pass
348 if installParallel:
349 t = main.Thread( target=ctrl.Bench.atomixInstall,
350 name="atomix-install-" + ctrl.name,
351 kwargs={ "node" : ctrl.ipAddress,
352 "options" : options } )
353 threads.append( t )
354 t.start()
355 else:
356 result = result and \
357 main.ONOSbench.atomixInstall( node=ctrl.ipAddress, options=options )
358 i += 1
359 if installParallel:
360 for t in threads:
361 t.join()
362 result = result and t.result
363 return result
364
365 def installOnos( self, installMax=True, installParallel=True ):
Devin Lim142b5342017-07-20 15:22:39 -0700366 """
367 Description:
368 Installing onos.
369 Required:
370 * installMax - True for installing max number of nodes
371 False for installing current running nodes only.
372 Returns:
373 Returns main.TRUE if it successfully installed
374 """
375 result = main.TRUE
376 threads = []
377 i = 0
378 for ctrl in self.controllers if installMax else self.runningNodes:
379 options = "-f"
380 if installMax and i >= self.numCtrls:
381 options = "-nf"
Devin Lime9f0ccf2017-08-11 17:25:12 -0700382 if installParallel:
Jon Hall4173b242017-09-12 17:04:38 -0700383 t = main.Thread( target=ctrl.Bench.onosInstall,
You Wangf9d95be2018-08-01 14:35:37 -0700384 name="onos-install-" + ctrl.name,
Jon Hall4173b242017-09-12 17:04:38 -0700385 kwargs={ "node" : ctrl.ipAddress,
386 "options" : options } )
Devin Lime9f0ccf2017-08-11 17:25:12 -0700387 threads.append( t )
388 t.start()
389 else:
390 result = result and \
Devin Lim142b5342017-07-20 15:22:39 -0700391 main.ONOSbench.onosInstall( node=ctrl.ipAddress, options=options )
Jon Halla6771b32018-01-26 16:07:28 -0800392 i += 1
Devin Lime9f0ccf2017-08-11 17:25:12 -0700393 if installParallel:
394 for t in threads:
395 t.join()
396 result = result and t.result
Jon Hallca319892017-06-15 15:25:22 -0700397 return result
398
399 def startCLIs( self ):
400 """
Devin Lim142b5342017-07-20 15:22:39 -0700401 Description:
402 starting Onos using onosCli driver
403 Required:
404 Returns:
405 Returns main.TRUE if it successfully started.
Jon Hallca319892017-06-15 15:25:22 -0700406 """
Devin Lim40a19092017-08-15 14:54:22 -0700407 result = main.TRUE
408 cliResults = self.command( "startOnosCli",
409 args=[ "ipAddress" ],
410 specificDriver=2,
411 getFrom=1,
412 funcFromCtrl=True )
Jon Hall4173b242017-09-12 17:04:38 -0700413 for i in range( len( cliResults ) ):
Devin Lim40a19092017-08-15 14:54:22 -0700414 result = result and cliResults[ i ]
415 self.controllers[ i ].active = True
416 return result
Jon Hallca319892017-06-15 15:25:22 -0700417
Devin Lim3ebd5e72017-11-14 10:38:00 -0800418 def nodesCheck( self ):
You Wang0d9f2c02018-08-10 14:56:32 -0700419 """
420 Description:
421 Checking if all the onos nodes are in READY state
422 Required:
423 Returns:
424 Returns True if it successfully checked
425 """
Devin Lim3ebd5e72017-11-14 10:38:00 -0800426 results = True
427 nodesOutput = self.command( "nodes", specificDriver=2 )
428 ips = sorted( self.getIps( activeOnly=True ) )
429 for i in nodesOutput:
430 try:
431 current = json.loads( i )
432 activeIps = []
433 currentResult = False
434 for node in current:
435 if node[ 'state' ] == 'READY':
436 activeIps.append( node[ 'ip' ] )
437 activeIps.sort()
438 if ips == activeIps:
439 currentResult = True
440 except ( ValueError, TypeError ):
441 main.log.error( "Error parsing nodes output" )
442 main.log.warn( repr( i ) )
443 currentResult = False
444 results = results and currentResult
445 return results
446
You Wang0d9f2c02018-08-10 14:56:32 -0700447 def appsCheck( self, apps ):
448 """
449 Description:
450 Checking if all the applications are activated
451 Required:
452 apps: list of applications that are expected to be activated
453 Returns:
454 Returns True if it successfully checked
455 """
456 results = True
457 for app in apps:
458 states = self.command( "appStatus",
459 args=[ app ],
460 specificDriver=2 )
461 for i in range( len( states ) ):
462 ctrl = self.controllers[ i ]
463 if states[ i ] == "ACTIVE":
464 results = results and True
465 main.log.info( "{}: {} is activated".format( ctrl.name, app ) )
466 else:
467 results = False
468 main.log.warn( "{}: {} is in {} state".format( ctrl.name, app, states[ i ] ) )
469 return results
470
Devin Lim142b5342017-07-20 15:22:39 -0700471 def printResult( self, results, activeList, logLevel="debug" ):
472 """
473 Description:
474 Print the value of the list.
475 Required:
476 * results - list of the result
477 * activeList - list of the acitve nodes.
478 * logLevel - Type of log level you want it to be printed.
479 Returns:
480 """
481 f = getattr( main.log, logLevel )
Jon Hall4173b242017-09-12 17:04:38 -0700482 for i in range( len( results ) ):
483 f( activeList[ i ].name + "'s result : " + str( results[ i ] ) )
Devin Lim142b5342017-07-20 15:22:39 -0700484
485 def allTrueResultCheck( self, results, activeList ):
486 """
487 Description:
488 check if all the result has main.TRUE.
489 Required:
490 * results - list of the result
491 * activeList - list of the acitve nodes.
492 Returns:
493 Returns True if all == main.TRUE else
494 returns False
495 """
496 self.printResult( results, activeList )
497 return all( result == main.TRUE for result in results )
498
499 def notEmptyResultCheck( self, results, activeList ):
500 """
501 Description:
502 check if all the result has any contents
503 Required:
504 * results - list of the result
505 * activeList - list of the acitve nodes.
506 Returns:
507 Returns True if all the results has
508 something else returns False
509 """
510 self.printResult( results, activeList )
511 return all( result for result in results )
512
513 def identicalResultsCheck( self, results, activeList ):
514 """
515 Description:
516 check if all the results has same output.
517 Required:
518 * results - list of the result
519 * activeList - list of the acitve nodes.
520 Returns:
521 Returns True if all the results has
522 same result else returns False
523 """
524 self.printResult( results, activeList )
525 resultOne = results[ 0 ]
526 return all( resultOne == result for result in results )
527
Devin Lime9f0ccf2017-08-11 17:25:12 -0700528 def command( self, function, args=(), kwargs={}, returnBool=False,
Devin Lim40a19092017-08-15 14:54:22 -0700529 specificDriver=0, contentCheck=False, getFrom=2,
530 funcFromCtrl=False ):
Devin Lim142b5342017-07-20 15:22:39 -0700531 """
532 Description:
533 execute some function of the active nodes.
534 Required:
535 * function - name of the function
536 * args - argument of the function
537 * kwargs - kwargs of the funciton
538 * returnBool - True if wish to check all the result has main.TRUE
539 * specificDriver - specific driver to execute the function. Since
540 some of the function can be used in different drivers, it is important
541 to specify which driver it will be executed from.
542 0 - any type of driver
543 1 - from bench
544 2 - from cli
545 3 - from rest
546 * contentCheck - If this is True, it will check if the result has some
547 contents.
Devin Lime9f0ccf2017-08-11 17:25:12 -0700548 * getFrom - from which nodes
549 2 - active nodes
550 1 - current running nodes
551 0 - all nodes
Devin Lim40a19092017-08-15 14:54:22 -0700552 * funcFromCtrl - specific function of the args/kwargs
553 from each controller from the list of the controllers
Devin Lim142b5342017-07-20 15:22:39 -0700554 Returns:
555 Returns results if not returnBool and not contentCheck
556 Returns checkTruthValue of the result if returnBool
557 Returns resultContent of the result if contentCheck
558 """
Jon Hallca319892017-06-15 15:25:22 -0700559 threads = []
Devin Lim142b5342017-07-20 15:22:39 -0700560 drivers = [ None, "Bench", "CLI", "REST" ]
Devin Lime9f0ccf2017-08-11 17:25:12 -0700561 fromNode = [ self.controllers, self.runningNodes, self.active() ]
Jon Hallca319892017-06-15 15:25:22 -0700562 results = []
Devin Lime9f0ccf2017-08-11 17:25:12 -0700563 for ctrl in fromNode[ getFrom ]:
Devin Lim142b5342017-07-20 15:22:39 -0700564 try:
Devin Lim40a19092017-08-15 14:54:22 -0700565 funcArgs = []
566 funcKwargs = {}
Devin Lim142b5342017-07-20 15:22:39 -0700567 f = getattr( ( ctrl if not specificDriver else
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700568 getattr( ctrl, drivers[ specificDriver ] ) ), function )
Devin Lim40a19092017-08-15 14:54:22 -0700569 if funcFromCtrl:
570 if args:
571 for i in range( len( args ) ):
572 funcArgs.append( getattr( ctrl, args[ i ] ) )
573 if kwargs:
574 for k in kwargs:
Jon Hall4173b242017-09-12 17:04:38 -0700575 funcKwargs.update( { k: getattr( ctrl, kwargs[ k ] ) } )
Devin Lim142b5342017-07-20 15:22:39 -0700576 except AttributeError:
577 main.log.error( "Function " + function + " not found. Exiting the Test." )
Devin Lim44075962017-08-11 10:56:37 -0700578 main.cleanAndExit()
Jon Hallca319892017-06-15 15:25:22 -0700579 t = main.Thread( target=f,
580 name=function + "-" + ctrl.name,
Devin Lim40a19092017-08-15 14:54:22 -0700581 args=funcArgs if funcFromCtrl else args,
582 kwargs=funcKwargs if funcFromCtrl else kwargs )
Jon Hallca319892017-06-15 15:25:22 -0700583 threads.append( t )
584 t.start()
585
586 for t in threads:
587 t.join()
588 results.append( t.result )
Devin Lim142b5342017-07-20 15:22:39 -0700589 if returnBool:
Devin Lime9f0ccf2017-08-11 17:25:12 -0700590 return self.allTrueResultCheck( results, fromNode[ getFrom ] )
Devin Lim142b5342017-07-20 15:22:39 -0700591 elif contentCheck:
Devin Lime9f0ccf2017-08-11 17:25:12 -0700592 return self.notEmptyResultCheck( results, fromNode[ getFrom ] )
Jon Hall4173b242017-09-12 17:04:38 -0700593 return results
594
595 def checkPartitionSize( self, segmentSize='64', units='M', multiplier='3' ):
596 # max segment size in bytes: 1024 * 1024 * 64
597 # multiplier is somewhat arbitrary, but the idea is the logs would have
598 # been compacted before this many segments are written
599
600 maxSize = float( segmentSize ) * float( multiplier )
601 ret = True
602 for n in self.runningNodes:
Jon Hall5d5876e2017-11-30 09:33:16 -0800603 # Partition logs
Jon Halld81e0162018-08-13 12:06:13 -0700604 ret = ret and n.server.folderSize( "/opt/atomix/data/raft/partitions/*/*.log",
Jon Hall4173b242017-09-12 17:04:38 -0700605 size=maxSize, unit=units, ignoreRoot=False )
606 return ret