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