blob: 60fc47f6dbf7ee6f00b56f3533f40d8406bf5402 [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 = []
Jeremye1ea0602016-02-08 16:35:05 -080068 main.CLIs2 = []
kelvin-onlab44147802015-07-27 17:57:31 -070069 main.ONOSip = []
Jeremy2f190ca2016-01-29 15:23:57 -080070 main.scapyHostNames = main.params[ 'SCAPY' ][ 'HOSTNAMES' ].split( ',' )
71 main.scapyHosts = [] # List of scapy hosts for iterating
72 main.assertReturnString = '' # Assembled assert return string
kelvin-onlab44147802015-07-27 17:57:31 -070073
74 main.ONOSip = main.ONOSbench.getOnosIps()
Jeremy2f190ca2016-01-29 15:23:57 -080075 print main.ONOSip
kelvin-onlab44147802015-07-27 17:57:31 -070076
77 # Assigning ONOS cli handles to a list
Jon Hallf7234882015-08-28 13:16:31 -070078 try:
79 for i in range( 1, main.maxNodes + 1 ):
80 main.CLIs.append( getattr( main, 'ONOSrest' + str( i ) ) )
Jeremye1ea0602016-02-08 16:35:05 -080081 main.CLIs2.append( getattr( main, 'ONOScli' + str( i ) ) )
Jon Hallf7234882015-08-28 13:16:31 -070082 except AttributeError:
83 main.log.warn( "A " + str( main.maxNodes ) + " node cluster " +
84 "was defined in env variables, but only " +
85 str( len( main.CLIs ) ) +
86 " nodes were defined in the .topo file. " +
87 "Using " + str( len( main.CLIs ) ) +
88 " nodes for the test." )
kelvin-onlab44147802015-07-27 17:57:31 -070089
90 # -- INIT SECTION, ONLY RUNS ONCE -- #
91 main.startUp = imp.load_source( wrapperFile1,
92 main.dependencyPath +
93 wrapperFile1 +
94 ".py" )
95
96 main.intentFunction = imp.load_source( wrapperFile2,
97 main.dependencyPath +
98 wrapperFile2 +
99 ".py" )
100
101 main.topo = imp.load_source( wrapperFile3,
102 main.dependencyPath +
103 wrapperFile3 +
104 ".py" )
105
Jon Hallf7234882015-08-28 13:16:31 -0700106 copyResult1 = main.ONOSbench.scp( main.Mininet1,
107 main.dependencyPath +
108 main.topology,
Jeremy2f190ca2016-01-29 15:23:57 -0800109 main.Mininet1.home + "custom/",
Jon Hallf7234882015-08-28 13:16:31 -0700110 direction="to" )
Jeremye1ea0602016-02-08 16:35:05 -0800111 if main.CLIs and main.CLIs2:
kelvin-onlab44147802015-07-27 17:57:31 -0700112 stepResult = main.TRUE
113 else:
114 main.log.error( "Did not properly created list of ONOS CLI handle" )
115 stepResult = main.FALSE
116 except Exception as e:
117 main.log.exception(e)
118 main.cleanup()
119 main.exit()
120
121 utilities.assert_equals( expect=main.TRUE,
122 actual=stepResult,
123 onpass="Successfully construct " +
124 "test variables ",
125 onfail="Failed to construct test variables" )
126
127 if gitPull == 'True':
128 main.step( "Building ONOS in " + gitBranch + " branch" )
129 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
130 stepResult = onosBuildResult
131 utilities.assert_equals( expect=main.TRUE,
132 actual=stepResult,
133 onpass="Successfully compiled " +
134 "latest ONOS",
135 onfail="Failed to compile " +
136 "latest ONOS" )
137 else:
138 main.log.warn( "Did not pull new code so skipping mvn " +
139 "clean install" )
140 main.ONOSbench.getVersion( report=True )
141
142 def CASE2( self, main ):
143 """
144 - Set up cell
145 - Create cell file
146 - Set cell file
147 - Verify cell file
148 - Kill ONOS process
149 - Uninstall ONOS cluster
150 - Verify ONOS start up
151 - Install ONOS cluster
152 - Connect to cli
153 """
154
155 # main.scale[ 0 ] determines the current number of ONOS controller
156 main.numCtrls = int( main.scale[ 0 ] )
Jeremyeb51cb12016-03-28 17:53:35 -0700157 main.flowCompiler = "Flow Rules"
Jeremydd9bda62016-04-18 12:02:32 -0700158 main.initialized = main.TRUE
kelvin-onlab44147802015-07-27 17:57:31 -0700159
160 main.case( "Starting up " + str( main.numCtrls ) +
161 " node(s) ONOS cluster" )
162 main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
163 " node(s) ONOS cluster"
164
165
166
167 #kill off all onos processes
168 main.log.info( "Safety check, killing all ONOS processes" +
Jon Hall70b2ff42015-11-17 15:49:44 -0800169 " before initiating environment setup" )
kelvin-onlab44147802015-07-27 17:57:31 -0700170
Jeremy2f190ca2016-01-29 15:23:57 -0800171 time.sleep( main.startUpSleep )
Jeremy42df2e72016-02-23 16:37:46 -0800172
Jeremy2f190ca2016-01-29 15:23:57 -0800173 main.step( "Uninstalling ONOS package" )
174 onosUninstallResult = main.TRUE
175 for ip in main.ONOSip:
176 onosUninstallResult = onosUninstallResult and \
177 main.ONOSbench.onosUninstall( nodeIp=ip )
178 stepResult = onosUninstallResult
179 utilities.assert_equals( expect=main.TRUE,
180 actual=stepResult,
181 onpass="Successfully uninstalled ONOS package",
182 onfail="Failed to uninstall ONOS package" )
183
Jeremy42df2e72016-02-23 16:37:46 -0800184 time.sleep( main.startUpSleep )
185
kelvin-onlab44147802015-07-27 17:57:31 -0700186 for i in range( main.maxNodes ):
187 main.ONOSbench.onosDie( main.ONOSip[ i ] )
188
189 print "NODE COUNT = ", main.numCtrls
190
191 tempOnosIp = []
192 for i in range( main.numCtrls ):
193 tempOnosIp.append( main.ONOSip[i] )
194
195 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
196 "temp", main.Mininet1.ip_address,
197 main.apps, tempOnosIp )
198
199 main.step( "Apply cell to environment" )
200 cellResult = main.ONOSbench.setCell( "temp" )
201 verifyResult = main.ONOSbench.verifyCell()
202 stepResult = cellResult and verifyResult
203 utilities.assert_equals( expect=main.TRUE,
204 actual=stepResult,
205 onpass="Successfully applied cell to " + \
206 "environment",
207 onfail="Failed to apply cell to environment " )
208
209 main.step( "Creating ONOS package" )
210 packageResult = main.ONOSbench.onosPackage()
211 stepResult = packageResult
212 utilities.assert_equals( expect=main.TRUE,
213 actual=stepResult,
214 onpass="Successfully created ONOS package",
215 onfail="Failed to create ONOS package" )
216
217 time.sleep( main.startUpSleep )
kelvin-onlab44147802015-07-27 17:57:31 -0700218 main.step( "Installing ONOS package" )
219 onosInstallResult = main.TRUE
220 for i in range( main.numCtrls ):
221 onosInstallResult = onosInstallResult and \
222 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
223 stepResult = onosInstallResult
224 utilities.assert_equals( expect=main.TRUE,
225 actual=stepResult,
226 onpass="Successfully installed ONOS package",
227 onfail="Failed to install ONOS package" )
228
229 time.sleep( main.startUpSleep )
230 main.step( "Starting ONOS service" )
231 stopResult = main.TRUE
232 startResult = main.TRUE
233 onosIsUp = main.TRUE
234
235 for i in range( main.numCtrls ):
236 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
Jeremydd9bda62016-04-18 12:02:32 -0700237 if onosIsUp == main.TRUE:
238 main.log.report( "ONOS instance {0} is up and ready".format( i + 1 ) )
239 else:
240 main.log.report( "ONOS instance {0} may not be up, stop and ".format( i + 1 ) +
241 "start ONOS again " )
242 stopResult = stopResult and main.ONOSbench.onosStop( main.ONOSip[ i ] )
243 startResult = startResult and main.ONOSbench.onosStart( main.ONOSip[ i ] )
244 if not startResult or stopResult:
245 main.log.report( "ONOS instance {0} did not start correctly.".format( i + 1 ) )
kelvin-onlab44147802015-07-27 17:57:31 -0700246 stepResult = onosIsUp and stopResult and startResult
247 utilities.assert_equals( expect=main.TRUE,
248 actual=stepResult,
249 onpass="ONOS service is ready",
250 onfail="ONOS service did not start properly" )
Jeremydd9bda62016-04-18 12:02:32 -0700251 if not stepResult:
252 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700253
Jeremy2f190ca2016-01-29 15:23:57 -0800254 # Start an ONOS cli to provide functionality that is not currently
Jeremye1ea0602016-02-08 16:35:05 -0800255 # supported by the Rest API remove this when Leader Checking is supported
256 # by the REST API
Jeremy2f190ca2016-01-29 15:23:57 -0800257
Jeremye1ea0602016-02-08 16:35:05 -0800258 main.step( "Start ONOS cli" )
259 cliResult = main.TRUE
260 for i in range( main.numCtrls ):
261 cliResult = cliResult and \
262 main.CLIs2[ i ].startOnosCli( main.ONOSip[ i ] )
263 stepResult = cliResult
264 utilities.assert_equals( expect=main.TRUE,
265 actual=stepResult,
266 onpass="Successfully start ONOS cli",
267 onfail="Failed to start ONOS cli" )
Jeremydd9bda62016-04-18 12:02:32 -0700268 if not stepResult:
269 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800270
kelvin-onlab44147802015-07-27 17:57:31 -0700271 # Remove the first element in main.scale list
272 main.scale.remove( main.scale[ 0 ] )
273
Jeremy2f190ca2016-01-29 15:23:57 -0800274 main.intentFunction.report( main )
275
kelvin-onlab44147802015-07-27 17:57:31 -0700276 def CASE8( self, main ):
Jeremy2f190ca2016-01-29 15:23:57 -0800277 # OLD FUNCintentRest CASE 8
278 # This remains here for archiving and reference purposes and will be
279 # removed when the new FUNCintentRest is verified to work.
280 # """
281 # Compare Topo
282 # """
283 # import json
284
285 # main.case( "Compare ONOS Topology view to Mininet topology" )
286 # main.caseExplanation = "Compare topology elements between Mininet" +\
287 # " and ONOS"
288
289 # main.step( "Gathering topology information" )
290 # # TODO: add a paramaterized sleep here
291 # devicesResults = main.TRUE # Overall Boolean for device correctness
292 # linksResults = main.TRUE # Overall Boolean for link correctness
293 # hostsResults = main.TRUE # Overall Boolean for host correctness
294 # devices = main.topo.getAllDevices( main )
295 # hosts = main.topo.getAllHosts( main )
296 # ports = main.topo.getAllPorts( main )
297 # links = main.topo.getAllLinks( main )
298 # clusters = main.topo.getAllClusters( main )
299
300 # mnSwitches = main.Mininet1.getSwitches()
301 # mnLinks = main.Mininet1.getLinks()
302 # mnHosts = main.Mininet1.getHosts()
303
304 # main.step( "Comparing MN topology to ONOS topology" )
305 # for controller in range( main.numCtrls ):
306 # controllerStr = str( controller + 1 )
307 # if devices[ controller ] and ports[ controller ] and\
308 # "Error" not in devices[ controller ] and\
309 # "Error" not in ports[ controller ]:
310
311 # currentDevicesResult = main.Mininet1.compareSwitches(
312 # mnSwitches,
313 # json.loads( devices[ controller ] ),
314 # json.loads( ports[ controller ] ) )
315 # else:
316 # currentDevicesResult = main.FALSE
317 # utilities.assert_equals( expect=main.TRUE,
318 # actual=currentDevicesResult,
319 # onpass="ONOS" + controllerStr +
320 # " Switches view is correct",
321 # onfail="ONOS" + controllerStr +
322 # " Switches view is incorrect" )
323
324 # if links[ controller ] and "Error" not in links[ controller ]:
325 # currentLinksResult = main.Mininet1.compareLinks(
326 # mnSwitches, mnLinks,
327 # json.loads( links[ controller ] ) )
328 # else:
329 # currentLinksResult = main.FALSE
330 # utilities.assert_equals( expect=main.TRUE,
331 # actual=currentLinksResult,
332 # onpass="ONOS" + controllerStr +
333 # " links view is correct",
334 # onfail="ONOS" + controllerStr +
335 # " links view is incorrect" )
336
337 # if hosts[ controller ] or "Error" not in hosts[ controller ]:
338 # currentHostsResult = main.Mininet1.compareHosts(
339 # mnHosts,
340 # json.loads( hosts[ controller ] ) )
341 # else:
342 # currentHostsResult = main.FALSE
343 # utilities.assert_equals( expect=main.TRUE,
344 # actual=currentHostsResult,
345 # onpass="ONOS" + controllerStr +
346 # " hosts exist in Mininet",
347 # onfail="ONOS" + controllerStr +
348 # " hosts don't match Mininet" )
349
350 # NEW FUNCintentRest Case 8 as based off of the CASE 8 from FUNCintent
kelvin-onlab44147802015-07-27 17:57:31 -0700351 """
Jeremy2f190ca2016-01-29 15:23:57 -0800352 Compare ONOS Topology to Mininet Topology
kelvin-onlab44147802015-07-27 17:57:31 -0700353 """
354 import json
355
356 main.case( "Compare ONOS Topology view to Mininet topology" )
357 main.caseExplanation = "Compare topology elements between Mininet" +\
358 " and ONOS"
359
Jeremy2f190ca2016-01-29 15:23:57 -0800360 main.log.info( "Gathering topology information from Mininet" )
361 devicesResults = main.FALSE # Overall Boolean for device correctness
362 linksResults = main.FALSE # Overall Boolean for link correctness
363 hostsResults = main.FALSE # Overall Boolean for host correctness
364 deviceFails = [] # Nodes where devices are incorrect
365 linkFails = [] # Nodes where links are incorrect
366 hostFails = [] # Nodes where hosts are incorrect
367 attempts = main.checkTopoAttempts # Remaining Attempts
kelvin-onlab44147802015-07-27 17:57:31 -0700368
369 mnSwitches = main.Mininet1.getSwitches()
370 mnLinks = main.Mininet1.getLinks()
371 mnHosts = main.Mininet1.getHosts()
372
Jeremy2f190ca2016-01-29 15:23:57 -0800373 main.step( "Comparing Mininet topology to ONOS topology" )
kelvin-onlab44147802015-07-27 17:57:31 -0700374
Jeremy2f190ca2016-01-29 15:23:57 -0800375 while ( attempts >= 0 ) and\
376 ( not devicesResults or not linksResults or not hostsResults ):
377 time.sleep( 2 )
378 if not devicesResults:
379 devices = main.topo.getAllDevices( main )
380 ports = main.topo.getAllPorts( main )
381 devicesResults = main.TRUE
382 deviceFails = [] # Reset for each failed attempt
383 if not linksResults:
384 links = main.topo.getAllLinks( main )
385 linksResults = main.TRUE
386 linkFails = [] # Reset for each failed attempt
387 if not hostsResults:
388 hosts = main.topo.getAllHosts( main )
389 hostsResults = main.TRUE
390 hostFails = [] # Reset for each failed attempt
kelvin-onlab44147802015-07-27 17:57:31 -0700391
Jeremy2f190ca2016-01-29 15:23:57 -0800392 # Check for matching topology on each node
393 for controller in range( main.numCtrls ):
394 controllerStr = str( controller + 1 ) # ONOS node number
395 # Compare Devices
396 if devices[ controller ] and ports[ controller ] and\
397 "Error" not in devices[ controller ] and\
398 "Error" not in ports[ controller ]:
kelvin-onlab44147802015-07-27 17:57:31 -0700399
Jeremy2f190ca2016-01-29 15:23:57 -0800400 try:
401 deviceData = json.loads( devices[ controller ] )
402 portData = json.loads( ports[ controller ] )
403 except (TypeError,ValueError):
404 main.log.error( "Could not load json: {0} or {1}".format( str( devices[ controller ] ), str( ports[ controller ] ) ) )
405 currentDevicesResult = main.FALSE
406 else:
407 currentDevicesResult = main.Mininet1.compareSwitches(
408 mnSwitches,deviceData,portData )
409 else:
410 currentDevicesResult = main.FALSE
411 if not currentDevicesResult:
412 deviceFails.append( controllerStr )
413 devicesResults = devicesResults and currentDevicesResult
414 # Compare Links
415 if links[ controller ] and "Error" not in links[ controller ]:
416 try:
417 linkData = json.loads( links[ controller ] )
418 except (TypeError,ValueError):
419 main.log.error("Could not load json:" + str( links[ controller ] ) )
420 currentLinksResult = main.FALSE
421 else:
422 currentLinksResult = main.Mininet1.compareLinks(
423 mnSwitches, mnLinks,linkData )
424 else:
425 currentLinksResult = main.FALSE
426 if not currentLinksResult:
427 linkFails.append( controllerStr )
428 linksResults = linksResults and currentLinksResult
429 # Compare Hosts
430 if hosts[ controller ] and "Error" not in hosts[ controller ]:
431 try:
432 hostData = json.loads( hosts[ controller ] )
433 except (TypeError,ValueError):
434 main.log.error("Could not load json:" + str( hosts[ controller ] ) )
435 currentHostsResult = main.FALSE
436 else:
437 currentHostsResult = main.Mininet1.compareHosts(
438 mnHosts,hostData )
439 else:
440 currentHostsResult = main.FALSE
441 if not currentHostsResult:
442 hostFails.append( controllerStr )
443 hostsResults = hostsResults and currentHostsResult
444 # Decrement Attempts Remaining
445 attempts -= 1
446
447
448 utilities.assert_equals( expect=[],
449 actual=deviceFails,
450 onpass="ONOS correctly discovered all devices",
451 onfail="ONOS incorrectly discovered devices on nodes: " +
452 str( deviceFails ) )
453 utilities.assert_equals( expect=[],
454 actual=linkFails,
455 onpass="ONOS correctly discovered all links",
456 onfail="ONOS incorrectly discovered links on nodes: " +
457 str( linkFails ) )
458 utilities.assert_equals( expect=[],
459 actual=hostFails,
460 onpass="ONOS correctly discovered all hosts",
461 onfail="ONOS incorrectly discovered hosts on nodes: " +
462 str( hostFails ) )
463 topoResults = hostsResults and linksResults and devicesResults
464 utilities.assert_equals( expect=main.TRUE,
465 actual=topoResults,
466 onpass="ONOS correctly discovered the topology",
467 onfail="ONOS incorrectly discovered the topology" )
kelvin-onlab44147802015-07-27 17:57:31 -0700468
469 def CASE9( self, main ):
470 '''
471 Report errors/warnings/exceptions
472 '''
473 main.log.info( "Error report: \n" )
474 main.ONOSbench.logReport( globalONOSip[0],
475 [ "INFO", "FOLLOWER", "WARN", "flow", "ERROR" , "Except" ],
476 "s" )
477 #main.ONOSbench.logReport( globalONOSip[1], [ "INFO" ], "d" )
478
479 def CASE10( self, main ):
480 """
481 Start Mininet topology with OF 1.0 switches
482 """
Jeremydd9bda62016-04-18 12:02:32 -0700483 if main.initialized == main.FALSE:
484 main.log.error( "Test components did not start correctly, skipping further tests" )
485 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700486 main.OFProtocol = "1.0"
487 main.log.report( "Start Mininet topology with OF 1.0 switches" )
488 main.case( "Start Mininet topology with OF 1.0 switches" )
489 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
490 "switches to test intents, exits out if " +\
491 "topology did not start correctly"
492
493 main.step( "Starting Mininet topology with OF 1.0 switches" )
494 args = "--switch ovs,protocols=OpenFlow10"
495 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
496 main.topology,
497 args=args )
498 stepResult = topoResult
499 utilities.assert_equals( expect=main.TRUE,
500 actual=stepResult,
501 onpass="Successfully loaded topology",
502 onfail="Failed to load topology" )
503 # Exit if topology did not load properly
504 if not topoResult:
Jeremydd9bda62016-04-18 12:02:32 -0700505 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700506
507 def CASE11( self, main ):
508 """
509 Start Mininet topology with OF 1.3 switches
510 """
Jeremydd9bda62016-04-18 12:02:32 -0700511 if main.initialized == main.FALSE:
512 main.log.error( "Test components did not start correctly, skipping further tests" )
513 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700514 main.OFProtocol = "1.3"
515 main.log.report( "Start Mininet topology with OF 1.3 switches" )
516 main.case( "Start Mininet topology with OF 1.3 switches" )
517 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
518 "switches to test intents, exits out if " +\
519 "topology did not start correctly"
520
521 main.step( "Starting Mininet topology with OF 1.3 switches" )
522 args = "--switch ovs,protocols=OpenFlow13"
523 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
524 main.topology,
525 args=args )
526 stepResult = topoResult
527 utilities.assert_equals( expect=main.TRUE,
528 actual=stepResult,
529 onpass="Successfully loaded topology",
530 onfail="Failed to load topology" )
531 # Exit if topology did not load properly
532 if not topoResult:
Jeremydd9bda62016-04-18 12:02:32 -0700533 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700534
535 def CASE12( self, main ):
536 """
537 Assign mastership to controllers
538 """
539 import re
540
Jeremydd9bda62016-04-18 12:02:32 -0700541 if main.initialized == main.FALSE:
542 main.log.error( "Test components did not start correctly, skipping further tests" )
543 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700544 main.case( "Assign switches to controllers" )
545 main.step( "Assigning switches to controllers" )
546 main.caseExplanation = "Assign OF " + main.OFProtocol +\
547 " switches to ONOS nodes"
548
549 assignResult = main.TRUE
550 switchList = []
551
552 # Creates a list switch name, use getSwitch() function later...
553 for i in range( 1, ( main.numSwitch + 1 ) ):
554 switchList.append( 's' + str( i ) )
555
556 tempONOSip = []
557 for i in range( main.numCtrls ):
558 tempONOSip.append( main.ONOSip[ i ] )
559
560 assignResult = main.Mininet1.assignSwController( sw=switchList,
561 ip=tempONOSip,
Charles Chan029be652015-08-24 01:46:10 +0800562 port='6653' )
kelvin-onlab44147802015-07-27 17:57:31 -0700563 if not assignResult:
Jeremydd9bda62016-04-18 12:02:32 -0700564 main.log.error( "Problem assigning mastership of switches, skipping further test cases" )
565 main.initialized = main.FALSE
566 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700567
568 for i in range( 1, ( main.numSwitch + 1 ) ):
569 response = main.Mininet1.getSwController( "s" + str( i ) )
570 print( "Response is " + str( response ) )
571 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
572 assignResult = assignResult and main.TRUE
573 else:
574 assignResult = main.FALSE
575 stepResult = assignResult
576 utilities.assert_equals( expect=main.TRUE,
577 actual=stepResult,
578 onpass="Successfully assigned switches" +
579 "to controller",
580 onfail="Failed to assign switches to " +
581 "controller" )
Jeremydd9bda62016-04-18 12:02:32 -0700582 if not stepResult:
583 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800584
585 def CASE13( self,main ):
586 """
587 Create Scapy components
588 """
Jeremydd9bda62016-04-18 12:02:32 -0700589 if main.initialized == main.FALSE:
590 main.log.error( "Test components did not start correctly, skipping further tests" )
591 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800592 main.case( "Create scapy components" )
593 main.step( "Create scapy components" )
594 import json
595 scapyResult = main.TRUE
596 for hostName in main.scapyHostNames:
597 main.Scapy1.createHostComponent( hostName )
598 main.scapyHosts.append( getattr( main, hostName ) )
599
600 main.step( "Start scapy components" )
601 for host in main.scapyHosts:
602 host.startHostCli()
603 host.startScapy()
604 host.updateSelf()
605 main.log.debug( host.name )
606 main.log.debug( host.hostIp )
607 main.log.debug( host.hostMac )
608
609
610 utilities.assert_equals( expect=main.TRUE,
611 actual=scapyResult,
612 onpass="Successfully created Scapy Components",
613 onfail="Failed to discover Scapy Components" )
Jeremydd9bda62016-04-18 12:02:32 -0700614 if not scapyResult:
615 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800616
617 def CASE14( self, main ):
kelvin-onlab44147802015-07-27 17:57:31 -0700618 """
619 Discover all hosts and store its data to a dictionary
620 """
Jeremydd9bda62016-04-18 12:02:32 -0700621 if main.initialized == main.FALSE:
622 main.log.error( "Test components did not start correctly, skipping further tests" )
623 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700624 main.case( "Discover all hosts" )
625
626 stepResult = main.TRUE
kelvin-onlab0e684682015-08-11 18:51:41 -0700627 main.step( "Discover all ipv4 host hosts " )
628 hostList = []
629 # List of host with default vlan
630 defaultHosts = [ "h1", "h3", "h8", "h9", "h11", "h16", "h17", "h19", "h24" ]
631 # Lists of host with unique vlan
632 vlanHosts1 = [ "h4", "h12", "h20" ]
633 vlanHosts2 = [ "h5", "h13", "h21" ]
634 vlanHosts3 = [ "h6", "h14", "h22" ]
635 vlanHosts4 = [ "h7", "h15", "h23" ]
636 hostList.append( defaultHosts )
637 hostList.append( vlanHosts1 )
638 hostList.append( vlanHosts2 )
639 hostList.append( vlanHosts3 )
640 hostList.append( vlanHosts4 )
641
642 stepResult = main.intentFunction.getHostsData( main, hostList )
kelvin-onlab44147802015-07-27 17:57:31 -0700643 utilities.assert_equals( expect=main.TRUE,
644 actual=stepResult,
645 onpass="Successfully discovered hosts",
646 onfail="Failed to discover hosts" )
Jeremydd9bda62016-04-18 12:02:32 -0700647 if not stepResult:
648 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700649
Jeremy2f190ca2016-01-29 15:23:57 -0800650 def CASE15( self, main ):
kelvin-onlab44147802015-07-27 17:57:31 -0700651 """
Jeremy2f190ca2016-01-29 15:23:57 -0800652 Discover all hosts with scapy arp packets and store its data to a dictionary
kelvin-onlab44147802015-07-27 17:57:31 -0700653 """
Jeremydd9bda62016-04-18 12:02:32 -0700654 if main.initialized == main.FALSE:
655 main.log.error( "Test components did not start correctly, skipping further tests" )
656 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800657 main.case( "Discover all hosts using scapy" )
658 main.step( "Send packets from each host to the first host and confirm onos discovery" )
659
660 import collections
661 if len( main.scapyHosts ) < 1:
662 main.log.error( "No scapy hosts have been created" )
Jeremydd9bda62016-04-18 12:02:32 -0700663 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800664 main.skipCase()
665
666 # Send ARP packets from each scapy host component
667 main.intentFunction.sendDiscoveryArp( main, main.scapyHosts )
668
669 stepResult = utilities.retry( f=main.intentFunction.confirmHostDiscovery,
670 retValue=main.FALSE, args=[ main ],
671 attempts=main.checkTopoAttempts, sleep=2 )
672
673 utilities.assert_equals( expect=main.TRUE,
674 actual=stepResult,
675 onpass="ONOS correctly discovered all hosts",
676 onfail="ONOS incorrectly discovered hosts" )
Jeremydd9bda62016-04-18 12:02:32 -0700677 if not stepResult:
678 main.initialized = main.FALSE
679 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800680
681 main.step( "Populate hostsData" )
682 stepResult = main.intentFunction.populateHostData( main )
683 utilities.assert_equals( expect=main.TRUE,
684 actual=stepResult,
685 onpass="Successfully populated hostsData",
686 onfail="Failed to populate hostsData" )
Jeremydd9bda62016-04-18 12:02:32 -0700687 if not stepResult:
688 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800689
690 def CASE16( self, main ):
691 """
Jeremy42df2e72016-02-23 16:37:46 -0800692 Balance Masters
693 """
Jeremydd9bda62016-04-18 12:02:32 -0700694 if main.initialized == main.FALSE:
695 main.log.error( "Test components did not start correctly, skipping further tests" )
696 main.skipCase()
Jeremy42df2e72016-02-23 16:37:46 -0800697 main.case( "Balance mastership of switches" )
698 main.step( "Balancing mastership of switches" )
699
700 balanceResult = main.FALSE
701 balanceResult = utilities.retry( f=main.CLIs2[ 0 ].balanceMasters, retValue=main.FALSE, args=[] )
702
703 utilities.assert_equals( expect=main.TRUE,
704 actual=stepResult,
705 onpass="Successfully balanced mastership of switches",
706 onfail="Failed to balance mastership of switches" )
Jeremydd9bda62016-04-18 12:02:32 -0700707 if not stepResult:
708 main.initialized = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800709
710 def CASE17( self, main ):
711 """
Jeremyeb51cb12016-03-28 17:53:35 -0700712 Use Flow Objectives
713 """
Jeremydd9bda62016-04-18 12:02:32 -0700714 if main.initialized == main.FALSE:
715 main.log.error( "Test components did not start correctly, skipping further tests" )
716 main.skipCase()
Jeremyeb51cb12016-03-28 17:53:35 -0700717 main.case( "Enable intent compilation using Flow Objectives" )
718 main.step( "Enabling Flow Objectives" )
719
720 main.flowCompiler = "Flow Objectives"
721
722 cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator"
723
724 stepResult = main.CLIs2[ 0 ].setCfg( component=cmd,
725 propName="useFlowObjectives", value="true" )
726
727 utilities.assert_equals( expect=main.TRUE,
728 actual=stepResult,
729 onpass="Successfully activated Flow Objectives",
730 onfail="Failed to activate Flow Objectives" )
Jeremydd9bda62016-04-18 12:02:32 -0700731 if not stepResult:
732 main.initialized = main.FALSE
Jeremyeb51cb12016-03-28 17:53:35 -0700733
734 def CASE18( self, main ):
735 """
Jeremy2f190ca2016-01-29 15:23:57 -0800736 Stop mininet and remove scapy hosts
737 """
738 main.log.report( "Stop Mininet and Scapy" )
739 main.case( "Stop Mininet and Scapy" )
kelvin-onlab44147802015-07-27 17:57:31 -0700740 main.caseExplanation = "Stopping the current mininet topology " +\
741 "to start up fresh"
742
Jeremy2f190ca2016-01-29 15:23:57 -0800743 main.step( "Stopping and Removing Scapy Host Components" )
744 scapyResult = main.TRUE
745 for host in main.scapyHosts:
746 scapyResult = scapyResult and host.stopScapy()
747 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
748
749 for host in main.scapyHosts:
750 scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
751 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
752
753 main.scapyHosts = []
754 main.scapyHostIPs = []
755
756 utilities.assert_equals( expect=main.TRUE,
757 actual=scapyResult,
758 onpass="Successfully stopped scapy and removed host components",
759 onfail="Failed to stop mininet and scapy" )
760
kelvin-onlab44147802015-07-27 17:57:31 -0700761 main.step( "Stopping Mininet Topology" )
Jeremy2f190ca2016-01-29 15:23:57 -0800762 mininetResult = main.Mininet1.stopNet( )
763
kelvin-onlab44147802015-07-27 17:57:31 -0700764 utilities.assert_equals( expect=main.TRUE,
765 actual=stepResult,
766 onpass="Successfully stop mininet",
767 onfail="Failed to stop mininet" )
768 # Exit if topology did not load properly
Jeremy2f190ca2016-01-29 15:23:57 -0800769 if not (mininetResult and scapyResult ):
kelvin-onlab44147802015-07-27 17:57:31 -0700770 main.cleanup()
771 main.exit()
772
773 def CASE1000( self, main ):
774 """
775 Add host intents between 2 host:
776 - Discover hosts
777 - Add host intents
778 - Check intents
779 - Verify flows
780 - Ping hosts
781 - Reroute
782 - Link down
783 - Verify flows
784 - Check topology
785 - Ping hosts
786 - Link up
787 - Verify flows
788 - Check topology
789 - Ping hosts
790 - Remove intents
791 """
792 import time
793 import json
794 import re
Jeremydd9bda62016-04-18 12:02:32 -0700795 if main.initialized == main.FALSE:
796 main.log.error( "Test components did not start correctly, skipping further tests" )
797 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700798 # Assert variables - These variable's name|format must be followed
799 # if you want to use the wrapper function
800 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -0700801 try:
802 assert main.CLIs
803 except AssertionError:
804 main.log.error( "There is no main.CLIs, skipping test cases" )
805 main.initialized = main.FALSE
806 main.skipCase()
807 try:
808 assert main.Mininet1
809 except AssertionError:
810 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
811 main.initialized = main.FALSE
812 main.skipCase()
813 try:
814 assert main.numSwitch
815 except AssertionError:
816 main.log.error( "Place the total number of switch topology in \
817 main.numSwitch" )
818 main.initialized = main.FALSE
819 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700820
Jeremye1ea0602016-02-08 16:35:05 -0800821 # Save leader candidates
822 intentLeadersOld = main.CLIs2[ 0 ].leaderCandidates()
823
kelvin-onlab44147802015-07-27 17:57:31 -0700824 main.case( "Host Intents Test - " + str( main.numCtrls ) +
Jeremyeb51cb12016-03-28 17:53:35 -0700825 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -0700826 main.caseExplanation = "This test case tests Host intents using " +\
827 str( main.numCtrls ) + " node(s) cluster;\n" +\
828 "Different type of hosts will be tested in " +\
829 "each step such as IPV4, Dual stack, VLAN " +\
Jeremyeb51cb12016-03-28 17:53:35 -0700830 "etc;\nThe test will use OF " + main.OFProtocol +\
831 " OVS running in Mininet and compile intents" +\
832 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -0700833
Jeremy2f190ca2016-01-29 15:23:57 -0800834 main.step( "IPV4: Add and test host intents between h1 and h9" )
835 main.assertReturnString = "Assertion result for IPV4 host intent with mac addresses\n"
836 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
837 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
838 testResult = main.FALSE
839 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlab44147802015-07-27 17:57:31 -0700840 name='IPV4',
Jeremy2f190ca2016-01-29 15:23:57 -0800841 onosNode='0',
842 host1=host1,
843 host2=host2 )
844
845 if installResult:
846 testResult = main.intentFunction.testHostIntent( main,
847 name='IPV4',
848 intentId = installResult,
849 onosNode='0',
850 host1=host1,
851 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700852 sw1='s5',
853 sw2='s2',
Jeremy2f190ca2016-01-29 15:23:57 -0800854 expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700855
856 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800857 actual=testResult,
858 onpass=main.assertReturnString,
859 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700860
861 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800862 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
863 host1 = { "name":"h3", "id":"00:00:00:00:00:03/-1" }
864 host2 = { "name":"h11","id":"00:00:00:00:00:0B/-1"}
865 testResult = main.FALSE
866 installResult = main.intentFunction.installHostIntent( main,
867 name='DUALSTACK1',
868 onosNode='0',
869 host1=host1,
870 host2=host2 )
871
872 if installResult:
873 testResult = main.intentFunction.testHostIntent( main,
874 name='DUALSTACK1',
875 intentId = installResult,
876 onosNode='0',
877 host1=host1,
878 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700879 sw1='s5',
880 sw2='s2',
Jeremy2f190ca2016-01-29 15:23:57 -0800881 expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700882
883 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800884 actual=testResult,
885 onpass=main.assertReturnString,
886 onfail=main.assertReturnString)
kelvin-onlab44147802015-07-27 17:57:31 -0700887
888 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800889 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
890 host1 = { "name":"h1" }
891 host2 = { "name":"h11" }
892 testResult = main.FALSE
893 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlab44147802015-07-27 17:57:31 -0700894 name='DUALSTACK2',
Jeremy2f190ca2016-01-29 15:23:57 -0800895 onosNode='0',
896 host1=host1,
897 host2=host2 )
898
899 if installResult:
900 testResult = main.intentFunction.testHostIntent( main,
901 name='DUALSTACK2',
902 intentId = installResult,
903 onosNode='0',
904 host1=host1,
905 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700906 sw1='s5',
907 sw2='s2',
Jeremy2f190ca2016-01-29 15:23:57 -0800908 expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700909
910 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800911 actual=testResult,
912 onpass=main.assertReturnString,
913 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700914
915 main.step( "1HOP: Add host intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -0800916 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
917 host1 = { "name":"h1" }
918 host2 = { "name":"h3" }
919 testResult = main.FALSE
920 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlab44147802015-07-27 17:57:31 -0700921 name='1HOP',
Jeremy2f190ca2016-01-29 15:23:57 -0800922 onosNode='0',
923 host1=host1,
924 host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700925
Jeremy2f190ca2016-01-29 15:23:57 -0800926 if installResult:
927 testResult = main.intentFunction.testHostIntent( main,
928 name='1HOP',
929 intentId = installResult,
930 onosNode='0',
931 host1=host1,
932 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700933 sw1='s5',
934 sw2='s2',
Jeremy2f190ca2016-01-29 15:23:57 -0800935 expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700936
937 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800938 actual=testResult,
939 onpass=main.assertReturnString,
940 onfail=main.assertReturnString )
941
942 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
943 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700944 host1 = { "name":"h4","id":"00:00:00:00:00:04/100", "vlanId":"100" }
945 host2 = { "name":"h12","id":"00:00:00:00:00:0C/100", "vlanId":"100" }
Jeremy2f190ca2016-01-29 15:23:57 -0800946 testResult = main.FALSE
947 installResult = main.intentFunction.installHostIntent( main,
948 name='VLAN1',
949 onosNode='0',
950 host1=host1,
951 host2=host2 )
952
953 if installResult:
954 testResult = main.intentFunction.testHostIntent( main,
955 name='VLAN1',
956 intentId = installResult,
957 onosNode='0',
958 host1=host1,
959 host2=host2,
960 sw1='s5',
961 sw2='s2',
962 expectedLink = 18 )
963
964 utilities.assert_equals( expect=main.TRUE,
965 actual=testResult,
966 onpass=main.assertReturnString,
967 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700968
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700969 # This step isn't currently possible to perform in the REST API
970 # main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
971 # main.assertReturnString = "Assertion Result different VLAN negative test\n"
972 # host1 = { "name":"h13" }
973 # host2 = { "name":"h20" }
974 # testResult = main.FALSE
975 # installResult = main.intentFunction.installHostIntent( main,
976 # name='VLAN2',
977 # onosNode='0',
978 # host1=host1,
979 # host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700980
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700981 # if installResult:
982 # testResult = main.intentFunction.testHostIntent( main,
983 # name='VLAN2',
984 # intentId = installResult,
985 # onosNode='0',
986 # host1=host1,
987 # host2=host2,
988 # sw1='s5',
989 # sw2='s2',
990 # expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700991
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700992 # utilities.assert_equals( expect=main.TRUE,
993 # actual=testResult,
994 # onpass=main.assertReturnString,
995 # onfail=main.assertReturnString )
Jeremy2f190ca2016-01-29 15:23:57 -0800996
Jeremye1ea0602016-02-08 16:35:05 -0800997 # Change the following to use the REST API when leader checking is
998 # supported by it
Jeremy2f190ca2016-01-29 15:23:57 -0800999
Jeremye1ea0602016-02-08 16:35:05 -08001000 main.step( "Confirm that ONOS leadership is unchanged")
1001 intentLeadersNew = main.CLIs2[ 0 ].leaderCandidates()
1002 main.intentFunction.checkLeaderChange( intentLeadersOld,
1003 intentLeadersNew )
Jeremy2f190ca2016-01-29 15:23:57 -08001004
Jeremye1ea0602016-02-08 16:35:05 -08001005 utilities.assert_equals( expect=main.TRUE,
1006 actual=testResult,
1007 onpass="ONOS Leaders Unchanged",
1008 onfail="ONOS Leader Mismatch")
Jeremy2f190ca2016-01-29 15:23:57 -08001009
1010 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001011
1012 def CASE2000( self, main ):
1013 """
1014 Add point intents between 2 hosts:
1015 - Get device ids | ports
1016 - Add point intents
1017 - Check intents
1018 - Verify flows
1019 - Ping hosts
1020 - Reroute
1021 - Link down
1022 - Verify flows
1023 - Check topology
1024 - Ping hosts
1025 - Link up
1026 - Verify flows
1027 - Check topology
1028 - Ping hosts
1029 - Remove intents
1030 """
1031 import time
1032 import json
1033 import re
Jeremydd9bda62016-04-18 12:02:32 -07001034 if main.initialized == main.FALSE:
1035 main.log.error( "Test components did not start correctly, skipping further tests" )
1036 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001037 # Assert variables - These variable's name|format must be followed
1038 # if you want to use the wrapper function
1039 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -07001040 try:
1041 assert main.CLIs
1042 except AssertionError:
1043 main.log.error( "There is no main.CLIs, skipping test cases" )
1044 main.initialized = main.FALSE
1045 main.skipCase()
1046 try:
1047 assert main.Mininet1
1048 except AssertionError:
1049 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1050 main.initialized = main.FALSE
1051 main.skipCase()
1052 try:
1053 assert main.numSwitch
1054 except AssertionError:
1055 main.log.error( "Place the total number of switch topology in \
1056 main.numSwitch" )
1057 main.initialized = main.FALSE
1058 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001059
1060 main.case( "Point Intents Test - " + str( main.numCtrls ) +
Jeremyeb51cb12016-03-28 17:53:35 -07001061 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -07001062 main.caseExplanation = "This test case will test point to point" +\
1063 " intents using " + str( main.numCtrls ) +\
1064 " node(s) cluster;\n" +\
1065 "Different type of hosts will be tested in " +\
1066 "each step such as IPV4, Dual stack, VLAN etc" +\
1067 ";\nThe test will use OF " + main.OFProtocol +\
Jeremyeb51cb12016-03-28 17:53:35 -07001068 " OVS running in Mininet and compile intents" +\
1069 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001070
1071 # No option point intents
1072 main.step( "NOOPTION: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001073 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
1074 senders = [
1075 { "name":"h1","device":"of:0000000000000005/1" }
1076 ]
1077 recipients = [
1078 { "name":"h9","device":"of:0000000000000006/1" }
1079 ]
1080 testResult = main.FALSE
1081 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001082 main,
1083 name="NOOPTION",
Jeremy2f190ca2016-01-29 15:23:57 -08001084 senders=senders,
1085 recipients=recipients )
1086
1087 if installResult:
1088 testResult = main.intentFunction.testPointIntent(
1089 main,
1090 intentId=installResult,
1091 name="NOOPTION",
1092 senders=senders,
1093 recipients=recipients,
1094 sw1="s5",
1095 sw2="s2",
1096 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001097
1098 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001099 actual=testResult,
1100 onpass=main.assertReturnString,
1101 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001102
kelvin-onlab44147802015-07-27 17:57:31 -07001103 main.step( "IPV4: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001104 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
1105 senders = [
1106 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1107 ]
1108 recipients = [
1109 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09" }
1110 ]
1111 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001112 main,
1113 name="IPV4",
Jeremy2f190ca2016-01-29 15:23:57 -08001114 senders=senders,
1115 recipients=recipients,
1116 ethType="IPV4" )
1117
1118 if installResult:
1119 testResult = main.intentFunction.testPointIntent(
1120 main,
1121 intentId=installResult,
1122 name="IPV4",
1123 senders=senders,
1124 recipients=recipients,
1125 sw1="s5",
1126 sw2="s2",
1127 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001128
1129 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001130 actual=testResult,
1131 onpass=main.assertReturnString,
1132 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001133 main.step( "IPV4_2: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001134 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
1135 senders = [
1136 { "name":"h1","device":"of:0000000000000005/1" }
1137 ]
1138 recipients = [
1139 { "name":"h9","device":"of:0000000000000006/1" }
1140 ]
1141 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001142 main,
1143 name="IPV4_2",
Jeremy2f190ca2016-01-29 15:23:57 -08001144 senders=senders,
1145 recipients=recipients,
1146 ethType="IPV4" )
1147
1148 if installResult:
1149 testResult = main.intentFunction.testPointIntent(
1150 main,
1151 intentId=installResult,
1152 name="IPV4_2",
1153 senders=senders,
1154 recipients=recipients,
1155 sw1="s5",
1156 sw2="s2",
1157 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001158
1159 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001160 actual=testResult,
1161 onpass=main.assertReturnString,
1162 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001163
kelvin-onlab0e684682015-08-11 18:51:41 -07001164 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001165 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
1166 senders = [
1167 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01",
1168 "ip":main.h1.hostIp }
1169 ]
1170 recipients = [
1171 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09",
1172 "ip":main.h9.hostIp }
1173 ]
kelvin-onlab44147802015-07-27 17:57:31 -07001174 ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
1175 # Uneccessary, not including this in the selectors
Jeremy2f190ca2016-01-29 15:23:57 -08001176 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
1177 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
kelvin-onlab44147802015-07-27 17:57:31 -07001178
Jeremy2f190ca2016-01-29 15:23:57 -08001179 installResult = main.intentFunction.installPointIntent(
1180 main,
1181 name="SDNIP-ICMP",
1182 senders=senders,
1183 recipients=recipients,
1184 ethType="IPV4",
1185 ipProto=ipProto,
1186 tcpSrc=tcpSrc,
1187 tcpDst=tcpDst )
1188
1189 if installResult:
1190 testResult = main.intentFunction.testPointIntent(
1191 main,
1192 intentId=installResult,
1193 name="SDNIP_ICMP",
1194 senders=senders,
1195 recipients=recipients,
1196 sw1="s5",
1197 sw2="s2",
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001198 expectedLink=18,
1199 useTCP=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001200
1201 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001202 actual=testResult,
1203 onpass=main.assertReturnString,
1204 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001205
kelvin-onlab0e684682015-08-11 18:51:41 -07001206 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001207 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
kelvin-onlab44147802015-07-27 17:57:31 -07001208 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
1209 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab0e684682015-08-11 18:51:41 -07001210 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
1211 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlab44147802015-07-27 17:57:31 -07001212 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
1213 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
1214 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
1215
kelvin-onlab0e684682015-08-11 18:51:41 -07001216 stepResult = main.intentFunction.pointIntentTcp(
kelvin-onlab44147802015-07-27 17:57:31 -07001217 main,
kelvin-onlab0e684682015-08-11 18:51:41 -07001218 name="SDNIP-TCP",
kelvin-onlab44147802015-07-27 17:57:31 -07001219 host1="h1",
1220 host2="h9",
1221 deviceId1="of:0000000000000005/1",
1222 deviceId2="of:0000000000000006/1",
1223 mac1=mac1,
1224 mac2=mac2,
1225 ethType="IPV4",
kelvin-onlab0e684682015-08-11 18:51:41 -07001226 ipProto=ipProto,
1227 ip1=ip1,
1228 ip2=ip2,
1229 tcp1=tcp1,
1230 tcp2=tcp2 )
kelvin-onlab44147802015-07-27 17:57:31 -07001231
1232 utilities.assert_equals( expect=main.TRUE,
1233 actual=stepResult,
Jeremy2f190ca2016-01-29 15:23:57 -08001234 onpass=main.assertReturnString,
1235 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001236
Jeremy2f190ca2016-01-29 15:23:57 -08001237 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
1238 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
1239 senders = [
1240 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1241 ]
1242 recipients = [
1243 { "name":"h11","device":"of:0000000000000006/3","mac":"00:00:00:00:00:0B" }
1244 ]
1245 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001246 main,
1247 name="DUALSTACK1",
Jeremy2f190ca2016-01-29 15:23:57 -08001248 senders=senders,
1249 recipients=recipients,
1250 ethType="IPV4" )
1251
1252 if installResult:
1253 testResult = main.intentFunction.testPointIntent(
1254 main,
1255 intentId=installResult,
1256 name="DUALSTACK1",
1257 senders=senders,
1258 recipients=recipients,
1259 sw1="s5",
1260 sw2="s2",
1261 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001262
1263 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001264 actual=testResult,
1265 onpass=main.assertReturnString,
1266 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001267
1268 main.step( "VLAN: Add point intents between h5 and h21" )
Jeremy2f190ca2016-01-29 15:23:57 -08001269 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
1270 senders = [
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001271 { "name":"h5","device":"of:0000000000000005/5","mac":"00:00:00:00:00:05", "vlanId":"200" }
Jeremy2f190ca2016-01-29 15:23:57 -08001272 ]
1273 recipients = [
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001274 { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15", "vlanId":"200" }
Jeremy2f190ca2016-01-29 15:23:57 -08001275 ]
1276 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001277 main,
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001278 name="VLAN",
Jeremy2f190ca2016-01-29 15:23:57 -08001279 senders=senders,
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001280 recipients=recipients )
Jeremy2f190ca2016-01-29 15:23:57 -08001281
1282 if installResult:
1283 testResult = main.intentFunction.testPointIntent(
1284 main,
1285 intentId=installResult,
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001286 name="VLAN",
Jeremy2f190ca2016-01-29 15:23:57 -08001287 senders=senders,
1288 recipients=recipients,
1289 sw1="s5",
1290 sw2="s2",
1291 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001292
1293 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001294 actual=testResult,
1295 onpass=main.assertReturnString,
1296 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001297
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001298 # TODO: implement VLAN selector REST API intent test once supported
1299
kelvin-onlab44147802015-07-27 17:57:31 -07001300 main.step( "1HOP: Add point intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -08001301 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
1302 senders = [
1303 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1304 ]
1305 recipients = [
1306 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1307 ]
1308 installResult = main.intentFunction.installPointIntent(
1309 main,
1310 name="1HOP IPV4",
1311 senders=senders,
1312 recipients=recipients,
1313 ethType="IPV4" )
1314
1315 if installResult:
1316 testResult = main.intentFunction.testPointIntent(
1317 main,
1318 intentId=installResult,
1319 name="1HOP IPV4",
1320 senders=senders,
1321 recipients=recipients,
1322 sw1="s5",
1323 sw2="s2",
1324 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001325
1326 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001327 actual=testResult,
1328 onpass=main.assertReturnString,
1329 onfail=main.assertReturnString )
1330
1331 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001332
1333 def CASE3000( self, main ):
1334 """
1335 Add single point to multi point intents
1336 - Get device ids
1337 - Add single point to multi point intents
1338 - Check intents
1339 - Verify flows
1340 - Ping hosts
1341 - Reroute
1342 - Link down
1343 - Verify flows
1344 - Check topology
1345 - Ping hosts
1346 - Link up
1347 - Verify flows
1348 - Check topology
1349 - Ping hosts
1350 - Remove intents
1351 """
1352 assert main, "There is no main"
1353 assert main.CLIs, "There is no main.CLIs"
1354 assert main.Mininet1, "Mininet handle should be named Mininet1"
1355 assert main.numSwitch, "Placed the total number of switch topology in \
1356 main.numSwitch"
1357
1358 main.case( "Single To Multi Point Intents Test - " +
Jeremyeb51cb12016-03-28 17:53:35 -07001359 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -07001360 main.caseExplanation = "This test case will test single point to" +\
1361 " multi point intents using " +\
1362 str( main.numCtrls ) + " node(s) cluster;\n" +\
1363 "Different type of hosts will be tested in " +\
1364 "each step such as IPV4, Dual stack, VLAN etc" +\
1365 ";\nThe test will use OF " + main.OFProtocol +\
Jeremyeb51cb12016-03-28 17:53:35 -07001366 " OVS running in Mininet and compile intents" +\
1367 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001368
1369 main.step( "NOOPTION: Add single point to multi point intents" )
1370 stepResult = main.TRUE
1371 hostNames = [ 'h8', 'h16', 'h24' ]
1372 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
1373 'of:0000000000000007/8' ]
1374 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
1375 stepResult = main.intentFunction.singleToMultiIntent(
1376 main,
1377 name="NOOPTION",
1378 hostNames=hostNames,
1379 devices=devices,
1380 sw1="s5",
1381 sw2="s2",
1382 expectedLink=18 )
1383
1384 utilities.assert_equals( expect=main.TRUE,
1385 actual=stepResult,
1386 onpass="NOOPTION: Successfully added single "
1387 + " point to multi point intents" +
1388 " with no match action",
1389 onfail="NOOPTION: Failed to add single point"
1390 + " point to multi point intents" +
1391 " with no match action" )
1392
1393 main.step( "IPV4: Add single point to multi point intents" )
1394 stepResult = main.TRUE
1395 stepResult = main.intentFunction.singleToMultiIntent(
1396 main,
1397 name="IPV4",
1398 hostNames=hostNames,
1399 devices=devices,
1400 ports=None,
1401 ethType="IPV4",
1402 macs=macs,
1403 bandwidth="",
1404 lambdaAlloc=False,
1405 ipProto="",
1406 ipAddresses="",
1407 tcp="",
1408 sw1="s5",
1409 sw2="s2",
1410 expectedLink=18 )
1411
1412 utilities.assert_equals( expect=main.TRUE,
1413 actual=stepResult,
1414 onpass="IPV4: Successfully added single "
1415 + " point to multi point intents" +
1416 " with IPV4 type and MAC addresses",
1417 onfail="IPV4: Failed to add single point"
1418 + " point to multi point intents" +
1419 " with IPV4 type and MAC addresses" )
1420
1421 main.step( "IPV4_2: Add single point to multi point intents" )
1422 stepResult = main.TRUE
1423 hostNames = [ 'h8', 'h16', 'h24' ]
1424 stepResult = main.intentFunction.singleToMultiIntent(
1425 main,
1426 name="IPV4",
1427 hostNames=hostNames,
1428 ethType="IPV4",
1429 lambdaAlloc=False )
1430
1431 utilities.assert_equals( expect=main.TRUE,
1432 actual=stepResult,
1433 onpass="IPV4_2: Successfully added single "
1434 + " point to multi point intents" +
1435 " with IPV4 type and no MAC addresses",
1436 onfail="IPV4_2: Failed to add single point"
1437 + " point to multi point intents" +
1438 " with IPV4 type and no MAC addresses" )
1439
1440 main.step( "VLAN: Add single point to multi point intents" )
1441 stepResult = main.TRUE
1442 hostNames = [ 'h4', 'h12', 'h20' ]
1443 devices = [ 'of:0000000000000005/4', 'of:0000000000000006/4', \
1444 'of:0000000000000007/4' ]
1445 macs = [ '00:00:00:00:00:04', '00:00:00:00:00:0C', '00:00:00:00:00:14' ]
1446 stepResult = main.intentFunction.singleToMultiIntent(
1447 main,
1448 name="VLAN",
1449 hostNames=hostNames,
1450 devices=devices,
1451 ports=None,
1452 ethType="IPV4",
1453 macs=macs,
1454 bandwidth="",
1455 lambdaAlloc=False,
1456 ipProto="",
1457 ipAddresses="",
1458 tcp="",
1459 sw1="s5",
1460 sw2="s2",
1461 expectedLink=18 )
1462
1463 utilities.assert_equals( expect=main.TRUE,
1464 actual=stepResult,
1465 onpass="VLAN: Successfully added single "
1466 + " point to multi point intents" +
1467 " with IPV4 type and MAC addresses" +
1468 " in the same VLAN",
1469 onfail="VLAN: Failed to add single point"
1470 + " point to multi point intents" +
1471 " with IPV4 type and MAC addresses" +
1472 " in the same VLAN")
1473
1474 def CASE4000( self, main ):
1475 """
1476 Add multi point to single point intents
1477 - Get device ids
1478 - Add multi point to single point intents
1479 - Check intents
1480 - Verify flows
1481 - Ping hosts
1482 - Reroute
1483 - Link down
1484 - Verify flows
1485 - Check topology
1486 - Ping hosts
1487 - Link up
1488 - Verify flows
1489 - Check topology
1490 - Ping hosts
1491 - Remove intents
1492 """
1493 assert main, "There is no main"
1494 assert main.CLIs, "There is no main.CLIs"
1495 assert main.Mininet1, "Mininet handle should be named Mininet1"
1496 assert main.numSwitch, "Placed the total number of switch topology in \
1497 main.numSwitch"
1498
1499 main.case( "Multi To Single Point Intents Test - " +
Jeremyeb51cb12016-03-28 17:53:35 -07001500 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -07001501 main.caseExplanation = "This test case will test single point to" +\
1502 " multi point intents using " +\
1503 str( main.numCtrls ) + " node(s) cluster;\n" +\
1504 "Different type of hosts will be tested in " +\
1505 "each step such as IPV4, Dual stack, VLAN etc" +\
1506 ";\nThe test will use OF " + main.OFProtocol +\
Jeremyeb51cb12016-03-28 17:53:35 -07001507 " OVS running in Mininet and compile intents" +\
1508 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001509
1510 main.step( "NOOPTION: Add multi point to single point intents" )
1511 stepResult = main.TRUE
1512 hostNames = [ 'h8', 'h16', 'h24' ]
1513 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
1514 'of:0000000000000007/8' ]
1515 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
1516 stepResult = main.intentFunction.multiToSingleIntent(
1517 main,
1518 name="NOOPTION",
1519 hostNames=hostNames,
1520 devices=devices,
1521 sw1="s5",
1522 sw2="s2",
1523 expectedLink=18 )
1524
1525 utilities.assert_equals( expect=main.TRUE,
1526 actual=stepResult,
1527 onpass="NOOPTION: Successfully added multi "
1528 + " point to single point intents" +
1529 " with no match action",
1530 onfail="NOOPTION: Failed to add multi point" +
1531 " to single point intents" +
1532 " with no match action" )
1533
1534 main.step( "IPV4: Add multi point to single point intents" )
1535 stepResult = main.TRUE
1536 stepResult = main.intentFunction.multiToSingleIntent(
1537 main,
1538 name="IPV4",
1539 hostNames=hostNames,
1540 devices=devices,
1541 ports=None,
1542 ethType="IPV4",
1543 macs=macs,
1544 bandwidth="",
1545 lambdaAlloc=False,
1546 ipProto="",
1547 ipAddresses="",
1548 tcp="",
1549 sw1="s5",
1550 sw2="s2",
1551 expectedLink=18 )
1552
1553 utilities.assert_equals( expect=main.TRUE,
1554 actual=stepResult,
1555 onpass="IPV4: Successfully added multi point"
1556 + " to single point intents" +
1557 " with IPV4 type and MAC addresses",
1558 onfail="IPV4: Failed to add multi point" +
1559 " to single point intents" +
1560 " with IPV4 type and MAC addresses" )
1561
1562 main.step( "IPV4_2: Add multi point to single point intents" )
1563 stepResult = main.TRUE
1564 hostNames = [ 'h8', 'h16', 'h24' ]
1565 stepResult = main.intentFunction.multiToSingleIntent(
1566 main,
1567 name="IPV4",
1568 hostNames=hostNames,
1569 ethType="IPV4",
1570 lambdaAlloc=False )
1571
1572 utilities.assert_equals( expect=main.TRUE,
1573 actual=stepResult,
1574 onpass="IPV4_2: Successfully added multi point"
1575 + " to single point intents" +
1576 " with IPV4 type and no MAC addresses",
1577 onfail="IPV4_2: Failed to add multi point" +
1578 " to single point intents" +
1579 " with IPV4 type and no MAC addresses" )
1580
1581 main.step( "VLAN: Add multi point to single point intents" )
1582 stepResult = main.TRUE
1583 hostNames = [ 'h5', 'h13', 'h21' ]
1584 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \
1585 'of:0000000000000007/5' ]
1586 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
1587 stepResult = main.intentFunction.multiToSingleIntent(
1588 main,
1589 name="VLAN",
1590 hostNames=hostNames,
1591 devices=devices,
1592 ports=None,
1593 ethType="IPV4",
1594 macs=macs,
1595 bandwidth="",
1596 lambdaAlloc=False,
1597 ipProto="",
1598 ipAddresses="",
1599 tcp="",
1600 sw1="s5",
1601 sw2="s2",
1602 expectedLink=18 )
1603
1604 utilities.assert_equals( expect=main.TRUE,
1605 actual=stepResult,
1606 onpass="VLAN: Successfully added multi point"
1607 + " to single point intents" +
1608 " with IPV4 type and MAC addresses" +
1609 " in the same VLAN",
1610 onfail="VLAN: Failed to add multi point" +
1611 " to single point intents" )
1612
1613 def CASE5000( self, main ):
1614 """
Jeremy2f190ca2016-01-29 15:23:57 -08001615 Tests Host Mobility
1616 Modifies the topology location of h1
kelvin-onlab44147802015-07-27 17:57:31 -07001617 """
Jeremydd9bda62016-04-18 12:02:32 -07001618 if main.initialized == main.FALSE:
1619 main.log.error( "Test components did not start correctly, skipping further tests" )
1620 main.skipCase()
1621 # Assert variables - These variable's name|format must be followed
1622 # if you want to use the wrapper function
kelvin-onlab44147802015-07-27 17:57:31 -07001623 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -07001624 try:
1625 assert main.CLIs
1626 except AssertionError:
1627 main.log.error( "There is no main.CLIs, skipping test cases" )
1628 main.initialized = main.FALSE
1629 main.skipCase()
1630 try:
1631 assert main.Mininet1
1632 except AssertionError:
1633 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1634 main.initialized = main.FALSE
1635 main.skipCase()
1636 try:
1637 assert main.numSwitch
1638 except AssertionError:
1639 main.log.error( "Place the total number of switch topology in \
1640 main.numSwitch" )
1641 main.initialized = main.FALSE
1642 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001643 main.case( "Test host mobility with host intents " )
Jeremy2f190ca2016-01-29 15:23:57 -08001644 main.step( "Testing host mobility by moving h1 from s5 to s6" )
kelvin-onlab44147802015-07-27 17:57:31 -07001645 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1646
1647 main.log.info( "Moving h1 from s5 to s6")
kelvin-onlab44147802015-07-27 17:57:31 -07001648 main.Mininet1.moveHost( "h1","s5","s6" )
1649
Jeremy2f190ca2016-01-29 15:23:57 -08001650 # Send discovery ping from moved host
1651 # Moving the host brings down the default interfaces and creates a new one.
1652 # Scapy is restarted on this host to detect the new interface
1653 main.h1.stopScapy()
1654 main.h1.startScapy()
1655
1656 # Discover new host location in ONOS and populate host data.
1657 # Host 1 IP and MAC should be unchanged
1658 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
1659 main.intentFunction.populateHostData( main )
1660
kelvin-onlab44147802015-07-27 17:57:31 -07001661 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1662
1663 utilities.assert_equals( expect="of:0000000000000006",
1664 actual=h1PostMove,
1665 onpass="Mobility: Successfully moved h1 to s6",
Jeremy2f190ca2016-01-29 15:23:57 -08001666 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlab44147802015-07-27 17:57:31 -07001667 " to single point intents" +
1668 " with IPV4 type and MAC addresses" +
1669 " in the same VLAN" )
1670
1671 main.step( "IPV4: Add host intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001672 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
1673 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
1674 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
1675
1676 installResult = main.intentFunction.installHostIntent( main,
1677 name='IPV4 Mobility IPV4',
kelvin-onlab44147802015-07-27 17:57:31 -07001678 onosNode='0',
Jeremy2f190ca2016-01-29 15:23:57 -08001679 host1=host1,
1680 host2=host2)
1681 if installResult:
1682 testResult = main.intentFunction.testHostIntent( main,
1683 name='Host Mobility IPV4',
1684 intentId = installResult,
1685 onosNode='0',
1686 host1=host1,
1687 host2=host2,
1688 sw1="s6",
1689 sw2="s2",
1690 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001691
1692 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001693 actual=testResult,
1694 onpass=main.assertReturnString,
1695 onfail=main.assertReturnString )
1696
1697 main.intentFunction.report( main )
1698