blob: 5a8e5cc86b7488b89d901f2970d16c242314f3f0 [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" )
785 i = 0
Jeremy Songster4e001502016-06-08 10:42:36 -0700786 for cli in main.CLIs2:
Jeremy Songster17147f22016-05-31 18:30:52 -0700787 main.node = cli
788 ip = main.ONOSip[ i ]
789 main.node.ip_address = ip
790 main.ONOSbench.scp( main.node ,
791 "/opt/onos/log/karaf.log",
792 "/tmp/karaf.log",
793 direction="from" )
794 main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
795 copyFileName=( "karaf.log.node{0}.cycle{1}".format( str( i + 1 ), str( main.cycle ) ) ) )
796 i += 1
797
kelvin-onlab44147802015-07-27 17:57:31 -0700798 def CASE1000( self, main ):
799 """
800 Add host intents between 2 host:
801 - Discover hosts
802 - Add host intents
803 - Check intents
804 - Verify flows
805 - Ping hosts
806 - Reroute
807 - Link down
808 - Verify flows
809 - Check topology
810 - Ping hosts
811 - Link up
812 - Verify flows
813 - Check topology
814 - Ping hosts
815 - Remove intents
816 """
817 import time
818 import json
819 import re
Jeremydd9bda62016-04-18 12:02:32 -0700820 if main.initialized == main.FALSE:
821 main.log.error( "Test components did not start correctly, skipping further tests" )
822 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700823 # Assert variables - These variable's name|format must be followed
824 # if you want to use the wrapper function
825 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -0700826 try:
827 assert main.CLIs
828 except AssertionError:
829 main.log.error( "There is no main.CLIs, skipping test cases" )
830 main.initialized = main.FALSE
831 main.skipCase()
832 try:
833 assert main.Mininet1
834 except AssertionError:
835 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
836 main.initialized = main.FALSE
837 main.skipCase()
838 try:
839 assert main.numSwitch
840 except AssertionError:
841 main.log.error( "Place the total number of switch topology in \
842 main.numSwitch" )
843 main.initialized = main.FALSE
844 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700845
Jeremye1ea0602016-02-08 16:35:05 -0800846 # Save leader candidates
847 intentLeadersOld = main.CLIs2[ 0 ].leaderCandidates()
848
kelvin-onlab44147802015-07-27 17:57:31 -0700849 main.case( "Host Intents Test - " + str( main.numCtrls ) +
Jeremyeb51cb12016-03-28 17:53:35 -0700850 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -0700851 main.caseExplanation = "This test case tests Host intents using " +\
852 str( main.numCtrls ) + " node(s) cluster;\n" +\
853 "Different type of hosts will be tested in " +\
854 "each step such as IPV4, Dual stack, VLAN " +\
Jeremyeb51cb12016-03-28 17:53:35 -0700855 "etc;\nThe test will use OF " + main.OFProtocol +\
856 " OVS running in Mininet and compile intents" +\
857 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -0700858
Jeremy2f190ca2016-01-29 15:23:57 -0800859 main.step( "IPV4: Add and test host intents between h1 and h9" )
860 main.assertReturnString = "Assertion result for IPV4 host intent with mac addresses\n"
861 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
862 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
863 testResult = main.FALSE
864 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlab44147802015-07-27 17:57:31 -0700865 name='IPV4',
Jeremy2f190ca2016-01-29 15:23:57 -0800866 onosNode='0',
867 host1=host1,
868 host2=host2 )
869
870 if installResult:
871 testResult = main.intentFunction.testHostIntent( main,
872 name='IPV4',
873 intentId = installResult,
874 onosNode='0',
875 host1=host1,
876 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700877 sw1='s5',
878 sw2='s2',
Jeremy2f190ca2016-01-29 15:23:57 -0800879 expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700880
881 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800882 actual=testResult,
883 onpass=main.assertReturnString,
884 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700885
886 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800887 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
888 host1 = { "name":"h3", "id":"00:00:00:00:00:03/-1" }
889 host2 = { "name":"h11","id":"00:00:00:00:00:0B/-1"}
890 testResult = main.FALSE
891 installResult = main.intentFunction.installHostIntent( main,
892 name='DUALSTACK1',
893 onosNode='0',
894 host1=host1,
895 host2=host2 )
896
897 if installResult:
898 testResult = main.intentFunction.testHostIntent( main,
899 name='DUALSTACK1',
900 intentId = installResult,
901 onosNode='0',
902 host1=host1,
903 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700904 sw1='s5',
905 sw2='s2',
Jeremy2f190ca2016-01-29 15:23:57 -0800906 expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700907
908 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800909 actual=testResult,
910 onpass=main.assertReturnString,
911 onfail=main.assertReturnString)
kelvin-onlab44147802015-07-27 17:57:31 -0700912
913 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800914 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
915 host1 = { "name":"h1" }
916 host2 = { "name":"h11" }
917 testResult = main.FALSE
918 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlab44147802015-07-27 17:57:31 -0700919 name='DUALSTACK2',
Jeremy2f190ca2016-01-29 15:23:57 -0800920 onosNode='0',
921 host1=host1,
922 host2=host2 )
923
924 if installResult:
925 testResult = main.intentFunction.testHostIntent( main,
926 name='DUALSTACK2',
927 intentId = installResult,
928 onosNode='0',
929 host1=host1,
930 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700931 sw1='s5',
932 sw2='s2',
Jeremy2f190ca2016-01-29 15:23:57 -0800933 expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700934
935 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800936 actual=testResult,
937 onpass=main.assertReturnString,
938 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700939
940 main.step( "1HOP: Add host intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -0800941 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
942 host1 = { "name":"h1" }
943 host2 = { "name":"h3" }
944 testResult = main.FALSE
945 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlab44147802015-07-27 17:57:31 -0700946 name='1HOP',
Jeremy2f190ca2016-01-29 15:23:57 -0800947 onosNode='0',
948 host1=host1,
949 host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700950
Jeremy2f190ca2016-01-29 15:23:57 -0800951 if installResult:
952 testResult = main.intentFunction.testHostIntent( main,
953 name='1HOP',
954 intentId = installResult,
955 onosNode='0',
956 host1=host1,
957 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700958 sw1='s5',
959 sw2='s2',
Jeremy2f190ca2016-01-29 15:23:57 -0800960 expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700961
962 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800963 actual=testResult,
964 onpass=main.assertReturnString,
965 onfail=main.assertReturnString )
966
967 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
968 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700969 host1 = { "name":"h4","id":"00:00:00:00:00:04/100", "vlanId":"100" }
970 host2 = { "name":"h12","id":"00:00:00:00:00:0C/100", "vlanId":"100" }
Jeremy2f190ca2016-01-29 15:23:57 -0800971 testResult = main.FALSE
972 installResult = main.intentFunction.installHostIntent( main,
973 name='VLAN1',
974 onosNode='0',
975 host1=host1,
976 host2=host2 )
977
978 if installResult:
979 testResult = main.intentFunction.testHostIntent( main,
980 name='VLAN1',
981 intentId = installResult,
982 onosNode='0',
983 host1=host1,
984 host2=host2,
985 sw1='s5',
986 sw2='s2',
987 expectedLink = 18 )
988
989 utilities.assert_equals( expect=main.TRUE,
990 actual=testResult,
991 onpass=main.assertReturnString,
992 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700993
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700994 # This step isn't currently possible to perform in the REST API
995 # main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
996 # main.assertReturnString = "Assertion Result different VLAN negative test\n"
997 # host1 = { "name":"h13" }
998 # host2 = { "name":"h20" }
999 # testResult = main.FALSE
1000 # installResult = main.intentFunction.installHostIntent( main,
1001 # name='VLAN2',
1002 # onosNode='0',
1003 # host1=host1,
1004 # host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -07001005
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001006 # if installResult:
1007 # testResult = main.intentFunction.testHostIntent( main,
1008 # name='VLAN2',
1009 # intentId = installResult,
1010 # onosNode='0',
1011 # host1=host1,
1012 # host2=host2,
1013 # sw1='s5',
1014 # sw2='s2',
1015 # expectedLink = 18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001016
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001017 # utilities.assert_equals( expect=main.TRUE,
1018 # actual=testResult,
1019 # onpass=main.assertReturnString,
1020 # onfail=main.assertReturnString )
Jeremy2f190ca2016-01-29 15:23:57 -08001021
Jeremye1ea0602016-02-08 16:35:05 -08001022 # Change the following to use the REST API when leader checking is
1023 # supported by it
Jeremy2f190ca2016-01-29 15:23:57 -08001024
Jeremye1ea0602016-02-08 16:35:05 -08001025 main.step( "Confirm that ONOS leadership is unchanged")
1026 intentLeadersNew = main.CLIs2[ 0 ].leaderCandidates()
1027 main.intentFunction.checkLeaderChange( intentLeadersOld,
1028 intentLeadersNew )
Jeremy2f190ca2016-01-29 15:23:57 -08001029
Jeremye1ea0602016-02-08 16:35:05 -08001030 utilities.assert_equals( expect=main.TRUE,
1031 actual=testResult,
1032 onpass="ONOS Leaders Unchanged",
1033 onfail="ONOS Leader Mismatch")
Jeremy2f190ca2016-01-29 15:23:57 -08001034
1035 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001036
1037 def CASE2000( self, main ):
1038 """
1039 Add point intents between 2 hosts:
1040 - Get device ids | ports
1041 - Add point intents
1042 - Check intents
1043 - Verify flows
1044 - Ping hosts
1045 - Reroute
1046 - Link down
1047 - Verify flows
1048 - Check topology
1049 - Ping hosts
1050 - Link up
1051 - Verify flows
1052 - Check topology
1053 - Ping hosts
1054 - Remove intents
1055 """
1056 import time
1057 import json
1058 import re
Jeremydd9bda62016-04-18 12:02:32 -07001059 if main.initialized == main.FALSE:
1060 main.log.error( "Test components did not start correctly, skipping further tests" )
1061 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001062 # Assert variables - These variable's name|format must be followed
1063 # if you want to use the wrapper function
1064 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -07001065 try:
1066 assert main.CLIs
1067 except AssertionError:
1068 main.log.error( "There is no main.CLIs, skipping test cases" )
1069 main.initialized = main.FALSE
1070 main.skipCase()
1071 try:
1072 assert main.Mininet1
1073 except AssertionError:
1074 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1075 main.initialized = main.FALSE
1076 main.skipCase()
1077 try:
1078 assert main.numSwitch
1079 except AssertionError:
1080 main.log.error( "Place the total number of switch topology in \
1081 main.numSwitch" )
1082 main.initialized = main.FALSE
1083 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001084
1085 main.case( "Point Intents Test - " + str( main.numCtrls ) +
Jeremyeb51cb12016-03-28 17:53:35 -07001086 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -07001087 main.caseExplanation = "This test case will test point to point" +\
1088 " intents using " + str( main.numCtrls ) +\
1089 " node(s) cluster;\n" +\
1090 "Different type of hosts will be tested in " +\
1091 "each step such as IPV4, Dual stack, VLAN etc" +\
1092 ";\nThe test will use OF " + main.OFProtocol +\
Jeremyeb51cb12016-03-28 17:53:35 -07001093 " OVS running in Mininet and compile intents" +\
1094 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001095
1096 # No option point intents
1097 main.step( "NOOPTION: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001098 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
1099 senders = [
1100 { "name":"h1","device":"of:0000000000000005/1" }
1101 ]
1102 recipients = [
1103 { "name":"h9","device":"of:0000000000000006/1" }
1104 ]
1105 testResult = main.FALSE
1106 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001107 main,
1108 name="NOOPTION",
Jeremy2f190ca2016-01-29 15:23:57 -08001109 senders=senders,
1110 recipients=recipients )
1111
1112 if installResult:
1113 testResult = main.intentFunction.testPointIntent(
1114 main,
1115 intentId=installResult,
1116 name="NOOPTION",
1117 senders=senders,
1118 recipients=recipients,
1119 sw1="s5",
1120 sw2="s2",
1121 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001122
1123 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001124 actual=testResult,
1125 onpass=main.assertReturnString,
1126 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001127
kelvin-onlab44147802015-07-27 17:57:31 -07001128 main.step( "IPV4: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001129 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
1130 senders = [
1131 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1132 ]
1133 recipients = [
1134 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09" }
1135 ]
1136 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001137 main,
1138 name="IPV4",
Jeremy2f190ca2016-01-29 15:23:57 -08001139 senders=senders,
1140 recipients=recipients,
1141 ethType="IPV4" )
1142
1143 if installResult:
1144 testResult = main.intentFunction.testPointIntent(
1145 main,
1146 intentId=installResult,
1147 name="IPV4",
1148 senders=senders,
1149 recipients=recipients,
1150 sw1="s5",
1151 sw2="s2",
1152 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001153
1154 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001155 actual=testResult,
1156 onpass=main.assertReturnString,
1157 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001158 main.step( "IPV4_2: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001159 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
1160 senders = [
1161 { "name":"h1","device":"of:0000000000000005/1" }
1162 ]
1163 recipients = [
1164 { "name":"h9","device":"of:0000000000000006/1" }
1165 ]
1166 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001167 main,
1168 name="IPV4_2",
Jeremy2f190ca2016-01-29 15:23:57 -08001169 senders=senders,
1170 recipients=recipients,
1171 ethType="IPV4" )
1172
1173 if installResult:
1174 testResult = main.intentFunction.testPointIntent(
1175 main,
1176 intentId=installResult,
1177 name="IPV4_2",
1178 senders=senders,
1179 recipients=recipients,
1180 sw1="s5",
1181 sw2="s2",
1182 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001183
1184 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001185 actual=testResult,
1186 onpass=main.assertReturnString,
1187 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001188
kelvin-onlab0e684682015-08-11 18:51:41 -07001189 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001190 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
1191 senders = [
1192 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01",
1193 "ip":main.h1.hostIp }
1194 ]
1195 recipients = [
1196 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09",
1197 "ip":main.h9.hostIp }
1198 ]
kelvin-onlab44147802015-07-27 17:57:31 -07001199 ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
1200 # Uneccessary, not including this in the selectors
Jeremy2f190ca2016-01-29 15:23:57 -08001201 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
1202 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
kelvin-onlab44147802015-07-27 17:57:31 -07001203
Jeremy2f190ca2016-01-29 15:23:57 -08001204 installResult = main.intentFunction.installPointIntent(
1205 main,
1206 name="SDNIP-ICMP",
1207 senders=senders,
1208 recipients=recipients,
1209 ethType="IPV4",
1210 ipProto=ipProto,
1211 tcpSrc=tcpSrc,
1212 tcpDst=tcpDst )
1213
1214 if installResult:
1215 testResult = main.intentFunction.testPointIntent(
1216 main,
1217 intentId=installResult,
1218 name="SDNIP_ICMP",
1219 senders=senders,
1220 recipients=recipients,
1221 sw1="s5",
1222 sw2="s2",
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001223 expectedLink=18,
1224 useTCP=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001225
1226 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001227 actual=testResult,
1228 onpass=main.assertReturnString,
1229 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001230
kelvin-onlab0e684682015-08-11 18:51:41 -07001231 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001232 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
kelvin-onlab44147802015-07-27 17:57:31 -07001233 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
1234 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab0e684682015-08-11 18:51:41 -07001235 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
1236 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlab44147802015-07-27 17:57:31 -07001237 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
1238 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
1239 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
1240
kelvin-onlab0e684682015-08-11 18:51:41 -07001241 stepResult = main.intentFunction.pointIntentTcp(
kelvin-onlab44147802015-07-27 17:57:31 -07001242 main,
kelvin-onlab0e684682015-08-11 18:51:41 -07001243 name="SDNIP-TCP",
kelvin-onlab44147802015-07-27 17:57:31 -07001244 host1="h1",
1245 host2="h9",
1246 deviceId1="of:0000000000000005/1",
1247 deviceId2="of:0000000000000006/1",
1248 mac1=mac1,
1249 mac2=mac2,
1250 ethType="IPV4",
kelvin-onlab0e684682015-08-11 18:51:41 -07001251 ipProto=ipProto,
1252 ip1=ip1,
1253 ip2=ip2,
1254 tcp1=tcp1,
1255 tcp2=tcp2 )
kelvin-onlab44147802015-07-27 17:57:31 -07001256
1257 utilities.assert_equals( expect=main.TRUE,
1258 actual=stepResult,
Jeremy2f190ca2016-01-29 15:23:57 -08001259 onpass=main.assertReturnString,
1260 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001261
Jeremy2f190ca2016-01-29 15:23:57 -08001262 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
1263 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
1264 senders = [
1265 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1266 ]
1267 recipients = [
1268 { "name":"h11","device":"of:0000000000000006/3","mac":"00:00:00:00:00:0B" }
1269 ]
1270 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001271 main,
1272 name="DUALSTACK1",
Jeremy2f190ca2016-01-29 15:23:57 -08001273 senders=senders,
1274 recipients=recipients,
1275 ethType="IPV4" )
1276
1277 if installResult:
1278 testResult = main.intentFunction.testPointIntent(
1279 main,
1280 intentId=installResult,
1281 name="DUALSTACK1",
1282 senders=senders,
1283 recipients=recipients,
1284 sw1="s5",
1285 sw2="s2",
1286 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001287
1288 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001289 actual=testResult,
1290 onpass=main.assertReturnString,
1291 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001292
1293 main.step( "VLAN: Add point intents between h5 and h21" )
Jeremy2f190ca2016-01-29 15:23:57 -08001294 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
1295 senders = [
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001296 { "name":"h5","device":"of:0000000000000005/5","mac":"00:00:00:00:00:05", "vlanId":"200" }
Jeremy2f190ca2016-01-29 15:23:57 -08001297 ]
1298 recipients = [
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001299 { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15", "vlanId":"200" }
Jeremy2f190ca2016-01-29 15:23:57 -08001300 ]
1301 installResult = main.intentFunction.installPointIntent(
kelvin-onlab44147802015-07-27 17:57:31 -07001302 main,
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001303 name="VLAN",
Jeremy2f190ca2016-01-29 15:23:57 -08001304 senders=senders,
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001305 recipients=recipients )
Jeremy2f190ca2016-01-29 15:23:57 -08001306
1307 if installResult:
1308 testResult = main.intentFunction.testPointIntent(
1309 main,
1310 intentId=installResult,
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001311 name="VLAN",
Jeremy2f190ca2016-01-29 15:23:57 -08001312 senders=senders,
1313 recipients=recipients,
1314 sw1="s5",
1315 sw2="s2",
1316 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001317
1318 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001319 actual=testResult,
1320 onpass=main.assertReturnString,
1321 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001322
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001323 # TODO: implement VLAN selector REST API intent test once supported
1324
kelvin-onlab44147802015-07-27 17:57:31 -07001325 main.step( "1HOP: Add point intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -08001326 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
1327 senders = [
1328 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1329 ]
1330 recipients = [
1331 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1332 ]
1333 installResult = main.intentFunction.installPointIntent(
1334 main,
1335 name="1HOP IPV4",
1336 senders=senders,
1337 recipients=recipients,
1338 ethType="IPV4" )
1339
1340 if installResult:
1341 testResult = main.intentFunction.testPointIntent(
1342 main,
1343 intentId=installResult,
1344 name="1HOP IPV4",
1345 senders=senders,
1346 recipients=recipients,
1347 sw1="s5",
1348 sw2="s2",
1349 expectedLink=18)
kelvin-onlab44147802015-07-27 17:57:31 -07001350
1351 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001352 actual=testResult,
1353 onpass=main.assertReturnString,
1354 onfail=main.assertReturnString )
1355
1356 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001357
1358 def CASE3000( self, main ):
1359 """
1360 Add single point to multi point intents
1361 - Get device ids
1362 - Add single point to multi point intents
1363 - Check intents
1364 - Verify flows
1365 - Ping hosts
1366 - Reroute
1367 - Link down
1368 - Verify flows
1369 - Check topology
1370 - Ping hosts
1371 - Link up
1372 - Verify flows
1373 - Check topology
1374 - Ping hosts
1375 - Remove intents
1376 """
1377 assert main, "There is no main"
1378 assert main.CLIs, "There is no main.CLIs"
1379 assert main.Mininet1, "Mininet handle should be named Mininet1"
1380 assert main.numSwitch, "Placed the total number of switch topology in \
1381 main.numSwitch"
1382
1383 main.case( "Single To Multi Point Intents Test - " +
Jeremyeb51cb12016-03-28 17:53:35 -07001384 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -07001385 main.caseExplanation = "This test case will test single point to" +\
1386 " multi point intents using " +\
1387 str( main.numCtrls ) + " node(s) cluster;\n" +\
1388 "Different type of hosts will be tested in " +\
1389 "each step such as IPV4, Dual stack, VLAN etc" +\
1390 ";\nThe test will use OF " + main.OFProtocol +\
Jeremyeb51cb12016-03-28 17:53:35 -07001391 " OVS running in Mininet and compile intents" +\
1392 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001393
1394 main.step( "NOOPTION: Add single point to multi point intents" )
1395 stepResult = main.TRUE
1396 hostNames = [ 'h8', 'h16', 'h24' ]
1397 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
1398 'of:0000000000000007/8' ]
1399 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
1400 stepResult = main.intentFunction.singleToMultiIntent(
1401 main,
1402 name="NOOPTION",
1403 hostNames=hostNames,
1404 devices=devices,
1405 sw1="s5",
1406 sw2="s2",
1407 expectedLink=18 )
1408
1409 utilities.assert_equals( expect=main.TRUE,
1410 actual=stepResult,
1411 onpass="NOOPTION: Successfully added single "
1412 + " point to multi point intents" +
1413 " with no match action",
1414 onfail="NOOPTION: Failed to add single point"
1415 + " point to multi point intents" +
1416 " with no match action" )
1417
1418 main.step( "IPV4: Add single point to multi point intents" )
1419 stepResult = main.TRUE
1420 stepResult = main.intentFunction.singleToMultiIntent(
1421 main,
1422 name="IPV4",
1423 hostNames=hostNames,
1424 devices=devices,
1425 ports=None,
1426 ethType="IPV4",
1427 macs=macs,
1428 bandwidth="",
1429 lambdaAlloc=False,
1430 ipProto="",
1431 ipAddresses="",
1432 tcp="",
1433 sw1="s5",
1434 sw2="s2",
1435 expectedLink=18 )
1436
1437 utilities.assert_equals( expect=main.TRUE,
1438 actual=stepResult,
1439 onpass="IPV4: Successfully added single "
1440 + " point to multi point intents" +
1441 " with IPV4 type and MAC addresses",
1442 onfail="IPV4: Failed to add single point"
1443 + " point to multi point intents" +
1444 " with IPV4 type and MAC addresses" )
1445
1446 main.step( "IPV4_2: Add single point to multi point intents" )
1447 stepResult = main.TRUE
1448 hostNames = [ 'h8', 'h16', 'h24' ]
1449 stepResult = main.intentFunction.singleToMultiIntent(
1450 main,
1451 name="IPV4",
1452 hostNames=hostNames,
1453 ethType="IPV4",
1454 lambdaAlloc=False )
1455
1456 utilities.assert_equals( expect=main.TRUE,
1457 actual=stepResult,
1458 onpass="IPV4_2: Successfully added single "
1459 + " point to multi point intents" +
1460 " with IPV4 type and no MAC addresses",
1461 onfail="IPV4_2: Failed to add single point"
1462 + " point to multi point intents" +
1463 " with IPV4 type and no MAC addresses" )
1464
1465 main.step( "VLAN: Add single point to multi point intents" )
1466 stepResult = main.TRUE
1467 hostNames = [ 'h4', 'h12', 'h20' ]
1468 devices = [ 'of:0000000000000005/4', 'of:0000000000000006/4', \
1469 'of:0000000000000007/4' ]
1470 macs = [ '00:00:00:00:00:04', '00:00:00:00:00:0C', '00:00:00:00:00:14' ]
1471 stepResult = main.intentFunction.singleToMultiIntent(
1472 main,
1473 name="VLAN",
1474 hostNames=hostNames,
1475 devices=devices,
1476 ports=None,
1477 ethType="IPV4",
1478 macs=macs,
1479 bandwidth="",
1480 lambdaAlloc=False,
1481 ipProto="",
1482 ipAddresses="",
1483 tcp="",
1484 sw1="s5",
1485 sw2="s2",
1486 expectedLink=18 )
1487
1488 utilities.assert_equals( expect=main.TRUE,
1489 actual=stepResult,
1490 onpass="VLAN: Successfully added single "
1491 + " point to multi point intents" +
1492 " with IPV4 type and MAC addresses" +
1493 " in the same VLAN",
1494 onfail="VLAN: Failed to add single point"
1495 + " point to multi point intents" +
1496 " with IPV4 type and MAC addresses" +
1497 " in the same VLAN")
1498
1499 def CASE4000( self, main ):
1500 """
1501 Add multi point to single point intents
1502 - Get device ids
1503 - Add multi point to single point intents
1504 - Check intents
1505 - Verify flows
1506 - Ping hosts
1507 - Reroute
1508 - Link down
1509 - Verify flows
1510 - Check topology
1511 - Ping hosts
1512 - Link up
1513 - Verify flows
1514 - Check topology
1515 - Ping hosts
1516 - Remove intents
1517 """
1518 assert main, "There is no main"
1519 assert main.CLIs, "There is no main.CLIs"
1520 assert main.Mininet1, "Mininet handle should be named Mininet1"
1521 assert main.numSwitch, "Placed the total number of switch topology in \
1522 main.numSwitch"
1523
1524 main.case( "Multi To Single Point Intents Test - " +
Jeremyeb51cb12016-03-28 17:53:35 -07001525 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -07001526 main.caseExplanation = "This test case will test single point to" +\
1527 " multi point intents using " +\
1528 str( main.numCtrls ) + " node(s) cluster;\n" +\
1529 "Different type of hosts will be tested in " +\
1530 "each step such as IPV4, Dual stack, VLAN etc" +\
1531 ";\nThe test will use OF " + main.OFProtocol +\
Jeremyeb51cb12016-03-28 17:53:35 -07001532 " OVS running in Mininet and compile intents" +\
1533 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001534
1535 main.step( "NOOPTION: Add multi point to single point intents" )
1536 stepResult = main.TRUE
1537 hostNames = [ 'h8', 'h16', 'h24' ]
1538 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
1539 'of:0000000000000007/8' ]
1540 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
1541 stepResult = main.intentFunction.multiToSingleIntent(
1542 main,
1543 name="NOOPTION",
1544 hostNames=hostNames,
1545 devices=devices,
1546 sw1="s5",
1547 sw2="s2",
1548 expectedLink=18 )
1549
1550 utilities.assert_equals( expect=main.TRUE,
1551 actual=stepResult,
1552 onpass="NOOPTION: Successfully added multi "
1553 + " point to single point intents" +
1554 " with no match action",
1555 onfail="NOOPTION: Failed to add multi point" +
1556 " to single point intents" +
1557 " with no match action" )
1558
1559 main.step( "IPV4: Add multi point to single point intents" )
1560 stepResult = main.TRUE
1561 stepResult = main.intentFunction.multiToSingleIntent(
1562 main,
1563 name="IPV4",
1564 hostNames=hostNames,
1565 devices=devices,
1566 ports=None,
1567 ethType="IPV4",
1568 macs=macs,
1569 bandwidth="",
1570 lambdaAlloc=False,
1571 ipProto="",
1572 ipAddresses="",
1573 tcp="",
1574 sw1="s5",
1575 sw2="s2",
1576 expectedLink=18 )
1577
1578 utilities.assert_equals( expect=main.TRUE,
1579 actual=stepResult,
1580 onpass="IPV4: Successfully added multi point"
1581 + " to single point intents" +
1582 " with IPV4 type and MAC addresses",
1583 onfail="IPV4: Failed to add multi point" +
1584 " to single point intents" +
1585 " with IPV4 type and MAC addresses" )
1586
1587 main.step( "IPV4_2: Add multi point to single point intents" )
1588 stepResult = main.TRUE
1589 hostNames = [ 'h8', 'h16', 'h24' ]
1590 stepResult = main.intentFunction.multiToSingleIntent(
1591 main,
1592 name="IPV4",
1593 hostNames=hostNames,
1594 ethType="IPV4",
1595 lambdaAlloc=False )
1596
1597 utilities.assert_equals( expect=main.TRUE,
1598 actual=stepResult,
1599 onpass="IPV4_2: Successfully added multi point"
1600 + " to single point intents" +
1601 " with IPV4 type and no MAC addresses",
1602 onfail="IPV4_2: Failed to add multi point" +
1603 " to single point intents" +
1604 " with IPV4 type and no MAC addresses" )
1605
1606 main.step( "VLAN: Add multi point to single point intents" )
1607 stepResult = main.TRUE
1608 hostNames = [ 'h5', 'h13', 'h21' ]
1609 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \
1610 'of:0000000000000007/5' ]
1611 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
1612 stepResult = main.intentFunction.multiToSingleIntent(
1613 main,
1614 name="VLAN",
1615 hostNames=hostNames,
1616 devices=devices,
1617 ports=None,
1618 ethType="IPV4",
1619 macs=macs,
1620 bandwidth="",
1621 lambdaAlloc=False,
1622 ipProto="",
1623 ipAddresses="",
1624 tcp="",
1625 sw1="s5",
1626 sw2="s2",
1627 expectedLink=18 )
1628
1629 utilities.assert_equals( expect=main.TRUE,
1630 actual=stepResult,
1631 onpass="VLAN: Successfully added multi point"
1632 + " to single point intents" +
1633 " with IPV4 type and MAC addresses" +
1634 " in the same VLAN",
1635 onfail="VLAN: Failed to add multi point" +
1636 " to single point intents" )
1637
1638 def CASE5000( self, main ):
1639 """
Jeremy2f190ca2016-01-29 15:23:57 -08001640 Tests Host Mobility
1641 Modifies the topology location of h1
kelvin-onlab44147802015-07-27 17:57:31 -07001642 """
Jeremydd9bda62016-04-18 12:02:32 -07001643 if main.initialized == main.FALSE:
1644 main.log.error( "Test components did not start correctly, skipping further tests" )
1645 main.skipCase()
1646 # Assert variables - These variable's name|format must be followed
1647 # if you want to use the wrapper function
kelvin-onlab44147802015-07-27 17:57:31 -07001648 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -07001649 try:
1650 assert main.CLIs
1651 except AssertionError:
1652 main.log.error( "There is no main.CLIs, skipping test cases" )
1653 main.initialized = main.FALSE
1654 main.skipCase()
1655 try:
1656 assert main.Mininet1
1657 except AssertionError:
1658 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1659 main.initialized = main.FALSE
1660 main.skipCase()
1661 try:
1662 assert main.numSwitch
1663 except AssertionError:
1664 main.log.error( "Place the total number of switch topology in \
1665 main.numSwitch" )
1666 main.initialized = main.FALSE
1667 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001668 main.case( "Test host mobility with host intents " )
Jeremy2f190ca2016-01-29 15:23:57 -08001669 main.step( "Testing host mobility by moving h1 from s5 to s6" )
kelvin-onlab44147802015-07-27 17:57:31 -07001670 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1671
1672 main.log.info( "Moving h1 from s5 to s6")
kelvin-onlab44147802015-07-27 17:57:31 -07001673 main.Mininet1.moveHost( "h1","s5","s6" )
1674
Jeremy2f190ca2016-01-29 15:23:57 -08001675 # Send discovery ping from moved host
1676 # Moving the host brings down the default interfaces and creates a new one.
1677 # Scapy is restarted on this host to detect the new interface
1678 main.h1.stopScapy()
1679 main.h1.startScapy()
1680
1681 # Discover new host location in ONOS and populate host data.
1682 # Host 1 IP and MAC should be unchanged
1683 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
1684 main.intentFunction.populateHostData( main )
1685
kelvin-onlab44147802015-07-27 17:57:31 -07001686 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1687
1688 utilities.assert_equals( expect="of:0000000000000006",
1689 actual=h1PostMove,
1690 onpass="Mobility: Successfully moved h1 to s6",
Jeremy2f190ca2016-01-29 15:23:57 -08001691 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlab44147802015-07-27 17:57:31 -07001692 " to single point intents" +
1693 " with IPV4 type and MAC addresses" +
1694 " in the same VLAN" )
1695
1696 main.step( "IPV4: Add host intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001697 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
1698 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
1699 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
1700
1701 installResult = main.intentFunction.installHostIntent( main,
1702 name='IPV4 Mobility IPV4',
kelvin-onlab44147802015-07-27 17:57:31 -07001703 onosNode='0',
Jeremy2f190ca2016-01-29 15:23:57 -08001704 host1=host1,
1705 host2=host2)
1706 if installResult:
1707 testResult = main.intentFunction.testHostIntent( main,
1708 name='Host Mobility IPV4',
1709 intentId = installResult,
1710 onosNode='0',
1711 host1=host1,
1712 host2=host2,
1713 sw1="s6",
1714 sw2="s2",
1715 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001716
1717 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001718 actual=testResult,
1719 onpass=main.assertReturnString,
1720 onfail=main.assertReturnString )
1721
1722 main.intentFunction.report( main )
1723