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 | 17147f2 | 2016-05-31 18:30:52 -0700 | [diff] [blame] | 673 | i = 0 |
| 674 | for cli in main.CLIs: |
| 675 | main.node = cli |
| 676 | ip = main.ONOSip[ i ] |
| 677 | main.node.ip_address = ip |
Jeremy Songster | 31aad31 | 2016-06-13 16:32:11 -0700 | [diff] [blame] | 678 | scpResult = scpResult and main.ONOSbench.scp( main.node , |
| 679 | "/opt/onos/log/karaf.log", |
| 680 | "/tmp/karaf.log", |
| 681 | direction="from" ) |
| 682 | copyResult = copyResult and main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir, |
| 683 | copyFileName=( "karaf.log.node{0}.cycle{1}".format( str( i + 1 ), str( main.cycle ) ) ) ) |
| 684 | if scpResult and copyResult: |
| 685 | stepResult = main.TRUE and stepResult |
| 686 | else: |
| 687 | stepResult = main.FALSE and stepResult |
Jeremy Songster | 17147f2 | 2016-05-31 18:30:52 -0700 | [diff] [blame] | 688 | i += 1 |
Jeremy Songster | 31aad31 | 2016-06-13 16:32:11 -0700 | [diff] [blame] | 689 | utilities.assert_equals( expect=main.TRUE, |
| 690 | actual=stepResult, |
| 691 | onpass="Successfully copied remote ONOS logs", |
| 692 | onfail="Failed to copy remote ONOS logs" ) |
Jeremy Songster | 17147f2 | 2016-05-31 18:30:52 -0700 | [diff] [blame] | 693 | |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 694 | def CASE1000( self, main ): |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 695 | """ |
| 696 | Add host intents between 2 host: |
| 697 | - Discover hosts |
| 698 | - Add host intents |
| 699 | - Check intents |
| 700 | - Verify flows |
| 701 | - Ping hosts |
| 702 | - Reroute |
| 703 | - Link down |
| 704 | - Verify flows |
| 705 | - Check topology |
| 706 | - Ping hosts |
| 707 | - Link up |
| 708 | - Verify flows |
| 709 | - Check topology |
| 710 | - Ping hosts |
| 711 | - Remove intents |
| 712 | """ |
| 713 | import time |
| 714 | import json |
| 715 | import re |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 716 | if main.initialized == main.FALSE: |
| 717 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 718 | main.skipCase() |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 719 | # Assert variables - These variable's name|format must be followed |
| 720 | # if you want to use the wrapper function |
| 721 | assert main, "There is no main" |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 722 | try: |
| 723 | assert main.CLIs |
| 724 | except AssertionError: |
| 725 | main.log.error( "There is no main.CLIs, skipping test cases" ) |
| 726 | main.initialized = main.FALSE |
| 727 | main.skipCase() |
| 728 | try: |
| 729 | assert main.Mininet1 |
| 730 | except AssertionError: |
| 731 | main.log.error( "Mininet handle should be named Mininet1, skipping test cases" ) |
| 732 | main.initialized = main.FALSE |
| 733 | main.skipCase() |
| 734 | try: |
| 735 | assert main.numSwitch |
| 736 | except AssertionError: |
| 737 | main.log.error( "Place the total number of switch topology in \ |
| 738 | main.numSwitch" ) |
| 739 | main.initialized = main.FALSE |
| 740 | main.skipCase() |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 741 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 742 | # Save leader candidates |
acsmars | e6b410f | 2015-07-17 14:39:34 -0700 | [diff] [blame] | 743 | intentLeadersOld = main.CLIs[ 0 ].leaderCandidates() |
| 744 | |
kelvin-onlab | 7bb2d97 | 2015-08-05 10:56:16 -0700 | [diff] [blame] | 745 | main.testName = "Host Intents" |
| 746 | main.case( main.testName + " Test - " + str( main.numCtrls ) + |
Jeremy | 6e9748f | 2016-03-25 15:03:39 -0700 | [diff] [blame] | 747 | " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler ) |
Jon Hall | 783bbf9 | 2015-07-23 14:33:19 -0700 | [diff] [blame] | 748 | main.caseExplanation = "This test case tests Host intents using " +\ |
kelvin-onlab | 6dea6e6 | 2015-07-23 13:07:26 -0700 | [diff] [blame] | 749 | str( main.numCtrls ) + " node(s) cluster;\n" +\ |
| 750 | "Different type of hosts will be tested in " +\ |
| 751 | "each step such as IPV4, Dual stack, VLAN " +\ |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 752 | "etc;\nThe test will use OF " + main.OFProtocol +\ |
| 753 | " OVS running in Mininet and compile intents" +\ |
Jeremy | 6e9748f | 2016-03-25 15:03:39 -0700 | [diff] [blame] | 754 | " using " + main.flowCompiler |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 755 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 756 | main.step( "IPV4: Add host intents between h1 and h9" ) |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 757 | main.assertReturnString = "Assertion Result for IPV4 host intent with mac addresses\n" |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 758 | host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" } |
| 759 | host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" } |
| 760 | testResult = main.FALSE |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 761 | installResult = main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 762 | installResult = main.intentFunction.installHostIntent( main, |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 763 | name='IPV4', |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 764 | onosNode='0', |
| 765 | host1=host1, |
| 766 | host2=host2) |
| 767 | if installResult: |
| 768 | testResult = main.intentFunction.testHostIntent( main, |
| 769 | name='IPV4', |
| 770 | intentId = installResult, |
| 771 | onosNode='0', |
| 772 | host1=host1, |
| 773 | host2=host2, |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 774 | sw1='s5', |
| 775 | sw2='s2', |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 776 | expectedLink = 18) |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 777 | else: |
| 778 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 779 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 780 | utilities.assert_equals( expect=main.TRUE, |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 781 | actual=testResult, |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 782 | onpass=main.assertReturnString, |
| 783 | onfail=main.assertReturnString) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 784 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 785 | main.step( "DUALSTACK1: Add host intents between h3 and h11" ) |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 786 | main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n" |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 787 | host1 = { "name":"h3","id":"00:00:00:00:00:03/-1" } |
| 788 | host2 = { "name":"h11","id":"00:00:00:00:00:0B/-1 "} |
| 789 | testResult = main.FALSE |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 790 | installResult = main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 791 | installResult = main.intentFunction.installHostIntent( main, |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 792 | name='DUALSTACK', |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 793 | onosNode='0', |
| 794 | host1=host1, |
| 795 | host2=host2) |
| 796 | |
| 797 | if installResult: |
| 798 | testResult = main.intentFunction.testHostIntent( main, |
| 799 | name='DUALSTACK', |
| 800 | intentId = installResult, |
| 801 | onosNode='0', |
| 802 | host1=host1, |
| 803 | host2=host2, |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 804 | sw1='s5', |
| 805 | sw2='s2', |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 806 | expectedLink = 18) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 807 | |
| 808 | utilities.assert_equals( expect=main.TRUE, |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 809 | actual=testResult, |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 810 | onpass=main.assertReturnString, |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 811 | onfail=main.assertReturnString) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 812 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 813 | main.step( "DUALSTACK2: Add host intents between h1 and h11" ) |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 814 | main.assertReturnString = "Assertion Result for dualstack2 host intent\n" |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 815 | host1 = { "name":"h1" } |
| 816 | host2 = { "name":"h11" } |
| 817 | testResult = main.FALSE |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 818 | installResult = main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 819 | installResult = main.intentFunction.installHostIntent( main, |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 820 | name='DUALSTACK2', |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 821 | onosNode='0', |
| 822 | host1=host1, |
| 823 | host2=host2) |
| 824 | |
| 825 | if installResult: |
| 826 | testResult = main.intentFunction.testHostIntent( main, |
| 827 | name='DUALSTACK2', |
| 828 | intentId = installResult, |
| 829 | onosNode='0', |
| 830 | host1=host1, |
| 831 | host2=host2, |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 832 | sw1='s5', |
| 833 | sw2='s2', |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 834 | expectedLink = 18) |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 835 | else: |
| 836 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 837 | |
| 838 | utilities.assert_equals( expect=main.TRUE, |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 839 | actual=testResult, |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 840 | onpass=main.assertReturnString, |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 841 | onfail=main.assertReturnString) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 842 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 843 | main.step( "1HOP: Add host intents between h1 and h3" ) |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 844 | main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n" |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 845 | host1 = { "name":"h1" } |
| 846 | host2 = { "name":"h3" } |
| 847 | testResult = main.FALSE |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 848 | installResult = main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 849 | installResult = main.intentFunction.installHostIntent( main, |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 850 | name='1HOP', |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 851 | onosNode='0', |
| 852 | host1=host1, |
| 853 | host2=host2) |
| 854 | |
| 855 | if installResult: |
| 856 | testResult = main.intentFunction.testHostIntent( main, |
| 857 | name='1HOP', |
| 858 | intentId = installResult, |
| 859 | onosNode='0', |
| 860 | host1=host1, |
| 861 | host2=host2, |
| 862 | sw1='s5', |
| 863 | sw2='s2', |
| 864 | expectedLink = 18) |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 865 | else: |
| 866 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 867 | |
| 868 | utilities.assert_equals( expect=main.TRUE, |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 869 | actual=testResult, |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 870 | onpass=main.assertReturnString, |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 871 | onfail=main.assertReturnString) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 872 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 873 | main.step( "VLAN1: Add vlan host intents between h4 and h12" ) |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 874 | main.assertReturnString = "Assertion Result vlan IPV4\n" |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 875 | host1 = { "name":"h4","id":"00:00:00:00:00:04/100", "vlan":"100" } |
| 876 | 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] | 877 | testResult = main.FALSE |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 878 | installResult = main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 879 | installResult = main.intentFunction.installHostIntent( main, |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 880 | name='VLAN1', |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 881 | onosNode='0', |
| 882 | host1=host1, |
| 883 | host2=host2) |
| 884 | |
| 885 | if installResult: |
| 886 | testResult = main.intentFunction.testHostIntent( main, |
| 887 | name='VLAN1', |
| 888 | intentId = installResult, |
| 889 | onosNode='0', |
| 890 | host1=host1, |
| 891 | host2=host2, |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 892 | sw1='s5', |
| 893 | sw2='s2', |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 894 | expectedLink = 18) |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 895 | else: |
| 896 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 897 | |
| 898 | utilities.assert_equals( expect=main.TRUE, |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 899 | actual=testResult, |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 900 | onpass=main.assertReturnString, |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 901 | onfail=main.assertReturnString) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 902 | |
Jeremy Songster | ff55367 | 2016-05-12 17:06:23 -0700 | [diff] [blame] | 903 | main.step( "VLAN2: Add vlan host intents between h4 and h13" ) |
| 904 | main.assertReturnString = "Assertion Result vlan IPV4\n" |
| 905 | host1 = { "name":"h5", "vlan":"200" } |
| 906 | host2 = { "name":"h12", "vlan":"100" } |
| 907 | testResult = main.FALSE |
| 908 | installResult = main.FALSE |
| 909 | installResult = main.intentFunction.installHostIntent( main, |
| 910 | name='VLAN2', |
| 911 | onosNode='0', |
| 912 | host1=host1, |
| 913 | host2=host2) |
| 914 | |
| 915 | if installResult: |
| 916 | testResult = main.intentFunction.testHostIntent( main, |
| 917 | name='VLAN2', |
| 918 | intentId = installResult, |
| 919 | onosNode='0', |
| 920 | host1=host1, |
| 921 | host2=host2, |
| 922 | sw1='s5', |
| 923 | sw2='s2', |
| 924 | expectedLink = 18) |
| 925 | else: |
| 926 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
| 927 | |
| 928 | utilities.assert_equals( expect=main.TRUE, |
| 929 | actual=testResult, |
| 930 | onpass=main.assertReturnString, |
| 931 | onfail=main.assertReturnString) |
| 932 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 933 | main.step( "Confirm that ONOS leadership is unchanged") |
acsmars | e6b410f | 2015-07-17 14:39:34 -0700 | [diff] [blame] | 934 | intentLeadersNew = main.CLIs[ 0 ].leaderCandidates() |
| 935 | main.intentFunction.checkLeaderChange( intentLeadersOld, |
| 936 | intentLeadersNew ) |
| 937 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 938 | utilities.assert_equals( expect=main.TRUE, |
| 939 | actual=testResult, |
| 940 | onpass="ONOS Leaders Unchanged", |
| 941 | onfail="ONOS Leader Mismatch") |
| 942 | |
kelvin-onlab | 016dce2 | 2015-08-10 09:54:11 -0700 | [diff] [blame] | 943 | main.intentFunction.report( main ) |
| 944 | |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 945 | def CASE2000( self, main ): |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 946 | """ |
| 947 | Add point intents between 2 hosts: |
| 948 | - Get device ids | ports |
| 949 | - Add point intents |
| 950 | - Check intents |
| 951 | - Verify flows |
| 952 | - Ping hosts |
| 953 | - Reroute |
| 954 | - Link down |
| 955 | - Verify flows |
| 956 | - Check topology |
| 957 | - Ping hosts |
| 958 | - Link up |
| 959 | - Verify flows |
| 960 | - Check topology |
| 961 | - Ping hosts |
| 962 | - Remove intents |
| 963 | """ |
| 964 | import time |
| 965 | import json |
| 966 | import re |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 967 | if main.initialized == main.FALSE: |
| 968 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 969 | main.skipCase() |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 970 | # Assert variables - These variable's name|format must be followed |
| 971 | # if you want to use the wrapper function |
| 972 | assert main, "There is no main" |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 973 | try: |
| 974 | assert main.CLIs |
| 975 | except AssertionError: |
| 976 | main.log.error( "There is no main.CLIs, skipping test cases" ) |
| 977 | main.initialized = main.FALSE |
| 978 | main.skipCase() |
| 979 | try: |
| 980 | assert main.Mininet1 |
| 981 | except AssertionError: |
| 982 | main.log.error( "Mininet handle should be named Mininet1, skipping test cases" ) |
| 983 | main.initialized = main.FALSE |
| 984 | main.skipCase() |
| 985 | try: |
| 986 | assert main.numSwitch |
| 987 | except AssertionError: |
| 988 | main.log.error( "Place the total number of switch topology in \ |
| 989 | main.numSwitch" ) |
| 990 | main.initialized = main.FALSE |
| 991 | main.skipCase() |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 992 | |
kelvin-onlab | 7bb2d97 | 2015-08-05 10:56:16 -0700 | [diff] [blame] | 993 | main.testName = "Point Intents" |
| 994 | main.case( main.testName + " Test - " + str( main.numCtrls ) + |
Jeremy | 6e9748f | 2016-03-25 15:03:39 -0700 | [diff] [blame] | 995 | " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler ) |
Jon Hall | 783bbf9 | 2015-07-23 14:33:19 -0700 | [diff] [blame] | 996 | main.caseExplanation = "This test case will test point to point" +\ |
kelvin-onlab | 6dea6e6 | 2015-07-23 13:07:26 -0700 | [diff] [blame] | 997 | " intents using " + str( main.numCtrls ) +\ |
| 998 | " node(s) cluster;\n" +\ |
| 999 | "Different type of hosts will be tested in " +\ |
| 1000 | "each step such as IPV4, Dual stack, VLAN etc" +\ |
| 1001 | ";\nThe test will use OF " + main.OFProtocol +\ |
Jeremy | 6e9748f | 2016-03-25 15:03:39 -0700 | [diff] [blame] | 1002 | " OVS running in Mininet and compile intents" +\ |
| 1003 | " using " + main.flowCompiler |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1004 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1005 | # No option point intents |
| 1006 | main.step( "NOOPTION: Add point intents between h1 and h9" ) |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1007 | main.assertReturnString = "Assertion Result for NOOPTION point intent\n" |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1008 | senders = [ |
| 1009 | { "name":"h1","device":"of:0000000000000005/1" } |
| 1010 | ] |
| 1011 | recipients = [ |
| 1012 | { "name":"h9","device":"of:0000000000000006/1" } |
| 1013 | ] |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1014 | testResult = main.FALSE |
| 1015 | installResult = main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1016 | installResult = main.intentFunction.installPointIntent( |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1017 | main, |
| 1018 | name="NOOPTION", |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1019 | senders=senders, |
| 1020 | recipients=recipients ) |
| 1021 | |
| 1022 | if installResult: |
| 1023 | testResult = main.intentFunction.testPointIntent( |
| 1024 | main, |
| 1025 | intentId=installResult, |
| 1026 | name="NOOPTION", |
| 1027 | senders=senders, |
| 1028 | recipients=recipients, |
| 1029 | sw1="s5", |
| 1030 | sw2="s2", |
| 1031 | expectedLink=18) |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1032 | else: |
| 1033 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1034 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1035 | utilities.assert_equals( expect=main.TRUE, |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1036 | actual=testResult, |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1037 | onpass=main.assertReturnString, |
| 1038 | onfail=main.assertReturnString ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1039 | |
| 1040 | stepResult = main.TRUE |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 1041 | main.step( "IPV4: Add point intents between h1 and h9" ) |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1042 | main.assertReturnString = "Assertion Result for IPV4 point intent\n" |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1043 | senders = [ |
| 1044 | { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" } |
| 1045 | ] |
| 1046 | recipients = [ |
| 1047 | { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09" } |
| 1048 | ] |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1049 | testResult = main.FALSE |
| 1050 | installResult = main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1051 | installResult = main.intentFunction.installPointIntent( |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1052 | main, |
| 1053 | name="IPV4", |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1054 | senders=senders, |
| 1055 | recipients=recipients, |
| 1056 | ethType="IPV4" ) |
| 1057 | |
| 1058 | if installResult: |
| 1059 | testResult = main.intentFunction.testPointIntent( |
| 1060 | main, |
| 1061 | intentId=installResult, |
| 1062 | name="IPV4", |
| 1063 | senders=senders, |
| 1064 | recipients=recipients, |
| 1065 | sw1="s5", |
| 1066 | sw2="s2", |
| 1067 | expectedLink=18) |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1068 | else: |
| 1069 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1070 | |
| 1071 | utilities.assert_equals( expect=main.TRUE, |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1072 | actual=testResult, |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1073 | onpass=main.assertReturnString, |
| 1074 | onfail=main.assertReturnString ) |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 1075 | main.step( "IPV4_2: Add point intents between h1 and h9" ) |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1076 | main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n" |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1077 | senders = [ |
| 1078 | { "name":"h1","device":"of:0000000000000005/1" } |
| 1079 | ] |
| 1080 | recipients = [ |
| 1081 | { "name":"h9","device":"of:0000000000000006/1" } |
| 1082 | ] |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1083 | testResult = main.FALSE |
| 1084 | installResult = main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1085 | installResult = main.intentFunction.installPointIntent( |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1086 | main, |
| 1087 | name="IPV4_2", |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1088 | senders=senders, |
| 1089 | recipients=recipients, |
| 1090 | ethType="IPV4" ) |
| 1091 | |
| 1092 | if installResult: |
| 1093 | testResult = main.intentFunction.testPointIntent( |
| 1094 | main, |
| 1095 | intentId=installResult, |
| 1096 | name="IPV4_2", |
| 1097 | senders=senders, |
| 1098 | recipients=recipients, |
| 1099 | sw1="s5", |
| 1100 | sw2="s2", |
| 1101 | expectedLink=18) |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1102 | else: |
| 1103 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1104 | |
| 1105 | utilities.assert_equals( expect=main.TRUE, |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1106 | actual=testResult, |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1107 | onpass=main.assertReturnString, |
| 1108 | onfail=main.assertReturnString ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1109 | |
kelvin-onlab | b55e58e | 2015-08-04 00:13:48 -0700 | [diff] [blame] | 1110 | main.step( "SDNIP-ICMP: Add point intents between h1 and h9" ) |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1111 | 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] | 1112 | senders = [ |
| 1113 | { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01", |
Jeremy | 6f000c6 | 2016-02-25 17:02:28 -0800 | [diff] [blame] | 1114 | "ip":( main.h1.hostIp + "/24" ) } |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1115 | ] |
| 1116 | recipients = [ |
| 1117 | { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09", |
Jeremy | 6f000c6 | 2016-02-25 17:02:28 -0800 | [diff] [blame] | 1118 | "ip":( main.h9.hostIp + "/24" ) } |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1119 | ] |
Jeremy | 6f000c6 | 2016-02-25 17:02:28 -0800 | [diff] [blame] | 1120 | ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ] |
kelvin-onlab | 79ce049 | 2015-07-27 16:14:39 -0700 | [diff] [blame] | 1121 | # Uneccessary, not including this in the selectors |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1122 | tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ] |
| 1123 | tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ] |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1124 | testResult = main.FALSE |
| 1125 | installResult = main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1126 | installResult = main.intentFunction.installPointIntent( |
| 1127 | main, |
| 1128 | name="SDNIP-ICMP", |
| 1129 | senders=senders, |
| 1130 | recipients=recipients, |
| 1131 | ethType="IPV4", |
| 1132 | ipProto=ipProto, |
| 1133 | tcpSrc=tcpSrc, |
| 1134 | tcpDst=tcpDst ) |
| 1135 | |
| 1136 | if installResult: |
| 1137 | testResult = main.intentFunction.testPointIntent( |
| 1138 | main, |
| 1139 | intentId=installResult, |
| 1140 | name="SDNIP_ICMP", |
| 1141 | senders=senders, |
| 1142 | recipients=recipients, |
| 1143 | sw1="s5", |
| 1144 | sw2="s2", |
Jeremy Songster | e405d3d | 2016-05-17 11:18:57 -0700 | [diff] [blame] | 1145 | expectedLink=18, |
| 1146 | useTCP=True) |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1147 | else: |
| 1148 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 1149 | |
| 1150 | utilities.assert_equals( expect=main.TRUE, |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1151 | actual=testResult, |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1152 | onpass=main.assertReturnString, |
| 1153 | onfail=main.assertReturnString ) |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 1154 | |
kelvin-onlab | b55e58e | 2015-08-04 00:13:48 -0700 | [diff] [blame] | 1155 | main.step( "SDNIP-TCP: Add point intents between h1 and h9" ) |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1156 | 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] | 1157 | mac1 = main.hostsData[ 'h1' ][ 'mac' ] |
| 1158 | mac2 = main.hostsData[ 'h9' ][ 'mac' ] |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 1159 | ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32" |
| 1160 | ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32" |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 1161 | ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ] |
| 1162 | tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ] |
| 1163 | tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ] |
| 1164 | |
kelvin-onlab | 58dc39e | 2015-08-06 08:11:09 -0700 | [diff] [blame] | 1165 | stepResult = main.intentFunction.pointIntentTcp( |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 1166 | main, |
kelvin-onlab | b55e58e | 2015-08-04 00:13:48 -0700 | [diff] [blame] | 1167 | name="SDNIP-TCP", |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 1168 | host1="h1", |
| 1169 | host2="h9", |
| 1170 | deviceId1="of:0000000000000005/1", |
| 1171 | deviceId2="of:0000000000000006/1", |
| 1172 | mac1=mac1, |
| 1173 | mac2=mac2, |
| 1174 | ethType="IPV4", |
kelvin-onlab | b55e58e | 2015-08-04 00:13:48 -0700 | [diff] [blame] | 1175 | ipProto=ipProto, |
| 1176 | ip1=ip1, |
| 1177 | ip2=ip2, |
| 1178 | tcp1=tcp1, |
| 1179 | tcp2=tcp2 ) |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 1180 | |
| 1181 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 6f000c6 | 2016-02-25 17:02:28 -0800 | [diff] [blame] | 1182 | actual=stepResult, |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1183 | onpass=main.assertReturnString, |
| 1184 | onfail=main.assertReturnString ) |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 1185 | |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1186 | main.step( "DUALSTACK1: Add point intents between h3 and h11" ) |
| 1187 | 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] | 1188 | senders = [ |
| 1189 | { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" } |
| 1190 | ] |
| 1191 | recipients = [ |
| 1192 | { "name":"h11","device":"of:0000000000000006/3","mac":"00:00:00:00:00:0B" } |
| 1193 | ] |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1194 | testResult = main.FALSE |
| 1195 | installResult = main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1196 | installResult = main.intentFunction.installPointIntent( |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1197 | main, |
| 1198 | name="DUALSTACK1", |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1199 | senders=senders, |
| 1200 | recipients=recipients, |
| 1201 | ethType="IPV4" ) |
| 1202 | |
| 1203 | if installResult: |
| 1204 | testResult = main.intentFunction.testPointIntent( |
| 1205 | main, |
| 1206 | intentId=installResult, |
| 1207 | name="DUALSTACK1", |
| 1208 | senders=senders, |
| 1209 | recipients=recipients, |
| 1210 | sw1="s5", |
| 1211 | sw2="s2", |
| 1212 | expectedLink=18) |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1213 | else: |
| 1214 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1215 | |
| 1216 | utilities.assert_equals( expect=main.TRUE, |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1217 | actual=testResult, |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1218 | onpass=main.assertReturnString, |
| 1219 | onfail=main.assertReturnString ) |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 1220 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1221 | main.step( "VLAN: Add point intents between h5 and h21" ) |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1222 | 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] | 1223 | senders = [ |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 1224 | { "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] | 1225 | ] |
| 1226 | recipients = [ |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 1227 | { "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] | 1228 | ] |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1229 | testResult = main.FALSE |
| 1230 | installResult = main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1231 | installResult = main.intentFunction.installPointIntent( |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1232 | main, |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 1233 | name="VLAN", |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1234 | senders=senders, |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 1235 | recipients=recipients) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1236 | |
| 1237 | if installResult: |
| 1238 | testResult = main.intentFunction.testPointIntent( |
| 1239 | main, |
| 1240 | intentId=installResult, |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 1241 | name="VLAN", |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1242 | senders=senders, |
| 1243 | recipients=recipients, |
| 1244 | sw1="s5", |
| 1245 | sw2="s2", |
| 1246 | expectedLink=18) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1247 | |
| 1248 | utilities.assert_equals( expect=main.TRUE, |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1249 | actual=testResult, |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1250 | onpass=main.assertReturnString, |
| 1251 | onfail=main.assertReturnString ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1252 | |
Jeremy Songster | ff55367 | 2016-05-12 17:06:23 -0700 | [diff] [blame] | 1253 | main.step( "VLAN: Add point intents between h5 and h21" ) |
| 1254 | main.assertReturnString = "Assertion Result for VLAN IPV4 point intents with VLAN treatment\n" |
| 1255 | senders = [ |
| 1256 | { "name":"h4", "vlan":"100" } |
| 1257 | ] |
| 1258 | recipients = [ |
| 1259 | { "name":"h21", "vlan":"200" } |
| 1260 | ] |
| 1261 | testResult = main.FALSE |
| 1262 | installResult = main.FALSE |
| 1263 | installResult = main.intentFunction.installPointIntent( |
| 1264 | main, |
| 1265 | name="VLAN2", |
| 1266 | senders=senders, |
| 1267 | recipients=recipients, |
| 1268 | setVlan=200) |
| 1269 | |
| 1270 | if installResult: |
| 1271 | testResult = main.intentFunction.testPointIntent( |
| 1272 | main, |
| 1273 | intentId=installResult, |
| 1274 | name="VLAN2", |
| 1275 | senders=senders, |
| 1276 | recipients=recipients, |
| 1277 | sw1="s5", |
| 1278 | sw2="s2", |
| 1279 | expectedLink=18) |
| 1280 | |
| 1281 | utilities.assert_equals( expect=main.TRUE, |
| 1282 | actual=testResult, |
| 1283 | onpass=main.assertReturnString, |
| 1284 | onfail=main.assertReturnString ) |
| 1285 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1286 | main.step( "1HOP: Add point intents between h1 and h3" ) |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1287 | 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] | 1288 | senders = [ |
| 1289 | { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" } |
| 1290 | ] |
| 1291 | recipients = [ |
| 1292 | { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" } |
| 1293 | ] |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1294 | testResult = main.FALSE |
| 1295 | installResult = main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1296 | installResult = main.intentFunction.installPointIntent( |
| 1297 | main, |
| 1298 | name="1HOP IPV4", |
| 1299 | senders=senders, |
| 1300 | recipients=recipients, |
| 1301 | ethType="IPV4" ) |
| 1302 | |
| 1303 | if installResult: |
| 1304 | testResult = main.intentFunction.testPointIntent( |
| 1305 | main, |
| 1306 | intentId=installResult, |
| 1307 | name="1HOP IPV4", |
| 1308 | senders=senders, |
| 1309 | recipients=recipients, |
| 1310 | sw1="s5", |
| 1311 | sw2="s2", |
| 1312 | expectedLink=18) |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1313 | else: |
| 1314 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1315 | |
| 1316 | utilities.assert_equals( expect=main.TRUE, |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1317 | actual=testResult, |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1318 | onpass=main.assertReturnString, |
| 1319 | onfail=main.assertReturnString ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1320 | |
kelvin-onlab | 016dce2 | 2015-08-10 09:54:11 -0700 | [diff] [blame] | 1321 | main.intentFunction.report( main ) |
| 1322 | |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 1323 | def CASE3000( self, main ): |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1324 | """ |
| 1325 | Add single point to multi point intents |
| 1326 | - Get device ids |
| 1327 | - Add single point to multi point intents |
| 1328 | - Check intents |
| 1329 | - Verify flows |
| 1330 | - Ping hosts |
| 1331 | - Reroute |
| 1332 | - Link down |
| 1333 | - Verify flows |
| 1334 | - Check topology |
| 1335 | - Ping hosts |
| 1336 | - Link up |
| 1337 | - Verify flows |
| 1338 | - Check topology |
| 1339 | - Ping hosts |
| 1340 | - Remove intents |
| 1341 | """ |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1342 | if main.initialized == main.FALSE: |
| 1343 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 1344 | main.skipCase() |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1345 | assert main, "There is no main" |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1346 | try: |
| 1347 | assert main.CLIs |
| 1348 | except AssertionError: |
| 1349 | main.log.error( "There is no main.CLIs, skipping test cases" ) |
| 1350 | main.initialized = main.FALSE |
| 1351 | main.skipCase() |
| 1352 | try: |
| 1353 | assert main.Mininet1 |
| 1354 | except AssertionError: |
| 1355 | main.log.error( "Mininet handle should be named Mininet1, skipping test cases" ) |
| 1356 | main.initialized = main.FALSE |
| 1357 | main.skipCase() |
| 1358 | try: |
| 1359 | assert main.numSwitch |
| 1360 | except AssertionError: |
| 1361 | main.log.error( "Place the total number of switch topology in \ |
| 1362 | main.numSwitch" ) |
| 1363 | main.initialized = main.FALSE |
| 1364 | main.skipCase() |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1365 | |
kelvin-onlab | 7bb2d97 | 2015-08-05 10:56:16 -0700 | [diff] [blame] | 1366 | main.testName = "Single to Multi Point Intents" |
| 1367 | main.case( main.testName + " Test - " + str( main.numCtrls ) + |
Jeremy | 6e9748f | 2016-03-25 15:03:39 -0700 | [diff] [blame] | 1368 | " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler ) |
Jon Hall | 783bbf9 | 2015-07-23 14:33:19 -0700 | [diff] [blame] | 1369 | main.caseExplanation = "This test case will test single point to" +\ |
kelvin-onlab | 6dea6e6 | 2015-07-23 13:07:26 -0700 | [diff] [blame] | 1370 | " multi point intents using " +\ |
| 1371 | str( main.numCtrls ) + " node(s) cluster;\n" +\ |
| 1372 | "Different type of hosts will be tested in " +\ |
| 1373 | "each step such as IPV4, Dual stack, VLAN etc" +\ |
| 1374 | ";\nThe test will use OF " + main.OFProtocol +\ |
Jeremy | 6e9748f | 2016-03-25 15:03:39 -0700 | [diff] [blame] | 1375 | " OVS running in Mininet and compile intents" +\ |
| 1376 | " using " + main.flowCompiler |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1377 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1378 | main.step( "NOOPTION: Install and test single point to multi point intents" ) |
| 1379 | main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n" |
| 1380 | senders = [ |
| 1381 | { "name":"h8", "device":"of:0000000000000005/8" } |
| 1382 | ] |
| 1383 | recipients = [ |
| 1384 | { "name":"h16", "device":"of:0000000000000006/8" }, |
| 1385 | { "name":"h24", "device":"of:0000000000000007/8" } |
| 1386 | ] |
| 1387 | badSenders=[ { "name":"h9" } ] # Senders that are not in the intent |
| 1388 | badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent |
| 1389 | testResult = main.FALSE |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1390 | installResult = main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1391 | installResult = main.intentFunction.installSingleToMultiIntent( |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1392 | main, |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1393 | name="NOOPTION", |
| 1394 | senders=senders, |
| 1395 | recipients=recipients, |
| 1396 | sw1="s5", |
| 1397 | sw2="s2") |
| 1398 | |
| 1399 | if installResult: |
| 1400 | testResult = main.intentFunction.testPointIntent( |
| 1401 | main, |
| 1402 | intentId=installResult, |
| 1403 | name="NOOPTION", |
| 1404 | senders=senders, |
| 1405 | recipients=recipients, |
| 1406 | badSenders=badSenders, |
| 1407 | badRecipients=badRecipients, |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1408 | sw1="s5", |
| 1409 | sw2="s2", |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1410 | expectedLink=18) |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1411 | else: |
| 1412 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1413 | |
| 1414 | utilities.assert_equals( expect=main.TRUE, |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1415 | actual=testResult, |
| 1416 | onpass=main.assertReturnString, |
| 1417 | onfail=main.assertReturnString ) |
| 1418 | |
| 1419 | main.step( "IPV4: Install and test single point to multi point intents" ) |
| 1420 | main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses\n" |
| 1421 | senders = [ |
| 1422 | { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" } |
| 1423 | ] |
| 1424 | recipients = [ |
| 1425 | { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" }, |
| 1426 | { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" } |
| 1427 | ] |
| 1428 | badSenders=[ { "name":"h9" } ] # Senders that are not in the intent |
| 1429 | badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent |
| 1430 | testResult = main.FALSE |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1431 | installResult = main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1432 | installResult = main.intentFunction.installSingleToMultiIntent( |
| 1433 | main, |
| 1434 | name="IPV4", |
| 1435 | senders=senders, |
| 1436 | recipients=recipients, |
| 1437 | ethType="IPV4", |
| 1438 | sw1="s5", |
| 1439 | sw2="s2") |
| 1440 | |
| 1441 | if installResult: |
| 1442 | testResult = main.intentFunction.testPointIntent( |
| 1443 | main, |
| 1444 | intentId=installResult, |
| 1445 | name="IPV4", |
| 1446 | senders=senders, |
| 1447 | recipients=recipients, |
| 1448 | badSenders=badSenders, |
| 1449 | badRecipients=badRecipients, |
| 1450 | sw1="s5", |
| 1451 | sw2="s2", |
| 1452 | expectedLink=18) |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1453 | else: |
| 1454 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1455 | |
| 1456 | utilities.assert_equals( expect=main.TRUE, |
| 1457 | actual=testResult, |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1458 | onpass=main.assertReturnString, |
| 1459 | onfail=main.assertReturnString ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1460 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1461 | main.step( "IPV4_2: Add single point to multi point intents" ) |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1462 | 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] | 1463 | senders = [ |
| 1464 | { "name":"h8", "device":"of:0000000000000005/8" } |
| 1465 | ] |
| 1466 | recipients = [ |
| 1467 | { "name":"h16", "device":"of:0000000000000006/8" }, |
| 1468 | { "name":"h24", "device":"of:0000000000000007/8" } |
| 1469 | ] |
| 1470 | badSenders=[ { "name":"h9" } ] # Senders that are not in the intent |
| 1471 | badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent |
| 1472 | testResult = main.FALSE |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1473 | installResult = main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1474 | installResult = main.intentFunction.installSingleToMultiIntent( |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1475 | main, |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1476 | name="IPV4_2", |
| 1477 | senders=senders, |
| 1478 | recipients=recipients, |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1479 | ethType="IPV4", |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1480 | sw1="s5", |
| 1481 | sw2="s2") |
| 1482 | |
| 1483 | if installResult: |
| 1484 | testResult = main.intentFunction.testPointIntent( |
| 1485 | main, |
| 1486 | intentId=installResult, |
| 1487 | name="IPV4_2", |
| 1488 | senders=senders, |
| 1489 | recipients=recipients, |
| 1490 | badSenders=badSenders, |
| 1491 | badRecipients=badRecipients, |
| 1492 | sw1="s5", |
| 1493 | sw2="s2", |
| 1494 | expectedLink=18) |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1495 | else: |
| 1496 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1497 | |
| 1498 | utilities.assert_equals( expect=main.TRUE, |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1499 | actual=testResult, |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1500 | onpass=main.assertReturnString, |
| 1501 | onfail=main.assertReturnString ) |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 1502 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1503 | main.step( "VLAN: Add single point to multi point intents" ) |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1504 | 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] | 1505 | senders = [ |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 1506 | { "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] | 1507 | ] |
| 1508 | recipients = [ |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 1509 | { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C", "vlan":"100" }, |
| 1510 | { "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] | 1511 | ] |
| 1512 | badSenders=[ { "name":"h13" } ] # Senders that are not in the intent |
| 1513 | badRecipients=[ { "name":"h21" } ] # Recipients that are not in the intent |
| 1514 | testResult = main.FALSE |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1515 | installResult = main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1516 | installResult = main.intentFunction.installSingleToMultiIntent( |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1517 | main, |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 1518 | name="VLAN`", |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1519 | senders=senders, |
| 1520 | recipients=recipients, |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1521 | sw1="s5", |
| 1522 | sw2="s2") |
| 1523 | |
| 1524 | if installResult: |
| 1525 | testResult = main.intentFunction.testPointIntent( |
| 1526 | main, |
| 1527 | intentId=installResult, |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 1528 | name="VLAN", |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1529 | senders=senders, |
| 1530 | recipients=recipients, |
| 1531 | badSenders=badSenders, |
| 1532 | badRecipients=badRecipients, |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1533 | sw1="s5", |
| 1534 | sw2="s2", |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1535 | expectedLink=18) |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1536 | else: |
| 1537 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1538 | |
| 1539 | utilities.assert_equals( expect=main.TRUE, |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1540 | actual=testResult, |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1541 | onpass=main.assertReturnString, |
| 1542 | onfail=main.assertReturnString ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1543 | |
Jeremy Songster | ff55367 | 2016-05-12 17:06:23 -0700 | [diff] [blame] | 1544 | main.step( "VLAN: Add single point to multi point intents" ) |
| 1545 | main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n" |
| 1546 | senders = [ |
| 1547 | { "name":"h5", "vlan":"200" } |
| 1548 | ] |
| 1549 | recipients = [ |
| 1550 | { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C", "vlan":"100" }, |
| 1551 | { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14", "vlan":"100" } |
| 1552 | ] |
| 1553 | badSenders=[ { "name":"h13" } ] # Senders that are not in the intent |
| 1554 | badRecipients=[ { "name":"h21" } ] # Recipients that are not in the intent |
| 1555 | testResult = main.FALSE |
| 1556 | installResult = main.FALSE |
| 1557 | installResult = main.intentFunction.installSingleToMultiIntent( |
| 1558 | main, |
| 1559 | name="VLAN2", |
| 1560 | senders=senders, |
| 1561 | recipients=recipients, |
| 1562 | sw1="s5", |
| 1563 | sw2="s2", |
| 1564 | setVlan=100) |
| 1565 | |
| 1566 | if installResult: |
| 1567 | testResult = main.intentFunction.testPointIntent( |
| 1568 | main, |
| 1569 | intentId=installResult, |
| 1570 | name="VLAN2", |
| 1571 | senders=senders, |
| 1572 | recipients=recipients, |
| 1573 | badSenders=badSenders, |
| 1574 | badRecipients=badRecipients, |
| 1575 | sw1="s5", |
| 1576 | sw2="s2", |
| 1577 | expectedLink=18) |
| 1578 | else: |
| 1579 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
| 1580 | |
| 1581 | utilities.assert_equals( expect=main.TRUE, |
| 1582 | actual=testResult, |
| 1583 | onpass=main.assertReturnString, |
| 1584 | onfail=main.assertReturnString ) |
| 1585 | |
kelvin-onlab | 016dce2 | 2015-08-10 09:54:11 -0700 | [diff] [blame] | 1586 | main.intentFunction.report( main ) |
| 1587 | |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 1588 | def CASE4000( self, main ): |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1589 | """ |
| 1590 | Add multi point to single point intents |
| 1591 | - Get device ids |
| 1592 | - Add multi point to single point intents |
| 1593 | - Check intents |
| 1594 | - Verify flows |
| 1595 | - Ping hosts |
| 1596 | - Reroute |
| 1597 | - Link down |
| 1598 | - Verify flows |
| 1599 | - Check topology |
| 1600 | - Ping hosts |
| 1601 | - Link up |
| 1602 | - Verify flows |
| 1603 | - Check topology |
| 1604 | - Ping hosts |
| 1605 | - Remove intents |
| 1606 | """ |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1607 | if main.initialized == main.FALSE: |
| 1608 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 1609 | main.skipCase() |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1610 | assert main, "There is no main" |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1611 | try: |
| 1612 | assert main.CLIs |
| 1613 | except AssertionError: |
| 1614 | main.log.error( "There is no main.CLIs, skipping test cases" ) |
| 1615 | main.initialized = main.FALSE |
| 1616 | main.skipCase() |
| 1617 | try: |
| 1618 | assert main.Mininet1 |
| 1619 | except AssertionError: |
| 1620 | main.log.error( "Mininet handle should be named Mininet1, skipping test cases" ) |
| 1621 | main.initialized = main.FALSE |
| 1622 | main.skipCase() |
| 1623 | try: |
| 1624 | assert main.numSwitch |
| 1625 | except AssertionError: |
| 1626 | main.log.error( "Place the total number of switch topology in \ |
| 1627 | main.numSwitch" ) |
| 1628 | main.initialized = main.FALSE |
| 1629 | main.skipCase() |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1630 | |
kelvin-onlab | 7bb2d97 | 2015-08-05 10:56:16 -0700 | [diff] [blame] | 1631 | main.testName = "Multi To Single Point Intents" |
| 1632 | main.case( main.testName + " Test - " + str( main.numCtrls ) + |
Jeremy | 6e9748f | 2016-03-25 15:03:39 -0700 | [diff] [blame] | 1633 | " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler ) |
Jon Hall | 783bbf9 | 2015-07-23 14:33:19 -0700 | [diff] [blame] | 1634 | main.caseExplanation = "This test case will test single point to" +\ |
kelvin-onlab | 6dea6e6 | 2015-07-23 13:07:26 -0700 | [diff] [blame] | 1635 | " multi point intents using " +\ |
| 1636 | str( main.numCtrls ) + " node(s) cluster;\n" +\ |
| 1637 | "Different type of hosts will be tested in " +\ |
| 1638 | "each step such as IPV4, Dual stack, VLAN etc" +\ |
| 1639 | ";\nThe test will use OF " + main.OFProtocol +\ |
Jeremy | 6e9748f | 2016-03-25 15:03:39 -0700 | [diff] [blame] | 1640 | " OVS running in Mininet and compile intents" +\ |
| 1641 | " using " + main.flowCompiler |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1642 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1643 | main.step( "NOOPTION: Add multi point to single point intents" ) |
| 1644 | main.assertReturnString = "Assertion results for NOOPTION multi to single point intent\n" |
| 1645 | senders = [ |
| 1646 | { "name":"h16", "device":"of:0000000000000006/8" }, |
| 1647 | { "name":"h24", "device":"of:0000000000000007/8" } |
| 1648 | ] |
| 1649 | recipients = [ |
| 1650 | { "name":"h8", "device":"of:0000000000000005/8" } |
| 1651 | ] |
| 1652 | badSenders=[ { "name":"h17" } ] # Senders that are not in the intent |
| 1653 | badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent |
| 1654 | testResult = main.FALSE |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1655 | installResult = main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1656 | installResult = main.intentFunction.installMultiToSingleIntent( |
| 1657 | main, |
| 1658 | name="NOOPTION", |
| 1659 | senders=senders, |
| 1660 | recipients=recipients, |
| 1661 | sw1="s5", |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1662 | sw2="s2" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1663 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1664 | if installResult: |
| 1665 | testResult = main.intentFunction.testPointIntent( |
| 1666 | main, |
| 1667 | intentId=installResult, |
| 1668 | name="NOOPTION", |
| 1669 | senders=senders, |
| 1670 | recipients=recipients, |
| 1671 | badSenders=badSenders, |
| 1672 | badRecipients=badRecipients, |
| 1673 | sw1="s5", |
| 1674 | sw2="s2", |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1675 | expectedLink=18 ) |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1676 | else: |
| 1677 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1678 | |
| 1679 | utilities.assert_equals( expect=main.TRUE, |
| 1680 | actual=testResult, |
| 1681 | onpass=main.assertReturnString, |
| 1682 | onfail=main.assertReturnString ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1683 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1684 | main.step( "IPV4: Add multi point to single point intents" ) |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1685 | 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] | 1686 | senders = [ |
| 1687 | { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" }, |
| 1688 | { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" } |
| 1689 | ] |
| 1690 | recipients = [ |
| 1691 | { "name":"h8", "device":"of:0000000000000005/8", "mac":"00:00:00:00:00:08" } |
| 1692 | ] |
| 1693 | badSenders=[ { "name":"h17" } ] # Senders that are not in the intent |
| 1694 | badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent |
| 1695 | testResult = main.FALSE |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1696 | installResult = main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1697 | installResult = main.intentFunction.installMultiToSingleIntent( |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1698 | main, |
| 1699 | name="IPV4", |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1700 | senders=senders, |
| 1701 | recipients=recipients, |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1702 | ethType="IPV4", |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1703 | sw1="s5", |
| 1704 | sw2="s2") |
| 1705 | |
| 1706 | if installResult: |
| 1707 | testResult = main.intentFunction.testPointIntent( |
| 1708 | main, |
| 1709 | intentId=installResult, |
| 1710 | name="IPV4", |
| 1711 | senders=senders, |
| 1712 | recipients=recipients, |
| 1713 | badSenders=badSenders, |
| 1714 | badRecipients=badRecipients, |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1715 | sw1="s5", |
| 1716 | sw2="s2", |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1717 | expectedLink=18) |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1718 | else: |
| 1719 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1720 | |
| 1721 | utilities.assert_equals( expect=main.TRUE, |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1722 | actual=testResult, |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1723 | onpass=main.assertReturnString, |
| 1724 | onfail=main.assertReturnString ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1725 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1726 | main.step( "IPV4_2: Add multi point to single point intents" ) |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1727 | 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] | 1728 | senders = [ |
| 1729 | { "name":"h16", "device":"of:0000000000000006/8" }, |
| 1730 | { "name":"h24", "device":"of:0000000000000007/8" } |
| 1731 | ] |
| 1732 | recipients = [ |
| 1733 | { "name":"h8", "device":"of:0000000000000005/8" } |
| 1734 | ] |
| 1735 | badSenders=[ { "name":"h17" } ] # Senders that are not in the intent |
| 1736 | badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent |
| 1737 | testResult = main.FALSE |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1738 | installResult = main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1739 | installResult = main.intentFunction.installMultiToSingleIntent( |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1740 | main, |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1741 | name="IPV4_2", |
| 1742 | senders=senders, |
| 1743 | recipients=recipients, |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1744 | ethType="IPV4", |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1745 | sw1="s5", |
| 1746 | sw2="s2") |
| 1747 | |
| 1748 | if installResult: |
| 1749 | testResult = main.intentFunction.testPointIntent( |
| 1750 | main, |
| 1751 | intentId=installResult, |
| 1752 | name="IPV4_2", |
| 1753 | senders=senders, |
| 1754 | recipients=recipients, |
| 1755 | badSenders=badSenders, |
| 1756 | badRecipients=badRecipients, |
| 1757 | sw1="s5", |
| 1758 | sw2="s2", |
| 1759 | expectedLink=18) |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1760 | else: |
| 1761 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1762 | |
| 1763 | utilities.assert_equals( expect=main.TRUE, |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1764 | actual=testResult, |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1765 | onpass=main.assertReturnString, |
| 1766 | onfail=main.assertReturnString ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1767 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1768 | main.step( "VLAN: Add multi point to single point intents" ) |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1769 | 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] | 1770 | senders = [ |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 1771 | { "name":"h13", "device":"of:0000000000000006/5", "vlan":"200" }, |
| 1772 | { "name":"h21", "device":"of:0000000000000007/5", "vlan":"200" } |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1773 | ] |
| 1774 | recipients = [ |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 1775 | { "name":"h5", "device":"of:0000000000000005/5", "vlan":"200" } |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1776 | ] |
| 1777 | badSenders=[ { "name":"h12" } ] # Senders that are not in the intent |
| 1778 | badRecipients=[ { "name":"h20" } ] # Recipients that are not in the intent |
| 1779 | testResult = main.FALSE |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1780 | installResult = main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1781 | installResult = main.intentFunction.installMultiToSingleIntent( |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1782 | main, |
| 1783 | name="VLAN", |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1784 | senders=senders, |
| 1785 | recipients=recipients, |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1786 | sw1="s5", |
| 1787 | sw2="s2") |
| 1788 | |
| 1789 | if installResult: |
| 1790 | testResult = main.intentFunction.testPointIntent( |
| 1791 | main, |
| 1792 | intentId=installResult, |
| 1793 | name="VLAN", |
| 1794 | senders=senders, |
| 1795 | recipients=recipients, |
| 1796 | badSenders=badSenders, |
| 1797 | badRecipients=badRecipients, |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1798 | sw1="s5", |
| 1799 | sw2="s2", |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1800 | expectedLink=18) |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1801 | else: |
| 1802 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1803 | |
| 1804 | utilities.assert_equals( expect=main.TRUE, |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1805 | actual=testResult, |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1806 | onpass=main.assertReturnString, |
| 1807 | onfail=main.assertReturnString ) |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 1808 | |
Jeremy Songster | ff55367 | 2016-05-12 17:06:23 -0700 | [diff] [blame] | 1809 | # Right now this fails because of this bug: https://jira.onosproject.org/browse/ONOS-4383 |
| 1810 | main.step( "VLAN: Add multi point to single point intents" ) |
| 1811 | main.assertReturnString = "Assertion results for multi to single point intent with VLAN ID treatment\n" |
| 1812 | senders = [ |
| 1813 | { "name":"h13", "device":"of:0000000000000006/5", "vlan":"200" }, |
| 1814 | { "name":"h21", "device":"of:0000000000000007/5", "vlan":"200" } |
| 1815 | ] |
| 1816 | recipients = [ |
| 1817 | { "name":"h4", "vlan":"100" } |
| 1818 | ] |
| 1819 | badSenders=[ { "name":"h12" } ] # Senders that are not in the intent |
| 1820 | badRecipients=[ { "name":"h20" } ] # Recipients that are not in the intent |
| 1821 | testResult = main.FALSE |
| 1822 | installResult = main.FALSE |
| 1823 | installResult = main.intentFunction.installMultiToSingleIntent( |
| 1824 | main, |
| 1825 | name="VLAN2", |
| 1826 | senders=senders, |
| 1827 | recipients=recipients, |
| 1828 | sw1="s5", |
| 1829 | sw2="s2", |
| 1830 | setVlan=100) |
| 1831 | |
| 1832 | if installResult: |
| 1833 | testResult = main.intentFunction.testPointIntent( |
| 1834 | main, |
| 1835 | intentId=installResult, |
| 1836 | name="VLAN2", |
| 1837 | senders=senders, |
| 1838 | recipients=recipients, |
| 1839 | badSenders=badSenders, |
| 1840 | badRecipients=badRecipients, |
| 1841 | sw1="s5", |
| 1842 | sw2="s2", |
| 1843 | expectedLink=18) |
| 1844 | else: |
| 1845 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
| 1846 | |
| 1847 | utilities.assert_equals( expect=main.TRUE, |
| 1848 | actual=testResult, |
| 1849 | onpass=main.assertReturnString, |
| 1850 | onfail=main.assertReturnString ) |
| 1851 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1852 | main.intentFunction.report( main ) |
| 1853 | |
acsmars | 1ff5e05 | 2015-07-23 11:27:48 -0700 | [diff] [blame] | 1854 | def CASE5000( self, main ): |
| 1855 | """ |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1856 | Tests Host Mobility |
| 1857 | Modifies the topology location of h1 |
acsmars | 1ff5e05 | 2015-07-23 11:27:48 -0700 | [diff] [blame] | 1858 | """ |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1859 | if main.initialized == main.FALSE: |
| 1860 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 1861 | main.skipCase() |
acsmars | 1ff5e05 | 2015-07-23 11:27:48 -0700 | [diff] [blame] | 1862 | assert main, "There is no main" |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1863 | try: |
| 1864 | assert main.CLIs |
| 1865 | except AssertionError: |
| 1866 | main.log.error( "There is no main.CLIs, skipping test cases" ) |
| 1867 | main.initialized = main.FALSE |
| 1868 | main.skipCase() |
| 1869 | try: |
| 1870 | assert main.Mininet1 |
| 1871 | except AssertionError: |
| 1872 | main.log.error( "Mininet handle should be named Mininet1, skipping test cases" ) |
| 1873 | main.initialized = main.FALSE |
| 1874 | main.skipCase() |
| 1875 | try: |
| 1876 | assert main.numSwitch |
| 1877 | except AssertionError: |
| 1878 | main.log.error( "Place the total number of switch topology in \ |
| 1879 | main.numSwitch" ) |
| 1880 | main.initialized = main.FALSE |
| 1881 | main.skipCase() |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 1882 | main.case( "Test host mobility with host intents " ) |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1883 | main.step( "Testing host mobility by moving h1 from s5 to s6" ) |
acsmars | 1ff5e05 | 2015-07-23 11:27:48 -0700 | [diff] [blame] | 1884 | h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ] |
| 1885 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1886 | main.log.info( "Moving h1 from s5 to s6") |
acsmars | 1ff5e05 | 2015-07-23 11:27:48 -0700 | [diff] [blame] | 1887 | main.Mininet1.moveHost( "h1","s5","s6" ) |
| 1888 | |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1889 | # Send discovery ping from moved host |
| 1890 | # Moving the host brings down the default interfaces and creates a new one. |
| 1891 | # Scapy is restarted on this host to detect the new interface |
| 1892 | main.h1.stopScapy() |
| 1893 | main.h1.startScapy() |
| 1894 | |
| 1895 | # Discover new host location in ONOS and populate host data. |
| 1896 | # Host 1 IP and MAC should be unchanged |
| 1897 | main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] ) |
| 1898 | main.intentFunction.populateHostData( main ) |
| 1899 | |
acsmars | 1ff5e05 | 2015-07-23 11:27:48 -0700 | [diff] [blame] | 1900 | h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ] |
| 1901 | |
| 1902 | utilities.assert_equals( expect="of:0000000000000006", |
| 1903 | actual=h1PostMove, |
| 1904 | onpass="Mobility: Successfully moved h1 to s6", |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1905 | onfail="Mobility: Failed to move h1 to s6" + |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 1906 | " to single point intents" + |
| 1907 | " with IPV4 type and MAC addresses" + |
| 1908 | " in the same VLAN" ) |
| 1909 | |
| 1910 | main.step( "IPV4: Add host intents between h1 and h9" ) |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1911 | 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] | 1912 | host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" } |
| 1913 | host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" } |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1914 | testResult = main.FALSE |
| 1915 | installResult = main.FALSE |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1916 | installResult = main.intentFunction.installHostIntent( main, |
| 1917 | name='IPV4 Mobility IPV4', |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 1918 | onosNode='0', |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1919 | host1=host1, |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1920 | host2=host2 ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1921 | if installResult: |
| 1922 | testResult = main.intentFunction.testHostIntent( main, |
| 1923 | name='Host Mobility IPV4', |
| 1924 | intentId = installResult, |
| 1925 | onosNode='0', |
| 1926 | host1=host1, |
| 1927 | host2=host2, |
| 1928 | sw1="s6", |
| 1929 | sw2="s2", |
| 1930 | expectedLink=18 ) |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1931 | else: |
| 1932 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 1933 | |
| 1934 | utilities.assert_equals( expect=main.TRUE, |
Jeremy Songster | 1f39bf0 | 2016-01-20 17:17:25 -0800 | [diff] [blame] | 1935 | actual=testResult, |
acsmars | 5d8cc86 | 2015-09-25 09:44:50 -0700 | [diff] [blame] | 1936 | onpass=main.assertReturnString, |
| 1937 | onfail=main.assertReturnString ) |
kelvin-onlab | 016dce2 | 2015-08-10 09:54:11 -0700 | [diff] [blame] | 1938 | |
| 1939 | main.intentFunction.report( main ) |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1940 | |
| 1941 | def CASE6000( self, main ): |
| 1942 | """ |
| 1943 | Tests Multi to Single Point Intent and Single to Multi Point Intent End Point Failure |
| 1944 | """ |
Jeremy Songster | 9385d41 | 2016-06-02 17:57:36 -0700 | [diff] [blame] | 1945 | # At some later point discussion on this behavior in MPSP and SPMP intents |
| 1946 | # will be reoppened and this test case may need to be updated to reflect |
| 1947 | # the outcomes of that discussion |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1948 | if main.initialized == main.FALSE: |
| 1949 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 1950 | main.skipCase() |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1951 | assert main, "There is no main" |
Jeremy | d9e4eb1 | 2016-04-13 12:09:06 -0700 | [diff] [blame] | 1952 | try: |
| 1953 | assert main.CLIs |
| 1954 | except AssertionError: |
| 1955 | main.log.error( "There is no main.CLIs, skipping test cases" ) |
| 1956 | main.initialized = main.FALSE |
| 1957 | main.skipCase() |
| 1958 | try: |
| 1959 | assert main.Mininet1 |
| 1960 | except AssertionError: |
| 1961 | main.log.error( "Mininet handle should be named Mininet1, skipping test cases" ) |
| 1962 | main.initialized = main.FALSE |
| 1963 | main.skipCase() |
| 1964 | try: |
| 1965 | assert main.numSwitch |
| 1966 | except AssertionError: |
| 1967 | main.log.error( "Place the total number of switch topology in \ |
| 1968 | main.numSwitch" ) |
| 1969 | main.initialized = main.FALSE |
| 1970 | main.skipCase() |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1971 | main.case( "Test Multi to Single End Point Failure" ) |
Jeremy Songster | 9385d41 | 2016-06-02 17:57:36 -0700 | [diff] [blame] | 1972 | main.step( "Installing Multi to Single Point intents with no options set" ) |
| 1973 | main.assertReturnString = "Assertion results for IPV4 multi to single " +\ |
| 1974 | "point intent end point failure with no options set\n" |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1975 | senders = [ |
| 1976 | { "name":"h16", "device":"of:0000000000000006/8" }, |
| 1977 | { "name":"h24", "device":"of:0000000000000007/8" } |
| 1978 | ] |
| 1979 | recipients = [ |
| 1980 | { "name":"h8", "device":"of:0000000000000005/8" } |
| 1981 | ] |
| 1982 | isolatedSenders = [ |
| 1983 | { "name":"h24"} |
| 1984 | ] |
| 1985 | isolatedRecipients = [] |
| 1986 | testResult = main.FALSE |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 1987 | installResult = main.FALSE |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 1988 | installResult = main.intentFunction.installMultiToSingleIntent( |
| 1989 | main, |
| 1990 | name="NOOPTION", |
| 1991 | senders=senders, |
| 1992 | recipients=recipients, |
| 1993 | sw1="s5", |
| 1994 | sw2="s2" ) |
| 1995 | |
| 1996 | if installResult: |
| 1997 | testResult = main.intentFunction.testEndPointFail( |
| 1998 | main, |
| 1999 | intentId=installResult, |
| 2000 | name="NOOPTION", |
| 2001 | senders=senders, |
| 2002 | recipients=recipients, |
| 2003 | isolatedSenders=isolatedSenders, |
| 2004 | isolatedRecipients=isolatedRecipients, |
| 2005 | sw1="s6", |
| 2006 | sw2="s2", |
| 2007 | sw3="s4", |
| 2008 | sw4="s1", |
| 2009 | sw5="s3", |
| 2010 | expectedLink1=16, |
| 2011 | expectedLink2=14 ) |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 2012 | else: |
| 2013 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 2014 | |
| 2015 | utilities.assert_equals( expect=main.TRUE, |
| 2016 | actual=testResult, |
| 2017 | onpass=main.assertReturnString, |
| 2018 | onfail=main.assertReturnString ) |
| 2019 | |
Jeremy Songster | 9385d41 | 2016-06-02 17:57:36 -0700 | [diff] [blame] | 2020 | main.step( "Installing Multi to Single Point intents with partial failure allowed" ) |
| 2021 | |
| 2022 | main.assertReturnString = "Assertion results for IPV4 multi to single " +\ |
| 2023 | "with partial failures allowed\n" |
| 2024 | senders = [ |
| 2025 | { "name":"h16", "device":"of:0000000000000006/8" }, |
| 2026 | { "name":"h24", "device":"of:0000000000000007/8" } |
| 2027 | ] |
| 2028 | recipients = [ |
| 2029 | { "name":"h8", "device":"of:0000000000000005/8" } |
| 2030 | ] |
| 2031 | isolatedSenders = [ |
| 2032 | { "name":"h24"} |
| 2033 | ] |
| 2034 | isolatedRecipients = [] |
| 2035 | testResult = main.FALSE |
| 2036 | installResult = main.FALSE |
| 2037 | installResult = main.intentFunction.installMultiToSingleIntent( |
| 2038 | main, |
| 2039 | name="NOOPTION", |
| 2040 | senders=senders, |
| 2041 | recipients=recipients, |
| 2042 | sw1="s5", |
| 2043 | sw2="s2", |
| 2044 | partial=True ) |
| 2045 | |
| 2046 | if installResult: |
| 2047 | testResult = main.intentFunction.testEndPointFail( |
| 2048 | main, |
| 2049 | intentId=installResult, |
| 2050 | name="NOOPTION", |
| 2051 | senders=senders, |
| 2052 | recipients=recipients, |
| 2053 | isolatedSenders=isolatedSenders, |
| 2054 | isolatedRecipients=isolatedRecipients, |
| 2055 | sw1="s6", |
| 2056 | sw2="s2", |
| 2057 | sw3="s4", |
| 2058 | sw4="s1", |
| 2059 | sw5="s3", |
| 2060 | expectedLink1=16, |
| 2061 | expectedLink2=14, |
| 2062 | partial=True ) |
| 2063 | else: |
| 2064 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
| 2065 | |
| 2066 | utilities.assert_equals( expect=main.TRUE, |
| 2067 | actual=testResult, |
| 2068 | onpass=main.assertReturnString, |
| 2069 | onfail=main.assertReturnString ) |
| 2070 | |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 2071 | main.step( "NOOPTION: Install and test single point to multi point intents" ) |
Jeremy Songster | 9385d41 | 2016-06-02 17:57:36 -0700 | [diff] [blame] | 2072 | main.assertReturnString = "Assertion results for IPV4 single to multi " +\ |
| 2073 | "point intent with no options set\n" |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 2074 | senders = [ |
| 2075 | { "name":"h8", "device":"of:0000000000000005/8" } |
| 2076 | ] |
| 2077 | recipients = [ |
| 2078 | { "name":"h16", "device":"of:0000000000000006/8" }, |
| 2079 | { "name":"h24", "device":"of:0000000000000007/8" } |
| 2080 | ] |
Jeremy Songster | 9385d41 | 2016-06-02 17:57:36 -0700 | [diff] [blame] | 2081 | isolatedSenders = [] |
| 2082 | isolatedRecipients = [ |
Jeremy Songster | 832f9e9 | 2016-05-05 14:30:49 -0700 | [diff] [blame] | 2083 | { "name":"h24"} |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 2084 | ] |
| 2085 | testResult = main.FALSE |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 2086 | installResult = main.FALSE |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 2087 | installResult = main.intentFunction.installSingleToMultiIntent( |
| 2088 | main, |
| 2089 | name="NOOPTION", |
| 2090 | senders=senders, |
| 2091 | recipients=recipients, |
| 2092 | sw1="s5", |
| 2093 | sw2="s2") |
| 2094 | |
| 2095 | if installResult: |
| 2096 | testResult = main.intentFunction.testEndPointFail( |
| 2097 | main, |
| 2098 | intentId=installResult, |
| 2099 | name="NOOPTION", |
| 2100 | senders=senders, |
| 2101 | recipients=recipients, |
| 2102 | isolatedSenders=isolatedSenders, |
| 2103 | isolatedRecipients=isolatedRecipients, |
| 2104 | sw1="s6", |
| 2105 | sw2="s2", |
| 2106 | sw3="s4", |
| 2107 | sw4="s1", |
| 2108 | sw5="s3", |
| 2109 | expectedLink1=16, |
| 2110 | expectedLink2=14 ) |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 2111 | else: |
| 2112 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 2113 | |
| 2114 | utilities.assert_equals( expect=main.TRUE, |
| 2115 | actual=testResult, |
| 2116 | onpass=main.assertReturnString, |
| 2117 | onfail=main.assertReturnString ) |
Jeremy Songster | 9385d41 | 2016-06-02 17:57:36 -0700 | [diff] [blame] | 2118 | # Right now this functionality doesn't work properly in SPMP intents |
| 2119 | main.step( "NOOPTION: Install and test single point to multi point " +\ |
| 2120 | "intents with partial failures allowed" ) |
| 2121 | main.assertReturnString = "Assertion results for IPV4 single to multi " +\ |
| 2122 | "point intent with partial failures allowed\n" |
| 2123 | senders = [ |
| 2124 | { "name":"h8", "device":"of:0000000000000005/8" } |
| 2125 | ] |
| 2126 | recipients = [ |
| 2127 | { "name":"h16", "device":"of:0000000000000006/8" }, |
| 2128 | { "name":"h24", "device":"of:0000000000000007/8" } |
| 2129 | ] |
| 2130 | isolatedSenders = [] |
| 2131 | isolatedRecipients = [ |
| 2132 | { "name":"h24"} |
| 2133 | ] |
| 2134 | testResult = main.FALSE |
| 2135 | installResult = main.FALSE |
| 2136 | installResult = main.intentFunction.installSingleToMultiIntent( |
| 2137 | main, |
| 2138 | name="NOOPTION", |
| 2139 | senders=senders, |
| 2140 | recipients=recipients, |
| 2141 | sw1="s5", |
| 2142 | sw2="s2", |
| 2143 | partial=True) |
| 2144 | |
| 2145 | if installResult: |
| 2146 | testResult = main.intentFunction.testEndPointFail( |
| 2147 | main, |
| 2148 | intentId=installResult, |
| 2149 | name="NOOPTION", |
| 2150 | senders=senders, |
| 2151 | recipients=recipients, |
| 2152 | isolatedSenders=isolatedSenders, |
| 2153 | isolatedRecipients=isolatedRecipients, |
| 2154 | sw1="s6", |
| 2155 | sw2="s2", |
| 2156 | sw3="s4", |
| 2157 | sw4="s1", |
| 2158 | sw5="s3", |
| 2159 | expectedLink1=16, |
| 2160 | expectedLink2=14, |
| 2161 | partial=True ) |
| 2162 | else: |
| 2163 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
| 2164 | |
| 2165 | utilities.assert_equals( expect=main.TRUE, |
| 2166 | actual=testResult, |
| 2167 | onpass=main.assertReturnString, |
| 2168 | onfail=main.assertReturnString ) |
Jeremy | e0cb5eb | 2016-01-27 17:39:09 -0800 | [diff] [blame] | 2169 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 2170 | main.intentFunction.report( main ) |