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