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