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