blob: f48ae3ba8e0e9bb5241c4e5c3a8bf29609a022bd [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"
944 host1 = { "name":"h4","id":"00:00:00:00:00:04/100" }
945 host2 = { "name":"h12","id":"00:00:00:00:00:0C/100" }
946 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
969 main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
Jeremy2f190ca2016-01-29 15:23:57 -0800970 main.assertReturnString = "Assertion Result different VLAN negative test\n"
971 host1 = { "name":"h13" }
972 host2 = { "name":"h20" }
973 testResult = main.FALSE
974 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlab44147802015-07-27 17:57:31 -0700975 name='VLAN2',
Jeremy2f190ca2016-01-29 15:23:57 -0800976 onosNode='0',
977 host1=host1,
978 host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700979
Jeremy2f190ca2016-01-29 15:23:57 -0800980 if installResult:
981 testResult = main.intentFunction.testHostIntent( main,
982 name='VLAN2',
983 intentId = installResult,
984 onosNode='0',
985 host1=host1,
986 host2=host2,
987 sw1='s5',
988 sw2='s2',
989 expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700990
Jeremy2f190ca2016-01-29 15:23:57 -0800991 utilities.assert_equals( expect=main.TRUE,
992 actual=testResult,
993 onpass=main.assertReturnString,
994 onfail=main.assertReturnString )
995
Jeremye1ea0602016-02-08 16:35:05 -0800996 # Change the following to use the REST API when leader checking is
997 # supported by it
Jeremy2f190ca2016-01-29 15:23:57 -0800998
Jeremye1ea0602016-02-08 16:35:05 -0800999 main.step( "Confirm that ONOS leadership is unchanged")
1000 intentLeadersNew = main.CLIs2[ 0 ].leaderCandidates()
1001 main.intentFunction.checkLeaderChange( intentLeadersOld,
1002 intentLeadersNew )
Jeremy2f190ca2016-01-29 15:23:57 -08001003
Jeremye1ea0602016-02-08 16:35:05 -08001004 utilities.assert_equals( expect=main.TRUE,
1005 actual=testResult,
1006 onpass="ONOS Leaders Unchanged",
1007 onfail="ONOS Leader Mismatch")
Jeremy2f190ca2016-01-29 15:23:57 -08001008
1009 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001010
1011 def CASE2000( self, main ):
1012 """
1013 Add point intents between 2 hosts:
1014 - Get device ids | ports
1015 - Add point intents
1016 - Check intents
1017 - Verify flows
1018 - Ping hosts
1019 - Reroute
1020 - Link down
1021 - Verify flows
1022 - Check topology
1023 - Ping hosts
1024 - Link up
1025 - Verify flows
1026 - Check topology
1027 - Ping hosts
1028 - Remove intents
1029 """
1030 import time
1031 import json
1032 import re
Jeremydd9bda62016-04-18 12:02:32 -07001033 if main.initialized == main.FALSE:
1034 main.log.error( "Test components did not start correctly, skipping further tests" )
1035 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001036 # Assert variables - These variable's name|format must be followed
1037 # if you want to use the wrapper function
1038 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -07001039 try:
1040 assert main.CLIs
1041 except AssertionError:
1042 main.log.error( "There is no main.CLIs, skipping test cases" )
1043 main.initialized = main.FALSE
1044 main.skipCase()
1045 try:
1046 assert main.Mininet1
1047 except AssertionError:
1048 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1049 main.initialized = main.FALSE
1050 main.skipCase()
1051 try:
1052 assert main.numSwitch
1053 except AssertionError:
1054 main.log.error( "Place the total number of switch topology in \
1055 main.numSwitch" )
1056 main.initialized = main.FALSE
1057 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001058
1059 main.case( "Point Intents Test - " + str( main.numCtrls ) +
Jeremyeb51cb12016-03-28 17:53:35 -07001060 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -07001061 main.caseExplanation = "This test case will test point to point" +\
1062 " intents using " + str( main.numCtrls ) +\
1063 " node(s) cluster;\n" +\
1064 "Different type of hosts will be tested in " +\
1065 "each step such as IPV4, Dual stack, VLAN etc" +\
1066 ";\nThe test will use OF " + main.OFProtocol +\
Jeremyeb51cb12016-03-28 17:53:35 -07001067 " OVS running in Mininet and compile intents" +\
1068 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001069
1070 # No option point intents
1071 main.step( "NOOPTION: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001072 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
1073 senders = [
1074 { "name":"h1","device":"of:0000000000000005/1" }
1075 ]
1076 recipients = [
1077 { "name":"h9","device":"of:0000000000000006/1" }
1078 ]
1079 testResult = main.FALSE
1080 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001081 main,
1082 name="NOOPTION",
Jeremy2f190ca2016-01-29 15:23:57 -08001083 senders=senders,
1084 recipients=recipients )
1085
1086 if installResult:
1087 testResult = main.intentFunction.testPointIntent(
1088 main,
1089 intentId=installResult,
1090 name="NOOPTION",
1091 senders=senders,
1092 recipients=recipients,
1093 sw1="s5",
1094 sw2="s2",
1095 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001096
1097 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001098 actual=testResult,
1099 onpass=main.assertReturnString,
1100 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001101
kelvin-onlab44147802015-07-27 17:57:31 -07001102 main.step( "IPV4: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001103 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
1104 senders = [
1105 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1106 ]
1107 recipients = [
1108 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09" }
1109 ]
1110 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001111 main,
1112 name="IPV4",
Jeremy2f190ca2016-01-29 15:23:57 -08001113 senders=senders,
1114 recipients=recipients,
1115 ethType="IPV4" )
1116
1117 if installResult:
1118 testResult = main.intentFunction.testPointIntent(
1119 main,
1120 intentId=installResult,
1121 name="IPV4",
1122 senders=senders,
1123 recipients=recipients,
1124 sw1="s5",
1125 sw2="s2",
1126 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001127
1128 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001129 actual=testResult,
1130 onpass=main.assertReturnString,
1131 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001132 main.step( "IPV4_2: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001133 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
1134 senders = [
1135 { "name":"h1","device":"of:0000000000000005/1" }
1136 ]
1137 recipients = [
1138 { "name":"h9","device":"of:0000000000000006/1" }
1139 ]
1140 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001141 main,
1142 name="IPV4_2",
Jeremy2f190ca2016-01-29 15:23:57 -08001143 senders=senders,
1144 recipients=recipients,
1145 ethType="IPV4" )
1146
1147 if installResult:
1148 testResult = main.intentFunction.testPointIntent(
1149 main,
1150 intentId=installResult,
1151 name="IPV4_2",
1152 senders=senders,
1153 recipients=recipients,
1154 sw1="s5",
1155 sw2="s2",
1156 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001157
1158 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001159 actual=testResult,
1160 onpass=main.assertReturnString,
1161 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001162
kelvin-onlab0e684682015-08-11 18:51:41 -07001163 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001164 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
1165 senders = [
1166 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01",
1167 "ip":main.h1.hostIp }
1168 ]
1169 recipients = [
1170 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09",
1171 "ip":main.h9.hostIp }
1172 ]
kelvin-onlab44147802015-07-27 17:57:31 -07001173 ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
1174 # Uneccessary, not including this in the selectors
Jeremy2f190ca2016-01-29 15:23:57 -08001175 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
1176 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
kelvin-onlab44147802015-07-27 17:57:31 -07001177
Jeremy2f190ca2016-01-29 15:23:57 -08001178 installResult = main.intentFunction.installPointIntent(
1179 main,
1180 name="SDNIP-ICMP",
1181 senders=senders,
1182 recipients=recipients,
1183 ethType="IPV4",
1184 ipProto=ipProto,
1185 tcpSrc=tcpSrc,
1186 tcpDst=tcpDst )
1187
1188 if installResult:
1189 testResult = main.intentFunction.testPointIntent(
1190 main,
1191 intentId=installResult,
1192 name="SDNIP_ICMP",
1193 senders=senders,
1194 recipients=recipients,
1195 sw1="s5",
1196 sw2="s2",
1197 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001198
1199 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001200 actual=testResult,
1201 onpass=main.assertReturnString,
1202 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001203
kelvin-onlab0e684682015-08-11 18:51:41 -07001204 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001205 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
kelvin-onlab44147802015-07-27 17:57:31 -07001206 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
1207 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab0e684682015-08-11 18:51:41 -07001208 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
1209 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlab44147802015-07-27 17:57:31 -07001210 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
1211 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
1212 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
1213
kelvin-onlab0e684682015-08-11 18:51:41 -07001214 stepResult = main.intentFunction.pointIntentTcp(
kelvin-onlab44147802015-07-27 17:57:31 -07001215 main,
kelvin-onlab0e684682015-08-11 18:51:41 -07001216 name="SDNIP-TCP",
kelvin-onlab44147802015-07-27 17:57:31 -07001217 host1="h1",
1218 host2="h9",
1219 deviceId1="of:0000000000000005/1",
1220 deviceId2="of:0000000000000006/1",
1221 mac1=mac1,
1222 mac2=mac2,
1223 ethType="IPV4",
kelvin-onlab0e684682015-08-11 18:51:41 -07001224 ipProto=ipProto,
1225 ip1=ip1,
1226 ip2=ip2,
1227 tcp1=tcp1,
1228 tcp2=tcp2 )
kelvin-onlab44147802015-07-27 17:57:31 -07001229
1230 utilities.assert_equals( expect=main.TRUE,
1231 actual=stepResult,
Jeremy2f190ca2016-01-29 15:23:57 -08001232 onpass=main.assertReturnString,
1233 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001234
Jeremy2f190ca2016-01-29 15:23:57 -08001235 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
1236 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
1237 senders = [
1238 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1239 ]
1240 recipients = [
1241 { "name":"h11","device":"of:0000000000000006/3","mac":"00:00:00:00:00:0B" }
1242 ]
1243 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001244 main,
1245 name="DUALSTACK1",
Jeremy2f190ca2016-01-29 15:23:57 -08001246 senders=senders,
1247 recipients=recipients,
1248 ethType="IPV4" )
1249
1250 if installResult:
1251 testResult = main.intentFunction.testPointIntent(
1252 main,
1253 intentId=installResult,
1254 name="DUALSTACK1",
1255 senders=senders,
1256 recipients=recipients,
1257 sw1="s5",
1258 sw2="s2",
1259 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001260
1261 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001262 actual=testResult,
1263 onpass=main.assertReturnString,
1264 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001265
1266 main.step( "VLAN: Add point intents between h5 and h21" )
Jeremy2f190ca2016-01-29 15:23:57 -08001267 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
1268 senders = [
1269 { "name":"h5","device":"of:0000000000000005/5","mac":"00:00:00:00:00:05" }
1270 ]
1271 recipients = [
1272 { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15" }
1273 ]
1274 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001275 main,
Jeremy2f190ca2016-01-29 15:23:57 -08001276 name="DUALSTACK1",
1277 senders=senders,
1278 recipients=recipients,
1279 ethType="IPV4" )
1280
1281 if installResult:
1282 testResult = main.intentFunction.testPointIntent(
1283 main,
1284 intentId=installResult,
1285 name="DUALSTACK1",
1286 senders=senders,
1287 recipients=recipients,
1288 sw1="s5",
1289 sw2="s2",
1290 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001291
1292 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001293 actual=testResult,
1294 onpass=main.assertReturnString,
1295 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001296
1297 main.step( "1HOP: Add point intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -08001298 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
1299 senders = [
1300 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1301 ]
1302 recipients = [
1303 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1304 ]
1305 installResult = main.intentFunction.installPointIntent(
1306 main,
1307 name="1HOP IPV4",
1308 senders=senders,
1309 recipients=recipients,
1310 ethType="IPV4" )
1311
1312 if installResult:
1313 testResult = main.intentFunction.testPointIntent(
1314 main,
1315 intentId=installResult,
1316 name="1HOP IPV4",
1317 senders=senders,
1318 recipients=recipients,
1319 sw1="s5",
1320 sw2="s2",
1321 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001322
1323 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001324 actual=testResult,
1325 onpass=main.assertReturnString,
1326 onfail=main.assertReturnString )
1327
1328 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001329
1330 def CASE3000( self, main ):
1331 """
1332 Add single point to multi point intents
1333 - Get device ids
1334 - Add single point to multi point intents
1335 - Check intents
1336 - Verify flows
1337 - Ping hosts
1338 - Reroute
1339 - Link down
1340 - Verify flows
1341 - Check topology
1342 - Ping hosts
1343 - Link up
1344 - Verify flows
1345 - Check topology
1346 - Ping hosts
1347 - Remove intents
1348 """
1349 assert main, "There is no main"
1350 assert main.CLIs, "There is no main.CLIs"
1351 assert main.Mininet1, "Mininet handle should be named Mininet1"
1352 assert main.numSwitch, "Placed the total number of switch topology in \
1353 main.numSwitch"
1354
1355 main.case( "Single To Multi Point Intents Test - " +
Jeremyeb51cb12016-03-28 17:53:35 -07001356 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -07001357 main.caseExplanation = "This test case will test single point to" +\
1358 " multi point intents using " +\
1359 str( main.numCtrls ) + " node(s) cluster;\n" +\
1360 "Different type of hosts will be tested in " +\
1361 "each step such as IPV4, Dual stack, VLAN etc" +\
1362 ";\nThe test will use OF " + main.OFProtocol +\
Jeremyeb51cb12016-03-28 17:53:35 -07001363 " OVS running in Mininet and compile intents" +\
1364 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001365
1366 main.step( "NOOPTION: Add single point to multi point intents" )
1367 stepResult = main.TRUE
1368 hostNames = [ 'h8', 'h16', 'h24' ]
1369 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
1370 'of:0000000000000007/8' ]
1371 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
1372 stepResult = main.intentFunction.singleToMultiIntent(
1373 main,
1374 name="NOOPTION",
1375 hostNames=hostNames,
1376 devices=devices,
1377 sw1="s5",
1378 sw2="s2",
1379 expectedLink=18 )
1380
1381 utilities.assert_equals( expect=main.TRUE,
1382 actual=stepResult,
1383 onpass="NOOPTION: Successfully added single "
1384 + " point to multi point intents" +
1385 " with no match action",
1386 onfail="NOOPTION: Failed to add single point"
1387 + " point to multi point intents" +
1388 " with no match action" )
1389
1390 main.step( "IPV4: Add single point to multi point intents" )
1391 stepResult = main.TRUE
1392 stepResult = main.intentFunction.singleToMultiIntent(
1393 main,
1394 name="IPV4",
1395 hostNames=hostNames,
1396 devices=devices,
1397 ports=None,
1398 ethType="IPV4",
1399 macs=macs,
1400 bandwidth="",
1401 lambdaAlloc=False,
1402 ipProto="",
1403 ipAddresses="",
1404 tcp="",
1405 sw1="s5",
1406 sw2="s2",
1407 expectedLink=18 )
1408
1409 utilities.assert_equals( expect=main.TRUE,
1410 actual=stepResult,
1411 onpass="IPV4: Successfully added single "
1412 + " point to multi point intents" +
1413 " with IPV4 type and MAC addresses",
1414 onfail="IPV4: Failed to add single point"
1415 + " point to multi point intents" +
1416 " with IPV4 type and MAC addresses" )
1417
1418 main.step( "IPV4_2: Add single point to multi point intents" )
1419 stepResult = main.TRUE
1420 hostNames = [ 'h8', 'h16', 'h24' ]
1421 stepResult = main.intentFunction.singleToMultiIntent(
1422 main,
1423 name="IPV4",
1424 hostNames=hostNames,
1425 ethType="IPV4",
1426 lambdaAlloc=False )
1427
1428 utilities.assert_equals( expect=main.TRUE,
1429 actual=stepResult,
1430 onpass="IPV4_2: Successfully added single "
1431 + " point to multi point intents" +
1432 " with IPV4 type and no MAC addresses",
1433 onfail="IPV4_2: Failed to add single point"
1434 + " point to multi point intents" +
1435 " with IPV4 type and no MAC addresses" )
1436
1437 main.step( "VLAN: Add single point to multi point intents" )
1438 stepResult = main.TRUE
1439 hostNames = [ 'h4', 'h12', 'h20' ]
1440 devices = [ 'of:0000000000000005/4', 'of:0000000000000006/4', \
1441 'of:0000000000000007/4' ]
1442 macs = [ '00:00:00:00:00:04', '00:00:00:00:00:0C', '00:00:00:00:00:14' ]
1443 stepResult = main.intentFunction.singleToMultiIntent(
1444 main,
1445 name="VLAN",
1446 hostNames=hostNames,
1447 devices=devices,
1448 ports=None,
1449 ethType="IPV4",
1450 macs=macs,
1451 bandwidth="",
1452 lambdaAlloc=False,
1453 ipProto="",
1454 ipAddresses="",
1455 tcp="",
1456 sw1="s5",
1457 sw2="s2",
1458 expectedLink=18 )
1459
1460 utilities.assert_equals( expect=main.TRUE,
1461 actual=stepResult,
1462 onpass="VLAN: Successfully added single "
1463 + " point to multi point intents" +
1464 " with IPV4 type and MAC addresses" +
1465 " in the same VLAN",
1466 onfail="VLAN: Failed to add single point"
1467 + " point to multi point intents" +
1468 " with IPV4 type and MAC addresses" +
1469 " in the same VLAN")
1470
1471 def CASE4000( self, main ):
1472 """
1473 Add multi point to single point intents
1474 - Get device ids
1475 - Add multi point to single point intents
1476 - Check intents
1477 - Verify flows
1478 - Ping hosts
1479 - Reroute
1480 - Link down
1481 - Verify flows
1482 - Check topology
1483 - Ping hosts
1484 - Link up
1485 - Verify flows
1486 - Check topology
1487 - Ping hosts
1488 - Remove intents
1489 """
1490 assert main, "There is no main"
1491 assert main.CLIs, "There is no main.CLIs"
1492 assert main.Mininet1, "Mininet handle should be named Mininet1"
1493 assert main.numSwitch, "Placed the total number of switch topology in \
1494 main.numSwitch"
1495
1496 main.case( "Multi To Single Point Intents Test - " +
Jeremyeb51cb12016-03-28 17:53:35 -07001497 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -07001498 main.caseExplanation = "This test case will test single point to" +\
1499 " multi point intents using " +\
1500 str( main.numCtrls ) + " node(s) cluster;\n" +\
1501 "Different type of hosts will be tested in " +\
1502 "each step such as IPV4, Dual stack, VLAN etc" +\
1503 ";\nThe test will use OF " + main.OFProtocol +\
Jeremyeb51cb12016-03-28 17:53:35 -07001504 " OVS running in Mininet and compile intents" +\
1505 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001506
1507 main.step( "NOOPTION: Add multi point to single point intents" )
1508 stepResult = main.TRUE
1509 hostNames = [ 'h8', 'h16', 'h24' ]
1510 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
1511 'of:0000000000000007/8' ]
1512 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
1513 stepResult = main.intentFunction.multiToSingleIntent(
1514 main,
1515 name="NOOPTION",
1516 hostNames=hostNames,
1517 devices=devices,
1518 sw1="s5",
1519 sw2="s2",
1520 expectedLink=18 )
1521
1522 utilities.assert_equals( expect=main.TRUE,
1523 actual=stepResult,
1524 onpass="NOOPTION: Successfully added multi "
1525 + " point to single point intents" +
1526 " with no match action",
1527 onfail="NOOPTION: Failed to add multi point" +
1528 " to single point intents" +
1529 " with no match action" )
1530
1531 main.step( "IPV4: Add multi point to single point intents" )
1532 stepResult = main.TRUE
1533 stepResult = main.intentFunction.multiToSingleIntent(
1534 main,
1535 name="IPV4",
1536 hostNames=hostNames,
1537 devices=devices,
1538 ports=None,
1539 ethType="IPV4",
1540 macs=macs,
1541 bandwidth="",
1542 lambdaAlloc=False,
1543 ipProto="",
1544 ipAddresses="",
1545 tcp="",
1546 sw1="s5",
1547 sw2="s2",
1548 expectedLink=18 )
1549
1550 utilities.assert_equals( expect=main.TRUE,
1551 actual=stepResult,
1552 onpass="IPV4: Successfully added multi point"
1553 + " to single point intents" +
1554 " with IPV4 type and MAC addresses",
1555 onfail="IPV4: Failed to add multi point" +
1556 " to single point intents" +
1557 " with IPV4 type and MAC addresses" )
1558
1559 main.step( "IPV4_2: Add multi point to single point intents" )
1560 stepResult = main.TRUE
1561 hostNames = [ 'h8', 'h16', 'h24' ]
1562 stepResult = main.intentFunction.multiToSingleIntent(
1563 main,
1564 name="IPV4",
1565 hostNames=hostNames,
1566 ethType="IPV4",
1567 lambdaAlloc=False )
1568
1569 utilities.assert_equals( expect=main.TRUE,
1570 actual=stepResult,
1571 onpass="IPV4_2: Successfully added multi point"
1572 + " to single point intents" +
1573 " with IPV4 type and no MAC addresses",
1574 onfail="IPV4_2: Failed to add multi point" +
1575 " to single point intents" +
1576 " with IPV4 type and no MAC addresses" )
1577
1578 main.step( "VLAN: Add multi point to single point intents" )
1579 stepResult = main.TRUE
1580 hostNames = [ 'h5', 'h13', 'h21' ]
1581 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \
1582 'of:0000000000000007/5' ]
1583 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
1584 stepResult = main.intentFunction.multiToSingleIntent(
1585 main,
1586 name="VLAN",
1587 hostNames=hostNames,
1588 devices=devices,
1589 ports=None,
1590 ethType="IPV4",
1591 macs=macs,
1592 bandwidth="",
1593 lambdaAlloc=False,
1594 ipProto="",
1595 ipAddresses="",
1596 tcp="",
1597 sw1="s5",
1598 sw2="s2",
1599 expectedLink=18 )
1600
1601 utilities.assert_equals( expect=main.TRUE,
1602 actual=stepResult,
1603 onpass="VLAN: Successfully added multi point"
1604 + " to single point intents" +
1605 " with IPV4 type and MAC addresses" +
1606 " in the same VLAN",
1607 onfail="VLAN: Failed to add multi point" +
1608 " to single point intents" )
1609
1610 def CASE5000( self, main ):
1611 """
Jeremy2f190ca2016-01-29 15:23:57 -08001612 Tests Host Mobility
1613 Modifies the topology location of h1
kelvin-onlab44147802015-07-27 17:57:31 -07001614 """
Jeremydd9bda62016-04-18 12:02:32 -07001615 if main.initialized == main.FALSE:
1616 main.log.error( "Test components did not start correctly, skipping further tests" )
1617 main.skipCase()
1618 # Assert variables - These variable's name|format must be followed
1619 # if you want to use the wrapper function
kelvin-onlab44147802015-07-27 17:57:31 -07001620 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -07001621 try:
1622 assert main.CLIs
1623 except AssertionError:
1624 main.log.error( "There is no main.CLIs, skipping test cases" )
1625 main.initialized = main.FALSE
1626 main.skipCase()
1627 try:
1628 assert main.Mininet1
1629 except AssertionError:
1630 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1631 main.initialized = main.FALSE
1632 main.skipCase()
1633 try:
1634 assert main.numSwitch
1635 except AssertionError:
1636 main.log.error( "Place the total number of switch topology in \
1637 main.numSwitch" )
1638 main.initialized = main.FALSE
1639 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001640 main.case( "Test host mobility with host intents " )
Jeremy2f190ca2016-01-29 15:23:57 -08001641 main.step( "Testing host mobility by moving h1 from s5 to s6" )
kelvin-onlab44147802015-07-27 17:57:31 -07001642 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1643
1644 main.log.info( "Moving h1 from s5 to s6")
kelvin-onlab44147802015-07-27 17:57:31 -07001645 main.Mininet1.moveHost( "h1","s5","s6" )
1646
Jeremy2f190ca2016-01-29 15:23:57 -08001647 # Send discovery ping from moved host
1648 # Moving the host brings down the default interfaces and creates a new one.
1649 # Scapy is restarted on this host to detect the new interface
1650 main.h1.stopScapy()
1651 main.h1.startScapy()
1652
1653 # Discover new host location in ONOS and populate host data.
1654 # Host 1 IP and MAC should be unchanged
1655 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
1656 main.intentFunction.populateHostData( main )
1657
kelvin-onlab44147802015-07-27 17:57:31 -07001658 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1659
1660 utilities.assert_equals( expect="of:0000000000000006",
1661 actual=h1PostMove,
1662 onpass="Mobility: Successfully moved h1 to s6",
Jeremy2f190ca2016-01-29 15:23:57 -08001663 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlab44147802015-07-27 17:57:31 -07001664 " to single point intents" +
1665 " with IPV4 type and MAC addresses" +
1666 " in the same VLAN" )
1667
1668 main.step( "IPV4: Add host intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001669 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
1670 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
1671 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
1672
1673 installResult = main.intentFunction.installHostIntent( main,
1674 name='IPV4 Mobility IPV4',
kelvin-onlab44147802015-07-27 17:57:31 -07001675 onosNode='0',
Jeremy2f190ca2016-01-29 15:23:57 -08001676 host1=host1,
1677 host2=host2)
1678 if installResult:
1679 testResult = main.intentFunction.testHostIntent( main,
1680 name='Host Mobility IPV4',
1681 intentId = installResult,
1682 onosNode='0',
1683 host1=host1,
1684 host2=host2,
1685 sw1="s6",
1686 sw2="s2",
1687 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001688
1689 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001690 actual=testResult,
1691 onpass=main.assertReturnString,
1692 onfail=main.assertReturnString )
1693
1694 main.intentFunction.report( main )
1695