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