blob: 3824ea3f15b9031de3af4e21be8fe29828e2ada8 [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 Songstercc5414b2016-07-11 10:59:53 -0700788 for i in range( main.numCtrls ):
789 main.node = main.CLIs2[ i ]
Jeremy Songster17147f22016-05-31 18:30:52 -0700790 ip = main.ONOSip[ i ]
791 main.node.ip_address = ip
Jeremy Songster31aad312016-06-13 16:32:11 -0700792 scpResult = scpResult and main.ONOSbench.scp( main.node ,
793 "/opt/onos/log/karaf.log",
794 "/tmp/karaf.log",
795 direction="from" )
796 copyResult = copyResult and main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
797 copyFileName=( "karaf.log.node{0}.cycle{1}".format( str( i + 1 ), str( main.cycle ) ) ) )
798 if scpResult and copyResult:
799 stepResult = main.TRUE and stepResult
800 else:
801 stepResult = main.FALSE and stepResult
Jeremy Songster31aad312016-06-13 16:32:11 -0700802 utilities.assert_equals( expect=main.TRUE,
803 actual=stepResult,
804 onpass="Successfully copied remote ONOS logs",
805 onfail="Failed to copy remote ONOS logs" )
Jeremy Songster17147f22016-05-31 18:30:52 -0700806
kelvin-onlab44147802015-07-27 17:57:31 -0700807 def CASE1000( self, main ):
808 """
809 Add host intents between 2 host:
810 - Discover hosts
811 - Add host intents
812 - Check intents
813 - Verify flows
814 - Ping hosts
815 - Reroute
816 - Link down
817 - Verify flows
818 - Check topology
819 - Ping hosts
820 - Link up
821 - Verify flows
822 - Check topology
823 - Ping hosts
824 - Remove intents
825 """
826 import time
827 import json
828 import re
Jeremydd9bda62016-04-18 12:02:32 -0700829 if main.initialized == main.FALSE:
830 main.log.error( "Test components did not start correctly, skipping further tests" )
831 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700832 # Assert variables - These variable's name|format must be followed
833 # if you want to use the wrapper function
834 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -0700835 try:
836 assert main.CLIs
837 except AssertionError:
838 main.log.error( "There is no main.CLIs, skipping test cases" )
839 main.initialized = main.FALSE
840 main.skipCase()
841 try:
842 assert main.Mininet1
843 except AssertionError:
844 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
845 main.initialized = main.FALSE
846 main.skipCase()
847 try:
848 assert main.numSwitch
849 except AssertionError:
850 main.log.error( "Place the total number of switch topology in \
851 main.numSwitch" )
852 main.initialized = main.FALSE
853 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700854
Jeremye1ea0602016-02-08 16:35:05 -0800855 # Save leader candidates
856 intentLeadersOld = main.CLIs2[ 0 ].leaderCandidates()
857
kelvin-onlab44147802015-07-27 17:57:31 -0700858 main.case( "Host Intents Test - " + str( main.numCtrls ) +
Jeremyeb51cb12016-03-28 17:53:35 -0700859 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -0700860 main.caseExplanation = "This test case tests Host intents using " +\
861 str( main.numCtrls ) + " node(s) cluster;\n" +\
862 "Different type of hosts will be tested in " +\
863 "each step such as IPV4, Dual stack, VLAN " +\
Jeremyeb51cb12016-03-28 17:53:35 -0700864 "etc;\nThe test will use OF " + main.OFProtocol +\
865 " OVS running in Mininet and compile intents" +\
866 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -0700867
Jeremy2f190ca2016-01-29 15:23:57 -0800868 main.step( "IPV4: Add and test host intents between h1 and h9" )
869 main.assertReturnString = "Assertion result for IPV4 host intent with mac addresses\n"
870 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
871 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
872 testResult = main.FALSE
873 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlab44147802015-07-27 17:57:31 -0700874 name='IPV4',
Jeremy2f190ca2016-01-29 15:23:57 -0800875 onosNode='0',
876 host1=host1,
877 host2=host2 )
878
879 if installResult:
880 testResult = main.intentFunction.testHostIntent( main,
881 name='IPV4',
882 intentId = installResult,
883 onosNode='0',
884 host1=host1,
885 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700886 sw1='s5',
887 sw2='s2',
Jeremy2f190ca2016-01-29 15:23:57 -0800888 expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700889
890 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800891 actual=testResult,
892 onpass=main.assertReturnString,
893 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700894
895 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800896 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
897 host1 = { "name":"h3", "id":"00:00:00:00:00:03/-1" }
898 host2 = { "name":"h11","id":"00:00:00:00:00:0B/-1"}
899 testResult = main.FALSE
900 installResult = main.intentFunction.installHostIntent( main,
901 name='DUALSTACK1',
902 onosNode='0',
903 host1=host1,
904 host2=host2 )
905
906 if installResult:
907 testResult = main.intentFunction.testHostIntent( main,
908 name='DUALSTACK1',
909 intentId = installResult,
910 onosNode='0',
911 host1=host1,
912 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700913 sw1='s5',
914 sw2='s2',
Jeremy2f190ca2016-01-29 15:23:57 -0800915 expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700916
917 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800918 actual=testResult,
919 onpass=main.assertReturnString,
920 onfail=main.assertReturnString)
kelvin-onlab44147802015-07-27 17:57:31 -0700921
922 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800923 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
924 host1 = { "name":"h1" }
925 host2 = { "name":"h11" }
926 testResult = main.FALSE
927 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlab44147802015-07-27 17:57:31 -0700928 name='DUALSTACK2',
Jeremy2f190ca2016-01-29 15:23:57 -0800929 onosNode='0',
930 host1=host1,
931 host2=host2 )
932
933 if installResult:
934 testResult = main.intentFunction.testHostIntent( main,
935 name='DUALSTACK2',
936 intentId = installResult,
937 onosNode='0',
938 host1=host1,
939 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700940 sw1='s5',
941 sw2='s2',
Jeremy2f190ca2016-01-29 15:23:57 -0800942 expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700943
944 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800945 actual=testResult,
946 onpass=main.assertReturnString,
947 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700948
949 main.step( "1HOP: Add host intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -0800950 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
951 host1 = { "name":"h1" }
952 host2 = { "name":"h3" }
953 testResult = main.FALSE
954 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlab44147802015-07-27 17:57:31 -0700955 name='1HOP',
Jeremy2f190ca2016-01-29 15:23:57 -0800956 onosNode='0',
957 host1=host1,
958 host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700959
Jeremy2f190ca2016-01-29 15:23:57 -0800960 if installResult:
961 testResult = main.intentFunction.testHostIntent( main,
962 name='1HOP',
963 intentId = installResult,
964 onosNode='0',
965 host1=host1,
966 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700967 sw1='s5',
968 sw2='s2',
Jeremy2f190ca2016-01-29 15:23:57 -0800969 expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700970
971 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800972 actual=testResult,
973 onpass=main.assertReturnString,
974 onfail=main.assertReturnString )
975
976 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
977 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700978 host1 = { "name":"h4","id":"00:00:00:00:00:04/100", "vlanId":"100" }
979 host2 = { "name":"h12","id":"00:00:00:00:00:0C/100", "vlanId":"100" }
Jeremy2f190ca2016-01-29 15:23:57 -0800980 testResult = main.FALSE
981 installResult = main.intentFunction.installHostIntent( main,
982 name='VLAN1',
983 onosNode='0',
984 host1=host1,
985 host2=host2 )
986
987 if installResult:
988 testResult = main.intentFunction.testHostIntent( main,
989 name='VLAN1',
990 intentId = installResult,
991 onosNode='0',
992 host1=host1,
993 host2=host2,
994 sw1='s5',
995 sw2='s2',
996 expectedLink = 18 )
997
998 utilities.assert_equals( expect=main.TRUE,
999 actual=testResult,
1000 onpass=main.assertReturnString,
1001 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001002
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001003 # This step isn't currently possible to perform in the REST API
1004 # main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
1005 # main.assertReturnString = "Assertion Result different VLAN negative test\n"
1006 # host1 = { "name":"h13" }
1007 # host2 = { "name":"h20" }
1008 # testResult = main.FALSE
1009 # installResult = main.intentFunction.installHostIntent( main,
1010 # name='VLAN2',
1011 # onosNode='0',
1012 # host1=host1,
1013 # host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -07001014
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001015 # if installResult:
1016 # testResult = main.intentFunction.testHostIntent( main,
1017 # name='VLAN2',
1018 # intentId = installResult,
1019 # onosNode='0',
1020 # host1=host1,
1021 # host2=host2,
1022 # sw1='s5',
1023 # sw2='s2',
1024 # expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001025
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001026 # utilities.assert_equals( expect=main.TRUE,
1027 # actual=testResult,
1028 # onpass=main.assertReturnString,
1029 # onfail=main.assertReturnString )
Jeremy2f190ca2016-01-29 15:23:57 -08001030
Jeremye1ea0602016-02-08 16:35:05 -08001031 # Change the following to use the REST API when leader checking is
1032 # supported by it
Jeremy2f190ca2016-01-29 15:23:57 -08001033
Jeremye1ea0602016-02-08 16:35:05 -08001034 main.step( "Confirm that ONOS leadership is unchanged")
1035 intentLeadersNew = main.CLIs2[ 0 ].leaderCandidates()
1036 main.intentFunction.checkLeaderChange( intentLeadersOld,
1037 intentLeadersNew )
Jeremy2f190ca2016-01-29 15:23:57 -08001038
Jeremye1ea0602016-02-08 16:35:05 -08001039 utilities.assert_equals( expect=main.TRUE,
1040 actual=testResult,
1041 onpass="ONOS Leaders Unchanged",
1042 onfail="ONOS Leader Mismatch")
Jeremy2f190ca2016-01-29 15:23:57 -08001043
1044 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001045
1046 def CASE2000( self, main ):
1047 """
1048 Add point intents between 2 hosts:
1049 - Get device ids | ports
1050 - Add point intents
1051 - Check intents
1052 - Verify flows
1053 - Ping hosts
1054 - Reroute
1055 - Link down
1056 - Verify flows
1057 - Check topology
1058 - Ping hosts
1059 - Link up
1060 - Verify flows
1061 - Check topology
1062 - Ping hosts
1063 - Remove intents
1064 """
1065 import time
1066 import json
1067 import re
Jeremydd9bda62016-04-18 12:02:32 -07001068 if main.initialized == main.FALSE:
1069 main.log.error( "Test components did not start correctly, skipping further tests" )
1070 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001071 # Assert variables - These variable's name|format must be followed
1072 # if you want to use the wrapper function
1073 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -07001074 try:
1075 assert main.CLIs
1076 except AssertionError:
1077 main.log.error( "There is no main.CLIs, skipping test cases" )
1078 main.initialized = main.FALSE
1079 main.skipCase()
1080 try:
1081 assert main.Mininet1
1082 except AssertionError:
1083 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1084 main.initialized = main.FALSE
1085 main.skipCase()
1086 try:
1087 assert main.numSwitch
1088 except AssertionError:
1089 main.log.error( "Place the total number of switch topology in \
1090 main.numSwitch" )
1091 main.initialized = main.FALSE
1092 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001093
1094 main.case( "Point Intents Test - " + str( main.numCtrls ) +
Jeremyeb51cb12016-03-28 17:53:35 -07001095 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -07001096 main.caseExplanation = "This test case will test point to point" +\
1097 " intents using " + str( main.numCtrls ) +\
1098 " node(s) cluster;\n" +\
1099 "Different type of hosts will be tested in " +\
1100 "each step such as IPV4, Dual stack, VLAN etc" +\
1101 ";\nThe test will use OF " + main.OFProtocol +\
Jeremyeb51cb12016-03-28 17:53:35 -07001102 " OVS running in Mininet and compile intents" +\
1103 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001104
1105 # No option point intents
1106 main.step( "NOOPTION: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001107 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
1108 senders = [
1109 { "name":"h1","device":"of:0000000000000005/1" }
1110 ]
1111 recipients = [
1112 { "name":"h9","device":"of:0000000000000006/1" }
1113 ]
1114 testResult = main.FALSE
1115 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001116 main,
1117 name="NOOPTION",
Jeremy2f190ca2016-01-29 15:23:57 -08001118 senders=senders,
1119 recipients=recipients )
1120
1121 if installResult:
1122 testResult = main.intentFunction.testPointIntent(
1123 main,
1124 intentId=installResult,
1125 name="NOOPTION",
1126 senders=senders,
1127 recipients=recipients,
1128 sw1="s5",
1129 sw2="s2",
1130 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001131
1132 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001133 actual=testResult,
1134 onpass=main.assertReturnString,
1135 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001136
kelvin-onlab44147802015-07-27 17:57:31 -07001137 main.step( "IPV4: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001138 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
1139 senders = [
1140 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1141 ]
1142 recipients = [
1143 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09" }
1144 ]
1145 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001146 main,
1147 name="IPV4",
Jeremy2f190ca2016-01-29 15:23:57 -08001148 senders=senders,
1149 recipients=recipients,
1150 ethType="IPV4" )
1151
1152 if installResult:
1153 testResult = main.intentFunction.testPointIntent(
1154 main,
1155 intentId=installResult,
1156 name="IPV4",
1157 senders=senders,
1158 recipients=recipients,
1159 sw1="s5",
1160 sw2="s2",
1161 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001162
1163 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001164 actual=testResult,
1165 onpass=main.assertReturnString,
1166 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001167 main.step( "IPV4_2: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001168 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
1169 senders = [
1170 { "name":"h1","device":"of:0000000000000005/1" }
1171 ]
1172 recipients = [
1173 { "name":"h9","device":"of:0000000000000006/1" }
1174 ]
1175 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001176 main,
1177 name="IPV4_2",
Jeremy2f190ca2016-01-29 15:23:57 -08001178 senders=senders,
1179 recipients=recipients,
1180 ethType="IPV4" )
1181
1182 if installResult:
1183 testResult = main.intentFunction.testPointIntent(
1184 main,
1185 intentId=installResult,
1186 name="IPV4_2",
1187 senders=senders,
1188 recipients=recipients,
1189 sw1="s5",
1190 sw2="s2",
1191 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001192
1193 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001194 actual=testResult,
1195 onpass=main.assertReturnString,
1196 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001197
kelvin-onlab0e684682015-08-11 18:51:41 -07001198 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001199 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
1200 senders = [
1201 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01",
1202 "ip":main.h1.hostIp }
1203 ]
1204 recipients = [
1205 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09",
1206 "ip":main.h9.hostIp }
1207 ]
kelvin-onlab44147802015-07-27 17:57:31 -07001208 ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
1209 # Uneccessary, not including this in the selectors
Jeremy2f190ca2016-01-29 15:23:57 -08001210 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
1211 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
kelvin-onlab44147802015-07-27 17:57:31 -07001212
Jeremy2f190ca2016-01-29 15:23:57 -08001213 installResult = main.intentFunction.installPointIntent(
1214 main,
1215 name="SDNIP-ICMP",
1216 senders=senders,
1217 recipients=recipients,
1218 ethType="IPV4",
1219 ipProto=ipProto,
1220 tcpSrc=tcpSrc,
1221 tcpDst=tcpDst )
1222
1223 if installResult:
1224 testResult = main.intentFunction.testPointIntent(
1225 main,
1226 intentId=installResult,
1227 name="SDNIP_ICMP",
1228 senders=senders,
1229 recipients=recipients,
1230 sw1="s5",
1231 sw2="s2",
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001232 expectedLink=18,
1233 useTCP=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001234
1235 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001236 actual=testResult,
1237 onpass=main.assertReturnString,
1238 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001239
kelvin-onlab0e684682015-08-11 18:51:41 -07001240 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001241 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
kelvin-onlab44147802015-07-27 17:57:31 -07001242 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
1243 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab0e684682015-08-11 18:51:41 -07001244 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
1245 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlab44147802015-07-27 17:57:31 -07001246 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
1247 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
1248 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
1249
kelvin-onlab0e684682015-08-11 18:51:41 -07001250 stepResult = main.intentFunction.pointIntentTcp(
kelvin-onlab44147802015-07-27 17:57:31 -07001251 main,
kelvin-onlab0e684682015-08-11 18:51:41 -07001252 name="SDNIP-TCP",
kelvin-onlab44147802015-07-27 17:57:31 -07001253 host1="h1",
1254 host2="h9",
1255 deviceId1="of:0000000000000005/1",
1256 deviceId2="of:0000000000000006/1",
1257 mac1=mac1,
1258 mac2=mac2,
1259 ethType="IPV4",
kelvin-onlab0e684682015-08-11 18:51:41 -07001260 ipProto=ipProto,
1261 ip1=ip1,
1262 ip2=ip2,
1263 tcp1=tcp1,
1264 tcp2=tcp2 )
kelvin-onlab44147802015-07-27 17:57:31 -07001265
1266 utilities.assert_equals( expect=main.TRUE,
1267 actual=stepResult,
Jeremy2f190ca2016-01-29 15:23:57 -08001268 onpass=main.assertReturnString,
1269 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001270
Jeremy2f190ca2016-01-29 15:23:57 -08001271 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
1272 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
1273 senders = [
1274 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1275 ]
1276 recipients = [
1277 { "name":"h11","device":"of:0000000000000006/3","mac":"00:00:00:00:00:0B" }
1278 ]
1279 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001280 main,
1281 name="DUALSTACK1",
Jeremy2f190ca2016-01-29 15:23:57 -08001282 senders=senders,
1283 recipients=recipients,
1284 ethType="IPV4" )
1285
1286 if installResult:
1287 testResult = main.intentFunction.testPointIntent(
1288 main,
1289 intentId=installResult,
1290 name="DUALSTACK1",
1291 senders=senders,
1292 recipients=recipients,
1293 sw1="s5",
1294 sw2="s2",
1295 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001296
1297 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001298 actual=testResult,
1299 onpass=main.assertReturnString,
1300 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001301
1302 main.step( "VLAN: Add point intents between h5 and h21" )
Jeremy2f190ca2016-01-29 15:23:57 -08001303 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
1304 senders = [
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001305 { "name":"h5","device":"of:0000000000000005/5","mac":"00:00:00:00:00:05", "vlanId":"200" }
Jeremy2f190ca2016-01-29 15:23:57 -08001306 ]
1307 recipients = [
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001308 { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15", "vlanId":"200" }
Jeremy2f190ca2016-01-29 15:23:57 -08001309 ]
1310 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001311 main,
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001312 name="VLAN",
Jeremy2f190ca2016-01-29 15:23:57 -08001313 senders=senders,
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001314 recipients=recipients )
Jeremy2f190ca2016-01-29 15:23:57 -08001315
1316 if installResult:
1317 testResult = main.intentFunction.testPointIntent(
1318 main,
1319 intentId=installResult,
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001320 name="VLAN",
Jeremy2f190ca2016-01-29 15:23:57 -08001321 senders=senders,
1322 recipients=recipients,
1323 sw1="s5",
1324 sw2="s2",
1325 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001326
1327 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001328 actual=testResult,
1329 onpass=main.assertReturnString,
1330 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001331
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001332 # TODO: implement VLAN selector REST API intent test once supported
1333
kelvin-onlab44147802015-07-27 17:57:31 -07001334 main.step( "1HOP: Add point intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -08001335 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
1336 senders = [
1337 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1338 ]
1339 recipients = [
1340 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1341 ]
1342 installResult = main.intentFunction.installPointIntent(
1343 main,
1344 name="1HOP IPV4",
1345 senders=senders,
1346 recipients=recipients,
1347 ethType="IPV4" )
1348
1349 if installResult:
1350 testResult = main.intentFunction.testPointIntent(
1351 main,
1352 intentId=installResult,
1353 name="1HOP IPV4",
1354 senders=senders,
1355 recipients=recipients,
1356 sw1="s5",
1357 sw2="s2",
1358 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001359
1360 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001361 actual=testResult,
1362 onpass=main.assertReturnString,
1363 onfail=main.assertReturnString )
1364
1365 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001366
1367 def CASE3000( self, main ):
1368 """
1369 Add single point to multi point intents
1370 - Get device ids
1371 - Add single point to multi point intents
1372 - Check intents
1373 - Verify flows
1374 - Ping hosts
1375 - Reroute
1376 - Link down
1377 - Verify flows
1378 - Check topology
1379 - Ping hosts
1380 - Link up
1381 - Verify flows
1382 - Check topology
1383 - Ping hosts
1384 - Remove intents
1385 """
1386 assert main, "There is no main"
1387 assert main.CLIs, "There is no main.CLIs"
1388 assert main.Mininet1, "Mininet handle should be named Mininet1"
1389 assert main.numSwitch, "Placed the total number of switch topology in \
1390 main.numSwitch"
1391
1392 main.case( "Single To Multi Point Intents Test - " +
Jeremyeb51cb12016-03-28 17:53:35 -07001393 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -07001394 main.caseExplanation = "This test case will test single point to" +\
1395 " multi point intents using " +\
1396 str( main.numCtrls ) + " node(s) cluster;\n" +\
1397 "Different type of hosts will be tested in " +\
1398 "each step such as IPV4, Dual stack, VLAN etc" +\
1399 ";\nThe test will use OF " + main.OFProtocol +\
Jeremyeb51cb12016-03-28 17:53:35 -07001400 " OVS running in Mininet and compile intents" +\
1401 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001402
1403 main.step( "NOOPTION: Add single point to multi point intents" )
1404 stepResult = main.TRUE
1405 hostNames = [ 'h8', 'h16', 'h24' ]
1406 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
1407 'of:0000000000000007/8' ]
1408 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
1409 stepResult = main.intentFunction.singleToMultiIntent(
1410 main,
1411 name="NOOPTION",
1412 hostNames=hostNames,
1413 devices=devices,
1414 sw1="s5",
1415 sw2="s2",
1416 expectedLink=18 )
1417
1418 utilities.assert_equals( expect=main.TRUE,
1419 actual=stepResult,
1420 onpass="NOOPTION: Successfully added single "
1421 + " point to multi point intents" +
1422 " with no match action",
1423 onfail="NOOPTION: Failed to add single point"
1424 + " point to multi point intents" +
1425 " with no match action" )
1426
1427 main.step( "IPV4: Add single point to multi point intents" )
1428 stepResult = main.TRUE
1429 stepResult = main.intentFunction.singleToMultiIntent(
1430 main,
1431 name="IPV4",
1432 hostNames=hostNames,
1433 devices=devices,
1434 ports=None,
1435 ethType="IPV4",
1436 macs=macs,
1437 bandwidth="",
1438 lambdaAlloc=False,
1439 ipProto="",
1440 ipAddresses="",
1441 tcp="",
1442 sw1="s5",
1443 sw2="s2",
1444 expectedLink=18 )
1445
1446 utilities.assert_equals( expect=main.TRUE,
1447 actual=stepResult,
1448 onpass="IPV4: Successfully added single "
1449 + " point to multi point intents" +
1450 " with IPV4 type and MAC addresses",
1451 onfail="IPV4: Failed to add single point"
1452 + " point to multi point intents" +
1453 " with IPV4 type and MAC addresses" )
1454
1455 main.step( "IPV4_2: Add single point to multi point intents" )
1456 stepResult = main.TRUE
1457 hostNames = [ 'h8', 'h16', 'h24' ]
1458 stepResult = main.intentFunction.singleToMultiIntent(
1459 main,
1460 name="IPV4",
1461 hostNames=hostNames,
1462 ethType="IPV4",
1463 lambdaAlloc=False )
1464
1465 utilities.assert_equals( expect=main.TRUE,
1466 actual=stepResult,
1467 onpass="IPV4_2: Successfully added single "
1468 + " point to multi point intents" +
1469 " with IPV4 type and no MAC addresses",
1470 onfail="IPV4_2: Failed to add single point"
1471 + " point to multi point intents" +
1472 " with IPV4 type and no MAC addresses" )
1473
1474 main.step( "VLAN: Add single point to multi point intents" )
1475 stepResult = main.TRUE
1476 hostNames = [ 'h4', 'h12', 'h20' ]
1477 devices = [ 'of:0000000000000005/4', 'of:0000000000000006/4', \
1478 'of:0000000000000007/4' ]
1479 macs = [ '00:00:00:00:00:04', '00:00:00:00:00:0C', '00:00:00:00:00:14' ]
1480 stepResult = main.intentFunction.singleToMultiIntent(
1481 main,
1482 name="VLAN",
1483 hostNames=hostNames,
1484 devices=devices,
1485 ports=None,
1486 ethType="IPV4",
1487 macs=macs,
1488 bandwidth="",
1489 lambdaAlloc=False,
1490 ipProto="",
1491 ipAddresses="",
1492 tcp="",
1493 sw1="s5",
1494 sw2="s2",
1495 expectedLink=18 )
1496
1497 utilities.assert_equals( expect=main.TRUE,
1498 actual=stepResult,
1499 onpass="VLAN: Successfully added single "
1500 + " point to multi point intents" +
1501 " with IPV4 type and MAC addresses" +
1502 " in the same VLAN",
1503 onfail="VLAN: Failed to add single point"
1504 + " point to multi point intents" +
1505 " with IPV4 type and MAC addresses" +
1506 " in the same VLAN")
1507
1508 def CASE4000( self, main ):
1509 """
1510 Add multi point to single point intents
1511 - Get device ids
1512 - Add multi point to single point intents
1513 - Check intents
1514 - Verify flows
1515 - Ping hosts
1516 - Reroute
1517 - Link down
1518 - Verify flows
1519 - Check topology
1520 - Ping hosts
1521 - Link up
1522 - Verify flows
1523 - Check topology
1524 - Ping hosts
1525 - Remove intents
1526 """
1527 assert main, "There is no main"
1528 assert main.CLIs, "There is no main.CLIs"
1529 assert main.Mininet1, "Mininet handle should be named Mininet1"
1530 assert main.numSwitch, "Placed the total number of switch topology in \
1531 main.numSwitch"
1532
1533 main.case( "Multi To Single Point Intents Test - " +
Jeremyeb51cb12016-03-28 17:53:35 -07001534 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -07001535 main.caseExplanation = "This test case will test single point to" +\
1536 " multi point intents using " +\
1537 str( main.numCtrls ) + " node(s) cluster;\n" +\
1538 "Different type of hosts will be tested in " +\
1539 "each step such as IPV4, Dual stack, VLAN etc" +\
1540 ";\nThe test will use OF " + main.OFProtocol +\
Jeremyeb51cb12016-03-28 17:53:35 -07001541 " OVS running in Mininet and compile intents" +\
1542 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001543
1544 main.step( "NOOPTION: Add multi point to single point intents" )
1545 stepResult = main.TRUE
1546 hostNames = [ 'h8', 'h16', 'h24' ]
1547 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
1548 'of:0000000000000007/8' ]
1549 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
1550 stepResult = main.intentFunction.multiToSingleIntent(
1551 main,
1552 name="NOOPTION",
1553 hostNames=hostNames,
1554 devices=devices,
1555 sw1="s5",
1556 sw2="s2",
1557 expectedLink=18 )
1558
1559 utilities.assert_equals( expect=main.TRUE,
1560 actual=stepResult,
1561 onpass="NOOPTION: Successfully added multi "
1562 + " point to single point intents" +
1563 " with no match action",
1564 onfail="NOOPTION: Failed to add multi point" +
1565 " to single point intents" +
1566 " with no match action" )
1567
1568 main.step( "IPV4: Add multi point to single point intents" )
1569 stepResult = main.TRUE
1570 stepResult = main.intentFunction.multiToSingleIntent(
1571 main,
1572 name="IPV4",
1573 hostNames=hostNames,
1574 devices=devices,
1575 ports=None,
1576 ethType="IPV4",
1577 macs=macs,
1578 bandwidth="",
1579 lambdaAlloc=False,
1580 ipProto="",
1581 ipAddresses="",
1582 tcp="",
1583 sw1="s5",
1584 sw2="s2",
1585 expectedLink=18 )
1586
1587 utilities.assert_equals( expect=main.TRUE,
1588 actual=stepResult,
1589 onpass="IPV4: Successfully added multi point"
1590 + " to single point intents" +
1591 " with IPV4 type and MAC addresses",
1592 onfail="IPV4: Failed to add multi point" +
1593 " to single point intents" +
1594 " with IPV4 type and MAC addresses" )
1595
1596 main.step( "IPV4_2: Add multi point to single point intents" )
1597 stepResult = main.TRUE
1598 hostNames = [ 'h8', 'h16', 'h24' ]
1599 stepResult = main.intentFunction.multiToSingleIntent(
1600 main,
1601 name="IPV4",
1602 hostNames=hostNames,
1603 ethType="IPV4",
1604 lambdaAlloc=False )
1605
1606 utilities.assert_equals( expect=main.TRUE,
1607 actual=stepResult,
1608 onpass="IPV4_2: Successfully added multi point"
1609 + " to single point intents" +
1610 " with IPV4 type and no MAC addresses",
1611 onfail="IPV4_2: Failed to add multi point" +
1612 " to single point intents" +
1613 " with IPV4 type and no MAC addresses" )
1614
1615 main.step( "VLAN: Add multi point to single point intents" )
1616 stepResult = main.TRUE
1617 hostNames = [ 'h5', 'h13', 'h21' ]
1618 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \
1619 'of:0000000000000007/5' ]
1620 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
1621 stepResult = main.intentFunction.multiToSingleIntent(
1622 main,
1623 name="VLAN",
1624 hostNames=hostNames,
1625 devices=devices,
1626 ports=None,
1627 ethType="IPV4",
1628 macs=macs,
1629 bandwidth="",
1630 lambdaAlloc=False,
1631 ipProto="",
1632 ipAddresses="",
1633 tcp="",
1634 sw1="s5",
1635 sw2="s2",
1636 expectedLink=18 )
1637
1638 utilities.assert_equals( expect=main.TRUE,
1639 actual=stepResult,
1640 onpass="VLAN: Successfully added multi point"
1641 + " to single point intents" +
1642 " with IPV4 type and MAC addresses" +
1643 " in the same VLAN",
1644 onfail="VLAN: Failed to add multi point" +
1645 " to single point intents" )
1646
1647 def CASE5000( self, main ):
1648 """
Jeremy2f190ca2016-01-29 15:23:57 -08001649 Tests Host Mobility
1650 Modifies the topology location of h1
kelvin-onlab44147802015-07-27 17:57:31 -07001651 """
Jeremydd9bda62016-04-18 12:02:32 -07001652 if main.initialized == main.FALSE:
1653 main.log.error( "Test components did not start correctly, skipping further tests" )
1654 main.skipCase()
1655 # Assert variables - These variable's name|format must be followed
1656 # if you want to use the wrapper function
kelvin-onlab44147802015-07-27 17:57:31 -07001657 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -07001658 try:
1659 assert main.CLIs
1660 except AssertionError:
1661 main.log.error( "There is no main.CLIs, skipping test cases" )
1662 main.initialized = main.FALSE
1663 main.skipCase()
1664 try:
1665 assert main.Mininet1
1666 except AssertionError:
1667 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1668 main.initialized = main.FALSE
1669 main.skipCase()
1670 try:
1671 assert main.numSwitch
1672 except AssertionError:
1673 main.log.error( "Place the total number of switch topology in \
1674 main.numSwitch" )
1675 main.initialized = main.FALSE
1676 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001677 main.case( "Test host mobility with host intents " )
Jeremy2f190ca2016-01-29 15:23:57 -08001678 main.step( "Testing host mobility by moving h1 from s5 to s6" )
kelvin-onlab44147802015-07-27 17:57:31 -07001679 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1680
1681 main.log.info( "Moving h1 from s5 to s6")
kelvin-onlab44147802015-07-27 17:57:31 -07001682 main.Mininet1.moveHost( "h1","s5","s6" )
1683
Jeremy2f190ca2016-01-29 15:23:57 -08001684 # Send discovery ping from moved host
1685 # Moving the host brings down the default interfaces and creates a new one.
1686 # Scapy is restarted on this host to detect the new interface
1687 main.h1.stopScapy()
1688 main.h1.startScapy()
1689
1690 # Discover new host location in ONOS and populate host data.
1691 # Host 1 IP and MAC should be unchanged
1692 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
1693 main.intentFunction.populateHostData( main )
1694
kelvin-onlab44147802015-07-27 17:57:31 -07001695 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1696
1697 utilities.assert_equals( expect="of:0000000000000006",
1698 actual=h1PostMove,
1699 onpass="Mobility: Successfully moved h1 to s6",
Jeremy2f190ca2016-01-29 15:23:57 -08001700 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlab44147802015-07-27 17:57:31 -07001701 " to single point intents" +
1702 " with IPV4 type and MAC addresses" +
1703 " in the same VLAN" )
1704
1705 main.step( "IPV4: Add host intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001706 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
1707 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
1708 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
1709
1710 installResult = main.intentFunction.installHostIntent( main,
1711 name='IPV4 Mobility IPV4',
kelvin-onlab44147802015-07-27 17:57:31 -07001712 onosNode='0',
Jeremy2f190ca2016-01-29 15:23:57 -08001713 host1=host1,
1714 host2=host2)
1715 if installResult:
1716 testResult = main.intentFunction.testHostIntent( main,
1717 name='Host Mobility IPV4',
1718 intentId = installResult,
1719 onosNode='0',
1720 host1=host1,
1721 host2=host2,
1722 sw1="s6",
1723 sw2="s2",
1724 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001725
1726 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001727 actual=testResult,
1728 onpass=main.assertReturnString,
1729 onfail=main.assertReturnString )
1730
1731 main.intentFunction.report( main )
1732