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