blob: 26dabedbbb702c490fc867058d9fbfdff1536951 [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' ] )
Jeremy Songster306ed7a2016-07-19 10:59:07 -070062 main.flowDurationSleep = int( main.params[ 'SLEEP' ][ 'flowDuration' ] )
kelvin-onlab44147802015-07-27 17:57:31 -070063 gitPull = main.params[ 'GIT' ][ 'pull' ]
64 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
65 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
66 main.cellData = {} # for creating cell file
67 main.hostsData = {}
68 main.CLIs = []
Jeremye1ea0602016-02-08 16:35:05 -080069 main.CLIs2 = []
kelvin-onlab44147802015-07-27 17:57:31 -070070 main.ONOSip = []
Jeremy2f190ca2016-01-29 15:23:57 -080071 main.scapyHostNames = main.params[ 'SCAPY' ][ 'HOSTNAMES' ].split( ',' )
72 main.scapyHosts = [] # List of scapy hosts for iterating
73 main.assertReturnString = '' # Assembled assert return string
Jeremy Songster17147f22016-05-31 18:30:52 -070074 main.cycle = 0 # How many times FUNCintent has run through its tests
kelvin-onlab44147802015-07-27 17:57:31 -070075
76 main.ONOSip = main.ONOSbench.getOnosIps()
Jeremy2f190ca2016-01-29 15:23:57 -080077 print main.ONOSip
kelvin-onlab44147802015-07-27 17:57:31 -070078
79 # Assigning ONOS cli handles to a list
Jon Hallf7234882015-08-28 13:16:31 -070080 try:
81 for i in range( 1, main.maxNodes + 1 ):
82 main.CLIs.append( getattr( main, 'ONOSrest' + str( i ) ) )
Jeremye1ea0602016-02-08 16:35:05 -080083 main.CLIs2.append( getattr( main, 'ONOScli' + str( i ) ) )
Jon Hallf7234882015-08-28 13:16:31 -070084 except AttributeError:
85 main.log.warn( "A " + str( main.maxNodes ) + " node cluster " +
86 "was defined in env variables, but only " +
87 str( len( main.CLIs ) ) +
88 " nodes were defined in the .topo file. " +
89 "Using " + str( len( main.CLIs ) ) +
90 " nodes for the test." )
kelvin-onlab44147802015-07-27 17:57:31 -070091
92 # -- INIT SECTION, ONLY RUNS ONCE -- #
93 main.startUp = imp.load_source( wrapperFile1,
94 main.dependencyPath +
95 wrapperFile1 +
96 ".py" )
97
98 main.intentFunction = imp.load_source( wrapperFile2,
99 main.dependencyPath +
100 wrapperFile2 +
101 ".py" )
102
103 main.topo = imp.load_source( wrapperFile3,
104 main.dependencyPath +
105 wrapperFile3 +
106 ".py" )
107
Jon Hallf7234882015-08-28 13:16:31 -0700108 copyResult1 = main.ONOSbench.scp( main.Mininet1,
109 main.dependencyPath +
110 main.topology,
Jeremy2f190ca2016-01-29 15:23:57 -0800111 main.Mininet1.home + "custom/",
Jon Hallf7234882015-08-28 13:16:31 -0700112 direction="to" )
Jeremye1ea0602016-02-08 16:35:05 -0800113 if main.CLIs and main.CLIs2:
kelvin-onlab44147802015-07-27 17:57:31 -0700114 stepResult = main.TRUE
115 else:
116 main.log.error( "Did not properly created list of ONOS CLI handle" )
117 stepResult = main.FALSE
118 except Exception as e:
119 main.log.exception(e)
120 main.cleanup()
121 main.exit()
122
123 utilities.assert_equals( expect=main.TRUE,
124 actual=stepResult,
125 onpass="Successfully construct " +
126 "test variables ",
127 onfail="Failed to construct test variables" )
128
129 if gitPull == 'True':
130 main.step( "Building ONOS in " + gitBranch + " branch" )
131 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
132 stepResult = onosBuildResult
133 utilities.assert_equals( expect=main.TRUE,
134 actual=stepResult,
135 onpass="Successfully compiled " +
136 "latest ONOS",
137 onfail="Failed to compile " +
138 "latest ONOS" )
139 else:
140 main.log.warn( "Did not pull new code so skipping mvn " +
141 "clean install" )
142 main.ONOSbench.getVersion( report=True )
143
144 def CASE2( self, main ):
145 """
146 - Set up cell
147 - Create cell file
148 - Set cell file
149 - Verify cell file
150 - Kill ONOS process
151 - Uninstall ONOS cluster
152 - Verify ONOS start up
153 - Install ONOS cluster
154 - Connect to cli
155 """
156
Jeremy Songster17147f22016-05-31 18:30:52 -0700157 main.cycle += 1
158
kelvin-onlab44147802015-07-27 17:57:31 -0700159 # main.scale[ 0 ] determines the current number of ONOS controller
160 main.numCtrls = int( main.scale[ 0 ] )
Jeremyeb51cb12016-03-28 17:53:35 -0700161 main.flowCompiler = "Flow Rules"
Jeremydd9bda62016-04-18 12:02:32 -0700162 main.initialized = main.TRUE
kelvin-onlab44147802015-07-27 17:57:31 -0700163
164 main.case( "Starting up " + str( main.numCtrls ) +
165 " node(s) ONOS cluster" )
166 main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
167 " node(s) ONOS cluster"
168
169
170
171 #kill off all onos processes
172 main.log.info( "Safety check, killing all ONOS processes" +
Jon Hall70b2ff42015-11-17 15:49:44 -0800173 " before initiating environment setup" )
kelvin-onlab44147802015-07-27 17:57:31 -0700174
Jeremy2f190ca2016-01-29 15:23:57 -0800175 time.sleep( main.startUpSleep )
Jeremy42df2e72016-02-23 16:37:46 -0800176
Jeremy2f190ca2016-01-29 15:23:57 -0800177 main.step( "Uninstalling ONOS package" )
178 onosUninstallResult = main.TRUE
179 for ip in main.ONOSip:
180 onosUninstallResult = onosUninstallResult and \
181 main.ONOSbench.onosUninstall( nodeIp=ip )
182 stepResult = onosUninstallResult
183 utilities.assert_equals( expect=main.TRUE,
184 actual=stepResult,
185 onpass="Successfully uninstalled ONOS package",
186 onfail="Failed to uninstall ONOS package" )
187
Jeremy42df2e72016-02-23 16:37:46 -0800188 time.sleep( main.startUpSleep )
189
kelvin-onlab44147802015-07-27 17:57:31 -0700190 for i in range( main.maxNodes ):
191 main.ONOSbench.onosDie( main.ONOSip[ i ] )
192
193 print "NODE COUNT = ", main.numCtrls
194
195 tempOnosIp = []
196 for i in range( main.numCtrls ):
197 tempOnosIp.append( main.ONOSip[i] )
198
199 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
200 "temp", main.Mininet1.ip_address,
201 main.apps, tempOnosIp )
202
203 main.step( "Apply cell to environment" )
204 cellResult = main.ONOSbench.setCell( "temp" )
205 verifyResult = main.ONOSbench.verifyCell()
206 stepResult = cellResult and verifyResult
207 utilities.assert_equals( expect=main.TRUE,
208 actual=stepResult,
209 onpass="Successfully applied cell to " + \
210 "environment",
211 onfail="Failed to apply cell to environment " )
212
213 main.step( "Creating ONOS package" )
214 packageResult = main.ONOSbench.onosPackage()
215 stepResult = packageResult
216 utilities.assert_equals( expect=main.TRUE,
217 actual=stepResult,
218 onpass="Successfully created ONOS package",
219 onfail="Failed to create ONOS package" )
220
221 time.sleep( main.startUpSleep )
kelvin-onlab44147802015-07-27 17:57:31 -0700222 main.step( "Installing ONOS package" )
223 onosInstallResult = main.TRUE
224 for i in range( main.numCtrls ):
225 onosInstallResult = onosInstallResult and \
226 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
227 stepResult = onosInstallResult
228 utilities.assert_equals( expect=main.TRUE,
229 actual=stepResult,
230 onpass="Successfully installed ONOS package",
231 onfail="Failed to install ONOS package" )
232
233 time.sleep( main.startUpSleep )
234 main.step( "Starting ONOS service" )
235 stopResult = main.TRUE
236 startResult = main.TRUE
237 onosIsUp = main.TRUE
238
239 for i in range( main.numCtrls ):
240 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
Jeremydd9bda62016-04-18 12:02:32 -0700241 if onosIsUp == main.TRUE:
242 main.log.report( "ONOS instance {0} is up and ready".format( i + 1 ) )
243 else:
244 main.log.report( "ONOS instance {0} may not be up, stop and ".format( i + 1 ) +
245 "start ONOS again " )
246 stopResult = stopResult and main.ONOSbench.onosStop( main.ONOSip[ i ] )
247 startResult = startResult and main.ONOSbench.onosStart( main.ONOSip[ i ] )
248 if not startResult or stopResult:
249 main.log.report( "ONOS instance {0} did not start correctly.".format( i + 1 ) )
kelvin-onlab44147802015-07-27 17:57:31 -0700250 stepResult = onosIsUp and stopResult and startResult
251 utilities.assert_equals( expect=main.TRUE,
252 actual=stepResult,
253 onpass="ONOS service is ready",
254 onfail="ONOS service did not start properly" )
Jeremydd9bda62016-04-18 12:02:32 -0700255 if not stepResult:
256 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700257
Jeremy2f190ca2016-01-29 15:23:57 -0800258 # Start an ONOS cli to provide functionality that is not currently
Jeremye1ea0602016-02-08 16:35:05 -0800259 # supported by the Rest API remove this when Leader Checking is supported
260 # by the REST API
Jeremy2f190ca2016-01-29 15:23:57 -0800261
Jeremye1ea0602016-02-08 16:35:05 -0800262 main.step( "Start ONOS cli" )
263 cliResult = main.TRUE
264 for i in range( main.numCtrls ):
265 cliResult = cliResult and \
266 main.CLIs2[ i ].startOnosCli( main.ONOSip[ i ] )
267 stepResult = cliResult
268 utilities.assert_equals( expect=main.TRUE,
269 actual=stepResult,
270 onpass="Successfully start ONOS cli",
271 onfail="Failed to start ONOS cli" )
Jeremydd9bda62016-04-18 12:02:32 -0700272 if not stepResult:
273 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800274
kelvin-onlab44147802015-07-27 17:57:31 -0700275 # Remove the first element in main.scale list
276 main.scale.remove( main.scale[ 0 ] )
277
Jeremy2f190ca2016-01-29 15:23:57 -0800278 main.intentFunction.report( main )
279
kelvin-onlab44147802015-07-27 17:57:31 -0700280 def CASE8( self, main ):
Jeremy2f190ca2016-01-29 15:23:57 -0800281 # OLD FUNCintentRest CASE 8
282 # This remains here for archiving and reference purposes and will be
283 # removed when the new FUNCintentRest is verified to work.
284 # """
285 # Compare Topo
286 # """
287 # import json
288
289 # main.case( "Compare ONOS Topology view to Mininet topology" )
290 # main.caseExplanation = "Compare topology elements between Mininet" +\
291 # " and ONOS"
292
293 # main.step( "Gathering topology information" )
294 # # TODO: add a paramaterized sleep here
295 # devicesResults = main.TRUE # Overall Boolean for device correctness
296 # linksResults = main.TRUE # Overall Boolean for link correctness
297 # hostsResults = main.TRUE # Overall Boolean for host correctness
298 # devices = main.topo.getAllDevices( main )
299 # hosts = main.topo.getAllHosts( main )
300 # ports = main.topo.getAllPorts( main )
301 # links = main.topo.getAllLinks( main )
302 # clusters = main.topo.getAllClusters( main )
303
304 # mnSwitches = main.Mininet1.getSwitches()
305 # mnLinks = main.Mininet1.getLinks()
306 # mnHosts = main.Mininet1.getHosts()
307
308 # main.step( "Comparing MN topology to ONOS topology" )
309 # for controller in range( main.numCtrls ):
310 # controllerStr = str( controller + 1 )
311 # if devices[ controller ] and ports[ controller ] and\
312 # "Error" not in devices[ controller ] and\
313 # "Error" not in ports[ controller ]:
314
315 # currentDevicesResult = main.Mininet1.compareSwitches(
316 # mnSwitches,
317 # json.loads( devices[ controller ] ),
318 # json.loads( ports[ controller ] ) )
319 # else:
320 # currentDevicesResult = main.FALSE
321 # utilities.assert_equals( expect=main.TRUE,
322 # actual=currentDevicesResult,
323 # onpass="ONOS" + controllerStr +
324 # " Switches view is correct",
325 # onfail="ONOS" + controllerStr +
326 # " Switches view is incorrect" )
327
328 # if links[ controller ] and "Error" not in links[ controller ]:
329 # currentLinksResult = main.Mininet1.compareLinks(
330 # mnSwitches, mnLinks,
331 # json.loads( links[ controller ] ) )
332 # else:
333 # currentLinksResult = main.FALSE
334 # utilities.assert_equals( expect=main.TRUE,
335 # actual=currentLinksResult,
336 # onpass="ONOS" + controllerStr +
337 # " links view is correct",
338 # onfail="ONOS" + controllerStr +
339 # " links view is incorrect" )
340
341 # if hosts[ controller ] or "Error" not in hosts[ controller ]:
342 # currentHostsResult = main.Mininet1.compareHosts(
343 # mnHosts,
344 # json.loads( hosts[ controller ] ) )
345 # else:
346 # currentHostsResult = main.FALSE
347 # utilities.assert_equals( expect=main.TRUE,
348 # actual=currentHostsResult,
349 # onpass="ONOS" + controllerStr +
350 # " hosts exist in Mininet",
351 # onfail="ONOS" + controllerStr +
352 # " hosts don't match Mininet" )
353
354 # NEW FUNCintentRest Case 8 as based off of the CASE 8 from FUNCintent
kelvin-onlab44147802015-07-27 17:57:31 -0700355 """
Jeremy2f190ca2016-01-29 15:23:57 -0800356 Compare ONOS Topology to Mininet Topology
kelvin-onlab44147802015-07-27 17:57:31 -0700357 """
358 import json
359
360 main.case( "Compare ONOS Topology view to Mininet topology" )
361 main.caseExplanation = "Compare topology elements between Mininet" +\
362 " and ONOS"
363
Jeremy2f190ca2016-01-29 15:23:57 -0800364 main.log.info( "Gathering topology information from Mininet" )
365 devicesResults = main.FALSE # Overall Boolean for device correctness
366 linksResults = main.FALSE # Overall Boolean for link correctness
367 hostsResults = main.FALSE # Overall Boolean for host correctness
368 deviceFails = [] # Nodes where devices are incorrect
369 linkFails = [] # Nodes where links are incorrect
370 hostFails = [] # Nodes where hosts are incorrect
371 attempts = main.checkTopoAttempts # Remaining Attempts
kelvin-onlab44147802015-07-27 17:57:31 -0700372
373 mnSwitches = main.Mininet1.getSwitches()
374 mnLinks = main.Mininet1.getLinks()
375 mnHosts = main.Mininet1.getHosts()
376
Jeremy2f190ca2016-01-29 15:23:57 -0800377 main.step( "Comparing Mininet topology to ONOS topology" )
kelvin-onlab44147802015-07-27 17:57:31 -0700378
Jeremy2f190ca2016-01-29 15:23:57 -0800379 while ( attempts >= 0 ) and\
380 ( not devicesResults or not linksResults or not hostsResults ):
381 time.sleep( 2 )
382 if not devicesResults:
383 devices = main.topo.getAllDevices( main )
384 ports = main.topo.getAllPorts( main )
385 devicesResults = main.TRUE
386 deviceFails = [] # Reset for each failed attempt
387 if not linksResults:
388 links = main.topo.getAllLinks( main )
389 linksResults = main.TRUE
390 linkFails = [] # Reset for each failed attempt
391 if not hostsResults:
392 hosts = main.topo.getAllHosts( main )
393 hostsResults = main.TRUE
394 hostFails = [] # Reset for each failed attempt
kelvin-onlab44147802015-07-27 17:57:31 -0700395
Jeremy2f190ca2016-01-29 15:23:57 -0800396 # Check for matching topology on each node
397 for controller in range( main.numCtrls ):
398 controllerStr = str( controller + 1 ) # ONOS node number
399 # Compare Devices
400 if devices[ controller ] and ports[ controller ] and\
401 "Error" not in devices[ controller ] and\
402 "Error" not in ports[ controller ]:
kelvin-onlab44147802015-07-27 17:57:31 -0700403
Jeremy2f190ca2016-01-29 15:23:57 -0800404 try:
405 deviceData = json.loads( devices[ controller ] )
406 portData = json.loads( ports[ controller ] )
407 except (TypeError,ValueError):
408 main.log.error( "Could not load json: {0} or {1}".format( str( devices[ controller ] ), str( ports[ controller ] ) ) )
409 currentDevicesResult = main.FALSE
410 else:
411 currentDevicesResult = main.Mininet1.compareSwitches(
412 mnSwitches,deviceData,portData )
413 else:
414 currentDevicesResult = main.FALSE
415 if not currentDevicesResult:
416 deviceFails.append( controllerStr )
417 devicesResults = devicesResults and currentDevicesResult
418 # Compare Links
419 if links[ controller ] and "Error" not in links[ controller ]:
420 try:
421 linkData = json.loads( links[ controller ] )
422 except (TypeError,ValueError):
423 main.log.error("Could not load json:" + str( links[ controller ] ) )
424 currentLinksResult = main.FALSE
425 else:
426 currentLinksResult = main.Mininet1.compareLinks(
427 mnSwitches, mnLinks,linkData )
428 else:
429 currentLinksResult = main.FALSE
430 if not currentLinksResult:
431 linkFails.append( controllerStr )
432 linksResults = linksResults and currentLinksResult
433 # Compare Hosts
434 if hosts[ controller ] and "Error" not in hosts[ controller ]:
435 try:
436 hostData = json.loads( hosts[ controller ] )
437 except (TypeError,ValueError):
438 main.log.error("Could not load json:" + str( hosts[ controller ] ) )
439 currentHostsResult = main.FALSE
440 else:
441 currentHostsResult = main.Mininet1.compareHosts(
442 mnHosts,hostData )
443 else:
444 currentHostsResult = main.FALSE
445 if not currentHostsResult:
446 hostFails.append( controllerStr )
447 hostsResults = hostsResults and currentHostsResult
448 # Decrement Attempts Remaining
449 attempts -= 1
450
451
452 utilities.assert_equals( expect=[],
453 actual=deviceFails,
454 onpass="ONOS correctly discovered all devices",
455 onfail="ONOS incorrectly discovered devices on nodes: " +
456 str( deviceFails ) )
457 utilities.assert_equals( expect=[],
458 actual=linkFails,
459 onpass="ONOS correctly discovered all links",
460 onfail="ONOS incorrectly discovered links on nodes: " +
461 str( linkFails ) )
462 utilities.assert_equals( expect=[],
463 actual=hostFails,
464 onpass="ONOS correctly discovered all hosts",
465 onfail="ONOS incorrectly discovered hosts on nodes: " +
466 str( hostFails ) )
467 topoResults = hostsResults and linksResults and devicesResults
468 utilities.assert_equals( expect=main.TRUE,
469 actual=topoResults,
470 onpass="ONOS correctly discovered the topology",
471 onfail="ONOS incorrectly discovered the topology" )
kelvin-onlab44147802015-07-27 17:57:31 -0700472
473 def CASE9( self, main ):
474 '''
475 Report errors/warnings/exceptions
476 '''
477 main.log.info( "Error report: \n" )
478 main.ONOSbench.logReport( globalONOSip[0],
479 [ "INFO", "FOLLOWER", "WARN", "flow", "ERROR" , "Except" ],
480 "s" )
481 #main.ONOSbench.logReport( globalONOSip[1], [ "INFO" ], "d" )
482
483 def CASE10( self, main ):
484 """
485 Start Mininet topology with OF 1.0 switches
486 """
Jeremydd9bda62016-04-18 12:02:32 -0700487 if main.initialized == main.FALSE:
488 main.log.error( "Test components did not start correctly, skipping further tests" )
489 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700490 main.OFProtocol = "1.0"
491 main.log.report( "Start Mininet topology with OF 1.0 switches" )
492 main.case( "Start Mininet topology with OF 1.0 switches" )
493 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
494 "switches to test intents, exits out if " +\
495 "topology did not start correctly"
496
497 main.step( "Starting Mininet topology with OF 1.0 switches" )
498 args = "--switch ovs,protocols=OpenFlow10"
499 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
500 main.topology,
501 args=args )
502 stepResult = topoResult
503 utilities.assert_equals( expect=main.TRUE,
504 actual=stepResult,
505 onpass="Successfully loaded topology",
506 onfail="Failed to load topology" )
507 # Exit if topology did not load properly
508 if not topoResult:
Jeremydd9bda62016-04-18 12:02:32 -0700509 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700510
511 def CASE11( self, main ):
512 """
513 Start Mininet topology with OF 1.3 switches
514 """
Jeremydd9bda62016-04-18 12:02:32 -0700515 if main.initialized == main.FALSE:
516 main.log.error( "Test components did not start correctly, skipping further tests" )
517 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700518 main.OFProtocol = "1.3"
519 main.log.report( "Start Mininet topology with OF 1.3 switches" )
520 main.case( "Start Mininet topology with OF 1.3 switches" )
521 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
522 "switches to test intents, exits out if " +\
523 "topology did not start correctly"
524
525 main.step( "Starting Mininet topology with OF 1.3 switches" )
526 args = "--switch ovs,protocols=OpenFlow13"
527 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
528 main.topology,
529 args=args )
530 stepResult = topoResult
531 utilities.assert_equals( expect=main.TRUE,
532 actual=stepResult,
533 onpass="Successfully loaded topology",
534 onfail="Failed to load topology" )
535 # Exit if topology did not load properly
536 if not topoResult:
Jeremydd9bda62016-04-18 12:02:32 -0700537 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700538
539 def CASE12( self, main ):
540 """
541 Assign mastership to controllers
542 """
543 import re
544
Jeremydd9bda62016-04-18 12:02:32 -0700545 if main.initialized == main.FALSE:
546 main.log.error( "Test components did not start correctly, skipping further tests" )
547 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700548 main.case( "Assign switches to controllers" )
549 main.step( "Assigning switches to controllers" )
550 main.caseExplanation = "Assign OF " + main.OFProtocol +\
551 " switches to ONOS nodes"
552
553 assignResult = main.TRUE
554 switchList = []
555
556 # Creates a list switch name, use getSwitch() function later...
557 for i in range( 1, ( main.numSwitch + 1 ) ):
558 switchList.append( 's' + str( i ) )
559
560 tempONOSip = []
561 for i in range( main.numCtrls ):
562 tempONOSip.append( main.ONOSip[ i ] )
563
564 assignResult = main.Mininet1.assignSwController( sw=switchList,
565 ip=tempONOSip,
Charles Chan029be652015-08-24 01:46:10 +0800566 port='6653' )
kelvin-onlab44147802015-07-27 17:57:31 -0700567 if not assignResult:
Jeremydd9bda62016-04-18 12:02:32 -0700568 main.log.error( "Problem assigning mastership of switches, skipping further test cases" )
569 main.initialized = main.FALSE
570 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700571
572 for i in range( 1, ( main.numSwitch + 1 ) ):
573 response = main.Mininet1.getSwController( "s" + str( i ) )
574 print( "Response is " + str( response ) )
575 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
576 assignResult = assignResult and main.TRUE
577 else:
578 assignResult = main.FALSE
579 stepResult = assignResult
580 utilities.assert_equals( expect=main.TRUE,
581 actual=stepResult,
582 onpass="Successfully assigned switches" +
583 "to controller",
584 onfail="Failed to assign switches to " +
585 "controller" )
Jeremydd9bda62016-04-18 12:02:32 -0700586 if not stepResult:
587 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800588
589 def CASE13( self,main ):
590 """
591 Create Scapy components
592 """
Jeremydd9bda62016-04-18 12:02:32 -0700593 if main.initialized == main.FALSE:
594 main.log.error( "Test components did not start correctly, skipping further tests" )
595 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800596 main.case( "Create scapy components" )
597 main.step( "Create scapy components" )
598 import json
599 scapyResult = main.TRUE
600 for hostName in main.scapyHostNames:
601 main.Scapy1.createHostComponent( hostName )
602 main.scapyHosts.append( getattr( main, hostName ) )
603
604 main.step( "Start scapy components" )
605 for host in main.scapyHosts:
606 host.startHostCli()
607 host.startScapy()
608 host.updateSelf()
609 main.log.debug( host.name )
610 main.log.debug( host.hostIp )
611 main.log.debug( host.hostMac )
612
613
614 utilities.assert_equals( expect=main.TRUE,
615 actual=scapyResult,
616 onpass="Successfully created Scapy Components",
617 onfail="Failed to discover Scapy Components" )
Jeremydd9bda62016-04-18 12:02:32 -0700618 if not scapyResult:
619 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800620
621 def CASE14( self, main ):
kelvin-onlab44147802015-07-27 17:57:31 -0700622 """
623 Discover all hosts and store its data to a dictionary
624 """
Jeremydd9bda62016-04-18 12:02:32 -0700625 if main.initialized == main.FALSE:
626 main.log.error( "Test components did not start correctly, skipping further tests" )
627 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700628 main.case( "Discover all hosts" )
629
630 stepResult = main.TRUE
kelvin-onlab0e684682015-08-11 18:51:41 -0700631 main.step( "Discover all ipv4 host hosts " )
632 hostList = []
633 # List of host with default vlan
634 defaultHosts = [ "h1", "h3", "h8", "h9", "h11", "h16", "h17", "h19", "h24" ]
635 # Lists of host with unique vlan
636 vlanHosts1 = [ "h4", "h12", "h20" ]
637 vlanHosts2 = [ "h5", "h13", "h21" ]
638 vlanHosts3 = [ "h6", "h14", "h22" ]
639 vlanHosts4 = [ "h7", "h15", "h23" ]
640 hostList.append( defaultHosts )
641 hostList.append( vlanHosts1 )
642 hostList.append( vlanHosts2 )
643 hostList.append( vlanHosts3 )
644 hostList.append( vlanHosts4 )
645
646 stepResult = main.intentFunction.getHostsData( main, hostList )
kelvin-onlab44147802015-07-27 17:57:31 -0700647 utilities.assert_equals( expect=main.TRUE,
648 actual=stepResult,
649 onpass="Successfully discovered hosts",
650 onfail="Failed to discover hosts" )
Jeremydd9bda62016-04-18 12:02:32 -0700651 if not stepResult:
652 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700653
Jeremy2f190ca2016-01-29 15:23:57 -0800654 def CASE15( self, main ):
kelvin-onlab44147802015-07-27 17:57:31 -0700655 """
Jeremy2f190ca2016-01-29 15:23:57 -0800656 Discover all hosts with scapy arp packets and store its data to a dictionary
kelvin-onlab44147802015-07-27 17:57:31 -0700657 """
Jeremydd9bda62016-04-18 12:02:32 -0700658 if main.initialized == main.FALSE:
659 main.log.error( "Test components did not start correctly, skipping further tests" )
660 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800661 main.case( "Discover all hosts using scapy" )
662 main.step( "Send packets from each host to the first host and confirm onos discovery" )
663
664 import collections
665 if len( main.scapyHosts ) < 1:
666 main.log.error( "No scapy hosts have been created" )
Jeremydd9bda62016-04-18 12:02:32 -0700667 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800668 main.skipCase()
669
670 # Send ARP packets from each scapy host component
671 main.intentFunction.sendDiscoveryArp( main, main.scapyHosts )
672
673 stepResult = utilities.retry( f=main.intentFunction.confirmHostDiscovery,
674 retValue=main.FALSE, args=[ main ],
675 attempts=main.checkTopoAttempts, sleep=2 )
676
677 utilities.assert_equals( expect=main.TRUE,
678 actual=stepResult,
679 onpass="ONOS correctly discovered all hosts",
680 onfail="ONOS incorrectly discovered hosts" )
Jeremydd9bda62016-04-18 12:02:32 -0700681 if not stepResult:
682 main.initialized = main.FALSE
683 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800684
685 main.step( "Populate hostsData" )
686 stepResult = main.intentFunction.populateHostData( main )
687 utilities.assert_equals( expect=main.TRUE,
688 actual=stepResult,
689 onpass="Successfully populated hostsData",
690 onfail="Failed to populate hostsData" )
Jeremydd9bda62016-04-18 12:02:32 -0700691 if not stepResult:
692 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800693
694 def CASE16( self, main ):
695 """
Jeremy42df2e72016-02-23 16:37:46 -0800696 Balance Masters
697 """
Jeremydd9bda62016-04-18 12:02:32 -0700698 if main.initialized == main.FALSE:
699 main.log.error( "Test components did not start correctly, skipping further tests" )
700 main.skipCase()
Jeremy42df2e72016-02-23 16:37:46 -0800701 main.case( "Balance mastership of switches" )
702 main.step( "Balancing mastership of switches" )
703
704 balanceResult = main.FALSE
705 balanceResult = utilities.retry( f=main.CLIs2[ 0 ].balanceMasters, retValue=main.FALSE, args=[] )
706
707 utilities.assert_equals( expect=main.TRUE,
708 actual=stepResult,
709 onpass="Successfully balanced mastership of switches",
710 onfail="Failed to balance mastership of switches" )
Jeremydd9bda62016-04-18 12:02:32 -0700711 if not stepResult:
712 main.initialized = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800713
714 def CASE17( self, main ):
715 """
Jeremyeb51cb12016-03-28 17:53:35 -0700716 Use Flow Objectives
717 """
Jeremydd9bda62016-04-18 12:02:32 -0700718 if main.initialized == main.FALSE:
719 main.log.error( "Test components did not start correctly, skipping further tests" )
720 main.skipCase()
Jeremyeb51cb12016-03-28 17:53:35 -0700721 main.case( "Enable intent compilation using Flow Objectives" )
722 main.step( "Enabling Flow Objectives" )
723
724 main.flowCompiler = "Flow Objectives"
725
726 cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator"
727
728 stepResult = main.CLIs2[ 0 ].setCfg( component=cmd,
729 propName="useFlowObjectives", value="true" )
730
731 utilities.assert_equals( expect=main.TRUE,
732 actual=stepResult,
733 onpass="Successfully activated Flow Objectives",
734 onfail="Failed to activate Flow Objectives" )
Jeremydd9bda62016-04-18 12:02:32 -0700735 if not stepResult:
736 main.initialized = main.FALSE
Jeremyeb51cb12016-03-28 17:53:35 -0700737
738 def CASE18( self, main ):
739 """
Jeremy2f190ca2016-01-29 15:23:57 -0800740 Stop mininet and remove scapy hosts
741 """
742 main.log.report( "Stop Mininet and Scapy" )
743 main.case( "Stop Mininet and Scapy" )
kelvin-onlab44147802015-07-27 17:57:31 -0700744 main.caseExplanation = "Stopping the current mininet topology " +\
745 "to start up fresh"
746
Jeremy2f190ca2016-01-29 15:23:57 -0800747 main.step( "Stopping and Removing Scapy Host Components" )
748 scapyResult = main.TRUE
749 for host in main.scapyHosts:
750 scapyResult = scapyResult and host.stopScapy()
751 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
752
753 for host in main.scapyHosts:
754 scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
755 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
756
757 main.scapyHosts = []
758 main.scapyHostIPs = []
759
760 utilities.assert_equals( expect=main.TRUE,
761 actual=scapyResult,
762 onpass="Successfully stopped scapy and removed host components",
763 onfail="Failed to stop mininet and scapy" )
764
kelvin-onlab44147802015-07-27 17:57:31 -0700765 main.step( "Stopping Mininet Topology" )
Jeremy2f190ca2016-01-29 15:23:57 -0800766 mininetResult = main.Mininet1.stopNet( )
767
kelvin-onlab44147802015-07-27 17:57:31 -0700768 utilities.assert_equals( expect=main.TRUE,
769 actual=stepResult,
770 onpass="Successfully stop mininet",
771 onfail="Failed to stop mininet" )
772 # Exit if topology did not load properly
Jeremy2f190ca2016-01-29 15:23:57 -0800773 if not (mininetResult and scapyResult ):
kelvin-onlab44147802015-07-27 17:57:31 -0700774 main.cleanup()
775 main.exit()
776
Jeremy Songster17147f22016-05-31 18:30:52 -0700777 def CASE19( self, main ):
778 """
779 Copy the karaf.log files after each testcase cycle
780 """
781 main.log.report( "Copy karaf logs" )
782 main.case( "Copy karaf logs" )
783 main.caseExplanation = "Copying the karaf logs to preserve them through" +\
784 "reinstalling ONOS"
785 main.step( "Copying karaf logs" )
Jeremy Songster31aad312016-06-13 16:32:11 -0700786 stepResult = main.TRUE
787 scpResult = main.TRUE
788 copyResult = main.TRUE
Jeremy Songstercc5414b2016-07-11 10:59:53 -0700789 for i in range( main.numCtrls ):
790 main.node = main.CLIs2[ i ]
Jeremy Songster17147f22016-05-31 18:30:52 -0700791 ip = main.ONOSip[ i ]
792 main.node.ip_address = ip
Jeremy Songster31aad312016-06-13 16:32:11 -0700793 scpResult = scpResult and main.ONOSbench.scp( main.node ,
794 "/opt/onos/log/karaf.log",
795 "/tmp/karaf.log",
796 direction="from" )
797 copyResult = copyResult and main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
798 copyFileName=( "karaf.log.node{0}.cycle{1}".format( str( i + 1 ), str( main.cycle ) ) ) )
799 if scpResult and copyResult:
800 stepResult = main.TRUE and stepResult
801 else:
802 stepResult = main.FALSE and stepResult
Jeremy Songster31aad312016-06-13 16:32:11 -0700803 utilities.assert_equals( expect=main.TRUE,
804 actual=stepResult,
805 onpass="Successfully copied remote ONOS logs",
806 onfail="Failed to copy remote ONOS logs" )
Jeremy Songster17147f22016-05-31 18:30:52 -0700807
kelvin-onlab44147802015-07-27 17:57:31 -0700808 def CASE1000( self, main ):
809 """
810 Add host intents between 2 host:
811 - Discover hosts
812 - Add host intents
813 - Check intents
814 - Verify flows
815 - Ping hosts
816 - Reroute
817 - Link down
818 - Verify flows
819 - Check topology
820 - Ping hosts
821 - Link up
822 - Verify flows
823 - Check topology
824 - Ping hosts
825 - Remove intents
826 """
827 import time
828 import json
829 import re
Jeremydd9bda62016-04-18 12:02:32 -0700830 if main.initialized == main.FALSE:
831 main.log.error( "Test components did not start correctly, skipping further tests" )
832 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700833 # Assert variables - These variable's name|format must be followed
834 # if you want to use the wrapper function
835 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -0700836 try:
837 assert main.CLIs
838 except AssertionError:
839 main.log.error( "There is no main.CLIs, skipping test cases" )
840 main.initialized = main.FALSE
841 main.skipCase()
842 try:
843 assert main.Mininet1
844 except AssertionError:
845 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
846 main.initialized = main.FALSE
847 main.skipCase()
848 try:
849 assert main.numSwitch
850 except AssertionError:
851 main.log.error( "Place the total number of switch topology in \
852 main.numSwitch" )
853 main.initialized = main.FALSE
854 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700855
Jeremye1ea0602016-02-08 16:35:05 -0800856 # Save leader candidates
857 intentLeadersOld = main.CLIs2[ 0 ].leaderCandidates()
858
kelvin-onlab44147802015-07-27 17:57:31 -0700859 main.case( "Host Intents Test - " + str( main.numCtrls ) +
Jeremyeb51cb12016-03-28 17:53:35 -0700860 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -0700861 main.caseExplanation = "This test case tests Host intents using " +\
862 str( main.numCtrls ) + " node(s) cluster;\n" +\
863 "Different type of hosts will be tested in " +\
864 "each step such as IPV4, Dual stack, VLAN " +\
Jeremyeb51cb12016-03-28 17:53:35 -0700865 "etc;\nThe test will use OF " + main.OFProtocol +\
866 " OVS running in Mininet and compile intents" +\
867 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -0700868
Jeremy2f190ca2016-01-29 15:23:57 -0800869 main.step( "IPV4: Add and test host intents between h1 and h9" )
870 main.assertReturnString = "Assertion result for IPV4 host intent with mac addresses\n"
871 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
872 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
873 testResult = main.FALSE
874 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlab44147802015-07-27 17:57:31 -0700875 name='IPV4',
Jeremy2f190ca2016-01-29 15:23:57 -0800876 onosNode='0',
877 host1=host1,
878 host2=host2 )
879
880 if installResult:
881 testResult = main.intentFunction.testHostIntent( main,
882 name='IPV4',
883 intentId = installResult,
884 onosNode='0',
885 host1=host1,
886 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700887 sw1='s5',
888 sw2='s2',
Jeremy2f190ca2016-01-29 15:23:57 -0800889 expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700890
891 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800892 actual=testResult,
893 onpass=main.assertReturnString,
894 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700895
896 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800897 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
898 host1 = { "name":"h3", "id":"00:00:00:00:00:03/-1" }
899 host2 = { "name":"h11","id":"00:00:00:00:00:0B/-1"}
900 testResult = main.FALSE
901 installResult = main.intentFunction.installHostIntent( main,
902 name='DUALSTACK1',
903 onosNode='0',
904 host1=host1,
905 host2=host2 )
906
907 if installResult:
908 testResult = main.intentFunction.testHostIntent( main,
909 name='DUALSTACK1',
910 intentId = installResult,
911 onosNode='0',
912 host1=host1,
913 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700914 sw1='s5',
915 sw2='s2',
Jeremy2f190ca2016-01-29 15:23:57 -0800916 expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700917
918 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800919 actual=testResult,
920 onpass=main.assertReturnString,
921 onfail=main.assertReturnString)
kelvin-onlab44147802015-07-27 17:57:31 -0700922
923 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800924 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
925 host1 = { "name":"h1" }
926 host2 = { "name":"h11" }
927 testResult = main.FALSE
928 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlab44147802015-07-27 17:57:31 -0700929 name='DUALSTACK2',
Jeremy2f190ca2016-01-29 15:23:57 -0800930 onosNode='0',
931 host1=host1,
932 host2=host2 )
933
934 if installResult:
935 testResult = main.intentFunction.testHostIntent( main,
936 name='DUALSTACK2',
937 intentId = installResult,
938 onosNode='0',
939 host1=host1,
940 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700941 sw1='s5',
942 sw2='s2',
Jeremy2f190ca2016-01-29 15:23:57 -0800943 expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700944
945 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800946 actual=testResult,
947 onpass=main.assertReturnString,
948 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700949
950 main.step( "1HOP: Add host intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -0800951 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
952 host1 = { "name":"h1" }
953 host2 = { "name":"h3" }
954 testResult = main.FALSE
955 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlab44147802015-07-27 17:57:31 -0700956 name='1HOP',
Jeremy2f190ca2016-01-29 15:23:57 -0800957 onosNode='0',
958 host1=host1,
959 host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700960
Jeremy2f190ca2016-01-29 15:23:57 -0800961 if installResult:
962 testResult = main.intentFunction.testHostIntent( main,
963 name='1HOP',
964 intentId = installResult,
965 onosNode='0',
966 host1=host1,
967 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700968 sw1='s5',
969 sw2='s2',
Jeremy2f190ca2016-01-29 15:23:57 -0800970 expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700971
972 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800973 actual=testResult,
974 onpass=main.assertReturnString,
975 onfail=main.assertReturnString )
976
977 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
978 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700979 host1 = { "name":"h4","id":"00:00:00:00:00:04/100", "vlanId":"100" }
980 host2 = { "name":"h12","id":"00:00:00:00:00:0C/100", "vlanId":"100" }
Jeremy2f190ca2016-01-29 15:23:57 -0800981 testResult = main.FALSE
982 installResult = main.intentFunction.installHostIntent( main,
983 name='VLAN1',
984 onosNode='0',
985 host1=host1,
986 host2=host2 )
987
988 if installResult:
989 testResult = main.intentFunction.testHostIntent( main,
990 name='VLAN1',
991 intentId = installResult,
992 onosNode='0',
993 host1=host1,
994 host2=host2,
995 sw1='s5',
996 sw2='s2',
997 expectedLink = 18 )
998
999 utilities.assert_equals( expect=main.TRUE,
1000 actual=testResult,
1001 onpass=main.assertReturnString,
1002 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001003
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001004 # This step isn't currently possible to perform in the REST API
1005 # main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
1006 # main.assertReturnString = "Assertion Result different VLAN negative test\n"
1007 # host1 = { "name":"h13" }
1008 # host2 = { "name":"h20" }
1009 # testResult = main.FALSE
1010 # installResult = main.intentFunction.installHostIntent( main,
1011 # name='VLAN2',
1012 # onosNode='0',
1013 # host1=host1,
1014 # host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -07001015
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001016 # if installResult:
1017 # testResult = main.intentFunction.testHostIntent( main,
1018 # name='VLAN2',
1019 # intentId = installResult,
1020 # onosNode='0',
1021 # host1=host1,
1022 # host2=host2,
1023 # sw1='s5',
1024 # sw2='s2',
1025 # expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001026
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001027 # utilities.assert_equals( expect=main.TRUE,
1028 # actual=testResult,
1029 # onpass=main.assertReturnString,
1030 # onfail=main.assertReturnString )
Jeremy2f190ca2016-01-29 15:23:57 -08001031
Jeremye1ea0602016-02-08 16:35:05 -08001032 # Change the following to use the REST API when leader checking is
1033 # supported by it
Jeremy2f190ca2016-01-29 15:23:57 -08001034
Jeremye1ea0602016-02-08 16:35:05 -08001035 main.step( "Confirm that ONOS leadership is unchanged")
1036 intentLeadersNew = main.CLIs2[ 0 ].leaderCandidates()
1037 main.intentFunction.checkLeaderChange( intentLeadersOld,
1038 intentLeadersNew )
Jeremy2f190ca2016-01-29 15:23:57 -08001039
Jeremye1ea0602016-02-08 16:35:05 -08001040 utilities.assert_equals( expect=main.TRUE,
1041 actual=testResult,
1042 onpass="ONOS Leaders Unchanged",
1043 onfail="ONOS Leader Mismatch")
Jeremy2f190ca2016-01-29 15:23:57 -08001044
1045 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001046
1047 def CASE2000( self, main ):
1048 """
1049 Add point intents between 2 hosts:
1050 - Get device ids | ports
1051 - Add point intents
1052 - Check intents
1053 - Verify flows
1054 - Ping hosts
1055 - Reroute
1056 - Link down
1057 - Verify flows
1058 - Check topology
1059 - Ping hosts
1060 - Link up
1061 - Verify flows
1062 - Check topology
1063 - Ping hosts
1064 - Remove intents
1065 """
1066 import time
1067 import json
1068 import re
Jeremydd9bda62016-04-18 12:02:32 -07001069 if main.initialized == main.FALSE:
1070 main.log.error( "Test components did not start correctly, skipping further tests" )
1071 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001072 # Assert variables - These variable's name|format must be followed
1073 # if you want to use the wrapper function
1074 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -07001075 try:
1076 assert main.CLIs
1077 except AssertionError:
1078 main.log.error( "There is no main.CLIs, skipping test cases" )
1079 main.initialized = main.FALSE
1080 main.skipCase()
1081 try:
1082 assert main.Mininet1
1083 except AssertionError:
1084 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1085 main.initialized = main.FALSE
1086 main.skipCase()
1087 try:
1088 assert main.numSwitch
1089 except AssertionError:
1090 main.log.error( "Place the total number of switch topology in \
1091 main.numSwitch" )
1092 main.initialized = main.FALSE
1093 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001094
1095 main.case( "Point Intents Test - " + str( main.numCtrls ) +
Jeremyeb51cb12016-03-28 17:53:35 -07001096 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -07001097 main.caseExplanation = "This test case will test point to point" +\
1098 " intents using " + str( main.numCtrls ) +\
1099 " node(s) cluster;\n" +\
1100 "Different type of hosts will be tested in " +\
1101 "each step such as IPV4, Dual stack, VLAN etc" +\
1102 ";\nThe test will use OF " + main.OFProtocol +\
Jeremyeb51cb12016-03-28 17:53:35 -07001103 " OVS running in Mininet and compile intents" +\
1104 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001105
1106 # No option point intents
1107 main.step( "NOOPTION: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001108 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
1109 senders = [
1110 { "name":"h1","device":"of:0000000000000005/1" }
1111 ]
1112 recipients = [
1113 { "name":"h9","device":"of:0000000000000006/1" }
1114 ]
1115 testResult = main.FALSE
1116 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001117 main,
1118 name="NOOPTION",
Jeremy2f190ca2016-01-29 15:23:57 -08001119 senders=senders,
1120 recipients=recipients )
1121
1122 if installResult:
1123 testResult = main.intentFunction.testPointIntent(
1124 main,
1125 intentId=installResult,
1126 name="NOOPTION",
1127 senders=senders,
1128 recipients=recipients,
1129 sw1="s5",
1130 sw2="s2",
1131 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001132
1133 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001134 actual=testResult,
1135 onpass=main.assertReturnString,
1136 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001137
kelvin-onlab44147802015-07-27 17:57:31 -07001138 main.step( "IPV4: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001139 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
1140 senders = [
1141 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1142 ]
1143 recipients = [
1144 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09" }
1145 ]
1146 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001147 main,
1148 name="IPV4",
Jeremy2f190ca2016-01-29 15:23:57 -08001149 senders=senders,
1150 recipients=recipients,
1151 ethType="IPV4" )
1152
1153 if installResult:
1154 testResult = main.intentFunction.testPointIntent(
1155 main,
1156 intentId=installResult,
1157 name="IPV4",
1158 senders=senders,
1159 recipients=recipients,
1160 sw1="s5",
1161 sw2="s2",
1162 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001163
1164 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001165 actual=testResult,
1166 onpass=main.assertReturnString,
1167 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001168 main.step( "IPV4_2: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001169 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
1170 senders = [
1171 { "name":"h1","device":"of:0000000000000005/1" }
1172 ]
1173 recipients = [
1174 { "name":"h9","device":"of:0000000000000006/1" }
1175 ]
1176 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001177 main,
1178 name="IPV4_2",
Jeremy2f190ca2016-01-29 15:23:57 -08001179 senders=senders,
1180 recipients=recipients,
1181 ethType="IPV4" )
1182
1183 if installResult:
1184 testResult = main.intentFunction.testPointIntent(
1185 main,
1186 intentId=installResult,
1187 name="IPV4_2",
1188 senders=senders,
1189 recipients=recipients,
1190 sw1="s5",
1191 sw2="s2",
1192 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001193
1194 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001195 actual=testResult,
1196 onpass=main.assertReturnString,
1197 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001198
kelvin-onlab0e684682015-08-11 18:51:41 -07001199 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001200 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
1201 senders = [
1202 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01",
1203 "ip":main.h1.hostIp }
1204 ]
1205 recipients = [
1206 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09",
1207 "ip":main.h9.hostIp }
1208 ]
kelvin-onlab44147802015-07-27 17:57:31 -07001209 ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
1210 # Uneccessary, not including this in the selectors
Jeremy2f190ca2016-01-29 15:23:57 -08001211 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
1212 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
kelvin-onlab44147802015-07-27 17:57:31 -07001213
Jeremy2f190ca2016-01-29 15:23:57 -08001214 installResult = main.intentFunction.installPointIntent(
1215 main,
1216 name="SDNIP-ICMP",
1217 senders=senders,
1218 recipients=recipients,
1219 ethType="IPV4",
1220 ipProto=ipProto,
1221 tcpSrc=tcpSrc,
1222 tcpDst=tcpDst )
1223
1224 if installResult:
1225 testResult = main.intentFunction.testPointIntent(
1226 main,
1227 intentId=installResult,
1228 name="SDNIP_ICMP",
1229 senders=senders,
1230 recipients=recipients,
1231 sw1="s5",
1232 sw2="s2",
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001233 expectedLink=18,
1234 useTCP=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001235
1236 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001237 actual=testResult,
1238 onpass=main.assertReturnString,
1239 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001240
kelvin-onlab0e684682015-08-11 18:51:41 -07001241 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001242 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
kelvin-onlab44147802015-07-27 17:57:31 -07001243 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
1244 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab0e684682015-08-11 18:51:41 -07001245 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
1246 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlab44147802015-07-27 17:57:31 -07001247 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
1248 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
1249 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
1250
kelvin-onlab0e684682015-08-11 18:51:41 -07001251 stepResult = main.intentFunction.pointIntentTcp(
kelvin-onlab44147802015-07-27 17:57:31 -07001252 main,
kelvin-onlab0e684682015-08-11 18:51:41 -07001253 name="SDNIP-TCP",
kelvin-onlab44147802015-07-27 17:57:31 -07001254 host1="h1",
1255 host2="h9",
1256 deviceId1="of:0000000000000005/1",
1257 deviceId2="of:0000000000000006/1",
1258 mac1=mac1,
1259 mac2=mac2,
1260 ethType="IPV4",
kelvin-onlab0e684682015-08-11 18:51:41 -07001261 ipProto=ipProto,
1262 ip1=ip1,
1263 ip2=ip2,
1264 tcp1=tcp1,
1265 tcp2=tcp2 )
kelvin-onlab44147802015-07-27 17:57:31 -07001266
1267 utilities.assert_equals( expect=main.TRUE,
1268 actual=stepResult,
Jeremy2f190ca2016-01-29 15:23:57 -08001269 onpass=main.assertReturnString,
1270 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001271
Jeremy2f190ca2016-01-29 15:23:57 -08001272 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
1273 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
1274 senders = [
1275 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1276 ]
1277 recipients = [
1278 { "name":"h11","device":"of:0000000000000006/3","mac":"00:00:00:00:00:0B" }
1279 ]
1280 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001281 main,
1282 name="DUALSTACK1",
Jeremy2f190ca2016-01-29 15:23:57 -08001283 senders=senders,
1284 recipients=recipients,
1285 ethType="IPV4" )
1286
1287 if installResult:
1288 testResult = main.intentFunction.testPointIntent(
1289 main,
1290 intentId=installResult,
1291 name="DUALSTACK1",
1292 senders=senders,
1293 recipients=recipients,
1294 sw1="s5",
1295 sw2="s2",
1296 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001297
1298 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001299 actual=testResult,
1300 onpass=main.assertReturnString,
1301 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001302
1303 main.step( "VLAN: Add point intents between h5 and h21" )
Jeremy2f190ca2016-01-29 15:23:57 -08001304 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
1305 senders = [
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001306 { "name":"h5","device":"of:0000000000000005/5","mac":"00:00:00:00:00:05", "vlanId":"200" }
Jeremy2f190ca2016-01-29 15:23:57 -08001307 ]
1308 recipients = [
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001309 { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15", "vlanId":"200" }
Jeremy2f190ca2016-01-29 15:23:57 -08001310 ]
1311 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001312 main,
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001313 name="VLAN",
Jeremy2f190ca2016-01-29 15:23:57 -08001314 senders=senders,
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001315 recipients=recipients )
Jeremy2f190ca2016-01-29 15:23:57 -08001316
1317 if installResult:
1318 testResult = main.intentFunction.testPointIntent(
1319 main,
1320 intentId=installResult,
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001321 name="VLAN",
Jeremy2f190ca2016-01-29 15:23:57 -08001322 senders=senders,
1323 recipients=recipients,
1324 sw1="s5",
1325 sw2="s2",
1326 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001327
1328 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001329 actual=testResult,
1330 onpass=main.assertReturnString,
1331 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001332
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001333 # TODO: implement VLAN selector REST API intent test once supported
1334
kelvin-onlab44147802015-07-27 17:57:31 -07001335 main.step( "1HOP: Add point intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -08001336 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
1337 senders = [
1338 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1339 ]
1340 recipients = [
1341 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1342 ]
1343 installResult = main.intentFunction.installPointIntent(
1344 main,
1345 name="1HOP IPV4",
1346 senders=senders,
1347 recipients=recipients,
1348 ethType="IPV4" )
1349
1350 if installResult:
1351 testResult = main.intentFunction.testPointIntent(
1352 main,
1353 intentId=installResult,
1354 name="1HOP IPV4",
1355 senders=senders,
1356 recipients=recipients,
1357 sw1="s5",
1358 sw2="s2",
1359 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001360
1361 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001362 actual=testResult,
1363 onpass=main.assertReturnString,
1364 onfail=main.assertReturnString )
1365
1366 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001367
1368 def CASE3000( self, main ):
1369 """
1370 Add single point to multi point intents
1371 - Get device ids
1372 - Add single point to multi point intents
1373 - Check intents
1374 - Verify flows
1375 - Ping hosts
1376 - Reroute
1377 - Link down
1378 - Verify flows
1379 - Check topology
1380 - Ping hosts
1381 - Link up
1382 - Verify flows
1383 - Check topology
1384 - Ping hosts
1385 - Remove intents
1386 """
1387 assert main, "There is no main"
1388 assert main.CLIs, "There is no main.CLIs"
1389 assert main.Mininet1, "Mininet handle should be named Mininet1"
1390 assert main.numSwitch, "Placed the total number of switch topology in \
1391 main.numSwitch"
1392
1393 main.case( "Single To Multi Point Intents Test - " +
Jeremyeb51cb12016-03-28 17:53:35 -07001394 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -07001395 main.caseExplanation = "This test case will test single point to" +\
1396 " multi point intents using " +\
1397 str( main.numCtrls ) + " node(s) cluster;\n" +\
1398 "Different type of hosts will be tested in " +\
1399 "each step such as IPV4, Dual stack, VLAN etc" +\
1400 ";\nThe test will use OF " + main.OFProtocol +\
Jeremyeb51cb12016-03-28 17:53:35 -07001401 " OVS running in Mininet and compile intents" +\
1402 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001403
1404 main.step( "NOOPTION: Add single point to multi point intents" )
1405 stepResult = main.TRUE
1406 hostNames = [ 'h8', 'h16', 'h24' ]
1407 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
1408 'of:0000000000000007/8' ]
1409 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
1410 stepResult = main.intentFunction.singleToMultiIntent(
1411 main,
1412 name="NOOPTION",
1413 hostNames=hostNames,
1414 devices=devices,
1415 sw1="s5",
1416 sw2="s2",
1417 expectedLink=18 )
1418
1419 utilities.assert_equals( expect=main.TRUE,
1420 actual=stepResult,
1421 onpass="NOOPTION: Successfully added single "
1422 + " point to multi point intents" +
1423 " with no match action",
1424 onfail="NOOPTION: Failed to add single point"
1425 + " point to multi point intents" +
1426 " with no match action" )
1427
1428 main.step( "IPV4: Add single point to multi point intents" )
1429 stepResult = main.TRUE
1430 stepResult = main.intentFunction.singleToMultiIntent(
1431 main,
1432 name="IPV4",
1433 hostNames=hostNames,
1434 devices=devices,
1435 ports=None,
1436 ethType="IPV4",
1437 macs=macs,
1438 bandwidth="",
1439 lambdaAlloc=False,
1440 ipProto="",
1441 ipAddresses="",
1442 tcp="",
1443 sw1="s5",
1444 sw2="s2",
1445 expectedLink=18 )
1446
1447 utilities.assert_equals( expect=main.TRUE,
1448 actual=stepResult,
1449 onpass="IPV4: Successfully added single "
1450 + " point to multi point intents" +
1451 " with IPV4 type and MAC addresses",
1452 onfail="IPV4: Failed to add single point"
1453 + " point to multi point intents" +
1454 " with IPV4 type and MAC addresses" )
1455
1456 main.step( "IPV4_2: Add single point to multi point intents" )
1457 stepResult = main.TRUE
1458 hostNames = [ 'h8', 'h16', 'h24' ]
1459 stepResult = main.intentFunction.singleToMultiIntent(
1460 main,
1461 name="IPV4",
1462 hostNames=hostNames,
1463 ethType="IPV4",
1464 lambdaAlloc=False )
1465
1466 utilities.assert_equals( expect=main.TRUE,
1467 actual=stepResult,
1468 onpass="IPV4_2: Successfully added single "
1469 + " point to multi point intents" +
1470 " with IPV4 type and no MAC addresses",
1471 onfail="IPV4_2: Failed to add single point"
1472 + " point to multi point intents" +
1473 " with IPV4 type and no MAC addresses" )
1474
1475 main.step( "VLAN: Add single point to multi point intents" )
1476 stepResult = main.TRUE
1477 hostNames = [ 'h4', 'h12', 'h20' ]
1478 devices = [ 'of:0000000000000005/4', 'of:0000000000000006/4', \
1479 'of:0000000000000007/4' ]
1480 macs = [ '00:00:00:00:00:04', '00:00:00:00:00:0C', '00:00:00:00:00:14' ]
1481 stepResult = main.intentFunction.singleToMultiIntent(
1482 main,
1483 name="VLAN",
1484 hostNames=hostNames,
1485 devices=devices,
1486 ports=None,
1487 ethType="IPV4",
1488 macs=macs,
1489 bandwidth="",
1490 lambdaAlloc=False,
1491 ipProto="",
1492 ipAddresses="",
1493 tcp="",
1494 sw1="s5",
1495 sw2="s2",
1496 expectedLink=18 )
1497
1498 utilities.assert_equals( expect=main.TRUE,
1499 actual=stepResult,
1500 onpass="VLAN: Successfully added single "
1501 + " point to multi point intents" +
1502 " with IPV4 type and MAC addresses" +
1503 " in the same VLAN",
1504 onfail="VLAN: Failed to add single point"
1505 + " point to multi point intents" +
1506 " with IPV4 type and MAC addresses" +
1507 " in the same VLAN")
1508
1509 def CASE4000( self, main ):
1510 """
1511 Add multi point to single point intents
1512 - Get device ids
1513 - Add multi point to single point intents
1514 - Check intents
1515 - Verify flows
1516 - Ping hosts
1517 - Reroute
1518 - Link down
1519 - Verify flows
1520 - Check topology
1521 - Ping hosts
1522 - Link up
1523 - Verify flows
1524 - Check topology
1525 - Ping hosts
1526 - Remove intents
1527 """
1528 assert main, "There is no main"
1529 assert main.CLIs, "There is no main.CLIs"
1530 assert main.Mininet1, "Mininet handle should be named Mininet1"
1531 assert main.numSwitch, "Placed the total number of switch topology in \
1532 main.numSwitch"
1533
1534 main.case( "Multi To Single Point Intents Test - " +
Jeremyeb51cb12016-03-28 17:53:35 -07001535 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -07001536 main.caseExplanation = "This test case will test single point to" +\
1537 " multi point intents using " +\
1538 str( main.numCtrls ) + " node(s) cluster;\n" +\
1539 "Different type of hosts will be tested in " +\
1540 "each step such as IPV4, Dual stack, VLAN etc" +\
1541 ";\nThe test will use OF " + main.OFProtocol +\
Jeremyeb51cb12016-03-28 17:53:35 -07001542 " OVS running in Mininet and compile intents" +\
1543 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001544
1545 main.step( "NOOPTION: Add multi point to single point intents" )
1546 stepResult = main.TRUE
1547 hostNames = [ 'h8', 'h16', 'h24' ]
1548 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
1549 'of:0000000000000007/8' ]
1550 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
1551 stepResult = main.intentFunction.multiToSingleIntent(
1552 main,
1553 name="NOOPTION",
1554 hostNames=hostNames,
1555 devices=devices,
1556 sw1="s5",
1557 sw2="s2",
1558 expectedLink=18 )
1559
1560 utilities.assert_equals( expect=main.TRUE,
1561 actual=stepResult,
1562 onpass="NOOPTION: Successfully added multi "
1563 + " point to single point intents" +
1564 " with no match action",
1565 onfail="NOOPTION: Failed to add multi point" +
1566 " to single point intents" +
1567 " with no match action" )
1568
1569 main.step( "IPV4: Add multi point to single point intents" )
1570 stepResult = main.TRUE
1571 stepResult = main.intentFunction.multiToSingleIntent(
1572 main,
1573 name="IPV4",
1574 hostNames=hostNames,
1575 devices=devices,
1576 ports=None,
1577 ethType="IPV4",
1578 macs=macs,
1579 bandwidth="",
1580 lambdaAlloc=False,
1581 ipProto="",
1582 ipAddresses="",
1583 tcp="",
1584 sw1="s5",
1585 sw2="s2",
1586 expectedLink=18 )
1587
1588 utilities.assert_equals( expect=main.TRUE,
1589 actual=stepResult,
1590 onpass="IPV4: Successfully added multi point"
1591 + " to single point intents" +
1592 " with IPV4 type and MAC addresses",
1593 onfail="IPV4: Failed to add multi point" +
1594 " to single point intents" +
1595 " with IPV4 type and MAC addresses" )
1596
1597 main.step( "IPV4_2: Add multi point to single point intents" )
1598 stepResult = main.TRUE
1599 hostNames = [ 'h8', 'h16', 'h24' ]
1600 stepResult = main.intentFunction.multiToSingleIntent(
1601 main,
1602 name="IPV4",
1603 hostNames=hostNames,
1604 ethType="IPV4",
1605 lambdaAlloc=False )
1606
1607 utilities.assert_equals( expect=main.TRUE,
1608 actual=stepResult,
1609 onpass="IPV4_2: Successfully added multi point"
1610 + " to single point intents" +
1611 " with IPV4 type and no MAC addresses",
1612 onfail="IPV4_2: Failed to add multi point" +
1613 " to single point intents" +
1614 " with IPV4 type and no MAC addresses" )
1615
1616 main.step( "VLAN: Add multi point to single point intents" )
1617 stepResult = main.TRUE
1618 hostNames = [ 'h5', 'h13', 'h21' ]
1619 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \
1620 'of:0000000000000007/5' ]
1621 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
1622 stepResult = main.intentFunction.multiToSingleIntent(
1623 main,
1624 name="VLAN",
1625 hostNames=hostNames,
1626 devices=devices,
1627 ports=None,
1628 ethType="IPV4",
1629 macs=macs,
1630 bandwidth="",
1631 lambdaAlloc=False,
1632 ipProto="",
1633 ipAddresses="",
1634 tcp="",
1635 sw1="s5",
1636 sw2="s2",
1637 expectedLink=18 )
1638
1639 utilities.assert_equals( expect=main.TRUE,
1640 actual=stepResult,
1641 onpass="VLAN: Successfully added multi point"
1642 + " to single point intents" +
1643 " with IPV4 type and MAC addresses" +
1644 " in the same VLAN",
1645 onfail="VLAN: Failed to add multi point" +
1646 " to single point intents" )
1647
1648 def CASE5000( self, main ):
1649 """
Jeremy2f190ca2016-01-29 15:23:57 -08001650 Tests Host Mobility
1651 Modifies the topology location of h1
kelvin-onlab44147802015-07-27 17:57:31 -07001652 """
Jeremydd9bda62016-04-18 12:02:32 -07001653 if main.initialized == main.FALSE:
1654 main.log.error( "Test components did not start correctly, skipping further tests" )
1655 main.skipCase()
1656 # Assert variables - These variable's name|format must be followed
1657 # if you want to use the wrapper function
kelvin-onlab44147802015-07-27 17:57:31 -07001658 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -07001659 try:
1660 assert main.CLIs
1661 except AssertionError:
1662 main.log.error( "There is no main.CLIs, skipping test cases" )
1663 main.initialized = main.FALSE
1664 main.skipCase()
1665 try:
1666 assert main.Mininet1
1667 except AssertionError:
1668 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1669 main.initialized = main.FALSE
1670 main.skipCase()
1671 try:
1672 assert main.numSwitch
1673 except AssertionError:
1674 main.log.error( "Place the total number of switch topology in \
1675 main.numSwitch" )
1676 main.initialized = main.FALSE
1677 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001678 main.case( "Test host mobility with host intents " )
Jeremy2f190ca2016-01-29 15:23:57 -08001679 main.step( "Testing host mobility by moving h1 from s5 to s6" )
kelvin-onlab44147802015-07-27 17:57:31 -07001680 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1681
1682 main.log.info( "Moving h1 from s5 to s6")
kelvin-onlab44147802015-07-27 17:57:31 -07001683 main.Mininet1.moveHost( "h1","s5","s6" )
1684
Jeremy2f190ca2016-01-29 15:23:57 -08001685 # Send discovery ping from moved host
1686 # Moving the host brings down the default interfaces and creates a new one.
1687 # Scapy is restarted on this host to detect the new interface
1688 main.h1.stopScapy()
1689 main.h1.startScapy()
1690
1691 # Discover new host location in ONOS and populate host data.
1692 # Host 1 IP and MAC should be unchanged
1693 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
1694 main.intentFunction.populateHostData( main )
1695
kelvin-onlab44147802015-07-27 17:57:31 -07001696 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1697
1698 utilities.assert_equals( expect="of:0000000000000006",
1699 actual=h1PostMove,
1700 onpass="Mobility: Successfully moved h1 to s6",
Jeremy2f190ca2016-01-29 15:23:57 -08001701 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlab44147802015-07-27 17:57:31 -07001702 " to single point intents" +
1703 " with IPV4 type and MAC addresses" +
1704 " in the same VLAN" )
1705
1706 main.step( "IPV4: Add host intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001707 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
1708 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
1709 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
1710
1711 installResult = main.intentFunction.installHostIntent( main,
1712 name='IPV4 Mobility IPV4',
kelvin-onlab44147802015-07-27 17:57:31 -07001713 onosNode='0',
Jeremy2f190ca2016-01-29 15:23:57 -08001714 host1=host1,
1715 host2=host2)
1716 if installResult:
1717 testResult = main.intentFunction.testHostIntent( main,
1718 name='Host Mobility IPV4',
1719 intentId = installResult,
1720 onosNode='0',
1721 host1=host1,
1722 host2=host2,
1723 sw1="s6",
1724 sw2="s2",
1725 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001726
1727 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001728 actual=testResult,
1729 onpass=main.assertReturnString,
1730 onfail=main.assertReturnString )
1731
1732 main.intentFunction.report( main )
1733