blob: 51ad5b13f7aacfade020f94c3ced3d5ef8ab2a68 [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
Jeremy Songster17147f22016-05-31 18:30:52 -070073 main.cycle = 0 # How many times FUNCintent has run through its tests
kelvin-onlab44147802015-07-27 17:57:31 -070074
75 main.ONOSip = main.ONOSbench.getOnosIps()
Jeremy2f190ca2016-01-29 15:23:57 -080076 print main.ONOSip
kelvin-onlab44147802015-07-27 17:57:31 -070077
78 # Assigning ONOS cli handles to a list
Jon Hallf7234882015-08-28 13:16:31 -070079 try:
80 for i in range( 1, main.maxNodes + 1 ):
81 main.CLIs.append( getattr( main, 'ONOSrest' + str( i ) ) )
Jeremye1ea0602016-02-08 16:35:05 -080082 main.CLIs2.append( getattr( main, 'ONOScli' + str( i ) ) )
Jon Hallf7234882015-08-28 13:16:31 -070083 except AttributeError:
84 main.log.warn( "A " + str( main.maxNodes ) + " node cluster " +
85 "was defined in env variables, but only " +
86 str( len( main.CLIs ) ) +
87 " nodes were defined in the .topo file. " +
88 "Using " + str( len( main.CLIs ) ) +
89 " nodes for the test." )
kelvin-onlab44147802015-07-27 17:57:31 -070090
91 # -- INIT SECTION, ONLY RUNS ONCE -- #
92 main.startUp = imp.load_source( wrapperFile1,
93 main.dependencyPath +
94 wrapperFile1 +
95 ".py" )
96
97 main.intentFunction = imp.load_source( wrapperFile2,
98 main.dependencyPath +
99 wrapperFile2 +
100 ".py" )
101
102 main.topo = imp.load_source( wrapperFile3,
103 main.dependencyPath +
104 wrapperFile3 +
105 ".py" )
106
Jon Hallf7234882015-08-28 13:16:31 -0700107 copyResult1 = main.ONOSbench.scp( main.Mininet1,
108 main.dependencyPath +
109 main.topology,
Jeremy2f190ca2016-01-29 15:23:57 -0800110 main.Mininet1.home + "custom/",
Jon Hallf7234882015-08-28 13:16:31 -0700111 direction="to" )
Jeremye1ea0602016-02-08 16:35:05 -0800112 if main.CLIs and main.CLIs2:
kelvin-onlab44147802015-07-27 17:57:31 -0700113 stepResult = main.TRUE
114 else:
115 main.log.error( "Did not properly created list of ONOS CLI handle" )
116 stepResult = main.FALSE
117 except Exception as e:
118 main.log.exception(e)
119 main.cleanup()
120 main.exit()
121
122 utilities.assert_equals( expect=main.TRUE,
123 actual=stepResult,
124 onpass="Successfully construct " +
125 "test variables ",
126 onfail="Failed to construct test variables" )
127
128 if gitPull == 'True':
129 main.step( "Building ONOS in " + gitBranch + " branch" )
130 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
131 stepResult = onosBuildResult
132 utilities.assert_equals( expect=main.TRUE,
133 actual=stepResult,
134 onpass="Successfully compiled " +
135 "latest ONOS",
136 onfail="Failed to compile " +
137 "latest ONOS" )
138 else:
139 main.log.warn( "Did not pull new code so skipping mvn " +
140 "clean install" )
141 main.ONOSbench.getVersion( report=True )
142
143 def CASE2( self, main ):
144 """
145 - Set up cell
146 - Create cell file
147 - Set cell file
148 - Verify cell file
149 - Kill ONOS process
150 - Uninstall ONOS cluster
151 - Verify ONOS start up
152 - Install ONOS cluster
153 - Connect to cli
154 """
155
Jeremy Songster17147f22016-05-31 18:30:52 -0700156 main.cycle += 1
157
kelvin-onlab44147802015-07-27 17:57:31 -0700158 # main.scale[ 0 ] determines the current number of ONOS controller
159 main.numCtrls = int( main.scale[ 0 ] )
Jeremyeb51cb12016-03-28 17:53:35 -0700160 main.flowCompiler = "Flow Rules"
Jeremydd9bda62016-04-18 12:02:32 -0700161 main.initialized = main.TRUE
kelvin-onlab44147802015-07-27 17:57:31 -0700162
163 main.case( "Starting up " + str( main.numCtrls ) +
164 " node(s) ONOS cluster" )
165 main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
166 " node(s) ONOS cluster"
167
168
169
170 #kill off all onos processes
171 main.log.info( "Safety check, killing all ONOS processes" +
Jon Hall70b2ff42015-11-17 15:49:44 -0800172 " before initiating environment setup" )
kelvin-onlab44147802015-07-27 17:57:31 -0700173
Jeremy2f190ca2016-01-29 15:23:57 -0800174 time.sleep( main.startUpSleep )
Jeremy42df2e72016-02-23 16:37:46 -0800175
Jeremy2f190ca2016-01-29 15:23:57 -0800176 main.step( "Uninstalling ONOS package" )
177 onosUninstallResult = main.TRUE
178 for ip in main.ONOSip:
179 onosUninstallResult = onosUninstallResult and \
180 main.ONOSbench.onosUninstall( nodeIp=ip )
181 stepResult = onosUninstallResult
182 utilities.assert_equals( expect=main.TRUE,
183 actual=stepResult,
184 onpass="Successfully uninstalled ONOS package",
185 onfail="Failed to uninstall ONOS package" )
186
Jeremy42df2e72016-02-23 16:37:46 -0800187 time.sleep( main.startUpSleep )
188
kelvin-onlab44147802015-07-27 17:57:31 -0700189 for i in range( main.maxNodes ):
190 main.ONOSbench.onosDie( main.ONOSip[ i ] )
191
192 print "NODE COUNT = ", main.numCtrls
193
194 tempOnosIp = []
195 for i in range( main.numCtrls ):
196 tempOnosIp.append( main.ONOSip[i] )
197
198 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
199 "temp", main.Mininet1.ip_address,
200 main.apps, tempOnosIp )
201
202 main.step( "Apply cell to environment" )
203 cellResult = main.ONOSbench.setCell( "temp" )
204 verifyResult = main.ONOSbench.verifyCell()
205 stepResult = cellResult and verifyResult
206 utilities.assert_equals( expect=main.TRUE,
207 actual=stepResult,
208 onpass="Successfully applied cell to " + \
209 "environment",
210 onfail="Failed to apply cell to environment " )
211
212 main.step( "Creating ONOS package" )
213 packageResult = main.ONOSbench.onosPackage()
214 stepResult = packageResult
215 utilities.assert_equals( expect=main.TRUE,
216 actual=stepResult,
217 onpass="Successfully created ONOS package",
218 onfail="Failed to create ONOS package" )
219
220 time.sleep( main.startUpSleep )
kelvin-onlab44147802015-07-27 17:57:31 -0700221 main.step( "Installing ONOS package" )
222 onosInstallResult = main.TRUE
223 for i in range( main.numCtrls ):
224 onosInstallResult = onosInstallResult and \
225 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
226 stepResult = onosInstallResult
227 utilities.assert_equals( expect=main.TRUE,
228 actual=stepResult,
229 onpass="Successfully installed ONOS package",
230 onfail="Failed to install ONOS package" )
231
232 time.sleep( main.startUpSleep )
233 main.step( "Starting ONOS service" )
234 stopResult = main.TRUE
235 startResult = main.TRUE
236 onosIsUp = main.TRUE
237
238 for i in range( main.numCtrls ):
239 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
Jeremydd9bda62016-04-18 12:02:32 -0700240 if onosIsUp == main.TRUE:
241 main.log.report( "ONOS instance {0} is up and ready".format( i + 1 ) )
242 else:
243 main.log.report( "ONOS instance {0} may not be up, stop and ".format( i + 1 ) +
244 "start ONOS again " )
245 stopResult = stopResult and main.ONOSbench.onosStop( main.ONOSip[ i ] )
246 startResult = startResult and main.ONOSbench.onosStart( main.ONOSip[ i ] )
247 if not startResult or stopResult:
248 main.log.report( "ONOS instance {0} did not start correctly.".format( i + 1 ) )
kelvin-onlab44147802015-07-27 17:57:31 -0700249 stepResult = onosIsUp and stopResult and startResult
250 utilities.assert_equals( expect=main.TRUE,
251 actual=stepResult,
252 onpass="ONOS service is ready",
253 onfail="ONOS service did not start properly" )
Jeremydd9bda62016-04-18 12:02:32 -0700254 if not stepResult:
255 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700256
Jeremy2f190ca2016-01-29 15:23:57 -0800257 # Start an ONOS cli to provide functionality that is not currently
Jeremye1ea0602016-02-08 16:35:05 -0800258 # supported by the Rest API remove this when Leader Checking is supported
259 # by the REST API
Jeremy2f190ca2016-01-29 15:23:57 -0800260
Jeremye1ea0602016-02-08 16:35:05 -0800261 main.step( "Start ONOS cli" )
262 cliResult = main.TRUE
263 for i in range( main.numCtrls ):
264 cliResult = cliResult and \
265 main.CLIs2[ i ].startOnosCli( main.ONOSip[ i ] )
266 stepResult = cliResult
267 utilities.assert_equals( expect=main.TRUE,
268 actual=stepResult,
269 onpass="Successfully start ONOS cli",
270 onfail="Failed to start ONOS cli" )
Jeremydd9bda62016-04-18 12:02:32 -0700271 if not stepResult:
272 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800273
kelvin-onlab44147802015-07-27 17:57:31 -0700274 # Remove the first element in main.scale list
275 main.scale.remove( main.scale[ 0 ] )
276
Jeremy2f190ca2016-01-29 15:23:57 -0800277 main.intentFunction.report( main )
278
kelvin-onlab44147802015-07-27 17:57:31 -0700279 def CASE8( self, main ):
Jeremy2f190ca2016-01-29 15:23:57 -0800280 # OLD FUNCintentRest CASE 8
281 # This remains here for archiving and reference purposes and will be
282 # removed when the new FUNCintentRest is verified to work.
283 # """
284 # Compare Topo
285 # """
286 # import json
287
288 # main.case( "Compare ONOS Topology view to Mininet topology" )
289 # main.caseExplanation = "Compare topology elements between Mininet" +\
290 # " and ONOS"
291
292 # main.step( "Gathering topology information" )
293 # # TODO: add a paramaterized sleep here
294 # devicesResults = main.TRUE # Overall Boolean for device correctness
295 # linksResults = main.TRUE # Overall Boolean for link correctness
296 # hostsResults = main.TRUE # Overall Boolean for host correctness
297 # devices = main.topo.getAllDevices( main )
298 # hosts = main.topo.getAllHosts( main )
299 # ports = main.topo.getAllPorts( main )
300 # links = main.topo.getAllLinks( main )
301 # clusters = main.topo.getAllClusters( main )
302
303 # mnSwitches = main.Mininet1.getSwitches()
304 # mnLinks = main.Mininet1.getLinks()
305 # mnHosts = main.Mininet1.getHosts()
306
307 # main.step( "Comparing MN topology to ONOS topology" )
308 # for controller in range( main.numCtrls ):
309 # controllerStr = str( controller + 1 )
310 # if devices[ controller ] and ports[ controller ] and\
311 # "Error" not in devices[ controller ] and\
312 # "Error" not in ports[ controller ]:
313
314 # currentDevicesResult = main.Mininet1.compareSwitches(
315 # mnSwitches,
316 # json.loads( devices[ controller ] ),
317 # json.loads( ports[ controller ] ) )
318 # else:
319 # currentDevicesResult = main.FALSE
320 # utilities.assert_equals( expect=main.TRUE,
321 # actual=currentDevicesResult,
322 # onpass="ONOS" + controllerStr +
323 # " Switches view is correct",
324 # onfail="ONOS" + controllerStr +
325 # " Switches view is incorrect" )
326
327 # if links[ controller ] and "Error" not in links[ controller ]:
328 # currentLinksResult = main.Mininet1.compareLinks(
329 # mnSwitches, mnLinks,
330 # json.loads( links[ controller ] ) )
331 # else:
332 # currentLinksResult = main.FALSE
333 # utilities.assert_equals( expect=main.TRUE,
334 # actual=currentLinksResult,
335 # onpass="ONOS" + controllerStr +
336 # " links view is correct",
337 # onfail="ONOS" + controllerStr +
338 # " links view is incorrect" )
339
340 # if hosts[ controller ] or "Error" not in hosts[ controller ]:
341 # currentHostsResult = main.Mininet1.compareHosts(
342 # mnHosts,
343 # json.loads( hosts[ controller ] ) )
344 # else:
345 # currentHostsResult = main.FALSE
346 # utilities.assert_equals( expect=main.TRUE,
347 # actual=currentHostsResult,
348 # onpass="ONOS" + controllerStr +
349 # " hosts exist in Mininet",
350 # onfail="ONOS" + controllerStr +
351 # " hosts don't match Mininet" )
352
353 # NEW FUNCintentRest Case 8 as based off of the CASE 8 from FUNCintent
kelvin-onlab44147802015-07-27 17:57:31 -0700354 """
Jeremy2f190ca2016-01-29 15:23:57 -0800355 Compare ONOS Topology to Mininet Topology
kelvin-onlab44147802015-07-27 17:57:31 -0700356 """
357 import json
358
359 main.case( "Compare ONOS Topology view to Mininet topology" )
360 main.caseExplanation = "Compare topology elements between Mininet" +\
361 " and ONOS"
362
Jeremy2f190ca2016-01-29 15:23:57 -0800363 main.log.info( "Gathering topology information from Mininet" )
364 devicesResults = main.FALSE # Overall Boolean for device correctness
365 linksResults = main.FALSE # Overall Boolean for link correctness
366 hostsResults = main.FALSE # Overall Boolean for host correctness
367 deviceFails = [] # Nodes where devices are incorrect
368 linkFails = [] # Nodes where links are incorrect
369 hostFails = [] # Nodes where hosts are incorrect
370 attempts = main.checkTopoAttempts # Remaining Attempts
kelvin-onlab44147802015-07-27 17:57:31 -0700371
372 mnSwitches = main.Mininet1.getSwitches()
373 mnLinks = main.Mininet1.getLinks()
374 mnHosts = main.Mininet1.getHosts()
375
Jeremy2f190ca2016-01-29 15:23:57 -0800376 main.step( "Comparing Mininet topology to ONOS topology" )
kelvin-onlab44147802015-07-27 17:57:31 -0700377
Jeremy2f190ca2016-01-29 15:23:57 -0800378 while ( attempts >= 0 ) and\
379 ( not devicesResults or not linksResults or not hostsResults ):
380 time.sleep( 2 )
381 if not devicesResults:
382 devices = main.topo.getAllDevices( main )
383 ports = main.topo.getAllPorts( main )
384 devicesResults = main.TRUE
385 deviceFails = [] # Reset for each failed attempt
386 if not linksResults:
387 links = main.topo.getAllLinks( main )
388 linksResults = main.TRUE
389 linkFails = [] # Reset for each failed attempt
390 if not hostsResults:
391 hosts = main.topo.getAllHosts( main )
392 hostsResults = main.TRUE
393 hostFails = [] # Reset for each failed attempt
kelvin-onlab44147802015-07-27 17:57:31 -0700394
Jeremy2f190ca2016-01-29 15:23:57 -0800395 # Check for matching topology on each node
396 for controller in range( main.numCtrls ):
397 controllerStr = str( controller + 1 ) # ONOS node number
398 # Compare Devices
399 if devices[ controller ] and ports[ controller ] and\
400 "Error" not in devices[ controller ] and\
401 "Error" not in ports[ controller ]:
kelvin-onlab44147802015-07-27 17:57:31 -0700402
Jeremy2f190ca2016-01-29 15:23:57 -0800403 try:
404 deviceData = json.loads( devices[ controller ] )
405 portData = json.loads( ports[ controller ] )
406 except (TypeError,ValueError):
407 main.log.error( "Could not load json: {0} or {1}".format( str( devices[ controller ] ), str( ports[ controller ] ) ) )
408 currentDevicesResult = main.FALSE
409 else:
410 currentDevicesResult = main.Mininet1.compareSwitches(
411 mnSwitches,deviceData,portData )
412 else:
413 currentDevicesResult = main.FALSE
414 if not currentDevicesResult:
415 deviceFails.append( controllerStr )
416 devicesResults = devicesResults and currentDevicesResult
417 # Compare Links
418 if links[ controller ] and "Error" not in links[ controller ]:
419 try:
420 linkData = json.loads( links[ controller ] )
421 except (TypeError,ValueError):
422 main.log.error("Could not load json:" + str( links[ controller ] ) )
423 currentLinksResult = main.FALSE
424 else:
425 currentLinksResult = main.Mininet1.compareLinks(
426 mnSwitches, mnLinks,linkData )
427 else:
428 currentLinksResult = main.FALSE
429 if not currentLinksResult:
430 linkFails.append( controllerStr )
431 linksResults = linksResults and currentLinksResult
432 # Compare Hosts
433 if hosts[ controller ] and "Error" not in hosts[ controller ]:
434 try:
435 hostData = json.loads( hosts[ controller ] )
436 except (TypeError,ValueError):
437 main.log.error("Could not load json:" + str( hosts[ controller ] ) )
438 currentHostsResult = main.FALSE
439 else:
440 currentHostsResult = main.Mininet1.compareHosts(
441 mnHosts,hostData )
442 else:
443 currentHostsResult = main.FALSE
444 if not currentHostsResult:
445 hostFails.append( controllerStr )
446 hostsResults = hostsResults and currentHostsResult
447 # Decrement Attempts Remaining
448 attempts -= 1
449
450
451 utilities.assert_equals( expect=[],
452 actual=deviceFails,
453 onpass="ONOS correctly discovered all devices",
454 onfail="ONOS incorrectly discovered devices on nodes: " +
455 str( deviceFails ) )
456 utilities.assert_equals( expect=[],
457 actual=linkFails,
458 onpass="ONOS correctly discovered all links",
459 onfail="ONOS incorrectly discovered links on nodes: " +
460 str( linkFails ) )
461 utilities.assert_equals( expect=[],
462 actual=hostFails,
463 onpass="ONOS correctly discovered all hosts",
464 onfail="ONOS incorrectly discovered hosts on nodes: " +
465 str( hostFails ) )
466 topoResults = hostsResults and linksResults and devicesResults
467 utilities.assert_equals( expect=main.TRUE,
468 actual=topoResults,
469 onpass="ONOS correctly discovered the topology",
470 onfail="ONOS incorrectly discovered the topology" )
kelvin-onlab44147802015-07-27 17:57:31 -0700471
472 def CASE9( self, main ):
473 '''
474 Report errors/warnings/exceptions
475 '''
476 main.log.info( "Error report: \n" )
477 main.ONOSbench.logReport( globalONOSip[0],
478 [ "INFO", "FOLLOWER", "WARN", "flow", "ERROR" , "Except" ],
479 "s" )
480 #main.ONOSbench.logReport( globalONOSip[1], [ "INFO" ], "d" )
481
482 def CASE10( self, main ):
483 """
484 Start Mininet topology with OF 1.0 switches
485 """
Jeremydd9bda62016-04-18 12:02:32 -0700486 if main.initialized == main.FALSE:
487 main.log.error( "Test components did not start correctly, skipping further tests" )
488 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700489 main.OFProtocol = "1.0"
490 main.log.report( "Start Mininet topology with OF 1.0 switches" )
491 main.case( "Start Mininet topology with OF 1.0 switches" )
492 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
493 "switches to test intents, exits out if " +\
494 "topology did not start correctly"
495
496 main.step( "Starting Mininet topology with OF 1.0 switches" )
497 args = "--switch ovs,protocols=OpenFlow10"
498 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
499 main.topology,
500 args=args )
501 stepResult = topoResult
502 utilities.assert_equals( expect=main.TRUE,
503 actual=stepResult,
504 onpass="Successfully loaded topology",
505 onfail="Failed to load topology" )
506 # Exit if topology did not load properly
507 if not topoResult:
Jeremydd9bda62016-04-18 12:02:32 -0700508 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700509
510 def CASE11( self, main ):
511 """
512 Start Mininet topology with OF 1.3 switches
513 """
Jeremydd9bda62016-04-18 12:02:32 -0700514 if main.initialized == main.FALSE:
515 main.log.error( "Test components did not start correctly, skipping further tests" )
516 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700517 main.OFProtocol = "1.3"
518 main.log.report( "Start Mininet topology with OF 1.3 switches" )
519 main.case( "Start Mininet topology with OF 1.3 switches" )
520 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
521 "switches to test intents, exits out if " +\
522 "topology did not start correctly"
523
524 main.step( "Starting Mininet topology with OF 1.3 switches" )
525 args = "--switch ovs,protocols=OpenFlow13"
526 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
527 main.topology,
528 args=args )
529 stepResult = topoResult
530 utilities.assert_equals( expect=main.TRUE,
531 actual=stepResult,
532 onpass="Successfully loaded topology",
533 onfail="Failed to load topology" )
534 # Exit if topology did not load properly
535 if not topoResult:
Jeremydd9bda62016-04-18 12:02:32 -0700536 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700537
538 def CASE12( self, main ):
539 """
540 Assign mastership to controllers
541 """
542 import re
543
Jeremydd9bda62016-04-18 12:02:32 -0700544 if main.initialized == main.FALSE:
545 main.log.error( "Test components did not start correctly, skipping further tests" )
546 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700547 main.case( "Assign switches to controllers" )
548 main.step( "Assigning switches to controllers" )
549 main.caseExplanation = "Assign OF " + main.OFProtocol +\
550 " switches to ONOS nodes"
551
552 assignResult = main.TRUE
553 switchList = []
554
555 # Creates a list switch name, use getSwitch() function later...
556 for i in range( 1, ( main.numSwitch + 1 ) ):
557 switchList.append( 's' + str( i ) )
558
559 tempONOSip = []
560 for i in range( main.numCtrls ):
561 tempONOSip.append( main.ONOSip[ i ] )
562
563 assignResult = main.Mininet1.assignSwController( sw=switchList,
564 ip=tempONOSip,
Charles Chan029be652015-08-24 01:46:10 +0800565 port='6653' )
kelvin-onlab44147802015-07-27 17:57:31 -0700566 if not assignResult:
Jeremydd9bda62016-04-18 12:02:32 -0700567 main.log.error( "Problem assigning mastership of switches, skipping further test cases" )
568 main.initialized = main.FALSE
569 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700570
571 for i in range( 1, ( main.numSwitch + 1 ) ):
572 response = main.Mininet1.getSwController( "s" + str( i ) )
573 print( "Response is " + str( response ) )
574 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
575 assignResult = assignResult and main.TRUE
576 else:
577 assignResult = main.FALSE
578 stepResult = assignResult
579 utilities.assert_equals( expect=main.TRUE,
580 actual=stepResult,
581 onpass="Successfully assigned switches" +
582 "to controller",
583 onfail="Failed to assign switches to " +
584 "controller" )
Jeremydd9bda62016-04-18 12:02:32 -0700585 if not stepResult:
586 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800587
588 def CASE13( self,main ):
589 """
590 Create Scapy components
591 """
Jeremydd9bda62016-04-18 12:02:32 -0700592 if main.initialized == main.FALSE:
593 main.log.error( "Test components did not start correctly, skipping further tests" )
594 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800595 main.case( "Create scapy components" )
596 main.step( "Create scapy components" )
597 import json
598 scapyResult = main.TRUE
599 for hostName in main.scapyHostNames:
600 main.Scapy1.createHostComponent( hostName )
601 main.scapyHosts.append( getattr( main, hostName ) )
602
603 main.step( "Start scapy components" )
604 for host in main.scapyHosts:
605 host.startHostCli()
606 host.startScapy()
607 host.updateSelf()
608 main.log.debug( host.name )
609 main.log.debug( host.hostIp )
610 main.log.debug( host.hostMac )
611
612
613 utilities.assert_equals( expect=main.TRUE,
614 actual=scapyResult,
615 onpass="Successfully created Scapy Components",
616 onfail="Failed to discover Scapy Components" )
Jeremydd9bda62016-04-18 12:02:32 -0700617 if not scapyResult:
618 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800619
620 def CASE14( self, main ):
kelvin-onlab44147802015-07-27 17:57:31 -0700621 """
622 Discover all hosts and store its data to a dictionary
623 """
Jeremydd9bda62016-04-18 12:02:32 -0700624 if main.initialized == main.FALSE:
625 main.log.error( "Test components did not start correctly, skipping further tests" )
626 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700627 main.case( "Discover all hosts" )
628
629 stepResult = main.TRUE
kelvin-onlab0e684682015-08-11 18:51:41 -0700630 main.step( "Discover all ipv4 host hosts " )
631 hostList = []
632 # List of host with default vlan
633 defaultHosts = [ "h1", "h3", "h8", "h9", "h11", "h16", "h17", "h19", "h24" ]
634 # Lists of host with unique vlan
635 vlanHosts1 = [ "h4", "h12", "h20" ]
636 vlanHosts2 = [ "h5", "h13", "h21" ]
637 vlanHosts3 = [ "h6", "h14", "h22" ]
638 vlanHosts4 = [ "h7", "h15", "h23" ]
639 hostList.append( defaultHosts )
640 hostList.append( vlanHosts1 )
641 hostList.append( vlanHosts2 )
642 hostList.append( vlanHosts3 )
643 hostList.append( vlanHosts4 )
644
645 stepResult = main.intentFunction.getHostsData( main, hostList )
kelvin-onlab44147802015-07-27 17:57:31 -0700646 utilities.assert_equals( expect=main.TRUE,
647 actual=stepResult,
648 onpass="Successfully discovered hosts",
649 onfail="Failed to discover hosts" )
Jeremydd9bda62016-04-18 12:02:32 -0700650 if not stepResult:
651 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700652
Jeremy2f190ca2016-01-29 15:23:57 -0800653 def CASE15( self, main ):
kelvin-onlab44147802015-07-27 17:57:31 -0700654 """
Jeremy2f190ca2016-01-29 15:23:57 -0800655 Discover all hosts with scapy arp packets and store its data to a dictionary
kelvin-onlab44147802015-07-27 17:57:31 -0700656 """
Jeremydd9bda62016-04-18 12:02:32 -0700657 if main.initialized == main.FALSE:
658 main.log.error( "Test components did not start correctly, skipping further tests" )
659 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800660 main.case( "Discover all hosts using scapy" )
661 main.step( "Send packets from each host to the first host and confirm onos discovery" )
662
663 import collections
664 if len( main.scapyHosts ) < 1:
665 main.log.error( "No scapy hosts have been created" )
Jeremydd9bda62016-04-18 12:02:32 -0700666 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800667 main.skipCase()
668
669 # Send ARP packets from each scapy host component
670 main.intentFunction.sendDiscoveryArp( main, main.scapyHosts )
671
672 stepResult = utilities.retry( f=main.intentFunction.confirmHostDiscovery,
673 retValue=main.FALSE, args=[ main ],
674 attempts=main.checkTopoAttempts, sleep=2 )
675
676 utilities.assert_equals( expect=main.TRUE,
677 actual=stepResult,
678 onpass="ONOS correctly discovered all hosts",
679 onfail="ONOS incorrectly discovered hosts" )
Jeremydd9bda62016-04-18 12:02:32 -0700680 if not stepResult:
681 main.initialized = main.FALSE
682 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800683
684 main.step( "Populate hostsData" )
685 stepResult = main.intentFunction.populateHostData( main )
686 utilities.assert_equals( expect=main.TRUE,
687 actual=stepResult,
688 onpass="Successfully populated hostsData",
689 onfail="Failed to populate hostsData" )
Jeremydd9bda62016-04-18 12:02:32 -0700690 if not stepResult:
691 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800692
693 def CASE16( self, main ):
694 """
Jeremy42df2e72016-02-23 16:37:46 -0800695 Balance Masters
696 """
Jeremydd9bda62016-04-18 12:02:32 -0700697 if main.initialized == main.FALSE:
698 main.log.error( "Test components did not start correctly, skipping further tests" )
699 main.skipCase()
Jeremy42df2e72016-02-23 16:37:46 -0800700 main.case( "Balance mastership of switches" )
701 main.step( "Balancing mastership of switches" )
702
703 balanceResult = main.FALSE
704 balanceResult = utilities.retry( f=main.CLIs2[ 0 ].balanceMasters, retValue=main.FALSE, args=[] )
705
706 utilities.assert_equals( expect=main.TRUE,
707 actual=stepResult,
708 onpass="Successfully balanced mastership of switches",
709 onfail="Failed to balance mastership of switches" )
Jeremydd9bda62016-04-18 12:02:32 -0700710 if not stepResult:
711 main.initialized = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800712
713 def CASE17( self, main ):
714 """
Jeremyeb51cb12016-03-28 17:53:35 -0700715 Use Flow Objectives
716 """
Jeremydd9bda62016-04-18 12:02:32 -0700717 if main.initialized == main.FALSE:
718 main.log.error( "Test components did not start correctly, skipping further tests" )
719 main.skipCase()
Jeremyeb51cb12016-03-28 17:53:35 -0700720 main.case( "Enable intent compilation using Flow Objectives" )
721 main.step( "Enabling Flow Objectives" )
722
723 main.flowCompiler = "Flow Objectives"
724
725 cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator"
726
727 stepResult = main.CLIs2[ 0 ].setCfg( component=cmd,
728 propName="useFlowObjectives", value="true" )
729
730 utilities.assert_equals( expect=main.TRUE,
731 actual=stepResult,
732 onpass="Successfully activated Flow Objectives",
733 onfail="Failed to activate Flow Objectives" )
Jeremydd9bda62016-04-18 12:02:32 -0700734 if not stepResult:
735 main.initialized = main.FALSE
Jeremyeb51cb12016-03-28 17:53:35 -0700736
737 def CASE18( self, main ):
738 """
Jeremy2f190ca2016-01-29 15:23:57 -0800739 Stop mininet and remove scapy hosts
740 """
741 main.log.report( "Stop Mininet and Scapy" )
742 main.case( "Stop Mininet and Scapy" )
kelvin-onlab44147802015-07-27 17:57:31 -0700743 main.caseExplanation = "Stopping the current mininet topology " +\
744 "to start up fresh"
745
Jeremy2f190ca2016-01-29 15:23:57 -0800746 main.step( "Stopping and Removing Scapy Host Components" )
747 scapyResult = main.TRUE
748 for host in main.scapyHosts:
749 scapyResult = scapyResult and host.stopScapy()
750 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
751
752 for host in main.scapyHosts:
753 scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
754 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
755
756 main.scapyHosts = []
757 main.scapyHostIPs = []
758
759 utilities.assert_equals( expect=main.TRUE,
760 actual=scapyResult,
761 onpass="Successfully stopped scapy and removed host components",
762 onfail="Failed to stop mininet and scapy" )
763
kelvin-onlab44147802015-07-27 17:57:31 -0700764 main.step( "Stopping Mininet Topology" )
Jeremy2f190ca2016-01-29 15:23:57 -0800765 mininetResult = main.Mininet1.stopNet( )
766
kelvin-onlab44147802015-07-27 17:57:31 -0700767 utilities.assert_equals( expect=main.TRUE,
768 actual=stepResult,
769 onpass="Successfully stop mininet",
770 onfail="Failed to stop mininet" )
771 # Exit if topology did not load properly
Jeremy2f190ca2016-01-29 15:23:57 -0800772 if not (mininetResult and scapyResult ):
kelvin-onlab44147802015-07-27 17:57:31 -0700773 main.cleanup()
774 main.exit()
775
Jeremy Songster17147f22016-05-31 18:30:52 -0700776 def CASE19( self, main ):
777 """
778 Copy the karaf.log files after each testcase cycle
779 """
780 main.log.report( "Copy karaf logs" )
781 main.case( "Copy karaf logs" )
782 main.caseExplanation = "Copying the karaf logs to preserve them through" +\
783 "reinstalling ONOS"
784 main.step( "Copying karaf logs" )
Jeremy Songster31aad312016-06-13 16:32:11 -0700785 stepResult = main.TRUE
786 scpResult = main.TRUE
787 copyResult = main.TRUE
Jeremy Songster17147f22016-05-31 18:30:52 -0700788 i = 0
Jeremy Songster4e001502016-06-08 10:42:36 -0700789 for cli in main.CLIs2:
Jeremy Songster17147f22016-05-31 18:30:52 -0700790 main.node = cli
791 ip = main.ONOSip[ i ]
792 main.node.ip_address = ip
Jeremy Songster31aad312016-06-13 16:32:11 -0700793 scpResult = scpResult and main.ONOSbench.scp( main.node ,
794 "/opt/onos/log/karaf.log",
795 "/tmp/karaf.log",
796 direction="from" )
797 copyResult = copyResult and main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
798 copyFileName=( "karaf.log.node{0}.cycle{1}".format( str( i + 1 ), str( main.cycle ) ) ) )
799 if scpResult and copyResult:
800 stepResult = main.TRUE and stepResult
801 else:
802 stepResult = main.FALSE and stepResult
Jeremy Songster17147f22016-05-31 18:30:52 -0700803 i += 1
Jeremy Songster31aad312016-06-13 16:32:11 -0700804 utilities.assert_equals( expect=main.TRUE,
805 actual=stepResult,
806 onpass="Successfully copied remote ONOS logs",
807 onfail="Failed to copy remote ONOS logs" )
Jeremy Songster17147f22016-05-31 18:30:52 -0700808
kelvin-onlab44147802015-07-27 17:57:31 -0700809 def CASE1000( self, main ):
810 """
811 Add host intents between 2 host:
812 - Discover hosts
813 - Add host intents
814 - Check intents
815 - Verify flows
816 - Ping hosts
817 - Reroute
818 - Link down
819 - Verify flows
820 - Check topology
821 - Ping hosts
822 - Link up
823 - Verify flows
824 - Check topology
825 - Ping hosts
826 - Remove intents
827 """
828 import time
829 import json
830 import re
Jeremydd9bda62016-04-18 12:02:32 -0700831 if main.initialized == main.FALSE:
832 main.log.error( "Test components did not start correctly, skipping further tests" )
833 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700834 # Assert variables - These variable's name|format must be followed
835 # if you want to use the wrapper function
836 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -0700837 try:
838 assert main.CLIs
839 except AssertionError:
840 main.log.error( "There is no main.CLIs, skipping test cases" )
841 main.initialized = main.FALSE
842 main.skipCase()
843 try:
844 assert main.Mininet1
845 except AssertionError:
846 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
847 main.initialized = main.FALSE
848 main.skipCase()
849 try:
850 assert main.numSwitch
851 except AssertionError:
852 main.log.error( "Place the total number of switch topology in \
853 main.numSwitch" )
854 main.initialized = main.FALSE
855 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700856
Jeremye1ea0602016-02-08 16:35:05 -0800857 # Save leader candidates
858 intentLeadersOld = main.CLIs2[ 0 ].leaderCandidates()
859
kelvin-onlab44147802015-07-27 17:57:31 -0700860 main.case( "Host Intents Test - " + str( main.numCtrls ) +
Jeremyeb51cb12016-03-28 17:53:35 -0700861 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -0700862 main.caseExplanation = "This test case tests Host intents using " +\
863 str( main.numCtrls ) + " node(s) cluster;\n" +\
864 "Different type of hosts will be tested in " +\
865 "each step such as IPV4, Dual stack, VLAN " +\
Jeremyeb51cb12016-03-28 17:53:35 -0700866 "etc;\nThe test will use OF " + main.OFProtocol +\
867 " OVS running in Mininet and compile intents" +\
868 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -0700869
Jeremy2f190ca2016-01-29 15:23:57 -0800870 main.step( "IPV4: Add and test host intents between h1 and h9" )
871 main.assertReturnString = "Assertion result for IPV4 host intent with mac addresses\n"
872 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
873 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
874 testResult = main.FALSE
875 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlab44147802015-07-27 17:57:31 -0700876 name='IPV4',
Jeremy2f190ca2016-01-29 15:23:57 -0800877 onosNode='0',
878 host1=host1,
879 host2=host2 )
880
881 if installResult:
882 testResult = main.intentFunction.testHostIntent( main,
883 name='IPV4',
884 intentId = installResult,
885 onosNode='0',
886 host1=host1,
887 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700888 sw1='s5',
889 sw2='s2',
Jeremy2f190ca2016-01-29 15:23:57 -0800890 expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700891
892 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800893 actual=testResult,
894 onpass=main.assertReturnString,
895 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700896
897 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800898 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
899 host1 = { "name":"h3", "id":"00:00:00:00:00:03/-1" }
900 host2 = { "name":"h11","id":"00:00:00:00:00:0B/-1"}
901 testResult = main.FALSE
902 installResult = main.intentFunction.installHostIntent( main,
903 name='DUALSTACK1',
904 onosNode='0',
905 host1=host1,
906 host2=host2 )
907
908 if installResult:
909 testResult = main.intentFunction.testHostIntent( main,
910 name='DUALSTACK1',
911 intentId = installResult,
912 onosNode='0',
913 host1=host1,
914 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700915 sw1='s5',
916 sw2='s2',
Jeremy2f190ca2016-01-29 15:23:57 -0800917 expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700918
919 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800920 actual=testResult,
921 onpass=main.assertReturnString,
922 onfail=main.assertReturnString)
kelvin-onlab44147802015-07-27 17:57:31 -0700923
924 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800925 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
926 host1 = { "name":"h1" }
927 host2 = { "name":"h11" }
928 testResult = main.FALSE
929 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlab44147802015-07-27 17:57:31 -0700930 name='DUALSTACK2',
Jeremy2f190ca2016-01-29 15:23:57 -0800931 onosNode='0',
932 host1=host1,
933 host2=host2 )
934
935 if installResult:
936 testResult = main.intentFunction.testHostIntent( main,
937 name='DUALSTACK2',
938 intentId = installResult,
939 onosNode='0',
940 host1=host1,
941 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700942 sw1='s5',
943 sw2='s2',
Jeremy2f190ca2016-01-29 15:23:57 -0800944 expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700945
946 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800947 actual=testResult,
948 onpass=main.assertReturnString,
949 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700950
951 main.step( "1HOP: Add host intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -0800952 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
953 host1 = { "name":"h1" }
954 host2 = { "name":"h3" }
955 testResult = main.FALSE
956 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlab44147802015-07-27 17:57:31 -0700957 name='1HOP',
Jeremy2f190ca2016-01-29 15:23:57 -0800958 onosNode='0',
959 host1=host1,
960 host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700961
Jeremy2f190ca2016-01-29 15:23:57 -0800962 if installResult:
963 testResult = main.intentFunction.testHostIntent( main,
964 name='1HOP',
965 intentId = installResult,
966 onosNode='0',
967 host1=host1,
968 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700969 sw1='s5',
970 sw2='s2',
Jeremy2f190ca2016-01-29 15:23:57 -0800971 expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700972
973 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800974 actual=testResult,
975 onpass=main.assertReturnString,
976 onfail=main.assertReturnString )
977
978 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
979 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700980 host1 = { "name":"h4","id":"00:00:00:00:00:04/100", "vlanId":"100" }
981 host2 = { "name":"h12","id":"00:00:00:00:00:0C/100", "vlanId":"100" }
Jeremy2f190ca2016-01-29 15:23:57 -0800982 testResult = main.FALSE
983 installResult = main.intentFunction.installHostIntent( main,
984 name='VLAN1',
985 onosNode='0',
986 host1=host1,
987 host2=host2 )
988
989 if installResult:
990 testResult = main.intentFunction.testHostIntent( main,
991 name='VLAN1',
992 intentId = installResult,
993 onosNode='0',
994 host1=host1,
995 host2=host2,
996 sw1='s5',
997 sw2='s2',
998 expectedLink = 18 )
999
1000 utilities.assert_equals( expect=main.TRUE,
1001 actual=testResult,
1002 onpass=main.assertReturnString,
1003 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001004
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001005 # This step isn't currently possible to perform in the REST API
1006 # main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
1007 # main.assertReturnString = "Assertion Result different VLAN negative test\n"
1008 # host1 = { "name":"h13" }
1009 # host2 = { "name":"h20" }
1010 # testResult = main.FALSE
1011 # installResult = main.intentFunction.installHostIntent( main,
1012 # name='VLAN2',
1013 # onosNode='0',
1014 # host1=host1,
1015 # host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -07001016
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001017 # if installResult:
1018 # testResult = main.intentFunction.testHostIntent( main,
1019 # name='VLAN2',
1020 # intentId = installResult,
1021 # onosNode='0',
1022 # host1=host1,
1023 # host2=host2,
1024 # sw1='s5',
1025 # sw2='s2',
1026 # expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001027
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001028 # utilities.assert_equals( expect=main.TRUE,
1029 # actual=testResult,
1030 # onpass=main.assertReturnString,
1031 # onfail=main.assertReturnString )
Jeremy2f190ca2016-01-29 15:23:57 -08001032
Jeremye1ea0602016-02-08 16:35:05 -08001033 # Change the following to use the REST API when leader checking is
1034 # supported by it
Jeremy2f190ca2016-01-29 15:23:57 -08001035
Jeremye1ea0602016-02-08 16:35:05 -08001036 main.step( "Confirm that ONOS leadership is unchanged")
1037 intentLeadersNew = main.CLIs2[ 0 ].leaderCandidates()
1038 main.intentFunction.checkLeaderChange( intentLeadersOld,
1039 intentLeadersNew )
Jeremy2f190ca2016-01-29 15:23:57 -08001040
Jeremye1ea0602016-02-08 16:35:05 -08001041 utilities.assert_equals( expect=main.TRUE,
1042 actual=testResult,
1043 onpass="ONOS Leaders Unchanged",
1044 onfail="ONOS Leader Mismatch")
Jeremy2f190ca2016-01-29 15:23:57 -08001045
1046 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001047
1048 def CASE2000( self, main ):
1049 """
1050 Add point intents between 2 hosts:
1051 - Get device ids | ports
1052 - Add point intents
1053 - Check intents
1054 - Verify flows
1055 - Ping hosts
1056 - Reroute
1057 - Link down
1058 - Verify flows
1059 - Check topology
1060 - Ping hosts
1061 - Link up
1062 - Verify flows
1063 - Check topology
1064 - Ping hosts
1065 - Remove intents
1066 """
1067 import time
1068 import json
1069 import re
Jeremydd9bda62016-04-18 12:02:32 -07001070 if main.initialized == main.FALSE:
1071 main.log.error( "Test components did not start correctly, skipping further tests" )
1072 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001073 # Assert variables - These variable's name|format must be followed
1074 # if you want to use the wrapper function
1075 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -07001076 try:
1077 assert main.CLIs
1078 except AssertionError:
1079 main.log.error( "There is no main.CLIs, skipping test cases" )
1080 main.initialized = main.FALSE
1081 main.skipCase()
1082 try:
1083 assert main.Mininet1
1084 except AssertionError:
1085 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1086 main.initialized = main.FALSE
1087 main.skipCase()
1088 try:
1089 assert main.numSwitch
1090 except AssertionError:
1091 main.log.error( "Place the total number of switch topology in \
1092 main.numSwitch" )
1093 main.initialized = main.FALSE
1094 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001095
1096 main.case( "Point Intents Test - " + str( main.numCtrls ) +
Jeremyeb51cb12016-03-28 17:53:35 -07001097 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -07001098 main.caseExplanation = "This test case will test point to point" +\
1099 " intents using " + str( main.numCtrls ) +\
1100 " node(s) cluster;\n" +\
1101 "Different type of hosts will be tested in " +\
1102 "each step such as IPV4, Dual stack, VLAN etc" +\
1103 ";\nThe test will use OF " + main.OFProtocol +\
Jeremyeb51cb12016-03-28 17:53:35 -07001104 " OVS running in Mininet and compile intents" +\
1105 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001106
1107 # No option point intents
1108 main.step( "NOOPTION: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001109 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
1110 senders = [
1111 { "name":"h1","device":"of:0000000000000005/1" }
1112 ]
1113 recipients = [
1114 { "name":"h9","device":"of:0000000000000006/1" }
1115 ]
1116 testResult = main.FALSE
1117 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001118 main,
1119 name="NOOPTION",
Jeremy2f190ca2016-01-29 15:23:57 -08001120 senders=senders,
1121 recipients=recipients )
1122
1123 if installResult:
1124 testResult = main.intentFunction.testPointIntent(
1125 main,
1126 intentId=installResult,
1127 name="NOOPTION",
1128 senders=senders,
1129 recipients=recipients,
1130 sw1="s5",
1131 sw2="s2",
1132 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001133
1134 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001135 actual=testResult,
1136 onpass=main.assertReturnString,
1137 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001138
kelvin-onlab44147802015-07-27 17:57:31 -07001139 main.step( "IPV4: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001140 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
1141 senders = [
1142 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1143 ]
1144 recipients = [
1145 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09" }
1146 ]
1147 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001148 main,
1149 name="IPV4",
Jeremy2f190ca2016-01-29 15:23:57 -08001150 senders=senders,
1151 recipients=recipients,
1152 ethType="IPV4" )
1153
1154 if installResult:
1155 testResult = main.intentFunction.testPointIntent(
1156 main,
1157 intentId=installResult,
1158 name="IPV4",
1159 senders=senders,
1160 recipients=recipients,
1161 sw1="s5",
1162 sw2="s2",
1163 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001164
1165 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001166 actual=testResult,
1167 onpass=main.assertReturnString,
1168 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001169 main.step( "IPV4_2: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001170 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
1171 senders = [
1172 { "name":"h1","device":"of:0000000000000005/1" }
1173 ]
1174 recipients = [
1175 { "name":"h9","device":"of:0000000000000006/1" }
1176 ]
1177 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001178 main,
1179 name="IPV4_2",
Jeremy2f190ca2016-01-29 15:23:57 -08001180 senders=senders,
1181 recipients=recipients,
1182 ethType="IPV4" )
1183
1184 if installResult:
1185 testResult = main.intentFunction.testPointIntent(
1186 main,
1187 intentId=installResult,
1188 name="IPV4_2",
1189 senders=senders,
1190 recipients=recipients,
1191 sw1="s5",
1192 sw2="s2",
1193 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001194
1195 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001196 actual=testResult,
1197 onpass=main.assertReturnString,
1198 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001199
kelvin-onlab0e684682015-08-11 18:51:41 -07001200 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001201 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
1202 senders = [
1203 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01",
1204 "ip":main.h1.hostIp }
1205 ]
1206 recipients = [
1207 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09",
1208 "ip":main.h9.hostIp }
1209 ]
kelvin-onlab44147802015-07-27 17:57:31 -07001210 ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
1211 # Uneccessary, not including this in the selectors
Jeremy2f190ca2016-01-29 15:23:57 -08001212 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
1213 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
kelvin-onlab44147802015-07-27 17:57:31 -07001214
Jeremy2f190ca2016-01-29 15:23:57 -08001215 installResult = main.intentFunction.installPointIntent(
1216 main,
1217 name="SDNIP-ICMP",
1218 senders=senders,
1219 recipients=recipients,
1220 ethType="IPV4",
1221 ipProto=ipProto,
1222 tcpSrc=tcpSrc,
1223 tcpDst=tcpDst )
1224
1225 if installResult:
1226 testResult = main.intentFunction.testPointIntent(
1227 main,
1228 intentId=installResult,
1229 name="SDNIP_ICMP",
1230 senders=senders,
1231 recipients=recipients,
1232 sw1="s5",
1233 sw2="s2",
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001234 expectedLink=18,
1235 useTCP=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001236
1237 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001238 actual=testResult,
1239 onpass=main.assertReturnString,
1240 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001241
kelvin-onlab0e684682015-08-11 18:51:41 -07001242 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001243 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
kelvin-onlab44147802015-07-27 17:57:31 -07001244 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
1245 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab0e684682015-08-11 18:51:41 -07001246 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
1247 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlab44147802015-07-27 17:57:31 -07001248 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
1249 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
1250 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
1251
kelvin-onlab0e684682015-08-11 18:51:41 -07001252 stepResult = main.intentFunction.pointIntentTcp(
kelvin-onlab44147802015-07-27 17:57:31 -07001253 main,
kelvin-onlab0e684682015-08-11 18:51:41 -07001254 name="SDNIP-TCP",
kelvin-onlab44147802015-07-27 17:57:31 -07001255 host1="h1",
1256 host2="h9",
1257 deviceId1="of:0000000000000005/1",
1258 deviceId2="of:0000000000000006/1",
1259 mac1=mac1,
1260 mac2=mac2,
1261 ethType="IPV4",
kelvin-onlab0e684682015-08-11 18:51:41 -07001262 ipProto=ipProto,
1263 ip1=ip1,
1264 ip2=ip2,
1265 tcp1=tcp1,
1266 tcp2=tcp2 )
kelvin-onlab44147802015-07-27 17:57:31 -07001267
1268 utilities.assert_equals( expect=main.TRUE,
1269 actual=stepResult,
Jeremy2f190ca2016-01-29 15:23:57 -08001270 onpass=main.assertReturnString,
1271 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001272
Jeremy2f190ca2016-01-29 15:23:57 -08001273 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
1274 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
1275 senders = [
1276 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1277 ]
1278 recipients = [
1279 { "name":"h11","device":"of:0000000000000006/3","mac":"00:00:00:00:00:0B" }
1280 ]
1281 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001282 main,
1283 name="DUALSTACK1",
Jeremy2f190ca2016-01-29 15:23:57 -08001284 senders=senders,
1285 recipients=recipients,
1286 ethType="IPV4" )
1287
1288 if installResult:
1289 testResult = main.intentFunction.testPointIntent(
1290 main,
1291 intentId=installResult,
1292 name="DUALSTACK1",
1293 senders=senders,
1294 recipients=recipients,
1295 sw1="s5",
1296 sw2="s2",
1297 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001298
1299 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001300 actual=testResult,
1301 onpass=main.assertReturnString,
1302 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001303
1304 main.step( "VLAN: Add point intents between h5 and h21" )
Jeremy2f190ca2016-01-29 15:23:57 -08001305 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
1306 senders = [
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001307 { "name":"h5","device":"of:0000000000000005/5","mac":"00:00:00:00:00:05", "vlanId":"200" }
Jeremy2f190ca2016-01-29 15:23:57 -08001308 ]
1309 recipients = [
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001310 { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15", "vlanId":"200" }
Jeremy2f190ca2016-01-29 15:23:57 -08001311 ]
1312 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001313 main,
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001314 name="VLAN",
Jeremy2f190ca2016-01-29 15:23:57 -08001315 senders=senders,
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001316 recipients=recipients )
Jeremy2f190ca2016-01-29 15:23:57 -08001317
1318 if installResult:
1319 testResult = main.intentFunction.testPointIntent(
1320 main,
1321 intentId=installResult,
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001322 name="VLAN",
Jeremy2f190ca2016-01-29 15:23:57 -08001323 senders=senders,
1324 recipients=recipients,
1325 sw1="s5",
1326 sw2="s2",
1327 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001328
1329 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001330 actual=testResult,
1331 onpass=main.assertReturnString,
1332 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001333
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001334 # TODO: implement VLAN selector REST API intent test once supported
1335
kelvin-onlab44147802015-07-27 17:57:31 -07001336 main.step( "1HOP: Add point intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -08001337 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
1338 senders = [
1339 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1340 ]
1341 recipients = [
1342 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1343 ]
1344 installResult = main.intentFunction.installPointIntent(
1345 main,
1346 name="1HOP IPV4",
1347 senders=senders,
1348 recipients=recipients,
1349 ethType="IPV4" )
1350
1351 if installResult:
1352 testResult = main.intentFunction.testPointIntent(
1353 main,
1354 intentId=installResult,
1355 name="1HOP IPV4",
1356 senders=senders,
1357 recipients=recipients,
1358 sw1="s5",
1359 sw2="s2",
1360 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001361
1362 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001363 actual=testResult,
1364 onpass=main.assertReturnString,
1365 onfail=main.assertReturnString )
1366
1367 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001368
1369 def CASE3000( self, main ):
1370 """
1371 Add single point to multi point intents
1372 - Get device ids
1373 - Add single point to multi point intents
1374 - Check intents
1375 - Verify flows
1376 - Ping hosts
1377 - Reroute
1378 - Link down
1379 - Verify flows
1380 - Check topology
1381 - Ping hosts
1382 - Link up
1383 - Verify flows
1384 - Check topology
1385 - Ping hosts
1386 - Remove intents
1387 """
1388 assert main, "There is no main"
1389 assert main.CLIs, "There is no main.CLIs"
1390 assert main.Mininet1, "Mininet handle should be named Mininet1"
1391 assert main.numSwitch, "Placed the total number of switch topology in \
1392 main.numSwitch"
1393
1394 main.case( "Single To Multi Point Intents Test - " +
Jeremyeb51cb12016-03-28 17:53:35 -07001395 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -07001396 main.caseExplanation = "This test case will test single point to" +\
1397 " multi point intents using " +\
1398 str( main.numCtrls ) + " node(s) cluster;\n" +\
1399 "Different type of hosts will be tested in " +\
1400 "each step such as IPV4, Dual stack, VLAN etc" +\
1401 ";\nThe test will use OF " + main.OFProtocol +\
Jeremyeb51cb12016-03-28 17:53:35 -07001402 " OVS running in Mininet and compile intents" +\
1403 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001404
1405 main.step( "NOOPTION: Add single point to multi point intents" )
1406 stepResult = main.TRUE
1407 hostNames = [ 'h8', 'h16', 'h24' ]
1408 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
1409 'of:0000000000000007/8' ]
1410 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
1411 stepResult = main.intentFunction.singleToMultiIntent(
1412 main,
1413 name="NOOPTION",
1414 hostNames=hostNames,
1415 devices=devices,
1416 sw1="s5",
1417 sw2="s2",
1418 expectedLink=18 )
1419
1420 utilities.assert_equals( expect=main.TRUE,
1421 actual=stepResult,
1422 onpass="NOOPTION: Successfully added single "
1423 + " point to multi point intents" +
1424 " with no match action",
1425 onfail="NOOPTION: Failed to add single point"
1426 + " point to multi point intents" +
1427 " with no match action" )
1428
1429 main.step( "IPV4: Add single point to multi point intents" )
1430 stepResult = main.TRUE
1431 stepResult = main.intentFunction.singleToMultiIntent(
1432 main,
1433 name="IPV4",
1434 hostNames=hostNames,
1435 devices=devices,
1436 ports=None,
1437 ethType="IPV4",
1438 macs=macs,
1439 bandwidth="",
1440 lambdaAlloc=False,
1441 ipProto="",
1442 ipAddresses="",
1443 tcp="",
1444 sw1="s5",
1445 sw2="s2",
1446 expectedLink=18 )
1447
1448 utilities.assert_equals( expect=main.TRUE,
1449 actual=stepResult,
1450 onpass="IPV4: Successfully added single "
1451 + " point to multi point intents" +
1452 " with IPV4 type and MAC addresses",
1453 onfail="IPV4: Failed to add single point"
1454 + " point to multi point intents" +
1455 " with IPV4 type and MAC addresses" )
1456
1457 main.step( "IPV4_2: Add single point to multi point intents" )
1458 stepResult = main.TRUE
1459 hostNames = [ 'h8', 'h16', 'h24' ]
1460 stepResult = main.intentFunction.singleToMultiIntent(
1461 main,
1462 name="IPV4",
1463 hostNames=hostNames,
1464 ethType="IPV4",
1465 lambdaAlloc=False )
1466
1467 utilities.assert_equals( expect=main.TRUE,
1468 actual=stepResult,
1469 onpass="IPV4_2: Successfully added single "
1470 + " point to multi point intents" +
1471 " with IPV4 type and no MAC addresses",
1472 onfail="IPV4_2: Failed to add single point"
1473 + " point to multi point intents" +
1474 " with IPV4 type and no MAC addresses" )
1475
1476 main.step( "VLAN: Add single point to multi point intents" )
1477 stepResult = main.TRUE
1478 hostNames = [ 'h4', 'h12', 'h20' ]
1479 devices = [ 'of:0000000000000005/4', 'of:0000000000000006/4', \
1480 'of:0000000000000007/4' ]
1481 macs = [ '00:00:00:00:00:04', '00:00:00:00:00:0C', '00:00:00:00:00:14' ]
1482 stepResult = main.intentFunction.singleToMultiIntent(
1483 main,
1484 name="VLAN",
1485 hostNames=hostNames,
1486 devices=devices,
1487 ports=None,
1488 ethType="IPV4",
1489 macs=macs,
1490 bandwidth="",
1491 lambdaAlloc=False,
1492 ipProto="",
1493 ipAddresses="",
1494 tcp="",
1495 sw1="s5",
1496 sw2="s2",
1497 expectedLink=18 )
1498
1499 utilities.assert_equals( expect=main.TRUE,
1500 actual=stepResult,
1501 onpass="VLAN: Successfully added single "
1502 + " point to multi point intents" +
1503 " with IPV4 type and MAC addresses" +
1504 " in the same VLAN",
1505 onfail="VLAN: Failed to add single point"
1506 + " point to multi point intents" +
1507 " with IPV4 type and MAC addresses" +
1508 " in the same VLAN")
1509
1510 def CASE4000( self, main ):
1511 """
1512 Add multi point to single point intents
1513 - Get device ids
1514 - Add multi point to single point intents
1515 - Check intents
1516 - Verify flows
1517 - Ping hosts
1518 - Reroute
1519 - Link down
1520 - Verify flows
1521 - Check topology
1522 - Ping hosts
1523 - Link up
1524 - Verify flows
1525 - Check topology
1526 - Ping hosts
1527 - Remove intents
1528 """
1529 assert main, "There is no main"
1530 assert main.CLIs, "There is no main.CLIs"
1531 assert main.Mininet1, "Mininet handle should be named Mininet1"
1532 assert main.numSwitch, "Placed the total number of switch topology in \
1533 main.numSwitch"
1534
1535 main.case( "Multi To Single Point Intents Test - " +
Jeremyeb51cb12016-03-28 17:53:35 -07001536 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -07001537 main.caseExplanation = "This test case will test single point to" +\
1538 " multi point intents using " +\
1539 str( main.numCtrls ) + " node(s) cluster;\n" +\
1540 "Different type of hosts will be tested in " +\
1541 "each step such as IPV4, Dual stack, VLAN etc" +\
1542 ";\nThe test will use OF " + main.OFProtocol +\
Jeremyeb51cb12016-03-28 17:53:35 -07001543 " OVS running in Mininet and compile intents" +\
1544 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001545
1546 main.step( "NOOPTION: Add multi point to single point intents" )
1547 stepResult = main.TRUE
1548 hostNames = [ 'h8', 'h16', 'h24' ]
1549 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
1550 'of:0000000000000007/8' ]
1551 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
1552 stepResult = main.intentFunction.multiToSingleIntent(
1553 main,
1554 name="NOOPTION",
1555 hostNames=hostNames,
1556 devices=devices,
1557 sw1="s5",
1558 sw2="s2",
1559 expectedLink=18 )
1560
1561 utilities.assert_equals( expect=main.TRUE,
1562 actual=stepResult,
1563 onpass="NOOPTION: Successfully added multi "
1564 + " point to single point intents" +
1565 " with no match action",
1566 onfail="NOOPTION: Failed to add multi point" +
1567 " to single point intents" +
1568 " with no match action" )
1569
1570 main.step( "IPV4: Add multi point to single point intents" )
1571 stepResult = main.TRUE
1572 stepResult = main.intentFunction.multiToSingleIntent(
1573 main,
1574 name="IPV4",
1575 hostNames=hostNames,
1576 devices=devices,
1577 ports=None,
1578 ethType="IPV4",
1579 macs=macs,
1580 bandwidth="",
1581 lambdaAlloc=False,
1582 ipProto="",
1583 ipAddresses="",
1584 tcp="",
1585 sw1="s5",
1586 sw2="s2",
1587 expectedLink=18 )
1588
1589 utilities.assert_equals( expect=main.TRUE,
1590 actual=stepResult,
1591 onpass="IPV4: Successfully added multi point"
1592 + " to single point intents" +
1593 " with IPV4 type and MAC addresses",
1594 onfail="IPV4: Failed to add multi point" +
1595 " to single point intents" +
1596 " with IPV4 type and MAC addresses" )
1597
1598 main.step( "IPV4_2: Add multi point to single point intents" )
1599 stepResult = main.TRUE
1600 hostNames = [ 'h8', 'h16', 'h24' ]
1601 stepResult = main.intentFunction.multiToSingleIntent(
1602 main,
1603 name="IPV4",
1604 hostNames=hostNames,
1605 ethType="IPV4",
1606 lambdaAlloc=False )
1607
1608 utilities.assert_equals( expect=main.TRUE,
1609 actual=stepResult,
1610 onpass="IPV4_2: Successfully added multi point"
1611 + " to single point intents" +
1612 " with IPV4 type and no MAC addresses",
1613 onfail="IPV4_2: Failed to add multi point" +
1614 " to single point intents" +
1615 " with IPV4 type and no MAC addresses" )
1616
1617 main.step( "VLAN: Add multi point to single point intents" )
1618 stepResult = main.TRUE
1619 hostNames = [ 'h5', 'h13', 'h21' ]
1620 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \
1621 'of:0000000000000007/5' ]
1622 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
1623 stepResult = main.intentFunction.multiToSingleIntent(
1624 main,
1625 name="VLAN",
1626 hostNames=hostNames,
1627 devices=devices,
1628 ports=None,
1629 ethType="IPV4",
1630 macs=macs,
1631 bandwidth="",
1632 lambdaAlloc=False,
1633 ipProto="",
1634 ipAddresses="",
1635 tcp="",
1636 sw1="s5",
1637 sw2="s2",
1638 expectedLink=18 )
1639
1640 utilities.assert_equals( expect=main.TRUE,
1641 actual=stepResult,
1642 onpass="VLAN: Successfully added multi point"
1643 + " to single point intents" +
1644 " with IPV4 type and MAC addresses" +
1645 " in the same VLAN",
1646 onfail="VLAN: Failed to add multi point" +
1647 " to single point intents" )
1648
1649 def CASE5000( self, main ):
1650 """
Jeremy2f190ca2016-01-29 15:23:57 -08001651 Tests Host Mobility
1652 Modifies the topology location of h1
kelvin-onlab44147802015-07-27 17:57:31 -07001653 """
Jeremydd9bda62016-04-18 12:02:32 -07001654 if main.initialized == main.FALSE:
1655 main.log.error( "Test components did not start correctly, skipping further tests" )
1656 main.skipCase()
1657 # Assert variables - These variable's name|format must be followed
1658 # if you want to use the wrapper function
kelvin-onlab44147802015-07-27 17:57:31 -07001659 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -07001660 try:
1661 assert main.CLIs
1662 except AssertionError:
1663 main.log.error( "There is no main.CLIs, skipping test cases" )
1664 main.initialized = main.FALSE
1665 main.skipCase()
1666 try:
1667 assert main.Mininet1
1668 except AssertionError:
1669 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1670 main.initialized = main.FALSE
1671 main.skipCase()
1672 try:
1673 assert main.numSwitch
1674 except AssertionError:
1675 main.log.error( "Place the total number of switch topology in \
1676 main.numSwitch" )
1677 main.initialized = main.FALSE
1678 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001679 main.case( "Test host mobility with host intents " )
Jeremy2f190ca2016-01-29 15:23:57 -08001680 main.step( "Testing host mobility by moving h1 from s5 to s6" )
kelvin-onlab44147802015-07-27 17:57:31 -07001681 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1682
1683 main.log.info( "Moving h1 from s5 to s6")
kelvin-onlab44147802015-07-27 17:57:31 -07001684 main.Mininet1.moveHost( "h1","s5","s6" )
1685
Jeremy2f190ca2016-01-29 15:23:57 -08001686 # Send discovery ping from moved host
1687 # Moving the host brings down the default interfaces and creates a new one.
1688 # Scapy is restarted on this host to detect the new interface
1689 main.h1.stopScapy()
1690 main.h1.startScapy()
1691
1692 # Discover new host location in ONOS and populate host data.
1693 # Host 1 IP and MAC should be unchanged
1694 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
1695 main.intentFunction.populateHostData( main )
1696
kelvin-onlab44147802015-07-27 17:57:31 -07001697 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1698
1699 utilities.assert_equals( expect="of:0000000000000006",
1700 actual=h1PostMove,
1701 onpass="Mobility: Successfully moved h1 to s6",
Jeremy2f190ca2016-01-29 15:23:57 -08001702 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlab44147802015-07-27 17:57:31 -07001703 " to single point intents" +
1704 " with IPV4 type and MAC addresses" +
1705 " in the same VLAN" )
1706
1707 main.step( "IPV4: Add host intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001708 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
1709 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
1710 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
1711
1712 installResult = main.intentFunction.installHostIntent( main,
1713 name='IPV4 Mobility IPV4',
kelvin-onlab44147802015-07-27 17:57:31 -07001714 onosNode='0',
Jeremy2f190ca2016-01-29 15:23:57 -08001715 host1=host1,
1716 host2=host2)
1717 if installResult:
1718 testResult = main.intentFunction.testHostIntent( main,
1719 name='Host Mobility IPV4',
1720 intentId = installResult,
1721 onosNode='0',
1722 host1=host1,
1723 host2=host2,
1724 sw1="s6",
1725 sw2="s2",
1726 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001727
1728 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001729 actual=testResult,
1730 onpass=main.assertReturnString,
1731 onfail=main.assertReturnString )
1732
1733 main.intentFunction.report( main )
1734