blob: 86166691c9e13720df31bd8822429a5aab479f68 [file] [log] [blame]
Devin Lim142b5342017-07-20 15:22:39 -07001"""
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07002Copyright 2016 Open Networking Foundation ( ONF )
Devin Lim58046fa2017-07-05 16:55:00 -07003
Devin Lim142b5342017-07-20 15:22:39 -07004Please 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.
Devin Lim142b5342017-07-20 15:22:39 -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 Lim58046fa2017-07-05 16:55:00 -070021import re
Devin Lim58046fa2017-07-05 16:55:00 -070022
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070023
Devin Lim58046fa2017-07-05 16:55:00 -070024class ONOSSetup:
25 main = None
Jon Hall4f360bc2017-09-07 10:19:52 -070026
Devin Lim58046fa2017-07-05 16:55:00 -070027 def __init__( self ):
28 self.default = ''
Jon Hall4f360bc2017-09-07 10:19:52 -070029
Devin Lim0c972b72018-02-08 14:53:59 -080030 def envSetupDescription( self, includeCaseDesc=True ):
Devin Lim142b5342017-07-20 15:22:39 -070031 """
32 Introduction part of the test. It will initialize some basic vairables.
33 """
Devin Lim0c972b72018-02-08 14:53:59 -080034 if includeCaseDesc:
35 main.case( "Constructing test variables and building ONOS package" )
36 main.caseExplanation = "For loading from params file, and pull" + \
37 " and build the latest ONOS package"
Jon Halla604fd42018-05-04 14:27:27 -070038 main.step( "Constructing test variables" )
Devin Lim142b5342017-07-20 15:22:39 -070039 try:
40 from tests.dependencies.Cluster import Cluster
41 except ImportError:
42 main.log.error( "Cluster not found. exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -070043 main.cleanAndExit()
Devin Lim142b5342017-07-20 15:22:39 -070044 try:
45 main.Cluster
46 except ( NameError, AttributeError ):
47 main.Cluster = Cluster( main.ONOScell.nodes )
48 main.ONOSbench = main.Cluster.controllers[ 0 ].Bench
Jon Halld74d2952018-03-01 13:26:39 -080049 main.testOnDirectory = re.sub( "(/tests)$", "", main.testsRoot )
Devin Lim58046fa2017-07-05 16:55:00 -070050
Devin Lim0c972b72018-02-08 14:53:59 -080051 def gitPulling( self, includeCaseDesc=True ):
Devin Lim142b5342017-07-20 15:22:39 -070052 """
53 it will do git checkout or pull if they are enabled from the params file.
54 """
Devin Lim0c972b72018-02-08 14:53:59 -080055
56 if includeCaseDesc:
57 main.case( "Pull onos branch and build onos on Teststation." )
58
Devin Lim58046fa2017-07-05 16:55:00 -070059 gitPull = main.params[ 'GIT' ][ 'pull' ]
60 gitBranch = main.params[ 'GIT' ][ 'branch' ]
61 if gitPull == 'True':
62 main.step( "Git Checkout ONOS branch: " + gitBranch )
63 stepResult = main.ONOSbench.gitCheckout( branch=gitBranch )
64 utilities.assert_equals( expect=main.TRUE,
65 actual=stepResult,
66 onpass="Successfully checkout onos branch.",
67 onfail="Failed to checkout onos branch. Exiting test..." )
Jon Hall4f360bc2017-09-07 10:19:52 -070068 if not stepResult:
69 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -070070
71 main.step( "Git Pull on ONOS branch:" + gitBranch )
72 stepResult = main.ONOSbench.gitPull()
73 utilities.assert_equals( expect=main.TRUE,
74 actual=stepResult,
75 onpass="Successfully pull onos. ",
76 onfail="Failed to pull onos. Exiting test ..." )
Jon Hall4f360bc2017-09-07 10:19:52 -070077 if not stepResult:
78 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -070079
80 else:
81 main.log.info( "Skipped git checkout and pull as they are disabled in params file" )
82
Devin Lim0c972b72018-02-08 14:53:59 -080083 def envSetup( self, includeGitPull=True, includeCaseDesc=True ):
Devin Lim142b5342017-07-20 15:22:39 -070084 """
85 Description:
86 some environment setup for the test.
87 Required:
88 * includeGitPull - if wish to git pulling function to be executed.
89 Returns:
90 Returns main.TRUE
91 """
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070092 if includeGitPull:
Devin Lim0c972b72018-02-08 14:53:59 -080093 self.gitPulling( includeCaseDesc )
Jon Hallca319892017-06-15 15:25:22 -070094
Devin Lim142b5342017-07-20 15:22:39 -070095 try:
96 from tests.dependencies.Cluster import Cluster
97 except ImportError:
98 main.log.error( "Cluster not found. exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -070099 main.cleanAndExit()
Devin Lim142b5342017-07-20 15:22:39 -0700100 try:
101 main.Cluster
102 except ( NameError, AttributeError ):
103 main.Cluster = Cluster( main.ONOScell.nodes )
104
Devin Lim58046fa2017-07-05 16:55:00 -0700105 main.cellData = {} # For creating cell file
Devin Lim58046fa2017-07-05 16:55:00 -0700106
Jon Hallca319892017-06-15 15:25:22 -0700107 return main.TRUE
Devin Lim58046fa2017-07-05 16:55:00 -0700108
Jon Hallca319892017-06-15 15:25:22 -0700109 def envSetupException( self, e ):
Devin Lim142b5342017-07-20 15:22:39 -0700110 """
111 Description:
112 handles the exception that might occur from the environment setup.
113 Required:
114 * includeGitPull - exceeption code e.
115 """
Devin Lim58046fa2017-07-05 16:55:00 -0700116 main.log.exception( e )
Devin Lim44075962017-08-11 10:56:37 -0700117 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700118
Jon Hallca319892017-06-15 15:25:22 -0700119 def evnSetupConclusion( self, stepResult ):
Devin Lim142b5342017-07-20 15:22:39 -0700120 """
121 Description:
122 compare the result of the envSetup of the test.
123 Required:
124 * stepResult - Result of the envSetup.
125 """
Devin Lim58046fa2017-07-05 16:55:00 -0700126 utilities.assert_equals( expect=main.TRUE,
127 actual=stepResult,
128 onpass="Successfully construct " +
129 "test variables ",
130 onfail="Failed to construct test variables" )
131
Jeremy Ronquillo7f8fb572017-11-14 08:28:41 -0800132 url = self.generateGraphURL()
133 main.log.wiki( url )
134
Devin Lim58046fa2017-07-05 16:55:00 -0700135 main.commit = main.ONOSbench.getVersion( report=True )
136
Jeremy Ronquillo7f8fb572017-11-14 08:28:41 -0800137 def generateGraphURL( self, width=525, height=350 ):
138 """
139 Description:
140 Obtain the URL for the graph that corresponds to the test being run.
141 """
142
143 nodeCluster = main.params[ 'GRAPH' ][ 'nodeCluster' ]
144 testname = main.TEST
145 branch = main.ONOSbench.getBranchName()
146 maxBuildsToShow = main.params[ 'GRAPH' ][ 'builds' ]
147
148 return '<ac:structured-macro ac:name="html">\n' + \
149 '<ac:plain-text-body><![CDATA[\n' + \
Devin Limd1fb8e92018-02-28 16:29:33 -0800150 '<img src="https://jenkins.onosproject.org/view/QA/job/postjob-' + \
Jeremy Ronquillo7f8fb572017-11-14 08:28:41 -0800151 nodeCluster + \
152 '/lastSuccessfulBuild/artifact/' + \
153 testname + \
154 '_' + \
155 branch + \
156 '_' + \
157 maxBuildsToShow + \
158 '-builds_graph.jpg", alt="' + \
159 testname + \
160 '", style="width:' + \
161 str( width ) + \
162 'px;height:' + \
163 str( height ) + \
164 'px;border:0"' + \
165 '>' + \
166 ']]></ac:plain-text-body>\n' + \
167 '</ac:structured-macro>\n'
168
Devin Lim142b5342017-07-20 15:22:39 -0700169 def setNumCtrls( self, hasMultiNodeRounds ):
170 """
171 Description:
172 Set new number of controls if it uses different number of nodes.
173 different number of nodes should be pre-defined in main.scale.
174 Required:
175 * hasMultiNodeRouds - if the test is testing different number of nodes.
176 """
Devin Lim58046fa2017-07-05 16:55:00 -0700177 if hasMultiNodeRounds:
178 try:
179 main.cycle
180 except Exception:
181 main.cycle = 0
182 main.cycle += 1
183 # main.scale[ 0 ] determines the current number of ONOS controller
Devin Lim142b5342017-07-20 15:22:39 -0700184 main.Cluster.setRunningNode( int( main.scale.pop( 0 ) ) )
Devin Lim58046fa2017-07-05 16:55:00 -0700185
You Wangf9d95be2018-08-01 14:35:37 -0700186 def killingAllAtomix( self, cluster, killRemoveMax, stopAtomix ):
187 """
188 Description:
189 killing atomix. It will either kill the current runningnodes or
190 max number of the nodes.
191 Required:
192 * cluster - the cluster driver that will be used.
193 * killRemoveMax - The boolean that will decide either to kill
194 only running nodes ( False ) or max number of nodes ( True ).
195 * stopAtomix - If wish to stop atomix before killing it. True for
196 enable stop, False for disable stop.
197 Returns:
198 Returns main.TRUE if successfully killing it.
199 """
200 main.log.info( "Safety check, killing all Atomix processes" )
201 return cluster.killAtomix( killRemoveMax, stopAtomix )
202
Devin Lim142b5342017-07-20 15:22:39 -0700203 def killingAllOnos( self, cluster, killRemoveMax, stopOnos ):
204 """
205 Description:
206 killing the onos. It will either kill the current runningnodes or
207 max number of the nodes.
208 Required:
209 * cluster - the cluster driver that will be used.
210 * killRemoveMax - The boolean that will decide either to kill
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700211 only running nodes ( False ) or max number of nodes ( True ).
Devin Lim142b5342017-07-20 15:22:39 -0700212 * stopOnos - If wish to stop onos before killing it. True for
You Wangf9d95be2018-08-01 14:35:37 -0700213 enable stop, False for disable stop.
Devin Lim142b5342017-07-20 15:22:39 -0700214 Returns:
215 Returns main.TRUE if successfully killing it.
216 """
217 main.log.info( "Safety check, killing all ONOS processes" )
You Wangf9d95be2018-08-01 14:35:37 -0700218 return cluster.killOnos( killRemoveMax, stopOnos )
Devin Lim58046fa2017-07-05 16:55:00 -0700219
You Wang09b596b2018-01-10 10:42:38 -0800220 def createApplyCell( self, cluster, newCell, cellName, cellApps,
You Wanga0f6ff62018-01-11 15:46:30 -0800221 mininetIp, useSSH, ips, installMax=False ):
Devin Lim142b5342017-07-20 15:22:39 -0700222 """
223 Description:
224 create new cell ( optional ) and apply it. It will also verify the
225 cell.
226 Required:
227 * cluster - the cluster driver that will be used.
228 * newCell - True for making a new cell and False for not making it.
229 * cellName - The name of the cell.
You Wang09b596b2018-01-10 10:42:38 -0800230 * cellApps - The onos apps string.
You Wanga0f6ff62018-01-11 15:46:30 -0800231 * mininetIp - Mininet IP address.
Devin Lim142b5342017-07-20 15:22:39 -0700232 * useSSH - True for using ssh when creating a cell
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700233 * ips - ip( s ) of the node( s ).
Devin Lim142b5342017-07-20 15:22:39 -0700234 Returns:
235 Returns main.TRUE if it successfully executed.
236 """
Devin Lim58046fa2017-07-05 16:55:00 -0700237 if newCell:
You Wanga0f6ff62018-01-11 15:46:30 -0800238 cluster.createCell( cellName, cellApps, mininetIp, useSSH, ips )
Devin Lim58046fa2017-07-05 16:55:00 -0700239 main.step( "Apply cell to environment" )
Devin Lim142b5342017-07-20 15:22:39 -0700240 stepResult = cluster.applyCell( cellName )
Devin Lim58046fa2017-07-05 16:55:00 -0700241 utilities.assert_equals( expect=main.TRUE,
242 actual=stepResult,
243 onpass="Successfully applied cell to " +
244 "environment",
Devin Lim142b5342017-07-20 15:22:39 -0700245 onfail="Failed to apply cell to environment" )
Devin Lim58046fa2017-07-05 16:55:00 -0700246 return stepResult
247
You Wangf9d95be2018-08-01 14:35:37 -0700248 def uninstallAtomix( self, cluster, uninstallMax ):
249 """
250 Description:
251 uninstalling atomix and verify the result.
252 Required:
253 * cluster - a cluster driver that will be used.
254 * uninstallMax - True for uninstalling max number of nodes
255 False for uninstalling the current running nodes.
256 Returns:
257 Returns main.TRUE if it successfully uninstalled.
258 """
259 main.step( "Uninstalling Atomix" )
260 atomixUninstallResult = cluster.uninstallAtomix( uninstallMax )
261 utilities.assert_equals( expect=main.TRUE,
262 actual=atomixUninstallResult,
263 onpass="Successfully uninstalled Atomix",
264 onfail="Failed to uninstall Atomix" )
265 return atomixUninstallResult
266
Devin Lim142b5342017-07-20 15:22:39 -0700267 def uninstallOnos( self, cluster, uninstallMax ):
268 """
269 Description:
270 uninstalling onos and verify the result.
271 Required:
272 * cluster - a cluster driver that will be used.
273 * uninstallMax - True for uninstalling max number of nodes
274 False for uninstalling the current running nodes.
275 Returns:
276 Returns main.TRUE if it successfully uninstalled.
277 """
Devin Lim58046fa2017-07-05 16:55:00 -0700278 main.step( "Uninstalling ONOS package" )
You Wangf9d95be2018-08-01 14:35:37 -0700279 onosUninstallResult = cluster.uninstallOnos( uninstallMax )
Devin Lim58046fa2017-07-05 16:55:00 -0700280 utilities.assert_equals( expect=main.TRUE,
281 actual=onosUninstallResult,
282 onpass="Successfully uninstalled ONOS package",
283 onfail="Failed to uninstall ONOS package" )
284 return onosUninstallResult
285
Devin Lim142b5342017-07-20 15:22:39 -0700286 def buildOnos( self, cluster ):
287 """
288 Description:
You Wangd54c7052018-08-07 16:06:27 -0700289 build the onos using bazel build onos and verify the result
Devin Lim142b5342017-07-20 15:22:39 -0700290 Required:
291 * cluster - the cluster driver that will be used.
292 Returns:
293 Returns main.TRUE if it successfully built.
294 """
Devin Lim58046fa2017-07-05 16:55:00 -0700295 main.step( "Creating ONOS package" )
You Wangd54c7052018-08-07 16:06:27 -0700296 packageResult = main.ONOSbench.bazelBuild()
Devin Lim58046fa2017-07-05 16:55:00 -0700297 utilities.assert_equals( expect=main.TRUE,
298 actual=packageResult,
299 onpass="Successfully created ONOS package",
300 onfail="Failed to create ONOS package" )
301 return packageResult
302
You Wangf9d95be2018-08-01 14:35:37 -0700303 def installAtomix( self, cluster, installMax, parallel=True ):
304 """
305 Description:
306 Installing atomix and verify the result
307 Required:
308 * cluster - the cluster driver that will be used.
309 * installMax - True for installing max number of nodes
310 False for installing current running nodes only.
311 Returns:
312 Returns main.TRUE if it successfully installed
313 """
314 main.step( "Installing Atomix" )
315 atomixInstallResult = main.TRUE
316
317 cluster.installAtomix( installMax, parallel )
318 utilities.assert_equals( expect=main.TRUE,
319 actual=atomixInstallResult,
320 onpass="Successfully installed Atomix",
321 onfail="Failed to install Atomix" )
322 if not atomixInstallResult:
323 main.cleanAndExit()
324 return atomixInstallResult
325
Devin Lime9f0ccf2017-08-11 17:25:12 -0700326 def installOnos( self, cluster, installMax, parallel=True ):
Devin Lim142b5342017-07-20 15:22:39 -0700327 """
328 Description:
329 Installing onos and verify the result
330 Required:
331 * cluster - the cluster driver that will be used.
332 * installMax - True for installing max number of nodes
333 False for installing current running nodes only.
334 Returns:
335 Returns main.TRUE if it successfully installed
336 """
Devin Lim58046fa2017-07-05 16:55:00 -0700337 main.step( "Installing ONOS package" )
338 onosInstallResult = main.TRUE
339
You Wangf9d95be2018-08-01 14:35:37 -0700340 cluster.installOnos( installMax, parallel )
Devin Lim58046fa2017-07-05 16:55:00 -0700341 utilities.assert_equals( expect=main.TRUE,
342 actual=onosInstallResult,
343 onpass="Successfully installed ONOS package",
344 onfail="Failed to install ONOS package" )
345 if not onosInstallResult:
Devin Lim44075962017-08-11 10:56:37 -0700346 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700347 return onosInstallResult
348
Devin Lim142b5342017-07-20 15:22:39 -0700349 def setupSsh( self, cluster ):
350 """
351 Description:
352 set up ssh to the onos and verify the result
353 Required:
354 * cluster - the cluster driver that will be used.
355 Returns:
356 Returns main.TRUE if it successfully setup the ssh to
357 the onos.
358 """
Devin Lim58046fa2017-07-05 16:55:00 -0700359 main.step( "Set up ONOS secure SSH" )
Devin Lim142b5342017-07-20 15:22:39 -0700360 secureSshResult = cluster.ssh()
Devin Lim58046fa2017-07-05 16:55:00 -0700361 utilities.assert_equals( expect=main.TRUE,
362 actual=secureSshResult,
363 onpass="Test step PASS",
364 onfail="Test step FAIL" )
365 return secureSshResult
366
Devin Lim142b5342017-07-20 15:22:39 -0700367 def checkOnosService( self, cluster ):
368 """
369 Description:
370 Checking if the onos service is up and verify the result
371 Required:
372 * cluster - the cluster driver that will be used.
373 Returns:
374 Returns main.TRUE if it successfully checked
375 """
376 main.step( "Checking ONOS service" )
377 stepResult = cluster.checkService()
Devin Lim58046fa2017-07-05 16:55:00 -0700378 utilities.assert_equals( expect=main.TRUE,
379 actual=stepResult,
380 onpass="ONOS service is ready on all nodes",
381 onfail="ONOS service did not start properly on all nodes" )
382 return stepResult
383
Jon Hallca319892017-06-15 15:25:22 -0700384 def startOnosClis( self, cluster ):
Devin Lim142b5342017-07-20 15:22:39 -0700385 """
386 Description:
387 starting Onos using onosCli driver and verify the result
388 Required:
389 * cluster - the cluster driver that will be used.
390 Returns:
391 Returns main.TRUE if it successfully started. It will exit
392 the test if not started properly.
393 """
Devin Lim58046fa2017-07-05 16:55:00 -0700394 main.step( "Starting ONOS CLI sessions" )
Jon Hallca319892017-06-15 15:25:22 -0700395 startCliResult = cluster.startCLIs()
Devin Lim58046fa2017-07-05 16:55:00 -0700396 if not startCliResult:
397 main.log.info( "ONOS CLI did not start up properly" )
Devin Lim44075962017-08-11 10:56:37 -0700398 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700399 else:
400 main.log.info( "Successful CLI startup" )
401 utilities.assert_equals( expect=main.TRUE,
402 actual=startCliResult,
403 onpass="Successfully start ONOS cli",
404 onfail="Failed to start ONOS cli" )
405 return startCliResult
406
You Wang0d9f2c02018-08-10 14:56:32 -0700407 def checkOnosNodes( self, cluster ):
408 """
409 Description:
410 Checking if the onos nodes are in READY state
411 Required:
412 * cluster - the cluster driver that will be used.
413 Returns:
414 Returns main.TRUE if it successfully checked
415 """
416 main.step( "Checking ONOS nodes" )
417 stepResult = utilities.retry( main.Cluster.nodesCheck,
418 False,
419 attempts=9 )
420
421 utilities.assert_equals( expect=True,
422 actual=stepResult,
423 onpass="All ONOS nodes are in READY state",
424 onfail="Not all ONOS nodes are in READY state" )
425
426 if not stepResult:
427 for ctrl in main.Cluster.active():
428 main.log.debug( "{} components not ACTIVE: \n{}".format(
429 ctrl.name,
430 ctrl.CLI.sendline( "scr:list | grep -v ACTIVE" ) ) )
431 main.log.error( "Failed to start ONOS, stopping test" )
You Wangba973f02018-08-30 12:33:41 -0700432 main.cleanAndExit()
433 return main.TRUE
You Wang0d9f2c02018-08-10 14:56:32 -0700434
435 def checkOnosApps( self, cluster, apps ):
436 """
437 Description:
438 Checking if the onos applications are activated
439 Required:
440 * cluster - the cluster driver that will be used.
441 * apps: list of applications that are expected to be activated
442 Returns:
443 Returns main.TRUE if it successfully checked
444 """
445 main.step( "Checking ONOS applications" )
446 stepResult = utilities.retry( main.Cluster.appsCheck,
447 False,
448 args = [ apps ],
449 sleep=5,
450 attempts=9 )
451
452 utilities.assert_equals( expect=True,
453 actual=stepResult,
454 onpass="All ONOS apps are activated",
455 onfail="Not all ONOS apps are activated" )
456
457 return main.TRUE if stepResult else main.FALSE
458
Jon Hall4f360bc2017-09-07 10:19:52 -0700459 def processList( self, functions, args ):
460 if functions is not None:
461 if isinstance( functions, list ):
462 i = 0
463 for f in functions:
464 f( *( args[ i ] ) ) if args is not None and args[ i ] is not None else f()
465 i += 1
466 else:
467 functions( *args ) if args is not None else functions()
468
You Wanga0f6ff62018-01-11 15:46:30 -0800469 def ONOSSetUp( self, cluster, hasMultiNodeRounds=False, startOnos=True, newCell=True,
You Wangcdc51fe2018-08-12 17:14:56 -0700470 cellName="temp", cellApps="drivers", appPrefix="org.onosproject.",
471 mininetIp="", removeLog=False, extraApply=None, applyArgs=None,
You Wang09b596b2018-01-10 10:42:38 -0800472 extraClean=None, cleanArgs=None, skipPack=False, installMax=False, useSSH=True,
You Wangf9d95be2018-08-01 14:35:37 -0700473 killRemoveMax=True, stopAtomix=False, stopOnos=False, installParallel=True, cellApply=True,
474 includeCaseDesc=True ):
Devin Lim142b5342017-07-20 15:22:39 -0700475 """
476 Description:
477 Initial ONOS setting up of the tests. It will also verify the result of each steps.
478 The procedures will be:
479 killing onos
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700480 creating ( optional ) /applying cell
481 removing raft logs ( optional )
Devin Lim142b5342017-07-20 15:22:39 -0700482 uninstalling onos
483 extra procedure to be applied( optional )
484 building onos
485 installing onos
486 extra cleanup to be applied ( optional )
487 setting up ssh to the onos
488 checking the onos service
489 starting onos
490 Required:
Devin Lim142b5342017-07-20 15:22:39 -0700491 * cluster - the cluster driver that will be used.
492 * hasMultiNodeRouds - True if the test is testing different set of nodes
493 * startOnos - True if wish to start onos.
494 * newCell - True for making a new cell and False for not making it.
495 * cellName - Name of the cell that will be used.
You Wang0d9f2c02018-08-10 14:56:32 -0700496 * cellApps - The cell apps string. Will be overwritten by main.apps if it exists
You Wangcdc51fe2018-08-12 17:14:56 -0700497 * appPrefix - Prefix of app names. Will use "org.onosproject." by default
You Wanga0f6ff62018-01-11 15:46:30 -0800498 * mininetIp - Mininet IP address.
Devin Lim142b5342017-07-20 15:22:39 -0700499 * removeLog - True if wish to remove raft logs
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700500 * extraApply - Function( s ) that will be called before building ONOS. Default to None.
501 * applyArgs - argument of the functon( s ) of the extraApply. Should be in list.
502 * extraClean - Function( s ) that will be called after building ONOS. Defaults to None.
503 * cleanArgs - argument of the functon( s ) of the extraClean. Should be in list.
Devin Lim142b5342017-07-20 15:22:39 -0700504 * skipPack - True if wish to skip some packing.
505 * installMax - True if wish to install onos max number of nodes
506 False if wish to install onos of running nodes only
507 * useSSH - True for using ssh when creating a cell
508 * killRemoveMax - True for removing/killing max number of nodes. False for
509 removing/killing running nodes only.
You Wangf9d95be2018-08-01 14:35:37 -0700510 * stopAtomix - True if wish to stop atomix before killing it.
Devin Lim142b5342017-07-20 15:22:39 -0700511 * stopOnos - True if wish to stop onos before killing it.
512 Returns:
513 Returns main.TRUE if it everything successfully proceeded.
514 """
515 self.setNumCtrls( hasMultiNodeRounds )
Devin Lim0c972b72018-02-08 14:53:59 -0800516 if includeCaseDesc:
517 main.case( "Starting up " + str( cluster.numCtrls ) +
518 " node(s) ONOS cluster" )
519 main.caseExplanation = "Set up ONOS with " + str( cluster.numCtrls ) + \
520 " node(s) ONOS cluster"
You Wangf9d95be2018-08-01 14:35:37 -0700521 atomixKillResult = self.killingAllAtomix( cluster, killRemoveMax, stopAtomix )
522 onosKillResult = self.killingAllOnos( cluster, killRemoveMax, stopOnos )
523 killResult = atomixKillResult and onosKillResult
Devin Lim58046fa2017-07-05 16:55:00 -0700524
Devin Lim142b5342017-07-20 15:22:39 -0700525 main.log.info( "NODE COUNT = " + str( cluster.numCtrls ) )
526 cellResult = main.TRUE
527 packageResult = main.TRUE
Devin Lim142b5342017-07-20 15:22:39 -0700528 onosCliResult = main.TRUE
Devin Lim6437c9c2018-01-29 17:24:16 -0800529 if cellApply:
You Wang0d9f2c02018-08-10 14:56:32 -0700530 try:
531 apps = main.apps
532 except ( NameError, AttributeError ):
533 apps = cellApps
534 main.log.debug( "Apps: " + str( apps ) )
Devin Lim142b5342017-07-20 15:22:39 -0700535 tempOnosIp = []
536 for ctrl in cluster.runningNodes:
537 tempOnosIp.append( ctrl.ipAddress )
You Wanga0f6ff62018-01-11 15:46:30 -0800538 if mininetIp == "":
539 mininetIp = "localhost"
540 for key, value in main.componentDictionary.items():
541 if value['type'] in ['MininetCliDriver', 'RemoteMininetDriver'] and hasattr( main, key ):
542 mininetIp = getattr( main, key ).ip_address
543 break
Devin Lim142b5342017-07-20 15:22:39 -0700544 cellResult = self.createApplyCell( cluster, newCell,
You Wang0d9f2c02018-08-10 14:56:32 -0700545 cellName, apps,
You Wanga0f6ff62018-01-11 15:46:30 -0800546 mininetIp, useSSH,
You Wang09b596b2018-01-10 10:42:38 -0800547 tempOnosIp, installMax )
Devin Lim58046fa2017-07-05 16:55:00 -0700548
Devin Lim6437c9c2018-01-29 17:24:16 -0800549 if removeLog:
550 main.log.info("Removing raft logs")
551 main.ONOSbench.onosRemoveRaftLogs()
You Wangf9d95be2018-08-01 14:35:37 -0700552 atomixUninstallResult = self.uninstallAtomix( cluster, killRemoveMax )
Devin Lim6437c9c2018-01-29 17:24:16 -0800553 onosUninstallResult = self.uninstallOnos( cluster, killRemoveMax )
You Wangf9d95be2018-08-01 14:35:37 -0700554 uninstallResult = atomixUninstallResult and onosUninstallResult
Devin Lim6437c9c2018-01-29 17:24:16 -0800555 self.processList( extraApply, applyArgs )
556
557 if not skipPack:
558 packageResult = self.buildOnos(cluster)
Devin Lim142b5342017-07-20 15:22:39 -0700559
You Wangf9d95be2018-08-01 14:35:37 -0700560 atomixInstallResult = self.installAtomix( cluster, installMax, installParallel )
Devin Lime9f0ccf2017-08-11 17:25:12 -0700561 onosInstallResult = self.installOnos( cluster, installMax, installParallel )
You Wangf9d95be2018-08-01 14:35:37 -0700562 installResult = atomixInstallResult and onosInstallResult
Devin Lim58046fa2017-07-05 16:55:00 -0700563
Jon Hall4f360bc2017-09-07 10:19:52 -0700564 self.processList( extraClean, cleanArgs )
Devin Lim142b5342017-07-20 15:22:39 -0700565 secureSshResult = self.setupSsh( cluster )
Devin Lim58046fa2017-07-05 16:55:00 -0700566
Devin Lim142b5342017-07-20 15:22:39 -0700567 onosServiceResult = self.checkOnosService( cluster )
Devin Lim58046fa2017-07-05 16:55:00 -0700568
Devin Lim142b5342017-07-20 15:22:39 -0700569 if startOnos:
Jon Hallca319892017-06-15 15:25:22 -0700570 onosCliResult = self.startOnosClis( cluster )
Devin Lim58046fa2017-07-05 16:55:00 -0700571
You Wang0d9f2c02018-08-10 14:56:32 -0700572 onosNodesResult = self.checkOnosNodes( cluster )
573
574 onosAppsResult = main.TRUE
575 if cellApply:
576 if apps:
577 apps = apps.split( ',' )
You Wangcdc51fe2018-08-12 17:14:56 -0700578 apps = [ appPrefix + app for app in apps ]
You Wang0d9f2c02018-08-10 14:56:32 -0700579 onosAppsResult = self.checkOnosApps( cluster, apps )
580 else:
581 main.log.warn( "No apps were specified to be checked after startup" )
582
You Wangf9d95be2018-08-01 14:35:37 -0700583 return killResult and cellResult and packageResult and uninstallResult and \
You Wang0d9f2c02018-08-10 14:56:32 -0700584 installResult and secureSshResult and onosServiceResult and onosCliResult and \
585 onosNodesResult and onosAppsResult