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