blob: 258a9c131f0464393537c70efdd6bd5566707f04 [file] [log] [blame]
kelvin-onlab44147802015-07-27 17:57:31 -07001
2# Testing the basic intent functionality of ONOS
Jeremy2f190ca2016-01-29 15:23:57 -08003# TODO: Replace the CLI calls with REST API equivalents as they become available.
4# - May need to write functions in the onosrestdriver.py file to do this
5# TODO: Complete implementation of case 3000, 4000, and 6000 as REST API allows
6# -Currently there is no support in the REST API for Multi to Single and Single to Multi point intents
7# As such, these cases are incomplete and should not be enabled in the .params file
kelvin-onlab44147802015-07-27 17:57:31 -07008
9import time
10import json
11
12class FUNCintentRest:
13
14 def __init__( self ):
15 self.default = ''
16
17 def CASE1( self, main ):
18 import time
kelvin-onlab44147802015-07-27 17:57:31 -070019 import imp
Jon Hallf7234882015-08-28 13:16:31 -070020 import re
kelvin-onlab44147802015-07-27 17:57:31 -070021
22 """
23 - Construct tests variables
24 - GIT ( optional )
25 - Checkout ONOS master branch
26 - Pull latest ONOS code
27 - Building ONOS ( optional )
28 - Install ONOS package
29 - Build ONOS package
30 """
31
32 main.case( "Constructing test variables and building ONOS package" )
33 main.step( "Constructing test variables" )
34 main.caseExplanation = "This test case is mainly for loading " +\
35 "from params file, and pull and build the " +\
36 " latest ONOS package"
37 stepResult = main.FALSE
38
39 # Test variables
40 try:
Jon Hallf7234882015-08-28 13:16:31 -070041 main.testOnDirectory = re.sub( "(/tests)$", "", main.testDir )
kelvin-onlab44147802015-07-27 17:57:31 -070042 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
43 gitBranch = main.params[ 'GIT' ][ 'branch' ]
44 main.dependencyPath = main.testOnDirectory + \
45 main.params[ 'DEPENDENCY' ][ 'path' ]
46 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
47 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
48 if main.ONOSbench.maxNodes:
49 main.maxNodes = int( main.ONOSbench.maxNodes )
50 else:
51 main.maxNodes = 0
52 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
53 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
54 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
55 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
Jeremy2f190ca2016-01-29 15:23:57 -080056 main.checkIntentSleep = int( main.params[ 'SLEEP' ][ 'checkintent' ] )
57 main.removeIntentsleeo = int( main.params[ 'SLEEP' ][ 'removeintent' ] )
kelvin-onlab44147802015-07-27 17:57:31 -070058 main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] )
59 main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
kelvin-onlab0e684682015-08-11 18:51:41 -070060 main.addIntentSleep = int( main.params[ 'SLEEP' ][ 'addIntent' ] )
Jeremy2f190ca2016-01-29 15:23:57 -080061 main.checkTopoAttempts = int( main.params[ 'SLEEP' ][ 'topoAttempts' ] )
kelvin-onlab44147802015-07-27 17:57:31 -070062 gitPull = main.params[ 'GIT' ][ 'pull' ]
63 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
64 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
65 main.cellData = {} # for creating cell file
66 main.hostsData = {}
67 main.CLIs = []
68 main.ONOSip = []
Jeremy2f190ca2016-01-29 15:23:57 -080069 main.scapyHostNames = main.params[ 'SCAPY' ][ 'HOSTNAMES' ].split( ',' )
70 main.scapyHosts = [] # List of scapy hosts for iterating
71 main.assertReturnString = '' # Assembled assert return string
kelvin-onlab44147802015-07-27 17:57:31 -070072
73 main.ONOSip = main.ONOSbench.getOnosIps()
Jeremy2f190ca2016-01-29 15:23:57 -080074 print main.ONOSip
kelvin-onlab44147802015-07-27 17:57:31 -070075
76 # Assigning ONOS cli handles to a list
Jon Hallf7234882015-08-28 13:16:31 -070077 try:
78 for i in range( 1, main.maxNodes + 1 ):
79 main.CLIs.append( getattr( main, 'ONOSrest' + str( i ) ) )
80 except AttributeError:
81 main.log.warn( "A " + str( main.maxNodes ) + " node cluster " +
82 "was defined in env variables, but only " +
83 str( len( main.CLIs ) ) +
84 " nodes were defined in the .topo file. " +
85 "Using " + str( len( main.CLIs ) ) +
86 " nodes for the test." )
kelvin-onlab44147802015-07-27 17:57:31 -070087
88 # -- INIT SECTION, ONLY RUNS ONCE -- #
89 main.startUp = imp.load_source( wrapperFile1,
90 main.dependencyPath +
91 wrapperFile1 +
92 ".py" )
93
94 main.intentFunction = imp.load_source( wrapperFile2,
95 main.dependencyPath +
96 wrapperFile2 +
97 ".py" )
98
99 main.topo = imp.load_source( wrapperFile3,
100 main.dependencyPath +
101 wrapperFile3 +
102 ".py" )
103
Jon Hallf7234882015-08-28 13:16:31 -0700104 copyResult1 = main.ONOSbench.scp( main.Mininet1,
105 main.dependencyPath +
106 main.topology,
Jeremy2f190ca2016-01-29 15:23:57 -0800107 main.Mininet1.home + "custom/",
Jon Hallf7234882015-08-28 13:16:31 -0700108 direction="to" )
kelvin-onlab44147802015-07-27 17:57:31 -0700109 if main.CLIs:
110 stepResult = main.TRUE
111 else:
112 main.log.error( "Did not properly created list of ONOS CLI handle" )
113 stepResult = main.FALSE
114 except Exception as e:
115 main.log.exception(e)
116 main.cleanup()
117 main.exit()
118
119 utilities.assert_equals( expect=main.TRUE,
120 actual=stepResult,
121 onpass="Successfully construct " +
122 "test variables ",
123 onfail="Failed to construct test variables" )
124
125 if gitPull == 'True':
126 main.step( "Building ONOS in " + gitBranch + " branch" )
127 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
128 stepResult = onosBuildResult
129 utilities.assert_equals( expect=main.TRUE,
130 actual=stepResult,
131 onpass="Successfully compiled " +
132 "latest ONOS",
133 onfail="Failed to compile " +
134 "latest ONOS" )
135 else:
136 main.log.warn( "Did not pull new code so skipping mvn " +
137 "clean install" )
138 main.ONOSbench.getVersion( report=True )
139
140 def CASE2( self, main ):
141 """
142 - Set up cell
143 - Create cell file
144 - Set cell file
145 - Verify cell file
146 - Kill ONOS process
147 - Uninstall ONOS cluster
148 - Verify ONOS start up
149 - Install ONOS cluster
150 - Connect to cli
151 """
152
153 # main.scale[ 0 ] determines the current number of ONOS controller
154 main.numCtrls = int( main.scale[ 0 ] )
155
156 main.case( "Starting up " + str( main.numCtrls ) +
157 " node(s) ONOS cluster" )
158 main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
159 " node(s) ONOS cluster"
160
161
162
163 #kill off all onos processes
164 main.log.info( "Safety check, killing all ONOS processes" +
Jon Hall70b2ff42015-11-17 15:49:44 -0800165 " before initiating environment setup" )
kelvin-onlab44147802015-07-27 17:57:31 -0700166
Jeremy2f190ca2016-01-29 15:23:57 -0800167 time.sleep( main.startUpSleep )
168 main.step( "Uninstalling ONOS package" )
169 onosUninstallResult = main.TRUE
170 for ip in main.ONOSip:
171 onosUninstallResult = onosUninstallResult and \
172 main.ONOSbench.onosUninstall( nodeIp=ip )
173 stepResult = onosUninstallResult
174 utilities.assert_equals( expect=main.TRUE,
175 actual=stepResult,
176 onpass="Successfully uninstalled ONOS package",
177 onfail="Failed to uninstall ONOS package" )
178
kelvin-onlab44147802015-07-27 17:57:31 -0700179 for i in range( main.maxNodes ):
180 main.ONOSbench.onosDie( main.ONOSip[ i ] )
181
182 print "NODE COUNT = ", main.numCtrls
183
184 tempOnosIp = []
185 for i in range( main.numCtrls ):
186 tempOnosIp.append( main.ONOSip[i] )
187
188 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
189 "temp", main.Mininet1.ip_address,
190 main.apps, tempOnosIp )
191
192 main.step( "Apply cell to environment" )
193 cellResult = main.ONOSbench.setCell( "temp" )
194 verifyResult = main.ONOSbench.verifyCell()
195 stepResult = cellResult and verifyResult
196 utilities.assert_equals( expect=main.TRUE,
197 actual=stepResult,
198 onpass="Successfully applied cell to " + \
199 "environment",
200 onfail="Failed to apply cell to environment " )
201
202 main.step( "Creating ONOS package" )
203 packageResult = main.ONOSbench.onosPackage()
204 stepResult = packageResult
205 utilities.assert_equals( expect=main.TRUE,
206 actual=stepResult,
207 onpass="Successfully created ONOS package",
208 onfail="Failed to create ONOS package" )
209
210 time.sleep( main.startUpSleep )
kelvin-onlab44147802015-07-27 17:57:31 -0700211 main.step( "Installing ONOS package" )
212 onosInstallResult = main.TRUE
213 for i in range( main.numCtrls ):
214 onosInstallResult = onosInstallResult and \
215 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
216 stepResult = onosInstallResult
217 utilities.assert_equals( expect=main.TRUE,
218 actual=stepResult,
219 onpass="Successfully installed ONOS package",
220 onfail="Failed to install ONOS package" )
221
222 time.sleep( main.startUpSleep )
223 main.step( "Starting ONOS service" )
224 stopResult = main.TRUE
225 startResult = main.TRUE
226 onosIsUp = main.TRUE
227
228 for i in range( main.numCtrls ):
229 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
230 if onosIsUp == main.TRUE:
231 main.log.report( "ONOS instance is up and ready" )
232 else:
233 main.log.report( "ONOS instance may not be up, stop and " +
234 "start ONOS again " )
235 for i in range( main.numCtrls ):
236 stopResult = stopResult and \
237 main.ONOSbench.onosStop( main.ONOSip[ i ] )
238 for i in range( main.numCtrls ):
239 startResult = startResult and \
240 main.ONOSbench.onosStart( main.ONOSip[ i ] )
241 stepResult = onosIsUp and stopResult and startResult
242 utilities.assert_equals( expect=main.TRUE,
243 actual=stepResult,
244 onpass="ONOS service is ready",
245 onfail="ONOS service did not start properly" )
246
Jeremy2f190ca2016-01-29 15:23:57 -0800247 # Revisit adding the cli after ensuring the test works without it
248 # Start an ONOS cli to provide functionality that is not currently
249 # supported by the Rest API
250
251 # main.step( "Start ONOS cli" )
252 # cliResult = main.TRUE
253 # for i in range( main.numCtrls ):
254 # cliResult = cliResult and \
255 # main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
256 # stepResult = cliResult
257 # utilities.assert_equals( expect=main.TRUE,
258 # actual=stepResult,
259 # onpass="Successfully start ONOS cli",
260 # onfail="Failed to start ONOS cli" )
261
kelvin-onlab44147802015-07-27 17:57:31 -0700262 # Remove the first element in main.scale list
263 main.scale.remove( main.scale[ 0 ] )
264
Jeremy2f190ca2016-01-29 15:23:57 -0800265 main.intentFunction.report( main )
266
kelvin-onlab44147802015-07-27 17:57:31 -0700267 def CASE8( self, main ):
Jeremy2f190ca2016-01-29 15:23:57 -0800268 # OLD FUNCintentRest CASE 8
269 # This remains here for archiving and reference purposes and will be
270 # removed when the new FUNCintentRest is verified to work.
271 # """
272 # Compare Topo
273 # """
274 # import json
275
276 # main.case( "Compare ONOS Topology view to Mininet topology" )
277 # main.caseExplanation = "Compare topology elements between Mininet" +\
278 # " and ONOS"
279
280 # main.step( "Gathering topology information" )
281 # # TODO: add a paramaterized sleep here
282 # devicesResults = main.TRUE # Overall Boolean for device correctness
283 # linksResults = main.TRUE # Overall Boolean for link correctness
284 # hostsResults = main.TRUE # Overall Boolean for host correctness
285 # devices = main.topo.getAllDevices( main )
286 # hosts = main.topo.getAllHosts( main )
287 # ports = main.topo.getAllPorts( main )
288 # links = main.topo.getAllLinks( main )
289 # clusters = main.topo.getAllClusters( main )
290
291 # mnSwitches = main.Mininet1.getSwitches()
292 # mnLinks = main.Mininet1.getLinks()
293 # mnHosts = main.Mininet1.getHosts()
294
295 # main.step( "Comparing MN topology to ONOS topology" )
296 # for controller in range( main.numCtrls ):
297 # controllerStr = str( controller + 1 )
298 # if devices[ controller ] and ports[ controller ] and\
299 # "Error" not in devices[ controller ] and\
300 # "Error" not in ports[ controller ]:
301
302 # currentDevicesResult = main.Mininet1.compareSwitches(
303 # mnSwitches,
304 # json.loads( devices[ controller ] ),
305 # json.loads( ports[ controller ] ) )
306 # else:
307 # currentDevicesResult = main.FALSE
308 # utilities.assert_equals( expect=main.TRUE,
309 # actual=currentDevicesResult,
310 # onpass="ONOS" + controllerStr +
311 # " Switches view is correct",
312 # onfail="ONOS" + controllerStr +
313 # " Switches view is incorrect" )
314
315 # if links[ controller ] and "Error" not in links[ controller ]:
316 # currentLinksResult = main.Mininet1.compareLinks(
317 # mnSwitches, mnLinks,
318 # json.loads( links[ controller ] ) )
319 # else:
320 # currentLinksResult = main.FALSE
321 # utilities.assert_equals( expect=main.TRUE,
322 # actual=currentLinksResult,
323 # onpass="ONOS" + controllerStr +
324 # " links view is correct",
325 # onfail="ONOS" + controllerStr +
326 # " links view is incorrect" )
327
328 # if hosts[ controller ] or "Error" not in hosts[ controller ]:
329 # currentHostsResult = main.Mininet1.compareHosts(
330 # mnHosts,
331 # json.loads( hosts[ controller ] ) )
332 # else:
333 # currentHostsResult = main.FALSE
334 # utilities.assert_equals( expect=main.TRUE,
335 # actual=currentHostsResult,
336 # onpass="ONOS" + controllerStr +
337 # " hosts exist in Mininet",
338 # onfail="ONOS" + controllerStr +
339 # " hosts don't match Mininet" )
340
341 # NEW FUNCintentRest Case 8 as based off of the CASE 8 from FUNCintent
kelvin-onlab44147802015-07-27 17:57:31 -0700342 """
Jeremy2f190ca2016-01-29 15:23:57 -0800343 Compare ONOS Topology to Mininet Topology
kelvin-onlab44147802015-07-27 17:57:31 -0700344 """
345 import json
346
347 main.case( "Compare ONOS Topology view to Mininet topology" )
348 main.caseExplanation = "Compare topology elements between Mininet" +\
349 " and ONOS"
350
Jeremy2f190ca2016-01-29 15:23:57 -0800351 main.log.info( "Gathering topology information from Mininet" )
352 devicesResults = main.FALSE # Overall Boolean for device correctness
353 linksResults = main.FALSE # Overall Boolean for link correctness
354 hostsResults = main.FALSE # Overall Boolean for host correctness
355 deviceFails = [] # Nodes where devices are incorrect
356 linkFails = [] # Nodes where links are incorrect
357 hostFails = [] # Nodes where hosts are incorrect
358 attempts = main.checkTopoAttempts # Remaining Attempts
kelvin-onlab44147802015-07-27 17:57:31 -0700359
360 mnSwitches = main.Mininet1.getSwitches()
361 mnLinks = main.Mininet1.getLinks()
362 mnHosts = main.Mininet1.getHosts()
363
Jeremy2f190ca2016-01-29 15:23:57 -0800364 main.step( "Comparing Mininet topology to ONOS topology" )
kelvin-onlab44147802015-07-27 17:57:31 -0700365
Jeremy2f190ca2016-01-29 15:23:57 -0800366 while ( attempts >= 0 ) and\
367 ( not devicesResults or not linksResults or not hostsResults ):
368 time.sleep( 2 )
369 if not devicesResults:
370 devices = main.topo.getAllDevices( main )
371 ports = main.topo.getAllPorts( main )
372 devicesResults = main.TRUE
373 deviceFails = [] # Reset for each failed attempt
374 if not linksResults:
375 links = main.topo.getAllLinks( main )
376 linksResults = main.TRUE
377 linkFails = [] # Reset for each failed attempt
378 if not hostsResults:
379 hosts = main.topo.getAllHosts( main )
380 hostsResults = main.TRUE
381 hostFails = [] # Reset for each failed attempt
kelvin-onlab44147802015-07-27 17:57:31 -0700382
Jeremy2f190ca2016-01-29 15:23:57 -0800383 # Check for matching topology on each node
384 for controller in range( main.numCtrls ):
385 controllerStr = str( controller + 1 ) # ONOS node number
386 # Compare Devices
387 if devices[ controller ] and ports[ controller ] and\
388 "Error" not in devices[ controller ] and\
389 "Error" not in ports[ controller ]:
kelvin-onlab44147802015-07-27 17:57:31 -0700390
Jeremy2f190ca2016-01-29 15:23:57 -0800391 try:
392 deviceData = json.loads( devices[ controller ] )
393 portData = json.loads( ports[ controller ] )
394 except (TypeError,ValueError):
395 main.log.error( "Could not load json: {0} or {1}".format( str( devices[ controller ] ), str( ports[ controller ] ) ) )
396 currentDevicesResult = main.FALSE
397 else:
398 currentDevicesResult = main.Mininet1.compareSwitches(
399 mnSwitches,deviceData,portData )
400 else:
401 currentDevicesResult = main.FALSE
402 if not currentDevicesResult:
403 deviceFails.append( controllerStr )
404 devicesResults = devicesResults and currentDevicesResult
405 # Compare Links
406 if links[ controller ] and "Error" not in links[ controller ]:
407 try:
408 linkData = json.loads( links[ controller ] )
409 except (TypeError,ValueError):
410 main.log.error("Could not load json:" + str( links[ controller ] ) )
411 currentLinksResult = main.FALSE
412 else:
413 currentLinksResult = main.Mininet1.compareLinks(
414 mnSwitches, mnLinks,linkData )
415 else:
416 currentLinksResult = main.FALSE
417 if not currentLinksResult:
418 linkFails.append( controllerStr )
419 linksResults = linksResults and currentLinksResult
420 # Compare Hosts
421 if hosts[ controller ] and "Error" not in hosts[ controller ]:
422 try:
423 hostData = json.loads( hosts[ controller ] )
424 except (TypeError,ValueError):
425 main.log.error("Could not load json:" + str( hosts[ controller ] ) )
426 currentHostsResult = main.FALSE
427 else:
428 currentHostsResult = main.Mininet1.compareHosts(
429 mnHosts,hostData )
430 else:
431 currentHostsResult = main.FALSE
432 if not currentHostsResult:
433 hostFails.append( controllerStr )
434 hostsResults = hostsResults and currentHostsResult
435 # Decrement Attempts Remaining
436 attempts -= 1
437
438
439 utilities.assert_equals( expect=[],
440 actual=deviceFails,
441 onpass="ONOS correctly discovered all devices",
442 onfail="ONOS incorrectly discovered devices on nodes: " +
443 str( deviceFails ) )
444 utilities.assert_equals( expect=[],
445 actual=linkFails,
446 onpass="ONOS correctly discovered all links",
447 onfail="ONOS incorrectly discovered links on nodes: " +
448 str( linkFails ) )
449 utilities.assert_equals( expect=[],
450 actual=hostFails,
451 onpass="ONOS correctly discovered all hosts",
452 onfail="ONOS incorrectly discovered hosts on nodes: " +
453 str( hostFails ) )
454 topoResults = hostsResults and linksResults and devicesResults
455 utilities.assert_equals( expect=main.TRUE,
456 actual=topoResults,
457 onpass="ONOS correctly discovered the topology",
458 onfail="ONOS incorrectly discovered the topology" )
kelvin-onlab44147802015-07-27 17:57:31 -0700459
460 def CASE9( self, main ):
461 '''
462 Report errors/warnings/exceptions
463 '''
464 main.log.info( "Error report: \n" )
465 main.ONOSbench.logReport( globalONOSip[0],
466 [ "INFO", "FOLLOWER", "WARN", "flow", "ERROR" , "Except" ],
467 "s" )
468 #main.ONOSbench.logReport( globalONOSip[1], [ "INFO" ], "d" )
469
470 def CASE10( self, main ):
471 """
472 Start Mininet topology with OF 1.0 switches
473 """
474 main.OFProtocol = "1.0"
475 main.log.report( "Start Mininet topology with OF 1.0 switches" )
476 main.case( "Start Mininet topology with OF 1.0 switches" )
477 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
478 "switches to test intents, exits out if " +\
479 "topology did not start correctly"
480
481 main.step( "Starting Mininet topology with OF 1.0 switches" )
482 args = "--switch ovs,protocols=OpenFlow10"
483 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
484 main.topology,
485 args=args )
486 stepResult = topoResult
487 utilities.assert_equals( expect=main.TRUE,
488 actual=stepResult,
489 onpass="Successfully loaded topology",
490 onfail="Failed to load topology" )
491 # Exit if topology did not load properly
492 if not topoResult:
493 main.cleanup()
494 main.exit()
495
496 def CASE11( self, main ):
497 """
498 Start Mininet topology with OF 1.3 switches
499 """
500 main.OFProtocol = "1.3"
501 main.log.report( "Start Mininet topology with OF 1.3 switches" )
502 main.case( "Start Mininet topology with OF 1.3 switches" )
503 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
504 "switches to test intents, exits out if " +\
505 "topology did not start correctly"
506
507 main.step( "Starting Mininet topology with OF 1.3 switches" )
508 args = "--switch ovs,protocols=OpenFlow13"
509 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
510 main.topology,
511 args=args )
512 stepResult = topoResult
513 utilities.assert_equals( expect=main.TRUE,
514 actual=stepResult,
515 onpass="Successfully loaded topology",
516 onfail="Failed to load topology" )
517 # Exit if topology did not load properly
518 if not topoResult:
519 main.cleanup()
520 main.exit()
521
522 def CASE12( self, main ):
523 """
524 Assign mastership to controllers
525 """
526 import re
527
528 main.case( "Assign switches to controllers" )
529 main.step( "Assigning switches to controllers" )
530 main.caseExplanation = "Assign OF " + main.OFProtocol +\
531 " switches to ONOS nodes"
532
533 assignResult = main.TRUE
534 switchList = []
535
536 # Creates a list switch name, use getSwitch() function later...
537 for i in range( 1, ( main.numSwitch + 1 ) ):
538 switchList.append( 's' + str( i ) )
539
540 tempONOSip = []
541 for i in range( main.numCtrls ):
542 tempONOSip.append( main.ONOSip[ i ] )
543
544 assignResult = main.Mininet1.assignSwController( sw=switchList,
545 ip=tempONOSip,
Charles Chan029be652015-08-24 01:46:10 +0800546 port='6653' )
kelvin-onlab44147802015-07-27 17:57:31 -0700547 if not assignResult:
548 main.cleanup()
549 main.exit()
550
551 for i in range( 1, ( main.numSwitch + 1 ) ):
552 response = main.Mininet1.getSwController( "s" + str( i ) )
553 print( "Response is " + str( response ) )
554 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
555 assignResult = assignResult and main.TRUE
556 else:
557 assignResult = main.FALSE
558 stepResult = assignResult
559 utilities.assert_equals( expect=main.TRUE,
560 actual=stepResult,
561 onpass="Successfully assigned switches" +
562 "to controller",
563 onfail="Failed to assign switches to " +
564 "controller" )
Jeremy2f190ca2016-01-29 15:23:57 -0800565
566 def CASE13( self,main ):
567 """
568 Create Scapy components
569 """
570 main.case( "Create scapy components" )
571 main.step( "Create scapy components" )
572 import json
573 scapyResult = main.TRUE
574 for hostName in main.scapyHostNames:
575 main.Scapy1.createHostComponent( hostName )
576 main.scapyHosts.append( getattr( main, hostName ) )
577
578 main.step( "Start scapy components" )
579 for host in main.scapyHosts:
580 host.startHostCli()
581 host.startScapy()
582 host.updateSelf()
583 main.log.debug( host.name )
584 main.log.debug( host.hostIp )
585 main.log.debug( host.hostMac )
586
587
588 utilities.assert_equals( expect=main.TRUE,
589 actual=scapyResult,
590 onpass="Successfully created Scapy Components",
591 onfail="Failed to discover Scapy Components" )
592
593 def CASE14( self, main ):
kelvin-onlab44147802015-07-27 17:57:31 -0700594 """
595 Discover all hosts and store its data to a dictionary
596 """
597 main.case( "Discover all hosts" )
598
599 stepResult = main.TRUE
kelvin-onlab0e684682015-08-11 18:51:41 -0700600 main.step( "Discover all ipv4 host hosts " )
601 hostList = []
602 # List of host with default vlan
603 defaultHosts = [ "h1", "h3", "h8", "h9", "h11", "h16", "h17", "h19", "h24" ]
604 # Lists of host with unique vlan
605 vlanHosts1 = [ "h4", "h12", "h20" ]
606 vlanHosts2 = [ "h5", "h13", "h21" ]
607 vlanHosts3 = [ "h6", "h14", "h22" ]
608 vlanHosts4 = [ "h7", "h15", "h23" ]
609 hostList.append( defaultHosts )
610 hostList.append( vlanHosts1 )
611 hostList.append( vlanHosts2 )
612 hostList.append( vlanHosts3 )
613 hostList.append( vlanHosts4 )
614
615 stepResult = main.intentFunction.getHostsData( main, hostList )
kelvin-onlab44147802015-07-27 17:57:31 -0700616 utilities.assert_equals( expect=main.TRUE,
617 actual=stepResult,
618 onpass="Successfully discovered hosts",
619 onfail="Failed to discover hosts" )
620
Jeremy2f190ca2016-01-29 15:23:57 -0800621 def CASE15( self, main ):
kelvin-onlab44147802015-07-27 17:57:31 -0700622 """
Jeremy2f190ca2016-01-29 15:23:57 -0800623 Discover all hosts with scapy arp packets and store its data to a dictionary
kelvin-onlab44147802015-07-27 17:57:31 -0700624 """
Jeremy2f190ca2016-01-29 15:23:57 -0800625 main.case( "Discover all hosts using scapy" )
626 main.step( "Send packets from each host to the first host and confirm onos discovery" )
627
628 import collections
629 if len( main.scapyHosts ) < 1:
630 main.log.error( "No scapy hosts have been created" )
631 main.skipCase()
632
633 # Send ARP packets from each scapy host component
634 main.intentFunction.sendDiscoveryArp( main, main.scapyHosts )
635
636 stepResult = utilities.retry( f=main.intentFunction.confirmHostDiscovery,
637 retValue=main.FALSE, args=[ main ],
638 attempts=main.checkTopoAttempts, sleep=2 )
639
640 utilities.assert_equals( expect=main.TRUE,
641 actual=stepResult,
642 onpass="ONOS correctly discovered all hosts",
643 onfail="ONOS incorrectly discovered hosts" )
644
645 main.step( "Populate hostsData" )
646 stepResult = main.intentFunction.populateHostData( main )
647 utilities.assert_equals( expect=main.TRUE,
648 actual=stepResult,
649 onpass="Successfully populated hostsData",
650 onfail="Failed to populate hostsData" )
651
652 def CASE16( self, main ):
653 """
654 Stop mininet and remove scapy hosts
655 """
656 main.log.report( "Stop Mininet and Scapy" )
657 main.case( "Stop Mininet and Scapy" )
kelvin-onlab44147802015-07-27 17:57:31 -0700658 main.caseExplanation = "Stopping the current mininet topology " +\
659 "to start up fresh"
660
Jeremy2f190ca2016-01-29 15:23:57 -0800661 main.step( "Stopping and Removing Scapy Host Components" )
662 scapyResult = main.TRUE
663 for host in main.scapyHosts:
664 scapyResult = scapyResult and host.stopScapy()
665 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
666
667 for host in main.scapyHosts:
668 scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
669 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
670
671 main.scapyHosts = []
672 main.scapyHostIPs = []
673
674 utilities.assert_equals( expect=main.TRUE,
675 actual=scapyResult,
676 onpass="Successfully stopped scapy and removed host components",
677 onfail="Failed to stop mininet and scapy" )
678
kelvin-onlab44147802015-07-27 17:57:31 -0700679 main.step( "Stopping Mininet Topology" )
Jeremy2f190ca2016-01-29 15:23:57 -0800680 mininetResult = main.Mininet1.stopNet( )
681
kelvin-onlab44147802015-07-27 17:57:31 -0700682 utilities.assert_equals( expect=main.TRUE,
683 actual=stepResult,
684 onpass="Successfully stop mininet",
685 onfail="Failed to stop mininet" )
686 # Exit if topology did not load properly
Jeremy2f190ca2016-01-29 15:23:57 -0800687 if not (mininetResult and scapyResult ):
kelvin-onlab44147802015-07-27 17:57:31 -0700688 main.cleanup()
689 main.exit()
690
691 def CASE1000( self, main ):
692 """
693 Add host intents between 2 host:
694 - Discover hosts
695 - Add host intents
696 - Check intents
697 - Verify flows
698 - Ping hosts
699 - Reroute
700 - Link down
701 - Verify flows
702 - Check topology
703 - Ping hosts
704 - Link up
705 - Verify flows
706 - Check topology
707 - Ping hosts
708 - Remove intents
709 """
710 import time
711 import json
712 import re
713
714 # Assert variables - These variable's name|format must be followed
715 # if you want to use the wrapper function
716 assert main, "There is no main"
717 assert main.CLIs, "There is no main.CLIs"
718 assert main.Mininet1, "Mininet handle should be named Mininet1"
719 assert main.numSwitch, "Placed the total number of switch topology in \
720 main.numSwitch"
721
722 main.case( "Host Intents Test - " + str( main.numCtrls ) +
723 " NODE(S) - OF " + main.OFProtocol )
724 main.caseExplanation = "This test case tests Host intents using " +\
725 str( main.numCtrls ) + " node(s) cluster;\n" +\
726 "Different type of hosts will be tested in " +\
727 "each step such as IPV4, Dual stack, VLAN " +\
728 "etc;\nThe test will use OF " + main.OFProtocol\
729 + " OVS running in Mininet"
730
Jeremy2f190ca2016-01-29 15:23:57 -0800731 main.step( "IPV4: Add and test host intents between h1 and h9" )
732 main.assertReturnString = "Assertion result for IPV4 host intent with mac addresses\n"
733 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
734 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
735 testResult = main.FALSE
736 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlab44147802015-07-27 17:57:31 -0700737 name='IPV4',
Jeremy2f190ca2016-01-29 15:23:57 -0800738 onosNode='0',
739 host1=host1,
740 host2=host2 )
741
742 if installResult:
743 testResult = main.intentFunction.testHostIntent( main,
744 name='IPV4',
745 intentId = installResult,
746 onosNode='0',
747 host1=host1,
748 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700749 sw1='s5',
750 sw2='s2',
Jeremy2f190ca2016-01-29 15:23:57 -0800751 expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700752
753 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800754 actual=testResult,
755 onpass=main.assertReturnString,
756 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700757
758 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800759 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
760 host1 = { "name":"h3", "id":"00:00:00:00:00:03/-1" }
761 host2 = { "name":"h11","id":"00:00:00:00:00:0B/-1"}
762 testResult = main.FALSE
763 installResult = main.intentFunction.installHostIntent( main,
764 name='DUALSTACK1',
765 onosNode='0',
766 host1=host1,
767 host2=host2 )
768
769 if installResult:
770 testResult = main.intentFunction.testHostIntent( main,
771 name='DUALSTACK1',
772 intentId = installResult,
773 onosNode='0',
774 host1=host1,
775 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700776 sw1='s5',
777 sw2='s2',
Jeremy2f190ca2016-01-29 15:23:57 -0800778 expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700779
780 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800781 actual=testResult,
782 onpass=main.assertReturnString,
783 onfail=main.assertReturnString)
kelvin-onlab44147802015-07-27 17:57:31 -0700784
785 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800786 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
787 host1 = { "name":"h1" }
788 host2 = { "name":"h11" }
789 testResult = main.FALSE
790 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlab44147802015-07-27 17:57:31 -0700791 name='DUALSTACK2',
Jeremy2f190ca2016-01-29 15:23:57 -0800792 onosNode='0',
793 host1=host1,
794 host2=host2 )
795
796 if installResult:
797 testResult = main.intentFunction.testHostIntent( main,
798 name='DUALSTACK2',
799 intentId = installResult,
800 onosNode='0',
801 host1=host1,
802 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700803 sw1='s5',
804 sw2='s2',
Jeremy2f190ca2016-01-29 15:23:57 -0800805 expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700806
807 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800808 actual=testResult,
809 onpass=main.assertReturnString,
810 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700811
812 main.step( "1HOP: Add host intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -0800813 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
814 host1 = { "name":"h1" }
815 host2 = { "name":"h3" }
816 testResult = main.FALSE
817 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlab44147802015-07-27 17:57:31 -0700818 name='1HOP',
Jeremy2f190ca2016-01-29 15:23:57 -0800819 onosNode='0',
820 host1=host1,
821 host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700822
Jeremy2f190ca2016-01-29 15:23:57 -0800823 if installResult:
824 testResult = main.intentFunction.testHostIntent( main,
825 name='1HOP',
826 intentId = installResult,
827 onosNode='0',
828 host1=host1,
829 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700830 sw1='s5',
831 sw2='s2',
Jeremy2f190ca2016-01-29 15:23:57 -0800832 expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700833
834 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800835 actual=testResult,
836 onpass=main.assertReturnString,
837 onfail=main.assertReturnString )
838
839 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
840 main.assertReturnString = "Assertion Result vlan IPV4\n"
841 host1 = { "name":"h4","id":"00:00:00:00:00:04/100" }
842 host2 = { "name":"h12","id":"00:00:00:00:00:0C/100" }
843 testResult = main.FALSE
844 installResult = main.intentFunction.installHostIntent( main,
845 name='VLAN1',
846 onosNode='0',
847 host1=host1,
848 host2=host2 )
849
850 if installResult:
851 testResult = main.intentFunction.testHostIntent( main,
852 name='VLAN1',
853 intentId = installResult,
854 onosNode='0',
855 host1=host1,
856 host2=host2,
857 sw1='s5',
858 sw2='s2',
859 expectedLink = 18 )
860
861 utilities.assert_equals( expect=main.TRUE,
862 actual=testResult,
863 onpass=main.assertReturnString,
864 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700865
866 main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
Jeremy2f190ca2016-01-29 15:23:57 -0800867 main.assertReturnString = "Assertion Result different VLAN negative test\n"
868 host1 = { "name":"h13" }
869 host2 = { "name":"h20" }
870 testResult = main.FALSE
871 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlab44147802015-07-27 17:57:31 -0700872 name='VLAN2',
Jeremy2f190ca2016-01-29 15:23:57 -0800873 onosNode='0',
874 host1=host1,
875 host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700876
Jeremy2f190ca2016-01-29 15:23:57 -0800877 if installResult:
878 testResult = main.intentFunction.testHostIntent( main,
879 name='VLAN2',
880 intentId = installResult,
881 onosNode='0',
882 host1=host1,
883 host2=host2,
884 sw1='s5',
885 sw2='s2',
886 expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700887
Jeremy2f190ca2016-01-29 15:23:57 -0800888 utilities.assert_equals( expect=main.TRUE,
889 actual=testResult,
890 onpass=main.assertReturnString,
891 onfail=main.assertReturnString )
892
893 # Uncomment the following if a REST command is ever added to check leaders
894 # or if the cli is enabled
895
896 # main.step( "Confirm that ONOS leadership is unchanged")
897 # intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
898 # main.intentFunction.checkLeaderChange( intentLeadersOld,
899 # intentLeadersNew )
900
901 # utilities.assert_equals( expect=main.TRUE,
902 # actual=testResult,
903 # onpass="ONOS Leaders Unchanged",
904 # onfail="ONOS Leader Mismatch")
905
906 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -0700907
908 def CASE2000( self, main ):
909 """
910 Add point intents between 2 hosts:
911 - Get device ids | ports
912 - Add point intents
913 - Check intents
914 - Verify flows
915 - Ping hosts
916 - Reroute
917 - Link down
918 - Verify flows
919 - Check topology
920 - Ping hosts
921 - Link up
922 - Verify flows
923 - Check topology
924 - Ping hosts
925 - Remove intents
926 """
927 import time
928 import json
929 import re
930
931 # Assert variables - These variable's name|format must be followed
932 # if you want to use the wrapper function
933 assert main, "There is no main"
934 assert main.CLIs, "There is no main.CLIs"
935 assert main.Mininet1, "Mininet handle should be named Mininet1"
936 assert main.numSwitch, "Placed the total number of switch topology in \
937 main.numSwitch"
938
939 main.case( "Point Intents Test - " + str( main.numCtrls ) +
940 " NODE(S) - OF " + main.OFProtocol )
941 main.caseExplanation = "This test case will test point to point" +\
942 " intents using " + str( main.numCtrls ) +\
943 " node(s) cluster;\n" +\
944 "Different type of hosts will be tested in " +\
945 "each step such as IPV4, Dual stack, VLAN etc" +\
946 ";\nThe test will use OF " + main.OFProtocol +\
947 " OVS running in Mininet"
948
949 # No option point intents
950 main.step( "NOOPTION: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800951 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
952 senders = [
953 { "name":"h1","device":"of:0000000000000005/1" }
954 ]
955 recipients = [
956 { "name":"h9","device":"of:0000000000000006/1" }
957 ]
958 testResult = main.FALSE
959 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -0700960 main,
961 name="NOOPTION",
Jeremy2f190ca2016-01-29 15:23:57 -0800962 senders=senders,
963 recipients=recipients )
964
965 if installResult:
966 testResult = main.intentFunction.testPointIntent(
967 main,
968 intentId=installResult,
969 name="NOOPTION",
970 senders=senders,
971 recipients=recipients,
972 sw1="s5",
973 sw2="s2",
974 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -0700975
976 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800977 actual=testResult,
978 onpass=main.assertReturnString,
979 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700980
kelvin-onlab44147802015-07-27 17:57:31 -0700981 main.step( "IPV4: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -0800982 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
983 senders = [
984 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
985 ]
986 recipients = [
987 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09" }
988 ]
989 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -0700990 main,
991 name="IPV4",
Jeremy2f190ca2016-01-29 15:23:57 -0800992 senders=senders,
993 recipients=recipients,
994 ethType="IPV4" )
995
996 if installResult:
997 testResult = main.intentFunction.testPointIntent(
998 main,
999 intentId=installResult,
1000 name="IPV4",
1001 senders=senders,
1002 recipients=recipients,
1003 sw1="s5",
1004 sw2="s2",
1005 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001006
1007 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001008 actual=testResult,
1009 onpass=main.assertReturnString,
1010 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001011 main.step( "IPV4_2: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001012 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
1013 senders = [
1014 { "name":"h1","device":"of:0000000000000005/1" }
1015 ]
1016 recipients = [
1017 { "name":"h9","device":"of:0000000000000006/1" }
1018 ]
1019 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001020 main,
1021 name="IPV4_2",
Jeremy2f190ca2016-01-29 15:23:57 -08001022 senders=senders,
1023 recipients=recipients,
1024 ethType="IPV4" )
1025
1026 if installResult:
1027 testResult = main.intentFunction.testPointIntent(
1028 main,
1029 intentId=installResult,
1030 name="IPV4_2",
1031 senders=senders,
1032 recipients=recipients,
1033 sw1="s5",
1034 sw2="s2",
1035 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001036
1037 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001038 actual=testResult,
1039 onpass=main.assertReturnString,
1040 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001041
kelvin-onlab0e684682015-08-11 18:51:41 -07001042 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001043 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
1044 senders = [
1045 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01",
1046 "ip":main.h1.hostIp }
1047 ]
1048 recipients = [
1049 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09",
1050 "ip":main.h9.hostIp }
1051 ]
kelvin-onlab44147802015-07-27 17:57:31 -07001052 ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
1053 # Uneccessary, not including this in the selectors
Jeremy2f190ca2016-01-29 15:23:57 -08001054 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
1055 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
kelvin-onlab44147802015-07-27 17:57:31 -07001056
Jeremy2f190ca2016-01-29 15:23:57 -08001057 installResult = main.intentFunction.installPointIntent(
1058 main,
1059 name="SDNIP-ICMP",
1060 senders=senders,
1061 recipients=recipients,
1062 ethType="IPV4",
1063 ipProto=ipProto,
1064 tcpSrc=tcpSrc,
1065 tcpDst=tcpDst )
1066
1067 if installResult:
1068 testResult = main.intentFunction.testPointIntent(
1069 main,
1070 intentId=installResult,
1071 name="SDNIP_ICMP",
1072 senders=senders,
1073 recipients=recipients,
1074 sw1="s5",
1075 sw2="s2",
1076 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001077
1078 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001079 actual=testResult,
1080 onpass=main.assertReturnString,
1081 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001082
kelvin-onlab0e684682015-08-11 18:51:41 -07001083 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001084 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
kelvin-onlab44147802015-07-27 17:57:31 -07001085 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
1086 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab0e684682015-08-11 18:51:41 -07001087 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
1088 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlab44147802015-07-27 17:57:31 -07001089 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
1090 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
1091 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
1092
kelvin-onlab0e684682015-08-11 18:51:41 -07001093 stepResult = main.intentFunction.pointIntentTcp(
kelvin-onlab44147802015-07-27 17:57:31 -07001094 main,
kelvin-onlab0e684682015-08-11 18:51:41 -07001095 name="SDNIP-TCP",
kelvin-onlab44147802015-07-27 17:57:31 -07001096 host1="h1",
1097 host2="h9",
1098 deviceId1="of:0000000000000005/1",
1099 deviceId2="of:0000000000000006/1",
1100 mac1=mac1,
1101 mac2=mac2,
1102 ethType="IPV4",
kelvin-onlab0e684682015-08-11 18:51:41 -07001103 ipProto=ipProto,
1104 ip1=ip1,
1105 ip2=ip2,
1106 tcp1=tcp1,
1107 tcp2=tcp2 )
kelvin-onlab44147802015-07-27 17:57:31 -07001108
1109 utilities.assert_equals( expect=main.TRUE,
1110 actual=stepResult,
Jeremy2f190ca2016-01-29 15:23:57 -08001111 onpass=main.assertReturnString,
1112 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001113
Jeremy2f190ca2016-01-29 15:23:57 -08001114 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
1115 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
1116 senders = [
1117 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1118 ]
1119 recipients = [
1120 { "name":"h11","device":"of:0000000000000006/3","mac":"00:00:00:00:00:0B" }
1121 ]
1122 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001123 main,
1124 name="DUALSTACK1",
Jeremy2f190ca2016-01-29 15:23:57 -08001125 senders=senders,
1126 recipients=recipients,
1127 ethType="IPV4" )
1128
1129 if installResult:
1130 testResult = main.intentFunction.testPointIntent(
1131 main,
1132 intentId=installResult,
1133 name="DUALSTACK1",
1134 senders=senders,
1135 recipients=recipients,
1136 sw1="s5",
1137 sw2="s2",
1138 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001139
1140 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001141 actual=testResult,
1142 onpass=main.assertReturnString,
1143 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001144
1145 main.step( "VLAN: Add point intents between h5 and h21" )
Jeremy2f190ca2016-01-29 15:23:57 -08001146 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
1147 senders = [
1148 { "name":"h5","device":"of:0000000000000005/5","mac":"00:00:00:00:00:05" }
1149 ]
1150 recipients = [
1151 { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15" }
1152 ]
1153 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001154 main,
Jeremy2f190ca2016-01-29 15:23:57 -08001155 name="DUALSTACK1",
1156 senders=senders,
1157 recipients=recipients,
1158 ethType="IPV4" )
1159
1160 if installResult:
1161 testResult = main.intentFunction.testPointIntent(
1162 main,
1163 intentId=installResult,
1164 name="DUALSTACK1",
1165 senders=senders,
1166 recipients=recipients,
1167 sw1="s5",
1168 sw2="s2",
1169 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001170
1171 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001172 actual=testResult,
1173 onpass=main.assertReturnString,
1174 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001175
1176 main.step( "1HOP: Add point intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -08001177 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
1178 senders = [
1179 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1180 ]
1181 recipients = [
1182 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1183 ]
1184 installResult = main.intentFunction.installPointIntent(
1185 main,
1186 name="1HOP IPV4",
1187 senders=senders,
1188 recipients=recipients,
1189 ethType="IPV4" )
1190
1191 if installResult:
1192 testResult = main.intentFunction.testPointIntent(
1193 main,
1194 intentId=installResult,
1195 name="1HOP IPV4",
1196 senders=senders,
1197 recipients=recipients,
1198 sw1="s5",
1199 sw2="s2",
1200 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001201
1202 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001203 actual=testResult,
1204 onpass=main.assertReturnString,
1205 onfail=main.assertReturnString )
1206
1207 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001208
1209 def CASE3000( self, main ):
1210 """
1211 Add single point to multi point intents
1212 - Get device ids
1213 - Add single point to multi point intents
1214 - Check intents
1215 - Verify flows
1216 - Ping hosts
1217 - Reroute
1218 - Link down
1219 - Verify flows
1220 - Check topology
1221 - Ping hosts
1222 - Link up
1223 - Verify flows
1224 - Check topology
1225 - Ping hosts
1226 - Remove intents
1227 """
1228 assert main, "There is no main"
1229 assert main.CLIs, "There is no main.CLIs"
1230 assert main.Mininet1, "Mininet handle should be named Mininet1"
1231 assert main.numSwitch, "Placed the total number of switch topology in \
1232 main.numSwitch"
1233
1234 main.case( "Single To Multi Point Intents Test - " +
1235 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol )
1236 main.caseExplanation = "This test case will test single point to" +\
1237 " multi point intents using " +\
1238 str( main.numCtrls ) + " node(s) cluster;\n" +\
1239 "Different type of hosts will be tested in " +\
1240 "each step such as IPV4, Dual stack, VLAN etc" +\
1241 ";\nThe test will use OF " + main.OFProtocol +\
1242 " OVS running in Mininet"
1243
1244 main.step( "NOOPTION: Add single point to multi point intents" )
1245 stepResult = main.TRUE
1246 hostNames = [ 'h8', 'h16', 'h24' ]
1247 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
1248 'of:0000000000000007/8' ]
1249 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
1250 stepResult = main.intentFunction.singleToMultiIntent(
1251 main,
1252 name="NOOPTION",
1253 hostNames=hostNames,
1254 devices=devices,
1255 sw1="s5",
1256 sw2="s2",
1257 expectedLink=18 )
1258
1259 utilities.assert_equals( expect=main.TRUE,
1260 actual=stepResult,
1261 onpass="NOOPTION: Successfully added single "
1262 + " point to multi point intents" +
1263 " with no match action",
1264 onfail="NOOPTION: Failed to add single point"
1265 + " point to multi point intents" +
1266 " with no match action" )
1267
1268 main.step( "IPV4: Add single point to multi point intents" )
1269 stepResult = main.TRUE
1270 stepResult = main.intentFunction.singleToMultiIntent(
1271 main,
1272 name="IPV4",
1273 hostNames=hostNames,
1274 devices=devices,
1275 ports=None,
1276 ethType="IPV4",
1277 macs=macs,
1278 bandwidth="",
1279 lambdaAlloc=False,
1280 ipProto="",
1281 ipAddresses="",
1282 tcp="",
1283 sw1="s5",
1284 sw2="s2",
1285 expectedLink=18 )
1286
1287 utilities.assert_equals( expect=main.TRUE,
1288 actual=stepResult,
1289 onpass="IPV4: Successfully added single "
1290 + " point to multi point intents" +
1291 " with IPV4 type and MAC addresses",
1292 onfail="IPV4: Failed to add single point"
1293 + " point to multi point intents" +
1294 " with IPV4 type and MAC addresses" )
1295
1296 main.step( "IPV4_2: Add single point to multi point intents" )
1297 stepResult = main.TRUE
1298 hostNames = [ 'h8', 'h16', 'h24' ]
1299 stepResult = main.intentFunction.singleToMultiIntent(
1300 main,
1301 name="IPV4",
1302 hostNames=hostNames,
1303 ethType="IPV4",
1304 lambdaAlloc=False )
1305
1306 utilities.assert_equals( expect=main.TRUE,
1307 actual=stepResult,
1308 onpass="IPV4_2: Successfully added single "
1309 + " point to multi point intents" +
1310 " with IPV4 type and no MAC addresses",
1311 onfail="IPV4_2: Failed to add single point"
1312 + " point to multi point intents" +
1313 " with IPV4 type and no MAC addresses" )
1314
1315 main.step( "VLAN: Add single point to multi point intents" )
1316 stepResult = main.TRUE
1317 hostNames = [ 'h4', 'h12', 'h20' ]
1318 devices = [ 'of:0000000000000005/4', 'of:0000000000000006/4', \
1319 'of:0000000000000007/4' ]
1320 macs = [ '00:00:00:00:00:04', '00:00:00:00:00:0C', '00:00:00:00:00:14' ]
1321 stepResult = main.intentFunction.singleToMultiIntent(
1322 main,
1323 name="VLAN",
1324 hostNames=hostNames,
1325 devices=devices,
1326 ports=None,
1327 ethType="IPV4",
1328 macs=macs,
1329 bandwidth="",
1330 lambdaAlloc=False,
1331 ipProto="",
1332 ipAddresses="",
1333 tcp="",
1334 sw1="s5",
1335 sw2="s2",
1336 expectedLink=18 )
1337
1338 utilities.assert_equals( expect=main.TRUE,
1339 actual=stepResult,
1340 onpass="VLAN: Successfully added single "
1341 + " point to multi point intents" +
1342 " with IPV4 type and MAC addresses" +
1343 " in the same VLAN",
1344 onfail="VLAN: Failed to add single point"
1345 + " point to multi point intents" +
1346 " with IPV4 type and MAC addresses" +
1347 " in the same VLAN")
1348
1349 def CASE4000( self, main ):
1350 """
1351 Add multi point to single point intents
1352 - Get device ids
1353 - Add multi point to single point intents
1354 - Check intents
1355 - Verify flows
1356 - Ping hosts
1357 - Reroute
1358 - Link down
1359 - Verify flows
1360 - Check topology
1361 - Ping hosts
1362 - Link up
1363 - Verify flows
1364 - Check topology
1365 - Ping hosts
1366 - Remove intents
1367 """
1368 assert main, "There is no main"
1369 assert main.CLIs, "There is no main.CLIs"
1370 assert main.Mininet1, "Mininet handle should be named Mininet1"
1371 assert main.numSwitch, "Placed the total number of switch topology in \
1372 main.numSwitch"
1373
1374 main.case( "Multi To Single Point Intents Test - " +
1375 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol )
1376 main.caseExplanation = "This test case will test single point to" +\
1377 " multi point intents using " +\
1378 str( main.numCtrls ) + " node(s) cluster;\n" +\
1379 "Different type of hosts will be tested in " +\
1380 "each step such as IPV4, Dual stack, VLAN etc" +\
1381 ";\nThe test will use OF " + main.OFProtocol +\
1382 " OVS running in Mininet"
1383
1384 main.step( "NOOPTION: Add multi point to single point intents" )
1385 stepResult = main.TRUE
1386 hostNames = [ 'h8', 'h16', 'h24' ]
1387 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
1388 'of:0000000000000007/8' ]
1389 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
1390 stepResult = main.intentFunction.multiToSingleIntent(
1391 main,
1392 name="NOOPTION",
1393 hostNames=hostNames,
1394 devices=devices,
1395 sw1="s5",
1396 sw2="s2",
1397 expectedLink=18 )
1398
1399 utilities.assert_equals( expect=main.TRUE,
1400 actual=stepResult,
1401 onpass="NOOPTION: Successfully added multi "
1402 + " point to single point intents" +
1403 " with no match action",
1404 onfail="NOOPTION: Failed to add multi point" +
1405 " to single point intents" +
1406 " with no match action" )
1407
1408 main.step( "IPV4: Add multi point to single point intents" )
1409 stepResult = main.TRUE
1410 stepResult = main.intentFunction.multiToSingleIntent(
1411 main,
1412 name="IPV4",
1413 hostNames=hostNames,
1414 devices=devices,
1415 ports=None,
1416 ethType="IPV4",
1417 macs=macs,
1418 bandwidth="",
1419 lambdaAlloc=False,
1420 ipProto="",
1421 ipAddresses="",
1422 tcp="",
1423 sw1="s5",
1424 sw2="s2",
1425 expectedLink=18 )
1426
1427 utilities.assert_equals( expect=main.TRUE,
1428 actual=stepResult,
1429 onpass="IPV4: Successfully added multi point"
1430 + " to single point intents" +
1431 " with IPV4 type and MAC addresses",
1432 onfail="IPV4: Failed to add multi point" +
1433 " to single point intents" +
1434 " with IPV4 type and MAC addresses" )
1435
1436 main.step( "IPV4_2: Add multi point to single point intents" )
1437 stepResult = main.TRUE
1438 hostNames = [ 'h8', 'h16', 'h24' ]
1439 stepResult = main.intentFunction.multiToSingleIntent(
1440 main,
1441 name="IPV4",
1442 hostNames=hostNames,
1443 ethType="IPV4",
1444 lambdaAlloc=False )
1445
1446 utilities.assert_equals( expect=main.TRUE,
1447 actual=stepResult,
1448 onpass="IPV4_2: Successfully added multi point"
1449 + " to single point intents" +
1450 " with IPV4 type and no MAC addresses",
1451 onfail="IPV4_2: Failed to add multi point" +
1452 " to single point intents" +
1453 " with IPV4 type and no MAC addresses" )
1454
1455 main.step( "VLAN: Add multi point to single point intents" )
1456 stepResult = main.TRUE
1457 hostNames = [ 'h5', 'h13', 'h21' ]
1458 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \
1459 'of:0000000000000007/5' ]
1460 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
1461 stepResult = main.intentFunction.multiToSingleIntent(
1462 main,
1463 name="VLAN",
1464 hostNames=hostNames,
1465 devices=devices,
1466 ports=None,
1467 ethType="IPV4",
1468 macs=macs,
1469 bandwidth="",
1470 lambdaAlloc=False,
1471 ipProto="",
1472 ipAddresses="",
1473 tcp="",
1474 sw1="s5",
1475 sw2="s2",
1476 expectedLink=18 )
1477
1478 utilities.assert_equals( expect=main.TRUE,
1479 actual=stepResult,
1480 onpass="VLAN: Successfully added multi point"
1481 + " to single point intents" +
1482 " with IPV4 type and MAC addresses" +
1483 " in the same VLAN",
1484 onfail="VLAN: Failed to add multi point" +
1485 " to single point intents" )
1486
1487 def CASE5000( self, main ):
Jeremy2f190ca2016-01-29 15:23:57 -08001488 # """
1489 # Will add description in next patch set
1490 # """
1491 # assert main, "There is no main"
1492 # assert main.CLIs, "There is no main.CLIs"
1493 # assert main.Mininet1, "Mininet handle should be named Mininet1"
1494 # assert main.numSwitch, "Placed the total number of switch topology in \
1495 # main.numSwitch"
1496 # main.case( "Test host mobility with host intents " )
1497 # main.step( " Testing host mobility by moving h1 from s5 to s6" )
1498 # h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1499
1500 # main.log.info( "Moving h1 from s5 to s6")
1501
1502 # main.Mininet1.moveHost( "h1","s5","s6" )
1503
1504 # main.intentFunction.getHostsData( main )
1505 # h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1506
1507 # utilities.assert_equals( expect="of:0000000000000006",
1508 # actual=h1PostMove,
1509 # onpass="Mobility: Successfully moved h1 to s6",
1510 # onfail="Mobility: Failed to moved h1 to s6" +
1511 # " to single point intents" +
1512 # " with IPV4 type and MAC addresses" +
1513 # " in the same VLAN" )
1514
1515 # main.step( "IPV4: Add host intents between h1 and h9" )
1516 # stepResult = main.TRUE
1517 # stepResult = main.intentFunction.hostIntent( main,
1518 # onosNode='0',
1519 # name='IPV4',
1520 # host1='h1',
1521 # host2='h9',
1522 # host1Id='00:00:00:00:00:01/-1',
1523 # host2Id='00:00:00:00:00:09/-1' )
1524
1525 # utilities.assert_equals( expect=main.TRUE,
1526 # actual=stepResult,
1527 # onpass="IPV4: Host intent test successful " +
1528 # "between two IPV4 hosts",
1529 # onfail="IPV4: Host intent test failed " +
1530 # "between two IPV4 hosts")
kelvin-onlab44147802015-07-27 17:57:31 -07001531 """
Jeremy2f190ca2016-01-29 15:23:57 -08001532 Tests Host Mobility
1533 Modifies the topology location of h1
kelvin-onlab44147802015-07-27 17:57:31 -07001534 """
1535 assert main, "There is no main"
1536 assert main.CLIs, "There is no main.CLIs"
1537 assert main.Mininet1, "Mininet handle should be named Mininet1"
1538 assert main.numSwitch, "Placed the total number of switch topology in \
1539 main.numSwitch"
1540 main.case( "Test host mobility with host intents " )
Jeremy2f190ca2016-01-29 15:23:57 -08001541 main.step( "Testing host mobility by moving h1 from s5 to s6" )
kelvin-onlab44147802015-07-27 17:57:31 -07001542 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1543
1544 main.log.info( "Moving h1 from s5 to s6")
kelvin-onlab44147802015-07-27 17:57:31 -07001545 main.Mininet1.moveHost( "h1","s5","s6" )
1546
Jeremy2f190ca2016-01-29 15:23:57 -08001547 # Send discovery ping from moved host
1548 # Moving the host brings down the default interfaces and creates a new one.
1549 # Scapy is restarted on this host to detect the new interface
1550 main.h1.stopScapy()
1551 main.h1.startScapy()
1552
1553 # Discover new host location in ONOS and populate host data.
1554 # Host 1 IP and MAC should be unchanged
1555 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
1556 main.intentFunction.populateHostData( main )
1557
kelvin-onlab44147802015-07-27 17:57:31 -07001558 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1559
1560 utilities.assert_equals( expect="of:0000000000000006",
1561 actual=h1PostMove,
1562 onpass="Mobility: Successfully moved h1 to s6",
Jeremy2f190ca2016-01-29 15:23:57 -08001563 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlab44147802015-07-27 17:57:31 -07001564 " to single point intents" +
1565 " with IPV4 type and MAC addresses" +
1566 " in the same VLAN" )
1567
1568 main.step( "IPV4: Add host intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001569 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
1570 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
1571 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
1572
1573 installResult = main.intentFunction.installHostIntent( main,
1574 name='IPV4 Mobility IPV4',
kelvin-onlab44147802015-07-27 17:57:31 -07001575 onosNode='0',
Jeremy2f190ca2016-01-29 15:23:57 -08001576 host1=host1,
1577 host2=host2)
1578 if installResult:
1579 testResult = main.intentFunction.testHostIntent( main,
1580 name='Host Mobility IPV4',
1581 intentId = installResult,
1582 onosNode='0',
1583 host1=host1,
1584 host2=host2,
1585 sw1="s6",
1586 sw2="s2",
1587 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001588
1589 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001590 actual=testResult,
1591 onpass=main.assertReturnString,
1592 onfail=main.assertReturnString )
1593
1594 main.intentFunction.report( main )
1595