blob: dcf742550c478e12ec3e950378abf9ecb130fb56 [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" )
Jon Hallbd60ea02016-08-23 10:03:59 -0700214 packageResult = main.ONOSbench.buckBuild()
kelvin-onlab44147802015-07-27 17:57:31 -0700215 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
You Wangf5de25b2017-01-06 15:13:01 -0800233 main.step( "Set up ONOS secure SSH" )
234 secureSshResult = main.TRUE
235 for i in range( int( main.numCtrls ) ):
236 secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
237 utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
238 onpass="Test step PASS",
239 onfail="Test step FAIL" )
240
kelvin-onlab44147802015-07-27 17:57:31 -0700241 time.sleep( main.startUpSleep )
242 main.step( "Starting ONOS service" )
243 stopResult = main.TRUE
244 startResult = main.TRUE
245 onosIsUp = main.TRUE
246
247 for i in range( main.numCtrls ):
248 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
Jeremydd9bda62016-04-18 12:02:32 -0700249 if onosIsUp == main.TRUE:
250 main.log.report( "ONOS instance {0} is up and ready".format( i + 1 ) )
251 else:
252 main.log.report( "ONOS instance {0} may not be up, stop and ".format( i + 1 ) +
253 "start ONOS again " )
254 stopResult = stopResult and main.ONOSbench.onosStop( main.ONOSip[ i ] )
255 startResult = startResult and main.ONOSbench.onosStart( main.ONOSip[ i ] )
256 if not startResult or stopResult:
257 main.log.report( "ONOS instance {0} did not start correctly.".format( i + 1 ) )
kelvin-onlab44147802015-07-27 17:57:31 -0700258 stepResult = onosIsUp and stopResult and startResult
259 utilities.assert_equals( expect=main.TRUE,
260 actual=stepResult,
261 onpass="ONOS service is ready",
262 onfail="ONOS service did not start properly" )
Jeremydd9bda62016-04-18 12:02:32 -0700263 if not stepResult:
264 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700265
Jeremy2f190ca2016-01-29 15:23:57 -0800266 # Start an ONOS cli to provide functionality that is not currently
Jeremye1ea0602016-02-08 16:35:05 -0800267 # supported by the Rest API remove this when Leader Checking is supported
268 # by the REST API
Jeremy2f190ca2016-01-29 15:23:57 -0800269
Jeremye1ea0602016-02-08 16:35:05 -0800270 main.step( "Start ONOS cli" )
271 cliResult = main.TRUE
272 for i in range( main.numCtrls ):
273 cliResult = cliResult and \
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700274 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
Jeremye1ea0602016-02-08 16:35:05 -0800275 stepResult = cliResult
276 utilities.assert_equals( expect=main.TRUE,
277 actual=stepResult,
278 onpass="Successfully start ONOS cli",
279 onfail="Failed to start ONOS cli" )
Jeremydd9bda62016-04-18 12:02:32 -0700280 if not stepResult:
281 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800282
kelvin-onlab44147802015-07-27 17:57:31 -0700283 # Remove the first element in main.scale list
284 main.scale.remove( main.scale[ 0 ] )
285
Jeremy2f190ca2016-01-29 15:23:57 -0800286 main.intentFunction.report( main )
287
kelvin-onlab44147802015-07-27 17:57:31 -0700288 def CASE8( self, main ):
Jeremy2f190ca2016-01-29 15:23:57 -0800289 # OLD FUNCintentRest CASE 8
290 # This remains here for archiving and reference purposes and will be
291 # removed when the new FUNCintentRest is verified to work.
292 # """
293 # Compare Topo
294 # """
295 # import json
296
297 # main.case( "Compare ONOS Topology view to Mininet topology" )
298 # main.caseExplanation = "Compare topology elements between Mininet" +\
299 # " and ONOS"
300
301 # main.step( "Gathering topology information" )
302 # # TODO: add a paramaterized sleep here
303 # devicesResults = main.TRUE # Overall Boolean for device correctness
304 # linksResults = main.TRUE # Overall Boolean for link correctness
305 # hostsResults = main.TRUE # Overall Boolean for host correctness
306 # devices = main.topo.getAllDevices( main )
307 # hosts = main.topo.getAllHosts( main )
308 # ports = main.topo.getAllPorts( main )
309 # links = main.topo.getAllLinks( main )
310 # clusters = main.topo.getAllClusters( main )
311
312 # mnSwitches = main.Mininet1.getSwitches()
313 # mnLinks = main.Mininet1.getLinks()
314 # mnHosts = main.Mininet1.getHosts()
315
316 # main.step( "Comparing MN topology to ONOS topology" )
317 # for controller in range( main.numCtrls ):
318 # controllerStr = str( controller + 1 )
319 # if devices[ controller ] and ports[ controller ] and\
320 # "Error" not in devices[ controller ] and\
321 # "Error" not in ports[ controller ]:
322
323 # currentDevicesResult = main.Mininet1.compareSwitches(
324 # mnSwitches,
325 # json.loads( devices[ controller ] ),
326 # json.loads( ports[ controller ] ) )
327 # else:
328 # currentDevicesResult = main.FALSE
329 # utilities.assert_equals( expect=main.TRUE,
330 # actual=currentDevicesResult,
331 # onpass="ONOS" + controllerStr +
332 # " Switches view is correct",
333 # onfail="ONOS" + controllerStr +
334 # " Switches view is incorrect" )
335
336 # if links[ controller ] and "Error" not in links[ controller ]:
337 # currentLinksResult = main.Mininet1.compareLinks(
338 # mnSwitches, mnLinks,
339 # json.loads( links[ controller ] ) )
340 # else:
341 # currentLinksResult = main.FALSE
342 # utilities.assert_equals( expect=main.TRUE,
343 # actual=currentLinksResult,
344 # onpass="ONOS" + controllerStr +
345 # " links view is correct",
346 # onfail="ONOS" + controllerStr +
347 # " links view is incorrect" )
348
349 # if hosts[ controller ] or "Error" not in hosts[ controller ]:
350 # currentHostsResult = main.Mininet1.compareHosts(
351 # mnHosts,
352 # json.loads( hosts[ controller ] ) )
353 # else:
354 # currentHostsResult = main.FALSE
355 # utilities.assert_equals( expect=main.TRUE,
356 # actual=currentHostsResult,
357 # onpass="ONOS" + controllerStr +
358 # " hosts exist in Mininet",
359 # onfail="ONOS" + controllerStr +
360 # " hosts don't match Mininet" )
361
362 # NEW FUNCintentRest Case 8 as based off of the CASE 8 from FUNCintent
kelvin-onlab44147802015-07-27 17:57:31 -0700363 """
Jeremy2f190ca2016-01-29 15:23:57 -0800364 Compare ONOS Topology to Mininet Topology
kelvin-onlab44147802015-07-27 17:57:31 -0700365 """
366 import json
367
368 main.case( "Compare ONOS Topology view to Mininet topology" )
369 main.caseExplanation = "Compare topology elements between Mininet" +\
370 " and ONOS"
371
Jeremy2f190ca2016-01-29 15:23:57 -0800372 main.log.info( "Gathering topology information from Mininet" )
373 devicesResults = main.FALSE # Overall Boolean for device correctness
374 linksResults = main.FALSE # Overall Boolean for link correctness
375 hostsResults = main.FALSE # Overall Boolean for host correctness
376 deviceFails = [] # Nodes where devices are incorrect
377 linkFails = [] # Nodes where links are incorrect
378 hostFails = [] # Nodes where hosts are incorrect
379 attempts = main.checkTopoAttempts # Remaining Attempts
kelvin-onlab44147802015-07-27 17:57:31 -0700380
381 mnSwitches = main.Mininet1.getSwitches()
382 mnLinks = main.Mininet1.getLinks()
383 mnHosts = main.Mininet1.getHosts()
384
Jeremy2f190ca2016-01-29 15:23:57 -0800385 main.step( "Comparing Mininet topology to ONOS topology" )
kelvin-onlab44147802015-07-27 17:57:31 -0700386
Jeremy2f190ca2016-01-29 15:23:57 -0800387 while ( attempts >= 0 ) and\
388 ( not devicesResults or not linksResults or not hostsResults ):
389 time.sleep( 2 )
390 if not devicesResults:
391 devices = main.topo.getAllDevices( main )
392 ports = main.topo.getAllPorts( main )
393 devicesResults = main.TRUE
394 deviceFails = [] # Reset for each failed attempt
395 if not linksResults:
396 links = main.topo.getAllLinks( main )
397 linksResults = main.TRUE
398 linkFails = [] # Reset for each failed attempt
399 if not hostsResults:
400 hosts = main.topo.getAllHosts( main )
401 hostsResults = main.TRUE
402 hostFails = [] # Reset for each failed attempt
kelvin-onlab44147802015-07-27 17:57:31 -0700403
Jeremy2f190ca2016-01-29 15:23:57 -0800404 # Check for matching topology on each node
405 for controller in range( main.numCtrls ):
406 controllerStr = str( controller + 1 ) # ONOS node number
407 # Compare Devices
408 if devices[ controller ] and ports[ controller ] and\
409 "Error" not in devices[ controller ] and\
410 "Error" not in ports[ controller ]:
kelvin-onlab44147802015-07-27 17:57:31 -0700411
Jeremy2f190ca2016-01-29 15:23:57 -0800412 try:
413 deviceData = json.loads( devices[ controller ] )
414 portData = json.loads( ports[ controller ] )
415 except (TypeError,ValueError):
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700416 main.log.error( "Could not load json: {0} or {1}".format( str( devices[ controller ] ),
417 str( ports[ controller ] ) ) )
Jeremy2f190ca2016-01-29 15:23:57 -0800418 currentDevicesResult = main.FALSE
419 else:
420 currentDevicesResult = main.Mininet1.compareSwitches(
421 mnSwitches,deviceData,portData )
422 else:
423 currentDevicesResult = main.FALSE
424 if not currentDevicesResult:
425 deviceFails.append( controllerStr )
426 devicesResults = devicesResults and currentDevicesResult
427 # Compare Links
428 if links[ controller ] and "Error" not in links[ controller ]:
429 try:
430 linkData = json.loads( links[ controller ] )
431 except (TypeError,ValueError):
432 main.log.error("Could not load json:" + str( links[ controller ] ) )
433 currentLinksResult = main.FALSE
434 else:
435 currentLinksResult = main.Mininet1.compareLinks(
436 mnSwitches, mnLinks,linkData )
437 else:
438 currentLinksResult = main.FALSE
439 if not currentLinksResult:
440 linkFails.append( controllerStr )
441 linksResults = linksResults and currentLinksResult
442 # Compare Hosts
443 if hosts[ controller ] and "Error" not in hosts[ controller ]:
444 try:
445 hostData = json.loads( hosts[ controller ] )
446 except (TypeError,ValueError):
447 main.log.error("Could not load json:" + str( hosts[ controller ] ) )
448 currentHostsResult = main.FALSE
449 else:
450 currentHostsResult = main.Mininet1.compareHosts(
451 mnHosts,hostData )
452 else:
453 currentHostsResult = main.FALSE
454 if not currentHostsResult:
455 hostFails.append( controllerStr )
456 hostsResults = hostsResults and currentHostsResult
457 # Decrement Attempts Remaining
458 attempts -= 1
459
460
461 utilities.assert_equals( expect=[],
462 actual=deviceFails,
463 onpass="ONOS correctly discovered all devices",
464 onfail="ONOS incorrectly discovered devices on nodes: " +
465 str( deviceFails ) )
466 utilities.assert_equals( expect=[],
467 actual=linkFails,
468 onpass="ONOS correctly discovered all links",
469 onfail="ONOS incorrectly discovered links on nodes: " +
470 str( linkFails ) )
471 utilities.assert_equals( expect=[],
472 actual=hostFails,
473 onpass="ONOS correctly discovered all hosts",
474 onfail="ONOS incorrectly discovered hosts on nodes: " +
475 str( hostFails ) )
476 topoResults = hostsResults and linksResults and devicesResults
477 utilities.assert_equals( expect=main.TRUE,
478 actual=topoResults,
479 onpass="ONOS correctly discovered the topology",
480 onfail="ONOS incorrectly discovered the topology" )
kelvin-onlab44147802015-07-27 17:57:31 -0700481
482 def CASE9( self, main ):
483 '''
484 Report errors/warnings/exceptions
485 '''
486 main.log.info( "Error report: \n" )
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700487 main.ONOSbench.logReport( globalONOSip[ 0 ],
kelvin-onlab44147802015-07-27 17:57:31 -0700488 [ "INFO", "FOLLOWER", "WARN", "flow", "ERROR" , "Except" ],
489 "s" )
490 #main.ONOSbench.logReport( globalONOSip[1], [ "INFO" ], "d" )
491
492 def CASE10( self, main ):
493 """
494 Start Mininet topology with OF 1.0 switches
495 """
Jeremydd9bda62016-04-18 12:02:32 -0700496 if main.initialized == main.FALSE:
497 main.log.error( "Test components did not start correctly, skipping further tests" )
498 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700499 main.OFProtocol = "1.0"
500 main.log.report( "Start Mininet topology with OF 1.0 switches" )
501 main.case( "Start Mininet topology with OF 1.0 switches" )
502 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
503 "switches to test intents, exits out if " +\
504 "topology did not start correctly"
505
506 main.step( "Starting Mininet topology with OF 1.0 switches" )
507 args = "--switch ovs,protocols=OpenFlow10"
508 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
509 main.topology,
510 args=args )
511 stepResult = topoResult
512 utilities.assert_equals( expect=main.TRUE,
513 actual=stepResult,
514 onpass="Successfully loaded topology",
515 onfail="Failed to load topology" )
516 # Exit if topology did not load properly
517 if not topoResult:
Jeremydd9bda62016-04-18 12:02:32 -0700518 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700519
520 def CASE11( self, main ):
521 """
522 Start Mininet topology with OF 1.3 switches
523 """
Jeremydd9bda62016-04-18 12:02:32 -0700524 if main.initialized == main.FALSE:
525 main.log.error( "Test components did not start correctly, skipping further tests" )
526 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700527 main.OFProtocol = "1.3"
528 main.log.report( "Start Mininet topology with OF 1.3 switches" )
529 main.case( "Start Mininet topology with OF 1.3 switches" )
530 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
531 "switches to test intents, exits out if " +\
532 "topology did not start correctly"
533
534 main.step( "Starting Mininet topology with OF 1.3 switches" )
535 args = "--switch ovs,protocols=OpenFlow13"
536 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
537 main.topology,
538 args=args )
539 stepResult = topoResult
540 utilities.assert_equals( expect=main.TRUE,
541 actual=stepResult,
542 onpass="Successfully loaded topology",
543 onfail="Failed to load topology" )
544 # Exit if topology did not load properly
545 if not topoResult:
Jeremydd9bda62016-04-18 12:02:32 -0700546 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700547
548 def CASE12( self, main ):
549 """
550 Assign mastership to controllers
551 """
552 import re
553
Jeremydd9bda62016-04-18 12:02:32 -0700554 if main.initialized == main.FALSE:
555 main.log.error( "Test components did not start correctly, skipping further tests" )
556 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700557 main.case( "Assign switches to controllers" )
558 main.step( "Assigning switches to controllers" )
559 main.caseExplanation = "Assign OF " + main.OFProtocol +\
560 " switches to ONOS nodes"
561
562 assignResult = main.TRUE
563 switchList = []
564
565 # Creates a list switch name, use getSwitch() function later...
566 for i in range( 1, ( main.numSwitch + 1 ) ):
567 switchList.append( 's' + str( i ) )
568
569 tempONOSip = []
570 for i in range( main.numCtrls ):
571 tempONOSip.append( main.ONOSip[ i ] )
572
573 assignResult = main.Mininet1.assignSwController( sw=switchList,
574 ip=tempONOSip,
Charles Chan029be652015-08-24 01:46:10 +0800575 port='6653' )
kelvin-onlab44147802015-07-27 17:57:31 -0700576 if not assignResult:
Jeremydd9bda62016-04-18 12:02:32 -0700577 main.log.error( "Problem assigning mastership of switches, skipping further test cases" )
578 main.initialized = main.FALSE
579 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700580
581 for i in range( 1, ( main.numSwitch + 1 ) ):
582 response = main.Mininet1.getSwController( "s" + str( i ) )
583 print( "Response is " + str( response ) )
584 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
585 assignResult = assignResult and main.TRUE
586 else:
587 assignResult = main.FALSE
588 stepResult = assignResult
589 utilities.assert_equals( expect=main.TRUE,
590 actual=stepResult,
591 onpass="Successfully assigned switches" +
592 "to controller",
593 onfail="Failed to assign switches to " +
594 "controller" )
Jeremydd9bda62016-04-18 12:02:32 -0700595 if not stepResult:
596 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800597
598 def CASE13( self,main ):
599 """
600 Create Scapy components
601 """
Jeremydd9bda62016-04-18 12:02:32 -0700602 if main.initialized == main.FALSE:
603 main.log.error( "Test components did not start correctly, skipping further tests" )
604 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800605 main.case( "Create scapy components" )
606 main.step( "Create scapy components" )
607 import json
608 scapyResult = main.TRUE
609 for hostName in main.scapyHostNames:
610 main.Scapy1.createHostComponent( hostName )
611 main.scapyHosts.append( getattr( main, hostName ) )
612
613 main.step( "Start scapy components" )
614 for host in main.scapyHosts:
615 host.startHostCli()
616 host.startScapy()
617 host.updateSelf()
618 main.log.debug( host.name )
619 main.log.debug( host.hostIp )
620 main.log.debug( host.hostMac )
621
622
623 utilities.assert_equals( expect=main.TRUE,
624 actual=scapyResult,
625 onpass="Successfully created Scapy Components",
626 onfail="Failed to discover Scapy Components" )
Jeremydd9bda62016-04-18 12:02:32 -0700627 if not scapyResult:
628 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800629
630 def CASE14( self, main ):
kelvin-onlab44147802015-07-27 17:57:31 -0700631 """
632 Discover all hosts and store its data to a dictionary
633 """
Jeremydd9bda62016-04-18 12:02:32 -0700634 if main.initialized == main.FALSE:
635 main.log.error( "Test components did not start correctly, skipping further tests" )
636 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700637 main.case( "Discover all hosts" )
638
639 stepResult = main.TRUE
kelvin-onlab0e684682015-08-11 18:51:41 -0700640 main.step( "Discover all ipv4 host hosts " )
641 hostList = []
642 # List of host with default vlan
643 defaultHosts = [ "h1", "h3", "h8", "h9", "h11", "h16", "h17", "h19", "h24" ]
644 # Lists of host with unique vlan
645 vlanHosts1 = [ "h4", "h12", "h20" ]
646 vlanHosts2 = [ "h5", "h13", "h21" ]
647 vlanHosts3 = [ "h6", "h14", "h22" ]
648 vlanHosts4 = [ "h7", "h15", "h23" ]
649 hostList.append( defaultHosts )
650 hostList.append( vlanHosts1 )
651 hostList.append( vlanHosts2 )
652 hostList.append( vlanHosts3 )
653 hostList.append( vlanHosts4 )
654
655 stepResult = main.intentFunction.getHostsData( main, hostList )
kelvin-onlab44147802015-07-27 17:57:31 -0700656 utilities.assert_equals( expect=main.TRUE,
657 actual=stepResult,
658 onpass="Successfully discovered hosts",
659 onfail="Failed to discover hosts" )
Jeremydd9bda62016-04-18 12:02:32 -0700660 if not stepResult:
661 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700662
Jeremy2f190ca2016-01-29 15:23:57 -0800663 def CASE15( self, main ):
kelvin-onlab44147802015-07-27 17:57:31 -0700664 """
Jeremy2f190ca2016-01-29 15:23:57 -0800665 Discover all hosts with scapy arp packets and store its data to a dictionary
kelvin-onlab44147802015-07-27 17:57:31 -0700666 """
Jeremydd9bda62016-04-18 12:02:32 -0700667 if main.initialized == main.FALSE:
668 main.log.error( "Test components did not start correctly, skipping further tests" )
669 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800670 main.case( "Discover all hosts using scapy" )
671 main.step( "Send packets from each host to the first host and confirm onos discovery" )
672
673 import collections
674 if len( main.scapyHosts ) < 1:
675 main.log.error( "No scapy hosts have been created" )
Jeremydd9bda62016-04-18 12:02:32 -0700676 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800677 main.skipCase()
678
679 # Send ARP packets from each scapy host component
680 main.intentFunction.sendDiscoveryArp( main, main.scapyHosts )
681
682 stepResult = utilities.retry( f=main.intentFunction.confirmHostDiscovery,
683 retValue=main.FALSE, args=[ main ],
684 attempts=main.checkTopoAttempts, sleep=2 )
685
686 utilities.assert_equals( expect=main.TRUE,
687 actual=stepResult,
688 onpass="ONOS correctly discovered all hosts",
689 onfail="ONOS incorrectly discovered hosts" )
Jeremydd9bda62016-04-18 12:02:32 -0700690 if not stepResult:
691 main.initialized = main.FALSE
692 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800693
694 main.step( "Populate hostsData" )
695 stepResult = main.intentFunction.populateHostData( main )
696 utilities.assert_equals( expect=main.TRUE,
697 actual=stepResult,
698 onpass="Successfully populated hostsData",
699 onfail="Failed to populate hostsData" )
Jeremydd9bda62016-04-18 12:02:32 -0700700 if not stepResult:
701 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800702
703 def CASE16( self, main ):
704 """
Jeremy42df2e72016-02-23 16:37:46 -0800705 Balance Masters
706 """
Jeremydd9bda62016-04-18 12:02:32 -0700707 if main.initialized == main.FALSE:
708 main.log.error( "Test components did not start correctly, skipping further tests" )
709 main.skipCase()
Jeremy42df2e72016-02-23 16:37:46 -0800710 main.case( "Balance mastership of switches" )
711 main.step( "Balancing mastership of switches" )
712
713 balanceResult = main.FALSE
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700714 balanceResult = utilities.retry( f=main.CLIs[ 0 ].balanceMasters, retValue=main.FALSE, args=[] )
Jeremy42df2e72016-02-23 16:37:46 -0800715
716 utilities.assert_equals( expect=main.TRUE,
717 actual=stepResult,
718 onpass="Successfully balanced mastership of switches",
719 onfail="Failed to balance mastership of switches" )
Jeremydd9bda62016-04-18 12:02:32 -0700720 if not stepResult:
721 main.initialized = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800722
723 def CASE17( self, main ):
724 """
Jeremyeb51cb12016-03-28 17:53:35 -0700725 Use Flow Objectives
726 """
Jeremydd9bda62016-04-18 12:02:32 -0700727 if main.initialized == main.FALSE:
728 main.log.error( "Test components did not start correctly, skipping further tests" )
729 main.skipCase()
Jeremyeb51cb12016-03-28 17:53:35 -0700730 main.case( "Enable intent compilation using Flow Objectives" )
731 main.step( "Enabling Flow Objectives" )
732
733 main.flowCompiler = "Flow Objectives"
734
735 cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator"
736
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700737 stepResult = main.CLIs[ 0 ].setCfg( component=cmd,
Jeremyeb51cb12016-03-28 17:53:35 -0700738 propName="useFlowObjectives", value="true" )
739
740 utilities.assert_equals( expect=main.TRUE,
741 actual=stepResult,
742 onpass="Successfully activated Flow Objectives",
743 onfail="Failed to activate Flow Objectives" )
Jeremydd9bda62016-04-18 12:02:32 -0700744 if not stepResult:
745 main.initialized = main.FALSE
Jeremyeb51cb12016-03-28 17:53:35 -0700746
747 def CASE18( self, main ):
748 """
Jeremy2f190ca2016-01-29 15:23:57 -0800749 Stop mininet and remove scapy hosts
750 """
751 main.log.report( "Stop Mininet and Scapy" )
752 main.case( "Stop Mininet and Scapy" )
kelvin-onlab44147802015-07-27 17:57:31 -0700753 main.caseExplanation = "Stopping the current mininet topology " +\
754 "to start up fresh"
755
Jeremy2f190ca2016-01-29 15:23:57 -0800756 main.step( "Stopping and Removing Scapy Host Components" )
757 scapyResult = main.TRUE
758 for host in main.scapyHosts:
759 scapyResult = scapyResult and host.stopScapy()
760 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
761
762 for host in main.scapyHosts:
763 scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
764 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
765
766 main.scapyHosts = []
767 main.scapyHostIPs = []
768
769 utilities.assert_equals( expect=main.TRUE,
770 actual=scapyResult,
771 onpass="Successfully stopped scapy and removed host components",
772 onfail="Failed to stop mininet and scapy" )
773
kelvin-onlab44147802015-07-27 17:57:31 -0700774 main.step( "Stopping Mininet Topology" )
Jeremy2f190ca2016-01-29 15:23:57 -0800775 mininetResult = main.Mininet1.stopNet( )
776
kelvin-onlab44147802015-07-27 17:57:31 -0700777 utilities.assert_equals( expect=main.TRUE,
778 actual=stepResult,
779 onpass="Successfully stop mininet",
780 onfail="Failed to stop mininet" )
781 # Exit if topology did not load properly
Jeremy2f190ca2016-01-29 15:23:57 -0800782 if not (mininetResult and scapyResult ):
kelvin-onlab44147802015-07-27 17:57:31 -0700783 main.cleanup()
784 main.exit()
785
Jeremy Songster17147f22016-05-31 18:30:52 -0700786 def CASE19( self, main ):
787 """
788 Copy the karaf.log files after each testcase cycle
789 """
790 main.log.report( "Copy karaf logs" )
791 main.case( "Copy karaf logs" )
792 main.caseExplanation = "Copying the karaf logs to preserve them through" +\
793 "reinstalling ONOS"
794 main.step( "Copying karaf logs" )
Jeremy Songster31aad312016-06-13 16:32:11 -0700795 stepResult = main.TRUE
796 scpResult = main.TRUE
797 copyResult = main.TRUE
Jeremy Songstercc5414b2016-07-11 10:59:53 -0700798 for i in range( main.numCtrls ):
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700799 main.node = main.CLIs[ i ]
Jeremy Songster17147f22016-05-31 18:30:52 -0700800 ip = main.ONOSip[ i ]
801 main.node.ip_address = ip
Jeremy Songster31aad312016-06-13 16:32:11 -0700802 scpResult = scpResult and main.ONOSbench.scp( main.node ,
803 "/opt/onos/log/karaf.log",
804 "/tmp/karaf.log",
805 direction="from" )
806 copyResult = copyResult and main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700807 copyFileName=( "karaf.log.node{0}.cycle{1}".format(
808 str( i + 1 ), str( main.cycle ) ) ) )
Jeremy Songster31aad312016-06-13 16:32:11 -0700809 if scpResult and copyResult:
810 stepResult = main.TRUE and stepResult
811 else:
812 stepResult = main.FALSE and stepResult
Jeremy Songster31aad312016-06-13 16:32:11 -0700813 utilities.assert_equals( expect=main.TRUE,
814 actual=stepResult,
815 onpass="Successfully copied remote ONOS logs",
816 onfail="Failed to copy remote ONOS logs" )
Jeremy Songster17147f22016-05-31 18:30:52 -0700817
kelvin-onlab44147802015-07-27 17:57:31 -0700818 def CASE1000( self, main ):
819 """
820 Add host intents between 2 host:
821 - Discover hosts
822 - Add host intents
823 - Check intents
824 - Verify flows
825 - Ping hosts
826 - Reroute
827 - Link down
828 - Verify flows
829 - Check topology
830 - Ping hosts
831 - Link up
832 - Verify flows
833 - Check topology
834 - Ping hosts
835 - Remove intents
836 """
837 import time
838 import json
839 import re
Jeremydd9bda62016-04-18 12:02:32 -0700840 if main.initialized == main.FALSE:
841 main.log.error( "Test components did not start correctly, skipping further tests" )
842 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700843 # Assert variables - These variable's name|format must be followed
844 # if you want to use the wrapper function
845 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -0700846 try:
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700847 assert main.RESTs
Jeremydd9bda62016-04-18 12:02:32 -0700848 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700849 main.log.error( "There is no main.RESTs, skipping test cases" )
Jeremydd9bda62016-04-18 12:02:32 -0700850 main.initialized = main.FALSE
851 main.skipCase()
852 try:
853 assert main.Mininet1
854 except AssertionError:
855 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
856 main.initialized = main.FALSE
857 main.skipCase()
858 try:
859 assert main.numSwitch
860 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700861 main.log.error( "Place the total number of switch topology in "+\
862 main.numSwitch )
Jeremydd9bda62016-04-18 12:02:32 -0700863 main.initialized = main.FALSE
864 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700865
Jeremye1ea0602016-02-08 16:35:05 -0800866 # Save leader candidates
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700867 intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
Jeremye1ea0602016-02-08 16:35:05 -0800868
kelvin-onlab44147802015-07-27 17:57:31 -0700869 main.case( "Host Intents Test - " + str( main.numCtrls ) +
Jeremyeb51cb12016-03-28 17:53:35 -0700870 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -0700871 main.caseExplanation = "This test case tests Host intents using " +\
872 str( main.numCtrls ) + " node(s) cluster;\n" +\
873 "Different type of hosts will be tested in " +\
874 "each step such as IPV4, Dual stack, VLAN " +\
Jeremyeb51cb12016-03-28 17:53:35 -0700875 "etc;\nThe test will use OF " + main.OFProtocol +\
876 " OVS running in Mininet and compile intents" +\
877 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -0700878
Jeremy2f190ca2016-01-29 15:23:57 -0800879 main.step( "IPV4: Add and test host intents between h1 and h9" )
880 main.assertReturnString = "Assertion result for IPV4 host intent with mac addresses\n"
881 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
882 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
883 testResult = main.FALSE
884 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlab44147802015-07-27 17:57:31 -0700885 name='IPV4',
Jeremy2f190ca2016-01-29 15:23:57 -0800886 onosNode='0',
887 host1=host1,
888 host2=host2 )
889
890 if installResult:
891 testResult = main.intentFunction.testHostIntent( main,
892 name='IPV4',
893 intentId = installResult,
894 onosNode='0',
895 host1=host1,
896 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700897 sw1='s5',
898 sw2='s2',
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700899 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700900
901 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800902 actual=testResult,
903 onpass=main.assertReturnString,
904 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700905
906 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800907 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
908 host1 = { "name":"h3", "id":"00:00:00:00:00:03/-1" }
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700909 host2 = { "name":"h11","id":"00:00:00:00:00:0B/-1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800910 testResult = main.FALSE
911 installResult = main.intentFunction.installHostIntent( main,
912 name='DUALSTACK1',
913 onosNode='0',
914 host1=host1,
915 host2=host2 )
916
917 if installResult:
918 testResult = main.intentFunction.testHostIntent( main,
919 name='DUALSTACK1',
920 intentId = installResult,
921 onosNode='0',
922 host1=host1,
923 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700924 sw1='s5',
925 sw2='s2',
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700926 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700927
928 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800929 actual=testResult,
930 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700931 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700932
933 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800934 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
935 host1 = { "name":"h1" }
936 host2 = { "name":"h11" }
937 testResult = main.FALSE
938 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlab44147802015-07-27 17:57:31 -0700939 name='DUALSTACK2',
Jeremy2f190ca2016-01-29 15:23:57 -0800940 onosNode='0',
941 host1=host1,
942 host2=host2 )
943
944 if installResult:
945 testResult = main.intentFunction.testHostIntent( main,
946 name='DUALSTACK2',
947 intentId = installResult,
948 onosNode='0',
949 host1=host1,
950 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700951 sw1='s5',
952 sw2='s2',
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700953 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700954
955 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800956 actual=testResult,
957 onpass=main.assertReturnString,
958 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700959
960 main.step( "1HOP: Add host intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -0800961 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
962 host1 = { "name":"h1" }
963 host2 = { "name":"h3" }
964 testResult = main.FALSE
965 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlab44147802015-07-27 17:57:31 -0700966 name='1HOP',
Jeremy2f190ca2016-01-29 15:23:57 -0800967 onosNode='0',
968 host1=host1,
969 host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700970
Jeremy2f190ca2016-01-29 15:23:57 -0800971 if installResult:
972 testResult = main.intentFunction.testHostIntent( main,
973 name='1HOP',
974 intentId = installResult,
975 onosNode='0',
976 host1=host1,
977 host2=host2,
kelvin-onlab44147802015-07-27 17:57:31 -0700978 sw1='s5',
979 sw2='s2',
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700980 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700981
982 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800983 actual=testResult,
984 onpass=main.assertReturnString,
985 onfail=main.assertReturnString )
986
987 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
988 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700989 host1 = { "name":"h4","id":"00:00:00:00:00:04/100", "vlanId":"100" }
990 host2 = { "name":"h12","id":"00:00:00:00:00:0C/100", "vlanId":"100" }
Jeremy2f190ca2016-01-29 15:23:57 -0800991 testResult = main.FALSE
992 installResult = main.intentFunction.installHostIntent( main,
993 name='VLAN1',
994 onosNode='0',
995 host1=host1,
996 host2=host2 )
997
998 if installResult:
999 testResult = main.intentFunction.testHostIntent( main,
1000 name='VLAN1',
1001 intentId = installResult,
1002 onosNode='0',
1003 host1=host1,
1004 host2=host2,
1005 sw1='s5',
1006 sw2='s2',
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001007 expectedLink=18 )
Jeremy2f190ca2016-01-29 15:23:57 -08001008
1009 utilities.assert_equals( expect=main.TRUE,
1010 actual=testResult,
1011 onpass=main.assertReturnString,
1012 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001013
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001014 # This step isn't currently possible to perform in the REST API
1015 # main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
1016 # main.assertReturnString = "Assertion Result different VLAN negative test\n"
1017 # host1 = { "name":"h13" }
1018 # host2 = { "name":"h20" }
1019 # testResult = main.FALSE
1020 # installResult = main.intentFunction.installHostIntent( main,
1021 # name='VLAN2',
1022 # onosNode='0',
1023 # host1=host1,
1024 # host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -07001025
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001026 # if installResult:
1027 # testResult = main.intentFunction.testHostIntent( main,
1028 # name='VLAN2',
1029 # intentId = installResult,
1030 # onosNode='0',
1031 # host1=host1,
1032 # host2=host2,
1033 # sw1='s5',
1034 # sw2='s2',
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001035 # expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001036
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001037 # utilities.assert_equals( expect=main.TRUE,
1038 # actual=testResult,
1039 # onpass=main.assertReturnString,
1040 # onfail=main.assertReturnString )
Jeremy2f190ca2016-01-29 15:23:57 -08001041
Jeremye1ea0602016-02-08 16:35:05 -08001042 # Change the following to use the REST API when leader checking is
1043 # supported by it
Jeremy2f190ca2016-01-29 15:23:57 -08001044
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001045 main.step( "Confirm that ONOS leadership is unchanged" )
1046 intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
Jeremye1ea0602016-02-08 16:35:05 -08001047 main.intentFunction.checkLeaderChange( intentLeadersOld,
1048 intentLeadersNew )
Jeremy2f190ca2016-01-29 15:23:57 -08001049
Jeremye1ea0602016-02-08 16:35:05 -08001050 utilities.assert_equals( expect=main.TRUE,
1051 actual=testResult,
1052 onpass="ONOS Leaders Unchanged",
1053 onfail="ONOS Leader Mismatch")
Jeremy2f190ca2016-01-29 15:23:57 -08001054
1055 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001056
1057 def CASE2000( self, main ):
1058 """
1059 Add point intents between 2 hosts:
1060 - Get device ids | ports
1061 - Add point intents
1062 - Check intents
1063 - Verify flows
1064 - Ping hosts
1065 - Reroute
1066 - Link down
1067 - Verify flows
1068 - Check topology
1069 - Ping hosts
1070 - Link up
1071 - Verify flows
1072 - Check topology
1073 - Ping hosts
1074 - Remove intents
1075 """
Jeremydd9bda62016-04-18 12:02:32 -07001076 if main.initialized == main.FALSE:
1077 main.log.error( "Test components did not start correctly, skipping further tests" )
1078 main.skipCase()
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001079 # Assert variables - These variable's name|format must be followed
1080 # if you want to use the wrapper function
kelvin-onlab44147802015-07-27 17:57:31 -07001081 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -07001082 try:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001083 assert main.RESTs
Jeremydd9bda62016-04-18 12:02:32 -07001084 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001085 main.log.error( "There is no main.RESTs, skipping test cases" )
Jeremydd9bda62016-04-18 12:02:32 -07001086 main.initialized = main.FALSE
1087 main.skipCase()
1088 try:
1089 assert main.Mininet1
1090 except AssertionError:
1091 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1092 main.initialized = main.FALSE
1093 main.skipCase()
1094 try:
1095 assert main.numSwitch
1096 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001097 main.log.error( "Place the total number of switch topology in "+\
1098 main.numSwitch )
Jeremydd9bda62016-04-18 12:02:32 -07001099 main.initialized = main.FALSE
1100 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001101
1102 main.case( "Point Intents Test - " + str( main.numCtrls ) +
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001103 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
1104 main.caseExplanation = "This test case will test point to point" + \
1105 " intents using " + str( main.numCtrls ) + \
1106 " node(s) cluster;\n" + \
1107 "Different type of hosts will be tested in " + \
1108 "each step such as IPV4, Dual stack, VLAN etc" + \
1109 ";\nThe test will use OF " + main.OFProtocol + \
1110 " OVS running in Mininet and compile intents" + \
Jeremyeb51cb12016-03-28 17:53:35 -07001111 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001112
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001113 # No option point intent
kelvin-onlab44147802015-07-27 17:57:31 -07001114 main.step( "NOOPTION: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001115 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
1116 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001117 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy2f190ca2016-01-29 15:23:57 -08001118 ]
1119 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001120 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy2f190ca2016-01-29 15:23:57 -08001121 ]
1122 testResult = main.FALSE
1123 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001124 main,
1125 name="NOOPTION",
1126 senders=senders,
1127 recipients=recipients )
Jeremy2f190ca2016-01-29 15:23:57 -08001128
1129 if installResult:
1130 testResult = main.intentFunction.testPointIntent(
1131 main,
1132 intentId=installResult,
1133 name="NOOPTION",
1134 senders=senders,
1135 recipients=recipients,
1136 sw1="s5",
1137 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001138 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001139
1140 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001141 actual=testResult,
1142 onpass=main.assertReturnString,
1143 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001144
kelvin-onlab44147802015-07-27 17:57:31 -07001145 main.step( "IPV4: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001146 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
1147 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001148 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
Jeremy2f190ca2016-01-29 15:23:57 -08001149 ]
1150 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001151 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" }
Jeremy2f190ca2016-01-29 15:23:57 -08001152 ]
1153 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001154 main,
1155 name="IPV4",
1156 senders=senders,
1157 recipients=recipients,
1158 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -08001159
1160 if installResult:
1161 testResult = main.intentFunction.testPointIntent(
1162 main,
1163 intentId=installResult,
1164 name="IPV4",
1165 senders=senders,
1166 recipients=recipients,
1167 sw1="s5",
1168 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001169 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001170
1171 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001172 actual=testResult,
1173 onpass=main.assertReturnString,
1174 onfail=main.assertReturnString )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001175
kelvin-onlab44147802015-07-27 17:57:31 -07001176 main.step( "IPV4_2: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001177 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
1178 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001179 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy2f190ca2016-01-29 15:23:57 -08001180 ]
1181 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001182 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy2f190ca2016-01-29 15:23:57 -08001183 ]
1184 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001185 main,
1186 name="IPV4_2",
1187 senders=senders,
1188 recipients=recipients,
1189 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -08001190
1191 if installResult:
1192 testResult = main.intentFunction.testPointIntent(
1193 main,
1194 intentId=installResult,
1195 name="IPV4_2",
1196 senders=senders,
1197 recipients=recipients,
1198 sw1="s5",
1199 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001200 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001201
1202 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001203 actual=testResult,
1204 onpass=main.assertReturnString,
1205 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001206
kelvin-onlab0e684682015-08-11 18:51:41 -07001207 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001208 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
1209 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001210 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01",
1211 "ip": ( main.h1.hostIp + "/24" ) }
Jeremy2f190ca2016-01-29 15:23:57 -08001212 ]
1213 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001214 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09",
1215 "ip": ( main.h9.hostIp + "/24" ) }
Jeremy2f190ca2016-01-29 15:23:57 -08001216 ]
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001217 # ipProto = main.params['SDNIP']['icmpProto']
1218 ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ]
kelvin-onlab44147802015-07-27 17:57:31 -07001219 # Uneccessary, not including this in the selectors
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001220 tcpSrc = main.params['SDNIP']['srcPort']
1221 tcpDst = main.params['SDNIP']['dstPort']
kelvin-onlab44147802015-07-27 17:57:31 -07001222
Jeremy2f190ca2016-01-29 15:23:57 -08001223 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001224 main,
1225 name="SDNIP-ICMP",
1226 senders=senders,
1227 recipients=recipients,
1228 ethType="IPV4",
1229 ipProto=ipProto,
1230 tcpSrc=tcpSrc,
1231 tcpDst=tcpDst )
Jeremy2f190ca2016-01-29 15:23:57 -08001232
1233 if installResult:
1234 testResult = main.intentFunction.testPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001235 main,
1236 intentId=installResult,
1237 name="SDNIP_ICMP",
1238 senders=senders,
1239 recipients=recipients,
1240 sw1="s5",
1241 sw2="s2",
1242 expectedLink=18,
1243 useTCP=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001244
1245 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001246 actual=testResult,
1247 onpass=main.assertReturnString,
1248 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001249
kelvin-onlab0e684682015-08-11 18:51:41 -07001250 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001251 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001252 mac1 = main.hostsData['h1']['mac']
1253 mac2 = main.hostsData['h9']['mac']
1254 ip1 = str(main.hostsData['h1']['ipAddresses'][0]) + "/32"
1255 ip2 = str(main.hostsData['h9']['ipAddresses'][0]) + "/32"
1256 ipProto = main.params['SDNIP']['tcpProto']
1257 tcp1 = main.params['SDNIP']['srcPort']
1258 tcp2 = main.params['SDNIP']['dstPort']
kelvin-onlab44147802015-07-27 17:57:31 -07001259
kelvin-onlab0e684682015-08-11 18:51:41 -07001260 stepResult = main.intentFunction.pointIntentTcp(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001261 main,
1262 name="SDNIP-TCP",
1263 host1="h1",
1264 host2="h9",
1265 deviceId1="of:0000000000000005/1",
1266 deviceId2="of:0000000000000006/1",
1267 mac1=mac1,
1268 mac2=mac2,
1269 ethType="IPV4",
1270 ipProto=ipProto,
1271 ip1=ip1,
1272 ip2=ip2,
1273 tcp1=tcp1,
1274 tcp2=tcp2 )
kelvin-onlab44147802015-07-27 17:57:31 -07001275
1276 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001277 actual=stepResult,
Jeremy2f190ca2016-01-29 15:23:57 -08001278 onpass=main.assertReturnString,
1279 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001280
Jeremy2f190ca2016-01-29 15:23:57 -08001281 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
1282 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
1283 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001284 { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
Jeremy2f190ca2016-01-29 15:23:57 -08001285 ]
1286 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001287 { "name": "h11", "device": "of:0000000000000006/3", "mac": "00:00:00:00:00:0B" }
Jeremy2f190ca2016-01-29 15:23:57 -08001288 ]
1289 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001290 main,
1291 name="DUALSTACK1",
1292 senders=senders,
1293 recipients=recipients,
1294 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -08001295
1296 if installResult:
1297 testResult = main.intentFunction.testPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001298 main,
1299 intentId=installResult,
1300 name="DUALSTACK1",
1301 senders=senders,
1302 recipients=recipients,
1303 sw1="s5",
1304 sw2="s2",
1305 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001306
1307 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001308 actual=testResult,
1309 onpass=main.assertReturnString,
1310 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001311
1312 main.step( "VLAN: Add point intents between h5 and h21" )
Jeremy2f190ca2016-01-29 15:23:57 -08001313 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
1314 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001315 { "name": "h5", "device": "of:0000000000000005/5", "mac": "00:00:00:00:00:05", "vlanId": "200" }
Jeremy2f190ca2016-01-29 15:23:57 -08001316 ]
1317 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001318 { "name": "h21", "device": "of:0000000000000007/5", "mac": "00:00:00:00:00:15", "vlanId": "200" }
Jeremy2f190ca2016-01-29 15:23:57 -08001319 ]
1320 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001321 main,
1322 name="VLAN",
1323 senders=senders,
1324 recipients=recipients )
Jeremy2f190ca2016-01-29 15:23:57 -08001325
1326 if installResult:
1327 testResult = main.intentFunction.testPointIntent(
1328 main,
1329 intentId=installResult,
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001330 name="VLAN",
Jeremy2f190ca2016-01-29 15:23:57 -08001331 senders=senders,
1332 recipients=recipients,
1333 sw1="s5",
1334 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001335 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001336
1337 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001338 actual=testResult,
1339 onpass=main.assertReturnString,
1340 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001341
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001342 # TODO: implement VLAN selector REST API intent test once supported
1343
kelvin-onlab44147802015-07-27 17:57:31 -07001344 main.step( "1HOP: Add point intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -08001345 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
1346 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001347 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
Jeremy2f190ca2016-01-29 15:23:57 -08001348 ]
1349 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001350 { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
Jeremy2f190ca2016-01-29 15:23:57 -08001351 ]
1352 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001353 main,
1354 name="1HOP IPV4",
1355 senders=senders,
1356 recipients=recipients,
1357 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -08001358
1359 if installResult:
1360 testResult = main.intentFunction.testPointIntent(
1361 main,
1362 intentId=installResult,
1363 name="1HOP IPV4",
1364 senders=senders,
1365 recipients=recipients,
1366 sw1="s5",
1367 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001368 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001369
1370 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001371 actual=testResult,
1372 onpass=main.assertReturnString,
1373 onfail=main.assertReturnString )
1374
1375 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001376
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001377
kelvin-onlab44147802015-07-27 17:57:31 -07001378 def CASE3000( self, main ):
1379 """
1380 Add single point to multi point intents
1381 - Get device ids
1382 - Add single point to multi point intents
1383 - Check intents
1384 - Verify flows
1385 - Ping hosts
1386 - Reroute
1387 - Link down
1388 - Verify flows
1389 - Check topology
1390 - Ping hosts
1391 - Link up
1392 - Verify flows
1393 - Check topology
1394 - Ping hosts
1395 - Remove intents
1396 """
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001397 if main.initialized == main.FALSE:
1398 main.log.error( "Test components did not start correctly, skipping further tests" )
1399 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001400 assert main, "There is no main"
kelvin-onlab44147802015-07-27 17:57:31 -07001401
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001402 try:
1403 assert main.CLIs, "There is no main.CLIs, skipping test cases"
1404 assert main.Mininet1, "Mininet handle should be named Mininet1, skipping test cases"
1405 assert main.numSwitch, "Place the total number of switch topology in main.numSwitch"
1406 except AssertionError:
1407 main.initialized = main.FALSE
1408 main.skipCase()
1409
1410 main.testName = "Single to Multi Point Intents"
1411 main.case( main.testName + " Test - " + str( main.numCtrls ) +
1412 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
1413 main.caseExplanation = "This test case will test single point to" + \
1414 " multi point intents using " + \
1415 str( main.numCtrls ) + " node(s) cluster;\n" + \
1416 "Different type of hosts will be tested in " + \
1417 "each step such as IPV4, Dual stack, VLAN etc" + \
1418 ";\nThe test will use OF " + main.OFProtocol + \
1419 " OVS running in Mininet and compile intents" + \
Jeremyeb51cb12016-03-28 17:53:35 -07001420 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001421
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001422 main.step( "NOOPTION: Install and test single point to multi point intents" )
1423 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
1424 senders = [
1425 { "name": "h8", "device": "of:0000000000000005/8" }
1426 ]
1427 recipients = [
1428 { "name": "h16", "device": "of:0000000000000006/8" },
1429 { "name": "h24", "device": "of:0000000000000007/8" }
1430 ]
1431 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1432 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
1433 testResult = main.FALSE
1434 installResult = main.intentFunction.installSingleToMultiIntent(
1435 main,
1436 name="NOOPTION",
1437 senders=senders,
1438 recipients=recipients )
1439
1440 if installResult:
1441 testResult = main.intentFunction.testPointIntent(
1442 main,
1443 intentId=installResult,
1444 name="NOOPTION",
1445 senders=senders,
1446 recipients=recipients,
1447 badSenders=badSenders,
1448 badRecipients=badRecipients,
1449 sw1="s5",
1450 sw2="s2",
1451 expectedLink=18 )
1452 else:
1453 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001454
1455 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001456 actual=testResult,
1457 onpass=main.assertReturnString,
1458 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001459
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001460 main.step("IPV4: Install and test single point to multi point intents")
1461 main.assertReturnString = "Assertion results for IPV4 single to multi point intent " \
1462 "with IPV4 type and MAC addresses\n"
1463 senders = [
1464 {"name": "h8", "device": "of:0000000000000005/8", "mac": "00:00:00:00:00:08"}
1465 ]
1466 recipients = [
1467 {"name": "h16", "device": "of:0000000000000006/8", "mac": "00:00:00:00:00:10"},
1468 {"name": "h24", "device": "of:0000000000000007/8", "mac": "00:00:00:00:00:18"}
1469 ]
1470 badSenders = [{"name": "h9"}] # Senders that are not in the intent
1471 badRecipients = [{"name": "h17"}] # Recipients that are not in the intent
1472 installResult = main.intentFunction.installSingleToMultiIntent(
1473 main,
1474 name="IPV4",
1475 senders=senders,
1476 recipients=recipients,
1477 ethType="IPV4")
1478
1479 if installResult:
1480 testResult = main.intentFunction.testPointIntent(
1481 main,
1482 intentId=installResult,
1483 name="IPV4",
1484 senders=senders,
1485 recipients=recipients,
1486 badSenders=badSenders,
1487 badRecipients=badRecipients,
1488 sw1="s5",
1489 sw2="s2",
1490 expectedLink=18 )
1491 else:
1492 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001493
1494 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001495 actual=testResult,
1496 onpass=main.assertReturnString,
1497 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001498
1499 main.step( "IPV4_2: Add single point to multi point intents" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001500 main.assertReturnString = "Assertion results for IPV4 single to multi point intent " \
1501 "with IPV4 type and no MAC addresses\n"
1502 senders = [
1503 { "name": "h8", "device": "of:0000000000000005/8" }
1504 ]
1505 recipients = [
1506 { "name": "h16", "device": "of:0000000000000006/8" },
1507 { "name": "h24", "device": "of:0000000000000007/8" }
1508 ]
1509 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1510 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
1511 installResult = main.intentFunction.installSingleToMultiIntent(
1512 main,
1513 name="IPV4_2",
1514 senders=senders,
1515 recipients=recipients,
1516 ethType="IPV4" )
1517
1518 if installResult:
1519 testResult = main.intentFunction.testPointIntent(
1520 main,
1521 intentId=installResult,
1522 name="IPV4_2",
1523 senders=senders,
1524 recipients=recipients,
1525 badSenders=badSenders,
1526 badRecipients=badRecipients,
1527 sw1="s5",
1528 sw2="s2",
1529 expectedLink=18 )
1530 else:
1531 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001532
1533 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001534 actual=testResult,
1535 onpass=main.assertReturnString,
1536 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001537
1538 main.step( "VLAN: Add single point to multi point intents" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001539 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type " \
1540 "and MAC addresses in the same VLAN\n"
1541 senders = [
1542 { "name": "h4", "device": "of:0000000000000005/4", "mac": "00:00:00:00:00:04", "vlan": "100" }
1543 ]
1544 recipients = [
1545 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1546 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
1547 ]
1548 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1549 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
1550 installResult = main.intentFunction.installSingleToMultiIntent(
1551 main,
1552 name="VLAN",
1553 senders=senders,
1554 recipients=recipients,
1555 sw1="s5",
1556 sw2="s2" )
1557
1558 if installResult:
1559 testResult = main.intentFunction.testPointIntent(
1560 main,
1561 intentId=installResult,
1562 name="VLAN",
1563 senders=senders,
1564 recipients=recipients,
1565 badSenders=badSenders,
1566 badRecipients=badRecipients,
1567 sw1="s5",
1568 sw2="s2",
1569 expectedLink=18 )
1570 else:
1571 main.CLIs[ 0 ].removeAllIntents()
kelvin-onlab44147802015-07-27 17:57:31 -07001572
1573 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001574 actual=testResult,
1575 onpass=main.assertReturnString,
1576 onfail=main.assertReturnString )
1577
1578 main.step( "VLAN: Add single point to multi point intents" )
1579 main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n"
1580 senders = [
1581 { "name": "h5", "vlan": "200" }
1582 ]
1583 recipients = [
1584 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1585 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
1586 ]
1587 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1588 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
1589 testResult = main.FALSE
1590 installResult = main.intentFunction.installSingleToMultiIntent(
1591 main,
1592 name="VLAN2",
1593 senders=senders,
1594 recipients=recipients,
1595 sw1="s5",
1596 sw2="s2" )
1597 #setVlan=100 )
1598
1599 if installResult:
1600 testResult = main.intentFunction.testPointIntent(
1601 main,
1602 intentId=installResult,
1603 name="VLAN2",
1604 senders=senders,
1605 recipients=recipients,
1606 badSenders=badSenders,
1607 badRecipients=badRecipients,
1608 sw1="s5",
1609 sw2="s2",
1610 expectedLink=18 )
1611 else:
1612 main.CLIs[ 0 ].removeAllIntents()
1613
1614 utilities.assert_equals( expect=main.TRUE,
1615 actual=testResult,
1616 onpass=main.assertReturnString,
1617 onfail=main.assertReturnString )
1618
1619 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001620
1621 def CASE4000( self, main ):
1622 """
1623 Add multi point to single point intents
1624 - Get device ids
1625 - Add multi point to single point intents
1626 - Check intents
1627 - Verify flows
1628 - Ping hosts
1629 - Reroute
1630 - Link down
1631 - Verify flows
1632 - Check topology
1633 - Ping hosts
1634 - Link up
1635 - Verify flows
1636 - Check topology
1637 - Ping hosts
1638 - Remove intents
1639 """
1640 assert main, "There is no main"
1641 assert main.CLIs, "There is no main.CLIs"
1642 assert main.Mininet1, "Mininet handle should be named Mininet1"
1643 assert main.numSwitch, "Placed the total number of switch topology in \
1644 main.numSwitch"
1645
1646 main.case( "Multi To Single Point Intents Test - " +
Jeremyeb51cb12016-03-28 17:53:35 -07001647 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -07001648 main.caseExplanation = "This test case will test single point to" +\
1649 " multi point intents using " +\
1650 str( main.numCtrls ) + " node(s) cluster;\n" +\
1651 "Different type of hosts will be tested in " +\
1652 "each step such as IPV4, Dual stack, VLAN etc" +\
1653 ";\nThe test will use OF " + main.OFProtocol +\
Jeremyeb51cb12016-03-28 17:53:35 -07001654 " OVS running in Mininet and compile intents" +\
1655 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001656
1657 main.step( "NOOPTION: Add multi point to single point intents" )
1658 stepResult = main.TRUE
1659 hostNames = [ 'h8', 'h16', 'h24' ]
1660 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
1661 'of:0000000000000007/8' ]
1662 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
1663 stepResult = main.intentFunction.multiToSingleIntent(
1664 main,
1665 name="NOOPTION",
1666 hostNames=hostNames,
1667 devices=devices,
1668 sw1="s5",
1669 sw2="s2",
1670 expectedLink=18 )
1671
1672 utilities.assert_equals( expect=main.TRUE,
1673 actual=stepResult,
1674 onpass="NOOPTION: Successfully added multi "
1675 + " point to single point intents" +
1676 " with no match action",
1677 onfail="NOOPTION: Failed to add multi point" +
1678 " to single point intents" +
1679 " with no match action" )
1680
1681 main.step( "IPV4: Add multi point to single point intents" )
1682 stepResult = main.TRUE
1683 stepResult = main.intentFunction.multiToSingleIntent(
1684 main,
1685 name="IPV4",
1686 hostNames=hostNames,
1687 devices=devices,
1688 ports=None,
1689 ethType="IPV4",
1690 macs=macs,
1691 bandwidth="",
1692 lambdaAlloc=False,
1693 ipProto="",
1694 ipAddresses="",
1695 tcp="",
1696 sw1="s5",
1697 sw2="s2",
1698 expectedLink=18 )
1699
1700 utilities.assert_equals( expect=main.TRUE,
1701 actual=stepResult,
1702 onpass="IPV4: Successfully added multi point"
1703 + " to single point intents" +
1704 " with IPV4 type and MAC addresses",
1705 onfail="IPV4: Failed to add multi point" +
1706 " to single point intents" +
1707 " with IPV4 type and MAC addresses" )
1708
1709 main.step( "IPV4_2: Add multi point to single point intents" )
1710 stepResult = main.TRUE
1711 hostNames = [ 'h8', 'h16', 'h24' ]
1712 stepResult = main.intentFunction.multiToSingleIntent(
1713 main,
1714 name="IPV4",
1715 hostNames=hostNames,
1716 ethType="IPV4",
1717 lambdaAlloc=False )
1718
1719 utilities.assert_equals( expect=main.TRUE,
1720 actual=stepResult,
1721 onpass="IPV4_2: Successfully added multi point"
1722 + " to single point intents" +
1723 " with IPV4 type and no MAC addresses",
1724 onfail="IPV4_2: Failed to add multi point" +
1725 " to single point intents" +
1726 " with IPV4 type and no MAC addresses" )
1727
1728 main.step( "VLAN: Add multi point to single point intents" )
1729 stepResult = main.TRUE
1730 hostNames = [ 'h5', 'h13', 'h21' ]
1731 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \
1732 'of:0000000000000007/5' ]
1733 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
1734 stepResult = main.intentFunction.multiToSingleIntent(
1735 main,
1736 name="VLAN",
1737 hostNames=hostNames,
1738 devices=devices,
1739 ports=None,
1740 ethType="IPV4",
1741 macs=macs,
1742 bandwidth="",
1743 lambdaAlloc=False,
1744 ipProto="",
1745 ipAddresses="",
1746 tcp="",
1747 sw1="s5",
1748 sw2="s2",
1749 expectedLink=18 )
1750
1751 utilities.assert_equals( expect=main.TRUE,
1752 actual=stepResult,
1753 onpass="VLAN: Successfully added multi point"
1754 + " to single point intents" +
1755 " with IPV4 type and MAC addresses" +
1756 " in the same VLAN",
1757 onfail="VLAN: Failed to add multi point" +
1758 " to single point intents" )
1759
1760 def CASE5000( self, main ):
1761 """
Jeremy2f190ca2016-01-29 15:23:57 -08001762 Tests Host Mobility
1763 Modifies the topology location of h1
kelvin-onlab44147802015-07-27 17:57:31 -07001764 """
Jeremydd9bda62016-04-18 12:02:32 -07001765 if main.initialized == main.FALSE:
1766 main.log.error( "Test components did not start correctly, skipping further tests" )
1767 main.skipCase()
1768 # Assert variables - These variable's name|format must be followed
1769 # if you want to use the wrapper function
kelvin-onlab44147802015-07-27 17:57:31 -07001770 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -07001771 try:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001772 assert main.RESTs
Jeremydd9bda62016-04-18 12:02:32 -07001773 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001774 main.log.error( "There is no main.RESTs, skipping test cases" )
Jeremydd9bda62016-04-18 12:02:32 -07001775 main.initialized = main.FALSE
1776 main.skipCase()
1777 try:
1778 assert main.Mininet1
1779 except AssertionError:
1780 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1781 main.initialized = main.FALSE
1782 main.skipCase()
1783 try:
1784 assert main.numSwitch
1785 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001786 main.log.error( "Place the total number of switch topology in " +\
1787 main.numSwitch )
Jeremydd9bda62016-04-18 12:02:32 -07001788 main.initialized = main.FALSE
1789 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001790 main.case( "Test host mobility with host intents " )
Jeremy2f190ca2016-01-29 15:23:57 -08001791 main.step( "Testing host mobility by moving h1 from s5 to s6" )
kelvin-onlab44147802015-07-27 17:57:31 -07001792 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1793
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001794 main.log.info( "Moving h1 from s5 to s6" )
1795 main.Mininet1.moveHost( "h1", "s5", "s6" )
kelvin-onlab44147802015-07-27 17:57:31 -07001796
Jeremy2f190ca2016-01-29 15:23:57 -08001797 # Send discovery ping from moved host
1798 # Moving the host brings down the default interfaces and creates a new one.
1799 # Scapy is restarted on this host to detect the new interface
1800 main.h1.stopScapy()
1801 main.h1.startScapy()
1802
1803 # Discover new host location in ONOS and populate host data.
1804 # Host 1 IP and MAC should be unchanged
1805 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
1806 main.intentFunction.populateHostData( main )
1807
kelvin-onlab44147802015-07-27 17:57:31 -07001808 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1809
1810 utilities.assert_equals( expect="of:0000000000000006",
1811 actual=h1PostMove,
1812 onpass="Mobility: Successfully moved h1 to s6",
Jeremy2f190ca2016-01-29 15:23:57 -08001813 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlab44147802015-07-27 17:57:31 -07001814 " to single point intents" +
1815 " with IPV4 type and MAC addresses" +
1816 " in the same VLAN" )
1817
1818 main.step( "IPV4: Add host intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001819 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
1820 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
1821 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
1822
1823 installResult = main.intentFunction.installHostIntent( main,
1824 name='IPV4 Mobility IPV4',
kelvin-onlab44147802015-07-27 17:57:31 -07001825 onosNode='0',
Jeremy2f190ca2016-01-29 15:23:57 -08001826 host1=host1,
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001827 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -08001828 if installResult:
1829 testResult = main.intentFunction.testHostIntent( main,
1830 name='Host Mobility IPV4',
1831 intentId = installResult,
1832 onosNode='0',
1833 host1=host1,
1834 host2=host2,
1835 sw1="s6",
1836 sw2="s2",
1837 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001838
1839 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001840 actual=testResult,
1841 onpass=main.assertReturnString,
1842 onfail=main.assertReturnString )
1843
Jon Hallbd60ea02016-08-23 10:03:59 -07001844 main.intentFunction.report( main )