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