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