Package TestON :: Package tests :: Package FUNCintent :: Module FUNCintent
[hide private]
[frames] | no frames]

Source Code for Module TestON.tests.FUNCintent.FUNCintent

   1  # Testing the basic intent functionality of ONOS 
   2   
3 -class FUNCintent:
4
5 - def __init__( self ):
6 self.default = ''
7
8 - def CASE1( self, main ):
9 import time 10 import os 11 import imp 12 import re 13 14 """ 15 - Construct tests variables 16 - GIT ( optional ) 17 - Checkout ONOS master branch 18 - Pull latest ONOS code 19 - Building ONOS ( optional ) 20 - Install ONOS package 21 - Build ONOS package 22 """ 23 24 main.case( "Constructing test variables and building ONOS package" ) 25 main.step( "Constructing test variables" ) 26 main.caseExplanation = "This test case is mainly for loading " +\ 27 "from params file, and pull and build the " +\ 28 " latest ONOS package" 29 stepResult = main.FALSE 30 31 # Test variables 32 try: 33 main.testOnDirectory = re.sub( "(/tests)$", "", main.testDir ) 34 main.apps = main.params[ 'ENV' ][ 'cellApps' ] 35 gitBranch = main.params[ 'GIT' ][ 'branch' ] 36 main.dependencyPath = main.testOnDirectory + \ 37 main.params[ 'DEPENDENCY' ][ 'path' ] 38 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ] 39 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," ) 40 if main.ONOSbench.maxNodes: 41 main.maxNodes = int( main.ONOSbench.maxNodes ) 42 else: 43 main.maxNodes = 0 44 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] 45 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ] 46 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ] 47 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] ) 48 main.checkIntentSleep = int( main.params[ 'SLEEP' ][ 'checkintent' ] ) 49 main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] ) 50 main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] ) 51 gitPull = main.params[ 'GIT' ][ 'pull' ] 52 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] ) 53 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] ) 54 main.cellData = {} # for creating cell file 55 main.hostsData = {} 56 main.CLIs = [] 57 main.ONOSip = [] 58 59 main.ONOSip = main.ONOSbench.getOnosIps() 60 print main.ONOSip 61 62 # Assigning ONOS cli handles to a list 63 for i in range( 1, main.maxNodes + 1 ): 64 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) ) 65 66 # -- INIT SECTION, ONLY RUNS ONCE -- # 67 main.startUp = imp.load_source( wrapperFile1, 68 main.dependencyPath + 69 wrapperFile1 + 70 ".py" ) 71 72 main.intentFunction = imp.load_source( wrapperFile2, 73 main.dependencyPath + 74 wrapperFile2 + 75 ".py" ) 76 77 main.topo = imp.load_source( wrapperFile3, 78 main.dependencyPath + 79 wrapperFile3 + 80 ".py" ) 81 82 copyResult = main.ONOSbench.copyMininetFile( main.topology, 83 main.dependencyPath, 84 main.Mininet1.user_name, 85 main.Mininet1.ip_address ) 86 if main.CLIs: 87 stepResult = main.TRUE 88 else: 89 main.log.error( "Did not properly created list of ONOS CLI handle" ) 90 stepResult = main.FALSE 91 except Exception as e: 92 main.log.exception(e) 93 main.cleanup() 94 main.exit() 95 96 utilities.assert_equals( expect=main.TRUE, 97 actual=stepResult, 98 onpass="Successfully construct " + 99 "test variables ", 100 onfail="Failed to construct test variables" ) 101 102 if gitPull == 'True': 103 main.step( "Building ONOS in " + gitBranch + " branch" ) 104 onosBuildResult = main.startUp.onosBuild( main, gitBranch ) 105 stepResult = onosBuildResult 106 utilities.assert_equals( expect=main.TRUE, 107 actual=stepResult, 108 onpass="Successfully compiled " + 109 "latest ONOS", 110 onfail="Failed to compile " + 111 "latest ONOS" ) 112 else: 113 main.log.warn( "Did not pull new code so skipping mvn " + 114 "clean install" ) 115 main.ONOSbench.getVersion( report=True )
116
117 - def CASE2( self, main ):
118 """ 119 - Set up cell 120 - Create cell file 121 - Set cell file 122 - Verify cell file 123 - Kill ONOS process 124 - Uninstall ONOS cluster 125 - Verify ONOS start up 126 - Install ONOS cluster 127 - Connect to cli 128 """ 129 130 # main.scale[ 0 ] determines the current number of ONOS controller 131 main.numCtrls = int( main.scale[ 0 ] ) 132 133 main.case( "Starting up " + str( main.numCtrls ) + 134 " node(s) ONOS cluster" ) 135 main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\ 136 " node(s) ONOS cluster" 137 138 139 140 #kill off all onos processes 141 main.log.info( "Safety check, killing all ONOS processes" + 142 " before initiating enviornment setup" ) 143 144 for i in range( main.maxNodes ): 145 main.ONOSbench.onosDie( main.ONOSip[ i ] ) 146 147 print "NODE COUNT = ", main.numCtrls 148 149 tempOnosIp = [] 150 for i in range( main.numCtrls ): 151 tempOnosIp.append( main.ONOSip[i] ) 152 153 main.ONOSbench.createCellFile( main.ONOSbench.ip_address, 154 "temp", main.Mininet1.ip_address, 155 main.apps, tempOnosIp ) 156 157 main.step( "Apply cell to environment" ) 158 cellResult = main.ONOSbench.setCell( "temp" ) 159 verifyResult = main.ONOSbench.verifyCell() 160 stepResult = cellResult and verifyResult 161 utilities.assert_equals( expect=main.TRUE, 162 actual=stepResult, 163 onpass="Successfully applied cell to " + \ 164 "environment", 165 onfail="Failed to apply cell to environment " ) 166 167 main.step( "Creating ONOS package" ) 168 packageResult = main.ONOSbench.onosPackage() 169 stepResult = packageResult 170 utilities.assert_equals( expect=main.TRUE, 171 actual=stepResult, 172 onpass="Successfully created ONOS package", 173 onfail="Failed to create ONOS package" ) 174 175 time.sleep( main.startUpSleep ) 176 main.step( "Uninstalling ONOS package" ) 177 onosUninstallResult = main.TRUE 178 for ip in main.ONOSip: 179 onosUninstallResult = onosUninstallResult and \ 180 main.ONOSbench.onosUninstall( nodeIp=ip ) 181 stepResult = onosUninstallResult 182 utilities.assert_equals( expect=main.TRUE, 183 actual=stepResult, 184 onpass="Successfully uninstalled ONOS package", 185 onfail="Failed to uninstall ONOS package" ) 186 187 time.sleep( main.startUpSleep ) 188 main.step( "Installing ONOS package" ) 189 onosInstallResult = main.TRUE 190 for i in range( main.numCtrls ): 191 onosInstallResult = onosInstallResult and \ 192 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] ) 193 stepResult = onosInstallResult 194 utilities.assert_equals( expect=main.TRUE, 195 actual=stepResult, 196 onpass="Successfully installed ONOS package", 197 onfail="Failed to install ONOS package" ) 198 199 time.sleep( main.startUpSleep ) 200 main.step( "Starting ONOS service" ) 201 stopResult = main.TRUE 202 startResult = main.TRUE 203 onosIsUp = main.TRUE 204 205 for i in range( main.numCtrls ): 206 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] ) 207 if onosIsUp == main.TRUE: 208 main.log.report( "ONOS instance is up and ready" ) 209 else: 210 main.log.report( "ONOS instance may not be up, stop and " + 211 "start ONOS again " ) 212 for i in range( main.numCtrls ): 213 stopResult = stopResult and \ 214 main.ONOSbench.onosStop( main.ONOSip[ i ] ) 215 for i in range( main.numCtrls ): 216 startResult = startResult and \ 217 main.ONOSbench.onosStart( main.ONOSip[ i ] ) 218 stepResult = onosIsUp and stopResult and startResult 219 utilities.assert_equals( expect=main.TRUE, 220 actual=stepResult, 221 onpass="ONOS service is ready", 222 onfail="ONOS service did not start properly" ) 223 224 main.step( "Start ONOS cli" ) 225 cliResult = main.TRUE 226 for i in range( main.numCtrls ): 227 cliResult = cliResult and \ 228 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] ) 229 stepResult = cliResult 230 utilities.assert_equals( expect=main.TRUE, 231 actual=stepResult, 232 onpass="Successfully start ONOS cli", 233 onfail="Failed to start ONOS cli" ) 234 235 # Remove the first element in main.scale list 236 main.scale.remove( main.scale[ 0 ] )
237
238 - def CASE8( self, main ):
239 """ 240 Compare Topo 241 """ 242 import json 243 244 main.case( "Compare ONOS Topology view to Mininet topology" ) 245 main.caseExplanation = "Compare topology elements between Mininet" +\ 246 " and ONOS" 247 248 main.step( "Gathering topology information" ) 249 # TODO: add a paramaterized sleep here 250 devicesResults = main.TRUE 251 linksResults = main.TRUE 252 hostsResults = main.TRUE 253 devices = main.topo.getAllDevices( main ) 254 hosts = main.topo.getAllHosts( main ) 255 ports = main.topo.getAllPorts( main ) 256 links = main.topo.getAllLinks( main ) 257 clusters = main.topo.getAllClusters( main ) 258 259 mnSwitches = main.Mininet1.getSwitches() 260 mnLinks = main.Mininet1.getLinks() 261 mnHosts = main.Mininet1.getHosts() 262 263 main.step( "Conmparing MN topology to ONOS topology" ) 264 for controller in range( main.numCtrls ): 265 controllerStr = str( controller + 1 ) 266 if devices[ controller ] and ports[ controller ] and\ 267 "Error" not in devices[ controller ] and\ 268 "Error" not in ports[ controller ]: 269 270 currentDevicesResult = main.Mininet1.compareSwitches( 271 mnSwitches, 272 json.loads( devices[ controller ] ), 273 json.loads( ports[ controller ] ) ) 274 else: 275 currentDevicesResult = main.FALSE 276 utilities.assert_equals( expect=main.TRUE, 277 actual=currentDevicesResult, 278 onpass="ONOS" + controllerStr + 279 " Switches view is correct", 280 onfail="ONOS" + controllerStr + 281 " Switches view is incorrect" ) 282 devicesResults = devicesResults and currentDevicesResult 283 284 if links[ controller ] and "Error" not in links[ controller ]: 285 currentLinksResult = main.Mininet1.compareLinks( 286 mnSwitches, mnLinks, 287 json.loads( links[ controller ] ) ) 288 else: 289 currentLinksResult = main.FALSE 290 utilities.assert_equals( expect=main.TRUE, 291 actual=currentLinksResult, 292 onpass="ONOS" + controllerStr + 293 " links view is correct", 294 onfail="ONOS" + controllerStr + 295 " links view is incorrect" ) 296 linksResults = linksResults and currentLinksResult 297 298 if hosts[ controller ] or "Error" not in hosts[ controller ]: 299 currentHostsResult = main.Mininet1.compareHosts( 300 mnHosts, 301 json.loads( hosts[ controller ] ) ) 302 else: 303 currentHostsResult = main.FALSE 304 utilities.assert_equals( expect=main.TRUE, 305 actual=currentHostsResult, 306 onpass="ONOS" + controllerStr + 307 " hosts exist in Mininet", 308 onfail="ONOS" + controllerStr + 309 " hosts don't match Mininet" ) 310 hostsResults = hostsResults and currentHostsResult 311 topoResults = hostsResults and linksResults and devicesResults 312 utilities.assert_equals( expect=main.TRUE, 313 actual=topoResults, 314 onpass="ONOS correctly discovered the topology", 315 onfail="ONOS incorrectly discovered the topology" )
316 317
318 - def CASE9( self, main ):
319 ''' 320 Report errors/warnings/exceptions 321 ''' 322 main.case( main.testName + " Report - " + str( main.numCtrls ) + 323 " NODE(S) - OF " + main.OFProtocol ) 324 325 main.ONOSbench.logReport( main.ONOSip[ 0 ], 326 [ "INFO", 327 "FOLLOWER", 328 "WARN", 329 "flow", 330 "ERROR", 331 "Except" ], 332 "s" ) 333 334 main.step( "ERROR report: \n" ) 335 for i in range( main.numCtrls ): 336 main.ONOSbench.logReport( main.ONOSip[ i ], 337 [ "ERROR" ], 338 "d" ) 339 340 main.step( "EXCEPTIONS report: \n" ) 341 for i in range( main.numCtrls ): 342 main.ONOSbench.logReport( main.ONOSip[ i ], 343 [ "Except" ], 344 "d" ) 345 346 main.step( "WARNING report: \n" ) 347 for i in range( main.numCtrls ): 348 main.ONOSbench.logReport( main.ONOSip[ i ], 349 [ "WARN" ], 350 "d" )
351
352 - def CASE10( self, main ):
353 """ 354 Start Mininet topology with OF 1.0 switches 355 """ 356 main.OFProtocol = "1.0" 357 main.log.report( "Start Mininet topology with OF 1.0 switches" ) 358 main.case( "Start Mininet topology with OF 1.0 switches" ) 359 main.caseExplanation = "Start mininet topology with OF 1.0 " +\ 360 "switches to test intents, exits out if " +\ 361 "topology did not start correctly" 362 363 main.step( "Starting Mininet topology with OF 1.0 switches" ) 364 args = "--switch ovs,protocols=OpenFlow10" 365 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath + 366 main.topology, 367 args=args ) 368 stepResult = topoResult 369 utilities.assert_equals( expect=main.TRUE, 370 actual=stepResult, 371 onpass="Successfully loaded topology", 372 onfail="Failed to load topology" ) 373 # Exit if topology did not load properly 374 if not topoResult: 375 main.cleanup() 376 main.exit()
377
378 - def CASE11( self, main ):
379 """ 380 Start Mininet topology with OF 1.3 switches 381 """ 382 main.OFProtocol = "1.3" 383 main.log.report( "Start Mininet topology with OF 1.3 switches" ) 384 main.case( "Start Mininet topology with OF 1.3 switches" ) 385 main.caseExplanation = "Start mininet topology with OF 1.3 " +\ 386 "switches to test intents, exits out if " +\ 387 "topology did not start correctly" 388 389 main.step( "Starting Mininet topology with OF 1.3 switches" ) 390 args = "--switch ovs,protocols=OpenFlow13" 391 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath + 392 main.topology, 393 args=args ) 394 stepResult = topoResult 395 utilities.assert_equals( expect=main.TRUE, 396 actual=stepResult, 397 onpass="Successfully loaded topology", 398 onfail="Failed to load topology" ) 399 # Exit if topology did not load properly 400 if not topoResult: 401 main.cleanup() 402 main.exit()
403
404 - def CASE12( self, main ):
405 """ 406 Assign mastership to controllers 407 """ 408 import re 409 410 main.case( "Assign switches to controllers" ) 411 main.step( "Assigning switches to controllers" ) 412 main.caseExplanation = "Assign OF " + main.OFProtocol +\ 413 " switches to ONOS nodes" 414 415 assignResult = main.TRUE 416 switchList = [] 417 418 # Creates a list switch name, use getSwitch() function later... 419 for i in range( 1, ( main.numSwitch + 1 ) ): 420 switchList.append( 's' + str( i ) ) 421 422 tempONOSip = [] 423 for i in range( main.numCtrls ): 424 tempONOSip.append( main.ONOSip[ i ] ) 425 426 assignResult = main.Mininet1.assignSwController( sw=switchList, 427 ip=tempONOSip, 428 port='6633' ) 429 if not assignResult: 430 main.cleanup() 431 main.exit() 432 433 for i in range( 1, ( main.numSwitch + 1 ) ): 434 response = main.Mininet1.getSwController( "s" + str( i ) ) 435 print( "Response is " + str( response ) ) 436 if re.search( "tcp:" + main.ONOSip[ 0 ], response ): 437 assignResult = assignResult and main.TRUE 438 else: 439 assignResult = main.FALSE 440 stepResult = assignResult 441 utilities.assert_equals( expect=main.TRUE, 442 actual=stepResult, 443 onpass="Successfully assigned switches" + 444 "to controller", 445 onfail="Failed to assign switches to " + 446 "controller" )
447 - def CASE13( self, main ):
448 """ 449 Discover all hosts and store its data to a dictionary 450 """ 451 main.case( "Discover all hosts" ) 452 453 stepResult = main.TRUE 454 main.step( "Discover all hosts using pingall " ) 455 stepResult = main.intentFunction.getHostsData( main ) 456 utilities.assert_equals( expect=main.TRUE, 457 actual=stepResult, 458 onpass="Successfully discovered hosts", 459 onfail="Failed to discover hosts" )
460
461 - def CASE14( self, main ):
462 """ 463 Stop mininet 464 """ 465 main.log.report( "Stop Mininet topology" ) 466 main.case( "Stop Mininet topology" ) 467 main.caseExplanation = "Stopping the current mininet topology " +\ 468 "to start up fresh" 469 470 main.step( "Stopping Mininet Topology" ) 471 topoResult = main.Mininet1.stopNet( ) 472 stepResult = topoResult 473 utilities.assert_equals( expect=main.TRUE, 474 actual=stepResult, 475 onpass="Successfully stop mininet", 476 onfail="Failed to stop mininet" ) 477 # Exit if topology did not load properly 478 if not topoResult: 479 main.cleanup() 480 main.exit()
481
482 - def CASE1000( self, main ):
483 """ 484 Add host intents between 2 host: 485 - Discover hosts 486 - Add host intents 487 - Check intents 488 - Verify flows 489 - Ping hosts 490 - Reroute 491 - Link down 492 - Verify flows 493 - Check topology 494 - Ping hosts 495 - Link up 496 - Verify flows 497 - Check topology 498 - Ping hosts 499 - Remove intents 500 """ 501 import time 502 import json 503 import re 504 505 # Assert variables - These variable's name|format must be followed 506 # if you want to use the wrapper function 507 assert main, "There is no main" 508 assert main.CLIs, "There is no main.CLIs" 509 assert main.Mininet1, "Mininet handle should be named Mininet1" 510 assert main.numSwitch, "Placed the total number of switch topology in \ 511 main.numSwitch" 512 513 intentLeadersOld = main.CLIs[ 0 ].leaderCandidates() 514 515 main.testName = "Host Intents" 516 main.case( main.testName + " Test - " + str( main.numCtrls ) + 517 " NODE(S) - OF " + main.OFProtocol ) 518 main.caseExplanation = "This test case tests Host intents using " +\ 519 str( main.numCtrls ) + " node(s) cluster;\n" +\ 520 "Different type of hosts will be tested in " +\ 521 "each step such as IPV4, Dual stack, VLAN " +\ 522 "etc;\nThe test will use OF " + main.OFProtocol\ 523 + " OVS running in Mininet" 524 525 main.step( "IPV4: Add host intents between h1 and h9" ) 526 stepResult = main.TRUE 527 stepResult = main.intentFunction.hostIntent( main, 528 onosNode='0', 529 name='IPV4', 530 host1='h1', 531 host2='h9', 532 host1Id='00:00:00:00:00:01/-1', 533 host2Id='00:00:00:00:00:09/-1', 534 sw1='s5', 535 sw2='s2', 536 expectedLink=18 ) 537 538 utilities.assert_equals( expect=main.TRUE, 539 actual=stepResult, 540 onpass="IPV4: Host intent test successful " + 541 "between two IPV4 hosts", 542 onfail="IPV4: Host intent test failed " + 543 "between two IPV4 hosts") 544 545 main.step( "DUALSTACK1: Add host intents between h3 and h11" ) 546 stepResult = main.TRUE 547 stepResult = main.intentFunction.hostIntent( main, 548 name='DUALSTACK', 549 host1='h3', 550 host2='h11', 551 host1Id='00:00:00:00:00:03/-1', 552 host2Id='00:00:00:00:00:0B/-1', 553 sw1='s5', 554 sw2='s2', 555 expectedLink=18 ) 556 557 utilities.assert_equals( expect=main.TRUE, 558 actual=stepResult, 559 onpass="DUALSTACK: Host intent test " + 560 "successful between two " + 561 "dual stack host using IPV4", 562 onfail="DUALSTACK: Host intent test " + 563 "failed between two" + 564 "dual stack host using IPV4" ) 565 566 567 main.step( "DUALSTACK2: Add host intents between h1 and h11" ) 568 stepResult = main.TRUE 569 stepResult = main.intentFunction.hostIntent( main, 570 name='DUALSTACK2', 571 host1='h1', 572 host2='h11', 573 sw1='s5', 574 sw2='s2', 575 expectedLink=18 ) 576 577 utilities.assert_equals( expect=main.TRUE, 578 actual=stepResult, 579 onpass="DUALSTACK2: Host intent test " + 580 "successful between two " + 581 "dual stack host using IPV4", 582 onfail="DUALSTACK2: Host intent test " + 583 "failed between two" + 584 "dual stack host using IPV4" ) 585 586 main.step( "1HOP: Add host intents between h1 and h3" ) 587 stepResult = main.TRUE 588 stepResult = main.intentFunction.hostIntent( main, 589 name='1HOP', 590 host1='h1', 591 host2='h3' ) 592 593 utilities.assert_equals( expect=main.TRUE, 594 actual=stepResult, 595 onpass="1HOP: Host intent test " + 596 "successful between two " + 597 "host using IPV4 in the same switch", 598 onfail="1HOP: Host intent test " + 599 "failed between two" + 600 "host using IPV4 in the same switch" ) 601 602 main.step( "VLAN1: Add vlan host intents between h4 and h12" ) 603 stepResult = main.TRUE 604 stepResult = main.intentFunction.hostIntent( main, 605 name='VLAN1', 606 host1='h4', 607 host2='h12', 608 host1Id='00:00:00:00:00:04/100', 609 host2Id='00:00:00:00:00:0C/100', 610 sw1='s5', 611 sw2='s2', 612 expectedLink=18 ) 613 614 utilities.assert_equals( expect=main.TRUE, 615 actual=stepResult, 616 onpass="VLAN1: Host intent test " + 617 "successful between two " + 618 "host using IPV4 in the same VLAN", 619 onfail="VLAN1: Host intent test " + 620 "failed between two" + 621 "host using IPV4 in the same VLAN" ) 622 623 main.step( "VLAN2: Add inter vlan host intents between h13 and h20" ) 624 stepResult = main.TRUE 625 stepResult = main.intentFunction.hostIntent( main, 626 name='VLAN2', 627 host1='h13', 628 host2='h20' ) 629 630 utilities.assert_equals( expect=main.FALSE, 631 actual=stepResult, 632 onpass="VLAN2: Host intent negative test " + 633 "successful between two " + 634 "host using IPV4 in different VLAN", 635 onfail="VLAN2: Host intent negative test " + 636 "failed between two" + 637 "host using IPV4 in different VLAN" ) 638 639 640 intentLeadersNew = main.CLIs[ 0 ].leaderCandidates() 641 main.intentFunction.checkLeaderChange( intentLeadersOld, 642 intentLeadersNew )
643
644 - def CASE2000( self, main ):
645 """ 646 Add point intents between 2 hosts: 647 - Get device ids | ports 648 - Add point intents 649 - Check intents 650 - Verify flows 651 - Ping hosts 652 - Reroute 653 - Link down 654 - Verify flows 655 - Check topology 656 - Ping hosts 657 - Link up 658 - Verify flows 659 - Check topology 660 - Ping hosts 661 - Remove intents 662 """ 663 import time 664 import json 665 import re 666 667 # Assert variables - These variable's name|format must be followed 668 # if you want to use the wrapper function 669 assert main, "There is no main" 670 assert main.CLIs, "There is no main.CLIs" 671 assert main.Mininet1, "Mininet handle should be named Mininet1" 672 assert main.numSwitch, "Placed the total number of switch topology in \ 673 main.numSwitch" 674 675 main.testName = "Point Intents" 676 main.case( main.testName + " Test - " + str( main.numCtrls ) + 677 " NODE(S) - OF " + main.OFProtocol ) 678 main.caseExplanation = "This test case will test point to point" +\ 679 " intents using " + str( main.numCtrls ) +\ 680 " node(s) cluster;\n" +\ 681 "Different type of hosts will be tested in " +\ 682 "each step such as IPV4, Dual stack, VLAN etc" +\ 683 ";\nThe test will use OF " + main.OFProtocol +\ 684 " OVS running in Mininet" 685 686 # No option point intents 687 main.step( "NOOPTION: Add point intents between h1 and h9" ) 688 stepResult = main.TRUE 689 stepResult = main.intentFunction.pointIntent( 690 main, 691 name="NOOPTION", 692 host1="h1", 693 host2="h9", 694 deviceId1="of:0000000000000005/1", 695 deviceId2="of:0000000000000006/1", 696 sw1="s5", 697 sw2="s2", 698 expectedLink=18 ) 699 700 utilities.assert_equals( expect=main.TRUE, 701 actual=stepResult, 702 onpass="NOOPTION: Point intent test " + 703 "successful using no match action", 704 onfail="NOOPTION: Point intent test " + 705 "failed using no match action" ) 706 707 stepResult = main.TRUE 708 main.step( "IPV4: Add point intents between h1 and h9" ) 709 stepResult = main.intentFunction.pointIntent( 710 main, 711 name="IPV4", 712 host1="h1", 713 host2="h9", 714 deviceId1="of:0000000000000005/1", 715 deviceId2="of:0000000000000006/1", 716 port1="", 717 port2="", 718 ethType="IPV4", 719 mac1="00:00:00:00:00:01", 720 mac2="00:00:00:00:00:09", 721 bandwidth="", 722 lambdaAlloc=False, 723 ipProto="", 724 ip1="", 725 ip2="", 726 tcp1="", 727 tcp2="", 728 sw1="s5", 729 sw2="s2", 730 expectedLink=18 ) 731 732 utilities.assert_equals( expect=main.TRUE, 733 actual=stepResult, 734 onpass="IPV4: Point intent test " + 735 "successful using IPV4 type with " + 736 "MAC addresses", 737 onfail="IPV4: Point intent test " + 738 "failed using IPV4 type with " + 739 "MAC addresses" ) 740 main.step( "IPV4_2: Add point intents between h1 and h9" ) 741 stepResult = main.TRUE 742 stepResult = main.intentFunction.pointIntent( 743 main, 744 name="IPV4_2", 745 host1="h1", 746 host2="h9", 747 deviceId1="of:0000000000000005/1", 748 deviceId2="of:0000000000000006/1", 749 ipProto="", 750 ip1="", 751 ip2="", 752 tcp1="", 753 tcp2="", 754 sw1="s5", 755 sw2="s2", 756 expectedLink=18 ) 757 758 utilities.assert_equals( expect=main.TRUE, 759 actual=stepResult, 760 onpass="IPV4_2: Point intent test " + 761 "successful using IPV4 type with " + 762 "no MAC addresses", 763 onfail="IPV4_2: Point intent test " + 764 "failed using IPV4 type with " + 765 "no MAC addresses" ) 766 767 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" ) 768 stepResult = main.TRUE 769 mac1 = main.hostsData[ 'h1' ][ 'mac' ] 770 mac2 = main.hostsData[ 'h9' ][ 'mac' ] 771 try: 772 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/24" 773 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/24" 774 except KeyError: 775 main.log.debug( "Key Error getting IP addresses of h1 | h9 in" + 776 "main.hostsData" ) 777 ip1 = main.Mininet1.getIPAddress( 'h1') 778 ip2 = main.Mininet1.getIPAddress( 'h9') 779 780 ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ] 781 # Uneccessary, not including this in the selectors 782 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ] 783 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ] 784 785 stepResult = main.intentFunction.pointIntent( 786 main, 787 name="SDNIP-ICMP", 788 host1="h1", 789 host2="h9", 790 deviceId1="of:0000000000000005/1", 791 deviceId2="of:0000000000000006/1", 792 mac1=mac1, 793 mac2=mac2, 794 ethType="IPV4", 795 ipProto=ipProto, 796 ip1=ip1, 797 ip2=ip2 ) 798 799 utilities.assert_equals( expect=main.TRUE, 800 actual=stepResult, 801 onpass="SDNIP-ICMP: Point intent test " + 802 "successful using IPV4 type with " + 803 "IP protocol TCP enabled", 804 onfail="SDNIP-ICMP: Point intent test " + 805 "failed using IPV4 type with " + 806 "IP protocol TCP enabled" ) 807 808 main.step( "SDNIP-TCP: Add point intents between h1 and h9" ) 809 stepResult = main.TRUE 810 mac1 = main.hostsData[ 'h1' ][ 'mac' ] 811 mac2 = main.hostsData[ 'h9' ][ 'mac' ] 812 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32" 813 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32" 814 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ] 815 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ] 816 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ] 817 818 stepResult = main.intentFunction.pointIntentTcp( 819 main, 820 name="SDNIP-TCP", 821 host1="h1", 822 host2="h9", 823 deviceId1="of:0000000000000005/1", 824 deviceId2="of:0000000000000006/1", 825 mac1=mac1, 826 mac2=mac2, 827 ethType="IPV4", 828 ipProto=ipProto, 829 ip1=ip1, 830 ip2=ip2, 831 tcp1=tcp1, 832 tcp2=tcp2 ) 833 834 utilities.assert_equals( expect=main.TRUE, 835 actual=stepResult, 836 onpass="SDNIP-TCP: Point intent test " + 837 "successful using IPV4 type with " + 838 "IP protocol ICMP enabled", 839 onfail="SDNIP-TCP: Point intent test " + 840 "failed using IPV4 type with " + 841 "IP protocol ICMP enabled" ) 842 843 main.step( "DUALSTACK1: Add point intents between h1 and h9" ) 844 stepResult = main.TRUE 845 stepResult = main.intentFunction.pointIntent( 846 main, 847 name="DUALSTACK1", 848 host1="h3", 849 host2="h11", 850 deviceId1="of:0000000000000005", 851 deviceId2="of:0000000000000006", 852 port1="3", 853 port2="3", 854 ethType="IPV4", 855 mac1="00:00:00:00:00:03", 856 mac2="00:00:00:00:00:0B", 857 bandwidth="", 858 lambdaAlloc=False, 859 ipProto="", 860 ip1="", 861 ip2="", 862 tcp1="", 863 tcp2="", 864 sw1="s5", 865 sw2="s2", 866 expectedLink=18 ) 867 868 utilities.assert_equals( expect=main.TRUE, 869 actual=stepResult, 870 onpass="DUALSTACK1: Point intent test " + 871 "successful using IPV4 type with " + 872 "MAC addresses", 873 onfail="DUALSTACK1: Point intent test " + 874 "failed using IPV4 type with " + 875 "MAC addresses" ) 876 877 main.step( "VLAN: Add point intents between h5 and h21" ) 878 stepResult = main.TRUE 879 stepResult = main.intentFunction.pointIntent( 880 main, 881 name="VLAN", 882 host1="h5", 883 host2="h21", 884 deviceId1="of:0000000000000005/5", 885 deviceId2="of:0000000000000007/5", 886 port1="", 887 port2="", 888 ethType="IPV4", 889 mac1="00:00:00:00:00:05", 890 mac2="00:00:00:00:00:15", 891 bandwidth="", 892 lambdaAlloc=False, 893 ipProto="", 894 ip1="", 895 ip2="", 896 tcp1="", 897 tcp2="", 898 sw1="s5", 899 sw2="s2", 900 expectedLink=18 ) 901 902 utilities.assert_equals( expect=main.TRUE, 903 actual=stepResult, 904 onpass="VLAN1: Point intent test " + 905 "successful using IPV4 type with " + 906 "MAC addresses", 907 onfail="VLAN1: Point intent test " + 908 "failed using IPV4 type with " + 909 "MAC addresses" ) 910 911 main.step( "1HOP: Add point intents between h1 and h3" ) 912 stepResult = main.TRUE 913 stepResult = main.intentFunction.hostIntent( main, 914 name='1HOP', 915 host1='h1', 916 host2='h3' ) 917 918 utilities.assert_equals( expect=main.TRUE, 919 actual=stepResult, 920 onpass="1HOP: Point intent test " + 921 "successful using IPV4 type with " + 922 "no MAC addresses", 923 onfail="1HOP: Point intent test " + 924 "failed using IPV4 type with " + 925 "no MAC addresses" )
926
927 - def CASE3000( self, main ):
928 """ 929 Add single point to multi point intents 930 - Get device ids 931 - Add single point to multi point intents 932 - Check intents 933 - Verify flows 934 - Ping hosts 935 - Reroute 936 - Link down 937 - Verify flows 938 - Check topology 939 - Ping hosts 940 - Link up 941 - Verify flows 942 - Check topology 943 - Ping hosts 944 - Remove intents 945 """ 946 assert main, "There is no main" 947 assert main.CLIs, "There is no main.CLIs" 948 assert main.Mininet1, "Mininet handle should be named Mininet1" 949 assert main.numSwitch, "Placed the total number of switch topology in \ 950 main.numSwitch" 951 952 main.testName = "Single to Multi Point Intents" 953 main.case( main.testName + " Test - " + str( main.numCtrls ) + 954 " NODE(S) - OF " + main.OFProtocol ) 955 main.caseExplanation = "This test case will test single point to" +\ 956 " multi point intents using " +\ 957 str( main.numCtrls ) + " node(s) cluster;\n" +\ 958 "Different type of hosts will be tested in " +\ 959 "each step such as IPV4, Dual stack, VLAN etc" +\ 960 ";\nThe test will use OF " + main.OFProtocol +\ 961 " OVS running in Mininet" 962 963 main.step( "NOOPTION: Add single point to multi point intents" ) 964 stepResult = main.TRUE 965 hostNames = [ 'h8', 'h16', 'h24' ] 966 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \ 967 'of:0000000000000007/8' ] 968 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ] 969 stepResult = main.intentFunction.singleToMultiIntent( 970 main, 971 name="NOOPTION", 972 hostNames=hostNames, 973 devices=devices, 974 sw1="s5", 975 sw2="s2", 976 expectedLink=18 ) 977 978 utilities.assert_equals( expect=main.TRUE, 979 actual=stepResult, 980 onpass="NOOPTION: Successfully added single " 981 + " point to multi point intents" + 982 " with no match action", 983 onfail="NOOPTION: Failed to add single point" 984 + " point to multi point intents" + 985 " with no match action" ) 986 987 main.step( "IPV4: Add single point to multi point intents" ) 988 stepResult = main.TRUE 989 stepResult = main.intentFunction.singleToMultiIntent( 990 main, 991 name="IPV4", 992 hostNames=hostNames, 993 devices=devices, 994 ports=None, 995 ethType="IPV4", 996 macs=macs, 997 bandwidth="", 998 lambdaAlloc=False, 999 ipProto="", 1000 ipAddresses="", 1001 tcp="", 1002 sw1="s5", 1003 sw2="s2", 1004 expectedLink=18 ) 1005 1006 utilities.assert_equals( expect=main.TRUE, 1007 actual=stepResult, 1008 onpass="IPV4: Successfully added single " 1009 + " point to multi point intents" + 1010 " with IPV4 type and MAC addresses", 1011 onfail="IPV4: Failed to add single point" 1012 + " point to multi point intents" + 1013 " with IPV4 type and MAC addresses" ) 1014 1015 main.step( "IPV4_2: Add single point to multi point intents" ) 1016 stepResult = main.TRUE 1017 hostNames = [ 'h8', 'h16', 'h24' ] 1018 stepResult = main.intentFunction.singleToMultiIntent( 1019 main, 1020 name="IPV4", 1021 hostNames=hostNames, 1022 ethType="IPV4", 1023 lambdaAlloc=False ) 1024 1025 utilities.assert_equals( expect=main.TRUE, 1026 actual=stepResult, 1027 onpass="IPV4_2: Successfully added single " 1028 + " point to multi point intents" + 1029 " with IPV4 type and no MAC addresses", 1030 onfail="IPV4_2: Failed to add single point" 1031 + " point to multi point intents" + 1032 " with IPV4 type and no MAC addresses" ) 1033 1034 main.step( "VLAN: Add single point to multi point intents" ) 1035 stepResult = main.TRUE 1036 hostNames = [ 'h4', 'h12', 'h20' ] 1037 devices = [ 'of:0000000000000005/4', 'of:0000000000000006/4', \ 1038 'of:0000000000000007/4' ] 1039 macs = [ '00:00:00:00:00:04', '00:00:00:00:00:0C', '00:00:00:00:00:14' ] 1040 stepResult = main.intentFunction.singleToMultiIntent( 1041 main, 1042 name="VLAN", 1043 hostNames=hostNames, 1044 devices=devices, 1045 ports=None, 1046 ethType="IPV4", 1047 macs=macs, 1048 bandwidth="", 1049 lambdaAlloc=False, 1050 ipProto="", 1051 ipAddresses="", 1052 tcp="", 1053 sw1="s5", 1054 sw2="s2", 1055 expectedLink=18 ) 1056 1057 utilities.assert_equals( expect=main.TRUE, 1058 actual=stepResult, 1059 onpass="VLAN: Successfully added single " 1060 + " point to multi point intents" + 1061 " with IPV4 type and MAC addresses" + 1062 " in the same VLAN", 1063 onfail="VLAN: Failed to add single point" 1064 + " point to multi point intents" + 1065 " with IPV4 type and MAC addresses" + 1066 " in the same VLAN")
1067
1068 - def CASE4000( self, main ):
1069 """ 1070 Add multi point to single point intents 1071 - Get device ids 1072 - Add multi point to single point intents 1073 - Check intents 1074 - Verify flows 1075 - Ping hosts 1076 - Reroute 1077 - Link down 1078 - Verify flows 1079 - Check topology 1080 - Ping hosts 1081 - Link up 1082 - Verify flows 1083 - Check topology 1084 - Ping hosts 1085 - Remove intents 1086 """ 1087 assert main, "There is no main" 1088 assert main.CLIs, "There is no main.CLIs" 1089 assert main.Mininet1, "Mininet handle should be named Mininet1" 1090 assert main.numSwitch, "Placed the total number of switch topology in \ 1091 main.numSwitch" 1092 1093 main.testName = "Multi To Single Point Intents" 1094 main.case( main.testName + " Test - " + str( main.numCtrls ) + 1095 " NODE(S) - OF " + main.OFProtocol ) 1096 main.caseExplanation = "This test case will test single point to" +\ 1097 " multi point intents using " +\ 1098 str( main.numCtrls ) + " node(s) cluster;\n" +\ 1099 "Different type of hosts will be tested in " +\ 1100 "each step such as IPV4, Dual stack, VLAN etc" +\ 1101 ";\nThe test will use OF " + main.OFProtocol +\ 1102 " OVS running in Mininet" 1103 1104 main.step( "NOOPTION: Add multi point to single point intents" ) 1105 stepResult = main.TRUE 1106 hostNames = [ 'h8', 'h16', 'h24' ] 1107 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \ 1108 'of:0000000000000007/8' ] 1109 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ] 1110 stepResult = main.intentFunction.multiToSingleIntent( 1111 main, 1112 name="NOOPTION", 1113 hostNames=hostNames, 1114 devices=devices, 1115 sw1="s5", 1116 sw2="s2", 1117 expectedLink=18 ) 1118 1119 utilities.assert_equals( expect=main.TRUE, 1120 actual=stepResult, 1121 onpass="NOOPTION: Successfully added multi " 1122 + " point to single point intents" + 1123 " with no match action", 1124 onfail="NOOPTION: Failed to add multi point" + 1125 " to single point intents" + 1126 " with no match action" ) 1127 1128 main.step( "IPV4: Add multi point to single point intents" ) 1129 stepResult = main.TRUE 1130 stepResult = main.intentFunction.multiToSingleIntent( 1131 main, 1132 name="IPV4", 1133 hostNames=hostNames, 1134 devices=devices, 1135 ports=None, 1136 ethType="IPV4", 1137 macs=macs, 1138 bandwidth="", 1139 lambdaAlloc=False, 1140 ipProto="", 1141 ipAddresses="", 1142 tcp="", 1143 sw1="s5", 1144 sw2="s2", 1145 expectedLink=18 ) 1146 1147 utilities.assert_equals( expect=main.TRUE, 1148 actual=stepResult, 1149 onpass="IPV4: Successfully added multi point" 1150 + " to single point intents" + 1151 " with IPV4 type and MAC addresses", 1152 onfail="IPV4: Failed to add multi point" + 1153 " to single point intents" + 1154 " with IPV4 type and MAC addresses" ) 1155 1156 main.step( "IPV4_2: Add multi point to single point intents" ) 1157 stepResult = main.TRUE 1158 hostNames = [ 'h8', 'h16', 'h24' ] 1159 stepResult = main.intentFunction.multiToSingleIntent( 1160 main, 1161 name="IPV4", 1162 hostNames=hostNames, 1163 ethType="IPV4", 1164 lambdaAlloc=False ) 1165 1166 utilities.assert_equals( expect=main.TRUE, 1167 actual=stepResult, 1168 onpass="IPV4_2: Successfully added multi point" 1169 + " to single point intents" + 1170 " with IPV4 type and no MAC addresses", 1171 onfail="IPV4_2: Failed to add multi point" + 1172 " to single point intents" + 1173 " with IPV4 type and no MAC addresses" ) 1174 1175 main.step( "VLAN: Add multi point to single point intents" ) 1176 stepResult = main.TRUE 1177 hostNames = [ 'h5', 'h13', 'h21' ] 1178 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \ 1179 'of:0000000000000007/5' ] 1180 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ] 1181 stepResult = main.intentFunction.multiToSingleIntent( 1182 main, 1183 name="VLAN", 1184 hostNames=hostNames, 1185 devices=devices, 1186 ports=None, 1187 ethType="IPV4", 1188 macs=macs, 1189 bandwidth="", 1190 lambdaAlloc=False, 1191 ipProto="", 1192 ipAddresses="", 1193 tcp="", 1194 sw1="s5", 1195 sw2="s2", 1196 expectedLink=18 ) 1197 1198 utilities.assert_equals( expect=main.TRUE, 1199 actual=stepResult, 1200 onpass="VLAN: Successfully added multi point" 1201 + " to single point intents" + 1202 " with IPV4 type and MAC addresses" + 1203 " in the same VLAN", 1204 onfail="VLAN: Failed to add multi point" + 1205 " to single point intents" )
1206
1207 - def CASE5000( self, main ):
1208 """ 1209 Will add description in next patch set 1210 """ 1211 assert main, "There is no main" 1212 assert main.CLIs, "There is no main.CLIs" 1213 assert main.Mininet1, "Mininet handle should be named Mininet1" 1214 assert main.numSwitch, "Placed the total number of switch topology in \ 1215 main.numSwitch" 1216 main.case( "Test host mobility with host intents " ) 1217 main.step( " Testing host mobility by moving h1 from s5 to s6" ) 1218 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ] 1219 1220 main.log.info( "Moving h1 from s5 to s6") 1221 1222 main.Mininet1.moveHost( "h1","s5","s6" ) 1223 1224 main.intentFunction.getHostsData( main ) 1225 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ] 1226 1227 utilities.assert_equals( expect="of:0000000000000006", 1228 actual=h1PostMove, 1229 onpass="Mobility: Successfully moved h1 to s6", 1230 onfail="Mobility: Failed to moved h1 to s6" + 1231 " to single point intents" + 1232 " with IPV4 type and MAC addresses" + 1233 " in the same VLAN" ) 1234 1235 main.step( "IPV4: Add host intents between h1 and h9" ) 1236 stepResult = main.TRUE 1237 stepResult = main.intentFunction.hostIntent( main, 1238 onosNode='0', 1239 name='IPV4', 1240 host1='h1', 1241 host2='h9', 1242 host1Id='00:00:00:00:00:01/-1', 1243 host2Id='00:00:00:00:00:09/-1' ) 1244 1245 utilities.assert_equals( expect=main.TRUE, 1246 actual=stepResult, 1247 onpass="IPV4: Host intent test successful " + 1248 "between two IPV4 hosts", 1249 onfail="IPV4: Host intent test failed " + 1250 "between two IPV4 hosts")
1251