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