Flavio Castro | f7faa42 | 2016-06-14 11:02:09 -0700 | [diff] [blame] | 1 | # This test should always succeed. it runs cases 1,2,3,4 |
| 2 | #CASE1: Get and Build ONOS |
| 3 | #CASE2: Package and Install ONOS |
| 4 | #CASE3: Start Mininet and check flows |
| 5 | #CASE4: Ping all |
| 6 | #CASE5: Link Failure |
| 7 | #CASE6: Switch Failure |
| 8 | #CASE7: ONOS Failure |
| 9 | #CASE8: CLUSTER Failure |
| 10 | #CASE10: Logging |
| 11 | |
| 12 | class SRSanity: |
| 13 | |
| 14 | def __init__( self ): |
| 15 | self.default = '' |
| 16 | |
| 17 | def CASE1( self, main ): |
| 18 | import time |
| 19 | import os |
| 20 | import imp |
| 21 | import re |
| 22 | |
| 23 | """ |
| 24 | - Construct tests variables |
| 25 | - GIT ( optional ) |
| 26 | - Checkout ONOS master branch |
| 27 | - Pull latest ONOS code |
| 28 | - Building ONOS ( optional ) |
| 29 | - Install ONOS package |
| 30 | - Build ONOS package |
| 31 | """ |
| 32 | |
| 33 | main.case( "Constructing test variables and building ONOS" ) |
| 34 | main.step( "Constructing test variables" ) |
| 35 | stepResult = main.FALSE |
| 36 | |
| 37 | # Test variables |
| 38 | main.cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 39 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
| 40 | main.diff = [] |
| 41 | main.diff.extend(( main.params[ 'ENV' ][ 'diffApps' ] ).split(";")) |
| 42 | main.diff=main.diff*2 |
| 43 | gitBranch = main.params[ 'GIT' ][ 'branch' ] |
| 44 | main.path = os.path.dirname( main.testFile ) |
| 45 | main.dependencyPath = main.path +"/../dependencies/" |
| 46 | main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ] |
| 47 | main.json = ["2x2"]*4 |
| 48 | main.args = [" "]*4 |
| 49 | main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," ) |
| 50 | main.maxNodes = int( main.params[ 'SCALE' ][ 'max' ] ) |
| 51 | main.ONOSport = main.params[ 'CTRL' ][ 'port' ] |
| 52 | wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
| 53 | main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] ) |
| 54 | gitPull = main.params[ 'GIT' ][ 'pull' ] |
| 55 | main.cellData = {} # for creating cell file |
| 56 | main.CLIs = [] |
| 57 | main.ONOSip = [] |
| 58 | |
| 59 | # Assigning ONOS cli handles to a list |
| 60 | for i in range( 1, main.maxNodes + 1 ): |
| 61 | main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) ) |
| 62 | main.ONOSip.append( main.CLIs[i-1].ip_address ) |
| 63 | # -- INIT SECTION, ONLY RUNS ONCE -- # |
| 64 | main.startUp = imp.load_source( wrapperFile1, |
| 65 | main.dependencyPath + |
| 66 | wrapperFile1 + |
| 67 | ".py" ) |
| 68 | |
| 69 | copyResult1 = main.ONOSbench.scp( main.Mininet1, |
| 70 | main.dependencyPath + |
| 71 | main.topology, |
| 72 | main.Mininet1.home, |
| 73 | direction="to" ) |
| 74 | if main.CLIs: |
| 75 | stepResult = main.TRUE |
| 76 | else: |
| 77 | main.log.error( "Did not properly created list of ONOS CLI handle" ) |
| 78 | stepResult = main.FALSE |
| 79 | |
| 80 | utilities.assert_equals( expect=main.TRUE, |
| 81 | actual=stepResult, |
| 82 | onpass="Successfully construct " + |
| 83 | "test variables ", |
| 84 | onfail="Failed to construct test variables" ) |
| 85 | |
| 86 | if gitPull == 'True': |
| 87 | main.step( "Building ONOS in " + gitBranch + " branch" ) |
| 88 | onosBuildResult = main.startUp.onosBuild( main, gitBranch ) |
| 89 | stepResult = onosBuildResult |
| 90 | utilities.assert_equals( expect=main.TRUE, |
| 91 | actual=stepResult, |
| 92 | onpass="Successfully compiled " + |
| 93 | "latest ONOS", |
| 94 | onfail="Failed to compile " + |
| 95 | "latest ONOS" ) |
| 96 | else: |
| 97 | main.log.warn( "Did not pull new code so skipping mvn " + |
| 98 | "clean install" ) |
| 99 | main.numCtrls = int( main.scale[ 0 ] ) |
| 100 | |
| 101 | def CASE2( self, main ): |
| 102 | """ |
| 103 | - Set up cell |
| 104 | - Create cell file |
| 105 | - Set cell file |
| 106 | - Verify cell file |
| 107 | - Kill ONOS process |
| 108 | - Uninstall ONOS cluster |
| 109 | - Verify ONOS start up |
| 110 | - Install ONOS cluster |
| 111 | - Connect to cli |
| 112 | """ |
| 113 | |
| 114 | # main.scale[ 0 ] determines the current number of ONOS controller |
| 115 | main.numCtrls = int( main.scale[ 0 ] ) |
| 116 | main.scale.remove( main.scale[ 0 ] ) |
| 117 | apps=main.apps |
| 118 | if main.diff: |
| 119 | apps = main.apps+","+main.diff.pop(0) |
| 120 | else: main.log.error( "App list is empty" ) |
| 121 | main.case( "Package and start ONOS using apps:" + apps) |
| 122 | |
| 123 | print "NODE COUNT = ", main.numCtrls |
| 124 | print main.ONOSip |
| 125 | tempOnosIp = [] |
| 126 | for i in range( main.numCtrls ): |
| 127 | tempOnosIp.append( main.ONOSip[i] ) |
| 128 | |
| 129 | onosUser = main.params[ 'ENV' ][ 'cellUser' ] |
| 130 | main.step("Create and Apply cell file") |
| 131 | main.ONOSbench.createCellFile( main.ONOSbench.ip_address, |
| 132 | "temp", |
| 133 | main.Mininet1.ip_address, |
| 134 | apps, |
| 135 | tempOnosIp, |
| 136 | onosUser ) |
| 137 | |
| 138 | cellResult = main.ONOSbench.setCell( "temp" ) |
| 139 | verifyResult = main.ONOSbench.verifyCell() |
| 140 | stepResult = cellResult and verifyResult |
| 141 | utilities.assert_equals( expect=main.TRUE, |
| 142 | actual=stepResult, |
| 143 | onpass="Successfully applied cell to " + \ |
| 144 | "environment", |
| 145 | onfail="Failed to apply cell to environment " ) |
| 146 | #kill off all onos processes |
| 147 | main.log.info( "Safety check, killing all ONOS processes" + |
| 148 | " before initiating environment setup" ) |
| 149 | |
| 150 | for i in range( main.maxNodes ): |
| 151 | main.ONOSbench.onosDie( main.ONOSip[ i ] ) |
| 152 | |
| 153 | main.step( "Create and Install ONOS package" ) |
| 154 | main.jsonFile=main.json.pop(0) |
| 155 | main.ONOSbench.handle.sendline( "cp "+main.dependencyPath+"/"+main.jsonFile+".json ~/onos/tools/package/config/network-cfg.json") |
| 156 | packageResult = main.ONOSbench.onosPackage() |
| 157 | |
| 158 | onosInstallResult = main.TRUE |
| 159 | for i in range( main.numCtrls ): |
| 160 | onosInstallResult = onosInstallResult and \ |
| 161 | main.ONOSbench.onosInstall( node=main.ONOSip[ i ] ) |
| 162 | stepResult = onosInstallResult |
| 163 | utilities.assert_equals( expect=main.TRUE, |
| 164 | actual=stepResult, |
| 165 | onpass="Successfully installed ONOS package", |
| 166 | onfail="Failed to install ONOS package" ) |
| 167 | |
| 168 | main.step( "Starting ONOS service" ) |
| 169 | stopResult = main.TRUE |
| 170 | startResult = main.TRUE |
| 171 | onosIsUp = main.TRUE |
| 172 | |
| 173 | for i in range( main.numCtrls ): |
| 174 | onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] ) |
| 175 | if onosIsUp == main.TRUE: |
| 176 | main.log.report( "ONOS instance is up and ready" ) |
| 177 | else: |
| 178 | main.log.report( "ONOS instance may not be up, stop and " + |
| 179 | "start ONOS again " ) |
| 180 | for i in range( main.numCtrls ): |
| 181 | stopResult = stopResult and \ |
| 182 | main.ONOSbench.onosStop( main.ONOSip[ i ] ) |
| 183 | for i in range( main.numCtrls ): |
| 184 | startResult = startResult and \ |
| 185 | main.ONOSbench.onosStart( main.ONOSip[ i ] ) |
| 186 | stepResult = onosIsUp and stopResult and startResult |
| 187 | |
| 188 | utilities.assert_equals( expect=main.TRUE, |
| 189 | actual=stepResult, |
| 190 | onpass="ONOS service is ready", |
| 191 | onfail="ONOS service did not start properly" ) |
| 192 | main.step( "Checking if ONOS CLI is ready" ) |
| 193 | main.CLIs[0].startCellCli() |
| 194 | cliResult = main.CLIs[0].startOnosCli( main.ONOSip[ 0 ], |
| 195 | commandlineTimeout=60, onosStartTimeout=100 ) |
| 196 | utilities.assert_equals( expect=main.TRUE, |
| 197 | actual=cliResult, |
| 198 | onpass="ONOS CLI is ready", |
| 199 | onfail="ONOS CLI is not ready" ) |
| 200 | for i in range( 10 ): |
| 201 | ready = True |
| 202 | output = main.CLIs[0].summary() |
| 203 | if not output: |
| 204 | ready = False |
| 205 | if ready: |
| 206 | break |
| 207 | time.sleep( 10 ) |
| 208 | utilities.assert_equals( expect=True, actual=ready, |
| 209 | onpass="ONOS summary command succeded", |
| 210 | onfail="ONOS summary command failed" ) |
| 211 | |
| 212 | if not ready: |
| 213 | main.log.error( "ONOS startup failed!" ) |
| 214 | main.cleanup() |
| 215 | main.exit() |
| 216 | |
| 217 | def CASE3( self, main ): |
| 218 | """ |
| 219 | Start mininet |
| 220 | """ |
| 221 | main.case( "Start Leaf-Spine "+main.jsonFile+" Mininet Topology" ) |
| 222 | main.log.report( "Start Mininet topology" ) |
| 223 | |
| 224 | main.step( "Starting Mininet Topology" ) |
| 225 | args,topo=" "," " |
| 226 | if main.args: |
| 227 | args = "--onos %d %s" % (main.numCtrls, main.args.pop(0)) |
| 228 | else: main.log.error( "Argument list is empty" ) |
| 229 | |
| 230 | topoResult = main.Mininet1.startNet( topoFile= main.dependencyPath + main.topology, args=args ) |
| 231 | stepResult = topoResult |
| 232 | utilities.assert_equals( expect=main.TRUE, |
| 233 | actual=stepResult, |
| 234 | onpass="Successfully loaded topology", |
| 235 | onfail="Failed to load topology" ) |
| 236 | # Exit if topology did not load properly |
| 237 | if not topoResult: |
| 238 | main.cleanup() |
| 239 | main.exit() |
| 240 | main.step(" Check whether the flow count is bigger than 116" ) |
| 241 | count = utilities.retry( main.CLIs[0].checkFlowCount, |
| 242 | main.FALSE, |
| 243 | kwargs={'min':116}, |
| 244 | attempts=10, |
| 245 | sleep=10 ) |
| 246 | utilities.assertEquals( \ |
| 247 | expect=True, |
| 248 | actual=(count>0), |
| 249 | onpass="Flow count looks correct: "+str(count), |
| 250 | onfail="Flow count looks wrong: "+str(count) ) |
| 251 | |
| 252 | main.step( "Check whether all flow status are ADDED" ) |
| 253 | flowCheck = utilities.retry( main.CLIs[0].checkFlowsState, |
| 254 | main.FALSE, |
| 255 | kwargs={'isPENDING':False}, |
| 256 | attempts=10, |
| 257 | sleep=10) |
| 258 | utilities.assertEquals( \ |
| 259 | expect=main.TRUE, |
| 260 | actual=flowCheck, |
| 261 | onpass="Flow status is correct!", |
| 262 | onfail="Flow status is wrong!" ) |
| 263 | main.ONOSbench.dumpFlows( main.ONOSip[0], |
| 264 | main.logdir, "flowsBefore" + main.jsonFile) |
| 265 | main.ONOSbench.dumpGroups( main.ONOSip[0], |
| 266 | main.logdir, "groupsBefore" + main.jsonFile) |
| 267 | main.count=1 |
| 268 | |
| 269 | def CASE4( self, main ): |
| 270 | main.case( "Check full connectivity" ) |
| 271 | main.log.report( "Check full connectivity" ) |
| 272 | |
| 273 | main.step("Check full connectivity"+str(main.count)) |
| 274 | pa = main.Mininet1.pingall() |
| 275 | utilities.assert_equals( expect=main.TRUE, actual=pa, |
| 276 | onpass="Full connectivity successfully tested", |
| 277 | onfail="Full connectivity failed" ) |
| 278 | main.ONOSbench.dumpFlows( main.ONOSip[0], |
| 279 | main.logdir, "flowsAfter" + str(main.count) + main.jsonFile) |
| 280 | main.ONOSbench.dumpGroups( main.ONOSip[0], |
| 281 | main.logdir, "groupsAfter" + str(main.count) + main.jsonFile) |
| 282 | |
| 283 | def CASE5( self, main ): |
| 284 | """ |
| 285 | Link spine101-leaf2 down |
| 286 | Pingall |
| 287 | Link spine101-leaf2 up |
| 288 | Pingall |
| 289 | """ |
| 290 | import time |
| 291 | assert main.numCtrls, "main.numCtrls not defined" |
| 292 | assert main, "main not defined" |
| 293 | assert utilities.assert_equals, "utilities.assert_equals not defined" |
| 294 | assert main.CLIs, "main.CLIs not defined" |
| 295 | |
| 296 | linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
| 297 | |
| 298 | description = "Turn off a link to ensure that Segment Routing reroutes traffic " + \ |
| 299 | "properly" |
| 300 | main.case( description ) |
| 301 | |
| 302 | main.step( "Kill Link between spine101 and leaf2" ) |
| 303 | LinkDown = main.Mininet1.link( END1="spine101", END2="leaf2", OPTION="down" ) |
| 304 | main.log.info( "Waiting %s seconds for link up to be discovered" % (linkSleep) ) |
| 305 | # TODO Maybe parameterize number of expected links |
| 306 | time.sleep( linkSleep ) |
| 307 | topology = utilities.retry( main.CLIs[0].checkStatus, |
| 308 | main.FALSE, |
| 309 | kwargs={'numoswitch':'4', 'numolink':'6'}, |
| 310 | attempts=10, |
| 311 | sleep=linkSleep) |
| 312 | result = topology & LinkDown |
| 313 | utilities.assert_equals( expect=main.TRUE, actual=result, |
| 314 | onpass="Link down successful", |
| 315 | onfail="Failed to turn off link?" ) |
| 316 | |
| 317 | main.step( "Check connectivity after link failure" ) |
| 318 | pa = main.Mininet1.pingall() |
| 319 | utilities.assert_equals( expect=main.TRUE, actual=pa, |
| 320 | onpass="Survived link failure successfully", |
| 321 | onfail="Did not survive link failure" ) |
| 322 | main.ONOSbench.dumpFlows( main.ONOSip[0], |
| 323 | main.logdir, |
| 324 | "flowsAfterLinkFailure" + main.jsonFile) |
| 325 | main.ONOSbench.dumpGroups( main.ONOSip[0], |
| 326 | main.logdir, |
| 327 | "groupsAfterLinkFailure" + main.jsonFile) |
| 328 | |
| 329 | main.step( "Restore link between spine101 and leaf2" ) |
| 330 | |
| 331 | result = False |
| 332 | count=0 |
| 333 | while True: |
| 334 | count+=0 |
| 335 | main.Mininet1.link( END1="spine101", END2="leaf2", OPTION="up" ) |
| 336 | main.Mininet1.link( END2="spine101", END1="leaf2", OPTION="up" ) |
| 337 | main.log.info( "Waiting %s seconds for link up to be discovered" % (linkSleep) ) |
| 338 | time.sleep( linkSleep ) |
| 339 | |
| 340 | main.CLIs[0].portstate(dpid='of:0000000000000002', port='1') |
| 341 | main.CLIs[0].portstate(dpid='of:0000000000000101', port='2') |
| 342 | time.sleep( linkSleep ) |
| 343 | |
| 344 | result = main.CLIs[0].checkStatus(numoswitch='4', numolink='8') |
| 345 | if count>10 or result: |
| 346 | break |
| 347 | utilities.assert_equals( expect=main.TRUE, actual=result, |
| 348 | onpass="Link up successful", |
| 349 | onfail="Failed to bring link up" ) |
| 350 | |
| 351 | main.step( "Check connectivity after link recovery" ) |
| 352 | pa = main.Mininet1.pingall() |
| 353 | utilities.assert_equals( expect=main.TRUE, actual=pa, |
| 354 | onpass="Survived link recovery successfully", |
| 355 | onfail="Did not survive link recovery" ) |
| 356 | main.ONOSbench.dumpFlows( main.ONOSip[0], |
| 357 | main.logdir, |
| 358 | "flowsAfterLinkRecovery" + main.jsonFile) |
| 359 | main.ONOSbench.dumpGroups( main.ONOSip[0], |
| 360 | main.logdir, |
| 361 | "groupsAfterLinkRecovery" + main.jsonFile) |
| 362 | |
| 363 | def CASE6( self, main ): |
| 364 | """ |
| 365 | Switch Down |
| 366 | Pingall |
| 367 | Switch up |
| 368 | Pingall |
| 369 | """ |
| 370 | import time |
| 371 | assert main.numCtrls, "main.numCtrls not defined" |
| 372 | assert main, "main not defined" |
| 373 | assert utilities.assert_equals, "utilities.assert_equals not defined" |
| 374 | assert main.CLIs, "main.CLIs not defined" |
| 375 | |
| 376 | switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] ) |
| 377 | |
| 378 | description = "Killing a switch to ensure it is discovered correctly" |
| 379 | onosCli = main.CLIs[0] |
| 380 | main.case( description ) |
| 381 | switch = main.params[ 'kill' ][ 'switch' ] |
| 382 | switchDPID = main.params[ 'kill' ][ 'dpid' ] |
| 383 | |
| 384 | main.step( "Kill " + switch ) |
| 385 | main.log.info( "Stopping" + switch ) |
| 386 | main.Mininet1.switch( SW=switch, OPTION="stop") |
| 387 | main.log.info( "Waiting %s seconds for switch down to be discovered" %(switchSleep)) |
| 388 | time.sleep( switchSleep ) |
| 389 | topology = utilities.retry( main.CLIs[0].checkStatus, |
| 390 | main.FALSE, |
| 391 | kwargs={'numoswitch':'3', 'numolink':'4'}, |
| 392 | attempts=10, |
| 393 | sleep=switchSleep) |
| 394 | utilities.assert_equals( expect=main.TRUE, actual=topology, |
| 395 | onpass="Kill switch successful", |
| 396 | onfail="Failed to kill switch?" ) |
| 397 | |
| 398 | main.step( "Check connectivity after switch failure" ) |
| 399 | pa = main.Mininet1.pingall() |
| 400 | utilities.assert_equals( expect=main.TRUE, actual=pa, |
| 401 | onpass="Survived switch failure successfully", |
| 402 | onfail="Did not survive switch failure" ) |
| 403 | main.ONOSbench.dumpFlows( main.ONOSip[0], |
| 404 | main.logdir, |
| 405 | "flowsAfterSwitchFailure" + main.jsonFile) |
| 406 | main.ONOSbench.dumpGroups( main.ONOSip[0], |
| 407 | main.logdir, |
| 408 | "groupsAfterSwitchFailure" + main.jsonFile) |
| 409 | |
| 410 | main.step( "Recovering " + switch ) |
| 411 | main.log.info( "Starting" + switch ) |
| 412 | main.Mininet1.switch( SW=switch, OPTION="start") |
| 413 | main.log.info( "Waiting %s seconds for switch up to be discovered" %(switchSleep)) |
| 414 | time.sleep( switchSleep ) |
| 415 | topology = utilities.retry( main.CLIs[0].checkStatus, |
| 416 | main.FALSE, |
| 417 | kwargs={'numoswitch':'4', 'numolink':'8'}, |
| 418 | attempts=10, |
| 419 | sleep=switchSleep) |
| 420 | utilities.assert_equals( expect=main.TRUE, actual=topology, |
| 421 | onpass="Switch recovery successful", |
| 422 | onfail="Failed to recover switch?" ) |
| 423 | |
| 424 | main.step( "Check connectivity after switch recovery" ) |
| 425 | pa = main.Mininet1.pingall() |
| 426 | utilities.assert_equals( expect=main.TRUE, actual=pa, |
| 427 | onpass="Survived switch recovery successfully", |
| 428 | onfail="Did not survive switch recovery" ) |
| 429 | main.ONOSbench.dumpFlows( main.ONOSip[0], |
| 430 | main.logdir, |
| 431 | "flowsAfterSwitchRecovery" + main.jsonFile) |
| 432 | main.ONOSbench.dumpGroups( main.ONOSip[0], |
| 433 | main.logdir, |
| 434 | "groupsAfterSwitchRecovery" + main.jsonFile) |
| 435 | |
| 436 | def CASE7( self, main ): |
| 437 | """ |
| 438 | OnosInstance1 Down |
| 439 | Pingall |
| 440 | OnosInstance1 up |
| 441 | Pingall |
| 442 | """ |
| 443 | |
| 444 | description = "Killing single instance to test controlplane resilience of Segment Routing" |
| 445 | main.case( description ) |
| 446 | main.step( "Killing ONOS instance" ) |
| 447 | killResult = main.ONOSbench.onosDie( main.CLIs[0].ip_address ) |
| 448 | utilities.assert_equals( expect=main.TRUE, actual=killResult, |
| 449 | onpass="ONOS instance Killed", |
| 450 | onfail="Error killing ONOS instance" ) |
| 451 | time.sleep( 12 ) |
| 452 | topology = utilities.retry( main.CLIs[1].checkStatus, |
| 453 | main.FALSE, |
| 454 | kwargs={'numoswitch':'4', 'numolink':'8', 'numoctrl':'2'}, |
| 455 | attempts=10, |
| 456 | sleep=12) |
| 457 | utilities.assert_equals( expect=main.TRUE, actual=topology, |
| 458 | onpass="ONOS Instance down successful", |
| 459 | onfail="Failed to turn off ONOS Instance" ) |
| 460 | main.step( "Check connectivity after ONOS instance failure" ) |
| 461 | pa = main.Mininet1.pingall() |
| 462 | utilities.assert_equals( expect=main.TRUE, actual=pa, |
| 463 | onpass="Survived instance failure successfully", |
| 464 | onfail="Did not survive instance failure" ) |
| 465 | main.ONOSbench.dumpFlows( main.ONOSip[1], main.logdir, |
| 466 | "flowsAfterSwitchFailure" + main.jsonFile) |
| 467 | main.ONOSbench.dumpGroups( main.ONOSip[1], main.logdir, |
| 468 | "groupsAfterSwitchFailure" + main.jsonFile) |
| 469 | main.step( "Recovering ONOS instance" ) |
| 470 | startResult = main.ONOSbench.onosStart( main.CLIs[0].ip_address ) |
| 471 | isUp = main.ONOSbench.isup( main.ONOSip[ 0 ] ) |
| 472 | utilities.assert_equals( expect=main.TRUE, actual=isUp, |
| 473 | onpass="ONOS service is ready", |
| 474 | onfail="ONOS service did not start properly" ) |
| 475 | main.step( "Checking if ONOS CLI is ready" ) |
| 476 | main.CLIs[0].startCellCli() |
| 477 | cliResult = main.CLIs[0].startOnosCli( main.ONOSip[ 0 ], |
| 478 | commandlineTimeout=60, onosStartTimeout=100 ) |
| 479 | utilities.assert_equals( expect=main.TRUE, |
| 480 | actual=cliResult, |
| 481 | onpass="ONOS CLI is ready", |
| 482 | onfail="ONOS CLI is not ready" ) |
| 483 | for i in range( 10 ): |
| 484 | ready = True |
| 485 | output = main.CLIs[0].summary() |
| 486 | if not output: |
| 487 | ready = False |
| 488 | if ready: |
| 489 | break |
| 490 | time.sleep( 10 ) |
| 491 | utilities.assert_equals( expect=True, actual=ready, |
| 492 | onpass="ONOS summary command succeded", |
| 493 | onfail="ONOS summary command failed" ) |
| 494 | if not ready: |
| 495 | main.log.error( "ONOS startup failed!" ) |
| 496 | main.cleanup() |
| 497 | main.exit() |
| 498 | main.step(" Check whether the flow count is bigger than 116" ) |
| 499 | count = utilities.retry( main.CLIs[0].checkFlowCount, |
| 500 | main.FALSE, |
| 501 | kwargs={'min':116}, |
| 502 | attempts=10, |
| 503 | sleep=10 ) |
| 504 | utilities.assertEquals( expect=True, |
| 505 | actual=(count>0), |
| 506 | onpass="Flow count looks correct: "+str(count), |
| 507 | onfail="Flow count looks wrong: "+str(count) ) |
| 508 | |
| 509 | main.step( "Check connectivity after ONOS instance recovery" ) |
| 510 | pa = main.Mininet1.pingall() |
| 511 | utilities.assert_equals( expect=main.TRUE, actual=pa, |
| 512 | onpass="Survived instance recovery successfully", |
| 513 | onfail="Did not survive recovery failure" ) |
| 514 | main.ONOSbench.dumpFlows( main.ONOSip[0], main.logdir, |
| 515 | "flowsAfterCtrlFailure" + main.jsonFile) |
| 516 | main.ONOSbench.dumpGroups( main.ONOSip[0], main.logdir, |
| 517 | "groupsAfterCtrlFailure" + main.jsonFile) |
| 518 | |
| 519 | def CASE8( self, main ): |
| 520 | """ |
| 521 | Cluster Down |
| 522 | Pingall |
| 523 | Cluster up |
| 524 | Pingall |
| 525 | """ |
| 526 | description = "Killing all instances to test controlplane resilience of Segment Routing" |
| 527 | main.case( description ) |
| 528 | main.step( "Shutting down ONOS Cluster" ) |
| 529 | for i in range( main.numCtrls ): |
| 530 | killResult = main.ONOSbench.onosDie( main.CLIs[i].ip_address ) |
| 531 | utilities.assert_equals( expect=main.TRUE, actual=killResult, |
| 532 | onpass="ONOS instance Killed", |
| 533 | onfail="Error killing ONOS instance" ) |
| 534 | time.sleep(12) |
| 535 | main.step( "Check connectivity after ONOS instance failure" ) |
| 536 | pa = main.Mininet1.pingall() |
| 537 | utilities.assert_equals( expect=main.TRUE, actual=pa, |
| 538 | onpass="Survived instance failure successfully", |
| 539 | onfail="Did not survive instance failure" ) |
| 540 | main.step( "Recovering ONOS Cluster" ) |
| 541 | for i in range( main.numCtrls ): |
| 542 | startResult = main.ONOSbench.onosStart( main.CLIs[i].ip_address ) |
| 543 | isUp = main.ONOSbench.isup( main.ONOSip[ i ] ) |
| 544 | utilities.assert_equals( expect=main.TRUE, actual=isUp, |
| 545 | onpass="ONOS service is ready", |
| 546 | onfail="ONOS service did not start properly" ) |
| 547 | main.step( "Checking if ONOS CLI is ready" ) |
| 548 | for i in range( main.numCtrls ): |
| 549 | main.CLIs[i].startCellCli() |
| 550 | cliResult = main.CLIs[i].startOnosCli( main.ONOSip[ i ], |
| 551 | commandlineTimeout=60, onosStartTimeout=100 ) |
| 552 | utilities.assert_equals( expect=main.TRUE, |
| 553 | actual=cliResult, |
| 554 | onpass="ONOS CLI is ready", |
| 555 | onfail="ONOS CLI is not ready" ) |
| 556 | for i in range( 10 ): |
| 557 | ready = True |
| 558 | output = main.CLIs[0].summary() |
| 559 | if not output: |
| 560 | ready = False |
| 561 | if ready: |
| 562 | break |
| 563 | time.sleep( 10 ) |
| 564 | utilities.assert_equals( expect=True, actual=ready, |
| 565 | onpass="ONOS summary command succeded", |
| 566 | onfail="ONOS summary command failed" ) |
| 567 | if not ready: |
| 568 | main.log.error( "ONOS startup failed!" ) |
| 569 | main.cleanup() |
| 570 | main.exit() |
| 571 | |
| 572 | main.step(" Check whether the flow count is bigger than 116" ) |
| 573 | count = utilities.retry( main.CLIs[0].checkFlowCount, |
| 574 | main.FALSE, |
| 575 | kwargs={'min':116}, |
| 576 | attempts=10, |
| 577 | sleep=10 ) |
| 578 | utilities.assertEquals( expect=True, |
| 579 | actual=(count>0), |
| 580 | onpass="Flow count looks correct: "+str(count), |
| 581 | onfail="Flow count looks wrong: "+str(count) ) |
| 582 | |
| 583 | main.step( "Check connectivity after CLUSTER recovery" ) |
| 584 | pa = main.Mininet1.pingall() |
| 585 | utilities.assert_equals( expect=main.TRUE, actual=pa, |
| 586 | onpass="Survived instance recovery successfully", |
| 587 | onfail="Did not survive recovery failure" ) |
| 588 | main.ONOSbench.dumpFlows( main.ONOSip[0], main.logdir, |
| 589 | "flowsAfterCtrlFailure" + main.jsonFile) |
| 590 | main.ONOSbench.dumpGroups( main.ONOSip[0], main.logdir, |
| 591 | "groupsAfterCtrlFailure" + main.jsonFile) |
| 592 | |
| 593 | def CASE10( self, main ): |
| 594 | ''' |
| 595 | Report errors/warnings/exceptions |
| 596 | ''' |
| 597 | main.case( "Logging test for " + main.jsonFile ) |
| 598 | for i in range(main.numCtrls): |
| 599 | main.ONOSbench.onosStop( main.ONOSip[i] ) |
| 600 | main.Mininet1.stopNet() |
| 601 | |
| 602 | main.ONOSbench.scp( main.ONOScli1 , |
| 603 | "/opt/onos/log/karaf.log", |
| 604 | "/tmp/karaf.log", |
| 605 | direction="from" ) |
| 606 | main.ONOSbench.cpLogsToDir("/tmp/karaf.log",main.logdir, |
| 607 | copyFileName="karaf.log."+main.jsonFile+str(len(main.json))) |
| 608 | #main.ONOSbench.logReport( main.ONOSip[ 0 ], |
| 609 | # [ "INFO" ], |
| 610 | # "a" ) |
| 611 | #main.log.info("Error report: \n" ) |
| 612 | main.ONOSbench.logReport( main.ONOSip[ 0 ], |
| 613 | [ "INFO", |
| 614 | "FOLLOWER", |
| 615 | "WARN", |
| 616 | "flow", |
| 617 | "ERROR", |
| 618 | "Except" ], |
| 619 | "s" ) |