kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1 | |
| 2 | # Testing the basic intent functionality of ONOS |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 3 | # TODO: Replace the CLI calls with REST API equivalents as they become available. |
| 4 | # - May need to write functions in the onosrestdriver.py file to do this |
| 5 | # TODO: Complete implementation of case 3000, 4000, and 6000 as REST API allows |
| 6 | # -Currently there is no support in the REST API for Multi to Single and Single to Multi point intents |
| 7 | # As such, these cases are incomplete and should not be enabled in the .params file |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 8 | |
| 9 | import time |
| 10 | import json |
| 11 | |
| 12 | class FUNCintentRest: |
| 13 | |
| 14 | def __init__( self ): |
| 15 | self.default = '' |
| 16 | |
| 17 | def CASE1( self, main ): |
| 18 | import time |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 19 | import imp |
Jon Hall | f723488 | 2015-08-28 13:16:31 -0700 | [diff] [blame] | 20 | import re |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 21 | |
| 22 | """ |
| 23 | - Construct tests variables |
| 24 | - GIT ( optional ) |
| 25 | - Checkout ONOS master branch |
| 26 | - Pull latest ONOS code |
| 27 | - Building ONOS ( optional ) |
| 28 | - Install ONOS package |
| 29 | - Build ONOS package |
| 30 | """ |
| 31 | |
| 32 | main.case( "Constructing test variables and building ONOS package" ) |
| 33 | main.step( "Constructing test variables" ) |
| 34 | main.caseExplanation = "This test case is mainly for loading " +\ |
| 35 | "from params file, and pull and build the " +\ |
| 36 | " latest ONOS package" |
| 37 | stepResult = main.FALSE |
| 38 | |
| 39 | # Test variables |
| 40 | try: |
Jon Hall | f723488 | 2015-08-28 13:16:31 -0700 | [diff] [blame] | 41 | main.testOnDirectory = re.sub( "(/tests)$", "", main.testDir ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 42 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
| 43 | gitBranch = main.params[ 'GIT' ][ 'branch' ] |
| 44 | main.dependencyPath = main.testOnDirectory + \ |
| 45 | main.params[ 'DEPENDENCY' ][ 'path' ] |
| 46 | main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ] |
| 47 | main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," ) |
| 48 | if main.ONOSbench.maxNodes: |
| 49 | main.maxNodes = int( main.ONOSbench.maxNodes ) |
| 50 | else: |
| 51 | main.maxNodes = 0 |
| 52 | wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
| 53 | wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ] |
| 54 | wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ] |
| 55 | main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 56 | main.checkIntentSleep = int( main.params[ 'SLEEP' ][ 'checkintent' ] ) |
| 57 | main.removeIntentsleeo = int( main.params[ 'SLEEP' ][ 'removeintent' ] ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 58 | main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] ) |
| 59 | main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] ) |
kelvin-onlab | 0e68468 | 2015-08-11 18:51:41 -0700 | [diff] [blame] | 60 | main.addIntentSleep = int( main.params[ 'SLEEP' ][ 'addIntent' ] ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 61 | main.checkTopoAttempts = int( main.params[ 'SLEEP' ][ 'topoAttempts' ] ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 62 | gitPull = main.params[ 'GIT' ][ 'pull' ] |
| 63 | main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] ) |
| 64 | main.numLinks = int( main.params[ 'MININET' ][ 'links' ] ) |
| 65 | main.cellData = {} # for creating cell file |
| 66 | main.hostsData = {} |
| 67 | main.CLIs = [] |
Jeremy | e1ea060 | 2016-02-08 16:35:05 -0800 | [diff] [blame] | 68 | main.CLIs2 = [] |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 69 | main.ONOSip = [] |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 70 | main.scapyHostNames = main.params[ 'SCAPY' ][ 'HOSTNAMES' ].split( ',' ) |
| 71 | main.scapyHosts = [] # List of scapy hosts for iterating |
| 72 | main.assertReturnString = '' # Assembled assert return string |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 73 | |
| 74 | main.ONOSip = main.ONOSbench.getOnosIps() |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 75 | print main.ONOSip |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 76 | |
| 77 | # Assigning ONOS cli handles to a list |
Jon Hall | f723488 | 2015-08-28 13:16:31 -0700 | [diff] [blame] | 78 | try: |
| 79 | for i in range( 1, main.maxNodes + 1 ): |
| 80 | main.CLIs.append( getattr( main, 'ONOSrest' + str( i ) ) ) |
Jeremy | e1ea060 | 2016-02-08 16:35:05 -0800 | [diff] [blame] | 81 | main.CLIs2.append( getattr( main, 'ONOScli' + str( i ) ) ) |
Jon Hall | f723488 | 2015-08-28 13:16:31 -0700 | [diff] [blame] | 82 | except AttributeError: |
| 83 | main.log.warn( "A " + str( main.maxNodes ) + " node cluster " + |
| 84 | "was defined in env variables, but only " + |
| 85 | str( len( main.CLIs ) ) + |
| 86 | " nodes were defined in the .topo file. " + |
| 87 | "Using " + str( len( main.CLIs ) ) + |
| 88 | " nodes for the test." ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 89 | |
| 90 | # -- INIT SECTION, ONLY RUNS ONCE -- # |
| 91 | main.startUp = imp.load_source( wrapperFile1, |
| 92 | main.dependencyPath + |
| 93 | wrapperFile1 + |
| 94 | ".py" ) |
| 95 | |
| 96 | main.intentFunction = imp.load_source( wrapperFile2, |
| 97 | main.dependencyPath + |
| 98 | wrapperFile2 + |
| 99 | ".py" ) |
| 100 | |
| 101 | main.topo = imp.load_source( wrapperFile3, |
| 102 | main.dependencyPath + |
| 103 | wrapperFile3 + |
| 104 | ".py" ) |
| 105 | |
Jon Hall | f723488 | 2015-08-28 13:16:31 -0700 | [diff] [blame] | 106 | copyResult1 = main.ONOSbench.scp( main.Mininet1, |
| 107 | main.dependencyPath + |
| 108 | main.topology, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 109 | main.Mininet1.home + "custom/", |
Jon Hall | f723488 | 2015-08-28 13:16:31 -0700 | [diff] [blame] | 110 | direction="to" ) |
Jeremy | e1ea060 | 2016-02-08 16:35:05 -0800 | [diff] [blame] | 111 | if main.CLIs and main.CLIs2: |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 112 | stepResult = main.TRUE |
| 113 | else: |
| 114 | main.log.error( "Did not properly created list of ONOS CLI handle" ) |
| 115 | stepResult = main.FALSE |
| 116 | except Exception as e: |
| 117 | main.log.exception(e) |
| 118 | main.cleanup() |
| 119 | main.exit() |
| 120 | |
| 121 | utilities.assert_equals( expect=main.TRUE, |
| 122 | actual=stepResult, |
| 123 | onpass="Successfully construct " + |
| 124 | "test variables ", |
| 125 | onfail="Failed to construct test variables" ) |
| 126 | |
| 127 | if gitPull == 'True': |
| 128 | main.step( "Building ONOS in " + gitBranch + " branch" ) |
| 129 | onosBuildResult = main.startUp.onosBuild( main, gitBranch ) |
| 130 | stepResult = onosBuildResult |
| 131 | utilities.assert_equals( expect=main.TRUE, |
| 132 | actual=stepResult, |
| 133 | onpass="Successfully compiled " + |
| 134 | "latest ONOS", |
| 135 | onfail="Failed to compile " + |
| 136 | "latest ONOS" ) |
| 137 | else: |
| 138 | main.log.warn( "Did not pull new code so skipping mvn " + |
| 139 | "clean install" ) |
| 140 | main.ONOSbench.getVersion( report=True ) |
| 141 | |
| 142 | def CASE2( self, main ): |
| 143 | """ |
| 144 | - Set up cell |
| 145 | - Create cell file |
| 146 | - Set cell file |
| 147 | - Verify cell file |
| 148 | - Kill ONOS process |
| 149 | - Uninstall ONOS cluster |
| 150 | - Verify ONOS start up |
| 151 | - Install ONOS cluster |
| 152 | - Connect to cli |
| 153 | """ |
| 154 | |
| 155 | # main.scale[ 0 ] determines the current number of ONOS controller |
| 156 | main.numCtrls = int( main.scale[ 0 ] ) |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 157 | main.flowCompiler = "Flow Rules" |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 158 | main.initialized = main.TRUE |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 159 | |
| 160 | main.case( "Starting up " + str( main.numCtrls ) + |
| 161 | " node(s) ONOS cluster" ) |
| 162 | main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\ |
| 163 | " node(s) ONOS cluster" |
| 164 | |
| 165 | |
| 166 | |
| 167 | #kill off all onos processes |
| 168 | main.log.info( "Safety check, killing all ONOS processes" + |
Jon Hall | 70b2ff4 | 2015-11-17 15:49:44 -0800 | [diff] [blame] | 169 | " before initiating environment setup" ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 170 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 171 | time.sleep( main.startUpSleep ) |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 172 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 173 | main.step( "Uninstalling ONOS package" ) |
| 174 | onosUninstallResult = main.TRUE |
| 175 | for ip in main.ONOSip: |
| 176 | onosUninstallResult = onosUninstallResult and \ |
| 177 | main.ONOSbench.onosUninstall( nodeIp=ip ) |
| 178 | stepResult = onosUninstallResult |
| 179 | utilities.assert_equals( expect=main.TRUE, |
| 180 | actual=stepResult, |
| 181 | onpass="Successfully uninstalled ONOS package", |
| 182 | onfail="Failed to uninstall ONOS package" ) |
| 183 | |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 184 | time.sleep( main.startUpSleep ) |
| 185 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 186 | for i in range( main.maxNodes ): |
| 187 | main.ONOSbench.onosDie( main.ONOSip[ i ] ) |
| 188 | |
| 189 | print "NODE COUNT = ", main.numCtrls |
| 190 | |
| 191 | tempOnosIp = [] |
| 192 | for i in range( main.numCtrls ): |
| 193 | tempOnosIp.append( main.ONOSip[i] ) |
| 194 | |
| 195 | main.ONOSbench.createCellFile( main.ONOSbench.ip_address, |
| 196 | "temp", main.Mininet1.ip_address, |
| 197 | main.apps, tempOnosIp ) |
| 198 | |
| 199 | main.step( "Apply cell to environment" ) |
| 200 | cellResult = main.ONOSbench.setCell( "temp" ) |
| 201 | verifyResult = main.ONOSbench.verifyCell() |
| 202 | stepResult = cellResult and verifyResult |
| 203 | utilities.assert_equals( expect=main.TRUE, |
| 204 | actual=stepResult, |
| 205 | onpass="Successfully applied cell to " + \ |
| 206 | "environment", |
| 207 | onfail="Failed to apply cell to environment " ) |
| 208 | |
| 209 | main.step( "Creating ONOS package" ) |
| 210 | packageResult = main.ONOSbench.onosPackage() |
| 211 | stepResult = packageResult |
| 212 | utilities.assert_equals( expect=main.TRUE, |
| 213 | actual=stepResult, |
| 214 | onpass="Successfully created ONOS package", |
| 215 | onfail="Failed to create ONOS package" ) |
| 216 | |
| 217 | time.sleep( main.startUpSleep ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 218 | main.step( "Installing ONOS package" ) |
| 219 | onosInstallResult = main.TRUE |
| 220 | for i in range( main.numCtrls ): |
| 221 | onosInstallResult = onosInstallResult and \ |
| 222 | main.ONOSbench.onosInstall( node=main.ONOSip[ i ] ) |
| 223 | stepResult = onosInstallResult |
| 224 | utilities.assert_equals( expect=main.TRUE, |
| 225 | actual=stepResult, |
| 226 | onpass="Successfully installed ONOS package", |
| 227 | onfail="Failed to install ONOS package" ) |
| 228 | |
| 229 | time.sleep( main.startUpSleep ) |
| 230 | main.step( "Starting ONOS service" ) |
| 231 | stopResult = main.TRUE |
| 232 | startResult = main.TRUE |
| 233 | onosIsUp = main.TRUE |
| 234 | |
| 235 | for i in range( main.numCtrls ): |
| 236 | onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 237 | if onosIsUp == main.TRUE: |
| 238 | main.log.report( "ONOS instance {0} is up and ready".format( i + 1 ) ) |
| 239 | else: |
| 240 | main.log.report( "ONOS instance {0} may not be up, stop and ".format( i + 1 ) + |
| 241 | "start ONOS again " ) |
| 242 | stopResult = stopResult and main.ONOSbench.onosStop( main.ONOSip[ i ] ) |
| 243 | startResult = startResult and main.ONOSbench.onosStart( main.ONOSip[ i ] ) |
| 244 | if not startResult or stopResult: |
| 245 | main.log.report( "ONOS instance {0} did not start correctly.".format( i + 1 ) ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 246 | stepResult = onosIsUp and stopResult and startResult |
| 247 | utilities.assert_equals( expect=main.TRUE, |
| 248 | actual=stepResult, |
| 249 | onpass="ONOS service is ready", |
| 250 | onfail="ONOS service did not start properly" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 251 | if not stepResult: |
| 252 | main.initialized = main.FALSE |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 253 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 254 | # Start an ONOS cli to provide functionality that is not currently |
Jeremy | e1ea060 | 2016-02-08 16:35:05 -0800 | [diff] [blame] | 255 | # supported by the Rest API remove this when Leader Checking is supported |
| 256 | # by the REST API |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 257 | |
Jeremy | e1ea060 | 2016-02-08 16:35:05 -0800 | [diff] [blame] | 258 | main.step( "Start ONOS cli" ) |
| 259 | cliResult = main.TRUE |
| 260 | for i in range( main.numCtrls ): |
| 261 | cliResult = cliResult and \ |
| 262 | main.CLIs2[ i ].startOnosCli( main.ONOSip[ i ] ) |
| 263 | stepResult = cliResult |
| 264 | utilities.assert_equals( expect=main.TRUE, |
| 265 | actual=stepResult, |
| 266 | onpass="Successfully start ONOS cli", |
| 267 | onfail="Failed to start ONOS cli" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 268 | if not stepResult: |
| 269 | main.initialized = main.FALSE |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 270 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 271 | # Remove the first element in main.scale list |
| 272 | main.scale.remove( main.scale[ 0 ] ) |
| 273 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 274 | main.intentFunction.report( main ) |
| 275 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 276 | def CASE8( self, main ): |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 277 | # OLD FUNCintentRest CASE 8 |
| 278 | # This remains here for archiving and reference purposes and will be |
| 279 | # removed when the new FUNCintentRest is verified to work. |
| 280 | # """ |
| 281 | # Compare Topo |
| 282 | # """ |
| 283 | # import json |
| 284 | |
| 285 | # main.case( "Compare ONOS Topology view to Mininet topology" ) |
| 286 | # main.caseExplanation = "Compare topology elements between Mininet" +\ |
| 287 | # " and ONOS" |
| 288 | |
| 289 | # main.step( "Gathering topology information" ) |
| 290 | # # TODO: add a paramaterized sleep here |
| 291 | # devicesResults = main.TRUE # Overall Boolean for device correctness |
| 292 | # linksResults = main.TRUE # Overall Boolean for link correctness |
| 293 | # hostsResults = main.TRUE # Overall Boolean for host correctness |
| 294 | # devices = main.topo.getAllDevices( main ) |
| 295 | # hosts = main.topo.getAllHosts( main ) |
| 296 | # ports = main.topo.getAllPorts( main ) |
| 297 | # links = main.topo.getAllLinks( main ) |
| 298 | # clusters = main.topo.getAllClusters( main ) |
| 299 | |
| 300 | # mnSwitches = main.Mininet1.getSwitches() |
| 301 | # mnLinks = main.Mininet1.getLinks() |
| 302 | # mnHosts = main.Mininet1.getHosts() |
| 303 | |
| 304 | # main.step( "Comparing MN topology to ONOS topology" ) |
| 305 | # for controller in range( main.numCtrls ): |
| 306 | # controllerStr = str( controller + 1 ) |
| 307 | # if devices[ controller ] and ports[ controller ] and\ |
| 308 | # "Error" not in devices[ controller ] and\ |
| 309 | # "Error" not in ports[ controller ]: |
| 310 | |
| 311 | # currentDevicesResult = main.Mininet1.compareSwitches( |
| 312 | # mnSwitches, |
| 313 | # json.loads( devices[ controller ] ), |
| 314 | # json.loads( ports[ controller ] ) ) |
| 315 | # else: |
| 316 | # currentDevicesResult = main.FALSE |
| 317 | # utilities.assert_equals( expect=main.TRUE, |
| 318 | # actual=currentDevicesResult, |
| 319 | # onpass="ONOS" + controllerStr + |
| 320 | # " Switches view is correct", |
| 321 | # onfail="ONOS" + controllerStr + |
| 322 | # " Switches view is incorrect" ) |
| 323 | |
| 324 | # if links[ controller ] and "Error" not in links[ controller ]: |
| 325 | # currentLinksResult = main.Mininet1.compareLinks( |
| 326 | # mnSwitches, mnLinks, |
| 327 | # json.loads( links[ controller ] ) ) |
| 328 | # else: |
| 329 | # currentLinksResult = main.FALSE |
| 330 | # utilities.assert_equals( expect=main.TRUE, |
| 331 | # actual=currentLinksResult, |
| 332 | # onpass="ONOS" + controllerStr + |
| 333 | # " links view is correct", |
| 334 | # onfail="ONOS" + controllerStr + |
| 335 | # " links view is incorrect" ) |
| 336 | |
| 337 | # if hosts[ controller ] or "Error" not in hosts[ controller ]: |
| 338 | # currentHostsResult = main.Mininet1.compareHosts( |
| 339 | # mnHosts, |
| 340 | # json.loads( hosts[ controller ] ) ) |
| 341 | # else: |
| 342 | # currentHostsResult = main.FALSE |
| 343 | # utilities.assert_equals( expect=main.TRUE, |
| 344 | # actual=currentHostsResult, |
| 345 | # onpass="ONOS" + controllerStr + |
| 346 | # " hosts exist in Mininet", |
| 347 | # onfail="ONOS" + controllerStr + |
| 348 | # " hosts don't match Mininet" ) |
| 349 | |
| 350 | # NEW FUNCintentRest Case 8 as based off of the CASE 8 from FUNCintent |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 351 | """ |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 352 | Compare ONOS Topology to Mininet Topology |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 353 | """ |
| 354 | import json |
| 355 | |
| 356 | main.case( "Compare ONOS Topology view to Mininet topology" ) |
| 357 | main.caseExplanation = "Compare topology elements between Mininet" +\ |
| 358 | " and ONOS" |
| 359 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 360 | main.log.info( "Gathering topology information from Mininet" ) |
| 361 | devicesResults = main.FALSE # Overall Boolean for device correctness |
| 362 | linksResults = main.FALSE # Overall Boolean for link correctness |
| 363 | hostsResults = main.FALSE # Overall Boolean for host correctness |
| 364 | deviceFails = [] # Nodes where devices are incorrect |
| 365 | linkFails = [] # Nodes where links are incorrect |
| 366 | hostFails = [] # Nodes where hosts are incorrect |
| 367 | attempts = main.checkTopoAttempts # Remaining Attempts |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 368 | |
| 369 | mnSwitches = main.Mininet1.getSwitches() |
| 370 | mnLinks = main.Mininet1.getLinks() |
| 371 | mnHosts = main.Mininet1.getHosts() |
| 372 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 373 | main.step( "Comparing Mininet topology to ONOS topology" ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 374 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 375 | while ( attempts >= 0 ) and\ |
| 376 | ( not devicesResults or not linksResults or not hostsResults ): |
| 377 | time.sleep( 2 ) |
| 378 | if not devicesResults: |
| 379 | devices = main.topo.getAllDevices( main ) |
| 380 | ports = main.topo.getAllPorts( main ) |
| 381 | devicesResults = main.TRUE |
| 382 | deviceFails = [] # Reset for each failed attempt |
| 383 | if not linksResults: |
| 384 | links = main.topo.getAllLinks( main ) |
| 385 | linksResults = main.TRUE |
| 386 | linkFails = [] # Reset for each failed attempt |
| 387 | if not hostsResults: |
| 388 | hosts = main.topo.getAllHosts( main ) |
| 389 | hostsResults = main.TRUE |
| 390 | hostFails = [] # Reset for each failed attempt |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 391 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 392 | # Check for matching topology on each node |
| 393 | for controller in range( main.numCtrls ): |
| 394 | controllerStr = str( controller + 1 ) # ONOS node number |
| 395 | # Compare Devices |
| 396 | if devices[ controller ] and ports[ controller ] and\ |
| 397 | "Error" not in devices[ controller ] and\ |
| 398 | "Error" not in ports[ controller ]: |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 399 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 400 | try: |
| 401 | deviceData = json.loads( devices[ controller ] ) |
| 402 | portData = json.loads( ports[ controller ] ) |
| 403 | except (TypeError,ValueError): |
| 404 | main.log.error( "Could not load json: {0} or {1}".format( str( devices[ controller ] ), str( ports[ controller ] ) ) ) |
| 405 | currentDevicesResult = main.FALSE |
| 406 | else: |
| 407 | currentDevicesResult = main.Mininet1.compareSwitches( |
| 408 | mnSwitches,deviceData,portData ) |
| 409 | else: |
| 410 | currentDevicesResult = main.FALSE |
| 411 | if not currentDevicesResult: |
| 412 | deviceFails.append( controllerStr ) |
| 413 | devicesResults = devicesResults and currentDevicesResult |
| 414 | # Compare Links |
| 415 | if links[ controller ] and "Error" not in links[ controller ]: |
| 416 | try: |
| 417 | linkData = json.loads( links[ controller ] ) |
| 418 | except (TypeError,ValueError): |
| 419 | main.log.error("Could not load json:" + str( links[ controller ] ) ) |
| 420 | currentLinksResult = main.FALSE |
| 421 | else: |
| 422 | currentLinksResult = main.Mininet1.compareLinks( |
| 423 | mnSwitches, mnLinks,linkData ) |
| 424 | else: |
| 425 | currentLinksResult = main.FALSE |
| 426 | if not currentLinksResult: |
| 427 | linkFails.append( controllerStr ) |
| 428 | linksResults = linksResults and currentLinksResult |
| 429 | # Compare Hosts |
| 430 | if hosts[ controller ] and "Error" not in hosts[ controller ]: |
| 431 | try: |
| 432 | hostData = json.loads( hosts[ controller ] ) |
| 433 | except (TypeError,ValueError): |
| 434 | main.log.error("Could not load json:" + str( hosts[ controller ] ) ) |
| 435 | currentHostsResult = main.FALSE |
| 436 | else: |
| 437 | currentHostsResult = main.Mininet1.compareHosts( |
| 438 | mnHosts,hostData ) |
| 439 | else: |
| 440 | currentHostsResult = main.FALSE |
| 441 | if not currentHostsResult: |
| 442 | hostFails.append( controllerStr ) |
| 443 | hostsResults = hostsResults and currentHostsResult |
| 444 | # Decrement Attempts Remaining |
| 445 | attempts -= 1 |
| 446 | |
| 447 | |
| 448 | utilities.assert_equals( expect=[], |
| 449 | actual=deviceFails, |
| 450 | onpass="ONOS correctly discovered all devices", |
| 451 | onfail="ONOS incorrectly discovered devices on nodes: " + |
| 452 | str( deviceFails ) ) |
| 453 | utilities.assert_equals( expect=[], |
| 454 | actual=linkFails, |
| 455 | onpass="ONOS correctly discovered all links", |
| 456 | onfail="ONOS incorrectly discovered links on nodes: " + |
| 457 | str( linkFails ) ) |
| 458 | utilities.assert_equals( expect=[], |
| 459 | actual=hostFails, |
| 460 | onpass="ONOS correctly discovered all hosts", |
| 461 | onfail="ONOS incorrectly discovered hosts on nodes: " + |
| 462 | str( hostFails ) ) |
| 463 | topoResults = hostsResults and linksResults and devicesResults |
| 464 | utilities.assert_equals( expect=main.TRUE, |
| 465 | actual=topoResults, |
| 466 | onpass="ONOS correctly discovered the topology", |
| 467 | onfail="ONOS incorrectly discovered the topology" ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 468 | |
| 469 | def CASE9( self, main ): |
| 470 | ''' |
| 471 | Report errors/warnings/exceptions |
| 472 | ''' |
| 473 | main.log.info( "Error report: \n" ) |
| 474 | main.ONOSbench.logReport( globalONOSip[0], |
| 475 | [ "INFO", "FOLLOWER", "WARN", "flow", "ERROR" , "Except" ], |
| 476 | "s" ) |
| 477 | #main.ONOSbench.logReport( globalONOSip[1], [ "INFO" ], "d" ) |
| 478 | |
| 479 | def CASE10( self, main ): |
| 480 | """ |
| 481 | Start Mininet topology with OF 1.0 switches |
| 482 | """ |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 483 | if main.initialized == main.FALSE: |
| 484 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 485 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 486 | main.OFProtocol = "1.0" |
| 487 | main.log.report( "Start Mininet topology with OF 1.0 switches" ) |
| 488 | main.case( "Start Mininet topology with OF 1.0 switches" ) |
| 489 | main.caseExplanation = "Start mininet topology with OF 1.0 " +\ |
| 490 | "switches to test intents, exits out if " +\ |
| 491 | "topology did not start correctly" |
| 492 | |
| 493 | main.step( "Starting Mininet topology with OF 1.0 switches" ) |
| 494 | args = "--switch ovs,protocols=OpenFlow10" |
| 495 | topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath + |
| 496 | main.topology, |
| 497 | args=args ) |
| 498 | stepResult = topoResult |
| 499 | utilities.assert_equals( expect=main.TRUE, |
| 500 | actual=stepResult, |
| 501 | onpass="Successfully loaded topology", |
| 502 | onfail="Failed to load topology" ) |
| 503 | # Exit if topology did not load properly |
| 504 | if not topoResult: |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 505 | main.initialized = main.FALSE |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 506 | |
| 507 | def CASE11( self, main ): |
| 508 | """ |
| 509 | Start Mininet topology with OF 1.3 switches |
| 510 | """ |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 511 | if main.initialized == main.FALSE: |
| 512 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 513 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 514 | main.OFProtocol = "1.3" |
| 515 | main.log.report( "Start Mininet topology with OF 1.3 switches" ) |
| 516 | main.case( "Start Mininet topology with OF 1.3 switches" ) |
| 517 | main.caseExplanation = "Start mininet topology with OF 1.3 " +\ |
| 518 | "switches to test intents, exits out if " +\ |
| 519 | "topology did not start correctly" |
| 520 | |
| 521 | main.step( "Starting Mininet topology with OF 1.3 switches" ) |
| 522 | args = "--switch ovs,protocols=OpenFlow13" |
| 523 | topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath + |
| 524 | main.topology, |
| 525 | args=args ) |
| 526 | stepResult = topoResult |
| 527 | utilities.assert_equals( expect=main.TRUE, |
| 528 | actual=stepResult, |
| 529 | onpass="Successfully loaded topology", |
| 530 | onfail="Failed to load topology" ) |
| 531 | # Exit if topology did not load properly |
| 532 | if not topoResult: |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 533 | main.initialized = main.FALSE |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 534 | |
| 535 | def CASE12( self, main ): |
| 536 | """ |
| 537 | Assign mastership to controllers |
| 538 | """ |
| 539 | import re |
| 540 | |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 541 | if main.initialized == main.FALSE: |
| 542 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 543 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 544 | main.case( "Assign switches to controllers" ) |
| 545 | main.step( "Assigning switches to controllers" ) |
| 546 | main.caseExplanation = "Assign OF " + main.OFProtocol +\ |
| 547 | " switches to ONOS nodes" |
| 548 | |
| 549 | assignResult = main.TRUE |
| 550 | switchList = [] |
| 551 | |
| 552 | # Creates a list switch name, use getSwitch() function later... |
| 553 | for i in range( 1, ( main.numSwitch + 1 ) ): |
| 554 | switchList.append( 's' + str( i ) ) |
| 555 | |
| 556 | tempONOSip = [] |
| 557 | for i in range( main.numCtrls ): |
| 558 | tempONOSip.append( main.ONOSip[ i ] ) |
| 559 | |
| 560 | assignResult = main.Mininet1.assignSwController( sw=switchList, |
| 561 | ip=tempONOSip, |
Charles Chan | 029be65 | 2015-08-24 01:46:10 +0800 | [diff] [blame] | 562 | port='6653' ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 563 | if not assignResult: |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 564 | main.log.error( "Problem assigning mastership of switches, skipping further test cases" ) |
| 565 | main.initialized = main.FALSE |
| 566 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 567 | |
| 568 | for i in range( 1, ( main.numSwitch + 1 ) ): |
| 569 | response = main.Mininet1.getSwController( "s" + str( i ) ) |
| 570 | print( "Response is " + str( response ) ) |
| 571 | if re.search( "tcp:" + main.ONOSip[ 0 ], response ): |
| 572 | assignResult = assignResult and main.TRUE |
| 573 | else: |
| 574 | assignResult = main.FALSE |
| 575 | stepResult = assignResult |
| 576 | utilities.assert_equals( expect=main.TRUE, |
| 577 | actual=stepResult, |
| 578 | onpass="Successfully assigned switches" + |
| 579 | "to controller", |
| 580 | onfail="Failed to assign switches to " + |
| 581 | "controller" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 582 | if not stepResult: |
| 583 | main.initialized = main.FALSE |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 584 | |
| 585 | def CASE13( self,main ): |
| 586 | """ |
| 587 | Create Scapy components |
| 588 | """ |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 589 | if main.initialized == main.FALSE: |
| 590 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 591 | main.skipCase() |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 592 | main.case( "Create scapy components" ) |
| 593 | main.step( "Create scapy components" ) |
| 594 | import json |
| 595 | scapyResult = main.TRUE |
| 596 | for hostName in main.scapyHostNames: |
| 597 | main.Scapy1.createHostComponent( hostName ) |
| 598 | main.scapyHosts.append( getattr( main, hostName ) ) |
| 599 | |
| 600 | main.step( "Start scapy components" ) |
| 601 | for host in main.scapyHosts: |
| 602 | host.startHostCli() |
| 603 | host.startScapy() |
| 604 | host.updateSelf() |
| 605 | main.log.debug( host.name ) |
| 606 | main.log.debug( host.hostIp ) |
| 607 | main.log.debug( host.hostMac ) |
| 608 | |
| 609 | |
| 610 | utilities.assert_equals( expect=main.TRUE, |
| 611 | actual=scapyResult, |
| 612 | onpass="Successfully created Scapy Components", |
| 613 | onfail="Failed to discover Scapy Components" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 614 | if not scapyResult: |
| 615 | main.initialized = main.FALSE |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 616 | |
| 617 | def CASE14( self, main ): |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 618 | """ |
| 619 | Discover all hosts and store its data to a dictionary |
| 620 | """ |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 621 | if main.initialized == main.FALSE: |
| 622 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 623 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 624 | main.case( "Discover all hosts" ) |
| 625 | |
| 626 | stepResult = main.TRUE |
kelvin-onlab | 0e68468 | 2015-08-11 18:51:41 -0700 | [diff] [blame] | 627 | main.step( "Discover all ipv4 host hosts " ) |
| 628 | hostList = [] |
| 629 | # List of host with default vlan |
| 630 | defaultHosts = [ "h1", "h3", "h8", "h9", "h11", "h16", "h17", "h19", "h24" ] |
| 631 | # Lists of host with unique vlan |
| 632 | vlanHosts1 = [ "h4", "h12", "h20" ] |
| 633 | vlanHosts2 = [ "h5", "h13", "h21" ] |
| 634 | vlanHosts3 = [ "h6", "h14", "h22" ] |
| 635 | vlanHosts4 = [ "h7", "h15", "h23" ] |
| 636 | hostList.append( defaultHosts ) |
| 637 | hostList.append( vlanHosts1 ) |
| 638 | hostList.append( vlanHosts2 ) |
| 639 | hostList.append( vlanHosts3 ) |
| 640 | hostList.append( vlanHosts4 ) |
| 641 | |
| 642 | stepResult = main.intentFunction.getHostsData( main, hostList ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 643 | utilities.assert_equals( expect=main.TRUE, |
| 644 | actual=stepResult, |
| 645 | onpass="Successfully discovered hosts", |
| 646 | onfail="Failed to discover hosts" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 647 | if not stepResult: |
| 648 | main.initialized = main.FALSE |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 649 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 650 | def CASE15( self, main ): |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 651 | """ |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 652 | Discover all hosts with scapy arp packets and store its data to a dictionary |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 653 | """ |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 654 | if main.initialized == main.FALSE: |
| 655 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 656 | main.skipCase() |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 657 | main.case( "Discover all hosts using scapy" ) |
| 658 | main.step( "Send packets from each host to the first host and confirm onos discovery" ) |
| 659 | |
| 660 | import collections |
| 661 | if len( main.scapyHosts ) < 1: |
| 662 | main.log.error( "No scapy hosts have been created" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 663 | main.initialized = main.FALSE |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 664 | main.skipCase() |
| 665 | |
| 666 | # Send ARP packets from each scapy host component |
| 667 | main.intentFunction.sendDiscoveryArp( main, main.scapyHosts ) |
| 668 | |
| 669 | stepResult = utilities.retry( f=main.intentFunction.confirmHostDiscovery, |
| 670 | retValue=main.FALSE, args=[ main ], |
| 671 | attempts=main.checkTopoAttempts, sleep=2 ) |
| 672 | |
| 673 | utilities.assert_equals( expect=main.TRUE, |
| 674 | actual=stepResult, |
| 675 | onpass="ONOS correctly discovered all hosts", |
| 676 | onfail="ONOS incorrectly discovered hosts" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 677 | if not stepResult: |
| 678 | main.initialized = main.FALSE |
| 679 | main.skipCase() |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 680 | |
| 681 | main.step( "Populate hostsData" ) |
| 682 | stepResult = main.intentFunction.populateHostData( main ) |
| 683 | utilities.assert_equals( expect=main.TRUE, |
| 684 | actual=stepResult, |
| 685 | onpass="Successfully populated hostsData", |
| 686 | onfail="Failed to populate hostsData" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 687 | if not stepResult: |
| 688 | main.initialized = main.FALSE |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 689 | |
| 690 | def CASE16( self, main ): |
| 691 | """ |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 692 | Balance Masters |
| 693 | """ |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 694 | if main.initialized == main.FALSE: |
| 695 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 696 | main.skipCase() |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 697 | main.case( "Balance mastership of switches" ) |
| 698 | main.step( "Balancing mastership of switches" ) |
| 699 | |
| 700 | balanceResult = main.FALSE |
| 701 | balanceResult = utilities.retry( f=main.CLIs2[ 0 ].balanceMasters, retValue=main.FALSE, args=[] ) |
| 702 | |
| 703 | utilities.assert_equals( expect=main.TRUE, |
| 704 | actual=stepResult, |
| 705 | onpass="Successfully balanced mastership of switches", |
| 706 | onfail="Failed to balance mastership of switches" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 707 | if not stepResult: |
| 708 | main.initialized = main.FALSE |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 709 | |
| 710 | def CASE17( self, main ): |
| 711 | """ |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 712 | Use Flow Objectives |
| 713 | """ |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 714 | if main.initialized == main.FALSE: |
| 715 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 716 | main.skipCase() |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 717 | main.case( "Enable intent compilation using Flow Objectives" ) |
| 718 | main.step( "Enabling Flow Objectives" ) |
| 719 | |
| 720 | main.flowCompiler = "Flow Objectives" |
| 721 | |
| 722 | cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator" |
| 723 | |
| 724 | stepResult = main.CLIs2[ 0 ].setCfg( component=cmd, |
| 725 | propName="useFlowObjectives", value="true" ) |
| 726 | |
| 727 | utilities.assert_equals( expect=main.TRUE, |
| 728 | actual=stepResult, |
| 729 | onpass="Successfully activated Flow Objectives", |
| 730 | onfail="Failed to activate Flow Objectives" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 731 | if not stepResult: |
| 732 | main.initialized = main.FALSE |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 733 | |
| 734 | def CASE18( self, main ): |
| 735 | """ |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 736 | Stop mininet and remove scapy hosts |
| 737 | """ |
| 738 | main.log.report( "Stop Mininet and Scapy" ) |
| 739 | main.case( "Stop Mininet and Scapy" ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 740 | main.caseExplanation = "Stopping the current mininet topology " +\ |
| 741 | "to start up fresh" |
| 742 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 743 | main.step( "Stopping and Removing Scapy Host Components" ) |
| 744 | scapyResult = main.TRUE |
| 745 | for host in main.scapyHosts: |
| 746 | scapyResult = scapyResult and host.stopScapy() |
| 747 | main.log.info( "Stopped Scapy Host: {0}".format( host.name ) ) |
| 748 | |
| 749 | for host in main.scapyHosts: |
| 750 | scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name ) |
| 751 | main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) ) |
| 752 | |
| 753 | main.scapyHosts = [] |
| 754 | main.scapyHostIPs = [] |
| 755 | |
| 756 | utilities.assert_equals( expect=main.TRUE, |
| 757 | actual=scapyResult, |
| 758 | onpass="Successfully stopped scapy and removed host components", |
| 759 | onfail="Failed to stop mininet and scapy" ) |
| 760 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 761 | main.step( "Stopping Mininet Topology" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 762 | mininetResult = main.Mininet1.stopNet( ) |
| 763 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 764 | utilities.assert_equals( expect=main.TRUE, |
| 765 | actual=stepResult, |
| 766 | onpass="Successfully stop mininet", |
| 767 | onfail="Failed to stop mininet" ) |
| 768 | # Exit if topology did not load properly |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 769 | if not (mininetResult and scapyResult ): |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 770 | main.cleanup() |
| 771 | main.exit() |
| 772 | |
| 773 | def CASE1000( self, main ): |
| 774 | """ |
| 775 | Add host intents between 2 host: |
| 776 | - Discover hosts |
| 777 | - Add host intents |
| 778 | - Check intents |
| 779 | - Verify flows |
| 780 | - Ping hosts |
| 781 | - Reroute |
| 782 | - Link down |
| 783 | - Verify flows |
| 784 | - Check topology |
| 785 | - Ping hosts |
| 786 | - Link up |
| 787 | - Verify flows |
| 788 | - Check topology |
| 789 | - Ping hosts |
| 790 | - Remove intents |
| 791 | """ |
| 792 | import time |
| 793 | import json |
| 794 | import re |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 795 | if main.initialized == main.FALSE: |
| 796 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 797 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 798 | # Assert variables - These variable's name|format must be followed |
| 799 | # if you want to use the wrapper function |
| 800 | assert main, "There is no main" |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 801 | try: |
| 802 | assert main.CLIs |
| 803 | except AssertionError: |
| 804 | main.log.error( "There is no main.CLIs, skipping test cases" ) |
| 805 | main.initialized = main.FALSE |
| 806 | main.skipCase() |
| 807 | try: |
| 808 | assert main.Mininet1 |
| 809 | except AssertionError: |
| 810 | main.log.error( "Mininet handle should be named Mininet1, skipping test cases" ) |
| 811 | main.initialized = main.FALSE |
| 812 | main.skipCase() |
| 813 | try: |
| 814 | assert main.numSwitch |
| 815 | except AssertionError: |
| 816 | main.log.error( "Place the total number of switch topology in \ |
| 817 | main.numSwitch" ) |
| 818 | main.initialized = main.FALSE |
| 819 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 820 | |
Jeremy | e1ea060 | 2016-02-08 16:35:05 -0800 | [diff] [blame] | 821 | # Save leader candidates |
| 822 | intentLeadersOld = main.CLIs2[ 0 ].leaderCandidates() |
| 823 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 824 | main.case( "Host Intents Test - " + str( main.numCtrls ) + |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 825 | " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 826 | main.caseExplanation = "This test case tests Host intents using " +\ |
| 827 | str( main.numCtrls ) + " node(s) cluster;\n" +\ |
| 828 | "Different type of hosts will be tested in " +\ |
| 829 | "each step such as IPV4, Dual stack, VLAN " +\ |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 830 | "etc;\nThe test will use OF " + main.OFProtocol +\ |
| 831 | " OVS running in Mininet and compile intents" +\ |
| 832 | " using " + main.flowCompiler |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 833 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 834 | main.step( "IPV4: Add and test host intents between h1 and h9" ) |
| 835 | main.assertReturnString = "Assertion result for IPV4 host intent with mac addresses\n" |
| 836 | host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" } |
| 837 | host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" } |
| 838 | testResult = main.FALSE |
| 839 | installResult = main.intentFunction.installHostIntent( main, |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 840 | name='IPV4', |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 841 | onosNode='0', |
| 842 | host1=host1, |
| 843 | host2=host2 ) |
| 844 | |
| 845 | if installResult: |
| 846 | testResult = main.intentFunction.testHostIntent( main, |
| 847 | name='IPV4', |
| 848 | intentId = installResult, |
| 849 | onosNode='0', |
| 850 | host1=host1, |
| 851 | host2=host2, |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 852 | sw1='s5', |
| 853 | sw2='s2', |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 854 | expectedLink = 18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 855 | |
| 856 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 857 | actual=testResult, |
| 858 | onpass=main.assertReturnString, |
| 859 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 860 | |
| 861 | main.step( "DUALSTACK1: Add host intents between h3 and h11" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 862 | main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n" |
| 863 | host1 = { "name":"h3", "id":"00:00:00:00:00:03/-1" } |
| 864 | host2 = { "name":"h11","id":"00:00:00:00:00:0B/-1"} |
| 865 | testResult = main.FALSE |
| 866 | installResult = main.intentFunction.installHostIntent( main, |
| 867 | name='DUALSTACK1', |
| 868 | onosNode='0', |
| 869 | host1=host1, |
| 870 | host2=host2 ) |
| 871 | |
| 872 | if installResult: |
| 873 | testResult = main.intentFunction.testHostIntent( main, |
| 874 | name='DUALSTACK1', |
| 875 | intentId = installResult, |
| 876 | onosNode='0', |
| 877 | host1=host1, |
| 878 | host2=host2, |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 879 | sw1='s5', |
| 880 | sw2='s2', |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 881 | expectedLink = 18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 882 | |
| 883 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 884 | actual=testResult, |
| 885 | onpass=main.assertReturnString, |
| 886 | onfail=main.assertReturnString) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 887 | |
| 888 | main.step( "DUALSTACK2: Add host intents between h1 and h11" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 889 | main.assertReturnString = "Assertion Result for dualstack2 host intent\n" |
| 890 | host1 = { "name":"h1" } |
| 891 | host2 = { "name":"h11" } |
| 892 | testResult = main.FALSE |
| 893 | installResult = main.intentFunction.installHostIntent( main, |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 894 | name='DUALSTACK2', |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 895 | onosNode='0', |
| 896 | host1=host1, |
| 897 | host2=host2 ) |
| 898 | |
| 899 | if installResult: |
| 900 | testResult = main.intentFunction.testHostIntent( main, |
| 901 | name='DUALSTACK2', |
| 902 | intentId = installResult, |
| 903 | onosNode='0', |
| 904 | host1=host1, |
| 905 | host2=host2, |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 906 | sw1='s5', |
| 907 | sw2='s2', |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 908 | expectedLink = 18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 909 | |
| 910 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 911 | actual=testResult, |
| 912 | onpass=main.assertReturnString, |
| 913 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 914 | |
| 915 | main.step( "1HOP: Add host intents between h1 and h3" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 916 | main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n" |
| 917 | host1 = { "name":"h1" } |
| 918 | host2 = { "name":"h3" } |
| 919 | testResult = main.FALSE |
| 920 | installResult = main.intentFunction.installHostIntent( main, |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 921 | name='1HOP', |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 922 | onosNode='0', |
| 923 | host1=host1, |
| 924 | host2=host2 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 925 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 926 | if installResult: |
| 927 | testResult = main.intentFunction.testHostIntent( main, |
| 928 | name='1HOP', |
| 929 | intentId = installResult, |
| 930 | onosNode='0', |
| 931 | host1=host1, |
| 932 | host2=host2, |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 933 | sw1='s5', |
| 934 | sw2='s2', |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 935 | expectedLink = 18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 936 | |
| 937 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 938 | actual=testResult, |
| 939 | onpass=main.assertReturnString, |
| 940 | onfail=main.assertReturnString ) |
| 941 | |
| 942 | main.step( "VLAN1: Add vlan host intents between h4 and h12" ) |
| 943 | main.assertReturnString = "Assertion Result vlan IPV4\n" |
| 944 | host1 = { "name":"h4","id":"00:00:00:00:00:04/100" } |
| 945 | host2 = { "name":"h12","id":"00:00:00:00:00:0C/100" } |
| 946 | testResult = main.FALSE |
| 947 | installResult = main.intentFunction.installHostIntent( main, |
| 948 | name='VLAN1', |
| 949 | onosNode='0', |
| 950 | host1=host1, |
| 951 | host2=host2 ) |
| 952 | |
| 953 | if installResult: |
| 954 | testResult = main.intentFunction.testHostIntent( main, |
| 955 | name='VLAN1', |
| 956 | intentId = installResult, |
| 957 | onosNode='0', |
| 958 | host1=host1, |
| 959 | host2=host2, |
| 960 | sw1='s5', |
| 961 | sw2='s2', |
| 962 | expectedLink = 18 ) |
| 963 | |
| 964 | utilities.assert_equals( expect=main.TRUE, |
| 965 | actual=testResult, |
| 966 | onpass=main.assertReturnString, |
| 967 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 968 | |
| 969 | main.step( "VLAN2: Add inter vlan host intents between h13 and h20" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 970 | main.assertReturnString = "Assertion Result different VLAN negative test\n" |
| 971 | host1 = { "name":"h13" } |
| 972 | host2 = { "name":"h20" } |
| 973 | testResult = main.FALSE |
| 974 | installResult = main.intentFunction.installHostIntent( main, |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 975 | name='VLAN2', |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 976 | onosNode='0', |
| 977 | host1=host1, |
| 978 | host2=host2 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 979 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 980 | if installResult: |
| 981 | testResult = main.intentFunction.testHostIntent( main, |
| 982 | name='VLAN2', |
| 983 | intentId = installResult, |
| 984 | onosNode='0', |
| 985 | host1=host1, |
| 986 | host2=host2, |
| 987 | sw1='s5', |
| 988 | sw2='s2', |
| 989 | expectedLink = 18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 990 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 991 | utilities.assert_equals( expect=main.TRUE, |
| 992 | actual=testResult, |
| 993 | onpass=main.assertReturnString, |
| 994 | onfail=main.assertReturnString ) |
| 995 | |
Jeremy | e1ea060 | 2016-02-08 16:35:05 -0800 | [diff] [blame] | 996 | # Change the following to use the REST API when leader checking is |
| 997 | # supported by it |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 998 | |
Jeremy | e1ea060 | 2016-02-08 16:35:05 -0800 | [diff] [blame] | 999 | main.step( "Confirm that ONOS leadership is unchanged") |
| 1000 | intentLeadersNew = main.CLIs2[ 0 ].leaderCandidates() |
| 1001 | main.intentFunction.checkLeaderChange( intentLeadersOld, |
| 1002 | intentLeadersNew ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1003 | |
Jeremy | e1ea060 | 2016-02-08 16:35:05 -0800 | [diff] [blame] | 1004 | utilities.assert_equals( expect=main.TRUE, |
| 1005 | actual=testResult, |
| 1006 | onpass="ONOS Leaders Unchanged", |
| 1007 | onfail="ONOS Leader Mismatch") |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1008 | |
| 1009 | main.intentFunction.report( main ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1010 | |
| 1011 | def CASE2000( self, main ): |
| 1012 | """ |
| 1013 | Add point intents between 2 hosts: |
| 1014 | - Get device ids | ports |
| 1015 | - Add point intents |
| 1016 | - Check intents |
| 1017 | - Verify flows |
| 1018 | - Ping hosts |
| 1019 | - Reroute |
| 1020 | - Link down |
| 1021 | - Verify flows |
| 1022 | - Check topology |
| 1023 | - Ping hosts |
| 1024 | - Link up |
| 1025 | - Verify flows |
| 1026 | - Check topology |
| 1027 | - Ping hosts |
| 1028 | - Remove intents |
| 1029 | """ |
| 1030 | import time |
| 1031 | import json |
| 1032 | import re |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 1033 | if main.initialized == main.FALSE: |
| 1034 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 1035 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1036 | # Assert variables - These variable's name|format must be followed |
| 1037 | # if you want to use the wrapper function |
| 1038 | assert main, "There is no main" |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 1039 | try: |
| 1040 | assert main.CLIs |
| 1041 | except AssertionError: |
| 1042 | main.log.error( "There is no main.CLIs, skipping test cases" ) |
| 1043 | main.initialized = main.FALSE |
| 1044 | main.skipCase() |
| 1045 | try: |
| 1046 | assert main.Mininet1 |
| 1047 | except AssertionError: |
| 1048 | main.log.error( "Mininet handle should be named Mininet1, skipping test cases" ) |
| 1049 | main.initialized = main.FALSE |
| 1050 | main.skipCase() |
| 1051 | try: |
| 1052 | assert main.numSwitch |
| 1053 | except AssertionError: |
| 1054 | main.log.error( "Place the total number of switch topology in \ |
| 1055 | main.numSwitch" ) |
| 1056 | main.initialized = main.FALSE |
| 1057 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1058 | |
| 1059 | main.case( "Point Intents Test - " + str( main.numCtrls ) + |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 1060 | " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1061 | main.caseExplanation = "This test case will test point to point" +\ |
| 1062 | " intents using " + str( main.numCtrls ) +\ |
| 1063 | " 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 +\ |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 1067 | " OVS running in Mininet and compile intents" +\ |
| 1068 | " using " + main.flowCompiler |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1069 | |
| 1070 | # No option point intents |
| 1071 | main.step( "NOOPTION: Add point intents between h1 and h9" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1072 | main.assertReturnString = "Assertion Result for NOOPTION point intent\n" |
| 1073 | senders = [ |
| 1074 | { "name":"h1","device":"of:0000000000000005/1" } |
| 1075 | ] |
| 1076 | recipients = [ |
| 1077 | { "name":"h9","device":"of:0000000000000006/1" } |
| 1078 | ] |
| 1079 | testResult = main.FALSE |
| 1080 | installResult = main.intentFunction.installPointIntent( |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1081 | main, |
| 1082 | name="NOOPTION", |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1083 | senders=senders, |
| 1084 | recipients=recipients ) |
| 1085 | |
| 1086 | if installResult: |
| 1087 | testResult = main.intentFunction.testPointIntent( |
| 1088 | main, |
| 1089 | intentId=installResult, |
| 1090 | name="NOOPTION", |
| 1091 | senders=senders, |
| 1092 | recipients=recipients, |
| 1093 | sw1="s5", |
| 1094 | sw2="s2", |
| 1095 | expectedLink=18) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1096 | |
| 1097 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1098 | actual=testResult, |
| 1099 | onpass=main.assertReturnString, |
| 1100 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1101 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1102 | main.step( "IPV4: Add point intents between h1 and h9" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1103 | main.assertReturnString = "Assertion Result for IPV4 point intent\n" |
| 1104 | senders = [ |
| 1105 | { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" } |
| 1106 | ] |
| 1107 | recipients = [ |
| 1108 | { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09" } |
| 1109 | ] |
| 1110 | installResult = main.intentFunction.installPointIntent( |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1111 | main, |
| 1112 | name="IPV4", |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1113 | senders=senders, |
| 1114 | recipients=recipients, |
| 1115 | ethType="IPV4" ) |
| 1116 | |
| 1117 | if installResult: |
| 1118 | testResult = main.intentFunction.testPointIntent( |
| 1119 | main, |
| 1120 | intentId=installResult, |
| 1121 | name="IPV4", |
| 1122 | senders=senders, |
| 1123 | recipients=recipients, |
| 1124 | sw1="s5", |
| 1125 | sw2="s2", |
| 1126 | expectedLink=18) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1127 | |
| 1128 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1129 | actual=testResult, |
| 1130 | onpass=main.assertReturnString, |
| 1131 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1132 | main.step( "IPV4_2: Add point intents between h1 and h9" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1133 | main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n" |
| 1134 | senders = [ |
| 1135 | { "name":"h1","device":"of:0000000000000005/1" } |
| 1136 | ] |
| 1137 | recipients = [ |
| 1138 | { "name":"h9","device":"of:0000000000000006/1" } |
| 1139 | ] |
| 1140 | installResult = main.intentFunction.installPointIntent( |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1141 | main, |
| 1142 | name="IPV4_2", |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1143 | senders=senders, |
| 1144 | recipients=recipients, |
| 1145 | ethType="IPV4" ) |
| 1146 | |
| 1147 | if installResult: |
| 1148 | testResult = main.intentFunction.testPointIntent( |
| 1149 | main, |
| 1150 | intentId=installResult, |
| 1151 | name="IPV4_2", |
| 1152 | senders=senders, |
| 1153 | recipients=recipients, |
| 1154 | sw1="s5", |
| 1155 | sw2="s2", |
| 1156 | expectedLink=18) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1157 | |
| 1158 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1159 | actual=testResult, |
| 1160 | onpass=main.assertReturnString, |
| 1161 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1162 | |
kelvin-onlab | 0e68468 | 2015-08-11 18:51:41 -0700 | [diff] [blame] | 1163 | main.step( "SDNIP-ICMP: Add point intents between h1 and h9" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1164 | main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n" |
| 1165 | senders = [ |
| 1166 | { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01", |
| 1167 | "ip":main.h1.hostIp } |
| 1168 | ] |
| 1169 | recipients = [ |
| 1170 | { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09", |
| 1171 | "ip":main.h9.hostIp } |
| 1172 | ] |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1173 | ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ] |
| 1174 | # Uneccessary, not including this in the selectors |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1175 | tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ] |
| 1176 | tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ] |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1177 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1178 | installResult = main.intentFunction.installPointIntent( |
| 1179 | main, |
| 1180 | name="SDNIP-ICMP", |
| 1181 | senders=senders, |
| 1182 | recipients=recipients, |
| 1183 | ethType="IPV4", |
| 1184 | ipProto=ipProto, |
| 1185 | tcpSrc=tcpSrc, |
| 1186 | tcpDst=tcpDst ) |
| 1187 | |
| 1188 | if installResult: |
| 1189 | testResult = main.intentFunction.testPointIntent( |
| 1190 | main, |
| 1191 | intentId=installResult, |
| 1192 | name="SDNIP_ICMP", |
| 1193 | senders=senders, |
| 1194 | recipients=recipients, |
| 1195 | sw1="s5", |
| 1196 | sw2="s2", |
| 1197 | expectedLink=18) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1198 | |
| 1199 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1200 | actual=testResult, |
| 1201 | onpass=main.assertReturnString, |
| 1202 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1203 | |
kelvin-onlab | 0e68468 | 2015-08-11 18:51:41 -0700 | [diff] [blame] | 1204 | main.step( "SDNIP-TCP: Add point intents between h1 and h9" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1205 | main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n" |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1206 | mac1 = main.hostsData[ 'h1' ][ 'mac' ] |
| 1207 | mac2 = main.hostsData[ 'h9' ][ 'mac' ] |
kelvin-onlab | 0e68468 | 2015-08-11 18:51:41 -0700 | [diff] [blame] | 1208 | ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32" |
| 1209 | ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32" |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1210 | ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ] |
| 1211 | tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ] |
| 1212 | tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ] |
| 1213 | |
kelvin-onlab | 0e68468 | 2015-08-11 18:51:41 -0700 | [diff] [blame] | 1214 | stepResult = main.intentFunction.pointIntentTcp( |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1215 | main, |
kelvin-onlab | 0e68468 | 2015-08-11 18:51:41 -0700 | [diff] [blame] | 1216 | name="SDNIP-TCP", |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1217 | host1="h1", |
| 1218 | host2="h9", |
| 1219 | deviceId1="of:0000000000000005/1", |
| 1220 | deviceId2="of:0000000000000006/1", |
| 1221 | mac1=mac1, |
| 1222 | mac2=mac2, |
| 1223 | ethType="IPV4", |
kelvin-onlab | 0e68468 | 2015-08-11 18:51:41 -0700 | [diff] [blame] | 1224 | ipProto=ipProto, |
| 1225 | ip1=ip1, |
| 1226 | ip2=ip2, |
| 1227 | tcp1=tcp1, |
| 1228 | tcp2=tcp2 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1229 | |
| 1230 | utilities.assert_equals( expect=main.TRUE, |
| 1231 | actual=stepResult, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1232 | onpass=main.assertReturnString, |
| 1233 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1234 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1235 | main.step( "DUALSTACK1: Add point intents between h3 and h11" ) |
| 1236 | main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n" |
| 1237 | senders = [ |
| 1238 | { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" } |
| 1239 | ] |
| 1240 | recipients = [ |
| 1241 | { "name":"h11","device":"of:0000000000000006/3","mac":"00:00:00:00:00:0B" } |
| 1242 | ] |
| 1243 | installResult = main.intentFunction.installPointIntent( |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1244 | main, |
| 1245 | name="DUALSTACK1", |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1246 | senders=senders, |
| 1247 | recipients=recipients, |
| 1248 | ethType="IPV4" ) |
| 1249 | |
| 1250 | if installResult: |
| 1251 | testResult = main.intentFunction.testPointIntent( |
| 1252 | main, |
| 1253 | intentId=installResult, |
| 1254 | name="DUALSTACK1", |
| 1255 | senders=senders, |
| 1256 | recipients=recipients, |
| 1257 | sw1="s5", |
| 1258 | sw2="s2", |
| 1259 | expectedLink=18) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1260 | |
| 1261 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1262 | actual=testResult, |
| 1263 | onpass=main.assertReturnString, |
| 1264 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1265 | |
| 1266 | main.step( "VLAN: Add point intents between h5 and h21" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1267 | main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n" |
| 1268 | senders = [ |
| 1269 | { "name":"h5","device":"of:0000000000000005/5","mac":"00:00:00:00:00:05" } |
| 1270 | ] |
| 1271 | recipients = [ |
| 1272 | { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15" } |
| 1273 | ] |
| 1274 | installResult = main.intentFunction.installPointIntent( |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1275 | main, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1276 | name="DUALSTACK1", |
| 1277 | senders=senders, |
| 1278 | recipients=recipients, |
| 1279 | ethType="IPV4" ) |
| 1280 | |
| 1281 | if installResult: |
| 1282 | testResult = main.intentFunction.testPointIntent( |
| 1283 | main, |
| 1284 | intentId=installResult, |
| 1285 | name="DUALSTACK1", |
| 1286 | senders=senders, |
| 1287 | recipients=recipients, |
| 1288 | sw1="s5", |
| 1289 | sw2="s2", |
| 1290 | expectedLink=18) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1291 | |
| 1292 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1293 | actual=testResult, |
| 1294 | onpass=main.assertReturnString, |
| 1295 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1296 | |
| 1297 | main.step( "1HOP: Add point intents between h1 and h3" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1298 | main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n" |
| 1299 | senders = [ |
| 1300 | { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" } |
| 1301 | ] |
| 1302 | recipients = [ |
| 1303 | { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" } |
| 1304 | ] |
| 1305 | installResult = main.intentFunction.installPointIntent( |
| 1306 | main, |
| 1307 | name="1HOP IPV4", |
| 1308 | senders=senders, |
| 1309 | recipients=recipients, |
| 1310 | ethType="IPV4" ) |
| 1311 | |
| 1312 | if installResult: |
| 1313 | testResult = main.intentFunction.testPointIntent( |
| 1314 | main, |
| 1315 | intentId=installResult, |
| 1316 | name="1HOP IPV4", |
| 1317 | senders=senders, |
| 1318 | recipients=recipients, |
| 1319 | sw1="s5", |
| 1320 | sw2="s2", |
| 1321 | expectedLink=18) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1322 | |
| 1323 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1324 | actual=testResult, |
| 1325 | onpass=main.assertReturnString, |
| 1326 | onfail=main.assertReturnString ) |
| 1327 | |
| 1328 | main.intentFunction.report( main ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1329 | |
| 1330 | def CASE3000( self, main ): |
| 1331 | """ |
| 1332 | Add single point to multi point intents |
| 1333 | - Get device ids |
| 1334 | - Add single point to multi point intents |
| 1335 | - Check intents |
| 1336 | - Verify flows |
| 1337 | - Ping hosts |
| 1338 | - Reroute |
| 1339 | - Link down |
| 1340 | - Verify flows |
| 1341 | - Check topology |
| 1342 | - Ping hosts |
| 1343 | - Link up |
| 1344 | - Verify flows |
| 1345 | - Check topology |
| 1346 | - Ping hosts |
| 1347 | - Remove intents |
| 1348 | """ |
| 1349 | assert main, "There is no main" |
| 1350 | assert main.CLIs, "There is no main.CLIs" |
| 1351 | assert main.Mininet1, "Mininet handle should be named Mininet1" |
| 1352 | assert main.numSwitch, "Placed the total number of switch topology in \ |
| 1353 | main.numSwitch" |
| 1354 | |
| 1355 | main.case( "Single To Multi Point Intents Test - " + |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 1356 | str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1357 | main.caseExplanation = "This test case will test single point to" +\ |
| 1358 | " multi point intents using " +\ |
| 1359 | str( main.numCtrls ) + " node(s) cluster;\n" +\ |
| 1360 | "Different type of hosts will be tested in " +\ |
| 1361 | "each step such as IPV4, Dual stack, VLAN etc" +\ |
| 1362 | ";\nThe test will use OF " + main.OFProtocol +\ |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 1363 | " OVS running in Mininet and compile intents" +\ |
| 1364 | " using " + main.flowCompiler |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1365 | |
| 1366 | main.step( "NOOPTION: Add single point to multi point intents" ) |
| 1367 | stepResult = main.TRUE |
| 1368 | hostNames = [ 'h8', 'h16', 'h24' ] |
| 1369 | devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \ |
| 1370 | 'of:0000000000000007/8' ] |
| 1371 | macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ] |
| 1372 | stepResult = main.intentFunction.singleToMultiIntent( |
| 1373 | main, |
| 1374 | name="NOOPTION", |
| 1375 | hostNames=hostNames, |
| 1376 | devices=devices, |
| 1377 | sw1="s5", |
| 1378 | sw2="s2", |
| 1379 | expectedLink=18 ) |
| 1380 | |
| 1381 | utilities.assert_equals( expect=main.TRUE, |
| 1382 | actual=stepResult, |
| 1383 | onpass="NOOPTION: Successfully added single " |
| 1384 | + " point to multi point intents" + |
| 1385 | " with no match action", |
| 1386 | onfail="NOOPTION: Failed to add single point" |
| 1387 | + " point to multi point intents" + |
| 1388 | " with no match action" ) |
| 1389 | |
| 1390 | main.step( "IPV4: Add single point to multi point intents" ) |
| 1391 | stepResult = main.TRUE |
| 1392 | stepResult = main.intentFunction.singleToMultiIntent( |
| 1393 | main, |
| 1394 | name="IPV4", |
| 1395 | hostNames=hostNames, |
| 1396 | devices=devices, |
| 1397 | ports=None, |
| 1398 | ethType="IPV4", |
| 1399 | macs=macs, |
| 1400 | bandwidth="", |
| 1401 | lambdaAlloc=False, |
| 1402 | ipProto="", |
| 1403 | ipAddresses="", |
| 1404 | tcp="", |
| 1405 | sw1="s5", |
| 1406 | sw2="s2", |
| 1407 | expectedLink=18 ) |
| 1408 | |
| 1409 | utilities.assert_equals( expect=main.TRUE, |
| 1410 | actual=stepResult, |
| 1411 | onpass="IPV4: Successfully added single " |
| 1412 | + " point to multi point intents" + |
| 1413 | " with IPV4 type and MAC addresses", |
| 1414 | onfail="IPV4: Failed to add single point" |
| 1415 | + " point to multi point intents" + |
| 1416 | " with IPV4 type and MAC addresses" ) |
| 1417 | |
| 1418 | main.step( "IPV4_2: Add single point to multi point intents" ) |
| 1419 | stepResult = main.TRUE |
| 1420 | hostNames = [ 'h8', 'h16', 'h24' ] |
| 1421 | stepResult = main.intentFunction.singleToMultiIntent( |
| 1422 | main, |
| 1423 | name="IPV4", |
| 1424 | hostNames=hostNames, |
| 1425 | ethType="IPV4", |
| 1426 | lambdaAlloc=False ) |
| 1427 | |
| 1428 | utilities.assert_equals( expect=main.TRUE, |
| 1429 | actual=stepResult, |
| 1430 | onpass="IPV4_2: Successfully added single " |
| 1431 | + " point to multi point intents" + |
| 1432 | " with IPV4 type and no MAC addresses", |
| 1433 | onfail="IPV4_2: Failed to add single point" |
| 1434 | + " point to multi point intents" + |
| 1435 | " with IPV4 type and no MAC addresses" ) |
| 1436 | |
| 1437 | main.step( "VLAN: Add single point to multi point intents" ) |
| 1438 | stepResult = main.TRUE |
| 1439 | hostNames = [ 'h4', 'h12', 'h20' ] |
| 1440 | devices = [ 'of:0000000000000005/4', 'of:0000000000000006/4', \ |
| 1441 | 'of:0000000000000007/4' ] |
| 1442 | macs = [ '00:00:00:00:00:04', '00:00:00:00:00:0C', '00:00:00:00:00:14' ] |
| 1443 | stepResult = main.intentFunction.singleToMultiIntent( |
| 1444 | main, |
| 1445 | name="VLAN", |
| 1446 | hostNames=hostNames, |
| 1447 | devices=devices, |
| 1448 | ports=None, |
| 1449 | ethType="IPV4", |
| 1450 | macs=macs, |
| 1451 | bandwidth="", |
| 1452 | lambdaAlloc=False, |
| 1453 | ipProto="", |
| 1454 | ipAddresses="", |
| 1455 | tcp="", |
| 1456 | sw1="s5", |
| 1457 | sw2="s2", |
| 1458 | expectedLink=18 ) |
| 1459 | |
| 1460 | utilities.assert_equals( expect=main.TRUE, |
| 1461 | actual=stepResult, |
| 1462 | onpass="VLAN: Successfully added single " |
| 1463 | + " point to multi point intents" + |
| 1464 | " with IPV4 type and MAC addresses" + |
| 1465 | " in the same VLAN", |
| 1466 | onfail="VLAN: Failed to add single point" |
| 1467 | + " point to multi point intents" + |
| 1468 | " with IPV4 type and MAC addresses" + |
| 1469 | " in the same VLAN") |
| 1470 | |
| 1471 | def CASE4000( self, main ): |
| 1472 | """ |
| 1473 | Add multi point to single point intents |
| 1474 | - Get device ids |
| 1475 | - Add multi point to single point intents |
| 1476 | - Check intents |
| 1477 | - Verify flows |
| 1478 | - Ping hosts |
| 1479 | - Reroute |
| 1480 | - Link down |
| 1481 | - Verify flows |
| 1482 | - Check topology |
| 1483 | - Ping hosts |
| 1484 | - Link up |
| 1485 | - Verify flows |
| 1486 | - Check topology |
| 1487 | - Ping hosts |
| 1488 | - Remove intents |
| 1489 | """ |
| 1490 | assert main, "There is no main" |
| 1491 | assert main.CLIs, "There is no main.CLIs" |
| 1492 | assert main.Mininet1, "Mininet handle should be named Mininet1" |
| 1493 | assert main.numSwitch, "Placed the total number of switch topology in \ |
| 1494 | main.numSwitch" |
| 1495 | |
| 1496 | main.case( "Multi To Single Point Intents Test - " + |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 1497 | str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1498 | main.caseExplanation = "This test case will test single point to" +\ |
| 1499 | " multi point intents using " +\ |
| 1500 | str( main.numCtrls ) + " node(s) cluster;\n" +\ |
| 1501 | "Different type of hosts will be tested in " +\ |
| 1502 | "each step such as IPV4, Dual stack, VLAN etc" +\ |
| 1503 | ";\nThe test will use OF " + main.OFProtocol +\ |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 1504 | " OVS running in Mininet and compile intents" +\ |
| 1505 | " using " + main.flowCompiler |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1506 | |
| 1507 | main.step( "NOOPTION: Add multi point to single point intents" ) |
| 1508 | stepResult = main.TRUE |
| 1509 | hostNames = [ 'h8', 'h16', 'h24' ] |
| 1510 | devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \ |
| 1511 | 'of:0000000000000007/8' ] |
| 1512 | macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ] |
| 1513 | stepResult = main.intentFunction.multiToSingleIntent( |
| 1514 | main, |
| 1515 | name="NOOPTION", |
| 1516 | hostNames=hostNames, |
| 1517 | devices=devices, |
| 1518 | sw1="s5", |
| 1519 | sw2="s2", |
| 1520 | expectedLink=18 ) |
| 1521 | |
| 1522 | utilities.assert_equals( expect=main.TRUE, |
| 1523 | actual=stepResult, |
| 1524 | onpass="NOOPTION: Successfully added multi " |
| 1525 | + " point to single point intents" + |
| 1526 | " with no match action", |
| 1527 | onfail="NOOPTION: Failed to add multi point" + |
| 1528 | " to single point intents" + |
| 1529 | " with no match action" ) |
| 1530 | |
| 1531 | main.step( "IPV4: Add multi point to single point intents" ) |
| 1532 | stepResult = main.TRUE |
| 1533 | stepResult = main.intentFunction.multiToSingleIntent( |
| 1534 | main, |
| 1535 | name="IPV4", |
| 1536 | hostNames=hostNames, |
| 1537 | devices=devices, |
| 1538 | ports=None, |
| 1539 | ethType="IPV4", |
| 1540 | macs=macs, |
| 1541 | bandwidth="", |
| 1542 | lambdaAlloc=False, |
| 1543 | ipProto="", |
| 1544 | ipAddresses="", |
| 1545 | tcp="", |
| 1546 | sw1="s5", |
| 1547 | sw2="s2", |
| 1548 | expectedLink=18 ) |
| 1549 | |
| 1550 | utilities.assert_equals( expect=main.TRUE, |
| 1551 | actual=stepResult, |
| 1552 | onpass="IPV4: Successfully added multi point" |
| 1553 | + " to single point intents" + |
| 1554 | " with IPV4 type and MAC addresses", |
| 1555 | onfail="IPV4: Failed to add multi point" + |
| 1556 | " to single point intents" + |
| 1557 | " with IPV4 type and MAC addresses" ) |
| 1558 | |
| 1559 | main.step( "IPV4_2: Add multi point to single point intents" ) |
| 1560 | stepResult = main.TRUE |
| 1561 | hostNames = [ 'h8', 'h16', 'h24' ] |
| 1562 | stepResult = main.intentFunction.multiToSingleIntent( |
| 1563 | main, |
| 1564 | name="IPV4", |
| 1565 | hostNames=hostNames, |
| 1566 | ethType="IPV4", |
| 1567 | lambdaAlloc=False ) |
| 1568 | |
| 1569 | utilities.assert_equals( expect=main.TRUE, |
| 1570 | actual=stepResult, |
| 1571 | onpass="IPV4_2: Successfully added multi point" |
| 1572 | + " to single point intents" + |
| 1573 | " with IPV4 type and no MAC addresses", |
| 1574 | onfail="IPV4_2: Failed to add multi point" + |
| 1575 | " to single point intents" + |
| 1576 | " with IPV4 type and no MAC addresses" ) |
| 1577 | |
| 1578 | main.step( "VLAN: Add multi point to single point intents" ) |
| 1579 | stepResult = main.TRUE |
| 1580 | hostNames = [ 'h5', 'h13', 'h21' ] |
| 1581 | devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \ |
| 1582 | 'of:0000000000000007/5' ] |
| 1583 | macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ] |
| 1584 | stepResult = main.intentFunction.multiToSingleIntent( |
| 1585 | main, |
| 1586 | name="VLAN", |
| 1587 | hostNames=hostNames, |
| 1588 | devices=devices, |
| 1589 | ports=None, |
| 1590 | ethType="IPV4", |
| 1591 | macs=macs, |
| 1592 | bandwidth="", |
| 1593 | lambdaAlloc=False, |
| 1594 | ipProto="", |
| 1595 | ipAddresses="", |
| 1596 | tcp="", |
| 1597 | sw1="s5", |
| 1598 | sw2="s2", |
| 1599 | expectedLink=18 ) |
| 1600 | |
| 1601 | utilities.assert_equals( expect=main.TRUE, |
| 1602 | actual=stepResult, |
| 1603 | onpass="VLAN: Successfully added multi point" |
| 1604 | + " to single point intents" + |
| 1605 | " with IPV4 type and MAC addresses" + |
| 1606 | " in the same VLAN", |
| 1607 | onfail="VLAN: Failed to add multi point" + |
| 1608 | " to single point intents" ) |
| 1609 | |
| 1610 | def CASE5000( self, main ): |
| 1611 | """ |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1612 | Tests Host Mobility |
| 1613 | Modifies the topology location of h1 |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1614 | """ |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 1615 | if main.initialized == main.FALSE: |
| 1616 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 1617 | main.skipCase() |
| 1618 | # Assert variables - These variable's name|format must be followed |
| 1619 | # if you want to use the wrapper function |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1620 | assert main, "There is no main" |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 1621 | try: |
| 1622 | assert main.CLIs |
| 1623 | except AssertionError: |
| 1624 | main.log.error( "There is no main.CLIs, skipping test cases" ) |
| 1625 | main.initialized = main.FALSE |
| 1626 | main.skipCase() |
| 1627 | try: |
| 1628 | assert main.Mininet1 |
| 1629 | except AssertionError: |
| 1630 | main.log.error( "Mininet handle should be named Mininet1, skipping test cases" ) |
| 1631 | main.initialized = main.FALSE |
| 1632 | main.skipCase() |
| 1633 | try: |
| 1634 | assert main.numSwitch |
| 1635 | except AssertionError: |
| 1636 | main.log.error( "Place the total number of switch topology in \ |
| 1637 | main.numSwitch" ) |
| 1638 | main.initialized = main.FALSE |
| 1639 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1640 | main.case( "Test host mobility with host intents " ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1641 | main.step( "Testing host mobility by moving h1 from s5 to s6" ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1642 | h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ] |
| 1643 | |
| 1644 | main.log.info( "Moving h1 from s5 to s6") |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1645 | main.Mininet1.moveHost( "h1","s5","s6" ) |
| 1646 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1647 | # Send discovery ping from moved host |
| 1648 | # Moving the host brings down the default interfaces and creates a new one. |
| 1649 | # Scapy is restarted on this host to detect the new interface |
| 1650 | main.h1.stopScapy() |
| 1651 | main.h1.startScapy() |
| 1652 | |
| 1653 | # Discover new host location in ONOS and populate host data. |
| 1654 | # Host 1 IP and MAC should be unchanged |
| 1655 | main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] ) |
| 1656 | main.intentFunction.populateHostData( main ) |
| 1657 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1658 | h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ] |
| 1659 | |
| 1660 | utilities.assert_equals( expect="of:0000000000000006", |
| 1661 | actual=h1PostMove, |
| 1662 | onpass="Mobility: Successfully moved h1 to s6", |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1663 | onfail="Mobility: Failed to move h1 to s6" + |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1664 | " to single point intents" + |
| 1665 | " with IPV4 type and MAC addresses" + |
| 1666 | " in the same VLAN" ) |
| 1667 | |
| 1668 | main.step( "IPV4: Add host intents between h1 and h9" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1669 | main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n" |
| 1670 | host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" } |
| 1671 | host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" } |
| 1672 | |
| 1673 | installResult = main.intentFunction.installHostIntent( main, |
| 1674 | name='IPV4 Mobility IPV4', |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1675 | onosNode='0', |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1676 | host1=host1, |
| 1677 | host2=host2) |
| 1678 | if installResult: |
| 1679 | testResult = main.intentFunction.testHostIntent( main, |
| 1680 | name='Host Mobility IPV4', |
| 1681 | intentId = installResult, |
| 1682 | onosNode='0', |
| 1683 | host1=host1, |
| 1684 | host2=host2, |
| 1685 | sw1="s6", |
| 1686 | sw2="s2", |
| 1687 | expectedLink=18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1688 | |
| 1689 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1690 | actual=testResult, |
| 1691 | onpass=main.assertReturnString, |
| 1692 | onfail=main.assertReturnString ) |
| 1693 | |
| 1694 | main.intentFunction.report( main ) |
| 1695 | |