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