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