shahshreya | 7bf6444 | 2015-04-28 16:28:54 -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 time |
| 10 | import json |
| 11 | |
| 12 | time.sleep( 1 ) |
| 13 | |
| 14 | class IpOpticalMulti: |
| 15 | |
| 16 | def __init__( self ): |
| 17 | self.default = '' |
| 18 | |
| 19 | def CASE1( self, main ): |
| 20 | """ |
| 21 | Startup sequence: |
| 22 | cell <name> |
| 23 | onos-verify-cell |
| 24 | onos-remove-raft-logs |
| 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 | ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 34 | ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 35 | ONOS1Port = main.params[ 'CTRL' ][ 'port1' ] |
| 36 | ONOS2Port = main.params[ 'CTRL' ][ 'port2' ] |
| 37 | ONOS3Port = main.params[ 'CTRL' ][ 'port3' ] |
| 38 | |
| 39 | main.case( "Setting up test environment" ) |
| 40 | main.log.report( |
| 41 | "This testcase is testing setting up test environment" ) |
| 42 | main.log.report( "__________________________________" ) |
| 43 | |
| 44 | main.step( "Applying cell variable to environment" ) |
| 45 | cellResult1 = main.ONOSbench.setCell( cellName ) |
| 46 | # cellResult2 = main.ONOScli1.setCell( cellName ) |
| 47 | # cellResult3 = main.ONOScli2.setCell( cellName ) |
| 48 | # cellResult4 = main.ONOScli3.setCell( cellName ) |
| 49 | verifyResult = main.ONOSbench.verifyCell() |
| 50 | cellResult = cellResult1 |
| 51 | |
| 52 | main.step( "Removing raft logs before a clen installation of ONOS" ) |
| 53 | removeLogResult = main.ONOSbench.onosRemoveRaftLogs() |
| 54 | |
| 55 | main.step( "Git checkout, pull and get version" ) |
| 56 | #main.ONOSbench.gitCheckout( "master" ) |
| 57 | gitPullResult = main.ONOSbench.gitPull() |
| 58 | main.log.info( "git_pull_result = " + str( gitPullResult )) |
| 59 | versionResult = main.ONOSbench.getVersion( report=True ) |
| 60 | |
| 61 | if gitPullResult == 1: |
| 62 | main.step( "Using mvn clean & install" ) |
| 63 | cleanInstallResult = main.ONOSbench.cleanInstall() |
| 64 | # cleanInstallResult = main.TRUE |
| 65 | |
| 66 | main.step( "Creating ONOS package" ) |
| 67 | packageResult = main.ONOSbench.onosPackage() |
| 68 | |
| 69 | # main.step( "Creating a cell" ) |
| 70 | # cellCreateResult = main.ONOSbench.createCellFile( ************** |
| 71 | # ) |
| 72 | |
| 73 | main.step( "Installing ONOS package" ) |
| 74 | onos1InstallResult = main.ONOSbench.onosInstall( |
| 75 | options="-f", |
| 76 | node=ONOS1Ip ) |
| 77 | onos2InstallResult = main.ONOSbench.onosInstall( |
| 78 | options="-f", |
| 79 | node=ONOS2Ip ) |
| 80 | onos3InstallResult = main.ONOSbench.onosInstall( |
| 81 | options="-f", |
| 82 | node=ONOS3Ip ) |
| 83 | onosInstallResult = onos1InstallResult and onos2InstallResult and\ |
| 84 | onos3InstallResult |
| 85 | if onosInstallResult == main.TRUE: |
| 86 | main.log.report( "Installing ONOS package successful" ) |
| 87 | else: |
| 88 | main.log.report( "Installing ONOS package failed" ) |
| 89 | |
| 90 | onos1Isup = main.ONOSbench.isup( ONOS1Ip ) |
| 91 | onos2Isup = main.ONOSbench.isup( ONOS2Ip ) |
| 92 | onos3Isup = main.ONOSbench.isup( ONOS3Ip ) |
| 93 | onosIsup = onos1Isup and onos2Isup and onos3Isup |
| 94 | if onosIsup == main.TRUE: |
| 95 | main.log.report( "ONOS instances are up and ready" ) |
| 96 | else: |
| 97 | main.log.report( "ONOS instances may not be up" ) |
| 98 | |
| 99 | main.step( "Starting ONOS service" ) |
| 100 | startResult = main.TRUE |
| 101 | # startResult = main.ONOSbench.onosStart( ONOS1Ip ) |
| 102 | startcli1 = main.ONOScli1.startOnosCli( ONOSIp=ONOS1Ip ) |
| 103 | startcli2 = main.ONOScli2.startOnosCli( ONOSIp=ONOS2Ip ) |
| 104 | startcli3 = main.ONOScli3.startOnosCli( ONOSIp=ONOS3Ip ) |
| 105 | print startcli1 |
| 106 | print startcli2 |
| 107 | print startcli3 |
| 108 | |
| 109 | case1Result = ( packageResult and |
| 110 | cellResult and verifyResult and onosInstallResult and |
| 111 | onosIsup and startResult ) |
| 112 | utilities.assertEquals( expect=main.TRUE, actual=case1Result, |
| 113 | onpass="Test startup successful", |
| 114 | onfail="Test startup NOT successful" ) |
| 115 | |
| 116 | def CASE10( self ): |
| 117 | import time |
| 118 | main.log.report( |
| 119 | "This testcase uninstalls the reactive forwarding app" ) |
| 120 | main.log.report( "__________________________________" ) |
| 121 | main.case( "Uninstalling reactive forwarding app" ) |
| 122 | # Unistall onos-app-fwd app to disable reactive forwarding |
| 123 | appInstallResult = main.ONOScli1.deactivateApp( "org.onosproject.fwd" ) |
| 124 | appCheck = main.ONOScli1.appToIDCheck() |
| 125 | if appCheck != main.TRUE: |
| 126 | main.log.warn( main.ONOScli1.apps() ) |
| 127 | main.log.warn( main.ONOScli1.appIDs() ) |
| 128 | main.log.info( "onos-app-fwd uninstalled" ) |
| 129 | |
| 130 | # After reactive forwarding is disabled, |
| 131 | # the reactive flows on switches timeout in 10-15s |
| 132 | # So sleep for 15s |
| 133 | time.sleep( 15 ) |
| 134 | |
| 135 | hosts = main.ONOScli1.hosts() |
| 136 | main.log.info( hosts ) |
| 137 | case10Result = appInstallResult |
| 138 | utilities.assertEquals( |
| 139 | expect=main.TRUE, |
| 140 | actual=case10Result, |
| 141 | onpass="Reactive forwarding app uninstallation successful", |
| 142 | onfail="Reactive forwarding app uninstallation failed" ) |
| 143 | |
| 144 | def CASE20( self ): |
| 145 | """ |
| 146 | Exit from mininet cli |
| 147 | reinstall ONOS |
| 148 | """ |
| 149 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 150 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 151 | ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 152 | ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 153 | ONOS1Port = main.params[ 'CTRL' ][ 'port1' ] |
| 154 | ONOS2Port = main.params[ 'CTRL' ][ 'port2' ] |
| 155 | ONOS3Port = main.params[ 'CTRL' ][ 'port3' ] |
| 156 | |
| 157 | main.log.report( "This testcase exits the mininet cli and reinstalls" + |
| 158 | "ONOS to switch over to Packet Optical topology" ) |
| 159 | main.log.report( "_____________________________________________" ) |
| 160 | main.case( "Disconnecting mininet and restarting ONOS" ) |
| 161 | main.step( "Disconnecting mininet and restarting ONOS" ) |
| 162 | mininetDisconnect = main.Mininet1.disconnect() |
| 163 | print "mininetDisconnect = ", mininetDisconnect |
| 164 | |
| 165 | main.step( "Removing raft logs before a clen installation of ONOS" ) |
| 166 | main.ONOSbench.onosRemoveRaftLogs() |
| 167 | |
| 168 | main.step( "Applying cell variable to environment" ) |
| 169 | cellResult = main.ONOSbench.setCell( cellName ) |
| 170 | verifyResult = main.ONOSbench.verifyCell() |
| 171 | |
| 172 | |
| 173 | main.step( "Installing ONOS package" ) |
| 174 | onos1InstallResult = main.ONOSbench.onosInstall( |
| 175 | options="-f", |
| 176 | node=ONOS1Ip ) |
| 177 | onos2InstallResult = main.ONOSbench.onosInstall( |
| 178 | options="-f", |
| 179 | node=ONOS2Ip ) |
| 180 | onos3InstallResult = main.ONOSbench.onosInstall( |
| 181 | options="-f", |
| 182 | node=ONOS3Ip ) |
| 183 | onosInstallResult = onos1InstallResult and onos2InstallResult and\ |
| 184 | onos3InstallResult |
| 185 | if onosInstallResult == main.TRUE: |
| 186 | main.log.report( "Installing ONOS package successful" ) |
| 187 | else: |
| 188 | main.log.report( "Installing ONOS package failed" ) |
| 189 | |
| 190 | onos1Isup = main.ONOSbench.isup( ONOS1Ip ) |
| 191 | onos2Isup = main.ONOSbench.isup( ONOS2Ip ) |
| 192 | onos3Isup = main.ONOSbench.isup( ONOS3Ip ) |
| 193 | onosIsup = onos1Isup and onos2Isup and onos3Isup |
| 194 | if onosIsup == main.TRUE: |
| 195 | main.log.report( "ONOS instances are up and ready" ) |
| 196 | else: |
| 197 | main.log.report( "ONOS instances may not be up" ) |
| 198 | |
| 199 | main.step( "Starting ONOS service" ) |
| 200 | startResult = main.TRUE |
| 201 | # startResult = main.ONOSbench.onosStart( ONOS1Ip ) |
| 202 | startcli1 = main.ONOScli1.startOnosCli( ONOSIp=ONOS1Ip ) |
| 203 | startcli2 = main.ONOScli2.startOnosCli( ONOSIp=ONOS2Ip ) |
| 204 | startcli3 = main.ONOScli3.startOnosCli( ONOSIp=ONOS3Ip ) |
| 205 | startResult = startcli1 and startcli2 and startcli3 |
| 206 | if startResult == main.TRUE: |
| 207 | main.log.report( "ONOS cli starts properly" ) |
| 208 | case20Result = mininetDisconnect and cellResult and verifyResult \ |
| 209 | and onosInstallResult and onosIsup and startResult |
| 210 | |
| 211 | utilities.assert_equals( |
| 212 | expect=main.TRUE, |
| 213 | actual=case20Result, |
| 214 | onpass= "Exiting functionality mininet topology and reinstalling" + |
| 215 | " ONOS successful", |
| 216 | onfail= "Exiting functionality mininet topology and reinstalling" + |
| 217 | " ONOS failed" ) |
| 218 | |
| 219 | def CASE21( self, main ): |
| 220 | """ |
| 221 | On ONOS bench, run this command: |
| 222 | sudo -E python ~/onos/tools/test/topos/opticalTest.py -OC1 <Ctrls> |
| 223 | which spawns packet optical topology and copies the links |
| 224 | json file to the onos instance. |
| 225 | Note that in case of Packet Optical, the links are not learnt |
| 226 | from the topology, instead the links are learnt |
| 227 | from the json config file |
| 228 | """ |
| 229 | main.log.report( |
| 230 | "This testcase starts the packet layer topology and REST" ) |
| 231 | main.log.report( "_____________________________________________" ) |
| 232 | main.case( "Starting LINC-OE and other components" ) |
| 233 | main.step( "Starting LINC-OE and other components" ) |
| 234 | main.log.info( "Activate optical app" ) |
| 235 | appInstallResult = main.ONOScli1.activateApp( "org.onosproject.optical" ) |
| 236 | appCheck = main.ONOScli1.appToIDCheck() |
| 237 | appCheck = appCheck and main.ONOScli2.appToIDCheck() |
| 238 | appCheck = appCheck and main.ONOScli3.appToIDCheck() |
| 239 | if appCheck != main.TRUE: |
| 240 | main.log.warn( "Checking ONOS application unsuccesful" ) |
| 241 | |
| 242 | ctrllerIP = [] |
| 243 | ctrllerIP.append( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 244 | #ctrllerIP.append( main.params[ 'CTRL' ][ 'ip2' ] ) |
| 245 | #ctrllerIP.append( main.params[ 'CTRL' ][ 'ip3' ] ) |
| 246 | opticalMnScript = main.LincOE2.runOpticalMnScript( ctrllerIP = ctrllerIP ) |
| 247 | case21Result = opticalMnScript and appInstallResult |
| 248 | utilities.assert_equals( |
| 249 | expect=main.TRUE, |
| 250 | actual=case21Result, |
| 251 | onpass="Packet optical topology spawned successsfully", |
| 252 | onfail="Packet optical topology spawning failed" ) |
| 253 | |
| 254 | def CASE22( self, main ): |
| 255 | """ |
| 256 | Curretly we use, 10 optical switches(ROADM's) and |
| 257 | 6 packet layer mininet switches each with one host. |
| 258 | Therefore, the roadmCount variable = 10, |
| 259 | packetLayerSWCount variable = 6, hostCount=6 and |
| 260 | links=42. |
| 261 | All this is hardcoded in the testcase. If the topology changes, |
| 262 | these hardcoded values need to be changed |
| 263 | """ |
| 264 | main.log.report( |
| 265 | "This testcase compares the optical+packet topology against what" + |
| 266 | " is expected" ) |
| 267 | main.case( "Topology comparision" ) |
| 268 | main.step( "Topology comparision" ) |
| 269 | devicesResult = main.ONOScli3.devices( jsonFormat=False ) |
| 270 | |
| 271 | print "devices_result = ", devicesResult |
| 272 | devicesLinewise = devicesResult.split( "\n" ) |
| 273 | roadmCount = 0 |
| 274 | packetLayerSWCount = 0 |
| 275 | for line in devicesLinewise: |
| 276 | components = line.split( "," ) |
| 277 | availability = components[ 1 ].split( "=" )[ 1 ] |
| 278 | type = components[ 3 ].split( "=" )[ 1 ] |
| 279 | if availability == 'true' and type == 'ROADM': |
| 280 | roadmCount += 1 |
| 281 | elif availability == 'true' and type == 'SWITCH': |
| 282 | packetLayerSWCount += 1 |
| 283 | if roadmCount == 10: |
| 284 | print "Number of Optical Switches = %d and is" % roadmCount +\ |
| 285 | " correctly detected" |
| 286 | main.log.info( |
| 287 | "Number of Optical Switches = " + |
| 288 | str( roadmCount ) + |
| 289 | " and is correctly detected" ) |
| 290 | opticalSWResult = main.TRUE |
| 291 | else: |
| 292 | print "Number of Optical Switches = %d and is wrong" % roadmCount |
| 293 | main.log.info( |
| 294 | "Number of Optical Switches = " + |
| 295 | str( roadmCount ) + |
| 296 | " and is wrong" ) |
| 297 | opticalSWResult = main.FALSE |
| 298 | |
| 299 | if packetLayerSWCount == 6: |
| 300 | print "Number of Packet layer or mininet Switches = %d "\ |
| 301 | % packetLayerSWCount + "and is correctly detected" |
| 302 | main.log.info( |
| 303 | "Number of Packet layer or mininet Switches = " + |
| 304 | str( packetLayerSWCount ) + |
| 305 | " and is correctly detected" ) |
| 306 | packetSWResult = main.TRUE |
| 307 | else: |
| 308 | print "Number of Packet layer or mininet Switches = %d and"\ |
| 309 | % packetLayerSWCount + " is wrong" |
| 310 | main.log.info( |
| 311 | "Number of Packet layer or mininet Switches = " + |
| 312 | str( packetLayerSWCount ) + |
| 313 | " and is wrong" ) |
| 314 | packetSWResult = main.FALSE |
| 315 | print "_________________________________" |
| 316 | |
| 317 | linksResult = main.ONOScli3.links( jsonFormat=False ) |
| 318 | print "links_result = ", linksResult |
| 319 | print "_________________________________" |
| 320 | linkActiveCount = linksResult.count("state=ACTIVE") |
| 321 | main.log.info( "linkActiveCount = " + str( linkActiveCount )) |
| 322 | if linkActiveCount == 42: |
| 323 | linkActiveResult = main.TRUE |
| 324 | main.log.info( |
| 325 | "Number of links in ACTIVE state are correct") |
| 326 | else: |
| 327 | linkActiveResult = main.FALSE |
| 328 | main.log.info( |
| 329 | "Number of links in ACTIVE state are wrong") |
| 330 | |
| 331 | case22Result = opticalSWResult and packetSWResult and \ |
| 332 | linkActiveResult |
| 333 | utilities.assert_equals( |
| 334 | expect=main.TRUE, |
| 335 | actual=case22Result, |
| 336 | onpass="Packet optical topology discovery successful", |
| 337 | onfail="Packet optical topology discovery failed" ) |
| 338 | |
| 339 | def CASE23( self, main ): |
| 340 | import time |
| 341 | """ |
| 342 | Add bidirectional point intents between 2 packet layer( mininet ) |
| 343 | devices and |
| 344 | ping mininet hosts |
| 345 | """ |
| 346 | main.log.report( |
| 347 | "This testcase adds bidirectional point intents between 2 " + |
| 348 | "packet layer( mininet ) devices and ping mininet hosts" ) |
| 349 | main.case( "Topology comparision" ) |
| 350 | main.step( "Adding point intents" ) |
| 351 | ptpIntentResult = main.ONOScli1.addPointIntent( |
| 352 | "of:0000ffffffff0001/1", |
| 353 | "of:0000ffffffff0005/1" ) |
| 354 | if ptpIntentResult == main.TRUE: |
| 355 | main.ONOScli1.intents( jsonFormat=False ) |
| 356 | main.log.info( "Point to point intent install successful" ) |
| 357 | |
| 358 | ptpIntentResult = main.ONOScli1.addPointIntent( |
| 359 | "of:0000ffffffff0005/1", |
| 360 | "of:0000ffffffff0001/1" ) |
| 361 | if ptpIntentResult == main.TRUE: |
| 362 | main.ONOScli1.intents( jsonFormat=False ) |
| 363 | main.log.info( "Point to point intent install successful" ) |
| 364 | |
| 365 | time.sleep( 30 ) |
| 366 | flowHandle = main.ONOScli1.flows() |
| 367 | main.log.info( "flows :" + flowHandle ) |
| 368 | |
| 369 | # Sleep for 30 seconds to provide time for the intent state to change |
| 370 | time.sleep( 60 ) |
| 371 | intentHandle = main.ONOScli1.intents( jsonFormat=False ) |
| 372 | main.log.info( "intents :" + intentHandle ) |
| 373 | |
| 374 | PingResult = main.TRUE |
| 375 | count = 1 |
| 376 | main.log.info( "\n\nh1 is Pinging h5" ) |
| 377 | ping = main.LincOE2.pingHostOptical( src="h1", target="h5" ) |
| 378 | # ping = main.LincOE2.pinghost() |
| 379 | if ping == main.FALSE and count < 5: |
| 380 | count += 1 |
| 381 | PingResult = main.FALSE |
| 382 | main.log.info( |
| 383 | "Ping between h1 and h5 failed. Making attempt number " + |
| 384 | str( count ) + |
| 385 | " in 2 seconds" ) |
| 386 | time.sleep( 2 ) |
| 387 | elif ping == main.FALSE: |
| 388 | main.log.info( "All ping attempts between h1 and h5 have failed" ) |
| 389 | PingResult = main.FALSE |
| 390 | elif ping == main.TRUE: |
| 391 | main.log.info( "Ping test between h1 and h5 passed!" ) |
| 392 | PingResult = main.TRUE |
| 393 | else: |
| 394 | main.log.info( "Unknown error" ) |
| 395 | PingResult = main.ERROR |
| 396 | |
| 397 | if PingResult == main.FALSE: |
| 398 | main.log.report( |
| 399 | "Point intents for packet optical have not ben installed" + |
| 400 | " correctly. Cleaning up" ) |
| 401 | if PingResult == main.TRUE: |
| 402 | main.log.report( |
| 403 | "Point Intents for packet optical have been " + |
| 404 | "installed correctly" ) |
| 405 | |
| 406 | case23Result = PingResult |
| 407 | utilities.assert_equals( |
| 408 | expect=main.TRUE, |
| 409 | actual=case23Result, |
| 410 | onpass= "Point intents addition for packet optical and" + |
| 411 | "Pingall Test successful", |
| 412 | onfail= "Point intents addition for packet optical and" + |
| 413 | "Pingall Test NOT successful" ) |
| 414 | |
| 415 | def CASE24( self, main ): |
| 416 | import time |
| 417 | import json |
| 418 | """ |
| 419 | LINC uses its own switch IDs. You can use the following |
| 420 | command on the LINC console to find the mapping between |
| 421 | DPIDs and LINC IDs. |
| 422 | rp(application:get_all_key(linc)). |
| 423 | |
| 424 | Test Rerouting of Packet Optical by bringing a port down |
| 425 | ( port 20 ) of a switch( switchID=1, or LincOE switchID =9 ), |
| 426 | so that link |
| 427 | ( between switch1 port20 - switch5 port50 ) is inactive |
| 428 | and do a ping test. If rerouting is successful, |
| 429 | ping should pass. also check the flows |
| 430 | """ |
| 431 | main.log.report( |
| 432 | "This testcase tests rerouting and pings mininet hosts" ) |
| 433 | main.case( "Test rerouting and pings mininet hosts" ) |
| 434 | main.step( "Attach to the Linc-OE session" ) |
| 435 | attachConsole = main.LincOE1.attachLincOESession() |
| 436 | print "attachConsole = ", attachConsole |
| 437 | |
| 438 | main.step( "Bring a port down and verify the link state" ) |
| 439 | main.LincOE1.portDown( swId="9", ptId="20" ) |
| 440 | linksNonjson = main.ONOScli3.links( jsonFormat=False ) |
| 441 | main.log.info( "links = " + linksNonjson ) |
| 442 | |
| 443 | linkInactiveCount = linksNonjson.count("state=INACTIVE") |
| 444 | main.log.info( "linkInactiveCount = " + str( linkInactiveCount )) |
| 445 | if linkInactiveCount == 2: |
| 446 | main.log.info( |
| 447 | "Number of links in INACTIVE state are correct") |
| 448 | else: |
| 449 | main.log.info( |
| 450 | "Number of links in INACTIVE state are wrong") |
| 451 | |
| 452 | links = main.ONOScli3.links() |
| 453 | main.log.info( "links = " + links ) |
| 454 | |
| 455 | linksResult = json.loads( links ) |
| 456 | linksStateResult = main.FALSE |
| 457 | for item in linksResult: |
| 458 | if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[ |
| 459 | 'src' ][ 'port' ] == "20": |
| 460 | if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff05" and item[ |
| 461 | 'dst' ][ 'port' ] == "50": |
| 462 | linksState = item[ 'state' ] |
| 463 | if linksState == "INACTIVE": |
| 464 | main.log.info( |
| 465 | "Links state is inactive as expected due to one" + |
| 466 | " of the ports being down" ) |
| 467 | main.log.report( |
| 468 | "Links state is inactive as expected due to one" + |
| 469 | " of the ports being down" ) |
| 470 | linksStateResult = main.TRUE |
| 471 | break |
| 472 | else: |
| 473 | main.log.info( |
| 474 | "Links state is not inactive as expected" ) |
| 475 | main.log.report( |
| 476 | "Links state is not inactive as expected" ) |
| 477 | linksStateResult = main.FALSE |
| 478 | |
| 479 | print "links_state_result = ", linksStateResult |
| 480 | time.sleep( 10 ) |
| 481 | flowHandle = main.ONOScli3.flows() |
| 482 | main.log.info( "flows :" + flowHandle ) |
| 483 | |
| 484 | main.step( "Verify Rerouting by a ping test" ) |
| 485 | PingResult = main.TRUE |
| 486 | count = 1 |
| 487 | main.log.info( "\n\nh1 is Pinging h5" ) |
| 488 | ping = main.LincOE2.pingHostOptical( src="h1", target="h5" ) |
| 489 | # ping = main.LincOE2.pinghost() |
| 490 | if ping == main.FALSE and count < 5: |
| 491 | count += 1 |
| 492 | PingResult = main.FALSE |
| 493 | main.log.info( |
| 494 | "Ping between h1 and h5 failed. Making attempt number " + |
| 495 | str( count ) + |
| 496 | " in 2 seconds" ) |
| 497 | time.sleep( 2 ) |
| 498 | elif ping == main.FALSE: |
| 499 | main.log.info( "All ping attempts between h1 and h5 have failed" ) |
| 500 | PingResult = main.FALSE |
| 501 | elif ping == main.TRUE: |
| 502 | main.log.info( "Ping test between h1 and h5 passed!" ) |
| 503 | PingResult = main.TRUE |
| 504 | else: |
| 505 | main.log.info( "Unknown error" ) |
| 506 | PingResult = main.ERROR |
| 507 | |
| 508 | if PingResult == main.TRUE: |
| 509 | main.log.report( "Ping test successful " ) |
| 510 | if PingResult == main.FALSE: |
| 511 | main.log.report( "Ping test failed" ) |
| 512 | |
| 513 | case24Result = PingResult and linksStateResult |
| 514 | utilities.assert_equals( expect=main.TRUE, actual=case24Result, |
| 515 | onpass="Packet optical rerouting successful", |
| 516 | onfail="Packet optical rerouting failed" ) |
| 517 | |
| 518 | def CASE25( self ): |
| 519 | """ |
| 520 | Add host intents between 2 packet layer host |
| 521 | """ |
| 522 | import time |
| 523 | import json |
| 524 | main.log.report( "Adding host intents between 2 packet layer host" ) |
| 525 | main.hostMACs = [] |
| 526 | main.hostId = [] |
| 527 | #Listing host MAC addresses |
| 528 | for i in range( 1 , 7 ): |
| 529 | main.hostMACs.append( "00:00:00:00:00:" + |
| 530 | str( hex( i )[ 2: ] ).zfill( 2 ).upper() ) |
| 531 | for macs in main.hostMACs: |
| 532 | main.hostId.append( macs + "/-1" ) |
| 533 | |
| 534 | host1 = main.hostId[ 0 ] |
| 535 | host2 = main.hostId[ 1 ] |
| 536 | intentsId = [] |
| 537 | # Use arping to discover the hosts |
| 538 | main.LincOE2.arping( host = "h1" ) |
| 539 | main.LincOE2.arping( host = "h2" ) |
| 540 | # Adding host intent |
| 541 | main.log.step( "Adding host intents to h1 and h2" ) |
| 542 | intent1 = main.ONOScli1.addHostIntent( hostIdOne = host1, |
| 543 | hostIdTwo = host2 ) |
| 544 | intentsId.append( intent1 ) |
| 545 | time.sleep( 5 ) |
| 546 | intent2 = main.ONOScli1.addHostIntent( hostIdOne = host2, |
| 547 | hostIdTwo = host1 ) |
| 548 | intentsId.append( intent2 ) |
| 549 | # Checking intents state before pinging |
| 550 | main.log.step( "Checking intents state" ) |
| 551 | time.sleep( 10 ) |
| 552 | intentResult = main.ONOScli1.checkIntentState( intentsId = intentsId ) |
| 553 | utilities.assert_equals( expect=main.TRUE, actual=intentResult, |
| 554 | onpass="All intents are in INSTALLED state ", |
| 555 | onfail="Some of the intents are not in " + |
| 556 | "INSTALLED state " ) |
| 557 | |
| 558 | # pinging h1 to h2 and then ping h2 to h1 |
| 559 | main.log.step( "Pinging h1 and h2" ) |
| 560 | pingResult = main.TRUE |
| 561 | pingResult = main.LincOE2.pingHostOptical( src="h1", target="h2" ) |
| 562 | pingResult = pingResult and main.LincOE2.pingHostOptical( src="h2", |
| 563 | target="h1" ) |
| 564 | |
| 565 | utilities.assert_equals( expect=main.TRUE, actual=pingResult, |
| 566 | onpass="Pinged successfully between h1 and h2", |
| 567 | onfail="Pinged failed between h1 and h2" ) |
| 568 | |
| 569 | case25Result = pingResult |
| 570 | utilities.assert_equals( expect=main.TRUE, actual=case25Result, |
| 571 | onpass="Add host intent successful", |
| 572 | onfail="Add host intent failed" ) |