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