blob: 627275b590a9da2d2fe092bf89f10b50ea7c0577 [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' ] )
acsmars59a4c552015-09-10 18:11:19 -070051 main.checkTopoAttempts = int( main.params[ 'SLEEP' ][ 'topoAttempts' ] )
Jon Halla3e02432015-07-24 15:55:42 -070052 gitPull = main.params[ 'GIT' ][ 'pull' ]
53 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
54 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
55 main.cellData = {} # for creating cell file
56 main.hostsData = {}
57 main.CLIs = []
58 main.ONOSip = []
kelvin-onlabd48a68c2015-07-13 16:01:36 -070059
Jon Halla3e02432015-07-24 15:55:42 -070060 main.ONOSip = main.ONOSbench.getOnosIps()
61 print main.ONOSip
kelvin-onlabd48a68c2015-07-13 16:01:36 -070062
Jon Halla3e02432015-07-24 15:55:42 -070063 # Assigning ONOS cli handles to a list
64 for i in range( 1, main.maxNodes + 1 ):
65 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070066
Jon Halla3e02432015-07-24 15:55:42 -070067 # -- INIT SECTION, ONLY RUNS ONCE -- #
68 main.startUp = imp.load_source( wrapperFile1,
69 main.dependencyPath +
70 wrapperFile1 +
71 ".py" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070072
Jon Halla3e02432015-07-24 15:55:42 -070073 main.intentFunction = imp.load_source( wrapperFile2,
74 main.dependencyPath +
75 wrapperFile2 +
76 ".py" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070077
Jon Halla3e02432015-07-24 15:55:42 -070078 main.topo = imp.load_source( wrapperFile3,
79 main.dependencyPath +
80 wrapperFile3 +
81 ".py" )
82
kelvin-onlabd9e23de2015-08-06 10:34:44 -070083 copyResult1 = main.ONOSbench.scp( main.Mininet1,
84 main.dependencyPath +
85 main.topology,
86 main.Mininet1.home,
87 direction="to" )
Jon Halla3e02432015-07-24 15:55:42 -070088 if main.CLIs:
89 stepResult = main.TRUE
90 else:
91 main.log.error( "Did not properly created list of ONOS CLI handle" )
92 stepResult = main.FALSE
93 except Exception as e:
94 main.log.exception(e)
95 main.cleanup()
96 main.exit()
kelvin-onlabd48a68c2015-07-13 16:01:36 -070097
98 utilities.assert_equals( expect=main.TRUE,
99 actual=stepResult,
100 onpass="Successfully construct " +
101 "test variables ",
102 onfail="Failed to construct test variables" )
103
104 if gitPull == 'True':
105 main.step( "Building ONOS in " + gitBranch + " branch" )
106 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
107 stepResult = onosBuildResult
108 utilities.assert_equals( expect=main.TRUE,
109 actual=stepResult,
110 onpass="Successfully compiled " +
111 "latest ONOS",
112 onfail="Failed to compile " +
113 "latest ONOS" )
114 else:
115 main.log.warn( "Did not pull new code so skipping mvn " +
116 "clean install" )
Jon Hall106be082015-07-22 09:53:00 -0700117 main.ONOSbench.getVersion( report=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700118
119 def CASE2( self, main ):
120 """
121 - Set up cell
122 - Create cell file
123 - Set cell file
124 - Verify cell file
125 - Kill ONOS process
126 - Uninstall ONOS cluster
127 - Verify ONOS start up
128 - Install ONOS cluster
129 - Connect to cli
130 """
131
132 # main.scale[ 0 ] determines the current number of ONOS controller
133 main.numCtrls = int( main.scale[ 0 ] )
134
135 main.case( "Starting up " + str( main.numCtrls ) +
136 " node(s) ONOS cluster" )
Jon Hall783bbf92015-07-23 14:33:19 -0700137 main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700138 " node(s) ONOS cluster"
139
140
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700141
142 #kill off all onos processes
143 main.log.info( "Safety check, killing all ONOS processes" +
144 " before initiating enviornment setup" )
145
146 for i in range( main.maxNodes ):
147 main.ONOSbench.onosDie( main.ONOSip[ i ] )
148
149 print "NODE COUNT = ", main.numCtrls
150
151 tempOnosIp = []
152 for i in range( main.numCtrls ):
153 tempOnosIp.append( main.ONOSip[i] )
154
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700155 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
156 "temp", main.Mininet1.ip_address,
157 main.apps, tempOnosIp )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700158
159 main.step( "Apply cell to environment" )
160 cellResult = main.ONOSbench.setCell( "temp" )
161 verifyResult = main.ONOSbench.verifyCell()
162 stepResult = cellResult and verifyResult
163 utilities.assert_equals( expect=main.TRUE,
164 actual=stepResult,
165 onpass="Successfully applied cell to " + \
166 "environment",
167 onfail="Failed to apply cell to environment " )
168
169 main.step( "Creating ONOS package" )
170 packageResult = main.ONOSbench.onosPackage()
171 stepResult = packageResult
172 utilities.assert_equals( expect=main.TRUE,
173 actual=stepResult,
174 onpass="Successfully created ONOS package",
175 onfail="Failed to create ONOS package" )
176
177 time.sleep( main.startUpSleep )
178 main.step( "Uninstalling ONOS package" )
179 onosUninstallResult = main.TRUE
kelvin-onlab5f0d19e2015-08-04 15:21:00 -0700180 for ip in main.ONOSip:
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700181 onosUninstallResult = onosUninstallResult and \
kelvin-onlab5f0d19e2015-08-04 15:21:00 -0700182 main.ONOSbench.onosUninstall( nodeIp=ip )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700183 stepResult = onosUninstallResult
184 utilities.assert_equals( expect=main.TRUE,
185 actual=stepResult,
186 onpass="Successfully uninstalled ONOS package",
187 onfail="Failed to uninstall ONOS package" )
188
189 time.sleep( main.startUpSleep )
190 main.step( "Installing ONOS package" )
191 onosInstallResult = main.TRUE
192 for i in range( main.numCtrls ):
193 onosInstallResult = onosInstallResult and \
194 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
195 stepResult = onosInstallResult
196 utilities.assert_equals( expect=main.TRUE,
197 actual=stepResult,
198 onpass="Successfully installed ONOS package",
199 onfail="Failed to install ONOS package" )
200
201 time.sleep( main.startUpSleep )
202 main.step( "Starting ONOS service" )
203 stopResult = main.TRUE
204 startResult = main.TRUE
205 onosIsUp = main.TRUE
206
207 for i in range( main.numCtrls ):
208 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
209 if onosIsUp == main.TRUE:
210 main.log.report( "ONOS instance is up and ready" )
211 else:
212 main.log.report( "ONOS instance may not be up, stop and " +
213 "start ONOS again " )
214 for i in range( main.numCtrls ):
215 stopResult = stopResult and \
216 main.ONOSbench.onosStop( main.ONOSip[ i ] )
217 for i in range( main.numCtrls ):
218 startResult = startResult and \
219 main.ONOSbench.onosStart( main.ONOSip[ i ] )
220 stepResult = onosIsUp and stopResult and startResult
221 utilities.assert_equals( expect=main.TRUE,
222 actual=stepResult,
223 onpass="ONOS service is ready",
224 onfail="ONOS service did not start properly" )
225
226 main.step( "Start ONOS cli" )
227 cliResult = main.TRUE
228 for i in range( main.numCtrls ):
229 cliResult = cliResult and \
230 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
231 stepResult = cliResult
232 utilities.assert_equals( expect=main.TRUE,
233 actual=stepResult,
234 onpass="Successfully start ONOS cli",
235 onfail="Failed to start ONOS cli" )
236
237 # Remove the first element in main.scale list
238 main.scale.remove( main.scale[ 0 ] )
239
kelvin-onlab016dce22015-08-10 09:54:11 -0700240 main.intentFunction.report( main )
241
Jon Halla3e02432015-07-24 15:55:42 -0700242 def CASE8( self, main ):
243 """
acsmars59a4c552015-09-10 18:11:19 -0700244 Compare ONOS Topology to Mininet Topology
Jon Halla3e02432015-07-24 15:55:42 -0700245 """
246 import json
247
248 main.case( "Compare ONOS Topology view to Mininet topology" )
249 main.caseExplanation = "Compare topology elements between Mininet" +\
250 " and ONOS"
251
acsmars59a4c552015-09-10 18:11:19 -0700252 main.log.info( "Gathering topology information from Mininet" )
253 devicesResults = main.FALSE # Overall Boolean for device correctness
254 linksResults = main.FALSE # Overall Boolean for link correctness
255 hostsResults = main.FALSE # Overall Boolean for host correctness
256 deviceFails = [] # Nodes where devices are incorrect
257 linkFails = [] # Nodes where links are incorrect
258 hostFails = [] # Nodes where hosts are incorrect
259 attempts = main.checkTopoAttempts # Remaining Attempts
Jon Halla3e02432015-07-24 15:55:42 -0700260
261 mnSwitches = main.Mininet1.getSwitches()
262 mnLinks = main.Mininet1.getLinks()
263 mnHosts = main.Mininet1.getHosts()
264
acsmars59a4c552015-09-10 18:11:19 -0700265 main.step( "Conmparing Mininet topology to ONOS topology" )
Jon Halla3e02432015-07-24 15:55:42 -0700266
acsmars59a4c552015-09-10 18:11:19 -0700267 while ( attempts >= 0 ) and\
268 ( not devicesResults or not linksResults or not hostsResults ):
269 time.sleep( 2 )
270 if not devicesResults:
271 devices = main.topo.getAllDevices( main )
272 ports = main.topo.getAllPorts( main )
273 devicesResults = main.TRUE
274 deviceFails = [] # Reset for each attempt
275 if not linksResults:
276 links = main.topo.getAllLinks( main )
277 linksResults = main.TRUE
278 linkFails = [] # Reset for each attempt
279 if not hostsResults:
280 hosts = main.topo.getAllHosts( main )
281 hostsResults = main.TRUE
282 hostFails = [] # Reset for each attempt
Jon Halla3e02432015-07-24 15:55:42 -0700283
acsmars59a4c552015-09-10 18:11:19 -0700284 # Check for matching topology on each node
285 for controller in range( main.numCtrls ):
286 controllerStr = str( controller + 1 ) # ONOS node number
287 # Compare Devices
288 if devices[ controller ] and ports[ controller ] and\
289 "Error" not in devices[ controller ] and\
290 "Error" not in ports[ controller ]:
Jon Halla3e02432015-07-24 15:55:42 -0700291
acsmars59a4c552015-09-10 18:11:19 -0700292 currentDevicesResult = main.Mininet1.compareSwitches(
293 mnSwitches,
294 json.loads( devices[ controller ] ),
295 json.loads( ports[ controller ] ) )
296 else:
297 currentDevicesResult = main.FALSE
298 if not currentDevicesResult:
299 deviceFails.append( controllerStr )
300 devicesResults = devicesResults and currentDevicesResult
301 # Compare Links
302 if links[ controller ] and "Error" not in links[ controller ]:
303 currentLinksResult = main.Mininet1.compareLinks(
304 mnSwitches, mnLinks,
305 json.loads( links[ controller ] ) )
306 else:
307 currentLinksResult = main.FALSE
308 if not currentLinksResult:
309 linkFails.append( controllerStr )
310 linksResults = linksResults and currentLinksResult
311 # Compare Hosts
312 if hosts[ controller ] or "Error" not in hosts[ controller ]:
313 currentHostsResult = main.Mininet1.compareHosts(
314 mnHosts,
315 json.loads( hosts[ controller ] ) )
316 else:
317 currentHostsResult = main.FALSE
318 if not currentHostsResult:
319 hostFails.append( controllerStr )
320 hostsResults = hostsResults and currentHostsResult
321 # Decrement Attempts Remaining
322 attempts -= 1
323
324
325 utilities.assert_equals( expect=[],
326 actual=deviceFails,
327 onpass="ONOS correctly discovered all devices",
328 onfail="ONOS incorrectly discovered devices on nodes: " +
329 str( deviceFails ) )
330 utilities.assert_equals( expect=[],
331 actual=linkFails,
332 onpass="ONOS correctly discovered all links",
333 onfail="ONOS incorrectly discovered links on nodes: " +
334 str( linkFails ) )
335 utilities.assert_equals( expect=[],
336 actual=hostFails,
337 onpass="ONOS correctly discovered all hosts",
338 onfail="ONOS incorrectly discovered hosts on nodes: " +
339 str( hostFails ) )
Jon Hall46d48252015-08-03 11:41:16 -0700340 topoResults = hostsResults and linksResults and devicesResults
341 utilities.assert_equals( expect=main.TRUE,
342 actual=topoResults,
343 onpass="ONOS correctly discovered the topology",
344 onfail="ONOS incorrectly discovered the topology" )
Jon Halla3e02432015-07-24 15:55:42 -0700345
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700346 def CASE10( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700347 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700348 Start Mininet topology with OF 1.0 switches
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700349 """
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700350 main.OFProtocol = "1.0"
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700351 main.log.report( "Start Mininet topology with OF 1.0 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700352 main.case( "Start Mininet topology with OF 1.0 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700353 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700354 "switches to test intents, exits out if " +\
355 "topology did not start correctly"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700356
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700357 main.step( "Starting Mininet topology with OF 1.0 switches" )
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700358 args = "--switch ovs,protocols=OpenFlow10"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700359 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700360 main.topology,
361 args=args )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700362 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-onlabb5cfab32015-07-22 16:38:22 -0700372 def CASE11( self, main ):
373 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700374 Start Mininet topology with OF 1.3 switches
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700375 """
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700376 main.OFProtocol = "1.3"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700377 main.log.report( "Start Mininet topology with OF 1.3 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700378 main.case( "Start Mininet topology with OF 1.3 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700379 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700380 "switches to test intents, exits out if " +\
381 "topology did not start correctly"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700382
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700383 main.step( "Starting Mininet topology with OF 1.3 switches" )
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700384 args = "--switch ovs,protocols=OpenFlow13"
385 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
386 main.topology,
387 args=args )
388 stepResult = topoResult
389 utilities.assert_equals( expect=main.TRUE,
390 actual=stepResult,
391 onpass="Successfully loaded topology",
392 onfail="Failed to load topology" )
393 # Exit if topology did not load properly
394 if not topoResult:
395 main.cleanup()
396 main.exit()
397
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700398 def CASE12( self, main ):
399 """
400 Assign mastership to controllers
401 """
402 import re
403
404 main.case( "Assign switches to controllers" )
405 main.step( "Assigning switches to controllers" )
Jon Hall783bbf92015-07-23 14:33:19 -0700406 main.caseExplanation = "Assign OF " + main.OFProtocol +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700407 " switches to ONOS nodes"
408
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700409 assignResult = main.TRUE
410 switchList = []
411
412 # Creates a list switch name, use getSwitch() function later...
413 for i in range( 1, ( main.numSwitch + 1 ) ):
414 switchList.append( 's' + str( i ) )
415
416 tempONOSip = []
417 for i in range( main.numCtrls ):
418 tempONOSip.append( main.ONOSip[ i ] )
419
420 assignResult = main.Mininet1.assignSwController( sw=switchList,
421 ip=tempONOSip,
422 port='6633' )
423 if not assignResult:
424 main.cleanup()
425 main.exit()
426
427 for i in range( 1, ( main.numSwitch + 1 ) ):
428 response = main.Mininet1.getSwController( "s" + str( i ) )
429 print( "Response is " + str( response ) )
430 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
431 assignResult = assignResult and main.TRUE
432 else:
433 assignResult = main.FALSE
434 stepResult = assignResult
435 utilities.assert_equals( expect=main.TRUE,
436 actual=stepResult,
437 onpass="Successfully assigned switches" +
438 "to controller",
439 onfail="Failed to assign switches to " +
440 "controller" )
441 def CASE13( self, main ):
442 """
443 Discover all hosts and store its data to a dictionary
444 """
445 main.case( "Discover all hosts" )
446
447 stepResult = main.TRUE
448 main.step( "Discover all hosts using pingall " )
449 stepResult = main.intentFunction.getHostsData( main )
450 utilities.assert_equals( expect=main.TRUE,
451 actual=stepResult,
452 onpass="Successfully discovered hosts",
453 onfail="Failed to discover hosts" )
454
455 def CASE14( self, main ):
456 """
457 Stop mininet
458 """
459 main.log.report( "Stop Mininet topology" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700460 main.case( "Stop Mininet topology" )
Jon Hall783bbf92015-07-23 14:33:19 -0700461 main.caseExplanation = "Stopping the current mininet topology " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700462 "to start up fresh"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700463
464 main.step( "Stopping Mininet Topology" )
465 topoResult = main.Mininet1.stopNet( )
466 stepResult = topoResult
467 utilities.assert_equals( expect=main.TRUE,
468 actual=stepResult,
469 onpass="Successfully stop mininet",
470 onfail="Failed to stop mininet" )
471 # Exit if topology did not load properly
472 if not topoResult:
473 main.cleanup()
474 main.exit()
475
kelvin-onlabb769f562015-07-15 17:05:10 -0700476 def CASE1000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700477 """
478 Add host intents between 2 host:
479 - Discover hosts
480 - Add host intents
481 - Check intents
482 - Verify flows
483 - Ping hosts
484 - Reroute
485 - Link down
486 - Verify flows
487 - Check topology
488 - Ping hosts
489 - Link up
490 - Verify flows
491 - Check topology
492 - Ping hosts
493 - Remove intents
494 """
495 import time
496 import json
497 import re
498
499 # Assert variables - These variable's name|format must be followed
500 # if you want to use the wrapper function
501 assert main, "There is no main"
502 assert main.CLIs, "There is no main.CLIs"
503 assert main.Mininet1, "Mininet handle should be named Mininet1"
504 assert main.numSwitch, "Placed the total number of switch topology in \
505 main.numSwitch"
506
acsmarse6b410f2015-07-17 14:39:34 -0700507 intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
508
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700509 main.testName = "Host Intents"
510 main.case( main.testName + " Test - " + str( main.numCtrls ) +
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700511 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700512 main.caseExplanation = "This test case tests Host intents using " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700513 str( main.numCtrls ) + " node(s) cluster;\n" +\
514 "Different type of hosts will be tested in " +\
515 "each step such as IPV4, Dual stack, VLAN " +\
516 "etc;\nThe test will use OF " + main.OFProtocol\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700517 + " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700518
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700519 main.step( "IPV4: Add host intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700520 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700521 stepResult = main.intentFunction.hostIntent( main,
522 onosNode='0',
523 name='IPV4',
524 host1='h1',
525 host2='h9',
526 host1Id='00:00:00:00:00:01/-1',
527 host2Id='00:00:00:00:00:09/-1',
528 sw1='s5',
529 sw2='s2',
530 expectedLink=18 )
531
532 utilities.assert_equals( expect=main.TRUE,
533 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700534 onpass="IPV4: Host intent test successful " +
535 "between two IPV4 hosts",
536 onfail="IPV4: Host intent test failed " +
537 "between two IPV4 hosts")
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700538
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700539 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700540 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700541 stepResult = main.intentFunction.hostIntent( main,
542 name='DUALSTACK',
543 host1='h3',
544 host2='h11',
545 host1Id='00:00:00:00:00:03/-1',
546 host2Id='00:00:00:00:00:0B/-1',
547 sw1='s5',
548 sw2='s2',
549 expectedLink=18 )
550
551 utilities.assert_equals( expect=main.TRUE,
552 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700553 onpass="DUALSTACK: Host intent test " +
554 "successful between two " +
555 "dual stack host using IPV4",
556 onfail="DUALSTACK: Host intent test " +
557 "failed between two" +
558 "dual stack host using IPV4" )
559
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700560
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700561 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700562 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700563 stepResult = main.intentFunction.hostIntent( main,
564 name='DUALSTACK2',
565 host1='h1',
566 host2='h11',
567 sw1='s5',
568 sw2='s2',
569 expectedLink=18 )
570
571 utilities.assert_equals( expect=main.TRUE,
572 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700573 onpass="DUALSTACK2: Host intent test " +
574 "successful between two " +
575 "dual stack host using IPV4",
576 onfail="DUALSTACK2: Host intent test " +
577 "failed between two" +
578 "dual stack host using IPV4" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700579
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700580 main.step( "1HOP: Add host intents between h1 and h3" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700581 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700582 stepResult = main.intentFunction.hostIntent( main,
583 name='1HOP',
584 host1='h1',
585 host2='h3' )
586
587 utilities.assert_equals( expect=main.TRUE,
588 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700589 onpass="1HOP: Host intent test " +
590 "successful between two " +
591 "host using IPV4 in the same switch",
592 onfail="1HOP: Host intent test " +
593 "failed between two" +
594 "host using IPV4 in the same switch" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700595
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700596 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700597 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700598 stepResult = main.intentFunction.hostIntent( main,
599 name='VLAN1',
600 host1='h4',
601 host2='h12',
602 host1Id='00:00:00:00:00:04/100',
603 host2Id='00:00:00:00:00:0C/100',
604 sw1='s5',
605 sw2='s2',
606 expectedLink=18 )
607
608 utilities.assert_equals( expect=main.TRUE,
609 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700610 onpass="VLAN1: Host intent test " +
611 "successful between two " +
612 "host using IPV4 in the same VLAN",
613 onfail="VLAN1: Host intent test " +
614 "failed between two" +
615 "host using IPV4 in the same VLAN" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700616
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700617 main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700618 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700619 stepResult = main.intentFunction.hostIntent( main,
620 name='VLAN2',
621 host1='h13',
622 host2='h20' )
623
624 utilities.assert_equals( expect=main.FALSE,
625 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700626 onpass="VLAN2: Host intent negative test " +
627 "successful between two " +
628 "host using IPV4 in different VLAN",
629 onfail="VLAN2: Host intent negative test " +
630 "failed between two" +
631 "host using IPV4 in different VLAN" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700632
acsmarse6b410f2015-07-17 14:39:34 -0700633
634 intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
635 main.intentFunction.checkLeaderChange( intentLeadersOld,
636 intentLeadersNew )
637
kelvin-onlab016dce22015-08-10 09:54:11 -0700638 main.intentFunction.report( main )
639
kelvin-onlabb769f562015-07-15 17:05:10 -0700640 def CASE2000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700641 """
642 Add point intents between 2 hosts:
643 - Get device ids | ports
644 - Add point intents
645 - Check intents
646 - Verify flows
647 - Ping hosts
648 - Reroute
649 - Link down
650 - Verify flows
651 - Check topology
652 - Ping hosts
653 - Link up
654 - Verify flows
655 - Check topology
656 - Ping hosts
657 - Remove intents
658 """
659 import time
660 import json
661 import re
662
663 # Assert variables - These variable's name|format must be followed
664 # if you want to use the wrapper function
665 assert main, "There is no main"
666 assert main.CLIs, "There is no main.CLIs"
667 assert main.Mininet1, "Mininet handle should be named Mininet1"
668 assert main.numSwitch, "Placed the total number of switch topology in \
669 main.numSwitch"
670
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700671 main.testName = "Point Intents"
672 main.case( main.testName + " Test - " + str( main.numCtrls ) +
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700673 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700674 main.caseExplanation = "This test case will test point to point" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700675 " intents using " + str( main.numCtrls ) +\
676 " node(s) cluster;\n" +\
677 "Different type of hosts will be tested in " +\
678 "each step such as IPV4, Dual stack, VLAN etc" +\
679 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700680 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700681
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700682 # No option point intents
683 main.step( "NOOPTION: Add point intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700684 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700685 stepResult = main.intentFunction.pointIntent(
686 main,
687 name="NOOPTION",
688 host1="h1",
689 host2="h9",
690 deviceId1="of:0000000000000005/1",
691 deviceId2="of:0000000000000006/1",
692 sw1="s5",
693 sw2="s2",
694 expectedLink=18 )
695
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700696 utilities.assert_equals( expect=main.TRUE,
697 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700698 onpass="NOOPTION: Point intent test " +
699 "successful using no match action",
700 onfail="NOOPTION: Point intent test " +
701 "failed using no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700702
703 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -0700704 main.step( "IPV4: Add point intents between h1 and h9" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700705 stepResult = main.intentFunction.pointIntent(
706 main,
707 name="IPV4",
708 host1="h1",
709 host2="h9",
710 deviceId1="of:0000000000000005/1",
711 deviceId2="of:0000000000000006/1",
712 port1="",
713 port2="",
714 ethType="IPV4",
715 mac1="00:00:00:00:00:01",
716 mac2="00:00:00:00:00:09",
717 bandwidth="",
718 lambdaAlloc=False,
719 ipProto="",
720 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: Point intent test " +
731 "successful using IPV4 type with " +
732 "MAC addresses",
733 onfail="IPV4: Point intent test " +
734 "failed using IPV4 type with " +
735 "MAC addresses" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700736 main.step( "IPV4_2: Add point intents between h1 and h9" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700737 stepResult = main.TRUE
738 stepResult = main.intentFunction.pointIntent(
739 main,
740 name="IPV4_2",
741 host1="h1",
742 host2="h9",
743 deviceId1="of:0000000000000005/1",
744 deviceId2="of:0000000000000006/1",
kelvin-onlabb769f562015-07-15 17:05:10 -0700745 ipProto="",
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700746 ip1="",
747 ip2="",
748 tcp1="",
749 tcp2="",
750 sw1="s5",
751 sw2="s2",
752 expectedLink=18 )
753
754 utilities.assert_equals( expect=main.TRUE,
755 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700756 onpass="IPV4_2: Point intent test " +
757 "successful using IPV4 type with " +
758 "no MAC addresses",
759 onfail="IPV4_2: Point intent test " +
760 "failed using IPV4 type with " +
761 "no MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700762
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700763 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700764 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -0700765 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
766 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab0ad05d12015-07-23 14:21:15 -0700767 try:
768 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/24"
769 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/24"
770 except KeyError:
771 main.log.debug( "Key Error getting IP addresses of h1 | h9 in" +
772 "main.hostsData" )
773 ip1 = main.Mininet1.getIPAddress( 'h1')
774 ip2 = main.Mininet1.getIPAddress( 'h9')
775
kelvin-onlabb769f562015-07-15 17:05:10 -0700776 ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
kelvin-onlab79ce0492015-07-27 16:14:39 -0700777 # Uneccessary, not including this in the selectors
kelvin-onlabb769f562015-07-15 17:05:10 -0700778 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
779 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
780
781 stepResult = main.intentFunction.pointIntent(
782 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700783 name="SDNIP-ICMP",
kelvin-onlabb769f562015-07-15 17:05:10 -0700784 host1="h1",
785 host2="h9",
786 deviceId1="of:0000000000000005/1",
787 deviceId2="of:0000000000000006/1",
788 mac1=mac1,
789 mac2=mac2,
790 ethType="IPV4",
791 ipProto=ipProto,
792 ip1=ip1,
kelvin-onlab79ce0492015-07-27 16:14:39 -0700793 ip2=ip2 )
kelvin-onlabb769f562015-07-15 17:05:10 -0700794
795 utilities.assert_equals( expect=main.TRUE,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700796 actual=stepResult,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700797 onpass="SDNIP-ICMP: Point intent test " +
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700798 "successful using IPV4 type with " +
799 "IP protocol TCP enabled",
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700800 onfail="SDNIP-ICMP: Point intent test " +
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700801 "failed using IPV4 type with " +
802 "IP protocol TCP enabled" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700803
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700804 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700805 stepResult = main.TRUE
806 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
807 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab58dc39e2015-08-06 08:11:09 -0700808 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
809 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlabb769f562015-07-15 17:05:10 -0700810 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
811 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
812 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
813
kelvin-onlab58dc39e2015-08-06 08:11:09 -0700814 stepResult = main.intentFunction.pointIntentTcp(
kelvin-onlabb769f562015-07-15 17:05:10 -0700815 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700816 name="SDNIP-TCP",
kelvin-onlabb769f562015-07-15 17:05:10 -0700817 host1="h1",
818 host2="h9",
819 deviceId1="of:0000000000000005/1",
820 deviceId2="of:0000000000000006/1",
821 mac1=mac1,
822 mac2=mac2,
823 ethType="IPV4",
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700824 ipProto=ipProto,
825 ip1=ip1,
826 ip2=ip2,
827 tcp1=tcp1,
828 tcp2=tcp2 )
kelvin-onlabb769f562015-07-15 17:05:10 -0700829
830 utilities.assert_equals( expect=main.TRUE,
831 actual=stepResult,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700832 onpass="SDNIP-TCP: Point intent test " +
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700833 "successful using IPV4 type with " +
834 "IP protocol ICMP enabled",
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700835 onfail="SDNIP-TCP: Point intent test " +
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700836 "failed using IPV4 type with " +
837 "IP protocol ICMP enabled" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700838
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700839 main.step( "DUALSTACK1: Add point intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700840 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700841 stepResult = main.intentFunction.pointIntent(
842 main,
843 name="DUALSTACK1",
844 host1="h3",
845 host2="h11",
846 deviceId1="of:0000000000000005",
847 deviceId2="of:0000000000000006",
848 port1="3",
849 port2="3",
850 ethType="IPV4",
851 mac1="00:00:00:00:00:03",
852 mac2="00:00:00:00:00:0B",
853 bandwidth="",
854 lambdaAlloc=False,
855 ipProto="",
856 ip1="",
857 ip2="",
858 tcp1="",
859 tcp2="",
860 sw1="s5",
861 sw2="s2",
862 expectedLink=18 )
863
864 utilities.assert_equals( expect=main.TRUE,
865 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700866 onpass="DUALSTACK1: Point intent test " +
867 "successful using IPV4 type with " +
868 "MAC addresses",
869 onfail="DUALSTACK1: Point intent test " +
870 "failed using IPV4 type with " +
871 "MAC addresses" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700872
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700873 main.step( "VLAN: Add point intents between h5 and h21" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700874 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700875 stepResult = main.intentFunction.pointIntent(
876 main,
877 name="VLAN",
878 host1="h5",
879 host2="h21",
880 deviceId1="of:0000000000000005/5",
881 deviceId2="of:0000000000000007/5",
882 port1="",
883 port2="",
884 ethType="IPV4",
885 mac1="00:00:00:00:00:05",
886 mac2="00:00:00:00:00:15",
887 bandwidth="",
888 lambdaAlloc=False,
889 ipProto="",
890 ip1="",
891 ip2="",
892 tcp1="",
893 tcp2="",
894 sw1="s5",
895 sw2="s2",
896 expectedLink=18 )
897
898 utilities.assert_equals( expect=main.TRUE,
899 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700900 onpass="VLAN1: Point intent test " +
901 "successful using IPV4 type with " +
902 "MAC addresses",
903 onfail="VLAN1: Point intent test " +
904 "failed using IPV4 type with " +
905 "MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700906
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700907 main.step( "1HOP: Add point intents between h1 and h3" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700908 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700909 stepResult = main.intentFunction.hostIntent( main,
910 name='1HOP',
911 host1='h1',
912 host2='h3' )
913
914 utilities.assert_equals( expect=main.TRUE,
915 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700916 onpass="1HOP: Point intent test " +
917 "successful using IPV4 type with " +
918 "no MAC addresses",
919 onfail="1HOP: Point intent test " +
920 "failed using IPV4 type with " +
921 "no MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700922
kelvin-onlab016dce22015-08-10 09:54:11 -0700923 main.intentFunction.report( main )
924
kelvin-onlabb769f562015-07-15 17:05:10 -0700925 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700926 """
927 Add single point to multi point intents
928 - Get device ids
929 - Add single point to multi point intents
930 - Check intents
931 - Verify flows
932 - Ping hosts
933 - Reroute
934 - Link down
935 - Verify flows
936 - Check topology
937 - Ping hosts
938 - Link up
939 - Verify flows
940 - Check topology
941 - Ping hosts
942 - Remove intents
943 """
944 assert main, "There is no main"
945 assert main.CLIs, "There is no main.CLIs"
946 assert main.Mininet1, "Mininet handle should be named Mininet1"
947 assert main.numSwitch, "Placed the total number of switch topology in \
948 main.numSwitch"
949
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700950 main.testName = "Single to Multi Point Intents"
951 main.case( main.testName + " Test - " + str( main.numCtrls ) +
952 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700953 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700954 " multi point intents using " +\
955 str( main.numCtrls ) + " node(s) cluster;\n" +\
956 "Different type of hosts will be tested in " +\
957 "each step such as IPV4, Dual stack, VLAN etc" +\
958 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700959 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700960
kelvin-onlabb769f562015-07-15 17:05:10 -0700961 main.step( "NOOPTION: Add single point to multi point intents" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700962 stepResult = main.TRUE
963 hostNames = [ 'h8', 'h16', 'h24' ]
964 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
965 'of:0000000000000007/8' ]
966 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 -0700967 stepResult = main.intentFunction.singleToMultiIntent(
968 main,
969 name="NOOPTION",
970 hostNames=hostNames,
971 devices=devices,
972 sw1="s5",
973 sw2="s2",
974 expectedLink=18 )
975
976 utilities.assert_equals( expect=main.TRUE,
977 actual=stepResult,
978 onpass="NOOPTION: Successfully added single "
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700979 + " point to multi point intents" +
980 " with no match action",
981 onfail="NOOPTION: Failed to add single point"
982 + " point to multi point intents" +
983 " with no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700984
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700985 main.step( "IPV4: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700986 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700987 stepResult = main.intentFunction.singleToMultiIntent(
988 main,
989 name="IPV4",
990 hostNames=hostNames,
991 devices=devices,
992 ports=None,
993 ethType="IPV4",
994 macs=macs,
995 bandwidth="",
996 lambdaAlloc=False,
997 ipProto="",
998 ipAddresses="",
999 tcp="",
1000 sw1="s5",
1001 sw2="s2",
1002 expectedLink=18 )
1003
1004 utilities.assert_equals( expect=main.TRUE,
1005 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001006 onpass="IPV4: Successfully added single "
1007 + " point to multi point intents" +
1008 " with IPV4 type and MAC addresses",
1009 onfail="IPV4: Failed to add single point"
1010 + " point to multi point intents" +
1011 " with IPV4 type and MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001012
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001013 main.step( "IPV4_2: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001014 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001015 hostNames = [ 'h8', 'h16', 'h24' ]
1016 stepResult = main.intentFunction.singleToMultiIntent(
1017 main,
1018 name="IPV4",
1019 hostNames=hostNames,
1020 ethType="IPV4",
1021 lambdaAlloc=False )
1022
1023 utilities.assert_equals( expect=main.TRUE,
1024 actual=stepResult,
1025 onpass="IPV4_2: Successfully added single "
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001026 + " point to multi point intents" +
1027 " with IPV4 type and no MAC addresses",
1028 onfail="IPV4_2: Failed to add single point"
1029 + " point to multi point intents" +
1030 " with IPV4 type and no MAC addresses" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001031
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001032 main.step( "VLAN: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001033 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001034 hostNames = [ 'h4', 'h12', 'h20' ]
1035 devices = [ 'of:0000000000000005/4', 'of:0000000000000006/4', \
1036 'of:0000000000000007/4' ]
1037 macs = [ '00:00:00:00:00:04', '00:00:00:00:00:0C', '00:00:00:00:00:14' ]
1038 stepResult = main.intentFunction.singleToMultiIntent(
1039 main,
1040 name="VLAN",
1041 hostNames=hostNames,
1042 devices=devices,
1043 ports=None,
1044 ethType="IPV4",
1045 macs=macs,
1046 bandwidth="",
1047 lambdaAlloc=False,
1048 ipProto="",
1049 ipAddresses="",
1050 tcp="",
1051 sw1="s5",
1052 sw2="s2",
1053 expectedLink=18 )
1054
1055 utilities.assert_equals( expect=main.TRUE,
1056 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001057 onpass="VLAN: Successfully added single "
1058 + " point to multi point intents" +
1059 " with IPV4 type and MAC addresses" +
1060 " in the same VLAN",
1061 onfail="VLAN: Failed to add single point"
1062 + " point to multi point intents" +
1063 " with IPV4 type and MAC addresses" +
1064 " in the same VLAN")
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001065
kelvin-onlab016dce22015-08-10 09:54:11 -07001066 main.intentFunction.report( main )
1067
kelvin-onlabb769f562015-07-15 17:05:10 -07001068 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001069 """
1070 Add multi point to single point intents
1071 - Get device ids
1072 - Add multi point to single point intents
1073 - Check intents
1074 - Verify flows
1075 - Ping hosts
1076 - Reroute
1077 - Link down
1078 - Verify flows
1079 - Check topology
1080 - Ping hosts
1081 - Link up
1082 - Verify flows
1083 - Check topology
1084 - Ping hosts
1085 - Remove intents
1086 """
1087 assert main, "There is no main"
1088 assert main.CLIs, "There is no main.CLIs"
1089 assert main.Mininet1, "Mininet handle should be named Mininet1"
1090 assert main.numSwitch, "Placed the total number of switch topology in \
1091 main.numSwitch"
1092
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001093 main.testName = "Multi To Single Point Intents"
1094 main.case( main.testName + " Test - " + str( main.numCtrls ) +
1095 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -07001096 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001097 " multi point intents using " +\
1098 str( main.numCtrls ) + " node(s) cluster;\n" +\
1099 "Different type of hosts will be tested in " +\
1100 "each step such as IPV4, Dual stack, VLAN etc" +\
1101 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -07001102 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001103
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001104 hostNames = [ 'h8', 'h16', 'h24' ]
1105 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
1106 'of:0000000000000007/8' ]
1107 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 -07001108
acsmars5b78fcd2015-09-02 15:01:59 -07001109 # This test as written attempts something that is impossible
1110 # Multi to Single Raw intent cannot be bi-directional, so pings are not usable to test it
1111 # This test should be re-written so that one multi-to-single NOOPTION
1112 # intent is installed, with listeners at the destinations, so that one way
1113 # packets can be detected
1114 #
1115 # main.step( "NOOPTION: Add multi point to single point intents" )
1116 # stepResult = main.TRUE
1117 # stepResult = main.intentFunction.multiToSingleIntent(
1118 # main,
1119 # name="NOOPTION",
1120 # hostNames=hostNames,
1121 # devices=devices,
1122 # sw1="s5",
1123 # sw2="s2",
1124 # expectedLink=18 )
1125 #
1126 # utilities.assert_equals( expect=main.TRUE,
1127 # actual=stepResult,
1128 # onpass="NOOPTION: Successfully added multi "
1129 # + " point to single point intents" +
1130 # " with no match action",
1131 # onfail="NOOPTION: Failed to add multi point" +
1132 # " to single point intents" +
1133 # " with no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001134
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001135 main.step( "IPV4: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001136 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001137 stepResult = main.intentFunction.multiToSingleIntent(
1138 main,
1139 name="IPV4",
1140 hostNames=hostNames,
1141 devices=devices,
1142 ports=None,
1143 ethType="IPV4",
1144 macs=macs,
1145 bandwidth="",
1146 lambdaAlloc=False,
1147 ipProto="",
1148 ipAddresses="",
1149 tcp="",
1150 sw1="s5",
1151 sw2="s2",
1152 expectedLink=18 )
1153
1154 utilities.assert_equals( expect=main.TRUE,
1155 actual=stepResult,
1156 onpass="IPV4: Successfully added multi point"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001157 + " to single point intents" +
1158 " with IPV4 type and MAC addresses",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001159 onfail="IPV4: Failed to add multi point" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001160 " to single point intents" +
1161 " with IPV4 type and MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001162
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001163 main.step( "IPV4_2: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001164 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001165 hostNames = [ 'h8', 'h16', 'h24' ]
1166 stepResult = main.intentFunction.multiToSingleIntent(
1167 main,
1168 name="IPV4",
1169 hostNames=hostNames,
1170 ethType="IPV4",
1171 lambdaAlloc=False )
1172
1173 utilities.assert_equals( expect=main.TRUE,
1174 actual=stepResult,
1175 onpass="IPV4_2: Successfully added multi point"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001176 + " to single point intents" +
1177 " with IPV4 type and no MAC addresses",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001178 onfail="IPV4_2: Failed to add multi point" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001179 " to single point intents" +
1180 " with IPV4 type and no MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001181
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001182 main.step( "VLAN: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001183 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001184 hostNames = [ 'h5', 'h13', 'h21' ]
1185 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \
1186 'of:0000000000000007/5' ]
1187 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
1188 stepResult = main.intentFunction.multiToSingleIntent(
1189 main,
1190 name="VLAN",
1191 hostNames=hostNames,
1192 devices=devices,
1193 ports=None,
1194 ethType="IPV4",
1195 macs=macs,
1196 bandwidth="",
1197 lambdaAlloc=False,
1198 ipProto="",
1199 ipAddresses="",
1200 tcp="",
1201 sw1="s5",
1202 sw2="s2",
1203 expectedLink=18 )
1204
1205 utilities.assert_equals( expect=main.TRUE,
1206 actual=stepResult,
1207 onpass="VLAN: Successfully added multi point"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001208 + " to single point intents" +
1209 " with IPV4 type and MAC addresses" +
1210 " in the same VLAN",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001211 onfail="VLAN: Failed to add multi point" +
1212 " to single point intents" )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001213
acsmars1ff5e052015-07-23 11:27:48 -07001214 def CASE5000( self, main ):
1215 """
1216 Will add description in next patch set
acsmars1ff5e052015-07-23 11:27:48 -07001217 """
1218 assert main, "There is no main"
1219 assert main.CLIs, "There is no main.CLIs"
1220 assert main.Mininet1, "Mininet handle should be named Mininet1"
1221 assert main.numSwitch, "Placed the total number of switch topology in \
1222 main.numSwitch"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001223 main.case( "Test host mobility with host intents " )
1224 main.step( " Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07001225 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1226
1227 main.log.info( "Moving h1 from s5 to s6")
1228
1229 main.Mininet1.moveHost( "h1","s5","s6" )
1230
1231 main.intentFunction.getHostsData( main )
1232 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1233
1234 utilities.assert_equals( expect="of:0000000000000006",
1235 actual=h1PostMove,
1236 onpass="Mobility: Successfully moved h1 to s6",
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001237 onfail="Mobility: Failed to moved h1 to s6" +
1238 " to single point intents" +
1239 " with IPV4 type and MAC addresses" +
1240 " in the same VLAN" )
1241
1242 main.step( "IPV4: Add host intents between h1 and h9" )
1243 stepResult = main.TRUE
1244 stepResult = main.intentFunction.hostIntent( main,
1245 onosNode='0',
1246 name='IPV4',
1247 host1='h1',
1248 host2='h9',
1249 host1Id='00:00:00:00:00:01/-1',
1250 host2Id='00:00:00:00:00:09/-1' )
1251
1252 utilities.assert_equals( expect=main.TRUE,
1253 actual=stepResult,
1254 onpass="IPV4: Host intent test successful " +
1255 "between two IPV4 hosts",
1256 onfail="IPV4: Host intent test failed " +
1257 "between two IPV4 hosts")
kelvin-onlab016dce22015-08-10 09:54:11 -07001258
1259 main.intentFunction.report( main )