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