kelvin-onlab | 1d03c60 | 2015-05-05 11:14:42 -0700 | [diff] [blame^] | 1 | |
| 2 | # Testing the basic functionality of ONOS Next |
| 3 | # For sanity and driver functionality excercises only. |
| 4 | |
| 5 | import time |
| 6 | # import sys |
| 7 | # import os |
| 8 | # import re |
| 9 | import json |
| 10 | |
| 11 | time.sleep( 1 ) |
| 12 | |
| 13 | class IpOptical: |
| 14 | |
| 15 | def __init__( self ): |
| 16 | self.default = '' |
| 17 | |
| 18 | def CASE1( self, main ): |
| 19 | import time |
| 20 | """ |
| 21 | Startup sequence: |
| 22 | cell <name> |
| 23 | onos-verify-cell |
| 24 | onos-remove-raft-log |
| 25 | git pull |
| 26 | mvn clean install |
| 27 | onos-package |
| 28 | onos-install -f |
| 29 | onos-wait-for-start |
| 30 | """ |
| 31 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 32 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 33 | |
| 34 | main.case( "Setting up test environment" ) |
| 35 | main.log.report( |
| 36 | "This testcase is testing setting up test environment" ) |
| 37 | main.log.report( "__________________________________" ) |
| 38 | |
| 39 | main.step( "Applying cell variable to environment" ) |
| 40 | cellResult = main.ONOSbench.setCell( cellName ) |
| 41 | verifyResult = main.ONOSbench.verifyCell() |
| 42 | |
| 43 | main.step( "Removing raft logs before a clen installation of ONOS" ) |
| 44 | main.ONOSbench.onosRemoveRaftLogs() |
| 45 | |
| 46 | main.step( "Git checkout and get version" ) |
| 47 | #main.ONOSbench.gitCheckout( "master" ) |
| 48 | gitPullResult = main.ONOSbench.gitPull() |
| 49 | main.log.info( "git_pull_result = " + str( gitPullResult )) |
| 50 | main.ONOSbench.getVersion( report=True ) |
| 51 | |
| 52 | if gitPullResult == 1: |
| 53 | main.step( "Using mvn clean & install" ) |
| 54 | main.ONOSbench.cleanInstall() |
| 55 | elif gitPullResult == 0: |
| 56 | main.log.report( |
| 57 | "Git Pull Failed, look into logs for detailed reason" ) |
| 58 | main.cleanup() |
| 59 | main.exit() |
| 60 | |
| 61 | main.step( "Creating ONOS package" ) |
| 62 | packageResult = main.ONOSbench.onosPackage() |
| 63 | |
| 64 | main.step( "Uninstalling ONOS package" ) |
| 65 | ONOSip1 = main.params[ 'CTRL' ][ 'ip1' ] |
| 66 | onosUninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOSip1) |
| 67 | if onosUninstallResult: |
| 68 | main.log.report( "Uninstalling ONOS package successful" ) |
| 69 | else: |
| 70 | main.log.report( "Uninstalled ONOS package unsucessful" ) |
| 71 | time.sleep( 5 ) |
| 72 | main.step( "Installing ONOS package" ) |
| 73 | onosInstallResult = main.ONOSbench.onosInstall( node = ONOSip1 ) |
| 74 | if onosInstallResult == main.TRUE: |
| 75 | main.log.report( "Installing ONOS package successful" ) |
| 76 | else: |
| 77 | main.log.report( "Installing ONOS package failed" ) |
| 78 | |
| 79 | onos1Isup = main.ONOSbench.isup() |
| 80 | if onos1Isup == main.TRUE: |
| 81 | main.log.report( "ONOS instance is up and ready" ) |
| 82 | else: |
| 83 | main.log.report( "ONOS instance may not be up" ) |
| 84 | |
| 85 | main.step( "Starting ONOS service" ) |
| 86 | startResult = main.ONOSbench.onosStart( ONOS1Ip ) |
| 87 | |
| 88 | main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] ) |
| 89 | main.step( "Starting Mininet CLI..." ) |
| 90 | |
| 91 | case1Result = ( packageResult and |
| 92 | cellResult and verifyResult |
| 93 | and onosInstallResult and |
| 94 | onos1Isup and startResult ) |
| 95 | utilities.assert_equals( expect=main.TRUE, actual=case1Result, |
| 96 | onpass="Test startup successful", |
| 97 | onfail="Test startup NOT successful" ) |
| 98 | |
| 99 | def CASE20( self ): |
| 100 | """ |
| 101 | Exit from mininet cli |
| 102 | reinstall ONOS |
| 103 | """ |
| 104 | import time |
| 105 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 106 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 107 | |
| 108 | main.log.report( "This testcase exits the mininet cli and reinstalls" + |
| 109 | "ONOS to switch over to Packet Optical topology" ) |
| 110 | main.log.report( "_____________________________________________" ) |
| 111 | main.case( "Disconnecting mininet and restarting ONOS" ) |
| 112 | |
| 113 | main.step( "Disconnecting mininet and restarting ONOS" ) |
| 114 | step1Result = main.TRUE |
| 115 | mininetDisconnect = main.Mininet1.disconnect() |
| 116 | print "mininetDisconnect = ", mininetDisconnect |
| 117 | step1Result = mininetDisconnect |
| 118 | utilities.assert_equals( |
| 119 | expect=main.TRUE, |
| 120 | actual=step1Result, |
| 121 | onpass="Mininet disconnect successfully", |
| 122 | onfail="Mininet failed to disconnect") |
| 123 | """ |
| 124 | main.step( "Removing raft logs before a clean installation of ONOS" ) |
| 125 | step2Result = main.TRUE |
| 126 | removeRaftLogsResult = main.ONOSbench.onosRemoveRaftLogs() |
| 127 | step2Result = removeRaftLogsResult |
| 128 | utilities.assert_equals( |
| 129 | expect=main.TRUE, |
| 130 | actual=step2Result, |
| 131 | onpass="Raft logs removed successfully", |
| 132 | onfail="Failed to remove raft logs") |
| 133 | """ |
| 134 | main.step( "Applying cell variable to environment" ) |
| 135 | step3Result = main.TRUE |
| 136 | setCellResult = main.ONOSbench.setCell( cellName ) |
| 137 | verifyCellResult = main.ONOSbench.verifyCell() |
| 138 | step3Result = setCellResult and verifyCellResult |
| 139 | utilities.assert_equals( |
| 140 | expect=main.TRUE, |
| 141 | actual=step3Result, |
| 142 | onpass="Cell applied successfully", |
| 143 | onfail="Failed to apply cell") |
| 144 | |
| 145 | main.step( "Uninstalling ONOS package" ) |
| 146 | step4Result = main.TRUE |
| 147 | ONOSip1 = main.params[ 'CTRL' ][ 'ip1' ] |
| 148 | onosUninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOSip1) |
| 149 | step4Result = onosUninstallResult |
| 150 | utilities.assert_equals( |
| 151 | expect=main.TRUE, |
| 152 | actual=step4Result, |
| 153 | onpass="Successfully uninstalled ONOS", |
| 154 | onfail="Failed to uninstall ONOS") |
| 155 | |
| 156 | time.sleep( 5 ) |
| 157 | main.step( "Installing ONOS package" ) |
| 158 | step5Result = main.TRUE |
| 159 | onosInstallResult = main.ONOSbench.onosInstall( node = ONOSip1 ) |
| 160 | step5Result = onosInstallResult |
| 161 | utilities.assert_equals( |
| 162 | expect=main.TRUE, |
| 163 | actual=step5Result, |
| 164 | onpass="Successfully installed ONOS", |
| 165 | onfail="Failed to install ONOS") |
| 166 | |
| 167 | onos1Isup = main.ONOSbench.isup() |
| 168 | if onos1Isup == main.TRUE: |
| 169 | main.log.report( "ONOS instance is up and ready" ) |
| 170 | else: |
| 171 | main.log.report( "ONOS instance may not be up" ) |
| 172 | |
| 173 | main.step( "Starting ONOS service" ) |
| 174 | step6Result = main.TRUE |
| 175 | startResult = main.ONOSbench.onosStart( ONOS1Ip ) |
| 176 | step6Result = startResult |
| 177 | utilities.assert_equals( |
| 178 | expect=main.TRUE, |
| 179 | actual=step6Result, |
| 180 | onpass="Successfully started ONOS", |
| 181 | onfail="Failed to start ONOS") |
| 182 | |
| 183 | main.step( "Starting ONOS cli" ) |
| 184 | step7Result = main.TRUE |
| 185 | cliResult = main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] ) |
| 186 | step7Result = cliResult |
| 187 | utilities.assert_equals( |
| 188 | expect=main.TRUE, |
| 189 | actual=step7Result, |
| 190 | onpass="Successfully started ONOS cli", |
| 191 | onfail="Failed to start ONOS cli") |
| 192 | |
| 193 | case20Result = step1Result and step3Result and\ |
| 194 | step4Result and step5Result and step6Result and\ |
| 195 | step7Result |
| 196 | utilities.assert_equals( |
| 197 | expect=main.TRUE, |
| 198 | actual=case20Result, |
| 199 | onpass= "Exiting functionality mininet topology and reinstalling" + |
| 200 | " ONOS successful", |
| 201 | onfail= "Exiting functionality mininet topology and reinstalling" + |
| 202 | " ONOS failed" ) |
| 203 | |
| 204 | def CASE21( self, main ): |
| 205 | """ |
| 206 | On ONOS bench, run this command: |
| 207 | sudo -E python ~/onos/tools/test/topos/opticalTest.py -OC1 |
| 208 | which spawns packet optical topology and copies the links |
| 209 | json file to the onos instance. |
| 210 | Note that in case of Packet Optical, the links are not learnt |
| 211 | from the topology, instead the links are learnt |
| 212 | from the json config file |
| 213 | """ |
| 214 | import time |
| 215 | main.log.report( |
| 216 | "This testcase starts the packet layer topology and REST" ) |
| 217 | main.log.report( "_____________________________________________" ) |
| 218 | main.case( "Starting LINC-OE and other components" ) |
| 219 | |
| 220 | main.step( "Activate optical app" ) |
| 221 | step1Result = main.TRUE |
| 222 | activateOpticalResult = main.ONOS2.activateApp( "org.onosproject.optical" ) |
| 223 | step1Result = activateOpticalResult |
| 224 | utilities.assert_equals( |
| 225 | expect=main.TRUE, |
| 226 | actual=step1Result, |
| 227 | onpass="Successfully activated optical app", |
| 228 | onfail="Failed to activate optical app") |
| 229 | |
| 230 | appCheck = main.ONOS2.appToIDCheck() |
| 231 | if appCheck != main.TRUE: |
| 232 | main.log.warn( main.ONOS2.apps() ) |
| 233 | main.log.warn( main.ONOS2.appIDs() ) |
| 234 | |
| 235 | main.step( "Starting mininet and LINC-OE" ) |
| 236 | step2Result = main.TRUE |
| 237 | time.sleep( 10 ) |
| 238 | opticalMnScript = main.LincOE2.runOpticalMnScript(ctrllerIP = main.params[ 'CTRL' ][ 'ip1' ]) |
| 239 | step2Result = opticalMnScript |
| 240 | utilities.assert_equals( |
| 241 | expect=main.TRUE, |
| 242 | actual=step2Result, |
| 243 | onpass="Started the topology successfully ", |
| 244 | onfail="Failed to start the topology") |
| 245 | |
| 246 | case21Result = step1Result and step2Result |
| 247 | utilities.assert_equals( |
| 248 | expect=main.TRUE, |
| 249 | actual=case21Result, |
| 250 | onpass="Packet optical topology spawned successsfully", |
| 251 | onfail="Packet optical topology spawning failed" ) |
| 252 | |
| 253 | def CASE22( self, main ): |
| 254 | """ |
| 255 | Curretly we use, 10 optical switches(ROADM's) and |
| 256 | 6 packet layer mininet switches each with one host. |
| 257 | Therefore, the roadmCount variable = 10, |
| 258 | packetLayerSWCount variable = 6, hostCount=6 and |
| 259 | links=42. |
| 260 | All this is hardcoded in the testcase. If the topology changes, |
| 261 | these hardcoded values need to be changed |
| 262 | """ |
| 263 | import time |
| 264 | main.log.report( |
| 265 | "This testcase compares the optical+packet topology against what" + |
| 266 | " is expected" ) |
| 267 | main.case( "Topology comparision" ) |
| 268 | |
| 269 | main.step( "Starts new ONOS cli" ) |
| 270 | step1Result = main.TRUE |
| 271 | cliResult = main.ONOS3.startOnosCli( ONOSIp=main.params[ 'CTRL' ]\ |
| 272 | [ 'ip1' ] ) |
| 273 | step1Result = cliResult |
| 274 | utilities.assert_equals( |
| 275 | expect=main.TRUE, |
| 276 | actual=step1Result, |
| 277 | onpass="Successfully starts a new cli", |
| 278 | onfail="Failed to start new cli" ) |
| 279 | |
| 280 | main.step( "Compare topology" ) |
| 281 | step2Result = main.TRUE |
| 282 | devicesResult = main.ONOS3.devices( jsonFormat=False ) |
| 283 | print "devices_result :\n", devicesResult |
| 284 | devicesLinewise = devicesResult.split( "\n" ) |
| 285 | roadmCount = 0 |
| 286 | packetLayerSWCount = 0 |
| 287 | for line in devicesLinewise: |
| 288 | components = line.split( "," ) |
| 289 | availability = components[ 1 ].split( "=" )[ 1 ] |
| 290 | type = components[ 3 ].split( "=" )[ 1 ] |
| 291 | if availability == 'true' and type == 'ROADM': |
| 292 | roadmCount += 1 |
| 293 | elif availability == 'true' and type == 'SWITCH': |
| 294 | packetLayerSWCount += 1 |
| 295 | if roadmCount == 10: |
| 296 | print "Number of Optical Switches = %d and is" % roadmCount +\ |
| 297 | " correctly detected" |
| 298 | main.log.info( |
| 299 | "Number of Optical Switches = " + |
| 300 | str( roadmCount ) + |
| 301 | " and is correctly detected" ) |
| 302 | opticalSWResult = main.TRUE |
| 303 | else: |
| 304 | print "Number of Optical Switches = %d and is wrong" % roadmCount |
| 305 | main.log.info( |
| 306 | "Number of Optical Switches = " + |
| 307 | str( roadmCount ) + |
| 308 | " and is wrong" ) |
| 309 | opticalSWResult = main.FALSE |
| 310 | if packetLayerSWCount == 6: |
| 311 | print "Number of Packet layer or mininet Switches = %d "\ |
| 312 | % packetLayerSWCount + "and is correctly detected" |
| 313 | main.log.info( |
| 314 | "Number of Packet layer or mininet Switches = " + |
| 315 | str( packetLayerSWCount ) + |
| 316 | " and is correctly detected" ) |
| 317 | packetSWResult = main.TRUE |
| 318 | else: |
| 319 | print "Number of Packet layer or mininet Switches = %d and"\ |
| 320 | % packetLayerSWCount + " is wrong" |
| 321 | main.log.info( |
| 322 | "Number of Packet layer or mininet Switches = " + |
| 323 | str( packetLayerSWCount ) + |
| 324 | " and is wrong" ) |
| 325 | packetSWResult = main.FALSE |
| 326 | # sleeps for sometime so the state of the switches will be active |
| 327 | time.sleep( 30 ) |
| 328 | print "_________________________________" |
| 329 | linksResult = main.ONOS3.links( jsonFormat=False ) |
| 330 | print "links_result = ", linksResult |
| 331 | print "_________________________________" |
| 332 | linkActiveCount = linksResult.count("state=ACTIVE") |
| 333 | main.log.info( "linkActiveCount = " + str( linkActiveCount )) |
| 334 | if linkActiveCount == 42: |
| 335 | linkActiveResult = main.TRUE |
| 336 | main.log.info( |
| 337 | "Number of links in ACTIVE state are correct") |
| 338 | else: |
| 339 | linkActiveResult = main.FALSE |
| 340 | main.log.info( |
| 341 | "Number of links in ACTIVE state are wrong") |
| 342 | step2Result = opticalSWResult and packetSWResult and \ |
| 343 | linkActiveResult |
| 344 | utilities.assert_equals( |
| 345 | expect=main.TRUE, |
| 346 | actual=step2Result, |
| 347 | onpass="Successfully loaded packet optical topology", |
| 348 | onfail="Failed to load packet optical topology" ) |
| 349 | |
| 350 | case22Result = step1Result and step2Result |
| 351 | |
| 352 | utilities.assert_equals( |
| 353 | expect=main.TRUE, |
| 354 | actual=case22Result, |
| 355 | onpass="Packet optical topology discovery successful", |
| 356 | onfail="Packet optical topology discovery failed" ) |
| 357 | |
| 358 | def CASE23( self, main ): |
| 359 | import time |
| 360 | """ |
| 361 | Add bidirectional point intents between 2 packet layer( mininet ) |
| 362 | devices and |
| 363 | ping mininet hosts |
| 364 | """ |
| 365 | main.log.report( |
| 366 | "This testcase adds bidirectional point intents between 2 " + |
| 367 | "packet layer( mininet ) devices and ping mininet hosts" ) |
| 368 | main.case( "Install point intents between 2 packet layer device and " + |
| 369 | "ping the hosts" ) |
| 370 | |
| 371 | main.step( "Adding point intents" ) |
| 372 | step1Result = main.TRUE |
| 373 | intentsId = [] |
| 374 | pIntent1 = main.ONOS3.addPointIntent( |
| 375 | "of:0000ffffffff0001/1", |
| 376 | "of:0000ffffffff0005/1" ) |
| 377 | pIntent2 = main.ONOS3.addPointIntent( |
| 378 | "of:0000ffffffff0005/1", |
| 379 | "of:0000ffffffff0001/1" ) |
| 380 | intentsId.append( pIntent1 ) |
| 381 | intentsId.append( pIntent2 ) |
| 382 | main.log.info( "Checking intents state") |
| 383 | checkStateResult = main.ONOS3.checkIntentState( intentsId = intentsId ) |
| 384 | time.sleep( 30 ) |
| 385 | main.log.info( "Checking flows state") |
| 386 | checkFlowResult = main.ONOS3.checkFlowsState() |
| 387 | # Sleep for 30 seconds to provide time for the intent state to change |
| 388 | time.sleep( 30 ) |
| 389 | main.log.info( "Checking intents state one more time") |
| 390 | checkStateResult = main.ONOS3.checkIntentState( intentsId = intentsId ) |
| 391 | step1Result = checkStateResult and checkFlowResult |
| 392 | utilities.assert_equals( |
| 393 | expect=main.TRUE, |
| 394 | actual=step1Result, |
| 395 | onpass="Successfully added point intents", |
| 396 | onfail="Failed to add point intents") |
| 397 | |
| 398 | main.step( "Ping h1 and h5" ) |
| 399 | step2Result = main.TRUE |
| 400 | main.log.info( "\n\nh1 is Pinging h5" ) |
| 401 | pingResult = main.LincOE2.pingHostOptical( src="h1", target="h5" ) |
| 402 | step2Result = pingResult |
| 403 | utilities.assert_equals( |
| 404 | expect=main.TRUE, |
| 405 | actual=step2Result, |
| 406 | onpass="Successfully pinged h1 and h5", |
| 407 | onfail="Failed to ping between h1 and h5") |
| 408 | |
| 409 | case23Result = step1Result and step2Result |
| 410 | utilities.assert_equals( |
| 411 | expect=main.TRUE, |
| 412 | actual=case23Result, |
| 413 | onpass="Point intents are installed properly", |
| 414 | onfail="Failed to install point intents" ) |
| 415 | |
| 416 | def CASE24( self, main ): |
| 417 | import time |
| 418 | import json |
| 419 | """ |
| 420 | LINC uses its own switch IDs. You can use the following |
| 421 | command on the LINC console to find the mapping between |
| 422 | DPIDs and LINC IDs. |
| 423 | rp(application:get_all_key(linc)). |
| 424 | |
| 425 | Test Rerouting of Packet Optical by bringing a port down |
| 426 | ( port 20 ) of a switch( switchID=1, or LincOE switchID =9 ), |
| 427 | so that link |
| 428 | ( between switch1 port20 - switch5 port50 ) is inactive |
| 429 | and do a ping test. If rerouting is successful, |
| 430 | ping should pass. also check the flows |
| 431 | """ |
| 432 | main.log.report( |
| 433 | "This testcase tests rerouting and pings mininet hosts" ) |
| 434 | main.case( "Test rerouting and pings mininet hosts" ) |
| 435 | |
| 436 | main.step( "Attach to the Linc-OE session" ) |
| 437 | step1Result = main.TRUE |
| 438 | attachConsole = main.LincOE1.attachLincOESession() |
| 439 | step1Result = attachConsole |
| 440 | utilities.assert_equals( |
| 441 | expect=main.TRUE, |
| 442 | actual=step1Result, |
| 443 | onpass="Successfully attached Linc-OE session", |
| 444 | onfail="Failed to attached Linc-OE session") |
| 445 | |
| 446 | main.step( "Bring a port down and verify the link state" ) |
| 447 | step2Result = main.TRUE |
| 448 | main.LincOE1.portDown( swId="9", ptId="20" ) |
| 449 | linksNonjson = main.ONOS3.links( jsonFormat=False ) |
| 450 | main.log.info( "links = " + linksNonjson ) |
| 451 | linkInactiveCount = linksNonjson.count( "state=INACTIVE" ) |
| 452 | main.log.info( "linkInactiveCount = " + str( linkInactiveCount )) |
| 453 | if linkInactiveCount == 2: |
| 454 | main.log.info( |
| 455 | "Number of links in INACTIVE state are correct") |
| 456 | else: |
| 457 | main.log.info( |
| 458 | "Number of links in INACTIVE state are wrong") |
| 459 | links = main.ONOS3.links() |
| 460 | main.log.info( "links = " + links ) |
| 461 | linksResult = json.loads( links ) |
| 462 | linksStateResult = main.FALSE |
| 463 | for item in linksResult: |
| 464 | if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[ |
| 465 | 'src' ][ 'port' ] == "20": |
| 466 | if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff05" and item[ |
| 467 | 'dst' ][ 'port' ] == "50": |
| 468 | linksState = item[ 'state' ] |
| 469 | if linksState == "INACTIVE": |
| 470 | main.log.info( |
| 471 | "Links state is inactive as expected due to one" + |
| 472 | " of the ports being down" ) |
| 473 | main.log.report( |
| 474 | "Links state is inactive as expected due to one" + |
| 475 | " of the ports being down" ) |
| 476 | linksStateResult = main.TRUE |
| 477 | break |
| 478 | else: |
| 479 | main.log.info( |
| 480 | "Links state is not inactive as expected" ) |
| 481 | main.log.report( |
| 482 | "Links state is not inactive as expected" ) |
| 483 | linksStateResult = main.FALSE |
| 484 | time.sleep( 10 ) |
| 485 | checkFlowsState = main.ONOS3.checkFlowsState() |
| 486 | step2Result = linksStateResult |
| 487 | utilities.assert_equals( |
| 488 | expect=main.TRUE, |
| 489 | actual=step2Result, |
| 490 | onpass="Successfuly brought down a link", |
| 491 | onfail="Failed to bring down a link") |
| 492 | |
| 493 | main.step( "Verify Rerouting by a ping test" ) |
| 494 | step3Result = main.TRUE |
| 495 | main.log.info( "\n\nh1 is Pinging h5" ) |
| 496 | pingResult = main.LincOE2.pingHostOptical( src="h1", target="h5" ) |
| 497 | step3Result = pingResult |
| 498 | utilities.assert_equals( |
| 499 | expect=main.TRUE, |
| 500 | actual=step3Result, |
| 501 | onpass="Successfully pinged h1 and h5", |
| 502 | onfail="Failed to ping between h1 and h5") |
| 503 | |
| 504 | main.step( "Bring the downed port up and verify the link state" ) |
| 505 | step4Result = main.TRUE |
| 506 | main.LincOE1.portUp( swId="9", ptId="20" ) |
| 507 | linksNonjson = main.ONOS3.links( jsonFormat=False ) |
| 508 | main.log.info( "links = " + linksNonjson ) |
| 509 | linkInactiveCount = linksNonjson.count( "state=INACTIVE" ) |
| 510 | main.log.info( "linkInactiveCount = " + str( linkInactiveCount )) |
| 511 | if linkInactiveCount == 0: |
| 512 | main.log.info( |
| 513 | "Number of links in INACTIVE state are correct") |
| 514 | else: |
| 515 | main.log.info( |
| 516 | "Number of links in INACTIVE state are wrong") |
| 517 | step4Result = main.FALSE |
| 518 | utilities.assert_equals( |
| 519 | expect=main.TRUE, |
| 520 | actual=step4Result, |
| 521 | onpass="Successfully brought the port up", |
| 522 | onfail="Failed to bring the port up") |
| 523 | |
| 524 | case24Result = step1Result and step2Result and step3Result \ |
| 525 | and step4Result |
| 526 | utilities.assert_equals( expect=main.TRUE, |
| 527 | actual=case24Result, |
| 528 | onpass="Packet optical rerouting successful", |
| 529 | onfail="Packet optical rerouting failed" ) |
| 530 | |
| 531 | def CASE10( self ): |
| 532 | main.log.report( |
| 533 | "This testcase uninstalls the reactive forwarding app" ) |
| 534 | main.log.report( "__________________________________" ) |
| 535 | main.case( "Uninstalling reactive forwarding app" ) |
| 536 | main.step( "Uninstalling reactive forwarding app" ) |
| 537 | step1Result = main.TRUE |
| 538 | # Unistall onos-app-fwd app to disable reactive forwarding |
| 539 | main.log.info( "deactivate reactive forwarding app" ) |
| 540 | appUninstallResult = main.ONOS2.deactivateApp( "org.onosproject.fwd" ) |
| 541 | appCheck = main.ONOS2.appToIDCheck() |
| 542 | if appCheck != main.TRUE: |
| 543 | main.log.warn( main.ONOS2.apps() ) |
| 544 | main.log.warn( main.ONOS2.appIDs() ) |
| 545 | step1Result = appUninstallResult |
| 546 | utilities.assert_equals( |
| 547 | expect=main.TRUE, |
| 548 | actual=step1Result, |
| 549 | onpass="Successfully deactivate reactive forwarding app", |
| 550 | onfail="Failed to deactivate reactive forwarding app") |
| 551 | # After reactive forwarding is disabled, the reactive flows on |
| 552 | # switches timeout in 10-15s |
| 553 | # So sleep for 15s |
| 554 | time.sleep( 15 ) |
| 555 | flows = main.ONOS2.flows() |
| 556 | main.log.info( flows ) |
| 557 | |
| 558 | case10Result = step1Result |
| 559 | utilities.assert_equals( |
| 560 | expect=main.TRUE, |
| 561 | actual=case10Result, |
| 562 | onpass="Reactive forwarding app uninstallation successful", |
| 563 | onfail="Reactive forwarding app uninstallation failed" ) |
| 564 | |
| 565 | def CASE25( self ): |
| 566 | """ |
| 567 | Add host intents between 2 packet layer host |
| 568 | """ |
| 569 | import time |
| 570 | import json |
| 571 | main.log.report( "Adding host intents between 2 optical layer host" ) |
| 572 | main.case( "Test add host intents between optical layer host" ) |
| 573 | |
| 574 | main.step( "Discover host using arping" ) |
| 575 | step1Result = main.TRUE |
| 576 | main.hostMACs = [] |
| 577 | main.hostId = [] |
| 578 | #Listing host MAC addresses |
| 579 | for i in range( 1 , 7 ): |
| 580 | main.hostMACs.append( "00:00:00:00:00:" + |
| 581 | str( hex( i )[ 2: ] ).zfill( 2 ).upper() ) |
| 582 | for macs in main.hostMACs: |
| 583 | main.hostId.append( macs + "/-1" ) |
| 584 | host1 = main.hostId[ 0 ] |
| 585 | host2 = main.hostId[ 1 ] |
| 586 | # Use arping to discover the hosts |
| 587 | main.LincOE2.arping( host = "h1" ) |
| 588 | main.LincOE2.arping( host = "h2" ) |
| 589 | time.sleep( 5 ) |
| 590 | hostsDict = main.ONOS3.hosts() |
| 591 | if not len( hostsDict ): |
| 592 | step1Result = main.FALSE |
| 593 | # Adding host intent |
| 594 | utilities.assert_equals( |
| 595 | expect=main.TRUE, |
| 596 | actual=step1Result, |
| 597 | onpass="Hosts discovered", |
| 598 | onfail="Failed to discover hosts") |
| 599 | |
| 600 | main.step( "Adding host intents to h1 and h2" ) |
| 601 | step2Result = main.TRUE |
| 602 | intentsId = [] |
| 603 | intent1 = main.ONOS3.addHostIntent( hostIdOne = host1, |
| 604 | hostIdTwo = host2 ) |
| 605 | intentsId.append( intent1 ) |
| 606 | time.sleep( 5 ) |
| 607 | intent2 = main.ONOS3.addHostIntent( hostIdOne = host2, |
| 608 | hostIdTwo = host1 ) |
| 609 | intentsId.append( intent2 ) |
| 610 | # Checking intents state before pinging |
| 611 | main.log.info( "Checking intents state" ) |
| 612 | time.sleep( 15 ) |
| 613 | intentResult = main.ONOS3.checkIntentState( intentsId = intentsId ) |
| 614 | #check intent state again if intents are not in installed state |
| 615 | if not intentResult: |
| 616 | intentResult = main.ONOS3.checkIntentState( intentsId = intentsId ) |
| 617 | step2Result = intentResult |
| 618 | utilities.assert_equals( expect=main.TRUE, |
| 619 | actual=step2Result, |
| 620 | onpass="All intents are in INSTALLED state ", |
| 621 | onfail="Some of the intents are not in " + |
| 622 | "INSTALLED state " ) |
| 623 | |
| 624 | # pinging h1 to h2 and then ping h2 to h1 |
| 625 | main.step( "Pinging h1 and h2" ) |
| 626 | step3Result = main.TRUE |
| 627 | pingResult = main.TRUE |
| 628 | pingResult = main.LincOE2.pingHostOptical( src="h1", target="h2" ) |
| 629 | pingResult = pingResult and main.LincOE2.pingHostOptical( src="h2", |
| 630 | target="h1" ) |
| 631 | step3Result = pingResult |
| 632 | utilities.assert_equals( expect=main.TRUE, |
| 633 | actual=step3Result, |
| 634 | onpass="Pinged successfully between h1 and h2", |
| 635 | onfail="Pinged failed between h1 and h2" ) |
| 636 | # Removed all added host intents |
| 637 | main.step( "Removing host intents" ) |
| 638 | step4Result = main.TRUE |
| 639 | removeResult = main.TRUE |
| 640 | # Check remaining intents |
| 641 | intentsJson = json.loads( main.ONOS3.intents() ) |
| 642 | main.ONOS3.removeIntent( intentId=intent1, purge=True ) |
| 643 | main.ONOS3.removeIntent( intentId=intent2, purge=True ) |
| 644 | for intents in intentsJson: |
| 645 | main.ONOS3.removeIntent( intentId=intents.get( 'id' ), |
| 646 | app='org.onosproject.optical', |
| 647 | purge=True ) |
| 648 | print json.loads( main.ONOS3.intents() ) |
| 649 | if len( json.loads( main.ONOS3.intents() ) ): |
| 650 | removeResult = main.FALSE |
| 651 | step4Result = removeResult |
| 652 | utilities.assert_equals( expect=main.TRUE, |
| 653 | actual=step4Result, |
| 654 | onpass="Successfully removed host intents", |
| 655 | onfail="Failed to remove host intents" ) |
| 656 | case25Result = step1Result and step2Result and step3Result and \ |
| 657 | step4Result |
| 658 | utilities.assert_equals( expect=main.TRUE, |
| 659 | actual=case25Result, |
| 660 | onpass="Add host intent successful", |
| 661 | onfail="Add host intent failed" ) |