blob: 7a9d295a3478ef282d0764e0eee97b73b424b939 [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' ] )
Jeremy Songster306ed7a2016-07-19 10:59:07 -070062 main.flowDurationSleep = int( main.params[ 'SLEEP' ][ 'flowDuration' ] )
kelvin-onlab44147802015-07-27 17:57:31 -070063 gitPull = main.params[ 'GIT' ][ 'pull' ]
64 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
65 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
66 main.cellData = {} # for creating cell file
67 main.hostsData = {}
Jeremy Songstere7f3b342016-08-17 14:56:49 -070068 main.RESTs = []
kelvin-onlab44147802015-07-27 17:57:31 -070069 main.CLIs = []
70 main.ONOSip = []
Jeremy2f190ca2016-01-29 15:23:57 -080071 main.scapyHostNames = main.params[ 'SCAPY' ][ 'HOSTNAMES' ].split( ',' )
72 main.scapyHosts = [] # List of scapy hosts for iterating
73 main.assertReturnString = '' # Assembled assert return string
Jeremy Songster17147f22016-05-31 18:30:52 -070074 main.cycle = 0 # How many times FUNCintent has run through its tests
kelvin-onlab44147802015-07-27 17:57:31 -070075
76 main.ONOSip = main.ONOSbench.getOnosIps()
Jeremy2f190ca2016-01-29 15:23:57 -080077 print main.ONOSip
kelvin-onlab44147802015-07-27 17:57:31 -070078
79 # Assigning ONOS cli handles to a list
Jon Hallf7234882015-08-28 13:16:31 -070080 try:
81 for i in range( 1, main.maxNodes + 1 ):
Jeremy Songstere7f3b342016-08-17 14:56:49 -070082 main.RESTs.append( getattr( main, 'ONOSrest' + str( i ) ) )
83 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
Jon Hallf7234882015-08-28 13:16:31 -070084 except AttributeError:
85 main.log.warn( "A " + str( main.maxNodes ) + " node cluster " +
86 "was defined in env variables, but only " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -070087 str( len( main.RESTs ) ) +
Jon Hallf7234882015-08-28 13:16:31 -070088 " nodes were defined in the .topo file. " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -070089 "Using " + str( len( main.RESTs ) ) +
Jon Hallf7234882015-08-28 13:16:31 -070090 " nodes for the test." )
kelvin-onlab44147802015-07-27 17:57:31 -070091
92 # -- INIT SECTION, ONLY RUNS ONCE -- #
93 main.startUp = imp.load_source( wrapperFile1,
94 main.dependencyPath +
95 wrapperFile1 +
96 ".py" )
97
98 main.intentFunction = imp.load_source( wrapperFile2,
99 main.dependencyPath +
100 wrapperFile2 +
101 ".py" )
102
103 main.topo = imp.load_source( wrapperFile3,
104 main.dependencyPath +
105 wrapperFile3 +
106 ".py" )
107
Jon Hallf7234882015-08-28 13:16:31 -0700108 copyResult1 = main.ONOSbench.scp( main.Mininet1,
109 main.dependencyPath +
110 main.topology,
Jeremy2f190ca2016-01-29 15:23:57 -0800111 main.Mininet1.home + "custom/",
Jon Hallf7234882015-08-28 13:16:31 -0700112 direction="to" )
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700113 if main.RESTs and main.CLIs:
kelvin-onlab44147802015-07-27 17:57:31 -0700114 stepResult = main.TRUE
115 else:
116 main.log.error( "Did not properly created list of ONOS CLI handle" )
117 stepResult = main.FALSE
118 except Exception as e:
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700119 main.log.exception( e )
kelvin-onlab44147802015-07-27 17:57:31 -0700120 main.cleanup()
121 main.exit()
122
123 utilities.assert_equals( expect=main.TRUE,
124 actual=stepResult,
125 onpass="Successfully construct " +
126 "test variables ",
127 onfail="Failed to construct test variables" )
128
129 if gitPull == 'True':
130 main.step( "Building ONOS in " + gitBranch + " branch" )
131 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
132 stepResult = onosBuildResult
133 utilities.assert_equals( expect=main.TRUE,
134 actual=stepResult,
135 onpass="Successfully compiled " +
136 "latest ONOS",
137 onfail="Failed to compile " +
138 "latest ONOS" )
139 else:
140 main.log.warn( "Did not pull new code so skipping mvn " +
141 "clean install" )
142 main.ONOSbench.getVersion( report=True )
143
144 def CASE2( self, main ):
145 """
146 - Set up cell
147 - Create cell file
148 - Set cell file
149 - Verify cell file
150 - Kill ONOS process
151 - Uninstall ONOS cluster
152 - Verify ONOS start up
153 - Install ONOS cluster
154 - Connect to cli
155 """
156
Jeremy Songster17147f22016-05-31 18:30:52 -0700157 main.cycle += 1
158
kelvin-onlab44147802015-07-27 17:57:31 -0700159 # main.scale[ 0 ] determines the current number of ONOS controller
160 main.numCtrls = int( main.scale[ 0 ] )
Jeremyeb51cb12016-03-28 17:53:35 -0700161 main.flowCompiler = "Flow Rules"
Jeremydd9bda62016-04-18 12:02:32 -0700162 main.initialized = main.TRUE
kelvin-onlab44147802015-07-27 17:57:31 -0700163
164 main.case( "Starting up " + str( main.numCtrls ) +
165 " node(s) ONOS cluster" )
166 main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
167 " node(s) ONOS cluster"
168
169
170
171 #kill off all onos processes
172 main.log.info( "Safety check, killing all ONOS processes" +
Jon Hall70b2ff42015-11-17 15:49:44 -0800173 " before initiating environment setup" )
kelvin-onlab44147802015-07-27 17:57:31 -0700174
Jeremy2f190ca2016-01-29 15:23:57 -0800175 time.sleep( main.startUpSleep )
Jeremy42df2e72016-02-23 16:37:46 -0800176
Jeremy2f190ca2016-01-29 15:23:57 -0800177 main.step( "Uninstalling ONOS package" )
178 onosUninstallResult = main.TRUE
179 for ip in main.ONOSip:
180 onosUninstallResult = onosUninstallResult and \
181 main.ONOSbench.onosUninstall( nodeIp=ip )
182 stepResult = onosUninstallResult
183 utilities.assert_equals( expect=main.TRUE,
184 actual=stepResult,
185 onpass="Successfully uninstalled ONOS package",
186 onfail="Failed to uninstall ONOS package" )
187
Jeremy42df2e72016-02-23 16:37:46 -0800188 time.sleep( main.startUpSleep )
189
kelvin-onlab44147802015-07-27 17:57:31 -0700190 for i in range( main.maxNodes ):
191 main.ONOSbench.onosDie( main.ONOSip[ i ] )
192
193 print "NODE COUNT = ", main.numCtrls
194
195 tempOnosIp = []
196 for i in range( main.numCtrls ):
197 tempOnosIp.append( main.ONOSip[i] )
198
199 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
200 "temp", main.Mininet1.ip_address,
201 main.apps, tempOnosIp )
202
203 main.step( "Apply cell to environment" )
204 cellResult = main.ONOSbench.setCell( "temp" )
205 verifyResult = main.ONOSbench.verifyCell()
206 stepResult = cellResult and verifyResult
207 utilities.assert_equals( expect=main.TRUE,
208 actual=stepResult,
209 onpass="Successfully applied cell to " + \
210 "environment",
211 onfail="Failed to apply cell to environment " )
212
213 main.step( "Creating ONOS package" )
214 packageResult = main.ONOSbench.onosPackage()
215 stepResult = packageResult
216 utilities.assert_equals( expect=main.TRUE,
217 actual=stepResult,
218 onpass="Successfully created ONOS package",
219 onfail="Failed to create ONOS package" )
220
221 time.sleep( main.startUpSleep )
kelvin-onlab44147802015-07-27 17:57:31 -0700222 main.step( "Installing ONOS package" )
223 onosInstallResult = main.TRUE
224 for i in range( main.numCtrls ):
225 onosInstallResult = onosInstallResult and \
226 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
227 stepResult = onosInstallResult
228 utilities.assert_equals( expect=main.TRUE,
229 actual=stepResult,
230 onpass="Successfully installed ONOS package",
231 onfail="Failed to install ONOS package" )
232
233 time.sleep( main.startUpSleep )
234 main.step( "Starting ONOS service" )
235 stopResult = main.TRUE
236 startResult = main.TRUE
237 onosIsUp = main.TRUE
238
239 for i in range( main.numCtrls ):
240 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
Jeremydd9bda62016-04-18 12:02:32 -0700241 if onosIsUp == main.TRUE:
242 main.log.report( "ONOS instance {0} is up and ready".format( i + 1 ) )
243 else:
244 main.log.report( "ONOS instance {0} may not be up, stop and ".format( i + 1 ) +
245 "start ONOS again " )
246 stopResult = stopResult and main.ONOSbench.onosStop( main.ONOSip[ i ] )
247 startResult = startResult and main.ONOSbench.onosStart( main.ONOSip[ i ] )
248 if not startResult or stopResult:
249 main.log.report( "ONOS instance {0} did not start correctly.".format( i + 1 ) )
kelvin-onlab44147802015-07-27 17:57:31 -0700250 stepResult = onosIsUp and stopResult and startResult
251 utilities.assert_equals( expect=main.TRUE,
252 actual=stepResult,
253 onpass="ONOS service is ready",
254 onfail="ONOS service did not start properly" )
Jeremydd9bda62016-04-18 12:02:32 -0700255 if not stepResult:
256 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700257
Jeremy2f190ca2016-01-29 15:23:57 -0800258 # Start an ONOS cli to provide functionality that is not currently
Jeremye1ea0602016-02-08 16:35:05 -0800259 # supported by the Rest API remove this when Leader Checking is supported
260 # by the REST API
Jeremy2f190ca2016-01-29 15:23:57 -0800261
Jeremye1ea0602016-02-08 16:35:05 -0800262 main.step( "Start ONOS cli" )
263 cliResult = main.TRUE
264 for i in range( main.numCtrls ):
265 cliResult = cliResult and \
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700266 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
Jeremye1ea0602016-02-08 16:35:05 -0800267 stepResult = cliResult
268 utilities.assert_equals( expect=main.TRUE,
269 actual=stepResult,
270 onpass="Successfully start ONOS cli",
271 onfail="Failed to start ONOS cli" )
Jeremydd9bda62016-04-18 12:02:32 -0700272 if not stepResult:
273 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800274
kelvin-onlab44147802015-07-27 17:57:31 -0700275 # Remove the first element in main.scale list
276 main.scale.remove( main.scale[ 0 ] )
277
Jeremy2f190ca2016-01-29 15:23:57 -0800278 main.intentFunction.report( main )
279
kelvin-onlab44147802015-07-27 17:57:31 -0700280 def CASE8( self, main ):
Jeremy2f190ca2016-01-29 15:23:57 -0800281 # OLD FUNCintentRest CASE 8
282 # This remains here for archiving and reference purposes and will be
283 # removed when the new FUNCintentRest is verified to work.
284 # """
285 # Compare Topo
286 # """
287 # import json
288
289 # main.case( "Compare ONOS Topology view to Mininet topology" )
290 # main.caseExplanation = "Compare topology elements between Mininet" +\
291 # " and ONOS"
292
293 # main.step( "Gathering topology information" )
294 # # TODO: add a paramaterized sleep here
295 # devicesResults = main.TRUE # Overall Boolean for device correctness
296 # linksResults = main.TRUE # Overall Boolean for link correctness
297 # hostsResults = main.TRUE # Overall Boolean for host correctness
298 # devices = main.topo.getAllDevices( main )
299 # hosts = main.topo.getAllHosts( main )
300 # ports = main.topo.getAllPorts( main )
301 # links = main.topo.getAllLinks( main )
302 # clusters = main.topo.getAllClusters( main )
303
304 # mnSwitches = main.Mininet1.getSwitches()
305 # mnLinks = main.Mininet1.getLinks()
306 # mnHosts = main.Mininet1.getHosts()
307
308 # main.step( "Comparing MN topology to ONOS topology" )
309 # for controller in range( main.numCtrls ):
310 # controllerStr = str( controller + 1 )
311 # if devices[ controller ] and ports[ controller ] and\
312 # "Error" not in devices[ controller ] and\
313 # "Error" not in ports[ controller ]:
314
315 # currentDevicesResult = main.Mininet1.compareSwitches(
316 # mnSwitches,
317 # json.loads( devices[ controller ] ),
318 # json.loads( ports[ controller ] ) )
319 # else:
320 # currentDevicesResult = main.FALSE
321 # utilities.assert_equals( expect=main.TRUE,
322 # actual=currentDevicesResult,
323 # onpass="ONOS" + controllerStr +
324 # " Switches view is correct",
325 # onfail="ONOS" + controllerStr +
326 # " Switches view is incorrect" )
327
328 # if links[ controller ] and "Error" not in links[ controller ]:
329 # currentLinksResult = main.Mininet1.compareLinks(
330 # mnSwitches, mnLinks,
331 # json.loads( links[ controller ] ) )
332 # else:
333 # currentLinksResult = main.FALSE
334 # utilities.assert_equals( expect=main.TRUE,
335 # actual=currentLinksResult,
336 # onpass="ONOS" + controllerStr +
337 # " links view is correct",
338 # onfail="ONOS" + controllerStr +
339 # " links view is incorrect" )
340
341 # if hosts[ controller ] or "Error" not in hosts[ controller ]:
342 # currentHostsResult = main.Mininet1.compareHosts(
343 # mnHosts,
344 # json.loads( hosts[ controller ] ) )
345 # else:
346 # currentHostsResult = main.FALSE
347 # utilities.assert_equals( expect=main.TRUE,
348 # actual=currentHostsResult,
349 # onpass="ONOS" + controllerStr +
350 # " hosts exist in Mininet",
351 # onfail="ONOS" + controllerStr +
352 # " hosts don't match Mininet" )
353
354 # NEW FUNCintentRest Case 8 as based off of the CASE 8 from FUNCintent
kelvin-onlab44147802015-07-27 17:57:31 -0700355 """
Jeremy2f190ca2016-01-29 15:23:57 -0800356 Compare ONOS Topology to Mininet Topology
kelvin-onlab44147802015-07-27 17:57:31 -0700357 """
358 import json
359
360 main.case( "Compare ONOS Topology view to Mininet topology" )
361 main.caseExplanation = "Compare topology elements between Mininet" +\
362 " and ONOS"
363
Jeremy2f190ca2016-01-29 15:23:57 -0800364 main.log.info( "Gathering topology information from Mininet" )
365 devicesResults = main.FALSE # Overall Boolean for device correctness
366 linksResults = main.FALSE # Overall Boolean for link correctness
367 hostsResults = main.FALSE # Overall Boolean for host correctness
368 deviceFails = [] # Nodes where devices are incorrect
369 linkFails = [] # Nodes where links are incorrect
370 hostFails = [] # Nodes where hosts are incorrect
371 attempts = main.checkTopoAttempts # Remaining Attempts
kelvin-onlab44147802015-07-27 17:57:31 -0700372
373 mnSwitches = main.Mininet1.getSwitches()
374 mnLinks = main.Mininet1.getLinks()
375 mnHosts = main.Mininet1.getHosts()
376
Jeremy2f190ca2016-01-29 15:23:57 -0800377 main.step( "Comparing Mininet topology to ONOS topology" )
kelvin-onlab44147802015-07-27 17:57:31 -0700378
Jeremy2f190ca2016-01-29 15:23:57 -0800379 while ( attempts >= 0 ) and\
380 ( not devicesResults or not linksResults or not hostsResults ):
381 time.sleep( 2 )
382 if not devicesResults:
383 devices = main.topo.getAllDevices( main )
384 ports = main.topo.getAllPorts( main )
385 devicesResults = main.TRUE
386 deviceFails = [] # Reset for each failed attempt
387 if not linksResults:
388 links = main.topo.getAllLinks( main )
389 linksResults = main.TRUE
390 linkFails = [] # Reset for each failed attempt
391 if not hostsResults:
392 hosts = main.topo.getAllHosts( main )
393 hostsResults = main.TRUE
394 hostFails = [] # Reset for each failed attempt
kelvin-onlab44147802015-07-27 17:57:31 -0700395
Jeremy2f190ca2016-01-29 15:23:57 -0800396 # Check for matching topology on each node
397 for controller in range( main.numCtrls ):
398 controllerStr = str( controller + 1 ) # ONOS node number
399 # Compare Devices
400 if devices[ controller ] and ports[ controller ] and\
401 "Error" not in devices[ controller ] and\
402 "Error" not in ports[ controller ]:
kelvin-onlab44147802015-07-27 17:57:31 -0700403
Jeremy2f190ca2016-01-29 15:23:57 -0800404 try:
405 deviceData = json.loads( devices[ controller ] )
406 portData = json.loads( ports[ controller ] )
407 except (TypeError,ValueError):
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700408 main.log.error( "Could not load json: {0} or {1}".format( str( devices[ controller ] ),
409 str( ports[ controller ] ) ) )
Jeremy2f190ca2016-01-29 15:23:57 -0800410 currentDevicesResult = main.FALSE
411 else:
412 currentDevicesResult = main.Mininet1.compareSwitches(
413 mnSwitches,deviceData,portData )
414 else:
415 currentDevicesResult = main.FALSE
416 if not currentDevicesResult:
417 deviceFails.append( controllerStr )
418 devicesResults = devicesResults and currentDevicesResult
419 # Compare Links
420 if links[ controller ] and "Error" not in links[ controller ]:
421 try:
422 linkData = json.loads( links[ controller ] )
423 except (TypeError,ValueError):
424 main.log.error("Could not load json:" + str( links[ controller ] ) )
425 currentLinksResult = main.FALSE
426 else:
427 currentLinksResult = main.Mininet1.compareLinks(
428 mnSwitches, mnLinks,linkData )
429 else:
430 currentLinksResult = main.FALSE
431 if not currentLinksResult:
432 linkFails.append( controllerStr )
433 linksResults = linksResults and currentLinksResult
434 # Compare Hosts
435 if hosts[ controller ] and "Error" not in hosts[ controller ]:
436 try:
437 hostData = json.loads( hosts[ controller ] )
438 except (TypeError,ValueError):
439 main.log.error("Could not load json:" + str( hosts[ controller ] ) )
440 currentHostsResult = main.FALSE
441 else:
442 currentHostsResult = main.Mininet1.compareHosts(
443 mnHosts,hostData )
444 else:
445 currentHostsResult = main.FALSE
446 if not currentHostsResult:
447 hostFails.append( controllerStr )
448 hostsResults = hostsResults and currentHostsResult
449 # Decrement Attempts Remaining
450 attempts -= 1
451
452
453 utilities.assert_equals( expect=[],
454 actual=deviceFails,
455 onpass="ONOS correctly discovered all devices",
456 onfail="ONOS incorrectly discovered devices on nodes: " +
457 str( deviceFails ) )
458 utilities.assert_equals( expect=[],
459 actual=linkFails,
460 onpass="ONOS correctly discovered all links",
461 onfail="ONOS incorrectly discovered links on nodes: " +
462 str( linkFails ) )
463 utilities.assert_equals( expect=[],
464 actual=hostFails,
465 onpass="ONOS correctly discovered all hosts",
466 onfail="ONOS incorrectly discovered hosts on nodes: " +
467 str( hostFails ) )
468 topoResults = hostsResults and linksResults and devicesResults
469 utilities.assert_equals( expect=main.TRUE,
470 actual=topoResults,
471 onpass="ONOS correctly discovered the topology",
472 onfail="ONOS incorrectly discovered the topology" )
kelvin-onlab44147802015-07-27 17:57:31 -0700473
474 def CASE9( self, main ):
475 '''
476 Report errors/warnings/exceptions
477 '''
478 main.log.info( "Error report: \n" )
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700479 main.ONOSbench.logReport( globalONOSip[ 0 ],
kelvin-onlab44147802015-07-27 17:57:31 -0700480 [ "INFO", "FOLLOWER", "WARN", "flow", "ERROR" , "Except" ],
481 "s" )
482 #main.ONOSbench.logReport( globalONOSip[1], [ "INFO" ], "d" )
483
484 def CASE10( self, main ):
485 """
486 Start Mininet topology with OF 1.0 switches
487 """
Jeremydd9bda62016-04-18 12:02:32 -0700488 if main.initialized == main.FALSE:
489 main.log.error( "Test components did not start correctly, skipping further tests" )
490 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700491 main.OFProtocol = "1.0"
492 main.log.report( "Start Mininet topology with OF 1.0 switches" )
493 main.case( "Start Mininet topology with OF 1.0 switches" )
494 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
495 "switches to test intents, exits out if " +\
496 "topology did not start correctly"
497
498 main.step( "Starting Mininet topology with OF 1.0 switches" )
499 args = "--switch ovs,protocols=OpenFlow10"
500 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
501 main.topology,
502 args=args )
503 stepResult = topoResult
504 utilities.assert_equals( expect=main.TRUE,
505 actual=stepResult,
506 onpass="Successfully loaded topology",
507 onfail="Failed to load topology" )
508 # Exit if topology did not load properly
509 if not topoResult:
Jeremydd9bda62016-04-18 12:02:32 -0700510 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700511
512 def CASE11( self, main ):
513 """
514 Start Mininet topology with OF 1.3 switches
515 """
Jeremydd9bda62016-04-18 12:02:32 -0700516 if main.initialized == main.FALSE:
517 main.log.error( "Test components did not start correctly, skipping further tests" )
518 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700519 main.OFProtocol = "1.3"
520 main.log.report( "Start Mininet topology with OF 1.3 switches" )
521 main.case( "Start Mininet topology with OF 1.3 switches" )
522 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
523 "switches to test intents, exits out if " +\
524 "topology did not start correctly"
525
526 main.step( "Starting Mininet topology with OF 1.3 switches" )
527 args = "--switch ovs,protocols=OpenFlow13"
528 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
529 main.topology,
530 args=args )
531 stepResult = topoResult
532 utilities.assert_equals( expect=main.TRUE,
533 actual=stepResult,
534 onpass="Successfully loaded topology",
535 onfail="Failed to load topology" )
536 # Exit if topology did not load properly
537 if not topoResult:
Jeremydd9bda62016-04-18 12:02:32 -0700538 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700539
540 def CASE12( self, main ):
541 """
542 Assign mastership to controllers
543 """
544 import re
545
Jeremydd9bda62016-04-18 12:02:32 -0700546 if main.initialized == main.FALSE:
547 main.log.error( "Test components did not start correctly, skipping further tests" )
548 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700549 main.case( "Assign switches to controllers" )
550 main.step( "Assigning switches to controllers" )
551 main.caseExplanation = "Assign OF " + main.OFProtocol +\
552 " switches to ONOS nodes"
553
554 assignResult = main.TRUE
555 switchList = []
556
557 # Creates a list switch name, use getSwitch() function later...
558 for i in range( 1, ( main.numSwitch + 1 ) ):
559 switchList.append( 's' + str( i ) )
560
561 tempONOSip = []
562 for i in range( main.numCtrls ):
563 tempONOSip.append( main.ONOSip[ i ] )
564
565 assignResult = main.Mininet1.assignSwController( sw=switchList,
566 ip=tempONOSip,
Charles Chan029be652015-08-24 01:46:10 +0800567 port='6653' )
kelvin-onlab44147802015-07-27 17:57:31 -0700568 if not assignResult:
Jeremydd9bda62016-04-18 12:02:32 -0700569 main.log.error( "Problem assigning mastership of switches, skipping further test cases" )
570 main.initialized = main.FALSE
571 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700572
573 for i in range( 1, ( main.numSwitch + 1 ) ):
574 response = main.Mininet1.getSwController( "s" + str( i ) )
575 print( "Response is " + str( response ) )
576 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
577 assignResult = assignResult and main.TRUE
578 else:
579 assignResult = main.FALSE
580 stepResult = assignResult
581 utilities.assert_equals( expect=main.TRUE,
582 actual=stepResult,
583 onpass="Successfully assigned switches" +
584 "to controller",
585 onfail="Failed to assign switches to " +
586 "controller" )
Jeremydd9bda62016-04-18 12:02:32 -0700587 if not stepResult:
588 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800589
590 def CASE13( self,main ):
591 """
592 Create Scapy components
593 """
Jeremydd9bda62016-04-18 12:02:32 -0700594 if main.initialized == main.FALSE:
595 main.log.error( "Test components did not start correctly, skipping further tests" )
596 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800597 main.case( "Create scapy components" )
598 main.step( "Create scapy components" )
599 import json
600 scapyResult = main.TRUE
601 for hostName in main.scapyHostNames:
602 main.Scapy1.createHostComponent( hostName )
603 main.scapyHosts.append( getattr( main, hostName ) )
604
605 main.step( "Start scapy components" )
606 for host in main.scapyHosts:
607 host.startHostCli()
608 host.startScapy()
609 host.updateSelf()
610 main.log.debug( host.name )
611 main.log.debug( host.hostIp )
612 main.log.debug( host.hostMac )
613
614
615 utilities.assert_equals( expect=main.TRUE,
616 actual=scapyResult,
617 onpass="Successfully created Scapy Components",
618 onfail="Failed to discover Scapy Components" )
Jeremydd9bda62016-04-18 12:02:32 -0700619 if not scapyResult:
620 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800621
622 def CASE14( self, main ):
kelvin-onlab44147802015-07-27 17:57:31 -0700623 """
624 Discover all hosts and store its data to a dictionary
625 """
Jeremydd9bda62016-04-18 12:02:32 -0700626 if main.initialized == main.FALSE:
627 main.log.error( "Test components did not start correctly, skipping further tests" )
628 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700629 main.case( "Discover all hosts" )
630
631 stepResult = main.TRUE
kelvin-onlab0e684682015-08-11 18:51:41 -0700632 main.step( "Discover all ipv4 host hosts " )
633 hostList = []
634 # List of host with default vlan
635 defaultHosts = [ "h1", "h3", "h8", "h9", "h11", "h16", "h17", "h19", "h24" ]
636 # Lists of host with unique vlan
637 vlanHosts1 = [ "h4", "h12", "h20" ]
638 vlanHosts2 = [ "h5", "h13", "h21" ]
639 vlanHosts3 = [ "h6", "h14", "h22" ]
640 vlanHosts4 = [ "h7", "h15", "h23" ]
641 hostList.append( defaultHosts )
642 hostList.append( vlanHosts1 )
643 hostList.append( vlanHosts2 )
644 hostList.append( vlanHosts3 )
645 hostList.append( vlanHosts4 )
646
647 stepResult = main.intentFunction.getHostsData( main, hostList )
kelvin-onlab44147802015-07-27 17:57:31 -0700648 utilities.assert_equals( expect=main.TRUE,
649 actual=stepResult,
650 onpass="Successfully discovered hosts",
651 onfail="Failed to discover hosts" )
Jeremydd9bda62016-04-18 12:02:32 -0700652 if not stepResult:
653 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700654
Jeremy2f190ca2016-01-29 15:23:57 -0800655 def CASE15( self, main ):
kelvin-onlab44147802015-07-27 17:57:31 -0700656 """
Jeremy2f190ca2016-01-29 15:23:57 -0800657 Discover all hosts with scapy arp packets and store its data to a dictionary
kelvin-onlab44147802015-07-27 17:57:31 -0700658 """
Jeremydd9bda62016-04-18 12:02:32 -0700659 if main.initialized == main.FALSE:
660 main.log.error( "Test components did not start correctly, skipping further tests" )
661 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800662 main.case( "Discover all hosts using scapy" )
663 main.step( "Send packets from each host to the first host and confirm onos discovery" )
664
665 import collections
666 if len( main.scapyHosts ) < 1:
667 main.log.error( "No scapy hosts have been created" )
Jeremydd9bda62016-04-18 12:02:32 -0700668 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800669 main.skipCase()
670
671 # Send ARP packets from each scapy host component
672 main.intentFunction.sendDiscoveryArp( main, main.scapyHosts )
673
674 stepResult = utilities.retry( f=main.intentFunction.confirmHostDiscovery,
675 retValue=main.FALSE, args=[ main ],
676 attempts=main.checkTopoAttempts, sleep=2 )
677
678 utilities.assert_equals( expect=main.TRUE,
679 actual=stepResult,
680 onpass="ONOS correctly discovered all hosts",
681 onfail="ONOS incorrectly discovered hosts" )
Jeremydd9bda62016-04-18 12:02:32 -0700682 if not stepResult:
683 main.initialized = main.FALSE
684 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800685
686 main.step( "Populate hostsData" )
687 stepResult = main.intentFunction.populateHostData( main )
688 utilities.assert_equals( expect=main.TRUE,
689 actual=stepResult,
690 onpass="Successfully populated hostsData",
691 onfail="Failed to populate hostsData" )
Jeremydd9bda62016-04-18 12:02:32 -0700692 if not stepResult:
693 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800694
695 def CASE16( self, main ):
696 """
Jeremy42df2e72016-02-23 16:37:46 -0800697 Balance Masters
698 """
Jeremydd9bda62016-04-18 12:02:32 -0700699 if main.initialized == main.FALSE:
700 main.log.error( "Test components did not start correctly, skipping further tests" )
701 main.skipCase()
Jeremy42df2e72016-02-23 16:37:46 -0800702 main.case( "Balance mastership of switches" )
703 main.step( "Balancing mastership of switches" )
704
705 balanceResult = main.FALSE
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700706 balanceResult = utilities.retry( f=main.CLIs[ 0 ].balanceMasters, retValue=main.FALSE, args=[] )
Jeremy42df2e72016-02-23 16:37:46 -0800707
708 utilities.assert_equals( expect=main.TRUE,
709 actual=stepResult,
710 onpass="Successfully balanced mastership of switches",
711 onfail="Failed to balance mastership of switches" )
Jeremydd9bda62016-04-18 12:02:32 -0700712 if not stepResult:
713 main.initialized = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800714
715 def CASE17( self, main ):
716 """
Jeremyeb51cb12016-03-28 17:53:35 -0700717 Use Flow Objectives
718 """
Jeremydd9bda62016-04-18 12:02:32 -0700719 if main.initialized == main.FALSE:
720 main.log.error( "Test components did not start correctly, skipping further tests" )
721 main.skipCase()
Jeremyeb51cb12016-03-28 17:53:35 -0700722 main.case( "Enable intent compilation using Flow Objectives" )
723 main.step( "Enabling Flow Objectives" )
724
725 main.flowCompiler = "Flow Objectives"
726
727 cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator"
728
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700729 stepResult = main.CLIs[ 0 ].setCfg( component=cmd,
Jeremyeb51cb12016-03-28 17:53:35 -0700730 propName="useFlowObjectives", value="true" )
731
732 utilities.assert_equals( expect=main.TRUE,
733 actual=stepResult,
734 onpass="Successfully activated Flow Objectives",
735 onfail="Failed to activate Flow Objectives" )
Jeremydd9bda62016-04-18 12:02:32 -0700736 if not stepResult:
737 main.initialized = main.FALSE
Jeremyeb51cb12016-03-28 17:53:35 -0700738
739 def CASE18( self, main ):
740 """
Jeremy2f190ca2016-01-29 15:23:57 -0800741 Stop mininet and remove scapy hosts
742 """
743 main.log.report( "Stop Mininet and Scapy" )
744 main.case( "Stop Mininet and Scapy" )
kelvin-onlab44147802015-07-27 17:57:31 -0700745 main.caseExplanation = "Stopping the current mininet topology " +\
746 "to start up fresh"
747
Jeremy2f190ca2016-01-29 15:23:57 -0800748 main.step( "Stopping and Removing Scapy Host Components" )
749 scapyResult = main.TRUE
750 for host in main.scapyHosts:
751 scapyResult = scapyResult and host.stopScapy()
752 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
753
754 for host in main.scapyHosts:
755 scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
756 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
757
758 main.scapyHosts = []
759 main.scapyHostIPs = []
760
761 utilities.assert_equals( expect=main.TRUE,
762 actual=scapyResult,
763 onpass="Successfully stopped scapy and removed host components",
764 onfail="Failed to stop mininet and scapy" )
765
kelvin-onlab44147802015-07-27 17:57:31 -0700766 main.step( "Stopping Mininet Topology" )
Jeremy2f190ca2016-01-29 15:23:57 -0800767 mininetResult = main.Mininet1.stopNet( )
768
kelvin-onlab44147802015-07-27 17:57:31 -0700769 utilities.assert_equals( expect=main.TRUE,
770 actual=stepResult,
771 onpass="Successfully stop mininet",
772 onfail="Failed to stop mininet" )
773 # Exit if topology did not load properly
Jeremy2f190ca2016-01-29 15:23:57 -0800774 if not (mininetResult and scapyResult ):
kelvin-onlab44147802015-07-27 17:57:31 -0700775 main.cleanup()
776 main.exit()
777
Jeremy Songster17147f22016-05-31 18:30:52 -0700778 def CASE19( self, main ):
779 """
780 Copy the karaf.log files after each testcase cycle
781 """
782 main.log.report( "Copy karaf logs" )
783 main.case( "Copy karaf logs" )
784 main.caseExplanation = "Copying the karaf logs to preserve them through" +\
785 "reinstalling ONOS"
786 main.step( "Copying karaf logs" )
Jeremy Songster31aad312016-06-13 16:32:11 -0700787 stepResult = main.TRUE
788 scpResult = main.TRUE
789 copyResult = main.TRUE
Jeremy Songstercc5414b2016-07-11 10:59:53 -0700790 for i in range( main.numCtrls ):
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700791 main.node = main.CLIs[ i ]
Jeremy Songster17147f22016-05-31 18:30:52 -0700792 ip = main.ONOSip[ i ]
793 main.node.ip_address = ip
Jeremy Songster31aad312016-06-13 16:32:11 -0700794 scpResult = scpResult and main.ONOSbench.scp( main.node ,
795 "/opt/onos/log/karaf.log",
796 "/tmp/karaf.log",
797 direction="from" )
798 copyResult = copyResult and main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700799 copyFileName=( "karaf.log.node{0}.cycle{1}".format(
800 str( i + 1 ), str( main.cycle ) ) ) )
Jeremy Songster31aad312016-06-13 16:32:11 -0700801 if scpResult and copyResult:
802 stepResult = main.TRUE and stepResult
803 else:
804 stepResult = main.FALSE and stepResult
Jeremy Songster31aad312016-06-13 16:32:11 -0700805 utilities.assert_equals( expect=main.TRUE,
806 actual=stepResult,
807 onpass="Successfully copied remote ONOS logs",
808 onfail="Failed to copy remote ONOS logs" )
Jeremy Songster17147f22016-05-31 18:30:52 -0700809
kelvin-onlab44147802015-07-27 17:57:31 -0700810 def CASE1000( self, main ):
811 """
812 Add host intents between 2 host:
813 - Discover hosts
814 - Add host intents
815 - Check intents
816 - Verify flows
817 - Ping hosts
818 - Reroute
819 - Link down
820 - Verify flows
821 - Check topology
822 - Ping hosts
823 - Link up
824 - Verify flows
825 - Check topology
826 - Ping hosts
827 - Remove intents
828 """
829 import time
830 import json
831 import re
Jeremydd9bda62016-04-18 12:02:32 -0700832 if main.initialized == main.FALSE:
833 main.log.error( "Test components did not start correctly, skipping further tests" )
834 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700835 # Assert variables - These variable's name|format must be followed
836 # if you want to use the wrapper function
837 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -0700838 try:
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700839 assert main.RESTs
Jeremydd9bda62016-04-18 12:02:32 -0700840 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700841 main.log.error( "There is no main.RESTs, skipping test cases" )
Jeremydd9bda62016-04-18 12:02:32 -0700842 main.initialized = main.FALSE
843 main.skipCase()
844 try:
845 assert main.Mininet1
846 except AssertionError:
847 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
848 main.initialized = main.FALSE
849 main.skipCase()
850 try:
851 assert main.numSwitch
852 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700853 main.log.error( "Place the total number of switch topology in "+\
854 main.numSwitch )
Jeremydd9bda62016-04-18 12:02:32 -0700855 main.initialized = main.FALSE
856 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700857
Jeremye1ea0602016-02-08 16:35:05 -0800858 # Save leader candidates
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700859 intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
Jeremye1ea0602016-02-08 16:35:05 -0800860
kelvin-onlab44147802015-07-27 17:57:31 -0700861 main.case( "Host Intents Test - " + str( main.numCtrls ) +
Jeremyeb51cb12016-03-28 17:53:35 -0700862 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -0700863 main.caseExplanation = "This test case tests Host intents using " +\
864 str( main.numCtrls ) + " node(s) cluster;\n" +\
865 "Different type of hosts will be tested in " +\
866 "each step such as IPV4, Dual stack, VLAN " +\
Jeremyeb51cb12016-03-28 17:53:35 -0700867 "etc;\nThe test will use OF " + main.OFProtocol +\
868 " OVS running in Mininet and compile intents" +\
869 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -0700870
Jeremy2f190ca2016-01-29 15:23:57 -0800871 main.step( "IPV4: Add and test host intents between h1 and h9" )
872 main.assertReturnString = "Assertion result for IPV4 host intent with mac addresses\n"
873 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
874 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
875 testResult = main.FALSE
876 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlab44147802015-07-27 17:57:31 -0700877 name='IPV4',
Jeremy2f190ca2016-01-29 15:23:57 -0800878 onosNode='0',
879 host1=host1,
880 host2=host2 )
881
882 if installResult:
883 testResult = main.intentFunction.testHostIntent( main,
884 name='IPV4',
885 intentId = installResult,
886 onosNode='0',
887 host1=host1,
888 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700889 sw1='s5',
890 sw2='s2',
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700891 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700892
893 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800894 actual=testResult,
895 onpass=main.assertReturnString,
896 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700897
898 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800899 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
900 host1 = { "name":"h3", "id":"00:00:00:00:00:03/-1" }
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700901 host2 = { "name":"h11","id":"00:00:00:00:00:0B/-1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800902 testResult = main.FALSE
903 installResult = main.intentFunction.installHostIntent( main,
904 name='DUALSTACK1',
905 onosNode='0',
906 host1=host1,
907 host2=host2 )
908
909 if installResult:
910 testResult = main.intentFunction.testHostIntent( main,
911 name='DUALSTACK1',
912 intentId = installResult,
913 onosNode='0',
914 host1=host1,
915 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700916 sw1='s5',
917 sw2='s2',
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700918 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700919
920 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800921 actual=testResult,
922 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700923 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700924
925 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800926 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
927 host1 = { "name":"h1" }
928 host2 = { "name":"h11" }
929 testResult = main.FALSE
930 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlab44147802015-07-27 17:57:31 -0700931 name='DUALSTACK2',
Jeremy2f190ca2016-01-29 15:23:57 -0800932 onosNode='0',
933 host1=host1,
934 host2=host2 )
935
936 if installResult:
937 testResult = main.intentFunction.testHostIntent( main,
938 name='DUALSTACK2',
939 intentId = installResult,
940 onosNode='0',
941 host1=host1,
942 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700943 sw1='s5',
944 sw2='s2',
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700945 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700946
947 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800948 actual=testResult,
949 onpass=main.assertReturnString,
950 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700951
952 main.step( "1HOP: Add host intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -0800953 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
954 host1 = { "name":"h1" }
955 host2 = { "name":"h3" }
956 testResult = main.FALSE
957 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlab44147802015-07-27 17:57:31 -0700958 name='1HOP',
Jeremy2f190ca2016-01-29 15:23:57 -0800959 onosNode='0',
960 host1=host1,
961 host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700962
Jeremy2f190ca2016-01-29 15:23:57 -0800963 if installResult:
964 testResult = main.intentFunction.testHostIntent( main,
965 name='1HOP',
966 intentId = installResult,
967 onosNode='0',
968 host1=host1,
969 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700970 sw1='s5',
971 sw2='s2',
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700972 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700973
974 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800975 actual=testResult,
976 onpass=main.assertReturnString,
977 onfail=main.assertReturnString )
978
979 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
980 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700981 host1 = { "name":"h4","id":"00:00:00:00:00:04/100", "vlanId":"100" }
982 host2 = { "name":"h12","id":"00:00:00:00:00:0C/100", "vlanId":"100" }
Jeremy2f190ca2016-01-29 15:23:57 -0800983 testResult = main.FALSE
984 installResult = main.intentFunction.installHostIntent( main,
985 name='VLAN1',
986 onosNode='0',
987 host1=host1,
988 host2=host2 )
989
990 if installResult:
991 testResult = main.intentFunction.testHostIntent( main,
992 name='VLAN1',
993 intentId = installResult,
994 onosNode='0',
995 host1=host1,
996 host2=host2,
997 sw1='s5',
998 sw2='s2',
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700999 expectedLink=18 )
Jeremy2f190ca2016-01-29 15:23:57 -08001000
1001 utilities.assert_equals( expect=main.TRUE,
1002 actual=testResult,
1003 onpass=main.assertReturnString,
1004 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001005
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001006 # This step isn't currently possible to perform in the REST API
1007 # main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
1008 # main.assertReturnString = "Assertion Result different VLAN negative test\n"
1009 # host1 = { "name":"h13" }
1010 # host2 = { "name":"h20" }
1011 # testResult = main.FALSE
1012 # installResult = main.intentFunction.installHostIntent( main,
1013 # name='VLAN2',
1014 # onosNode='0',
1015 # host1=host1,
1016 # host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -07001017
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001018 # if installResult:
1019 # testResult = main.intentFunction.testHostIntent( main,
1020 # name='VLAN2',
1021 # intentId = installResult,
1022 # onosNode='0',
1023 # host1=host1,
1024 # host2=host2,
1025 # sw1='s5',
1026 # sw2='s2',
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001027 # expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001028
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001029 # utilities.assert_equals( expect=main.TRUE,
1030 # actual=testResult,
1031 # onpass=main.assertReturnString,
1032 # onfail=main.assertReturnString )
Jeremy2f190ca2016-01-29 15:23:57 -08001033
Jeremye1ea0602016-02-08 16:35:05 -08001034 # Change the following to use the REST API when leader checking is
1035 # supported by it
Jeremy2f190ca2016-01-29 15:23:57 -08001036
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001037 main.step( "Confirm that ONOS leadership is unchanged" )
1038 intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
Jeremye1ea0602016-02-08 16:35:05 -08001039 main.intentFunction.checkLeaderChange( intentLeadersOld,
1040 intentLeadersNew )
Jeremy2f190ca2016-01-29 15:23:57 -08001041
Jeremye1ea0602016-02-08 16:35:05 -08001042 utilities.assert_equals( expect=main.TRUE,
1043 actual=testResult,
1044 onpass="ONOS Leaders Unchanged",
1045 onfail="ONOS Leader Mismatch")
Jeremy2f190ca2016-01-29 15:23:57 -08001046
1047 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001048
1049 def CASE2000( self, main ):
1050 """
1051 Add point intents between 2 hosts:
1052 - Get device ids | ports
1053 - Add point intents
1054 - Check intents
1055 - Verify flows
1056 - Ping hosts
1057 - Reroute
1058 - Link down
1059 - Verify flows
1060 - Check topology
1061 - Ping hosts
1062 - Link up
1063 - Verify flows
1064 - Check topology
1065 - Ping hosts
1066 - Remove intents
1067 """
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()
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001071 # Assert variables - These variable's name|format must be followed
1072 # if you want to use the wrapper function
kelvin-onlab44147802015-07-27 17:57:31 -07001073 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -07001074 try:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001075 assert main.RESTs
Jeremydd9bda62016-04-18 12:02:32 -07001076 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001077 main.log.error( "There is no main.RESTs, skipping test cases" )
Jeremydd9bda62016-04-18 12:02:32 -07001078 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:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001089 main.log.error( "Place the total number of switch topology in "+\
1090 main.numSwitch )
Jeremydd9bda62016-04-18 12:02:32 -07001091 main.initialized = main.FALSE
1092 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001093
1094 main.case( "Point Intents Test - " + str( main.numCtrls ) +
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001095 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
1096 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 + \
1102 " OVS running in Mininet and compile intents" + \
Jeremyeb51cb12016-03-28 17:53:35 -07001103 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001104
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001105 # No option point intent
kelvin-onlab44147802015-07-27 17:57:31 -07001106 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 = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001109 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy2f190ca2016-01-29 15:23:57 -08001110 ]
1111 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001112 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy2f190ca2016-01-29 15:23:57 -08001113 ]
1114 testResult = main.FALSE
1115 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001116 main,
1117 name="NOOPTION",
1118 senders=senders,
1119 recipients=recipients )
Jeremy2f190ca2016-01-29 15:23:57 -08001120
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",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001130 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 = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001140 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
Jeremy2f190ca2016-01-29 15:23:57 -08001141 ]
1142 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001143 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" }
Jeremy2f190ca2016-01-29 15:23:57 -08001144 ]
1145 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001146 main,
1147 name="IPV4",
1148 senders=senders,
1149 recipients=recipients,
1150 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -08001151
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",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001161 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 )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001167
kelvin-onlab44147802015-07-27 17:57:31 -07001168 main.step( "IPV4_2: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001169 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
1170 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001171 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy2f190ca2016-01-29 15:23:57 -08001172 ]
1173 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001174 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy2f190ca2016-01-29 15:23:57 -08001175 ]
1176 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001177 main,
1178 name="IPV4_2",
1179 senders=senders,
1180 recipients=recipients,
1181 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -08001182
1183 if installResult:
1184 testResult = main.intentFunction.testPointIntent(
1185 main,
1186 intentId=installResult,
1187 name="IPV4_2",
1188 senders=senders,
1189 recipients=recipients,
1190 sw1="s5",
1191 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001192 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001193
1194 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001195 actual=testResult,
1196 onpass=main.assertReturnString,
1197 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001198
kelvin-onlab0e684682015-08-11 18:51:41 -07001199 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001200 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
1201 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001202 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01",
1203 "ip": ( main.h1.hostIp + "/24" ) }
Jeremy2f190ca2016-01-29 15:23:57 -08001204 ]
1205 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001206 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09",
1207 "ip": ( main.h9.hostIp + "/24" ) }
Jeremy2f190ca2016-01-29 15:23:57 -08001208 ]
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001209 # ipProto = main.params['SDNIP']['icmpProto']
1210 ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ]
kelvin-onlab44147802015-07-27 17:57:31 -07001211 # Uneccessary, not including this in the selectors
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001212 tcpSrc = main.params['SDNIP']['srcPort']
1213 tcpDst = main.params['SDNIP']['dstPort']
kelvin-onlab44147802015-07-27 17:57:31 -07001214
Jeremy2f190ca2016-01-29 15:23:57 -08001215 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001216 main,
1217 name="SDNIP-ICMP",
1218 senders=senders,
1219 recipients=recipients,
1220 ethType="IPV4",
1221 ipProto=ipProto,
1222 tcpSrc=tcpSrc,
1223 tcpDst=tcpDst )
Jeremy2f190ca2016-01-29 15:23:57 -08001224
1225 if installResult:
1226 testResult = main.intentFunction.testPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001227 main,
1228 intentId=installResult,
1229 name="SDNIP_ICMP",
1230 senders=senders,
1231 recipients=recipients,
1232 sw1="s5",
1233 sw2="s2",
1234 expectedLink=18,
1235 useTCP=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001236
1237 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001238 actual=testResult,
1239 onpass=main.assertReturnString,
1240 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001241
kelvin-onlab0e684682015-08-11 18:51:41 -07001242 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001243 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001244 mac1 = main.hostsData['h1']['mac']
1245 mac2 = main.hostsData['h9']['mac']
1246 ip1 = str(main.hostsData['h1']['ipAddresses'][0]) + "/32"
1247 ip2 = str(main.hostsData['h9']['ipAddresses'][0]) + "/32"
1248 ipProto = main.params['SDNIP']['tcpProto']
1249 tcp1 = main.params['SDNIP']['srcPort']
1250 tcp2 = main.params['SDNIP']['dstPort']
kelvin-onlab44147802015-07-27 17:57:31 -07001251
kelvin-onlab0e684682015-08-11 18:51:41 -07001252 stepResult = main.intentFunction.pointIntentTcp(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001253 main,
1254 name="SDNIP-TCP",
1255 host1="h1",
1256 host2="h9",
1257 deviceId1="of:0000000000000005/1",
1258 deviceId2="of:0000000000000006/1",
1259 mac1=mac1,
1260 mac2=mac2,
1261 ethType="IPV4",
1262 ipProto=ipProto,
1263 ip1=ip1,
1264 ip2=ip2,
1265 tcp1=tcp1,
1266 tcp2=tcp2 )
kelvin-onlab44147802015-07-27 17:57:31 -07001267
1268 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001269 actual=stepResult,
Jeremy2f190ca2016-01-29 15:23:57 -08001270 onpass=main.assertReturnString,
1271 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001272
Jeremy2f190ca2016-01-29 15:23:57 -08001273 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
1274 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
1275 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001276 { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
Jeremy2f190ca2016-01-29 15:23:57 -08001277 ]
1278 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001279 { "name": "h11", "device": "of:0000000000000006/3", "mac": "00:00:00:00:00:0B" }
Jeremy2f190ca2016-01-29 15:23:57 -08001280 ]
1281 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001282 main,
1283 name="DUALSTACK1",
1284 senders=senders,
1285 recipients=recipients,
1286 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -08001287
1288 if installResult:
1289 testResult = main.intentFunction.testPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001290 main,
1291 intentId=installResult,
1292 name="DUALSTACK1",
1293 senders=senders,
1294 recipients=recipients,
1295 sw1="s5",
1296 sw2="s2",
1297 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001298
1299 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001300 actual=testResult,
1301 onpass=main.assertReturnString,
1302 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001303
1304 main.step( "VLAN: Add point intents between h5 and h21" )
Jeremy2f190ca2016-01-29 15:23:57 -08001305 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
1306 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001307 { "name": "h5", "device": "of:0000000000000005/5", "mac": "00:00:00:00:00:05", "vlanId": "200" }
Jeremy2f190ca2016-01-29 15:23:57 -08001308 ]
1309 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001310 { "name": "h21", "device": "of:0000000000000007/5", "mac": "00:00:00:00:00:15", "vlanId": "200" }
Jeremy2f190ca2016-01-29 15:23:57 -08001311 ]
1312 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001313 main,
1314 name="VLAN",
1315 senders=senders,
1316 recipients=recipients )
Jeremy2f190ca2016-01-29 15:23:57 -08001317
1318 if installResult:
1319 testResult = main.intentFunction.testPointIntent(
1320 main,
1321 intentId=installResult,
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001322 name="VLAN",
Jeremy2f190ca2016-01-29 15:23:57 -08001323 senders=senders,
1324 recipients=recipients,
1325 sw1="s5",
1326 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001327 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001328
1329 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001330 actual=testResult,
1331 onpass=main.assertReturnString,
1332 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001333
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001334 # TODO: implement VLAN selector REST API intent test once supported
1335
kelvin-onlab44147802015-07-27 17:57:31 -07001336 main.step( "1HOP: Add point intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -08001337 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
1338 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001339 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
Jeremy2f190ca2016-01-29 15:23:57 -08001340 ]
1341 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001342 { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
Jeremy2f190ca2016-01-29 15:23:57 -08001343 ]
1344 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001345 main,
1346 name="1HOP IPV4",
1347 senders=senders,
1348 recipients=recipients,
1349 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -08001350
1351 if installResult:
1352 testResult = main.intentFunction.testPointIntent(
1353 main,
1354 intentId=installResult,
1355 name="1HOP IPV4",
1356 senders=senders,
1357 recipients=recipients,
1358 sw1="s5",
1359 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001360 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001361
1362 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001363 actual=testResult,
1364 onpass=main.assertReturnString,
1365 onfail=main.assertReturnString )
1366
1367 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001368
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001369
kelvin-onlab44147802015-07-27 17:57:31 -07001370 def CASE3000( self, main ):
1371 """
1372 Add single point to multi point intents
1373 - Get device ids
1374 - Add single point to multi point intents
1375 - Check intents
1376 - Verify flows
1377 - Ping hosts
1378 - Reroute
1379 - Link down
1380 - Verify flows
1381 - Check topology
1382 - Ping hosts
1383 - Link up
1384 - Verify flows
1385 - Check topology
1386 - Ping hosts
1387 - Remove intents
1388 """
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001389 if main.initialized == main.FALSE:
1390 main.log.error( "Test components did not start correctly, skipping further tests" )
1391 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001392 assert main, "There is no main"
kelvin-onlab44147802015-07-27 17:57:31 -07001393
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001394 try:
1395 assert main.CLIs, "There is no main.CLIs, skipping test cases"
1396 assert main.Mininet1, "Mininet handle should be named Mininet1, skipping test cases"
1397 assert main.numSwitch, "Place the total number of switch topology in main.numSwitch"
1398 except AssertionError:
1399 main.initialized = main.FALSE
1400 main.skipCase()
1401
1402 main.testName = "Single to Multi Point Intents"
1403 main.case( main.testName + " Test - " + str( main.numCtrls ) +
1404 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
1405 main.caseExplanation = "This test case will test single point to" + \
1406 " multi point intents using " + \
1407 str( main.numCtrls ) + " node(s) cluster;\n" + \
1408 "Different type of hosts will be tested in " + \
1409 "each step such as IPV4, Dual stack, VLAN etc" + \
1410 ";\nThe test will use OF " + main.OFProtocol + \
1411 " OVS running in Mininet and compile intents" + \
Jeremyeb51cb12016-03-28 17:53:35 -07001412 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001413
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001414 main.step( "NOOPTION: Install and test single point to multi point intents" )
1415 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
1416 senders = [
1417 { "name": "h8", "device": "of:0000000000000005/8" }
1418 ]
1419 recipients = [
1420 { "name": "h16", "device": "of:0000000000000006/8" },
1421 { "name": "h24", "device": "of:0000000000000007/8" }
1422 ]
1423 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1424 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
1425 testResult = main.FALSE
1426 installResult = main.intentFunction.installSingleToMultiIntent(
1427 main,
1428 name="NOOPTION",
1429 senders=senders,
1430 recipients=recipients )
1431
1432 if installResult:
1433 testResult = main.intentFunction.testPointIntent(
1434 main,
1435 intentId=installResult,
1436 name="NOOPTION",
1437 senders=senders,
1438 recipients=recipients,
1439 badSenders=badSenders,
1440 badRecipients=badRecipients,
1441 sw1="s5",
1442 sw2="s2",
1443 expectedLink=18 )
1444 else:
1445 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001446
1447 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001448 actual=testResult,
1449 onpass=main.assertReturnString,
1450 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001451
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001452 main.step("IPV4: Install and test single point to multi point intents")
1453 main.assertReturnString = "Assertion results for IPV4 single to multi point intent " \
1454 "with IPV4 type and MAC addresses\n"
1455 senders = [
1456 {"name": "h8", "device": "of:0000000000000005/8", "mac": "00:00:00:00:00:08"}
1457 ]
1458 recipients = [
1459 {"name": "h16", "device": "of:0000000000000006/8", "mac": "00:00:00:00:00:10"},
1460 {"name": "h24", "device": "of:0000000000000007/8", "mac": "00:00:00:00:00:18"}
1461 ]
1462 badSenders = [{"name": "h9"}] # Senders that are not in the intent
1463 badRecipients = [{"name": "h17"}] # Recipients that are not in the intent
1464 installResult = main.intentFunction.installSingleToMultiIntent(
1465 main,
1466 name="IPV4",
1467 senders=senders,
1468 recipients=recipients,
1469 ethType="IPV4")
1470
1471 if installResult:
1472 testResult = main.intentFunction.testPointIntent(
1473 main,
1474 intentId=installResult,
1475 name="IPV4",
1476 senders=senders,
1477 recipients=recipients,
1478 badSenders=badSenders,
1479 badRecipients=badRecipients,
1480 sw1="s5",
1481 sw2="s2",
1482 expectedLink=18 )
1483 else:
1484 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001485
1486 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001487 actual=testResult,
1488 onpass=main.assertReturnString,
1489 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001490
1491 main.step( "IPV4_2: Add single point to multi point intents" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001492 main.assertReturnString = "Assertion results for IPV4 single to multi point intent " \
1493 "with IPV4 type and no MAC addresses\n"
1494 senders = [
1495 { "name": "h8", "device": "of:0000000000000005/8" }
1496 ]
1497 recipients = [
1498 { "name": "h16", "device": "of:0000000000000006/8" },
1499 { "name": "h24", "device": "of:0000000000000007/8" }
1500 ]
1501 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1502 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
1503 installResult = main.intentFunction.installSingleToMultiIntent(
1504 main,
1505 name="IPV4_2",
1506 senders=senders,
1507 recipients=recipients,
1508 ethType="IPV4" )
1509
1510 if installResult:
1511 testResult = main.intentFunction.testPointIntent(
1512 main,
1513 intentId=installResult,
1514 name="IPV4_2",
1515 senders=senders,
1516 recipients=recipients,
1517 badSenders=badSenders,
1518 badRecipients=badRecipients,
1519 sw1="s5",
1520 sw2="s2",
1521 expectedLink=18 )
1522 else:
1523 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001524
1525 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001526 actual=testResult,
1527 onpass=main.assertReturnString,
1528 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001529
1530 main.step( "VLAN: Add single point to multi point intents" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001531 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type " \
1532 "and MAC addresses in the same VLAN\n"
1533 senders = [
1534 { "name": "h4", "device": "of:0000000000000005/4", "mac": "00:00:00:00:00:04", "vlan": "100" }
1535 ]
1536 recipients = [
1537 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1538 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
1539 ]
1540 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1541 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
1542 installResult = main.intentFunction.installSingleToMultiIntent(
1543 main,
1544 name="VLAN",
1545 senders=senders,
1546 recipients=recipients,
1547 sw1="s5",
1548 sw2="s2" )
1549
1550 if installResult:
1551 testResult = main.intentFunction.testPointIntent(
1552 main,
1553 intentId=installResult,
1554 name="VLAN",
1555 senders=senders,
1556 recipients=recipients,
1557 badSenders=badSenders,
1558 badRecipients=badRecipients,
1559 sw1="s5",
1560 sw2="s2",
1561 expectedLink=18 )
1562 else:
1563 main.CLIs[ 0 ].removeAllIntents()
kelvin-onlab44147802015-07-27 17:57:31 -07001564
1565 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001566 actual=testResult,
1567 onpass=main.assertReturnString,
1568 onfail=main.assertReturnString )
1569
1570 main.step( "VLAN: Add single point to multi point intents" )
1571 main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n"
1572 senders = [
1573 { "name": "h5", "vlan": "200" }
1574 ]
1575 recipients = [
1576 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1577 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
1578 ]
1579 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1580 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
1581 testResult = main.FALSE
1582 installResult = main.intentFunction.installSingleToMultiIntent(
1583 main,
1584 name="VLAN2",
1585 senders=senders,
1586 recipients=recipients,
1587 sw1="s5",
1588 sw2="s2" )
1589 #setVlan=100 )
1590
1591 if installResult:
1592 testResult = main.intentFunction.testPointIntent(
1593 main,
1594 intentId=installResult,
1595 name="VLAN2",
1596 senders=senders,
1597 recipients=recipients,
1598 badSenders=badSenders,
1599 badRecipients=badRecipients,
1600 sw1="s5",
1601 sw2="s2",
1602 expectedLink=18 )
1603 else:
1604 main.CLIs[ 0 ].removeAllIntents()
1605
1606 utilities.assert_equals( expect=main.TRUE,
1607 actual=testResult,
1608 onpass=main.assertReturnString,
1609 onfail=main.assertReturnString )
1610
1611 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001612
1613 def CASE4000( self, main ):
1614 """
1615 Add multi point to single point intents
1616 - Get device ids
1617 - Add multi point to single point intents
1618 - Check intents
1619 - Verify flows
1620 - Ping hosts
1621 - Reroute
1622 - Link down
1623 - Verify flows
1624 - Check topology
1625 - Ping hosts
1626 - Link up
1627 - Verify flows
1628 - Check topology
1629 - Ping hosts
1630 - Remove intents
1631 """
1632 assert main, "There is no main"
1633 assert main.CLIs, "There is no main.CLIs"
1634 assert main.Mininet1, "Mininet handle should be named Mininet1"
1635 assert main.numSwitch, "Placed the total number of switch topology in \
1636 main.numSwitch"
1637
1638 main.case( "Multi To Single Point Intents Test - " +
Jeremyeb51cb12016-03-28 17:53:35 -07001639 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -07001640 main.caseExplanation = "This test case will test single point to" +\
1641 " multi point intents using " +\
1642 str( main.numCtrls ) + " node(s) cluster;\n" +\
1643 "Different type of hosts will be tested in " +\
1644 "each step such as IPV4, Dual stack, VLAN etc" +\
1645 ";\nThe test will use OF " + main.OFProtocol +\
Jeremyeb51cb12016-03-28 17:53:35 -07001646 " OVS running in Mininet and compile intents" +\
1647 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001648
1649 main.step( "NOOPTION: Add multi point to single point intents" )
1650 stepResult = main.TRUE
1651 hostNames = [ 'h8', 'h16', 'h24' ]
1652 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
1653 'of:0000000000000007/8' ]
1654 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
1655 stepResult = main.intentFunction.multiToSingleIntent(
1656 main,
1657 name="NOOPTION",
1658 hostNames=hostNames,
1659 devices=devices,
1660 sw1="s5",
1661 sw2="s2",
1662 expectedLink=18 )
1663
1664 utilities.assert_equals( expect=main.TRUE,
1665 actual=stepResult,
1666 onpass="NOOPTION: Successfully added multi "
1667 + " point to single point intents" +
1668 " with no match action",
1669 onfail="NOOPTION: Failed to add multi point" +
1670 " to single point intents" +
1671 " with no match action" )
1672
1673 main.step( "IPV4: Add multi point to single point intents" )
1674 stepResult = main.TRUE
1675 stepResult = main.intentFunction.multiToSingleIntent(
1676 main,
1677 name="IPV4",
1678 hostNames=hostNames,
1679 devices=devices,
1680 ports=None,
1681 ethType="IPV4",
1682 macs=macs,
1683 bandwidth="",
1684 lambdaAlloc=False,
1685 ipProto="",
1686 ipAddresses="",
1687 tcp="",
1688 sw1="s5",
1689 sw2="s2",
1690 expectedLink=18 )
1691
1692 utilities.assert_equals( expect=main.TRUE,
1693 actual=stepResult,
1694 onpass="IPV4: Successfully added multi point"
1695 + " to single point intents" +
1696 " with IPV4 type and MAC addresses",
1697 onfail="IPV4: Failed to add multi point" +
1698 " to single point intents" +
1699 " with IPV4 type and MAC addresses" )
1700
1701 main.step( "IPV4_2: Add multi point to single point intents" )
1702 stepResult = main.TRUE
1703 hostNames = [ 'h8', 'h16', 'h24' ]
1704 stepResult = main.intentFunction.multiToSingleIntent(
1705 main,
1706 name="IPV4",
1707 hostNames=hostNames,
1708 ethType="IPV4",
1709 lambdaAlloc=False )
1710
1711 utilities.assert_equals( expect=main.TRUE,
1712 actual=stepResult,
1713 onpass="IPV4_2: Successfully added multi point"
1714 + " to single point intents" +
1715 " with IPV4 type and no MAC addresses",
1716 onfail="IPV4_2: Failed to add multi point" +
1717 " to single point intents" +
1718 " with IPV4 type and no MAC addresses" )
1719
1720 main.step( "VLAN: Add multi point to single point intents" )
1721 stepResult = main.TRUE
1722 hostNames = [ 'h5', 'h13', 'h21' ]
1723 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \
1724 'of:0000000000000007/5' ]
1725 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
1726 stepResult = main.intentFunction.multiToSingleIntent(
1727 main,
1728 name="VLAN",
1729 hostNames=hostNames,
1730 devices=devices,
1731 ports=None,
1732 ethType="IPV4",
1733 macs=macs,
1734 bandwidth="",
1735 lambdaAlloc=False,
1736 ipProto="",
1737 ipAddresses="",
1738 tcp="",
1739 sw1="s5",
1740 sw2="s2",
1741 expectedLink=18 )
1742
1743 utilities.assert_equals( expect=main.TRUE,
1744 actual=stepResult,
1745 onpass="VLAN: Successfully added multi point"
1746 + " to single point intents" +
1747 " with IPV4 type and MAC addresses" +
1748 " in the same VLAN",
1749 onfail="VLAN: Failed to add multi point" +
1750 " to single point intents" )
1751
1752 def CASE5000( self, main ):
1753 """
Jeremy2f190ca2016-01-29 15:23:57 -08001754 Tests Host Mobility
1755 Modifies the topology location of h1
kelvin-onlab44147802015-07-27 17:57:31 -07001756 """
Jeremydd9bda62016-04-18 12:02:32 -07001757 if main.initialized == main.FALSE:
1758 main.log.error( "Test components did not start correctly, skipping further tests" )
1759 main.skipCase()
1760 # Assert variables - These variable's name|format must be followed
1761 # if you want to use the wrapper function
kelvin-onlab44147802015-07-27 17:57:31 -07001762 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -07001763 try:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001764 assert main.RESTs
Jeremydd9bda62016-04-18 12:02:32 -07001765 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001766 main.log.error( "There is no main.RESTs, skipping test cases" )
Jeremydd9bda62016-04-18 12:02:32 -07001767 main.initialized = main.FALSE
1768 main.skipCase()
1769 try:
1770 assert main.Mininet1
1771 except AssertionError:
1772 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1773 main.initialized = main.FALSE
1774 main.skipCase()
1775 try:
1776 assert main.numSwitch
1777 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001778 main.log.error( "Place the total number of switch topology in " +\
1779 main.numSwitch )
Jeremydd9bda62016-04-18 12:02:32 -07001780 main.initialized = main.FALSE
1781 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001782 main.case( "Test host mobility with host intents " )
Jeremy2f190ca2016-01-29 15:23:57 -08001783 main.step( "Testing host mobility by moving h1 from s5 to s6" )
kelvin-onlab44147802015-07-27 17:57:31 -07001784 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1785
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001786 main.log.info( "Moving h1 from s5 to s6" )
1787 main.Mininet1.moveHost( "h1", "s5", "s6" )
kelvin-onlab44147802015-07-27 17:57:31 -07001788
Jeremy2f190ca2016-01-29 15:23:57 -08001789 # Send discovery ping from moved host
1790 # Moving the host brings down the default interfaces and creates a new one.
1791 # Scapy is restarted on this host to detect the new interface
1792 main.h1.stopScapy()
1793 main.h1.startScapy()
1794
1795 # Discover new host location in ONOS and populate host data.
1796 # Host 1 IP and MAC should be unchanged
1797 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
1798 main.intentFunction.populateHostData( main )
1799
kelvin-onlab44147802015-07-27 17:57:31 -07001800 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1801
1802 utilities.assert_equals( expect="of:0000000000000006",
1803 actual=h1PostMove,
1804 onpass="Mobility: Successfully moved h1 to s6",
Jeremy2f190ca2016-01-29 15:23:57 -08001805 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlab44147802015-07-27 17:57:31 -07001806 " to single point intents" +
1807 " with IPV4 type and MAC addresses" +
1808 " in the same VLAN" )
1809
1810 main.step( "IPV4: Add host intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001811 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
1812 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
1813 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
1814
1815 installResult = main.intentFunction.installHostIntent( main,
1816 name='IPV4 Mobility IPV4',
kelvin-onlab44147802015-07-27 17:57:31 -07001817 onosNode='0',
Jeremy2f190ca2016-01-29 15:23:57 -08001818 host1=host1,
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001819 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -08001820 if installResult:
1821 testResult = main.intentFunction.testHostIntent( main,
1822 name='Host Mobility IPV4',
1823 intentId = installResult,
1824 onosNode='0',
1825 host1=host1,
1826 host2=host2,
1827 sw1="s6",
1828 sw2="s2",
1829 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001830
1831 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001832 actual=testResult,
1833 onpass=main.assertReturnString,
1834 onfail=main.assertReturnString )
1835
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001836 main.intentFunction.report( main )