kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1 | |
| 2 | # Testing the basic intent functionality of ONOS |
| 3 | |
| 4 | import time |
| 5 | import json |
| 6 | |
| 7 | class FUNCintent: |
| 8 | |
| 9 | def __init__( self ): |
| 10 | self.default = '' |
| 11 | |
| 12 | def CASE1( self, main ): |
| 13 | import time |
| 14 | import os |
| 15 | import imp |
| 16 | |
| 17 | """ |
| 18 | - Construct tests variables |
| 19 | - GIT ( optional ) |
| 20 | - Checkout ONOS master branch |
| 21 | - Pull latest ONOS code |
| 22 | - Building ONOS ( optional ) |
| 23 | - Install ONOS package |
| 24 | - Build ONOS package |
| 25 | """ |
| 26 | |
| 27 | main.case( "Constructing test variables and building ONOS package" ) |
| 28 | main.step( "Constructing test variables" ) |
Jon Hall | 783bbf9 | 2015-07-23 14:33:19 -0700 | [diff] [blame] | 29 | main.caseExplanation = "This test case is mainly for loading " +\ |
kelvin-onlab | 6dea6e6 | 2015-07-23 13:07:26 -0700 | [diff] [blame] | 30 | "from params file, and pull and build the " +\ |
| 31 | " latest ONOS package" |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 32 | stepResult = main.FALSE |
| 33 | |
| 34 | # Test variables |
| 35 | main.testOnDirectory = os.path.dirname( os.getcwd ( ) ) |
| 36 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
| 37 | gitBranch = main.params[ 'GIT' ][ 'branch' ] |
| 38 | main.dependencyPath = main.testOnDirectory + \ |
| 39 | main.params[ 'DEPENDENCY' ][ 'path' ] |
| 40 | main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ] |
| 41 | main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," ) |
| 42 | main.maxNodes = int( main.ONOSbench.maxNodes ) |
| 43 | wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
| 44 | wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ] |
| 45 | main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] ) |
| 46 | main.checkIntentSleep = int( main.params[ 'SLEEP' ][ 'checkintent' ] ) |
| 47 | main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] ) |
kelvin-onlab | 0ad05d1 | 2015-07-23 14:21:15 -0700 | [diff] [blame] | 48 | main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 49 | gitPull = main.params[ 'GIT' ][ 'pull' ] |
| 50 | main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] ) |
| 51 | main.numLinks = int( main.params[ 'MININET' ][ 'links' ] ) |
| 52 | main.cellData = {} # for creating cell file |
| 53 | main.hostsData = {} |
| 54 | main.CLIs = [] |
| 55 | main.ONOSip = [] |
| 56 | |
| 57 | main.ONOSip = main.ONOSbench.getOnosIps() |
| 58 | print main.ONOSip |
| 59 | |
| 60 | # Assigning ONOS cli handles to a list |
| 61 | for i in range( 1, main.maxNodes + 1 ): |
| 62 | main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) ) |
| 63 | |
| 64 | # -- INIT SECTION, ONLY RUNS ONCE -- # |
| 65 | main.startUp = imp.load_source( wrapperFile1, |
| 66 | main.dependencyPath + |
| 67 | wrapperFile1 + |
| 68 | ".py" ) |
| 69 | |
| 70 | main.intentFunction = imp.load_source( wrapperFile2, |
| 71 | main.dependencyPath + |
| 72 | wrapperFile2 + |
| 73 | ".py" ) |
| 74 | |
| 75 | copyResult = main.ONOSbench.copyMininetFile( main.topology, |
| 76 | main.dependencyPath, |
| 77 | main.Mininet1.user_name, |
| 78 | main.Mininet1.ip_address ) |
| 79 | if main.CLIs: |
| 80 | stepResult = main.TRUE |
| 81 | else: |
| 82 | main.log.error( "Did not properly created list of ONOS CLI handle" ) |
| 83 | stepResult = main.FALSE |
| 84 | |
| 85 | utilities.assert_equals( expect=main.TRUE, |
| 86 | actual=stepResult, |
| 87 | onpass="Successfully construct " + |
| 88 | "test variables ", |
| 89 | onfail="Failed to construct test variables" ) |
| 90 | |
| 91 | if gitPull == 'True': |
| 92 | main.step( "Building ONOS in " + gitBranch + " branch" ) |
| 93 | onosBuildResult = main.startUp.onosBuild( main, gitBranch ) |
| 94 | stepResult = onosBuildResult |
| 95 | utilities.assert_equals( expect=main.TRUE, |
| 96 | actual=stepResult, |
| 97 | onpass="Successfully compiled " + |
| 98 | "latest ONOS", |
| 99 | onfail="Failed to compile " + |
| 100 | "latest ONOS" ) |
| 101 | else: |
| 102 | main.log.warn( "Did not pull new code so skipping mvn " + |
| 103 | "clean install" ) |
Jon Hall | 106be08 | 2015-07-22 09:53:00 -0700 | [diff] [blame] | 104 | main.ONOSbench.getVersion( report=True ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 105 | |
| 106 | def CASE2( self, main ): |
| 107 | """ |
| 108 | - Set up cell |
| 109 | - Create cell file |
| 110 | - Set cell file |
| 111 | - Verify cell file |
| 112 | - Kill ONOS process |
| 113 | - Uninstall ONOS cluster |
| 114 | - Verify ONOS start up |
| 115 | - Install ONOS cluster |
| 116 | - Connect to cli |
| 117 | """ |
| 118 | |
| 119 | # main.scale[ 0 ] determines the current number of ONOS controller |
| 120 | main.numCtrls = int( main.scale[ 0 ] ) |
| 121 | |
| 122 | main.case( "Starting up " + str( main.numCtrls ) + |
| 123 | " node(s) ONOS cluster" ) |
Jon Hall | 783bbf9 | 2015-07-23 14:33:19 -0700 | [diff] [blame] | 124 | main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\ |
kelvin-onlab | 6dea6e6 | 2015-07-23 13:07:26 -0700 | [diff] [blame] | 125 | " node(s) ONOS cluster" |
| 126 | |
| 127 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 128 | |
| 129 | #kill off all onos processes |
| 130 | main.log.info( "Safety check, killing all ONOS processes" + |
| 131 | " before initiating enviornment setup" ) |
| 132 | |
| 133 | for i in range( main.maxNodes ): |
| 134 | main.ONOSbench.onosDie( main.ONOSip[ i ] ) |
| 135 | |
| 136 | print "NODE COUNT = ", main.numCtrls |
| 137 | |
| 138 | tempOnosIp = [] |
| 139 | for i in range( main.numCtrls ): |
| 140 | tempOnosIp.append( main.ONOSip[i] ) |
| 141 | |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 142 | main.ONOSbench.createCellFile( main.ONOSbench.ip_address, |
| 143 | "temp", main.Mininet1.ip_address, |
| 144 | main.apps, tempOnosIp ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 145 | |
| 146 | main.step( "Apply cell to environment" ) |
| 147 | cellResult = main.ONOSbench.setCell( "temp" ) |
| 148 | verifyResult = main.ONOSbench.verifyCell() |
| 149 | stepResult = cellResult and verifyResult |
| 150 | utilities.assert_equals( expect=main.TRUE, |
| 151 | actual=stepResult, |
| 152 | onpass="Successfully applied cell to " + \ |
| 153 | "environment", |
| 154 | onfail="Failed to apply cell to environment " ) |
| 155 | |
| 156 | main.step( "Creating ONOS package" ) |
| 157 | packageResult = main.ONOSbench.onosPackage() |
| 158 | stepResult = packageResult |
| 159 | utilities.assert_equals( expect=main.TRUE, |
| 160 | actual=stepResult, |
| 161 | onpass="Successfully created ONOS package", |
| 162 | onfail="Failed to create ONOS package" ) |
| 163 | |
| 164 | time.sleep( main.startUpSleep ) |
| 165 | main.step( "Uninstalling ONOS package" ) |
| 166 | onosUninstallResult = main.TRUE |
| 167 | for i in range( main.numCtrls ): |
| 168 | onosUninstallResult = onosUninstallResult and \ |
| 169 | main.ONOSbench.onosUninstall( nodeIp=main.ONOSip[ i ] ) |
| 170 | stepResult = onosUninstallResult |
| 171 | utilities.assert_equals( expect=main.TRUE, |
| 172 | actual=stepResult, |
| 173 | onpass="Successfully uninstalled ONOS package", |
| 174 | onfail="Failed to uninstall ONOS package" ) |
| 175 | |
| 176 | time.sleep( main.startUpSleep ) |
| 177 | main.step( "Installing ONOS package" ) |
| 178 | onosInstallResult = main.TRUE |
| 179 | for i in range( main.numCtrls ): |
| 180 | onosInstallResult = onosInstallResult and \ |
| 181 | main.ONOSbench.onosInstall( node=main.ONOSip[ i ] ) |
| 182 | stepResult = onosInstallResult |
| 183 | utilities.assert_equals( expect=main.TRUE, |
| 184 | actual=stepResult, |
| 185 | onpass="Successfully installed ONOS package", |
| 186 | onfail="Failed to install ONOS package" ) |
| 187 | |
| 188 | time.sleep( main.startUpSleep ) |
| 189 | main.step( "Starting ONOS service" ) |
| 190 | stopResult = main.TRUE |
| 191 | startResult = main.TRUE |
| 192 | onosIsUp = main.TRUE |
| 193 | |
| 194 | for i in range( main.numCtrls ): |
| 195 | onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] ) |
| 196 | if onosIsUp == main.TRUE: |
| 197 | main.log.report( "ONOS instance is up and ready" ) |
| 198 | else: |
| 199 | main.log.report( "ONOS instance may not be up, stop and " + |
| 200 | "start ONOS again " ) |
| 201 | for i in range( main.numCtrls ): |
| 202 | stopResult = stopResult and \ |
| 203 | main.ONOSbench.onosStop( main.ONOSip[ i ] ) |
| 204 | for i in range( main.numCtrls ): |
| 205 | startResult = startResult and \ |
| 206 | main.ONOSbench.onosStart( main.ONOSip[ i ] ) |
| 207 | stepResult = onosIsUp and stopResult and startResult |
| 208 | utilities.assert_equals( expect=main.TRUE, |
| 209 | actual=stepResult, |
| 210 | onpass="ONOS service is ready", |
| 211 | onfail="ONOS service did not start properly" ) |
| 212 | |
| 213 | main.step( "Start ONOS cli" ) |
| 214 | cliResult = main.TRUE |
| 215 | for i in range( main.numCtrls ): |
| 216 | cliResult = cliResult and \ |
| 217 | main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] ) |
| 218 | stepResult = cliResult |
| 219 | utilities.assert_equals( expect=main.TRUE, |
| 220 | actual=stepResult, |
| 221 | onpass="Successfully start ONOS cli", |
| 222 | onfail="Failed to start ONOS cli" ) |
| 223 | |
| 224 | # Remove the first element in main.scale list |
| 225 | main.scale.remove( main.scale[ 0 ] ) |
| 226 | |
| 227 | def CASE9( self, main ): |
| 228 | ''' |
| 229 | Report errors/warnings/exceptions |
| 230 | ''' |
| 231 | main.log.info( "Error report: \n" ) |
| 232 | main.ONOSbench.logReport( globalONOSip[0], |
| 233 | [ "INFO", "FOLLOWER", "WARN", "flow", "ERROR" , "Except" ], |
| 234 | "s" ) |
| 235 | #main.ONOSbench.logReport( globalONOSip[1], [ "INFO" ], "d" ) |
| 236 | |
kelvin-onlab | b5cfab3 | 2015-07-22 16:38:22 -0700 | [diff] [blame] | 237 | def CASE10( self, main ): |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 238 | """ |
kelvin-onlab | b0b0dcb | 2015-07-22 16:51:33 -0700 | [diff] [blame] | 239 | Start Mininet topology with OF 1.0 switches |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 240 | """ |
kelvin-onlab | 6dea6e6 | 2015-07-23 13:07:26 -0700 | [diff] [blame] | 241 | main.OFProtocol = "1.0" |
kelvin-onlab | b0b0dcb | 2015-07-22 16:51:33 -0700 | [diff] [blame] | 242 | main.log.report( "Start Mininet topology with OF 1.0 switches" ) |
kelvin-onlab | 6dea6e6 | 2015-07-23 13:07:26 -0700 | [diff] [blame] | 243 | main.case( "Start Mininet topology with OF 1.0 switches" ) |
Jon Hall | 783bbf9 | 2015-07-23 14:33:19 -0700 | [diff] [blame] | 244 | main.caseExplanation = "Start mininet topology with OF 1.0 " +\ |
kelvin-onlab | 6dea6e6 | 2015-07-23 13:07:26 -0700 | [diff] [blame] | 245 | "switches to test intents, exits out if " +\ |
| 246 | "topology did not start correctly" |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 247 | |
kelvin-onlab | 6dea6e6 | 2015-07-23 13:07:26 -0700 | [diff] [blame] | 248 | main.step( "Starting Mininet topology with OF 1.0 switches" ) |
kelvin-onlab | b0b0dcb | 2015-07-22 16:51:33 -0700 | [diff] [blame] | 249 | args = "--switch ovs,protocols=OpenFlow10" |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 250 | topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath + |
kelvin-onlab | b0b0dcb | 2015-07-22 16:51:33 -0700 | [diff] [blame] | 251 | main.topology, |
| 252 | args=args ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 253 | stepResult = topoResult |
| 254 | utilities.assert_equals( expect=main.TRUE, |
| 255 | actual=stepResult, |
| 256 | onpass="Successfully loaded topology", |
| 257 | onfail="Failed to load topology" ) |
| 258 | # Exit if topology did not load properly |
| 259 | if not topoResult: |
| 260 | main.cleanup() |
| 261 | main.exit() |
| 262 | |
kelvin-onlab | b5cfab3 | 2015-07-22 16:38:22 -0700 | [diff] [blame] | 263 | def CASE11( self, main ): |
| 264 | """ |
kelvin-onlab | b0b0dcb | 2015-07-22 16:51:33 -0700 | [diff] [blame] | 265 | Start Mininet topology with OF 1.3 switches |
kelvin-onlab | b5cfab3 | 2015-07-22 16:38:22 -0700 | [diff] [blame] | 266 | """ |
kelvin-onlab | 6dea6e6 | 2015-07-23 13:07:26 -0700 | [diff] [blame] | 267 | main.OFProtocol = "1.3" |
kelvin-onlab | b5cfab3 | 2015-07-22 16:38:22 -0700 | [diff] [blame] | 268 | main.log.report( "Start Mininet topology with OF 1.3 switches" ) |
kelvin-onlab | 6dea6e6 | 2015-07-23 13:07:26 -0700 | [diff] [blame] | 269 | main.case( "Start Mininet topology with OF 1.3 switches" ) |
Jon Hall | 783bbf9 | 2015-07-23 14:33:19 -0700 | [diff] [blame] | 270 | main.caseExplanation = "Start mininet topology with OF 1.3 " +\ |
kelvin-onlab | 6dea6e6 | 2015-07-23 13:07:26 -0700 | [diff] [blame] | 271 | "switches to test intents, exits out if " +\ |
| 272 | "topology did not start correctly" |
kelvin-onlab | b5cfab3 | 2015-07-22 16:38:22 -0700 | [diff] [blame] | 273 | |
kelvin-onlab | 6dea6e6 | 2015-07-23 13:07:26 -0700 | [diff] [blame] | 274 | main.step( "Starting Mininet topology with OF 1.3 switches" ) |
kelvin-onlab | b5cfab3 | 2015-07-22 16:38:22 -0700 | [diff] [blame] | 275 | args = "--switch ovs,protocols=OpenFlow13" |
| 276 | topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath + |
| 277 | main.topology, |
| 278 | args=args ) |
| 279 | stepResult = topoResult |
| 280 | utilities.assert_equals( expect=main.TRUE, |
| 281 | actual=stepResult, |
| 282 | onpass="Successfully loaded topology", |
| 283 | onfail="Failed to load topology" ) |
| 284 | # Exit if topology did not load properly |
| 285 | if not topoResult: |
| 286 | main.cleanup() |
| 287 | main.exit() |
| 288 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 289 | def CASE12( self, main ): |
| 290 | """ |
| 291 | Assign mastership to controllers |
| 292 | """ |
| 293 | import re |
| 294 | |
| 295 | main.case( "Assign switches to controllers" ) |
| 296 | main.step( "Assigning switches to controllers" ) |
Jon Hall | 783bbf9 | 2015-07-23 14:33:19 -0700 | [diff] [blame] | 297 | main.caseExplanation = "Assign OF " + main.OFProtocol +\ |
kelvin-onlab | 6dea6e6 | 2015-07-23 13:07:26 -0700 | [diff] [blame] | 298 | " switches to ONOS nodes" |
| 299 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 300 | assignResult = main.TRUE |
| 301 | switchList = [] |
| 302 | |
| 303 | # Creates a list switch name, use getSwitch() function later... |
| 304 | for i in range( 1, ( main.numSwitch + 1 ) ): |
| 305 | switchList.append( 's' + str( i ) ) |
| 306 | |
| 307 | tempONOSip = [] |
| 308 | for i in range( main.numCtrls ): |
| 309 | tempONOSip.append( main.ONOSip[ i ] ) |
| 310 | |
| 311 | assignResult = main.Mininet1.assignSwController( sw=switchList, |
| 312 | ip=tempONOSip, |
| 313 | port='6633' ) |
| 314 | if not assignResult: |
| 315 | main.cleanup() |
| 316 | main.exit() |
| 317 | |
| 318 | for i in range( 1, ( main.numSwitch + 1 ) ): |
| 319 | response = main.Mininet1.getSwController( "s" + str( i ) ) |
| 320 | print( "Response is " + str( response ) ) |
| 321 | if re.search( "tcp:" + main.ONOSip[ 0 ], response ): |
| 322 | assignResult = assignResult and main.TRUE |
| 323 | else: |
| 324 | assignResult = main.FALSE |
| 325 | stepResult = assignResult |
| 326 | utilities.assert_equals( expect=main.TRUE, |
| 327 | actual=stepResult, |
| 328 | onpass="Successfully assigned switches" + |
| 329 | "to controller", |
| 330 | onfail="Failed to assign switches to " + |
| 331 | "controller" ) |
| 332 | def CASE13( self, main ): |
| 333 | """ |
| 334 | Discover all hosts and store its data to a dictionary |
| 335 | """ |
| 336 | main.case( "Discover all hosts" ) |
| 337 | |
| 338 | stepResult = main.TRUE |
| 339 | main.step( "Discover all hosts using pingall " ) |
| 340 | stepResult = main.intentFunction.getHostsData( main ) |
| 341 | utilities.assert_equals( expect=main.TRUE, |
| 342 | actual=stepResult, |
| 343 | onpass="Successfully discovered hosts", |
| 344 | onfail="Failed to discover hosts" ) |
| 345 | |
| 346 | def CASE14( self, main ): |
| 347 | """ |
| 348 | Stop mininet |
| 349 | """ |
| 350 | main.log.report( "Stop Mininet topology" ) |
kelvin-onlab | 6dea6e6 | 2015-07-23 13:07:26 -0700 | [diff] [blame] | 351 | main.case( "Stop Mininet topology" ) |
Jon Hall | 783bbf9 | 2015-07-23 14:33:19 -0700 | [diff] [blame] | 352 | main.caseExplanation = "Stopping the current mininet topology " +\ |
kelvin-onlab | 6dea6e6 | 2015-07-23 13:07:26 -0700 | [diff] [blame] | 353 | "to start up fresh" |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 354 | |
| 355 | main.step( "Stopping Mininet Topology" ) |
| 356 | topoResult = main.Mininet1.stopNet( ) |
| 357 | stepResult = topoResult |
| 358 | utilities.assert_equals( expect=main.TRUE, |
| 359 | actual=stepResult, |
| 360 | onpass="Successfully stop mininet", |
| 361 | onfail="Failed to stop mininet" ) |
| 362 | # Exit if topology did not load properly |
| 363 | if not topoResult: |
| 364 | main.cleanup() |
| 365 | main.exit() |
| 366 | |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 367 | def CASE1000( self, main ): |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 368 | """ |
| 369 | Add host intents between 2 host: |
| 370 | - Discover hosts |
| 371 | - Add host intents |
| 372 | - Check intents |
| 373 | - Verify flows |
| 374 | - Ping hosts |
| 375 | - Reroute |
| 376 | - Link down |
| 377 | - Verify flows |
| 378 | - Check topology |
| 379 | - Ping hosts |
| 380 | - Link up |
| 381 | - Verify flows |
| 382 | - Check topology |
| 383 | - Ping hosts |
| 384 | - Remove intents |
| 385 | """ |
| 386 | import time |
| 387 | import json |
| 388 | import re |
| 389 | |
| 390 | # Assert variables - These variable's name|format must be followed |
| 391 | # if you want to use the wrapper function |
| 392 | assert main, "There is no main" |
| 393 | assert main.CLIs, "There is no main.CLIs" |
| 394 | assert main.Mininet1, "Mininet handle should be named Mininet1" |
| 395 | assert main.numSwitch, "Placed the total number of switch topology in \ |
| 396 | main.numSwitch" |
| 397 | |
acsmars | e6b410f | 2015-07-17 14:39:34 -0700 | [diff] [blame] | 398 | intentLeadersOld = main.CLIs[ 0 ].leaderCandidates() |
| 399 | |
kelvin-onlab | 825b57d | 2015-07-24 13:43:59 -0700 | [diff] [blame] | 400 | main.case( "Host Intents Test - " + str( main.numCtrls ) + |
kelvin-onlab | 4cfa81c | 2015-07-24 11:36:23 -0700 | [diff] [blame] | 401 | " NODE(S) - OF " + main.OFProtocol ) |
Jon Hall | 783bbf9 | 2015-07-23 14:33:19 -0700 | [diff] [blame] | 402 | main.caseExplanation = "This test case tests Host intents using " +\ |
kelvin-onlab | 6dea6e6 | 2015-07-23 13:07:26 -0700 | [diff] [blame] | 403 | str( main.numCtrls ) + " node(s) cluster;\n" +\ |
| 404 | "Different type of hosts will be tested in " +\ |
| 405 | "each step such as IPV4, Dual stack, VLAN " +\ |
| 406 | "etc;\nThe test will use OF " + main.OFProtocol\ |
kelvin-onlab | 4cfa81c | 2015-07-24 11:36:23 -0700 | [diff] [blame] | 407 | + " OVS running in Mininet" |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 408 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 409 | main.step( "IPV4: Add host intents between h1 and h9" ) |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 410 | stepResult = main.TRUE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 411 | stepResult = main.intentFunction.hostIntent( main, |
| 412 | onosNode='0', |
| 413 | name='IPV4', |
| 414 | host1='h1', |
| 415 | host2='h9', |
| 416 | host1Id='00:00:00:00:00:01/-1', |
| 417 | host2Id='00:00:00:00:00:09/-1', |
| 418 | sw1='s5', |
| 419 | sw2='s2', |
| 420 | expectedLink=18 ) |
| 421 | |
| 422 | utilities.assert_equals( expect=main.TRUE, |
| 423 | actual=stepResult, |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 424 | onpass="IPV4: Host intent test successful " + |
| 425 | "between two IPV4 hosts", |
| 426 | onfail="IPV4: Host intent test failed " + |
| 427 | "between two IPV4 hosts") |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 428 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 429 | main.step( "DUALSTACK1: Add host intents between h3 and h11" ) |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 430 | stepResult = main.TRUE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 431 | stepResult = main.intentFunction.hostIntent( main, |
| 432 | name='DUALSTACK', |
| 433 | host1='h3', |
| 434 | host2='h11', |
| 435 | host1Id='00:00:00:00:00:03/-1', |
| 436 | host2Id='00:00:00:00:00:0B/-1', |
| 437 | sw1='s5', |
| 438 | sw2='s2', |
| 439 | expectedLink=18 ) |
| 440 | |
| 441 | utilities.assert_equals( expect=main.TRUE, |
| 442 | actual=stepResult, |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 443 | onpass="DUALSTACK: Host intent test " + |
| 444 | "successful between two " + |
| 445 | "dual stack host using IPV4", |
| 446 | onfail="DUALSTACK: Host intent test " + |
| 447 | "failed between two" + |
| 448 | "dual stack host using IPV4" ) |
| 449 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 450 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 451 | main.step( "DUALSTACK2: Add host intents between h1 and h11" ) |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 452 | stepResult = main.TRUE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 453 | stepResult = main.intentFunction.hostIntent( main, |
| 454 | name='DUALSTACK2', |
| 455 | host1='h1', |
| 456 | host2='h11', |
| 457 | sw1='s5', |
| 458 | sw2='s2', |
| 459 | expectedLink=18 ) |
| 460 | |
| 461 | utilities.assert_equals( expect=main.TRUE, |
| 462 | actual=stepResult, |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 463 | onpass="DUALSTACK2: Host intent test " + |
| 464 | "successful between two " + |
| 465 | "dual stack host using IPV4", |
| 466 | onfail="DUALSTACK2: Host intent test " + |
| 467 | "failed between two" + |
| 468 | "dual stack host using IPV4" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 469 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 470 | main.step( "1HOP: Add host intents between h1 and h3" ) |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 471 | stepResult = main.TRUE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 472 | stepResult = main.intentFunction.hostIntent( main, |
| 473 | name='1HOP', |
| 474 | host1='h1', |
| 475 | host2='h3' ) |
| 476 | |
| 477 | utilities.assert_equals( expect=main.TRUE, |
| 478 | actual=stepResult, |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 479 | onpass="1HOP: Host intent test " + |
| 480 | "successful between two " + |
| 481 | "host using IPV4 in the same switch", |
| 482 | onfail="1HOP: Host intent test " + |
| 483 | "failed between two" + |
| 484 | "host using IPV4 in the same switch" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 485 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 486 | main.step( "VLAN1: Add vlan host intents between h4 and h12" ) |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 487 | stepResult = main.TRUE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 488 | stepResult = main.intentFunction.hostIntent( main, |
| 489 | name='VLAN1', |
| 490 | host1='h4', |
| 491 | host2='h12', |
| 492 | host1Id='00:00:00:00:00:04/100', |
| 493 | host2Id='00:00:00:00:00:0C/100', |
| 494 | sw1='s5', |
| 495 | sw2='s2', |
| 496 | expectedLink=18 ) |
| 497 | |
| 498 | utilities.assert_equals( expect=main.TRUE, |
| 499 | actual=stepResult, |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 500 | onpass="VLAN1: Host intent test " + |
| 501 | "successful between two " + |
| 502 | "host using IPV4 in the same VLAN", |
| 503 | onfail="VLAN1: Host intent test " + |
| 504 | "failed between two" + |
| 505 | "host using IPV4 in the same VLAN" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 506 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 507 | main.step( "VLAN2: Add inter vlan host intents between h13 and h20" ) |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 508 | stepResult = main.TRUE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 509 | stepResult = main.intentFunction.hostIntent( main, |
| 510 | name='VLAN2', |
| 511 | host1='h13', |
| 512 | host2='h20' ) |
| 513 | |
| 514 | utilities.assert_equals( expect=main.FALSE, |
| 515 | actual=stepResult, |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 516 | onpass="VLAN2: Host intent negative test " + |
| 517 | "successful between two " + |
| 518 | "host using IPV4 in different VLAN", |
| 519 | onfail="VLAN2: Host intent negative test " + |
| 520 | "failed between two" + |
| 521 | "host using IPV4 in different VLAN" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 522 | |
acsmars | e6b410f | 2015-07-17 14:39:34 -0700 | [diff] [blame] | 523 | |
| 524 | intentLeadersNew = main.CLIs[ 0 ].leaderCandidates() |
| 525 | main.intentFunction.checkLeaderChange( intentLeadersOld, |
| 526 | intentLeadersNew ) |
| 527 | |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 528 | def CASE2000( self, main ): |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 529 | """ |
| 530 | Add point intents between 2 hosts: |
| 531 | - Get device ids | ports |
| 532 | - Add point intents |
| 533 | - Check intents |
| 534 | - Verify flows |
| 535 | - Ping hosts |
| 536 | - Reroute |
| 537 | - Link down |
| 538 | - Verify flows |
| 539 | - Check topology |
| 540 | - Ping hosts |
| 541 | - Link up |
| 542 | - Verify flows |
| 543 | - Check topology |
| 544 | - Ping hosts |
| 545 | - Remove intents |
| 546 | """ |
| 547 | import time |
| 548 | import json |
| 549 | import re |
| 550 | |
| 551 | # Assert variables - These variable's name|format must be followed |
| 552 | # if you want to use the wrapper function |
| 553 | assert main, "There is no main" |
| 554 | assert main.CLIs, "There is no main.CLIs" |
| 555 | assert main.Mininet1, "Mininet handle should be named Mininet1" |
| 556 | assert main.numSwitch, "Placed the total number of switch topology in \ |
| 557 | main.numSwitch" |
| 558 | |
kelvin-onlab | 825b57d | 2015-07-24 13:43:59 -0700 | [diff] [blame] | 559 | main.case( "Point Intents Test - " + str( main.numCtrls ) + |
kelvin-onlab | 4cfa81c | 2015-07-24 11:36:23 -0700 | [diff] [blame] | 560 | " NODE(S) - OF " + main.OFProtocol ) |
Jon Hall | 783bbf9 | 2015-07-23 14:33:19 -0700 | [diff] [blame] | 561 | main.caseExplanation = "This test case will test point to point" +\ |
kelvin-onlab | 6dea6e6 | 2015-07-23 13:07:26 -0700 | [diff] [blame] | 562 | " intents using " + str( main.numCtrls ) +\ |
| 563 | " node(s) cluster;\n" +\ |
| 564 | "Different type of hosts will be tested in " +\ |
| 565 | "each step such as IPV4, Dual stack, VLAN etc" +\ |
| 566 | ";\nThe test will use OF " + main.OFProtocol +\ |
kelvin-onlab | 4cfa81c | 2015-07-24 11:36:23 -0700 | [diff] [blame] | 567 | " OVS running in Mininet" |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 568 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 569 | # No option point intents |
| 570 | main.step( "NOOPTION: Add point intents between h1 and h9" ) |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 571 | stepResult = main.TRUE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 572 | stepResult = main.intentFunction.pointIntent( |
| 573 | main, |
| 574 | name="NOOPTION", |
| 575 | host1="h1", |
| 576 | host2="h9", |
| 577 | deviceId1="of:0000000000000005/1", |
| 578 | deviceId2="of:0000000000000006/1", |
| 579 | sw1="s5", |
| 580 | sw2="s2", |
| 581 | expectedLink=18 ) |
| 582 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 583 | utilities.assert_equals( expect=main.TRUE, |
| 584 | actual=stepResult, |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 585 | onpass="NOOPTION: Point intent test " + |
| 586 | "successful using no match action", |
| 587 | onfail="NOOPTION: Point intent test " + |
| 588 | "failed using no match action" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 589 | |
| 590 | stepResult = main.TRUE |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 591 | main.step( "IPV4: Add point intents between h1 and h9" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 592 | stepResult = main.intentFunction.pointIntent( |
| 593 | main, |
| 594 | name="IPV4", |
| 595 | host1="h1", |
| 596 | host2="h9", |
| 597 | deviceId1="of:0000000000000005/1", |
| 598 | deviceId2="of:0000000000000006/1", |
| 599 | port1="", |
| 600 | port2="", |
| 601 | ethType="IPV4", |
| 602 | mac1="00:00:00:00:00:01", |
| 603 | mac2="00:00:00:00:00:09", |
| 604 | bandwidth="", |
| 605 | lambdaAlloc=False, |
| 606 | ipProto="", |
| 607 | ip1="", |
| 608 | ip2="", |
| 609 | tcp1="", |
| 610 | tcp2="", |
| 611 | sw1="s5", |
| 612 | sw2="s2", |
| 613 | expectedLink=18 ) |
| 614 | |
| 615 | utilities.assert_equals( expect=main.TRUE, |
| 616 | actual=stepResult, |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 617 | onpass="IPV4: Point intent test " + |
| 618 | "successful using IPV4 type with " + |
| 619 | "MAC addresses", |
| 620 | onfail="IPV4: Point intent test " + |
| 621 | "failed using IPV4 type with " + |
| 622 | "MAC addresses" ) |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 623 | main.step( "IPV4_2: Add point intents between h1 and h9" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 624 | stepResult = main.TRUE |
| 625 | stepResult = main.intentFunction.pointIntent( |
| 626 | main, |
| 627 | name="IPV4_2", |
| 628 | host1="h1", |
| 629 | host2="h9", |
| 630 | deviceId1="of:0000000000000005/1", |
| 631 | deviceId2="of:0000000000000006/1", |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 632 | ipProto="", |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 633 | ip1="", |
| 634 | ip2="", |
| 635 | tcp1="", |
| 636 | tcp2="", |
| 637 | sw1="s5", |
| 638 | sw2="s2", |
| 639 | expectedLink=18 ) |
| 640 | |
| 641 | utilities.assert_equals( expect=main.TRUE, |
| 642 | actual=stepResult, |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 643 | onpass="IPV4_2: Point intent test " + |
| 644 | "successful using IPV4 type with " + |
| 645 | "no MAC addresses", |
| 646 | onfail="IPV4_2: Point intent test " + |
| 647 | "failed using IPV4 type with " + |
| 648 | "no MAC addresses" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 649 | |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 650 | main.step( "SDNIP-TCP: Add point intents between h1 and h9" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 651 | stepResult = main.TRUE |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 652 | mac1 = main.hostsData[ 'h1' ][ 'mac' ] |
| 653 | mac2 = main.hostsData[ 'h9' ][ 'mac' ] |
kelvin-onlab | 0ad05d1 | 2015-07-23 14:21:15 -0700 | [diff] [blame] | 654 | try: |
| 655 | ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/24" |
| 656 | ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/24" |
| 657 | except KeyError: |
| 658 | main.log.debug( "Key Error getting IP addresses of h1 | h9 in" + |
| 659 | "main.hostsData" ) |
| 660 | ip1 = main.Mininet1.getIPAddress( 'h1') |
| 661 | ip2 = main.Mininet1.getIPAddress( 'h9') |
| 662 | |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 663 | ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ] |
| 664 | tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ] |
| 665 | tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ] |
| 666 | |
| 667 | stepResult = main.intentFunction.pointIntent( |
| 668 | main, |
| 669 | name="SDNIP-TCP", |
| 670 | host1="h1", |
| 671 | host2="h9", |
| 672 | deviceId1="of:0000000000000005/1", |
| 673 | deviceId2="of:0000000000000006/1", |
| 674 | mac1=mac1, |
| 675 | mac2=mac2, |
| 676 | ethType="IPV4", |
| 677 | ipProto=ipProto, |
| 678 | ip1=ip1, |
| 679 | ip2=ip2, |
| 680 | tcp1=tcp1, |
| 681 | tcp2=tcp2 ) |
| 682 | |
| 683 | utilities.assert_equals( expect=main.TRUE, |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 684 | actual=stepResult, |
| 685 | onpass="SDNIP-TCP: Point intent test " + |
| 686 | "successful using IPV4 type with " + |
| 687 | "IP protocol TCP enabled", |
| 688 | onfail="SDNIP-TCP: Point intent test " + |
| 689 | "failed using IPV4 type with " + |
| 690 | "IP protocol TCP enabled" ) |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 691 | |
| 692 | main.step( "SDNIP-ICMP: Add point intents between h1 and h9" ) |
| 693 | stepResult = main.TRUE |
| 694 | mac1 = main.hostsData[ 'h1' ][ 'mac' ] |
| 695 | mac2 = main.hostsData[ 'h9' ][ 'mac' ] |
| 696 | ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/24" |
| 697 | ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/24" |
| 698 | ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ] |
| 699 | tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ] |
| 700 | tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ] |
| 701 | |
| 702 | stepResult = main.intentFunction.pointIntent( |
| 703 | main, |
| 704 | name="SDNIP-ICMP", |
| 705 | host1="h1", |
| 706 | host2="h9", |
| 707 | deviceId1="of:0000000000000005/1", |
| 708 | deviceId2="of:0000000000000006/1", |
| 709 | mac1=mac1, |
| 710 | mac2=mac2, |
| 711 | ethType="IPV4", |
| 712 | ipProto=ipProto ) |
| 713 | |
| 714 | utilities.assert_equals( expect=main.TRUE, |
| 715 | actual=stepResult, |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 716 | onpass="SDNIP-ICMP: Point intent test " + |
| 717 | "successful using IPV4 type with " + |
| 718 | "IP protocol ICMP enabled", |
| 719 | onfail="SDNIP-ICMP: Point intent test " + |
| 720 | "failed using IPV4 type with " + |
| 721 | "IP protocol ICMP enabled" ) |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 722 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 723 | main.step( "DUALSTACK1: Add point intents between h1 and h9" ) |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 724 | stepResult = main.TRUE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 725 | stepResult = main.intentFunction.pointIntent( |
| 726 | main, |
| 727 | name="DUALSTACK1", |
| 728 | host1="h3", |
| 729 | host2="h11", |
| 730 | deviceId1="of:0000000000000005", |
| 731 | deviceId2="of:0000000000000006", |
| 732 | port1="3", |
| 733 | port2="3", |
| 734 | ethType="IPV4", |
| 735 | mac1="00:00:00:00:00:03", |
| 736 | mac2="00:00:00:00:00:0B", |
| 737 | bandwidth="", |
| 738 | lambdaAlloc=False, |
| 739 | ipProto="", |
| 740 | ip1="", |
| 741 | ip2="", |
| 742 | tcp1="", |
| 743 | tcp2="", |
| 744 | sw1="s5", |
| 745 | sw2="s2", |
| 746 | expectedLink=18 ) |
| 747 | |
| 748 | utilities.assert_equals( expect=main.TRUE, |
| 749 | actual=stepResult, |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 750 | onpass="DUALSTACK1: Point intent test " + |
| 751 | "successful using IPV4 type with " + |
| 752 | "MAC addresses", |
| 753 | onfail="DUALSTACK1: Point intent test " + |
| 754 | "failed using IPV4 type with " + |
| 755 | "MAC addresses" ) |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 756 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 757 | main.step( "VLAN: Add point intents between h5 and h21" ) |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 758 | stepResult = main.TRUE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 759 | stepResult = main.intentFunction.pointIntent( |
| 760 | main, |
| 761 | name="VLAN", |
| 762 | host1="h5", |
| 763 | host2="h21", |
| 764 | deviceId1="of:0000000000000005/5", |
| 765 | deviceId2="of:0000000000000007/5", |
| 766 | port1="", |
| 767 | port2="", |
| 768 | ethType="IPV4", |
| 769 | mac1="00:00:00:00:00:05", |
| 770 | mac2="00:00:00:00:00:15", |
| 771 | bandwidth="", |
| 772 | lambdaAlloc=False, |
| 773 | ipProto="", |
| 774 | ip1="", |
| 775 | ip2="", |
| 776 | tcp1="", |
| 777 | tcp2="", |
| 778 | sw1="s5", |
| 779 | sw2="s2", |
| 780 | expectedLink=18 ) |
| 781 | |
| 782 | utilities.assert_equals( expect=main.TRUE, |
| 783 | actual=stepResult, |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 784 | onpass="VLAN1: Point intent test " + |
| 785 | "successful using IPV4 type with " + |
| 786 | "MAC addresses", |
| 787 | onfail="VLAN1: Point intent test " + |
| 788 | "failed using IPV4 type with " + |
| 789 | "MAC addresses" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 790 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 791 | main.step( "1HOP: Add point intents between h1 and h3" ) |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 792 | stepResult = main.TRUE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 793 | stepResult = main.intentFunction.hostIntent( main, |
| 794 | name='1HOP', |
| 795 | host1='h1', |
| 796 | host2='h3' ) |
| 797 | |
| 798 | utilities.assert_equals( expect=main.TRUE, |
| 799 | actual=stepResult, |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 800 | onpass="1HOP: Point intent test " + |
| 801 | "successful using IPV4 type with " + |
| 802 | "no MAC addresses", |
| 803 | onfail="1HOP: Point intent test " + |
| 804 | "failed using IPV4 type with " + |
| 805 | "no MAC addresses" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 806 | |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 807 | def CASE3000( self, main ): |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 808 | """ |
| 809 | Add single point to multi point intents |
| 810 | - Get device ids |
| 811 | - Add single point to multi point intents |
| 812 | - Check intents |
| 813 | - Verify flows |
| 814 | - Ping hosts |
| 815 | - Reroute |
| 816 | - Link down |
| 817 | - Verify flows |
| 818 | - Check topology |
| 819 | - Ping hosts |
| 820 | - Link up |
| 821 | - Verify flows |
| 822 | - Check topology |
| 823 | - Ping hosts |
| 824 | - Remove intents |
| 825 | """ |
| 826 | assert main, "There is no main" |
| 827 | assert main.CLIs, "There is no main.CLIs" |
| 828 | assert main.Mininet1, "Mininet handle should be named Mininet1" |
| 829 | assert main.numSwitch, "Placed the total number of switch topology in \ |
| 830 | main.numSwitch" |
| 831 | |
kelvin-onlab | 825b57d | 2015-07-24 13:43:59 -0700 | [diff] [blame] | 832 | main.case( "Single To Multi Point Intents Test - " + |
kelvin-onlab | e5c1ada | 2015-07-24 11:49:40 -0700 | [diff] [blame] | 833 | str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol ) |
Jon Hall | 783bbf9 | 2015-07-23 14:33:19 -0700 | [diff] [blame] | 834 | main.caseExplanation = "This test case will test single point to" +\ |
kelvin-onlab | 6dea6e6 | 2015-07-23 13:07:26 -0700 | [diff] [blame] | 835 | " multi point intents using " +\ |
| 836 | str( main.numCtrls ) + " node(s) cluster;\n" +\ |
| 837 | "Different type of hosts will be tested in " +\ |
| 838 | "each step such as IPV4, Dual stack, VLAN etc" +\ |
| 839 | ";\nThe test will use OF " + main.OFProtocol +\ |
kelvin-onlab | 4cfa81c | 2015-07-24 11:36:23 -0700 | [diff] [blame] | 840 | " OVS running in Mininet" |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 841 | |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 842 | main.step( "NOOPTION: Add single point to multi point intents" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 843 | stepResult = main.TRUE |
| 844 | hostNames = [ 'h8', 'h16', 'h24' ] |
| 845 | devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \ |
| 846 | 'of:0000000000000007/8' ] |
| 847 | macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ] |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 848 | stepResult = main.intentFunction.singleToMultiIntent( |
| 849 | main, |
| 850 | name="NOOPTION", |
| 851 | hostNames=hostNames, |
| 852 | devices=devices, |
| 853 | sw1="s5", |
| 854 | sw2="s2", |
| 855 | expectedLink=18 ) |
| 856 | |
| 857 | utilities.assert_equals( expect=main.TRUE, |
| 858 | actual=stepResult, |
| 859 | onpass="NOOPTION: Successfully added single " |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 860 | + " point to multi point intents" + |
| 861 | " with no match action", |
| 862 | onfail="NOOPTION: Failed to add single point" |
| 863 | + " point to multi point intents" + |
| 864 | " with no match action" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 865 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 866 | main.step( "IPV4: Add single point to multi point intents" ) |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 867 | stepResult = main.TRUE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 868 | stepResult = main.intentFunction.singleToMultiIntent( |
| 869 | main, |
| 870 | name="IPV4", |
| 871 | hostNames=hostNames, |
| 872 | devices=devices, |
| 873 | ports=None, |
| 874 | ethType="IPV4", |
| 875 | macs=macs, |
| 876 | bandwidth="", |
| 877 | lambdaAlloc=False, |
| 878 | ipProto="", |
| 879 | ipAddresses="", |
| 880 | tcp="", |
| 881 | sw1="s5", |
| 882 | sw2="s2", |
| 883 | expectedLink=18 ) |
| 884 | |
| 885 | utilities.assert_equals( expect=main.TRUE, |
| 886 | actual=stepResult, |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 887 | onpass="IPV4: Successfully added single " |
| 888 | + " point to multi point intents" + |
| 889 | " with IPV4 type and MAC addresses", |
| 890 | onfail="IPV4: Failed to add single point" |
| 891 | + " point to multi point intents" + |
| 892 | " with IPV4 type and MAC addresses" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 893 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 894 | main.step( "IPV4_2: Add single point to multi point intents" ) |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 895 | stepResult = main.TRUE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 896 | hostNames = [ 'h8', 'h16', 'h24' ] |
| 897 | stepResult = main.intentFunction.singleToMultiIntent( |
| 898 | main, |
| 899 | name="IPV4", |
| 900 | hostNames=hostNames, |
| 901 | ethType="IPV4", |
| 902 | lambdaAlloc=False ) |
| 903 | |
| 904 | utilities.assert_equals( expect=main.TRUE, |
| 905 | actual=stepResult, |
| 906 | onpass="IPV4_2: Successfully added single " |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 907 | + " point to multi point intents" + |
| 908 | " with IPV4 type and no MAC addresses", |
| 909 | onfail="IPV4_2: Failed to add single point" |
| 910 | + " point to multi point intents" + |
| 911 | " with IPV4 type and no MAC addresses" ) |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 912 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 913 | main.step( "VLAN: Add single point to multi point intents" ) |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 914 | stepResult = main.TRUE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 915 | hostNames = [ 'h4', 'h12', 'h20' ] |
| 916 | devices = [ 'of:0000000000000005/4', 'of:0000000000000006/4', \ |
| 917 | 'of:0000000000000007/4' ] |
| 918 | macs = [ '00:00:00:00:00:04', '00:00:00:00:00:0C', '00:00:00:00:00:14' ] |
| 919 | stepResult = main.intentFunction.singleToMultiIntent( |
| 920 | main, |
| 921 | name="VLAN", |
| 922 | hostNames=hostNames, |
| 923 | devices=devices, |
| 924 | ports=None, |
| 925 | ethType="IPV4", |
| 926 | macs=macs, |
| 927 | bandwidth="", |
| 928 | lambdaAlloc=False, |
| 929 | ipProto="", |
| 930 | ipAddresses="", |
| 931 | tcp="", |
| 932 | sw1="s5", |
| 933 | sw2="s2", |
| 934 | expectedLink=18 ) |
| 935 | |
| 936 | utilities.assert_equals( expect=main.TRUE, |
| 937 | actual=stepResult, |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 938 | onpass="VLAN: Successfully added single " |
| 939 | + " point to multi point intents" + |
| 940 | " with IPV4 type and MAC addresses" + |
| 941 | " in the same VLAN", |
| 942 | onfail="VLAN: Failed to add single point" |
| 943 | + " point to multi point intents" + |
| 944 | " with IPV4 type and MAC addresses" + |
| 945 | " in the same VLAN") |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 946 | |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 947 | def CASE4000( self, main ): |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 948 | """ |
| 949 | Add multi point to single point intents |
| 950 | - Get device ids |
| 951 | - Add multi point to single point intents |
| 952 | - Check intents |
| 953 | - Verify flows |
| 954 | - Ping hosts |
| 955 | - Reroute |
| 956 | - Link down |
| 957 | - Verify flows |
| 958 | - Check topology |
| 959 | - Ping hosts |
| 960 | - Link up |
| 961 | - Verify flows |
| 962 | - Check topology |
| 963 | - Ping hosts |
| 964 | - Remove intents |
| 965 | """ |
| 966 | assert main, "There is no main" |
| 967 | assert main.CLIs, "There is no main.CLIs" |
| 968 | assert main.Mininet1, "Mininet handle should be named Mininet1" |
| 969 | assert main.numSwitch, "Placed the total number of switch topology in \ |
| 970 | main.numSwitch" |
| 971 | |
kelvin-onlab | 825b57d | 2015-07-24 13:43:59 -0700 | [diff] [blame] | 972 | main.case( "Multi To Single Point Intents Test - " + |
kelvin-onlab | e5c1ada | 2015-07-24 11:49:40 -0700 | [diff] [blame] | 973 | str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol ) |
Jon Hall | 783bbf9 | 2015-07-23 14:33:19 -0700 | [diff] [blame] | 974 | main.caseExplanation = "This test case will test single point to" +\ |
kelvin-onlab | 6dea6e6 | 2015-07-23 13:07:26 -0700 | [diff] [blame] | 975 | " multi point intents using " +\ |
| 976 | str( main.numCtrls ) + " node(s) cluster;\n" +\ |
| 977 | "Different type of hosts will be tested in " +\ |
| 978 | "each step such as IPV4, Dual stack, VLAN etc" +\ |
| 979 | ";\nThe test will use OF " + main.OFProtocol +\ |
kelvin-onlab | 4cfa81c | 2015-07-24 11:36:23 -0700 | [diff] [blame] | 980 | " OVS running in Mininet" |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 981 | |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 982 | main.step( "NOOPTION: Add multi point to single point intents" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 983 | stepResult = main.TRUE |
| 984 | hostNames = [ 'h8', 'h16', 'h24' ] |
| 985 | devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \ |
| 986 | 'of:0000000000000007/8' ] |
| 987 | macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ] |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 988 | stepResult = main.intentFunction.multiToSingleIntent( |
| 989 | main, |
| 990 | name="NOOPTION", |
| 991 | hostNames=hostNames, |
| 992 | devices=devices, |
| 993 | sw1="s5", |
| 994 | sw2="s2", |
| 995 | expectedLink=18 ) |
| 996 | |
| 997 | utilities.assert_equals( expect=main.TRUE, |
| 998 | actual=stepResult, |
| 999 | onpass="NOOPTION: Successfully added multi " |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 1000 | + " point to single point intents" + |
| 1001 | " with no match action", |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1002 | onfail="NOOPTION: Failed to add multi point" + |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 1003 | " to single point intents" + |
| 1004 | " with no match action" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1005 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1006 | main.step( "IPV4: Add multi point to single point intents" ) |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 1007 | stepResult = main.TRUE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1008 | stepResult = main.intentFunction.multiToSingleIntent( |
| 1009 | main, |
| 1010 | name="IPV4", |
| 1011 | hostNames=hostNames, |
| 1012 | devices=devices, |
| 1013 | ports=None, |
| 1014 | ethType="IPV4", |
| 1015 | macs=macs, |
| 1016 | bandwidth="", |
| 1017 | lambdaAlloc=False, |
| 1018 | ipProto="", |
| 1019 | ipAddresses="", |
| 1020 | tcp="", |
| 1021 | sw1="s5", |
| 1022 | sw2="s2", |
| 1023 | expectedLink=18 ) |
| 1024 | |
| 1025 | utilities.assert_equals( expect=main.TRUE, |
| 1026 | actual=stepResult, |
| 1027 | onpass="IPV4: Successfully added multi point" |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 1028 | + " to single point intents" + |
| 1029 | " with IPV4 type and MAC addresses", |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1030 | onfail="IPV4: Failed to add multi point" + |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 1031 | " to single point intents" + |
| 1032 | " with IPV4 type and MAC addresses" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1033 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1034 | main.step( "IPV4_2: Add multi point to single point intents" ) |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 1035 | stepResult = main.TRUE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1036 | hostNames = [ 'h8', 'h16', 'h24' ] |
| 1037 | stepResult = main.intentFunction.multiToSingleIntent( |
| 1038 | main, |
| 1039 | name="IPV4", |
| 1040 | hostNames=hostNames, |
| 1041 | ethType="IPV4", |
| 1042 | lambdaAlloc=False ) |
| 1043 | |
| 1044 | utilities.assert_equals( expect=main.TRUE, |
| 1045 | actual=stepResult, |
| 1046 | onpass="IPV4_2: Successfully added multi point" |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 1047 | + " to single point intents" + |
| 1048 | " with IPV4 type and no MAC addresses", |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1049 | onfail="IPV4_2: Failed to add multi point" + |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 1050 | " to single point intents" + |
| 1051 | " with IPV4 type and no MAC addresses" ) |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1052 | |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1053 | main.step( "VLAN: Add multi point to single point intents" ) |
kelvin-onlab | b769f56 | 2015-07-15 17:05:10 -0700 | [diff] [blame] | 1054 | stepResult = main.TRUE |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1055 | hostNames = [ 'h5', 'h13', 'h21' ] |
| 1056 | devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \ |
| 1057 | 'of:0000000000000007/5' ] |
| 1058 | macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ] |
| 1059 | stepResult = main.intentFunction.multiToSingleIntent( |
| 1060 | main, |
| 1061 | name="VLAN", |
| 1062 | hostNames=hostNames, |
| 1063 | devices=devices, |
| 1064 | ports=None, |
| 1065 | ethType="IPV4", |
| 1066 | macs=macs, |
| 1067 | bandwidth="", |
| 1068 | lambdaAlloc=False, |
| 1069 | ipProto="", |
| 1070 | ipAddresses="", |
| 1071 | tcp="", |
| 1072 | sw1="s5", |
| 1073 | sw2="s2", |
| 1074 | expectedLink=18 ) |
| 1075 | |
| 1076 | utilities.assert_equals( expect=main.TRUE, |
| 1077 | actual=stepResult, |
| 1078 | onpass="VLAN: Successfully added multi point" |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 1079 | + " to single point intents" + |
| 1080 | " with IPV4 type and MAC addresses" + |
| 1081 | " in the same VLAN", |
kelvin-onlab | d48a68c | 2015-07-13 16:01:36 -0700 | [diff] [blame] | 1082 | onfail="VLAN: Failed to add multi point" + |
| 1083 | " to single point intents" ) |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 1084 | |
acsmars | 1ff5e05 | 2015-07-23 11:27:48 -0700 | [diff] [blame] | 1085 | def CASE5000( self, main ): |
| 1086 | """ |
| 1087 | Will add description in next patch set |
acsmars | 1ff5e05 | 2015-07-23 11:27:48 -0700 | [diff] [blame] | 1088 | """ |
| 1089 | assert main, "There is no main" |
| 1090 | assert main.CLIs, "There is no main.CLIs" |
| 1091 | assert main.Mininet1, "Mininet handle should be named Mininet1" |
| 1092 | assert main.numSwitch, "Placed the total number of switch topology in \ |
| 1093 | main.numSwitch" |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 1094 | main.case( "Test host mobility with host intents " ) |
| 1095 | main.step( " Testing host mobility by moving h1 from s5 to s6" ) |
acsmars | 1ff5e05 | 2015-07-23 11:27:48 -0700 | [diff] [blame] | 1096 | h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ] |
| 1097 | |
| 1098 | main.log.info( "Moving h1 from s5 to s6") |
| 1099 | |
| 1100 | main.Mininet1.moveHost( "h1","s5","s6" ) |
| 1101 | |
| 1102 | main.intentFunction.getHostsData( main ) |
| 1103 | h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ] |
| 1104 | |
| 1105 | utilities.assert_equals( expect="of:0000000000000006", |
| 1106 | actual=h1PostMove, |
| 1107 | onpass="Mobility: Successfully moved h1 to s6", |
kelvin-onlab | f34a58a | 2015-07-23 16:41:52 -0700 | [diff] [blame] | 1108 | onfail="Mobility: Failed to moved h1 to s6" + |
| 1109 | " to single point intents" + |
| 1110 | " with IPV4 type and MAC addresses" + |
| 1111 | " in the same VLAN" ) |
| 1112 | |
| 1113 | main.step( "IPV4: Add host intents between h1 and h9" ) |
| 1114 | stepResult = main.TRUE |
| 1115 | stepResult = main.intentFunction.hostIntent( main, |
| 1116 | onosNode='0', |
| 1117 | name='IPV4', |
| 1118 | host1='h1', |
| 1119 | host2='h9', |
| 1120 | host1Id='00:00:00:00:00:01/-1', |
| 1121 | host2Id='00:00:00:00:00:09/-1' ) |
| 1122 | |
| 1123 | utilities.assert_equals( expect=main.TRUE, |
| 1124 | actual=stepResult, |
| 1125 | onpass="IPV4: Host intent test successful " + |
| 1126 | "between two IPV4 hosts", |
| 1127 | onfail="IPV4: Host intent test failed " + |
| 1128 | "between two IPV4 hosts") |