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 |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 22 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 23 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 24 | class ONOSSetup: |
| 25 | main = None |
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 | 4f360bc | 2017-09-07 10:19:52 -0700 | [diff] [blame] | 29 | |
Devin Lim | 0c972b7 | 2018-02-08 14:53:59 -0800 | [diff] [blame] | 30 | def envSetupDescription( self, includeCaseDesc=True ): |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 31 | """ |
| 32 | Introduction part of the test. It will initialize some basic vairables. |
| 33 | """ |
Devin Lim | 0c972b7 | 2018-02-08 14:53:59 -0800 | [diff] [blame] | 34 | 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" |
| 38 | main.step("Constructing test variables") |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 39 | try: |
| 40 | from tests.dependencies.Cluster import Cluster |
| 41 | except ImportError: |
| 42 | main.log.error( "Cluster not found. exiting the test" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 43 | main.cleanAndExit() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 44 | try: |
| 45 | main.Cluster |
| 46 | except ( NameError, AttributeError ): |
| 47 | main.Cluster = Cluster( main.ONOScell.nodes ) |
| 48 | main.ONOSbench = main.Cluster.controllers[ 0 ].Bench |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 49 | main.testOnDirectory = re.sub( "(/tests)$", "", main.testDir ) |
| 50 | |
Devin Lim | 0c972b7 | 2018-02-08 14:53:59 -0800 | [diff] [blame] | 51 | def gitPulling( self, includeCaseDesc=True ): |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 52 | """ |
| 53 | it will do git checkout or pull if they are enabled from the params file. |
| 54 | """ |
Devin Lim | 0c972b7 | 2018-02-08 14:53:59 -0800 | [diff] [blame] | 55 | |
| 56 | if includeCaseDesc: |
| 57 | main.case( "Pull onos branch and build onos on Teststation." ) |
| 58 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 59 | 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 Hall | 4f360bc | 2017-09-07 10:19:52 -0700 | [diff] [blame] | 68 | if not stepResult: |
| 69 | main.cleanAndExit() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 70 | |
| 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 Hall | 4f360bc | 2017-09-07 10:19:52 -0700 | [diff] [blame] | 77 | if not stepResult: |
| 78 | main.cleanAndExit() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 79 | |
| 80 | else: |
| 81 | main.log.info( "Skipped git checkout and pull as they are disabled in params file" ) |
| 82 | |
Devin Lim | 0c972b7 | 2018-02-08 14:53:59 -0800 | [diff] [blame] | 83 | def envSetup( self, includeGitPull=True, includeCaseDesc=True ): |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 84 | """ |
| 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 Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 92 | if includeGitPull: |
Devin Lim | 0c972b7 | 2018-02-08 14:53:59 -0800 | [diff] [blame] | 93 | self.gitPulling( includeCaseDesc ) |
Jon Hall | ca31989 | 2017-06-15 15:25:22 -0700 | [diff] [blame] | 94 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 95 | try: |
| 96 | from tests.dependencies.Cluster import Cluster |
| 97 | except ImportError: |
| 98 | main.log.error( "Cluster not found. exiting the test" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 99 | main.cleanAndExit() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 100 | try: |
| 101 | main.Cluster |
| 102 | except ( NameError, AttributeError ): |
| 103 | main.Cluster = Cluster( main.ONOScell.nodes ) |
| 104 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 105 | main.cellData = {} # For creating cell file |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 106 | |
Jon Hall | ca31989 | 2017-06-15 15:25:22 -0700 | [diff] [blame] | 107 | return main.TRUE |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 108 | |
Jon Hall | ca31989 | 2017-06-15 15:25:22 -0700 | [diff] [blame] | 109 | def envSetupException( self, e ): |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 110 | """ |
| 111 | Description: |
| 112 | handles the exception that might occur from the environment setup. |
| 113 | Required: |
| 114 | * includeGitPull - exceeption code e. |
| 115 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 116 | main.log.exception( e ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 117 | main.cleanAndExit() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 118 | |
Jon Hall | ca31989 | 2017-06-15 15:25:22 -0700 | [diff] [blame] | 119 | def evnSetupConclusion( self, stepResult ): |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 120 | """ |
| 121 | Description: |
| 122 | compare the result of the envSetup of the test. |
| 123 | Required: |
| 124 | * stepResult - Result of the envSetup. |
| 125 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 126 | 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 Ronquillo | 7f8fb57 | 2017-11-14 08:28:41 -0800 | [diff] [blame] | 132 | url = self.generateGraphURL() |
| 133 | main.log.wiki( url ) |
| 134 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 135 | main.commit = main.ONOSbench.getVersion( report=True ) |
| 136 | |
Jeremy Ronquillo | 7f8fb57 | 2017-11-14 08:28:41 -0800 | [diff] [blame] | 137 | 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 Lim | d1fb8e9 | 2018-02-28 16:29:33 -0800 | [diff] [blame^] | 150 | '<img src="https://jenkins.onosproject.org/view/QA/job/postjob-' + \ |
Jeremy Ronquillo | 7f8fb57 | 2017-11-14 08:28:41 -0800 | [diff] [blame] | 151 | 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 Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 169 | 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 Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 177 | 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 Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 184 | main.Cluster.setRunningNode( int( main.scale.pop( 0 ) ) ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 185 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 186 | def killingAllOnos( self, cluster, killRemoveMax, stopOnos ): |
| 187 | """ |
| 188 | Description: |
| 189 | killing the onos. 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 |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 194 | only running nodes ( False ) or max number of nodes ( True ). |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 195 | * stopOnos - If wish to stop onos 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 ONOS processes" ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 201 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 202 | return cluster.kill( killRemoveMax, stopOnos ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 203 | |
You Wang | 09b596b | 2018-01-10 10:42:38 -0800 | [diff] [blame] | 204 | def createApplyCell( self, cluster, newCell, cellName, cellApps, |
You Wang | a0f6ff6 | 2018-01-11 15:46:30 -0800 | [diff] [blame] | 205 | mininetIp, useSSH, ips, installMax=False ): |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 206 | """ |
| 207 | Description: |
| 208 | create new cell ( optional ) and apply it. It will also verify the |
| 209 | cell. |
| 210 | Required: |
| 211 | * cluster - the cluster driver that will be used. |
| 212 | * newCell - True for making a new cell and False for not making it. |
| 213 | * cellName - The name of the cell. |
You Wang | 09b596b | 2018-01-10 10:42:38 -0800 | [diff] [blame] | 214 | * cellApps - The onos apps string. |
You Wang | a0f6ff6 | 2018-01-11 15:46:30 -0800 | [diff] [blame] | 215 | * mininetIp - Mininet IP address. |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 216 | * useSSH - True for using ssh when creating a cell |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 217 | * ips - ip( s ) of the node( s ). |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 218 | Returns: |
| 219 | Returns main.TRUE if it successfully executed. |
| 220 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 221 | if newCell: |
You Wang | a0f6ff6 | 2018-01-11 15:46:30 -0800 | [diff] [blame] | 222 | cluster.createCell( cellName, cellApps, mininetIp, useSSH, ips ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 223 | main.step( "Apply cell to environment" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 224 | stepResult = cluster.applyCell( cellName ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 225 | utilities.assert_equals( expect=main.TRUE, |
| 226 | actual=stepResult, |
| 227 | onpass="Successfully applied cell to " + |
| 228 | "environment", |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 229 | onfail="Failed to apply cell to environment" ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 230 | return stepResult |
| 231 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 232 | def uninstallOnos( self, cluster, uninstallMax ): |
| 233 | """ |
| 234 | Description: |
| 235 | uninstalling onos and verify the result. |
| 236 | Required: |
| 237 | * cluster - a cluster driver that will be used. |
| 238 | * uninstallMax - True for uninstalling max number of nodes |
| 239 | False for uninstalling the current running nodes. |
| 240 | Returns: |
| 241 | Returns main.TRUE if it successfully uninstalled. |
| 242 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 243 | main.step( "Uninstalling ONOS package" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 244 | onosUninstallResult = cluster.uninstall( uninstallMax ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 245 | utilities.assert_equals( expect=main.TRUE, |
| 246 | actual=onosUninstallResult, |
| 247 | onpass="Successfully uninstalled ONOS package", |
| 248 | onfail="Failed to uninstall ONOS package" ) |
| 249 | return onosUninstallResult |
| 250 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 251 | def buildOnos( self, cluster ): |
| 252 | """ |
| 253 | Description: |
| 254 | build the onos using buck build onos and verify the result |
| 255 | Required: |
| 256 | * cluster - the cluster driver that will be used. |
| 257 | Returns: |
| 258 | Returns main.TRUE if it successfully built. |
| 259 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 260 | main.step( "Creating ONOS package" ) |
| 261 | packageResult = main.ONOSbench.buckBuild() |
| 262 | utilities.assert_equals( expect=main.TRUE, |
| 263 | actual=packageResult, |
| 264 | onpass="Successfully created ONOS package", |
| 265 | onfail="Failed to create ONOS package" ) |
| 266 | return packageResult |
| 267 | |
Devin Lim | e9f0ccf | 2017-08-11 17:25:12 -0700 | [diff] [blame] | 268 | def installOnos( self, cluster, installMax, parallel=True ): |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 269 | """ |
| 270 | Description: |
| 271 | Installing onos and verify the result |
| 272 | Required: |
| 273 | * cluster - the cluster driver that will be used. |
| 274 | * installMax - True for installing max number of nodes |
| 275 | False for installing current running nodes only. |
| 276 | Returns: |
| 277 | Returns main.TRUE if it successfully installed |
| 278 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 279 | main.step( "Installing ONOS package" ) |
| 280 | onosInstallResult = main.TRUE |
| 281 | |
Devin Lim | e9f0ccf | 2017-08-11 17:25:12 -0700 | [diff] [blame] | 282 | cluster.install( installMax, parallel ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 283 | utilities.assert_equals( expect=main.TRUE, |
| 284 | actual=onosInstallResult, |
| 285 | onpass="Successfully installed ONOS package", |
| 286 | onfail="Failed to install ONOS package" ) |
| 287 | if not onosInstallResult: |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 288 | main.cleanAndExit() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 289 | return onosInstallResult |
| 290 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 291 | def setupSsh( self, cluster ): |
| 292 | """ |
| 293 | Description: |
| 294 | set up ssh to the onos and verify the result |
| 295 | Required: |
| 296 | * cluster - the cluster driver that will be used. |
| 297 | Returns: |
| 298 | Returns main.TRUE if it successfully setup the ssh to |
| 299 | the onos. |
| 300 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 301 | main.step( "Set up ONOS secure SSH" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 302 | secureSshResult = cluster.ssh() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 303 | utilities.assert_equals( expect=main.TRUE, |
| 304 | actual=secureSshResult, |
| 305 | onpass="Test step PASS", |
| 306 | onfail="Test step FAIL" ) |
| 307 | return secureSshResult |
| 308 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 309 | def checkOnosService( self, cluster ): |
| 310 | """ |
| 311 | Description: |
| 312 | Checking if the onos service is up and verify the result |
| 313 | Required: |
| 314 | * cluster - the cluster driver that will be used. |
| 315 | Returns: |
| 316 | Returns main.TRUE if it successfully checked |
| 317 | """ |
| 318 | main.step( "Checking ONOS service" ) |
| 319 | stepResult = cluster.checkService() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 320 | utilities.assert_equals( expect=main.TRUE, |
| 321 | actual=stepResult, |
| 322 | onpass="ONOS service is ready on all nodes", |
| 323 | onfail="ONOS service did not start properly on all nodes" ) |
| 324 | return stepResult |
| 325 | |
Jon Hall | ca31989 | 2017-06-15 15:25:22 -0700 | [diff] [blame] | 326 | def startOnosClis( self, cluster ): |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 327 | """ |
| 328 | Description: |
| 329 | starting Onos using onosCli driver and verify the result |
| 330 | Required: |
| 331 | * cluster - the cluster driver that will be used. |
| 332 | Returns: |
| 333 | Returns main.TRUE if it successfully started. It will exit |
| 334 | the test if not started properly. |
| 335 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 336 | main.step( "Starting ONOS CLI sessions" ) |
Jon Hall | ca31989 | 2017-06-15 15:25:22 -0700 | [diff] [blame] | 337 | startCliResult = cluster.startCLIs() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 338 | if not startCliResult: |
| 339 | main.log.info( "ONOS CLI did not start up properly" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 340 | main.cleanAndExit() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 341 | else: |
| 342 | main.log.info( "Successful CLI startup" ) |
| 343 | utilities.assert_equals( expect=main.TRUE, |
| 344 | actual=startCliResult, |
| 345 | onpass="Successfully start ONOS cli", |
| 346 | onfail="Failed to start ONOS cli" ) |
| 347 | return startCliResult |
| 348 | |
Jon Hall | 4f360bc | 2017-09-07 10:19:52 -0700 | [diff] [blame] | 349 | def processList( self, functions, args ): |
| 350 | if functions is not None: |
| 351 | if isinstance( functions, list ): |
| 352 | i = 0 |
| 353 | for f in functions: |
| 354 | f( *( args[ i ] ) ) if args is not None and args[ i ] is not None else f() |
| 355 | i += 1 |
| 356 | else: |
| 357 | functions( *args ) if args is not None else functions() |
| 358 | |
You Wang | a0f6ff6 | 2018-01-11 15:46:30 -0800 | [diff] [blame] | 359 | def ONOSSetUp( self, cluster, hasMultiNodeRounds=False, startOnos=True, newCell=True, |
| 360 | cellName="temp", cellApps="drivers", mininetIp="", removeLog=False, extraApply=None, applyArgs=None, |
You Wang | 09b596b | 2018-01-10 10:42:38 -0800 | [diff] [blame] | 361 | extraClean=None, cleanArgs=None, skipPack=False, installMax=False, useSSH=True, |
Devin Lim | 0c972b7 | 2018-02-08 14:53:59 -0800 | [diff] [blame] | 362 | killRemoveMax=True, stopOnos=False, installParallel=True, cellApply=True, includeCaseDesc=True ): |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 363 | """ |
| 364 | Description: |
| 365 | Initial ONOS setting up of the tests. It will also verify the result of each steps. |
| 366 | The procedures will be: |
| 367 | killing onos |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 368 | creating ( optional ) /applying cell |
| 369 | removing raft logs ( optional ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 370 | uninstalling onos |
| 371 | extra procedure to be applied( optional ) |
| 372 | building onos |
| 373 | installing onos |
| 374 | extra cleanup to be applied ( optional ) |
| 375 | setting up ssh to the onos |
| 376 | checking the onos service |
| 377 | starting onos |
| 378 | Required: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 379 | * cluster - the cluster driver that will be used. |
| 380 | * hasMultiNodeRouds - True if the test is testing different set of nodes |
| 381 | * startOnos - True if wish to start onos. |
| 382 | * newCell - True for making a new cell and False for not making it. |
| 383 | * cellName - Name of the cell that will be used. |
You Wang | 09b596b | 2018-01-10 10:42:38 -0800 | [diff] [blame] | 384 | * cellApps - The cell apps string. |
You Wang | a0f6ff6 | 2018-01-11 15:46:30 -0800 | [diff] [blame] | 385 | * mininetIp - Mininet IP address. |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 386 | * removeLog - True if wish to remove raft logs |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 387 | * extraApply - Function( s ) that will be called before building ONOS. Default to None. |
| 388 | * applyArgs - argument of the functon( s ) of the extraApply. Should be in list. |
| 389 | * extraClean - Function( s ) that will be called after building ONOS. Defaults to None. |
| 390 | * 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] | 391 | * skipPack - True if wish to skip some packing. |
| 392 | * installMax - True if wish to install onos max number of nodes |
| 393 | False if wish to install onos of running nodes only |
| 394 | * useSSH - True for using ssh when creating a cell |
| 395 | * killRemoveMax - True for removing/killing max number of nodes. False for |
| 396 | removing/killing running nodes only. |
| 397 | * stopOnos - True if wish to stop onos before killing it. |
| 398 | Returns: |
| 399 | Returns main.TRUE if it everything successfully proceeded. |
| 400 | """ |
| 401 | self.setNumCtrls( hasMultiNodeRounds ) |
Devin Lim | 0c972b7 | 2018-02-08 14:53:59 -0800 | [diff] [blame] | 402 | if includeCaseDesc: |
| 403 | main.case( "Starting up " + str( cluster.numCtrls ) + |
| 404 | " node(s) ONOS cluster" ) |
| 405 | main.caseExplanation = "Set up ONOS with " + str( cluster.numCtrls ) + \ |
| 406 | " node(s) ONOS cluster" |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 407 | killResult = self.killingAllOnos( cluster, killRemoveMax, stopOnos ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 408 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 409 | main.log.info( "NODE COUNT = " + str( cluster.numCtrls ) ) |
| 410 | cellResult = main.TRUE |
| 411 | packageResult = main.TRUE |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 412 | onosCliResult = main.TRUE |
Devin Lim | 6437c9c | 2018-01-29 17:24:16 -0800 | [diff] [blame] | 413 | if cellApply: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 414 | tempOnosIp = [] |
| 415 | for ctrl in cluster.runningNodes: |
| 416 | tempOnosIp.append( ctrl.ipAddress ) |
You Wang | a0f6ff6 | 2018-01-11 15:46:30 -0800 | [diff] [blame] | 417 | if mininetIp == "": |
| 418 | mininetIp = "localhost" |
| 419 | for key, value in main.componentDictionary.items(): |
| 420 | if value['type'] in ['MininetCliDriver', 'RemoteMininetDriver'] and hasattr( main, key ): |
| 421 | mininetIp = getattr( main, key ).ip_address |
| 422 | break |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 423 | cellResult = self.createApplyCell( cluster, newCell, |
You Wang | 09b596b | 2018-01-10 10:42:38 -0800 | [diff] [blame] | 424 | cellName, cellApps, |
You Wang | a0f6ff6 | 2018-01-11 15:46:30 -0800 | [diff] [blame] | 425 | mininetIp, useSSH, |
You Wang | 09b596b | 2018-01-10 10:42:38 -0800 | [diff] [blame] | 426 | tempOnosIp, installMax ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 427 | |
Devin Lim | 6437c9c | 2018-01-29 17:24:16 -0800 | [diff] [blame] | 428 | if removeLog: |
| 429 | main.log.info("Removing raft logs") |
| 430 | main.ONOSbench.onosRemoveRaftLogs() |
| 431 | onosUninstallResult = self.uninstallOnos( cluster, killRemoveMax ) |
| 432 | self.processList( extraApply, applyArgs ) |
| 433 | |
| 434 | if not skipPack: |
| 435 | packageResult = self.buildOnos(cluster) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 436 | |
Devin Lim | e9f0ccf | 2017-08-11 17:25:12 -0700 | [diff] [blame] | 437 | onosInstallResult = self.installOnos( cluster, installMax, installParallel ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 438 | |
Jon Hall | 4f360bc | 2017-09-07 10:19:52 -0700 | [diff] [blame] | 439 | self.processList( extraClean, cleanArgs ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 440 | secureSshResult = self.setupSsh( cluster ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 441 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 442 | onosServiceResult = self.checkOnosService( cluster ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 443 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 444 | if startOnos: |
Jon Hall | ca31989 | 2017-06-15 15:25:22 -0700 | [diff] [blame] | 445 | onosCliResult = self.startOnosClis( cluster ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 446 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 447 | return killResult and cellResult and packageResult and onosUninstallResult and \ |
Jon Hall | 4f360bc | 2017-09-07 10:19:52 -0700 | [diff] [blame] | 448 | onosInstallResult and secureSshResult and onosServiceResult and onosCliResult |