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" |
Jeremy Songster | ae2dd45 | 2016-05-17 16:44:35 -0700 | [diff] [blame] | 944 | host1 = { "name":"h4","id":"00:00:00:00:00:04/100", "vlanId":"100" } |
| 945 | host2 = { "name":"h12","id":"00:00:00:00:00:0C/100", "vlanId":"100" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 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 | |
Jeremy Songster | ae2dd45 | 2016-05-17 16:44:35 -0700 | [diff] [blame] | 969 | # This step isn't currently possible to perform in the REST API |
| 970 | # main.step( "VLAN2: Add inter vlan host intents between h13 and h20" ) |
| 971 | # main.assertReturnString = "Assertion Result different VLAN negative test\n" |
| 972 | # host1 = { "name":"h13" } |
| 973 | # host2 = { "name":"h20" } |
| 974 | # testResult = main.FALSE |
| 975 | # installResult = main.intentFunction.installHostIntent( main, |
| 976 | # name='VLAN2', |
| 977 | # onosNode='0', |
| 978 | # host1=host1, |
| 979 | # host2=host2 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 980 | |
Jeremy Songster | ae2dd45 | 2016-05-17 16:44:35 -0700 | [diff] [blame] | 981 | # if installResult: |
| 982 | # testResult = main.intentFunction.testHostIntent( main, |
| 983 | # name='VLAN2', |
| 984 | # intentId = installResult, |
| 985 | # onosNode='0', |
| 986 | # host1=host1, |
| 987 | # host2=host2, |
| 988 | # sw1='s5', |
| 989 | # sw2='s2', |
| 990 | # expectedLink = 18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 991 | |
Jeremy Songster | ae2dd45 | 2016-05-17 16:44:35 -0700 | [diff] [blame] | 992 | # utilities.assert_equals( expect=main.TRUE, |
| 993 | # actual=testResult, |
| 994 | # onpass=main.assertReturnString, |
| 995 | # onfail=main.assertReturnString ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 996 | |
Jeremy | e1ea060 | 2016-02-08 16:35:05 -0800 | [diff] [blame] | 997 | # Change the following to use the REST API when leader checking is |
| 998 | # supported by it |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 999 | |
Jeremy | e1ea060 | 2016-02-08 16:35:05 -0800 | [diff] [blame] | 1000 | main.step( "Confirm that ONOS leadership is unchanged") |
| 1001 | intentLeadersNew = main.CLIs2[ 0 ].leaderCandidates() |
| 1002 | main.intentFunction.checkLeaderChange( intentLeadersOld, |
| 1003 | intentLeadersNew ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1004 | |
Jeremy | e1ea060 | 2016-02-08 16:35:05 -0800 | [diff] [blame] | 1005 | utilities.assert_equals( expect=main.TRUE, |
| 1006 | actual=testResult, |
| 1007 | onpass="ONOS Leaders Unchanged", |
| 1008 | onfail="ONOS Leader Mismatch") |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1009 | |
| 1010 | main.intentFunction.report( main ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1011 | |
| 1012 | def CASE2000( self, main ): |
| 1013 | """ |
| 1014 | Add point intents between 2 hosts: |
| 1015 | - Get device ids | ports |
| 1016 | - Add point intents |
| 1017 | - Check intents |
| 1018 | - Verify flows |
| 1019 | - Ping hosts |
| 1020 | - Reroute |
| 1021 | - Link down |
| 1022 | - Verify flows |
| 1023 | - Check topology |
| 1024 | - Ping hosts |
| 1025 | - Link up |
| 1026 | - Verify flows |
| 1027 | - Check topology |
| 1028 | - Ping hosts |
| 1029 | - Remove intents |
| 1030 | """ |
| 1031 | import time |
| 1032 | import json |
| 1033 | import re |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 1034 | if main.initialized == main.FALSE: |
| 1035 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 1036 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1037 | # Assert variables - These variable's name|format must be followed |
| 1038 | # if you want to use the wrapper function |
| 1039 | assert main, "There is no main" |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 1040 | try: |
| 1041 | assert main.CLIs |
| 1042 | except AssertionError: |
| 1043 | main.log.error( "There is no main.CLIs, skipping test cases" ) |
| 1044 | main.initialized = main.FALSE |
| 1045 | main.skipCase() |
| 1046 | try: |
| 1047 | assert main.Mininet1 |
| 1048 | except AssertionError: |
| 1049 | main.log.error( "Mininet handle should be named Mininet1, skipping test cases" ) |
| 1050 | main.initialized = main.FALSE |
| 1051 | main.skipCase() |
| 1052 | try: |
| 1053 | assert main.numSwitch |
| 1054 | except AssertionError: |
| 1055 | main.log.error( "Place the total number of switch topology in \ |
| 1056 | main.numSwitch" ) |
| 1057 | main.initialized = main.FALSE |
| 1058 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1059 | |
| 1060 | main.case( "Point Intents Test - " + str( main.numCtrls ) + |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 1061 | " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1062 | main.caseExplanation = "This test case will test point to point" +\ |
| 1063 | " intents using " + str( main.numCtrls ) +\ |
| 1064 | " node(s) cluster;\n" +\ |
| 1065 | "Different type of hosts will be tested in " +\ |
| 1066 | "each step such as IPV4, Dual stack, VLAN etc" +\ |
| 1067 | ";\nThe test will use OF " + main.OFProtocol +\ |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 1068 | " OVS running in Mininet and compile intents" +\ |
| 1069 | " using " + main.flowCompiler |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1070 | |
| 1071 | # No option point intents |
| 1072 | main.step( "NOOPTION: Add point intents between h1 and h9" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1073 | main.assertReturnString = "Assertion Result for NOOPTION point intent\n" |
| 1074 | senders = [ |
| 1075 | { "name":"h1","device":"of:0000000000000005/1" } |
| 1076 | ] |
| 1077 | recipients = [ |
| 1078 | { "name":"h9","device":"of:0000000000000006/1" } |
| 1079 | ] |
| 1080 | testResult = main.FALSE |
| 1081 | installResult = main.intentFunction.installPointIntent( |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1082 | main, |
| 1083 | name="NOOPTION", |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1084 | senders=senders, |
| 1085 | recipients=recipients ) |
| 1086 | |
| 1087 | if installResult: |
| 1088 | testResult = main.intentFunction.testPointIntent( |
| 1089 | main, |
| 1090 | intentId=installResult, |
| 1091 | name="NOOPTION", |
| 1092 | senders=senders, |
| 1093 | recipients=recipients, |
| 1094 | sw1="s5", |
| 1095 | sw2="s2", |
| 1096 | expectedLink=18) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1097 | |
| 1098 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1099 | actual=testResult, |
| 1100 | onpass=main.assertReturnString, |
| 1101 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1102 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1103 | main.step( "IPV4: Add point intents between h1 and h9" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1104 | main.assertReturnString = "Assertion Result for IPV4 point intent\n" |
| 1105 | senders = [ |
| 1106 | { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" } |
| 1107 | ] |
| 1108 | recipients = [ |
| 1109 | { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09" } |
| 1110 | ] |
| 1111 | installResult = main.intentFunction.installPointIntent( |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1112 | main, |
| 1113 | name="IPV4", |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1114 | senders=senders, |
| 1115 | recipients=recipients, |
| 1116 | ethType="IPV4" ) |
| 1117 | |
| 1118 | if installResult: |
| 1119 | testResult = main.intentFunction.testPointIntent( |
| 1120 | main, |
| 1121 | intentId=installResult, |
| 1122 | name="IPV4", |
| 1123 | senders=senders, |
| 1124 | recipients=recipients, |
| 1125 | sw1="s5", |
| 1126 | sw2="s2", |
| 1127 | expectedLink=18) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1128 | |
| 1129 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1130 | actual=testResult, |
| 1131 | onpass=main.assertReturnString, |
| 1132 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1133 | main.step( "IPV4_2: Add point intents between h1 and h9" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1134 | main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n" |
| 1135 | senders = [ |
| 1136 | { "name":"h1","device":"of:0000000000000005/1" } |
| 1137 | ] |
| 1138 | recipients = [ |
| 1139 | { "name":"h9","device":"of:0000000000000006/1" } |
| 1140 | ] |
| 1141 | installResult = main.intentFunction.installPointIntent( |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1142 | main, |
| 1143 | name="IPV4_2", |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1144 | senders=senders, |
| 1145 | recipients=recipients, |
| 1146 | ethType="IPV4" ) |
| 1147 | |
| 1148 | if installResult: |
| 1149 | testResult = main.intentFunction.testPointIntent( |
| 1150 | main, |
| 1151 | intentId=installResult, |
| 1152 | name="IPV4_2", |
| 1153 | senders=senders, |
| 1154 | recipients=recipients, |
| 1155 | sw1="s5", |
| 1156 | sw2="s2", |
| 1157 | expectedLink=18) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1158 | |
| 1159 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1160 | actual=testResult, |
| 1161 | onpass=main.assertReturnString, |
| 1162 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1163 | |
kelvin-onlab | 0e68468 | 2015-08-11 18:51:41 -0700 | [diff] [blame] | 1164 | main.step( "SDNIP-ICMP: Add point intents between h1 and h9" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1165 | main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n" |
| 1166 | senders = [ |
| 1167 | { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01", |
| 1168 | "ip":main.h1.hostIp } |
| 1169 | ] |
| 1170 | recipients = [ |
| 1171 | { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09", |
| 1172 | "ip":main.h9.hostIp } |
| 1173 | ] |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1174 | ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ] |
| 1175 | # Uneccessary, not including this in the selectors |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1176 | tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ] |
| 1177 | tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ] |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1178 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1179 | installResult = main.intentFunction.installPointIntent( |
| 1180 | main, |
| 1181 | name="SDNIP-ICMP", |
| 1182 | senders=senders, |
| 1183 | recipients=recipients, |
| 1184 | ethType="IPV4", |
| 1185 | ipProto=ipProto, |
| 1186 | tcpSrc=tcpSrc, |
| 1187 | tcpDst=tcpDst ) |
| 1188 | |
| 1189 | if installResult: |
| 1190 | testResult = main.intentFunction.testPointIntent( |
| 1191 | main, |
| 1192 | intentId=installResult, |
| 1193 | name="SDNIP_ICMP", |
| 1194 | senders=senders, |
| 1195 | recipients=recipients, |
| 1196 | sw1="s5", |
| 1197 | sw2="s2", |
Jeremy Songster | ae2dd45 | 2016-05-17 16:44:35 -0700 | [diff] [blame] | 1198 | expectedLink=18, |
| 1199 | useTCP=True ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1200 | |
| 1201 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1202 | actual=testResult, |
| 1203 | onpass=main.assertReturnString, |
| 1204 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1205 | |
kelvin-onlab | 0e68468 | 2015-08-11 18:51:41 -0700 | [diff] [blame] | 1206 | main.step( "SDNIP-TCP: Add point intents between h1 and h9" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1207 | 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] | 1208 | mac1 = main.hostsData[ 'h1' ][ 'mac' ] |
| 1209 | mac2 = main.hostsData[ 'h9' ][ 'mac' ] |
kelvin-onlab | 0e68468 | 2015-08-11 18:51:41 -0700 | [diff] [blame] | 1210 | ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32" |
| 1211 | ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32" |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1212 | ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ] |
| 1213 | tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ] |
| 1214 | tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ] |
| 1215 | |
kelvin-onlab | 0e68468 | 2015-08-11 18:51:41 -0700 | [diff] [blame] | 1216 | stepResult = main.intentFunction.pointIntentTcp( |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1217 | main, |
kelvin-onlab | 0e68468 | 2015-08-11 18:51:41 -0700 | [diff] [blame] | 1218 | name="SDNIP-TCP", |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1219 | host1="h1", |
| 1220 | host2="h9", |
| 1221 | deviceId1="of:0000000000000005/1", |
| 1222 | deviceId2="of:0000000000000006/1", |
| 1223 | mac1=mac1, |
| 1224 | mac2=mac2, |
| 1225 | ethType="IPV4", |
kelvin-onlab | 0e68468 | 2015-08-11 18:51:41 -0700 | [diff] [blame] | 1226 | ipProto=ipProto, |
| 1227 | ip1=ip1, |
| 1228 | ip2=ip2, |
| 1229 | tcp1=tcp1, |
| 1230 | tcp2=tcp2 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1231 | |
| 1232 | utilities.assert_equals( expect=main.TRUE, |
| 1233 | actual=stepResult, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1234 | onpass=main.assertReturnString, |
| 1235 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1236 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1237 | main.step( "DUALSTACK1: Add point intents between h3 and h11" ) |
| 1238 | main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n" |
| 1239 | senders = [ |
| 1240 | { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" } |
| 1241 | ] |
| 1242 | recipients = [ |
| 1243 | { "name":"h11","device":"of:0000000000000006/3","mac":"00:00:00:00:00:0B" } |
| 1244 | ] |
| 1245 | installResult = main.intentFunction.installPointIntent( |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1246 | main, |
| 1247 | name="DUALSTACK1", |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1248 | senders=senders, |
| 1249 | recipients=recipients, |
| 1250 | ethType="IPV4" ) |
| 1251 | |
| 1252 | if installResult: |
| 1253 | testResult = main.intentFunction.testPointIntent( |
| 1254 | main, |
| 1255 | intentId=installResult, |
| 1256 | name="DUALSTACK1", |
| 1257 | senders=senders, |
| 1258 | recipients=recipients, |
| 1259 | sw1="s5", |
| 1260 | sw2="s2", |
| 1261 | expectedLink=18) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1262 | |
| 1263 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1264 | actual=testResult, |
| 1265 | onpass=main.assertReturnString, |
| 1266 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1267 | |
| 1268 | main.step( "VLAN: Add point intents between h5 and h21" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1269 | main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n" |
| 1270 | senders = [ |
Jeremy Songster | ae2dd45 | 2016-05-17 16:44:35 -0700 | [diff] [blame] | 1271 | { "name":"h5","device":"of:0000000000000005/5","mac":"00:00:00:00:00:05", "vlanId":"200" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1272 | ] |
| 1273 | recipients = [ |
Jeremy Songster | ae2dd45 | 2016-05-17 16:44:35 -0700 | [diff] [blame] | 1274 | { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15", "vlanId":"200" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1275 | ] |
| 1276 | installResult = main.intentFunction.installPointIntent( |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1277 | main, |
Jeremy Songster | ae2dd45 | 2016-05-17 16:44:35 -0700 | [diff] [blame] | 1278 | name="VLAN", |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1279 | senders=senders, |
Jeremy Songster | ae2dd45 | 2016-05-17 16:44:35 -0700 | [diff] [blame] | 1280 | recipients=recipients ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1281 | |
| 1282 | if installResult: |
| 1283 | testResult = main.intentFunction.testPointIntent( |
| 1284 | main, |
| 1285 | intentId=installResult, |
Jeremy Songster | ae2dd45 | 2016-05-17 16:44:35 -0700 | [diff] [blame] | 1286 | name="VLAN", |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1287 | senders=senders, |
| 1288 | recipients=recipients, |
| 1289 | sw1="s5", |
| 1290 | sw2="s2", |
| 1291 | expectedLink=18) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1292 | |
| 1293 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1294 | actual=testResult, |
| 1295 | onpass=main.assertReturnString, |
| 1296 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1297 | |
Jeremy Songster | ae2dd45 | 2016-05-17 16:44:35 -0700 | [diff] [blame] | 1298 | # TODO: implement VLAN selector REST API intent test once supported |
| 1299 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1300 | main.step( "1HOP: Add point intents between h1 and h3" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1301 | main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n" |
| 1302 | senders = [ |
| 1303 | { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" } |
| 1304 | ] |
| 1305 | recipients = [ |
| 1306 | { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" } |
| 1307 | ] |
| 1308 | installResult = main.intentFunction.installPointIntent( |
| 1309 | main, |
| 1310 | name="1HOP IPV4", |
| 1311 | senders=senders, |
| 1312 | recipients=recipients, |
| 1313 | ethType="IPV4" ) |
| 1314 | |
| 1315 | if installResult: |
| 1316 | testResult = main.intentFunction.testPointIntent( |
| 1317 | main, |
| 1318 | intentId=installResult, |
| 1319 | name="1HOP IPV4", |
| 1320 | senders=senders, |
| 1321 | recipients=recipients, |
| 1322 | sw1="s5", |
| 1323 | sw2="s2", |
| 1324 | expectedLink=18) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1325 | |
| 1326 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1327 | actual=testResult, |
| 1328 | onpass=main.assertReturnString, |
| 1329 | onfail=main.assertReturnString ) |
| 1330 | |
| 1331 | main.intentFunction.report( main ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1332 | |
| 1333 | def CASE3000( self, main ): |
| 1334 | """ |
| 1335 | Add single point to multi point intents |
| 1336 | - Get device ids |
| 1337 | - Add single point to multi point intents |
| 1338 | - Check intents |
| 1339 | - Verify flows |
| 1340 | - Ping hosts |
| 1341 | - Reroute |
| 1342 | - Link down |
| 1343 | - Verify flows |
| 1344 | - Check topology |
| 1345 | - Ping hosts |
| 1346 | - Link up |
| 1347 | - Verify flows |
| 1348 | - Check topology |
| 1349 | - Ping hosts |
| 1350 | - Remove intents |
| 1351 | """ |
| 1352 | assert main, "There is no main" |
| 1353 | assert main.CLIs, "There is no main.CLIs" |
| 1354 | assert main.Mininet1, "Mininet handle should be named Mininet1" |
| 1355 | assert main.numSwitch, "Placed the total number of switch topology in \ |
| 1356 | main.numSwitch" |
| 1357 | |
| 1358 | main.case( "Single To Multi Point Intents Test - " + |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 1359 | str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1360 | main.caseExplanation = "This test case will test single point to" +\ |
| 1361 | " multi point intents using " +\ |
| 1362 | str( main.numCtrls ) + " node(s) cluster;\n" +\ |
| 1363 | "Different type of hosts will be tested in " +\ |
| 1364 | "each step such as IPV4, Dual stack, VLAN etc" +\ |
| 1365 | ";\nThe test will use OF " + main.OFProtocol +\ |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 1366 | " OVS running in Mininet and compile intents" +\ |
| 1367 | " using " + main.flowCompiler |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1368 | |
| 1369 | main.step( "NOOPTION: Add single point to multi point intents" ) |
| 1370 | stepResult = main.TRUE |
| 1371 | hostNames = [ 'h8', 'h16', 'h24' ] |
| 1372 | devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \ |
| 1373 | 'of:0000000000000007/8' ] |
| 1374 | macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ] |
| 1375 | stepResult = main.intentFunction.singleToMultiIntent( |
| 1376 | main, |
| 1377 | name="NOOPTION", |
| 1378 | hostNames=hostNames, |
| 1379 | devices=devices, |
| 1380 | sw1="s5", |
| 1381 | sw2="s2", |
| 1382 | expectedLink=18 ) |
| 1383 | |
| 1384 | utilities.assert_equals( expect=main.TRUE, |
| 1385 | actual=stepResult, |
| 1386 | onpass="NOOPTION: Successfully added single " |
| 1387 | + " point to multi point intents" + |
| 1388 | " with no match action", |
| 1389 | onfail="NOOPTION: Failed to add single point" |
| 1390 | + " point to multi point intents" + |
| 1391 | " with no match action" ) |
| 1392 | |
| 1393 | main.step( "IPV4: Add single point to multi point intents" ) |
| 1394 | stepResult = main.TRUE |
| 1395 | stepResult = main.intentFunction.singleToMultiIntent( |
| 1396 | main, |
| 1397 | name="IPV4", |
| 1398 | hostNames=hostNames, |
| 1399 | devices=devices, |
| 1400 | ports=None, |
| 1401 | ethType="IPV4", |
| 1402 | macs=macs, |
| 1403 | bandwidth="", |
| 1404 | lambdaAlloc=False, |
| 1405 | ipProto="", |
| 1406 | ipAddresses="", |
| 1407 | tcp="", |
| 1408 | sw1="s5", |
| 1409 | sw2="s2", |
| 1410 | expectedLink=18 ) |
| 1411 | |
| 1412 | utilities.assert_equals( expect=main.TRUE, |
| 1413 | actual=stepResult, |
| 1414 | onpass="IPV4: Successfully added single " |
| 1415 | + " point to multi point intents" + |
| 1416 | " with IPV4 type and MAC addresses", |
| 1417 | onfail="IPV4: Failed to add single point" |
| 1418 | + " point to multi point intents" + |
| 1419 | " with IPV4 type and MAC addresses" ) |
| 1420 | |
| 1421 | main.step( "IPV4_2: Add single point to multi point intents" ) |
| 1422 | stepResult = main.TRUE |
| 1423 | hostNames = [ 'h8', 'h16', 'h24' ] |
| 1424 | stepResult = main.intentFunction.singleToMultiIntent( |
| 1425 | main, |
| 1426 | name="IPV4", |
| 1427 | hostNames=hostNames, |
| 1428 | ethType="IPV4", |
| 1429 | lambdaAlloc=False ) |
| 1430 | |
| 1431 | utilities.assert_equals( expect=main.TRUE, |
| 1432 | actual=stepResult, |
| 1433 | onpass="IPV4_2: Successfully added single " |
| 1434 | + " point to multi point intents" + |
| 1435 | " with IPV4 type and no MAC addresses", |
| 1436 | onfail="IPV4_2: Failed to add single point" |
| 1437 | + " point to multi point intents" + |
| 1438 | " with IPV4 type and no MAC addresses" ) |
| 1439 | |
| 1440 | main.step( "VLAN: Add single point to multi point intents" ) |
| 1441 | stepResult = main.TRUE |
| 1442 | hostNames = [ 'h4', 'h12', 'h20' ] |
| 1443 | devices = [ 'of:0000000000000005/4', 'of:0000000000000006/4', \ |
| 1444 | 'of:0000000000000007/4' ] |
| 1445 | macs = [ '00:00:00:00:00:04', '00:00:00:00:00:0C', '00:00:00:00:00:14' ] |
| 1446 | stepResult = main.intentFunction.singleToMultiIntent( |
| 1447 | main, |
| 1448 | name="VLAN", |
| 1449 | hostNames=hostNames, |
| 1450 | devices=devices, |
| 1451 | ports=None, |
| 1452 | ethType="IPV4", |
| 1453 | macs=macs, |
| 1454 | bandwidth="", |
| 1455 | lambdaAlloc=False, |
| 1456 | ipProto="", |
| 1457 | ipAddresses="", |
| 1458 | tcp="", |
| 1459 | sw1="s5", |
| 1460 | sw2="s2", |
| 1461 | expectedLink=18 ) |
| 1462 | |
| 1463 | utilities.assert_equals( expect=main.TRUE, |
| 1464 | actual=stepResult, |
| 1465 | onpass="VLAN: Successfully added single " |
| 1466 | + " point to multi point intents" + |
| 1467 | " with IPV4 type and MAC addresses" + |
| 1468 | " in the same VLAN", |
| 1469 | onfail="VLAN: Failed to add single point" |
| 1470 | + " point to multi point intents" + |
| 1471 | " with IPV4 type and MAC addresses" + |
| 1472 | " in the same VLAN") |
| 1473 | |
| 1474 | def CASE4000( self, main ): |
| 1475 | """ |
| 1476 | Add multi point to single point intents |
| 1477 | - Get device ids |
| 1478 | - Add multi point to single point intents |
| 1479 | - Check intents |
| 1480 | - Verify flows |
| 1481 | - Ping hosts |
| 1482 | - Reroute |
| 1483 | - Link down |
| 1484 | - Verify flows |
| 1485 | - Check topology |
| 1486 | - Ping hosts |
| 1487 | - Link up |
| 1488 | - Verify flows |
| 1489 | - Check topology |
| 1490 | - Ping hosts |
| 1491 | - Remove intents |
| 1492 | """ |
| 1493 | assert main, "There is no main" |
| 1494 | assert main.CLIs, "There is no main.CLIs" |
| 1495 | assert main.Mininet1, "Mininet handle should be named Mininet1" |
| 1496 | assert main.numSwitch, "Placed the total number of switch topology in \ |
| 1497 | main.numSwitch" |
| 1498 | |
| 1499 | main.case( "Multi To Single Point Intents Test - " + |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 1500 | str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1501 | main.caseExplanation = "This test case will test single point to" +\ |
| 1502 | " multi point intents using " +\ |
| 1503 | str( main.numCtrls ) + " node(s) cluster;\n" +\ |
| 1504 | "Different type of hosts will be tested in " +\ |
| 1505 | "each step such as IPV4, Dual stack, VLAN etc" +\ |
| 1506 | ";\nThe test will use OF " + main.OFProtocol +\ |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 1507 | " OVS running in Mininet and compile intents" +\ |
| 1508 | " using " + main.flowCompiler |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1509 | |
| 1510 | main.step( "NOOPTION: Add multi point to single point intents" ) |
| 1511 | stepResult = main.TRUE |
| 1512 | hostNames = [ 'h8', 'h16', 'h24' ] |
| 1513 | devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \ |
| 1514 | 'of:0000000000000007/8' ] |
| 1515 | macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ] |
| 1516 | stepResult = main.intentFunction.multiToSingleIntent( |
| 1517 | main, |
| 1518 | name="NOOPTION", |
| 1519 | hostNames=hostNames, |
| 1520 | devices=devices, |
| 1521 | sw1="s5", |
| 1522 | sw2="s2", |
| 1523 | expectedLink=18 ) |
| 1524 | |
| 1525 | utilities.assert_equals( expect=main.TRUE, |
| 1526 | actual=stepResult, |
| 1527 | onpass="NOOPTION: Successfully added multi " |
| 1528 | + " point to single point intents" + |
| 1529 | " with no match action", |
| 1530 | onfail="NOOPTION: Failed to add multi point" + |
| 1531 | " to single point intents" + |
| 1532 | " with no match action" ) |
| 1533 | |
| 1534 | main.step( "IPV4: Add multi point to single point intents" ) |
| 1535 | stepResult = main.TRUE |
| 1536 | stepResult = main.intentFunction.multiToSingleIntent( |
| 1537 | main, |
| 1538 | name="IPV4", |
| 1539 | hostNames=hostNames, |
| 1540 | devices=devices, |
| 1541 | ports=None, |
| 1542 | ethType="IPV4", |
| 1543 | macs=macs, |
| 1544 | bandwidth="", |
| 1545 | lambdaAlloc=False, |
| 1546 | ipProto="", |
| 1547 | ipAddresses="", |
| 1548 | tcp="", |
| 1549 | sw1="s5", |
| 1550 | sw2="s2", |
| 1551 | expectedLink=18 ) |
| 1552 | |
| 1553 | utilities.assert_equals( expect=main.TRUE, |
| 1554 | actual=stepResult, |
| 1555 | onpass="IPV4: Successfully added multi point" |
| 1556 | + " to single point intents" + |
| 1557 | " with IPV4 type and MAC addresses", |
| 1558 | onfail="IPV4: Failed to add multi point" + |
| 1559 | " to single point intents" + |
| 1560 | " with IPV4 type and MAC addresses" ) |
| 1561 | |
| 1562 | main.step( "IPV4_2: Add multi point to single point intents" ) |
| 1563 | stepResult = main.TRUE |
| 1564 | hostNames = [ 'h8', 'h16', 'h24' ] |
| 1565 | stepResult = main.intentFunction.multiToSingleIntent( |
| 1566 | main, |
| 1567 | name="IPV4", |
| 1568 | hostNames=hostNames, |
| 1569 | ethType="IPV4", |
| 1570 | lambdaAlloc=False ) |
| 1571 | |
| 1572 | utilities.assert_equals( expect=main.TRUE, |
| 1573 | actual=stepResult, |
| 1574 | onpass="IPV4_2: Successfully added multi point" |
| 1575 | + " to single point intents" + |
| 1576 | " with IPV4 type and no MAC addresses", |
| 1577 | onfail="IPV4_2: Failed to add multi point" + |
| 1578 | " to single point intents" + |
| 1579 | " with IPV4 type and no MAC addresses" ) |
| 1580 | |
| 1581 | main.step( "VLAN: Add multi point to single point intents" ) |
| 1582 | stepResult = main.TRUE |
| 1583 | hostNames = [ 'h5', 'h13', 'h21' ] |
| 1584 | devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \ |
| 1585 | 'of:0000000000000007/5' ] |
| 1586 | macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ] |
| 1587 | stepResult = main.intentFunction.multiToSingleIntent( |
| 1588 | main, |
| 1589 | name="VLAN", |
| 1590 | hostNames=hostNames, |
| 1591 | devices=devices, |
| 1592 | ports=None, |
| 1593 | ethType="IPV4", |
| 1594 | macs=macs, |
| 1595 | bandwidth="", |
| 1596 | lambdaAlloc=False, |
| 1597 | ipProto="", |
| 1598 | ipAddresses="", |
| 1599 | tcp="", |
| 1600 | sw1="s5", |
| 1601 | sw2="s2", |
| 1602 | expectedLink=18 ) |
| 1603 | |
| 1604 | utilities.assert_equals( expect=main.TRUE, |
| 1605 | actual=stepResult, |
| 1606 | onpass="VLAN: Successfully added multi point" |
| 1607 | + " to single point intents" + |
| 1608 | " with IPV4 type and MAC addresses" + |
| 1609 | " in the same VLAN", |
| 1610 | onfail="VLAN: Failed to add multi point" + |
| 1611 | " to single point intents" ) |
| 1612 | |
| 1613 | def CASE5000( self, main ): |
| 1614 | """ |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1615 | Tests Host Mobility |
| 1616 | Modifies the topology location of h1 |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1617 | """ |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 1618 | if main.initialized == main.FALSE: |
| 1619 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 1620 | main.skipCase() |
| 1621 | # Assert variables - These variable's name|format must be followed |
| 1622 | # if you want to use the wrapper function |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1623 | assert main, "There is no main" |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 1624 | try: |
| 1625 | assert main.CLIs |
| 1626 | except AssertionError: |
| 1627 | main.log.error( "There is no main.CLIs, skipping test cases" ) |
| 1628 | main.initialized = main.FALSE |
| 1629 | main.skipCase() |
| 1630 | try: |
| 1631 | assert main.Mininet1 |
| 1632 | except AssertionError: |
| 1633 | main.log.error( "Mininet handle should be named Mininet1, skipping test cases" ) |
| 1634 | main.initialized = main.FALSE |
| 1635 | main.skipCase() |
| 1636 | try: |
| 1637 | assert main.numSwitch |
| 1638 | except AssertionError: |
| 1639 | main.log.error( "Place the total number of switch topology in \ |
| 1640 | main.numSwitch" ) |
| 1641 | main.initialized = main.FALSE |
| 1642 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1643 | main.case( "Test host mobility with host intents " ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1644 | main.step( "Testing host mobility by moving h1 from s5 to s6" ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1645 | h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ] |
| 1646 | |
| 1647 | main.log.info( "Moving h1 from s5 to s6") |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1648 | main.Mininet1.moveHost( "h1","s5","s6" ) |
| 1649 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1650 | # Send discovery ping from moved host |
| 1651 | # Moving the host brings down the default interfaces and creates a new one. |
| 1652 | # Scapy is restarted on this host to detect the new interface |
| 1653 | main.h1.stopScapy() |
| 1654 | main.h1.startScapy() |
| 1655 | |
| 1656 | # Discover new host location in ONOS and populate host data. |
| 1657 | # Host 1 IP and MAC should be unchanged |
| 1658 | main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] ) |
| 1659 | main.intentFunction.populateHostData( main ) |
| 1660 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1661 | h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ] |
| 1662 | |
| 1663 | utilities.assert_equals( expect="of:0000000000000006", |
| 1664 | actual=h1PostMove, |
| 1665 | onpass="Mobility: Successfully moved h1 to s6", |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1666 | onfail="Mobility: Failed to move h1 to s6" + |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1667 | " to single point intents" + |
| 1668 | " with IPV4 type and MAC addresses" + |
| 1669 | " in the same VLAN" ) |
| 1670 | |
| 1671 | main.step( "IPV4: Add host intents between h1 and h9" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1672 | main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n" |
| 1673 | host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" } |
| 1674 | host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" } |
| 1675 | |
| 1676 | installResult = main.intentFunction.installHostIntent( main, |
| 1677 | name='IPV4 Mobility IPV4', |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1678 | onosNode='0', |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1679 | host1=host1, |
| 1680 | host2=host2) |
| 1681 | if installResult: |
| 1682 | testResult = main.intentFunction.testHostIntent( main, |
| 1683 | name='Host Mobility IPV4', |
| 1684 | intentId = installResult, |
| 1685 | onosNode='0', |
| 1686 | host1=host1, |
| 1687 | host2=host2, |
| 1688 | sw1="s6", |
| 1689 | sw2="s2", |
| 1690 | expectedLink=18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1691 | |
| 1692 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1693 | actual=testResult, |
| 1694 | onpass=main.assertReturnString, |
| 1695 | onfail=main.assertReturnString ) |
| 1696 | |
| 1697 | main.intentFunction.report( main ) |
| 1698 | |