Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 1 | """ |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 2 | Copyright 2016 Open Networking Foundation ( ONF ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 3 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 4 | Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 5 | the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 6 | or 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 Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 11 | ( at your option ) any later version. |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 12 | |
| 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 Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 21 | import re |
Jon Hall | 43060f6 | 2020-06-23 13:13:33 -0700 | [diff] [blame] | 22 | import os |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 23 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 24 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 25 | class ONOSSetup: |
Jon Hall | 4f360bc | 2017-09-07 10:19:52 -0700 | [diff] [blame] | 26 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 27 | def __init__( self ): |
| 28 | self.default = '' |
Jon Hall | 627b157 | 2020-12-01 12:01:15 -0800 | [diff] [blame] | 29 | try: |
| 30 | main.persistentSetup |
| 31 | except ( NameError, AttributeError ): |
| 32 | main.persistentSetup = False |
Jon Hall | 4f360bc | 2017-09-07 10:19:52 -0700 | [diff] [blame] | 33 | |
Devin Lim | 0c972b7 | 2018-02-08 14:53:59 -0800 | [diff] [blame] | 34 | def envSetupDescription( self, includeCaseDesc=True ): |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 35 | """ |
| 36 | Introduction part of the test. It will initialize some basic vairables. |
| 37 | """ |
Devin Lim | 0c972b7 | 2018-02-08 14:53:59 -0800 | [diff] [blame] | 38 | if includeCaseDesc: |
| 39 | main.case( "Constructing test variables and building ONOS package" ) |
| 40 | main.caseExplanation = "For loading from params file, and pull" + \ |
| 41 | " and build the latest ONOS package" |
Jon Hall | a604fd4 | 2018-05-04 14:27:27 -0700 | [diff] [blame] | 42 | main.step( "Constructing test variables" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 43 | try: |
| 44 | from tests.dependencies.Cluster import Cluster |
| 45 | except ImportError: |
| 46 | main.log.error( "Cluster not found. exiting the test" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 47 | main.cleanAndExit() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 48 | try: |
| 49 | main.Cluster |
| 50 | except ( NameError, AttributeError ): |
Jon Hall | 3c0114c | 2020-08-11 15:07:42 -0700 | [diff] [blame] | 51 | main.Cluster = Cluster( main.ONOScell.nodes, useDocker=main.ONOScell.useDocker ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 52 | main.ONOSbench = main.Cluster.controllers[ 0 ].Bench |
Jon Hall | d74d295 | 2018-03-01 13:26:39 -0800 | [diff] [blame] | 53 | main.testOnDirectory = re.sub( "(/tests)$", "", main.testsRoot ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 54 | |
Devin Lim | 0c972b7 | 2018-02-08 14:53:59 -0800 | [diff] [blame] | 55 | def gitPulling( self, includeCaseDesc=True ): |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 56 | """ |
| 57 | it will do git checkout or pull if they are enabled from the params file. |
| 58 | """ |
Devin Lim | 0c972b7 | 2018-02-08 14:53:59 -0800 | [diff] [blame] | 59 | |
| 60 | if includeCaseDesc: |
| 61 | main.case( "Pull onos branch and build onos on Teststation." ) |
| 62 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 63 | gitPull = main.params[ 'GIT' ][ 'pull' ] |
| 64 | gitBranch = main.params[ 'GIT' ][ 'branch' ] |
| 65 | if gitPull == 'True': |
| 66 | main.step( "Git Checkout ONOS branch: " + gitBranch ) |
| 67 | stepResult = main.ONOSbench.gitCheckout( branch=gitBranch ) |
| 68 | utilities.assert_equals( expect=main.TRUE, |
| 69 | actual=stepResult, |
| 70 | onpass="Successfully checkout onos branch.", |
| 71 | onfail="Failed to checkout onos branch. Exiting test..." ) |
Jon Hall | 4f360bc | 2017-09-07 10:19:52 -0700 | [diff] [blame] | 72 | if not stepResult: |
| 73 | main.cleanAndExit() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 74 | |
| 75 | main.step( "Git Pull on ONOS branch:" + gitBranch ) |
| 76 | stepResult = main.ONOSbench.gitPull() |
| 77 | utilities.assert_equals( expect=main.TRUE, |
| 78 | actual=stepResult, |
| 79 | onpass="Successfully pull onos. ", |
| 80 | onfail="Failed to pull onos. Exiting test ..." ) |
Jon Hall | 4f360bc | 2017-09-07 10:19:52 -0700 | [diff] [blame] | 81 | if not stepResult: |
| 82 | main.cleanAndExit() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 83 | |
| 84 | else: |
| 85 | main.log.info( "Skipped git checkout and pull as they are disabled in params file" ) |
| 86 | |
Devin Lim | 0c972b7 | 2018-02-08 14:53:59 -0800 | [diff] [blame] | 87 | def envSetup( self, includeGitPull=True, includeCaseDesc=True ): |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 88 | """ |
| 89 | Description: |
| 90 | some environment setup for the test. |
| 91 | Required: |
| 92 | * includeGitPull - if wish to git pulling function to be executed. |
| 93 | Returns: |
| 94 | Returns main.TRUE |
| 95 | """ |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 96 | if includeGitPull: |
Devin Lim | 0c972b7 | 2018-02-08 14:53:59 -0800 | [diff] [blame] | 97 | self.gitPulling( includeCaseDesc ) |
Jon Hall | ca31989 | 2017-06-15 15:25:22 -0700 | [diff] [blame] | 98 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 99 | try: |
| 100 | from tests.dependencies.Cluster import Cluster |
| 101 | except ImportError: |
| 102 | main.log.error( "Cluster not found. exiting the test" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 103 | main.cleanAndExit() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 104 | try: |
| 105 | main.Cluster |
| 106 | except ( NameError, AttributeError ): |
Jon Hall | 3c0114c | 2020-08-11 15:07:42 -0700 | [diff] [blame] | 107 | main.Cluster = Cluster( main.ONOScell.nodes, useDocker=main.ONOScell.useDocker ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 108 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 109 | main.cellData = {} # For creating cell file |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 110 | |
Jon Hall | ca31989 | 2017-06-15 15:25:22 -0700 | [diff] [blame] | 111 | return main.TRUE |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 112 | |
Jon Hall | 3c0114c | 2020-08-11 15:07:42 -0700 | [diff] [blame] | 113 | def envSetupException( self, error ): |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 114 | """ |
| 115 | Description: |
| 116 | handles the exception that might occur from the environment setup. |
| 117 | Required: |
Jon Hall | 3c0114c | 2020-08-11 15:07:42 -0700 | [diff] [blame] | 118 | * error - exception returned from except. |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 119 | """ |
Jon Hall | 3c0114c | 2020-08-11 15:07:42 -0700 | [diff] [blame] | 120 | main.log.exception( error ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 121 | main.cleanAndExit() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 122 | |
Jon Hall | aa1d9b8 | 2020-07-30 13:49:42 -0700 | [diff] [blame] | 123 | def envSetupConclusion( self, stepResult ): |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 124 | """ |
| 125 | Description: |
| 126 | compare the result of the envSetup of the test. |
| 127 | Required: |
| 128 | * stepResult - Result of the envSetup. |
| 129 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 130 | utilities.assert_equals( expect=main.TRUE, |
| 131 | actual=stepResult, |
| 132 | onpass="Successfully construct " + |
| 133 | "test variables ", |
| 134 | onfail="Failed to construct test variables" ) |
Jon Hall | 7633c38 | 2020-12-15 17:30:42 -0800 | [diff] [blame] | 135 | branch = main.params[ 'GRAPH' ].get('branch') |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 136 | |
Jon Hall | f252790 | 2020-07-30 12:56:08 -0700 | [diff] [blame] | 137 | if main.params[ 'GRAPH' ].get('jobName'): |
Jon Hall | 7633c38 | 2020-12-15 17:30:42 -0800 | [diff] [blame] | 138 | url = self.generateGraphURL( testname=main.params[ 'GRAPH' ][ 'jobName' ], branch=branch ) |
Jon Hall | f252790 | 2020-07-30 12:56:08 -0700 | [diff] [blame] | 139 | else: |
Jon Hall | 7633c38 | 2020-12-15 17:30:42 -0800 | [diff] [blame] | 140 | url = self.generateGraphURL( branch=branch ) |
Jeremy Ronquillo | 7f8fb57 | 2017-11-14 08:28:41 -0800 | [diff] [blame] | 141 | main.log.wiki( url ) |
| 142 | |
Jon Hall | c5b4c1c | 2020-12-15 16:50:54 -0800 | [diff] [blame] | 143 | if not main.persistentSetup: |
| 144 | # ONOS is not deployed by the test |
| 145 | # TODO: Try to get commit another way, maybe container labels? |
| 146 | # Or try to link to deployment job? |
| 147 | main.commit = main.ONOSbench.getVersion( report=True ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 148 | |
Jon Hall | 7633c38 | 2020-12-15 17:30:42 -0800 | [diff] [blame] | 149 | def generateGraphURL( self, testname=main.TEST, width=525, height=350, branch=None ): |
Jeremy Ronquillo | 7f8fb57 | 2017-11-14 08:28:41 -0800 | [diff] [blame] | 150 | """ |
| 151 | Description: |
| 152 | Obtain the URL for the graph that corresponds to the test being run. |
| 153 | """ |
| 154 | |
| 155 | nodeCluster = main.params[ 'GRAPH' ][ 'nodeCluster' ] |
Jon Hall | 7633c38 | 2020-12-15 17:30:42 -0800 | [diff] [blame] | 156 | if not branch: |
| 157 | branch = main.ONOSbench.getBranchName() |
Jeremy Ronquillo | 7f8fb57 | 2017-11-14 08:28:41 -0800 | [diff] [blame] | 158 | maxBuildsToShow = main.params[ 'GRAPH' ][ 'builds' ] |
| 159 | |
| 160 | return '<ac:structured-macro ac:name="html">\n' + \ |
| 161 | '<ac:plain-text-body><![CDATA[\n' + \ |
Devin Lim | d1fb8e9 | 2018-02-28 16:29:33 -0800 | [diff] [blame] | 162 | '<img src="https://jenkins.onosproject.org/view/QA/job/postjob-' + \ |
Jeremy Ronquillo | 7f8fb57 | 2017-11-14 08:28:41 -0800 | [diff] [blame] | 163 | nodeCluster + \ |
| 164 | '/lastSuccessfulBuild/artifact/' + \ |
| 165 | testname + \ |
| 166 | '_' + \ |
| 167 | branch + \ |
| 168 | '_' + \ |
| 169 | maxBuildsToShow + \ |
| 170 | '-builds_graph.jpg", alt="' + \ |
| 171 | testname + \ |
| 172 | '", style="width:' + \ |
| 173 | str( width ) + \ |
| 174 | 'px;height:' + \ |
| 175 | str( height ) + \ |
| 176 | 'px;border:0"' + \ |
| 177 | '>' + \ |
| 178 | ']]></ac:plain-text-body>\n' + \ |
| 179 | '</ac:structured-macro>\n' |
| 180 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 181 | def setNumCtrls( self, hasMultiNodeRounds ): |
| 182 | """ |
| 183 | Description: |
Jon Hall | 3e6edb3 | 2018-08-21 16:20:30 -0700 | [diff] [blame] | 184 | Set new number of controllers if it uses different number of nodes. |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 185 | different number of nodes should be pre-defined in main.scale. |
| 186 | Required: |
| 187 | * hasMultiNodeRouds - if the test is testing different number of nodes. |
| 188 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 189 | if hasMultiNodeRounds: |
| 190 | try: |
| 191 | main.cycle |
| 192 | except Exception: |
| 193 | main.cycle = 0 |
| 194 | main.cycle += 1 |
Jon Hall | 3e6edb3 | 2018-08-21 16:20:30 -0700 | [diff] [blame] | 195 | # main.scale[ 0 ] determines the current number of ONOS controllers |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 196 | main.Cluster.setRunningNode( int( main.scale.pop( 0 ) ) ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 197 | |
You Wang | f9d95be | 2018-08-01 14:35:37 -0700 | [diff] [blame] | 198 | def killingAllAtomix( self, cluster, killRemoveMax, stopAtomix ): |
| 199 | """ |
| 200 | Description: |
| 201 | killing atomix. It will either kill the current runningnodes or |
| 202 | max number of the nodes. |
| 203 | Required: |
| 204 | * cluster - the cluster driver that will be used. |
| 205 | * killRemoveMax - The boolean that will decide either to kill |
| 206 | only running nodes ( False ) or max number of nodes ( True ). |
| 207 | * stopAtomix - If wish to stop atomix before killing it. True for |
| 208 | enable stop, False for disable stop. |
| 209 | Returns: |
| 210 | Returns main.TRUE if successfully killing it. |
| 211 | """ |
| 212 | main.log.info( "Safety check, killing all Atomix processes" ) |
| 213 | return cluster.killAtomix( killRemoveMax, stopAtomix ) |
| 214 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 215 | def killingAllOnos( self, cluster, killRemoveMax, stopOnos ): |
| 216 | """ |
| 217 | Description: |
| 218 | killing the onos. It will either kill the current runningnodes or |
| 219 | max number of the nodes. |
| 220 | Required: |
| 221 | * cluster - the cluster driver that will be used. |
| 222 | * killRemoveMax - The boolean that will decide either to kill |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 223 | only running nodes ( False ) or max number of nodes ( True ). |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 224 | * stopOnos - If wish to stop onos before killing it. True for |
You Wang | f9d95be | 2018-08-01 14:35:37 -0700 | [diff] [blame] | 225 | enable stop, False for disable stop. |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 226 | Returns: |
| 227 | Returns main.TRUE if successfully killing it. |
| 228 | """ |
| 229 | main.log.info( "Safety check, killing all ONOS processes" ) |
You Wang | f9d95be | 2018-08-01 14:35:37 -0700 | [diff] [blame] | 230 | return cluster.killOnos( killRemoveMax, stopOnos ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 231 | |
Jon Hall | 3c0114c | 2020-08-11 15:07:42 -0700 | [diff] [blame] | 232 | def killingAllOnosDocker( self, cluster, killRemoveMax ): |
| 233 | """ |
| 234 | Description: |
| 235 | killing the onos docker images . It will either kill the |
| 236 | current runningnodes or max number of the nodes. |
| 237 | Required: |
| 238 | * cluster - the cluster driver that will be used. |
| 239 | * killRemoveMax - The boolean that will decide either to kill |
| 240 | only running nodes ( False ) or max number of nodes ( True ). |
| 241 | Returns: |
| 242 | Returns main.TRUE if successfully killing it. |
| 243 | """ |
| 244 | main.log.info( "Safety check, stopping all ONOS docker containers" ) |
| 245 | return cluster.dockerStop( killRemoveMax ) |
| 246 | |
You Wang | 09b596b | 2018-01-10 10:42:38 -0800 | [diff] [blame] | 247 | def createApplyCell( self, cluster, newCell, cellName, cellApps, |
Jon Hall | 3e6edb3 | 2018-08-21 16:20:30 -0700 | [diff] [blame] | 248 | mininetIp, useSSH, onosIps, installMax=False, |
| 249 | atomixClusterSize=None ): |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 250 | """ |
| 251 | Description: |
| 252 | create new cell ( optional ) and apply it. It will also verify the |
| 253 | cell. |
Jon Hall | 3e6edb3 | 2018-08-21 16:20:30 -0700 | [diff] [blame] | 254 | Required Arguments: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 255 | * cluster - the cluster driver that will be used. |
| 256 | * newCell - True for making a new cell and False for not making it. |
| 257 | * cellName - The name of the cell. |
You Wang | 09b596b | 2018-01-10 10:42:38 -0800 | [diff] [blame] | 258 | * cellApps - The onos apps string. |
You Wang | a0f6ff6 | 2018-01-11 15:46:30 -0800 | [diff] [blame] | 259 | * mininetIp - Mininet IP address. |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 260 | * useSSH - True for using ssh when creating a cell |
Jon Hall | 3e6edb3 | 2018-08-21 16:20:30 -0700 | [diff] [blame] | 261 | * onosIps - ip( s ) of the ONOS node( s ). |
| 262 | Optional Arguments: |
| 263 | * installMax |
| 264 | * atomixClusterSize - The size of the atomix cluster. Defaults to same |
| 265 | as ONOS Cluster size |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 266 | Returns: |
| 267 | Returns main.TRUE if it successfully executed. |
| 268 | """ |
Jon Hall | 579d21e | 2021-04-14 12:27:38 -0700 | [diff] [blame] | 269 | stepResult = main.TRUE |
Jon Hall | 3e6edb3 | 2018-08-21 16:20:30 -0700 | [diff] [blame] | 270 | if atomixClusterSize is None: |
| 271 | atomixClusterSize = len( cluster.runningNodes ) |
Jon Hall | 3c0114c | 2020-08-11 15:07:42 -0700 | [diff] [blame] | 272 | if atomixClusterSize is 1: |
| 273 | atomixClusterSize = len( cluster.controllers ) |
Jon Hall | 3e6edb3 | 2018-08-21 16:20:30 -0700 | [diff] [blame] | 274 | atomixClusterSize = int( atomixClusterSize ) |
| 275 | cluster.setAtomixNodes( atomixClusterSize ) |
| 276 | atomixIps = [ node.ipAddress for node in cluster.atomixNodes ] |
| 277 | main.log.info( "Atomix Cluster Size = {} ".format( atomixClusterSize ) ) |
Jon Hall | 579d21e | 2021-04-14 12:27:38 -0700 | [diff] [blame] | 278 | if not main.persistentSetup: |
| 279 | if newCell: |
| 280 | cluster.createCell( cellName, cellApps, mininetIp, useSSH, onosIps, |
| 281 | atomixIps, installMax ) |
| 282 | main.step( "Apply cell to environment" ) |
| 283 | stepResult = cluster.applyCell( cellName ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 284 | utilities.assert_equals( expect=main.TRUE, |
| 285 | actual=stepResult, |
| 286 | onpass="Successfully applied cell to " + |
| 287 | "environment", |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 288 | onfail="Failed to apply cell to environment" ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 289 | return stepResult |
| 290 | |
You Wang | f9d95be | 2018-08-01 14:35:37 -0700 | [diff] [blame] | 291 | def uninstallAtomix( self, cluster, uninstallMax ): |
| 292 | """ |
| 293 | Description: |
| 294 | uninstalling atomix and verify the result. |
| 295 | Required: |
| 296 | * cluster - a cluster driver that will be used. |
| 297 | * uninstallMax - True for uninstalling max number of nodes |
Jon Hall | 3e6edb3 | 2018-08-21 16:20:30 -0700 | [diff] [blame] | 298 | False for uninstalling the current running nodes. |
You Wang | f9d95be | 2018-08-01 14:35:37 -0700 | [diff] [blame] | 299 | Returns: |
| 300 | Returns main.TRUE if it successfully uninstalled. |
| 301 | """ |
| 302 | main.step( "Uninstalling Atomix" ) |
| 303 | atomixUninstallResult = cluster.uninstallAtomix( uninstallMax ) |
| 304 | utilities.assert_equals( expect=main.TRUE, |
| 305 | actual=atomixUninstallResult, |
| 306 | onpass="Successfully uninstalled Atomix", |
| 307 | onfail="Failed to uninstall Atomix" ) |
| 308 | return atomixUninstallResult |
| 309 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 310 | def uninstallOnos( self, cluster, uninstallMax ): |
| 311 | """ |
| 312 | Description: |
| 313 | uninstalling onos and verify the result. |
| 314 | Required: |
| 315 | * cluster - a cluster driver that will be used. |
| 316 | * uninstallMax - True for uninstalling max number of nodes |
| 317 | False for uninstalling the current running nodes. |
| 318 | Returns: |
| 319 | Returns main.TRUE if it successfully uninstalled. |
| 320 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 321 | main.step( "Uninstalling ONOS package" ) |
You Wang | f9d95be | 2018-08-01 14:35:37 -0700 | [diff] [blame] | 322 | onosUninstallResult = cluster.uninstallOnos( uninstallMax ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 323 | utilities.assert_equals( expect=main.TRUE, |
| 324 | actual=onosUninstallResult, |
| 325 | onpass="Successfully uninstalled ONOS package", |
| 326 | onfail="Failed to uninstall ONOS package" ) |
| 327 | return onosUninstallResult |
| 328 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 329 | def buildOnos( self, cluster ): |
| 330 | """ |
| 331 | Description: |
You Wang | d54c705 | 2018-08-07 16:06:27 -0700 | [diff] [blame] | 332 | build the onos using bazel build onos and verify the result |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 333 | Required: |
| 334 | * cluster - the cluster driver that will be used. |
| 335 | Returns: |
| 336 | Returns main.TRUE if it successfully built. |
| 337 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 338 | main.step( "Creating ONOS package" ) |
You Wang | d54c705 | 2018-08-07 16:06:27 -0700 | [diff] [blame] | 339 | packageResult = main.ONOSbench.bazelBuild() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 340 | utilities.assert_equals( expect=main.TRUE, |
| 341 | actual=packageResult, |
| 342 | onpass="Successfully created ONOS package", |
| 343 | onfail="Failed to create ONOS package" ) |
You Wang | 8f5ff15 | 2019-02-28 11:35:25 -0800 | [diff] [blame] | 344 | if not packageResult: |
| 345 | main.cleanAndExit() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 346 | return packageResult |
| 347 | |
Jon Hall | 3c0114c | 2020-08-11 15:07:42 -0700 | [diff] [blame] | 348 | def buildDocker( self, cluster ): |
| 349 | """ |
| 350 | Description: |
| 351 | Build the latest docker |
| 352 | Required: |
| 353 | * cluster - the cluster driver that will be used. |
| 354 | Returns: |
| 355 | Returns main.TRUE if it successfully built. |
| 356 | """ |
| 357 | main.step( "Building ONOS Docker image" ) |
| 358 | buildResult = cluster.dockerBuild() |
| 359 | utilities.assert_equals( expect=main.TRUE, |
| 360 | actual=buildResult, |
| 361 | onpass="Successfully created ONOS docker", |
| 362 | onfail="Failed to create ONOS docker" ) |
| 363 | if not buildResult: |
| 364 | main.cleanAndExit() |
| 365 | return buildResult |
| 366 | |
Jon Hall | 3e6edb3 | 2018-08-21 16:20:30 -0700 | [diff] [blame] | 367 | def installAtomix( self, cluster, parallel=True ): |
You Wang | f9d95be | 2018-08-01 14:35:37 -0700 | [diff] [blame] | 368 | """ |
| 369 | Description: |
| 370 | Installing atomix and verify the result |
| 371 | Required: |
| 372 | * cluster - the cluster driver that will be used. |
You Wang | f9d95be | 2018-08-01 14:35:37 -0700 | [diff] [blame] | 373 | False for installing current running nodes only. |
| 374 | Returns: |
| 375 | Returns main.TRUE if it successfully installed |
| 376 | """ |
| 377 | main.step( "Installing Atomix" ) |
| 378 | atomixInstallResult = main.TRUE |
| 379 | |
Jon Hall | b685a1c | 2018-10-30 15:17:01 -0700 | [diff] [blame] | 380 | atomixInstallResult = cluster.installAtomix( parallel ) |
You Wang | f9d95be | 2018-08-01 14:35:37 -0700 | [diff] [blame] | 381 | utilities.assert_equals( expect=main.TRUE, |
| 382 | actual=atomixInstallResult, |
| 383 | onpass="Successfully installed Atomix", |
| 384 | onfail="Failed to install Atomix" ) |
| 385 | if not atomixInstallResult: |
| 386 | main.cleanAndExit() |
| 387 | return atomixInstallResult |
| 388 | |
Devin Lim | e9f0ccf | 2017-08-11 17:25:12 -0700 | [diff] [blame] | 389 | def installOnos( self, cluster, installMax, parallel=True ): |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 390 | """ |
| 391 | Description: |
| 392 | Installing onos and verify the result |
| 393 | Required: |
| 394 | * cluster - the cluster driver that will be used. |
| 395 | * installMax - True for installing max number of nodes |
| 396 | False for installing current running nodes only. |
| 397 | Returns: |
| 398 | Returns main.TRUE if it successfully installed |
| 399 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 400 | main.step( "Installing ONOS package" ) |
| 401 | onosInstallResult = main.TRUE |
| 402 | |
You Wang | f9d95be | 2018-08-01 14:35:37 -0700 | [diff] [blame] | 403 | cluster.installOnos( installMax, parallel ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 404 | utilities.assert_equals( expect=main.TRUE, |
| 405 | actual=onosInstallResult, |
| 406 | onpass="Successfully installed ONOS package", |
| 407 | onfail="Failed to install ONOS package" ) |
| 408 | if not onosInstallResult: |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 409 | main.cleanAndExit() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 410 | return onosInstallResult |
| 411 | |
Jon Hall | 3c0114c | 2020-08-11 15:07:42 -0700 | [diff] [blame] | 412 | def startDocker( self, cluster, installMax, parallel=True ): |
| 413 | """ |
| 414 | Description: |
| 415 | Start onos docker containers and verify the result |
| 416 | Required: |
| 417 | * cluster - the cluster driver that will be used. |
| 418 | * installMax - True for installing max number of nodes |
| 419 | False for installing current running nodes only. |
| 420 | Returns: |
| 421 | Returns main.TRUE if it successfully installed |
| 422 | """ |
| 423 | main.step( "Create Cluster Config" ) |
| 424 | configResult = cluster.genPartitions() |
| 425 | utilities.assert_equals( expect=main.TRUE, |
| 426 | actual=configResult, |
| 427 | onpass="Successfully create cluster config", |
| 428 | onfail="Failed to create cluster config" ) |
| 429 | |
| 430 | # install atomix docker containers |
| 431 | main.step( "Installing Atomix via docker containers" ) |
| 432 | atomixInstallResult = cluster.startAtomixDocker( parallel ) |
| 433 | utilities.assert_equals( expect=main.TRUE, |
| 434 | actual=atomixInstallResult, |
| 435 | onpass="Successfully start atomix containers", |
| 436 | onfail="Failed to start atomix containers" ) |
| 437 | |
| 438 | main.step( "Installing ONOS via docker containers" ) |
| 439 | onosInstallResult = cluster.startONOSDocker( installMax, parallel ) |
| 440 | utilities.assert_equals( expect=main.TRUE, |
| 441 | actual=onosInstallResult, |
| 442 | onpass="Successfully start ONOS containers", |
| 443 | onfail="Failed to start ONOS containers" ) |
| 444 | if not onosInstallResult and atomixInstallResult: |
| 445 | main.cleanAndExit() |
| 446 | return onosInstallResult and atomixInstallResult |
| 447 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 448 | def setupSsh( self, cluster ): |
| 449 | """ |
| 450 | Description: |
| 451 | set up ssh to the onos and verify the result |
| 452 | Required: |
| 453 | * cluster - the cluster driver that will be used. |
| 454 | Returns: |
| 455 | Returns main.TRUE if it successfully setup the ssh to |
| 456 | the onos. |
| 457 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 458 | main.step( "Set up ONOS secure SSH" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 459 | secureSshResult = cluster.ssh() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 460 | utilities.assert_equals( expect=main.TRUE, |
| 461 | actual=secureSshResult, |
Jon Hall | 3e6edb3 | 2018-08-21 16:20:30 -0700 | [diff] [blame] | 462 | onpass="Secured ONOS ssh", |
| 463 | onfail="Failed to secure ssh" ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 464 | return secureSshResult |
| 465 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 466 | def checkOnosService( self, cluster ): |
| 467 | """ |
| 468 | Description: |
| 469 | Checking if the onos service is up and verify the result |
| 470 | Required: |
| 471 | * cluster - the cluster driver that will be used. |
| 472 | Returns: |
| 473 | Returns main.TRUE if it successfully checked |
| 474 | """ |
| 475 | main.step( "Checking ONOS service" ) |
| 476 | stepResult = cluster.checkService() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 477 | utilities.assert_equals( expect=main.TRUE, |
| 478 | actual=stepResult, |
| 479 | onpass="ONOS service is ready on all nodes", |
| 480 | onfail="ONOS service did not start properly on all nodes" ) |
| 481 | return stepResult |
| 482 | |
Jon Hall | ca31989 | 2017-06-15 15:25:22 -0700 | [diff] [blame] | 483 | def startOnosClis( self, cluster ): |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 484 | """ |
| 485 | Description: |
| 486 | starting Onos using onosCli driver and verify the result |
| 487 | Required: |
| 488 | * cluster - the cluster driver that will be used. |
| 489 | Returns: |
| 490 | Returns main.TRUE if it successfully started. It will exit |
| 491 | the test if not started properly. |
| 492 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 493 | main.step( "Starting ONOS CLI sessions" ) |
Jon Hall | ca31989 | 2017-06-15 15:25:22 -0700 | [diff] [blame] | 494 | startCliResult = cluster.startCLIs() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 495 | if not startCliResult: |
| 496 | main.log.info( "ONOS CLI did not start up properly" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 497 | main.cleanAndExit() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 498 | else: |
| 499 | main.log.info( "Successful CLI startup" ) |
| 500 | utilities.assert_equals( expect=main.TRUE, |
| 501 | actual=startCliResult, |
| 502 | onpass="Successfully start ONOS cli", |
| 503 | onfail="Failed to start ONOS cli" ) |
| 504 | return startCliResult |
| 505 | |
You Wang | 0d9f2c0 | 2018-08-10 14:56:32 -0700 | [diff] [blame] | 506 | def checkOnosNodes( self, cluster ): |
| 507 | """ |
| 508 | Description: |
| 509 | Checking if the onos nodes are in READY state |
| 510 | Required: |
| 511 | * cluster - the cluster driver that will be used. |
| 512 | Returns: |
| 513 | Returns main.TRUE if it successfully checked |
| 514 | """ |
| 515 | main.step( "Checking ONOS nodes" ) |
| 516 | stepResult = utilities.retry( main.Cluster.nodesCheck, |
| 517 | False, |
You Wang | 07831cb | 2018-09-04 12:18:04 -0700 | [diff] [blame] | 518 | attempts=90 ) |
You Wang | 0d9f2c0 | 2018-08-10 14:56:32 -0700 | [diff] [blame] | 519 | |
| 520 | utilities.assert_equals( expect=True, |
| 521 | actual=stepResult, |
| 522 | onpass="All ONOS nodes are in READY state", |
| 523 | onfail="Not all ONOS nodes are in READY state" ) |
| 524 | |
| 525 | if not stepResult: |
| 526 | for ctrl in main.Cluster.active(): |
| 527 | main.log.debug( "{} components not ACTIVE: \n{}".format( |
| 528 | ctrl.name, |
Jon Hall | f29368d | 2020-07-31 12:23:56 -0700 | [diff] [blame] | 529 | # FIXME: This output has changed a lot |
| 530 | ctrl.CLI.sendline( "onos:scr-list | grep -v ACTIVE" ) ) ) |
You Wang | 0d9f2c0 | 2018-08-10 14:56:32 -0700 | [diff] [blame] | 531 | main.log.error( "Failed to start ONOS, stopping test" ) |
You Wang | 7880b37 | 2019-02-27 16:50:47 -0800 | [diff] [blame] | 532 | main.cleanAndExit( msg="Failed to start ONOS: not all nodes are in READY state" ) |
You Wang | ba973f0 | 2018-08-30 12:33:41 -0700 | [diff] [blame] | 533 | return main.TRUE |
You Wang | 0d9f2c0 | 2018-08-10 14:56:32 -0700 | [diff] [blame] | 534 | |
| 535 | def checkOnosApps( self, cluster, apps ): |
| 536 | """ |
| 537 | Description: |
| 538 | Checking if the onos applications are activated |
| 539 | Required: |
| 540 | * cluster - the cluster driver that will be used. |
| 541 | * apps: list of applications that are expected to be activated |
| 542 | Returns: |
| 543 | Returns main.TRUE if it successfully checked |
| 544 | """ |
| 545 | main.step( "Checking ONOS applications" ) |
| 546 | stepResult = utilities.retry( main.Cluster.appsCheck, |
| 547 | False, |
| 548 | args = [ apps ], |
| 549 | sleep=5, |
Jon Hall | 3e6edb3 | 2018-08-21 16:20:30 -0700 | [diff] [blame] | 550 | attempts=90 ) |
You Wang | 0d9f2c0 | 2018-08-10 14:56:32 -0700 | [diff] [blame] | 551 | |
| 552 | utilities.assert_equals( expect=True, |
| 553 | actual=stepResult, |
| 554 | onpass="All ONOS apps are activated", |
| 555 | onfail="Not all ONOS apps are activated" ) |
| 556 | |
| 557 | return main.TRUE if stepResult else main.FALSE |
| 558 | |
Jon Hall | 4f360bc | 2017-09-07 10:19:52 -0700 | [diff] [blame] | 559 | def processList( self, functions, args ): |
| 560 | if functions is not None: |
| 561 | if isinstance( functions, list ): |
| 562 | i = 0 |
| 563 | for f in functions: |
| 564 | f( *( args[ i ] ) ) if args is not None and args[ i ] is not None else f() |
| 565 | i += 1 |
| 566 | else: |
| 567 | functions( *args ) if args is not None else functions() |
| 568 | |
You Wang | b1665b5 | 2019-02-01 15:49:48 -0800 | [diff] [blame] | 569 | def ONOSSetUp( self, cluster, hasMultiNodeRounds=False, startOnosCli=True, newCell=True, |
You Wang | cdc51fe | 2018-08-12 17:14:56 -0700 | [diff] [blame] | 570 | cellName="temp", cellApps="drivers", appPrefix="org.onosproject.", |
Jon Hall | 3e6edb3 | 2018-08-21 16:20:30 -0700 | [diff] [blame] | 571 | mininetIp="", extraApply=None, applyArgs=None, |
| 572 | extraClean=None, cleanArgs=None, skipPack=False, installMax=False, |
| 573 | atomixClusterSize=None, useSSH=True, killRemoveMax=True, stopAtomix=False, |
| 574 | stopOnos=False, installParallel=True, cellApply=True, |
You Wang | dbb95d6 | 2018-09-05 15:58:08 -0700 | [diff] [blame] | 575 | includeCaseDesc=True, restartCluster=True ): |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 576 | """ |
| 577 | Description: |
| 578 | Initial ONOS setting up of the tests. It will also verify the result of each steps. |
| 579 | The procedures will be: |
| 580 | killing onos |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 581 | creating ( optional ) /applying cell |
| 582 | removing raft logs ( optional ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 583 | uninstalling onos |
| 584 | extra procedure to be applied( optional ) |
| 585 | building onos |
| 586 | installing onos |
| 587 | extra cleanup to be applied ( optional ) |
| 588 | setting up ssh to the onos |
| 589 | checking the onos service |
| 590 | starting onos |
Jon Hall | 3e6edb3 | 2018-08-21 16:20:30 -0700 | [diff] [blame] | 591 | Required Arguments: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 592 | * cluster - the cluster driver that will be used. |
Jon Hall | 3e6edb3 | 2018-08-21 16:20:30 -0700 | [diff] [blame] | 593 | Optional Arguments: |
| 594 | * hasMultiNodeRounds - True if the test is testing different set of nodes |
You Wang | b1665b5 | 2019-02-01 15:49:48 -0800 | [diff] [blame] | 595 | * startOnosCli - True if wish to start onos CLI. |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 596 | * newCell - True for making a new cell and False for not making it. |
| 597 | * cellName - Name of the cell that will be used. |
You Wang | 0d9f2c0 | 2018-08-10 14:56:32 -0700 | [diff] [blame] | 598 | * cellApps - The cell apps string. Will be overwritten by main.apps if it exists |
You Wang | cdc51fe | 2018-08-12 17:14:56 -0700 | [diff] [blame] | 599 | * appPrefix - Prefix of app names. Will use "org.onosproject." by default |
You Wang | a0f6ff6 | 2018-01-11 15:46:30 -0800 | [diff] [blame] | 600 | * mininetIp - Mininet IP address. |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 601 | * extraApply - Function( s ) that will be called before building ONOS. Default to None. |
| 602 | * applyArgs - argument of the functon( s ) of the extraApply. Should be in list. |
| 603 | * extraClean - Function( s ) that will be called after building ONOS. Defaults to None. |
| 604 | * cleanArgs - argument of the functon( s ) of the extraClean. Should be in list. |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 605 | * skipPack - True if wish to skip some packing. |
| 606 | * installMax - True if wish to install onos max number of nodes |
Jon Hall | 3e6edb3 | 2018-08-21 16:20:30 -0700 | [diff] [blame] | 607 | False if wish to install onos of running nodes only |
| 608 | * atomixClusterSize - The number of Atomix nodes in the cluster. |
| 609 | Defaults to None which will be the number of OC# nodes in the cell |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 610 | * useSSH - True for using ssh when creating a cell |
| 611 | * killRemoveMax - True for removing/killing max number of nodes. False for |
Jon Hall | 3e6edb3 | 2018-08-21 16:20:30 -0700 | [diff] [blame] | 612 | removing/killing running nodes only. |
You Wang | f9d95be | 2018-08-01 14:35:37 -0700 | [diff] [blame] | 613 | * stopAtomix - True if wish to stop atomix before killing it. |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 614 | * stopOnos - True if wish to stop onos before killing it. |
You Wang | dbb95d6 | 2018-09-05 15:58:08 -0700 | [diff] [blame] | 615 | * restartCluster - True if wish to kill and restart atomix and onos clusters |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 616 | Returns: |
| 617 | Returns main.TRUE if it everything successfully proceeded. |
| 618 | """ |
| 619 | self.setNumCtrls( hasMultiNodeRounds ) |
Jon Hall | 627b157 | 2020-12-01 12:01:15 -0800 | [diff] [blame] | 620 | if not main.persistentSetup: |
| 621 | if includeCaseDesc: |
| 622 | main.case( "Starting up " + str( cluster.numCtrls ) + |
| 623 | " node(s) ONOS cluster" ) |
| 624 | main.caseExplanation = "Set up ONOS with " + str( cluster.numCtrls ) + \ |
| 625 | " node(s) ONOS cluster" |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 626 | |
Jon Hall | 3e6edb3 | 2018-08-21 16:20:30 -0700 | [diff] [blame] | 627 | main.log.info( "ONOS cluster size = " + str( cluster.numCtrls ) ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 628 | cellResult = main.TRUE |
Devin Lim | 6437c9c | 2018-01-29 17:24:16 -0800 | [diff] [blame] | 629 | if cellApply: |
You Wang | 0d9f2c0 | 2018-08-10 14:56:32 -0700 | [diff] [blame] | 630 | try: |
| 631 | apps = main.apps |
| 632 | except ( NameError, AttributeError ): |
| 633 | apps = cellApps |
| 634 | main.log.debug( "Apps: " + str( apps ) ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 635 | tempOnosIp = [] |
| 636 | for ctrl in cluster.runningNodes: |
| 637 | tempOnosIp.append( ctrl.ipAddress ) |
You Wang | a0f6ff6 | 2018-01-11 15:46:30 -0800 | [diff] [blame] | 638 | if mininetIp == "": |
| 639 | mininetIp = "localhost" |
| 640 | for key, value in main.componentDictionary.items(): |
| 641 | if value['type'] in ['MininetCliDriver', 'RemoteMininetDriver'] and hasattr( main, key ): |
| 642 | mininetIp = getattr( main, key ).ip_address |
| 643 | break |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 644 | cellResult = self.createApplyCell( cluster, newCell, |
You Wang | 0d9f2c0 | 2018-08-10 14:56:32 -0700 | [diff] [blame] | 645 | cellName, apps, |
You Wang | a0f6ff6 | 2018-01-11 15:46:30 -0800 | [diff] [blame] | 646 | mininetIp, useSSH, |
Jon Hall | 3e6edb3 | 2018-08-21 16:20:30 -0700 | [diff] [blame] | 647 | tempOnosIp, installMax, |
| 648 | atomixClusterSize ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 649 | |
Jon Hall | 627b157 | 2020-12-01 12:01:15 -0800 | [diff] [blame] | 650 | if not main.persistentSetup and restartCluster: |
You Wang | dbb95d6 | 2018-09-05 15:58:08 -0700 | [diff] [blame] | 651 | atomixKillResult = self.killingAllAtomix( cluster, killRemoveMax, stopAtomix ) |
| 652 | onosKillResult = self.killingAllOnos( cluster, killRemoveMax, stopOnos ) |
Jon Hall | 3c0114c | 2020-08-11 15:07:42 -0700 | [diff] [blame] | 653 | dockerKillResult = self.killingAllOnosDocker( cluster, killRemoveMax ) |
You Wang | dbb95d6 | 2018-09-05 15:58:08 -0700 | [diff] [blame] | 654 | killResult = atomixKillResult and onosKillResult |
| 655 | else: |
| 656 | killResult = main.TRUE |
You Wang | 4cc6191 | 2018-08-28 10:10:58 -0700 | [diff] [blame] | 657 | |
Jon Hall | 627b157 | 2020-12-01 12:01:15 -0800 | [diff] [blame] | 658 | if not main.persistentSetup and restartCluster: |
You Wang | dbb95d6 | 2018-09-05 15:58:08 -0700 | [diff] [blame] | 659 | atomixUninstallResult = self.uninstallAtomix( cluster, killRemoveMax ) |
| 660 | onosUninstallResult = self.uninstallOnos( cluster, killRemoveMax ) |
| 661 | uninstallResult = atomixUninstallResult and onosUninstallResult |
| 662 | self.processList( extraApply, applyArgs ) |
Devin Lim | 6437c9c | 2018-01-29 17:24:16 -0800 | [diff] [blame] | 663 | |
You Wang | dbb95d6 | 2018-09-05 15:58:08 -0700 | [diff] [blame] | 664 | packageResult = main.TRUE |
| 665 | if not skipPack: |
Jon Hall | 3c0114c | 2020-08-11 15:07:42 -0700 | [diff] [blame] | 666 | if cluster.useDocker: |
| 667 | packageResult = self.buildDocker( cluster ) |
| 668 | else: |
| 669 | packageResult = self.buildOnos( cluster ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 670 | |
Jon Hall | 3c0114c | 2020-08-11 15:07:42 -0700 | [diff] [blame] | 671 | if cluster.useDocker: |
| 672 | installResult = self.startDocker( cluster, installMax, installParallel ) |
| 673 | else: |
| 674 | atomixInstallResult = self.installAtomix( cluster, installParallel ) |
| 675 | onosInstallResult = self.installOnos( cluster, installMax, installParallel ) |
| 676 | installResult = atomixInstallResult and onosInstallResult |
| 677 | |
| 678 | preCLIResult = main.TRUE |
| 679 | if cluster.useDocker: |
| 680 | attachResult = cluster.attachToONOSDocker() |
| 681 | prepareResult = cluster.prepareForCLI() |
| 682 | |
| 683 | preCLIResult = preCLIResult and attachResult and prepareResult |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 684 | |
You Wang | dbb95d6 | 2018-09-05 15:58:08 -0700 | [diff] [blame] | 685 | self.processList( extraClean, cleanArgs ) |
| 686 | secureSshResult = self.setupSsh( cluster ) |
| 687 | else: |
| 688 | packageResult = main.TRUE |
| 689 | uninstallResult = main.TRUE |
| 690 | installResult = main.TRUE |
| 691 | secureSshResult = main.TRUE |
Jon Hall | 3c0114c | 2020-08-11 15:07:42 -0700 | [diff] [blame] | 692 | preCLIResult = main.TRUE |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 693 | |
Jon Hall | 3c0114c | 2020-08-11 15:07:42 -0700 | [diff] [blame] | 694 | onosServiceResult = main.TRUE |
| 695 | if not cluster.useDocker: |
| 696 | onosServiceResult = self.checkOnosService( cluster ) |
Jon Hall | 627b157 | 2020-12-01 12:01:15 -0800 | [diff] [blame] | 697 | elif main.persistentSetup: |
| 698 | for ctrl in cluster.getRunningNodes(): |
| 699 | ctrl.inDocker = True |
Jon Hall | 06fd0df | 2021-01-25 15:50:06 -0800 | [diff] [blame] | 700 | ctrl.CLI.inDocker = True |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 701 | |
You Wang | 4cc6191 | 2018-08-28 10:10:58 -0700 | [diff] [blame] | 702 | onosCliResult = main.TRUE |
You Wang | b1665b5 | 2019-02-01 15:49:48 -0800 | [diff] [blame] | 703 | if startOnosCli: |
Jon Hall | ca31989 | 2017-06-15 15:25:22 -0700 | [diff] [blame] | 704 | onosCliResult = self.startOnosClis( cluster ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 705 | |
You Wang | 0d9f2c0 | 2018-08-10 14:56:32 -0700 | [diff] [blame] | 706 | onosNodesResult = self.checkOnosNodes( cluster ) |
| 707 | |
Jon Hall | 3957026 | 2020-11-17 12:18:19 -0800 | [diff] [blame] | 708 | externalAppsResult = main.TRUE |
Jon Hall | 627b157 | 2020-12-01 12:01:15 -0800 | [diff] [blame] | 709 | if not main.persistentSetup and main.params.get( 'EXTERNAL_APPS' ): |
Jon Hall | 3957026 | 2020-11-17 12:18:19 -0800 | [diff] [blame] | 710 | node = main.Cluster.controllers[0] |
| 711 | for app, url in main.params[ 'EXTERNAL_APPS' ].iteritems(): |
| 712 | path, fileName = os.path.split( url ) |
| 713 | main.ONOSbench.onosApp( node.ipAddress, "reinstall!", fileName, appName=app, user=node.karafUser, password=node.karafPass ) |
| 714 | |
| 715 | |
You Wang | 0d9f2c0 | 2018-08-10 14:56:32 -0700 | [diff] [blame] | 716 | onosAppsResult = main.TRUE |
Jon Hall | 627b157 | 2020-12-01 12:01:15 -0800 | [diff] [blame] | 717 | if not main.persistentSetup and cellApply: |
You Wang | 0d9f2c0 | 2018-08-10 14:56:32 -0700 | [diff] [blame] | 718 | if apps: |
Jon Hall | 3957026 | 2020-11-17 12:18:19 -0800 | [diff] [blame] | 719 | newApps = [] |
| 720 | appNames = apps.split( ',' ) |
Jon Hall | 3c0114c | 2020-08-11 15:07:42 -0700 | [diff] [blame] | 721 | if cluster.useDocker: |
| 722 | node = main.Cluster.active( 0 ) |
Jon Hall | 3957026 | 2020-11-17 12:18:19 -0800 | [diff] [blame] | 723 | for app in appNames: |
| 724 | appName = app if "org." in app else appPrefix + app |
| 725 | node.activateApp( appName ) |
| 726 | newApps.append( appName ) |
Jon Hall | 3c0114c | 2020-08-11 15:07:42 -0700 | [diff] [blame] | 727 | |
Jon Hall | 3957026 | 2020-11-17 12:18:19 -0800 | [diff] [blame] | 728 | onosAppsResult = self.checkOnosApps( cluster, newApps ) |
You Wang | 0d9f2c0 | 2018-08-10 14:56:32 -0700 | [diff] [blame] | 729 | else: |
| 730 | main.log.warn( "No apps were specified to be checked after startup" ) |
| 731 | |
You Wang | f9d95be | 2018-08-01 14:35:37 -0700 | [diff] [blame] | 732 | return killResult and cellResult and packageResult and uninstallResult and \ |
You Wang | 0d9f2c0 | 2018-08-10 14:56:32 -0700 | [diff] [blame] | 733 | installResult and secureSshResult and onosServiceResult and onosCliResult and \ |
Jon Hall | 3c0114c | 2020-08-11 15:07:42 -0700 | [diff] [blame] | 734 | onosNodesResult and onosAppsResult and preCLIResult |