blob: 797a91a7a33e2caea4c194cad84be02d7ca916d5 [file] [log] [blame]
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001# Testing the basic intent functionality of ONOS
2
kelvin-onlabd48a68c2015-07-13 16:01:36 -07003class FUNCintent:
4
5 def __init__( self ):
6 self.default = ''
7
8 def CASE1( self, main ):
9 import time
kelvin-onlabd48a68c2015-07-13 16:01:36 -070010 import imp
Jon Hallf632d202015-07-30 15:45:11 -070011 import re
kelvin-onlabd48a68c2015-07-13 16:01:36 -070012
13 """
14 - Construct tests variables
15 - GIT ( optional )
16 - Checkout ONOS master branch
17 - Pull latest ONOS code
18 - Building ONOS ( optional )
19 - Install ONOS package
20 - Build ONOS package
21 """
22
23 main.case( "Constructing test variables and building ONOS package" )
24 main.step( "Constructing test variables" )
Jon Hall783bbf92015-07-23 14:33:19 -070025 main.caseExplanation = "This test case is mainly for loading " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -070026 "from params file, and pull and build the " +\
27 " latest ONOS package"
kelvin-onlabd48a68c2015-07-13 16:01:36 -070028 stepResult = main.FALSE
29
30 # Test variables
Jon Halla3e02432015-07-24 15:55:42 -070031 try:
Jon Hallf632d202015-07-30 15:45:11 -070032 main.testOnDirectory = re.sub( "(/tests)$", "", main.testDir )
Jon Halla3e02432015-07-24 15:55:42 -070033 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
34 gitBranch = main.params[ 'GIT' ][ 'branch' ]
35 main.dependencyPath = main.testOnDirectory + \
36 main.params[ 'DEPENDENCY' ][ 'path' ]
37 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
38 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
39 if main.ONOSbench.maxNodes:
40 main.maxNodes = int( main.ONOSbench.maxNodes )
41 else:
42 main.maxNodes = 0
43 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
44 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
45 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
46 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
47 main.checkIntentSleep = int( main.params[ 'SLEEP' ][ 'checkintent' ] )
acsmarscfa52272015-08-06 15:21:45 -070048 main.removeIntentSleep = int( main.params[ 'SLEEP' ][ 'removeintent' ] )
Jon Halla3e02432015-07-24 15:55:42 -070049 main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] )
50 main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
51 gitPull = main.params[ 'GIT' ][ 'pull' ]
52 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
53 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
54 main.cellData = {} # for creating cell file
55 main.hostsData = {}
56 main.CLIs = []
57 main.ONOSip = []
kelvin-onlabd48a68c2015-07-13 16:01:36 -070058
Jon Halla3e02432015-07-24 15:55:42 -070059 main.ONOSip = main.ONOSbench.getOnosIps()
60 print main.ONOSip
kelvin-onlabd48a68c2015-07-13 16:01:36 -070061
Jon Halla3e02432015-07-24 15:55:42 -070062 # Assigning ONOS cli handles to a list
63 for i in range( 1, main.maxNodes + 1 ):
64 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070065
Jon Halla3e02432015-07-24 15:55:42 -070066 # -- INIT SECTION, ONLY RUNS ONCE -- #
67 main.startUp = imp.load_source( wrapperFile1,
68 main.dependencyPath +
69 wrapperFile1 +
70 ".py" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070071
Jon Halla3e02432015-07-24 15:55:42 -070072 main.intentFunction = imp.load_source( wrapperFile2,
73 main.dependencyPath +
74 wrapperFile2 +
75 ".py" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070076
Jon Halla3e02432015-07-24 15:55:42 -070077 main.topo = imp.load_source( wrapperFile3,
78 main.dependencyPath +
79 wrapperFile3 +
80 ".py" )
81
kelvin-onlabd9e23de2015-08-06 10:34:44 -070082 copyResult1 = main.ONOSbench.scp( main.Mininet1,
83 main.dependencyPath +
84 main.topology,
85 main.Mininet1.home,
86 direction="to" )
Jon Halla3e02432015-07-24 15:55:42 -070087 if main.CLIs:
88 stepResult = main.TRUE
89 else:
90 main.log.error( "Did not properly created list of ONOS CLI handle" )
91 stepResult = main.FALSE
92 except Exception as e:
93 main.log.exception(e)
94 main.cleanup()
95 main.exit()
kelvin-onlabd48a68c2015-07-13 16:01:36 -070096
97 utilities.assert_equals( expect=main.TRUE,
98 actual=stepResult,
99 onpass="Successfully construct " +
100 "test variables ",
101 onfail="Failed to construct test variables" )
102
103 if gitPull == 'True':
104 main.step( "Building ONOS in " + gitBranch + " branch" )
105 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
106 stepResult = onosBuildResult
107 utilities.assert_equals( expect=main.TRUE,
108 actual=stepResult,
109 onpass="Successfully compiled " +
110 "latest ONOS",
111 onfail="Failed to compile " +
112 "latest ONOS" )
113 else:
114 main.log.warn( "Did not pull new code so skipping mvn " +
115 "clean install" )
Jon Hall106be082015-07-22 09:53:00 -0700116 main.ONOSbench.getVersion( report=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700117
118 def CASE2( self, main ):
119 """
120 - Set up cell
121 - Create cell file
122 - Set cell file
123 - Verify cell file
124 - Kill ONOS process
125 - Uninstall ONOS cluster
126 - Verify ONOS start up
127 - Install ONOS cluster
128 - Connect to cli
129 """
130
131 # main.scale[ 0 ] determines the current number of ONOS controller
132 main.numCtrls = int( main.scale[ 0 ] )
133
134 main.case( "Starting up " + str( main.numCtrls ) +
135 " node(s) ONOS cluster" )
Jon Hall783bbf92015-07-23 14:33:19 -0700136 main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700137 " node(s) ONOS cluster"
138
139
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700140
141 #kill off all onos processes
142 main.log.info( "Safety check, killing all ONOS processes" +
143 " before initiating enviornment setup" )
144
145 for i in range( main.maxNodes ):
146 main.ONOSbench.onosDie( main.ONOSip[ i ] )
147
148 print "NODE COUNT = ", main.numCtrls
149
150 tempOnosIp = []
151 for i in range( main.numCtrls ):
152 tempOnosIp.append( main.ONOSip[i] )
153
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700154 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
155 "temp", main.Mininet1.ip_address,
156 main.apps, tempOnosIp )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700157
158 main.step( "Apply cell to environment" )
159 cellResult = main.ONOSbench.setCell( "temp" )
160 verifyResult = main.ONOSbench.verifyCell()
161 stepResult = cellResult and verifyResult
162 utilities.assert_equals( expect=main.TRUE,
163 actual=stepResult,
164 onpass="Successfully applied cell to " + \
165 "environment",
166 onfail="Failed to apply cell to environment " )
167
168 main.step( "Creating ONOS package" )
169 packageResult = main.ONOSbench.onosPackage()
170 stepResult = packageResult
171 utilities.assert_equals( expect=main.TRUE,
172 actual=stepResult,
173 onpass="Successfully created ONOS package",
174 onfail="Failed to create ONOS package" )
175
176 time.sleep( main.startUpSleep )
177 main.step( "Uninstalling ONOS package" )
178 onosUninstallResult = main.TRUE
kelvin-onlab5f0d19e2015-08-04 15:21:00 -0700179 for ip in main.ONOSip:
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700180 onosUninstallResult = onosUninstallResult and \
kelvin-onlab5f0d19e2015-08-04 15:21:00 -0700181 main.ONOSbench.onosUninstall( nodeIp=ip )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700182 stepResult = onosUninstallResult
183 utilities.assert_equals( expect=main.TRUE,
184 actual=stepResult,
185 onpass="Successfully uninstalled ONOS package",
186 onfail="Failed to uninstall ONOS package" )
187
188 time.sleep( main.startUpSleep )
189 main.step( "Installing ONOS package" )
190 onosInstallResult = main.TRUE
191 for i in range( main.numCtrls ):
192 onosInstallResult = onosInstallResult and \
193 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
194 stepResult = onosInstallResult
195 utilities.assert_equals( expect=main.TRUE,
196 actual=stepResult,
197 onpass="Successfully installed ONOS package",
198 onfail="Failed to install ONOS package" )
199
200 time.sleep( main.startUpSleep )
201 main.step( "Starting ONOS service" )
202 stopResult = main.TRUE
203 startResult = main.TRUE
204 onosIsUp = main.TRUE
205
206 for i in range( main.numCtrls ):
207 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
208 if onosIsUp == main.TRUE:
209 main.log.report( "ONOS instance is up and ready" )
210 else:
211 main.log.report( "ONOS instance may not be up, stop and " +
212 "start ONOS again " )
213 for i in range( main.numCtrls ):
214 stopResult = stopResult and \
215 main.ONOSbench.onosStop( main.ONOSip[ i ] )
216 for i in range( main.numCtrls ):
217 startResult = startResult and \
218 main.ONOSbench.onosStart( main.ONOSip[ i ] )
219 stepResult = onosIsUp and stopResult and startResult
220 utilities.assert_equals( expect=main.TRUE,
221 actual=stepResult,
222 onpass="ONOS service is ready",
223 onfail="ONOS service did not start properly" )
224
225 main.step( "Start ONOS cli" )
226 cliResult = main.TRUE
227 for i in range( main.numCtrls ):
228 cliResult = cliResult and \
229 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
230 stepResult = cliResult
231 utilities.assert_equals( expect=main.TRUE,
232 actual=stepResult,
233 onpass="Successfully start ONOS cli",
234 onfail="Failed to start ONOS cli" )
235
236 # Remove the first element in main.scale list
237 main.scale.remove( main.scale[ 0 ] )
238
kelvin-onlab016dce22015-08-10 09:54:11 -0700239 main.intentFunction.report( main )
240
Jon Halla3e02432015-07-24 15:55:42 -0700241 def CASE8( self, main ):
242 """
243 Compare Topo
244 """
245 import json
246
247 main.case( "Compare ONOS Topology view to Mininet topology" )
248 main.caseExplanation = "Compare topology elements between Mininet" +\
249 " and ONOS"
250
acsmars8a605862015-08-25 17:41:02 -0700251 main.log.info( "Gathering topology information" )
252
Jon Halla3e02432015-07-24 15:55:42 -0700253 devicesResults = main.TRUE
254 linksResults = main.TRUE
255 hostsResults = main.TRUE
256 devices = main.topo.getAllDevices( main )
257 hosts = main.topo.getAllHosts( main )
258 ports = main.topo.getAllPorts( main )
259 links = main.topo.getAllLinks( main )
260 clusters = main.topo.getAllClusters( main )
261
262 mnSwitches = main.Mininet1.getSwitches()
263 mnLinks = main.Mininet1.getLinks()
264 mnHosts = main.Mininet1.getHosts()
265
266 main.step( "Conmparing MN topology to ONOS topology" )
267 for controller in range( main.numCtrls ):
268 controllerStr = str( controller + 1 )
269 if devices[ controller ] and ports[ controller ] and\
270 "Error" not in devices[ controller ] and\
271 "Error" not in ports[ controller ]:
272
273 currentDevicesResult = main.Mininet1.compareSwitches(
274 mnSwitches,
275 json.loads( devices[ controller ] ),
276 json.loads( ports[ controller ] ) )
277 else:
278 currentDevicesResult = main.FALSE
279 utilities.assert_equals( expect=main.TRUE,
280 actual=currentDevicesResult,
281 onpass="ONOS" + controllerStr +
282 " Switches view is correct",
283 onfail="ONOS" + controllerStr +
284 " Switches view is incorrect" )
Jon Hall46d48252015-08-03 11:41:16 -0700285 devicesResults = devicesResults and currentDevicesResult
Jon Halla3e02432015-07-24 15:55:42 -0700286
287 if links[ controller ] and "Error" not in links[ controller ]:
288 currentLinksResult = main.Mininet1.compareLinks(
289 mnSwitches, mnLinks,
290 json.loads( links[ controller ] ) )
291 else:
292 currentLinksResult = main.FALSE
293 utilities.assert_equals( expect=main.TRUE,
294 actual=currentLinksResult,
295 onpass="ONOS" + controllerStr +
296 " links view is correct",
297 onfail="ONOS" + controllerStr +
298 " links view is incorrect" )
Jon Hall46d48252015-08-03 11:41:16 -0700299 linksResults = linksResults and currentLinksResult
Jon Halla3e02432015-07-24 15:55:42 -0700300
301 if hosts[ controller ] or "Error" not in hosts[ controller ]:
302 currentHostsResult = main.Mininet1.compareHosts(
303 mnHosts,
304 json.loads( hosts[ controller ] ) )
305 else:
306 currentHostsResult = main.FALSE
307 utilities.assert_equals( expect=main.TRUE,
308 actual=currentHostsResult,
309 onpass="ONOS" + controllerStr +
310 " hosts exist in Mininet",
311 onfail="ONOS" + controllerStr +
312 " hosts don't match Mininet" )
Jon Hall46d48252015-08-03 11:41:16 -0700313 hostsResults = hostsResults and currentHostsResult
314 topoResults = hostsResults and linksResults and devicesResults
315 utilities.assert_equals( expect=main.TRUE,
316 actual=topoResults,
317 onpass="ONOS correctly discovered the topology",
318 onfail="ONOS incorrectly discovered the topology" )
Jon Halla3e02432015-07-24 15:55:42 -0700319
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700320 def CASE10( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700321 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700322 Start Mininet topology with OF 1.0 switches
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700323 """
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700324 main.OFProtocol = "1.0"
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700325 main.log.report( "Start Mininet topology with OF 1.0 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700326 main.case( "Start Mininet topology with OF 1.0 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700327 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700328 "switches to test intents, exits out if " +\
329 "topology did not start correctly"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700330
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700331 main.step( "Starting Mininet topology with OF 1.0 switches" )
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700332 args = "--switch ovs,protocols=OpenFlow10"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700333 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700334 main.topology,
335 args=args )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700336 stepResult = topoResult
337 utilities.assert_equals( expect=main.TRUE,
338 actual=stepResult,
339 onpass="Successfully loaded topology",
340 onfail="Failed to load topology" )
341 # Exit if topology did not load properly
342 if not topoResult:
343 main.cleanup()
344 main.exit()
345
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700346 def CASE11( self, main ):
347 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700348 Start Mininet topology with OF 1.3 switches
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700349 """
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700350 main.OFProtocol = "1.3"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700351 main.log.report( "Start Mininet topology with OF 1.3 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700352 main.case( "Start Mininet topology with OF 1.3 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700353 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700354 "switches to test intents, exits out if " +\
355 "topology did not start correctly"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700356
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700357 main.step( "Starting Mininet topology with OF 1.3 switches" )
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700358 args = "--switch ovs,protocols=OpenFlow13"
359 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
360 main.topology,
361 args=args )
362 stepResult = topoResult
363 utilities.assert_equals( expect=main.TRUE,
364 actual=stepResult,
365 onpass="Successfully loaded topology",
366 onfail="Failed to load topology" )
367 # Exit if topology did not load properly
368 if not topoResult:
369 main.cleanup()
370 main.exit()
371
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700372 def CASE12( self, main ):
373 """
374 Assign mastership to controllers
375 """
376 import re
377
378 main.case( "Assign switches to controllers" )
379 main.step( "Assigning switches to controllers" )
Jon Hall783bbf92015-07-23 14:33:19 -0700380 main.caseExplanation = "Assign OF " + main.OFProtocol +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700381 " switches to ONOS nodes"
382
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700383 assignResult = main.TRUE
384 switchList = []
385
386 # Creates a list switch name, use getSwitch() function later...
387 for i in range( 1, ( main.numSwitch + 1 ) ):
388 switchList.append( 's' + str( i ) )
389
390 tempONOSip = []
391 for i in range( main.numCtrls ):
392 tempONOSip.append( main.ONOSip[ i ] )
393
394 assignResult = main.Mininet1.assignSwController( sw=switchList,
395 ip=tempONOSip,
396 port='6633' )
397 if not assignResult:
398 main.cleanup()
399 main.exit()
400
401 for i in range( 1, ( main.numSwitch + 1 ) ):
402 response = main.Mininet1.getSwController( "s" + str( i ) )
403 print( "Response is " + str( response ) )
404 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
405 assignResult = assignResult and main.TRUE
406 else:
407 assignResult = main.FALSE
408 stepResult = assignResult
409 utilities.assert_equals( expect=main.TRUE,
410 actual=stepResult,
411 onpass="Successfully assigned switches" +
412 "to controller",
413 onfail="Failed to assign switches to " +
414 "controller" )
415 def CASE13( self, main ):
416 """
417 Discover all hosts and store its data to a dictionary
418 """
419 main.case( "Discover all hosts" )
420
421 stepResult = main.TRUE
422 main.step( "Discover all hosts using pingall " )
423 stepResult = main.intentFunction.getHostsData( main )
424 utilities.assert_equals( expect=main.TRUE,
425 actual=stepResult,
426 onpass="Successfully discovered hosts",
427 onfail="Failed to discover hosts" )
428
429 def CASE14( self, main ):
430 """
431 Stop mininet
432 """
433 main.log.report( "Stop Mininet topology" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700434 main.case( "Stop Mininet topology" )
Jon Hall783bbf92015-07-23 14:33:19 -0700435 main.caseExplanation = "Stopping the current mininet topology " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700436 "to start up fresh"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700437
438 main.step( "Stopping Mininet Topology" )
439 topoResult = main.Mininet1.stopNet( )
440 stepResult = topoResult
441 utilities.assert_equals( expect=main.TRUE,
442 actual=stepResult,
443 onpass="Successfully stop mininet",
444 onfail="Failed to stop mininet" )
445 # Exit if topology did not load properly
446 if not topoResult:
447 main.cleanup()
448 main.exit()
449
kelvin-onlabb769f562015-07-15 17:05:10 -0700450 def CASE1000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700451 """
452 Add host intents between 2 host:
453 - Discover hosts
454 - Add host intents
455 - Check intents
456 - Verify flows
457 - Ping hosts
458 - Reroute
459 - Link down
460 - Verify flows
461 - Check topology
462 - Ping hosts
463 - Link up
464 - Verify flows
465 - Check topology
466 - Ping hosts
467 - Remove intents
468 """
469 import time
470 import json
471 import re
472
473 # Assert variables - These variable's name|format must be followed
474 # if you want to use the wrapper function
475 assert main, "There is no main"
476 assert main.CLIs, "There is no main.CLIs"
477 assert main.Mininet1, "Mininet handle should be named Mininet1"
478 assert main.numSwitch, "Placed the total number of switch topology in \
479 main.numSwitch"
480
acsmarse6b410f2015-07-17 14:39:34 -0700481 intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
482
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700483 main.testName = "Host Intents"
484 main.case( main.testName + " Test - " + str( main.numCtrls ) +
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700485 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700486 main.caseExplanation = "This test case tests Host intents using " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700487 str( main.numCtrls ) + " node(s) cluster;\n" +\
488 "Different type of hosts will be tested in " +\
489 "each step such as IPV4, Dual stack, VLAN " +\
490 "etc;\nThe test will use OF " + main.OFProtocol\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700491 + " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700492
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700493 main.step( "IPV4: Add host intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700494 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700495 stepResult = main.intentFunction.hostIntent( main,
496 onosNode='0',
497 name='IPV4',
498 host1='h1',
499 host2='h9',
500 host1Id='00:00:00:00:00:01/-1',
501 host2Id='00:00:00:00:00:09/-1',
502 sw1='s5',
503 sw2='s2',
504 expectedLink=18 )
505
506 utilities.assert_equals( expect=main.TRUE,
507 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700508 onpass="IPV4: Host intent test successful " +
509 "between two IPV4 hosts",
510 onfail="IPV4: Host intent test failed " +
511 "between two IPV4 hosts")
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700512
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700513 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700514 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700515 stepResult = main.intentFunction.hostIntent( main,
516 name='DUALSTACK',
517 host1='h3',
518 host2='h11',
519 host1Id='00:00:00:00:00:03/-1',
520 host2Id='00:00:00:00:00:0B/-1',
521 sw1='s5',
522 sw2='s2',
523 expectedLink=18 )
524
525 utilities.assert_equals( expect=main.TRUE,
526 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700527 onpass="DUALSTACK: Host intent test " +
528 "successful between two " +
529 "dual stack host using IPV4",
530 onfail="DUALSTACK: Host intent test " +
531 "failed between two" +
532 "dual stack host using IPV4" )
533
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700534
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700535 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700536 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700537 stepResult = main.intentFunction.hostIntent( main,
538 name='DUALSTACK2',
539 host1='h1',
540 host2='h11',
541 sw1='s5',
542 sw2='s2',
543 expectedLink=18 )
544
545 utilities.assert_equals( expect=main.TRUE,
546 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700547 onpass="DUALSTACK2: Host intent test " +
548 "successful between two " +
549 "dual stack host using IPV4",
550 onfail="DUALSTACK2: Host intent test " +
551 "failed between two" +
552 "dual stack host using IPV4" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700553
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700554 main.step( "1HOP: Add host intents between h1 and h3" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700555 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700556 stepResult = main.intentFunction.hostIntent( main,
557 name='1HOP',
558 host1='h1',
559 host2='h3' )
560
561 utilities.assert_equals( expect=main.TRUE,
562 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700563 onpass="1HOP: Host intent test " +
564 "successful between two " +
565 "host using IPV4 in the same switch",
566 onfail="1HOP: Host intent test " +
567 "failed between two" +
568 "host using IPV4 in the same switch" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700569
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700570 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700571 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700572 stepResult = main.intentFunction.hostIntent( main,
573 name='VLAN1',
574 host1='h4',
575 host2='h12',
576 host1Id='00:00:00:00:00:04/100',
577 host2Id='00:00:00:00:00:0C/100',
578 sw1='s5',
579 sw2='s2',
580 expectedLink=18 )
581
582 utilities.assert_equals( expect=main.TRUE,
583 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700584 onpass="VLAN1: Host intent test " +
585 "successful between two " +
586 "host using IPV4 in the same VLAN",
587 onfail="VLAN1: Host intent test " +
588 "failed between two" +
589 "host using IPV4 in the same VLAN" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700590
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700591 main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700592 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700593 stepResult = main.intentFunction.hostIntent( main,
594 name='VLAN2',
595 host1='h13',
596 host2='h20' )
597
598 utilities.assert_equals( expect=main.FALSE,
599 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700600 onpass="VLAN2: Host intent negative test " +
601 "successful between two " +
602 "host using IPV4 in different VLAN",
603 onfail="VLAN2: Host intent negative test " +
604 "failed between two" +
605 "host using IPV4 in different VLAN" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700606
acsmarse6b410f2015-07-17 14:39:34 -0700607
608 intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
609 main.intentFunction.checkLeaderChange( intentLeadersOld,
610 intentLeadersNew )
611
kelvin-onlab016dce22015-08-10 09:54:11 -0700612 main.intentFunction.report( main )
613
kelvin-onlabb769f562015-07-15 17:05:10 -0700614 def CASE2000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700615 """
616 Add point intents between 2 hosts:
617 - Get device ids | ports
618 - Add point intents
619 - Check intents
620 - Verify flows
621 - Ping hosts
622 - Reroute
623 - Link down
624 - Verify flows
625 - Check topology
626 - Ping hosts
627 - Link up
628 - Verify flows
629 - Check topology
630 - Ping hosts
631 - Remove intents
632 """
633 import time
634 import json
635 import re
636
637 # Assert variables - These variable's name|format must be followed
638 # if you want to use the wrapper function
639 assert main, "There is no main"
640 assert main.CLIs, "There is no main.CLIs"
641 assert main.Mininet1, "Mininet handle should be named Mininet1"
642 assert main.numSwitch, "Placed the total number of switch topology in \
643 main.numSwitch"
644
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700645 main.testName = "Point Intents"
646 main.case( main.testName + " Test - " + str( main.numCtrls ) +
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700647 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700648 main.caseExplanation = "This test case will test point to point" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700649 " intents using " + str( main.numCtrls ) +\
650 " node(s) cluster;\n" +\
651 "Different type of hosts will be tested in " +\
652 "each step such as IPV4, Dual stack, VLAN etc" +\
653 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700654 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700655
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700656 # No option point intents
657 main.step( "NOOPTION: Add point intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700658 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700659 stepResult = main.intentFunction.pointIntent(
660 main,
661 name="NOOPTION",
662 host1="h1",
663 host2="h9",
664 deviceId1="of:0000000000000005/1",
665 deviceId2="of:0000000000000006/1",
666 sw1="s5",
667 sw2="s2",
668 expectedLink=18 )
669
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700670 utilities.assert_equals( expect=main.TRUE,
671 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700672 onpass="NOOPTION: Point intent test " +
673 "successful using no match action",
674 onfail="NOOPTION: Point intent test " +
675 "failed using no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700676
677 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -0700678 main.step( "IPV4: Add point intents between h1 and h9" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700679 stepResult = main.intentFunction.pointIntent(
680 main,
681 name="IPV4",
682 host1="h1",
683 host2="h9",
684 deviceId1="of:0000000000000005/1",
685 deviceId2="of:0000000000000006/1",
686 port1="",
687 port2="",
688 ethType="IPV4",
689 mac1="00:00:00:00:00:01",
690 mac2="00:00:00:00:00:09",
691 bandwidth="",
692 lambdaAlloc=False,
693 ipProto="",
694 ip1="",
695 ip2="",
696 tcp1="",
697 tcp2="",
698 sw1="s5",
699 sw2="s2",
700 expectedLink=18 )
701
702 utilities.assert_equals( expect=main.TRUE,
703 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700704 onpass="IPV4: Point intent test " +
705 "successful using IPV4 type with " +
706 "MAC addresses",
707 onfail="IPV4: Point intent test " +
708 "failed using IPV4 type with " +
709 "MAC addresses" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700710 main.step( "IPV4_2: Add point intents between h1 and h9" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700711 stepResult = main.TRUE
712 stepResult = main.intentFunction.pointIntent(
713 main,
714 name="IPV4_2",
715 host1="h1",
716 host2="h9",
717 deviceId1="of:0000000000000005/1",
718 deviceId2="of:0000000000000006/1",
kelvin-onlabb769f562015-07-15 17:05:10 -0700719 ipProto="",
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700720 ip1="",
721 ip2="",
722 tcp1="",
723 tcp2="",
724 sw1="s5",
725 sw2="s2",
726 expectedLink=18 )
727
728 utilities.assert_equals( expect=main.TRUE,
729 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700730 onpass="IPV4_2: Point intent test " +
731 "successful using IPV4 type with " +
732 "no MAC addresses",
733 onfail="IPV4_2: Point intent test " +
734 "failed using IPV4 type with " +
735 "no MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700736
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700737 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700738 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -0700739 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
740 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab0ad05d12015-07-23 14:21:15 -0700741 try:
742 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/24"
743 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/24"
744 except KeyError:
745 main.log.debug( "Key Error getting IP addresses of h1 | h9 in" +
746 "main.hostsData" )
747 ip1 = main.Mininet1.getIPAddress( 'h1')
748 ip2 = main.Mininet1.getIPAddress( 'h9')
749
kelvin-onlabb769f562015-07-15 17:05:10 -0700750 ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
kelvin-onlab79ce0492015-07-27 16:14:39 -0700751 # Uneccessary, not including this in the selectors
kelvin-onlabb769f562015-07-15 17:05:10 -0700752 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
753 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
754
755 stepResult = main.intentFunction.pointIntent(
756 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700757 name="SDNIP-ICMP",
kelvin-onlabb769f562015-07-15 17:05:10 -0700758 host1="h1",
759 host2="h9",
760 deviceId1="of:0000000000000005/1",
761 deviceId2="of:0000000000000006/1",
762 mac1=mac1,
763 mac2=mac2,
764 ethType="IPV4",
765 ipProto=ipProto,
766 ip1=ip1,
kelvin-onlab79ce0492015-07-27 16:14:39 -0700767 ip2=ip2 )
kelvin-onlabb769f562015-07-15 17:05:10 -0700768
769 utilities.assert_equals( expect=main.TRUE,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700770 actual=stepResult,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700771 onpass="SDNIP-ICMP: Point intent test " +
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700772 "successful using IPV4 type with " +
773 "IP protocol TCP enabled",
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700774 onfail="SDNIP-ICMP: Point intent test " +
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700775 "failed using IPV4 type with " +
776 "IP protocol TCP enabled" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700777
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700778 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700779 stepResult = main.TRUE
780 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
781 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab58dc39e2015-08-06 08:11:09 -0700782 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
783 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlabb769f562015-07-15 17:05:10 -0700784 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
785 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
786 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
787
kelvin-onlab58dc39e2015-08-06 08:11:09 -0700788 stepResult = main.intentFunction.pointIntentTcp(
kelvin-onlabb769f562015-07-15 17:05:10 -0700789 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700790 name="SDNIP-TCP",
kelvin-onlabb769f562015-07-15 17:05:10 -0700791 host1="h1",
792 host2="h9",
793 deviceId1="of:0000000000000005/1",
794 deviceId2="of:0000000000000006/1",
795 mac1=mac1,
796 mac2=mac2,
797 ethType="IPV4",
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700798 ipProto=ipProto,
799 ip1=ip1,
800 ip2=ip2,
801 tcp1=tcp1,
802 tcp2=tcp2 )
kelvin-onlabb769f562015-07-15 17:05:10 -0700803
804 utilities.assert_equals( expect=main.TRUE,
805 actual=stepResult,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700806 onpass="SDNIP-TCP: Point intent test " +
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700807 "successful using IPV4 type with " +
808 "IP protocol ICMP enabled",
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700809 onfail="SDNIP-TCP: Point intent test " +
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700810 "failed using IPV4 type with " +
811 "IP protocol ICMP enabled" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700812
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700813 main.step( "DUALSTACK1: Add point intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700814 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700815 stepResult = main.intentFunction.pointIntent(
816 main,
817 name="DUALSTACK1",
818 host1="h3",
819 host2="h11",
820 deviceId1="of:0000000000000005",
821 deviceId2="of:0000000000000006",
822 port1="3",
823 port2="3",
824 ethType="IPV4",
825 mac1="00:00:00:00:00:03",
826 mac2="00:00:00:00:00:0B",
827 bandwidth="",
828 lambdaAlloc=False,
829 ipProto="",
830 ip1="",
831 ip2="",
832 tcp1="",
833 tcp2="",
834 sw1="s5",
835 sw2="s2",
836 expectedLink=18 )
837
838 utilities.assert_equals( expect=main.TRUE,
839 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700840 onpass="DUALSTACK1: Point intent test " +
841 "successful using IPV4 type with " +
842 "MAC addresses",
843 onfail="DUALSTACK1: Point intent test " +
844 "failed using IPV4 type with " +
845 "MAC addresses" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700846
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700847 main.step( "VLAN: Add point intents between h5 and h21" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700848 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700849 stepResult = main.intentFunction.pointIntent(
850 main,
851 name="VLAN",
852 host1="h5",
853 host2="h21",
854 deviceId1="of:0000000000000005/5",
855 deviceId2="of:0000000000000007/5",
856 port1="",
857 port2="",
858 ethType="IPV4",
859 mac1="00:00:00:00:00:05",
860 mac2="00:00:00:00:00:15",
861 bandwidth="",
862 lambdaAlloc=False,
863 ipProto="",
864 ip1="",
865 ip2="",
866 tcp1="",
867 tcp2="",
868 sw1="s5",
869 sw2="s2",
870 expectedLink=18 )
871
872 utilities.assert_equals( expect=main.TRUE,
873 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700874 onpass="VLAN1: Point intent test " +
875 "successful using IPV4 type with " +
876 "MAC addresses",
877 onfail="VLAN1: Point intent test " +
878 "failed using IPV4 type with " +
879 "MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700880
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700881 main.step( "1HOP: Add point intents between h1 and h3" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700882 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700883 stepResult = main.intentFunction.hostIntent( main,
884 name='1HOP',
885 host1='h1',
886 host2='h3' )
887
888 utilities.assert_equals( expect=main.TRUE,
889 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700890 onpass="1HOP: Point intent test " +
891 "successful using IPV4 type with " +
892 "no MAC addresses",
893 onfail="1HOP: Point intent test " +
894 "failed using IPV4 type with " +
895 "no MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700896
kelvin-onlab016dce22015-08-10 09:54:11 -0700897 main.intentFunction.report( main )
898
kelvin-onlabb769f562015-07-15 17:05:10 -0700899 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700900 """
901 Add single point to multi point intents
902 - Get device ids
903 - Add single point to multi point intents
904 - Check intents
905 - Verify flows
906 - Ping hosts
907 - Reroute
908 - Link down
909 - Verify flows
910 - Check topology
911 - Ping hosts
912 - Link up
913 - Verify flows
914 - Check topology
915 - Ping hosts
916 - Remove intents
917 """
918 assert main, "There is no main"
919 assert main.CLIs, "There is no main.CLIs"
920 assert main.Mininet1, "Mininet handle should be named Mininet1"
921 assert main.numSwitch, "Placed the total number of switch topology in \
922 main.numSwitch"
923
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700924 main.testName = "Single to Multi Point Intents"
925 main.case( main.testName + " Test - " + str( main.numCtrls ) +
926 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700927 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700928 " multi point intents using " +\
929 str( main.numCtrls ) + " node(s) cluster;\n" +\
930 "Different type of hosts will be tested in " +\
931 "each step such as IPV4, Dual stack, VLAN etc" +\
932 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700933 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700934
kelvin-onlabb769f562015-07-15 17:05:10 -0700935 main.step( "NOOPTION: Add single point to multi point intents" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700936 stepResult = main.TRUE
937 hostNames = [ 'h8', 'h16', 'h24' ]
938 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
939 'of:0000000000000007/8' ]
940 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700941 stepResult = main.intentFunction.singleToMultiIntent(
942 main,
943 name="NOOPTION",
944 hostNames=hostNames,
945 devices=devices,
946 sw1="s5",
947 sw2="s2",
948 expectedLink=18 )
949
950 utilities.assert_equals( expect=main.TRUE,
951 actual=stepResult,
952 onpass="NOOPTION: Successfully added single "
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700953 + " point to multi point intents" +
954 " with no match action",
955 onfail="NOOPTION: Failed to add single point"
956 + " point to multi point intents" +
957 " with no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700958
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700959 main.step( "IPV4: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700960 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700961 stepResult = main.intentFunction.singleToMultiIntent(
962 main,
963 name="IPV4",
964 hostNames=hostNames,
965 devices=devices,
966 ports=None,
967 ethType="IPV4",
968 macs=macs,
969 bandwidth="",
970 lambdaAlloc=False,
971 ipProto="",
972 ipAddresses="",
973 tcp="",
974 sw1="s5",
975 sw2="s2",
976 expectedLink=18 )
977
978 utilities.assert_equals( expect=main.TRUE,
979 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700980 onpass="IPV4: Successfully added single "
981 + " point to multi point intents" +
982 " with IPV4 type and MAC addresses",
983 onfail="IPV4: Failed to add single point"
984 + " point to multi point intents" +
985 " with IPV4 type and MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700986
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700987 main.step( "IPV4_2: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700988 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700989 hostNames = [ 'h8', 'h16', 'h24' ]
990 stepResult = main.intentFunction.singleToMultiIntent(
991 main,
992 name="IPV4",
993 hostNames=hostNames,
994 ethType="IPV4",
995 lambdaAlloc=False )
996
997 utilities.assert_equals( expect=main.TRUE,
998 actual=stepResult,
999 onpass="IPV4_2: Successfully added single "
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001000 + " point to multi point intents" +
1001 " with IPV4 type and no MAC addresses",
1002 onfail="IPV4_2: Failed to add single point"
1003 + " point to multi point intents" +
1004 " with IPV4 type and no MAC addresses" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001005
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001006 main.step( "VLAN: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001007 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001008 hostNames = [ 'h4', 'h12', 'h20' ]
1009 devices = [ 'of:0000000000000005/4', 'of:0000000000000006/4', \
1010 'of:0000000000000007/4' ]
1011 macs = [ '00:00:00:00:00:04', '00:00:00:00:00:0C', '00:00:00:00:00:14' ]
1012 stepResult = main.intentFunction.singleToMultiIntent(
1013 main,
1014 name="VLAN",
1015 hostNames=hostNames,
1016 devices=devices,
1017 ports=None,
1018 ethType="IPV4",
1019 macs=macs,
1020 bandwidth="",
1021 lambdaAlloc=False,
1022 ipProto="",
1023 ipAddresses="",
1024 tcp="",
1025 sw1="s5",
1026 sw2="s2",
1027 expectedLink=18 )
1028
1029 utilities.assert_equals( expect=main.TRUE,
1030 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001031 onpass="VLAN: Successfully added single "
1032 + " point to multi point intents" +
1033 " with IPV4 type and MAC addresses" +
1034 " in the same VLAN",
1035 onfail="VLAN: Failed to add single point"
1036 + " point to multi point intents" +
1037 " with IPV4 type and MAC addresses" +
1038 " in the same VLAN")
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001039
kelvin-onlab016dce22015-08-10 09:54:11 -07001040 main.intentFunction.report( main )
1041
kelvin-onlabb769f562015-07-15 17:05:10 -07001042 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001043 """
1044 Add multi point to single point intents
1045 - Get device ids
1046 - Add multi point to single point intents
1047 - Check intents
1048 - Verify flows
1049 - Ping hosts
1050 - Reroute
1051 - Link down
1052 - Verify flows
1053 - Check topology
1054 - Ping hosts
1055 - Link up
1056 - Verify flows
1057 - Check topology
1058 - Ping hosts
1059 - Remove intents
1060 """
1061 assert main, "There is no main"
1062 assert main.CLIs, "There is no main.CLIs"
1063 assert main.Mininet1, "Mininet handle should be named Mininet1"
1064 assert main.numSwitch, "Placed the total number of switch topology in \
1065 main.numSwitch"
1066
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001067 main.testName = "Multi To Single Point Intents"
1068 main.case( main.testName + " Test - " + str( main.numCtrls ) +
1069 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -07001070 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001071 " multi point intents using " +\
1072 str( main.numCtrls ) + " node(s) cluster;\n" +\
1073 "Different type of hosts will be tested in " +\
1074 "each step such as IPV4, Dual stack, VLAN etc" +\
1075 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -07001076 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001077
kelvin-onlabb769f562015-07-15 17:05:10 -07001078 main.step( "NOOPTION: Add multi point to single point intents" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001079 stepResult = main.TRUE
1080 hostNames = [ 'h8', 'h16', 'h24' ]
1081 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
1082 'of:0000000000000007/8' ]
1083 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001084 stepResult = main.intentFunction.multiToSingleIntent(
1085 main,
1086 name="NOOPTION",
1087 hostNames=hostNames,
1088 devices=devices,
1089 sw1="s5",
1090 sw2="s2",
1091 expectedLink=18 )
1092
1093 utilities.assert_equals( expect=main.TRUE,
1094 actual=stepResult,
1095 onpass="NOOPTION: Successfully added multi "
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001096 + " point to single point intents" +
1097 " with no match action",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001098 onfail="NOOPTION: Failed to add multi point" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001099 " to single point intents" +
1100 " with no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001101
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001102 main.step( "IPV4: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001103 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001104 stepResult = main.intentFunction.multiToSingleIntent(
1105 main,
1106 name="IPV4",
1107 hostNames=hostNames,
1108 devices=devices,
1109 ports=None,
1110 ethType="IPV4",
1111 macs=macs,
1112 bandwidth="",
1113 lambdaAlloc=False,
1114 ipProto="",
1115 ipAddresses="",
1116 tcp="",
1117 sw1="s5",
1118 sw2="s2",
1119 expectedLink=18 )
1120
1121 utilities.assert_equals( expect=main.TRUE,
1122 actual=stepResult,
1123 onpass="IPV4: Successfully added multi point"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001124 + " to single point intents" +
1125 " with IPV4 type and MAC addresses",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001126 onfail="IPV4: Failed to add multi point" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001127 " to single point intents" +
1128 " with IPV4 type and MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001129
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001130 main.step( "IPV4_2: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001131 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001132 hostNames = [ 'h8', 'h16', 'h24' ]
1133 stepResult = main.intentFunction.multiToSingleIntent(
1134 main,
1135 name="IPV4",
1136 hostNames=hostNames,
1137 ethType="IPV4",
1138 lambdaAlloc=False )
1139
1140 utilities.assert_equals( expect=main.TRUE,
1141 actual=stepResult,
1142 onpass="IPV4_2: Successfully added multi point"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001143 + " to single point intents" +
1144 " with IPV4 type and no MAC addresses",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001145 onfail="IPV4_2: Failed to add multi point" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001146 " to single point intents" +
1147 " with IPV4 type and no MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001148
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001149 main.step( "VLAN: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001150 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001151 hostNames = [ 'h5', 'h13', 'h21' ]
1152 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \
1153 'of:0000000000000007/5' ]
1154 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
1155 stepResult = main.intentFunction.multiToSingleIntent(
1156 main,
1157 name="VLAN",
1158 hostNames=hostNames,
1159 devices=devices,
1160 ports=None,
1161 ethType="IPV4",
1162 macs=macs,
1163 bandwidth="",
1164 lambdaAlloc=False,
1165 ipProto="",
1166 ipAddresses="",
1167 tcp="",
1168 sw1="s5",
1169 sw2="s2",
1170 expectedLink=18 )
1171
1172 utilities.assert_equals( expect=main.TRUE,
1173 actual=stepResult,
1174 onpass="VLAN: Successfully added multi point"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001175 + " to single point intents" +
1176 " with IPV4 type and MAC addresses" +
1177 " in the same VLAN",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001178 onfail="VLAN: Failed to add multi point" +
1179 " to single point intents" )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001180
acsmars1ff5e052015-07-23 11:27:48 -07001181 def CASE5000( self, main ):
1182 """
1183 Will add description in next patch set
acsmars1ff5e052015-07-23 11:27:48 -07001184 """
1185 assert main, "There is no main"
1186 assert main.CLIs, "There is no main.CLIs"
1187 assert main.Mininet1, "Mininet handle should be named Mininet1"
1188 assert main.numSwitch, "Placed the total number of switch topology in \
1189 main.numSwitch"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001190 main.case( "Test host mobility with host intents " )
1191 main.step( " Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07001192 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1193
1194 main.log.info( "Moving h1 from s5 to s6")
1195
1196 main.Mininet1.moveHost( "h1","s5","s6" )
1197
1198 main.intentFunction.getHostsData( main )
1199 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1200
1201 utilities.assert_equals( expect="of:0000000000000006",
1202 actual=h1PostMove,
1203 onpass="Mobility: Successfully moved h1 to s6",
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001204 onfail="Mobility: Failed to moved h1 to s6" +
1205 " to single point intents" +
1206 " with IPV4 type and MAC addresses" +
1207 " in the same VLAN" )
1208
1209 main.step( "IPV4: Add host intents between h1 and h9" )
1210 stepResult = main.TRUE
1211 stepResult = main.intentFunction.hostIntent( main,
1212 onosNode='0',
1213 name='IPV4',
1214 host1='h1',
1215 host2='h9',
1216 host1Id='00:00:00:00:00:01/-1',
1217 host2Id='00:00:00:00:00:09/-1' )
1218
1219 utilities.assert_equals( expect=main.TRUE,
1220 actual=stepResult,
1221 onpass="IPV4: Host intent test successful " +
1222 "between two IPV4 hosts",
1223 onfail="IPV4: Host intent test failed " +
1224 "between two IPV4 hosts")
kelvin-onlab016dce22015-08-10 09:54:11 -07001225
1226 main.intentFunction.report( main )