blob: 4dab42caedcbd7ebc44db9e88dfec05d5036ecb6 [file] [log] [blame]
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001# Testing the basic intent functionality of ONOS
2
kelvin-onlabd48a68c2015-07-13 16:01:36 -07003class FUNCintent:
4
5 def __init__( self ):
6 self.default = ''
7
8 def CASE1( self, main ):
9 import time
kelvin-onlabd48a68c2015-07-13 16:01:36 -070010 import imp
Jon Hallf632d202015-07-30 15:45:11 -070011 import re
kelvin-onlabd48a68c2015-07-13 16:01:36 -070012
13 """
14 - Construct tests variables
15 - GIT ( optional )
16 - Checkout ONOS master branch
17 - Pull latest ONOS code
18 - Building ONOS ( optional )
19 - Install ONOS package
20 - Build ONOS package
21 """
22
23 main.case( "Constructing test variables and building ONOS package" )
24 main.step( "Constructing test variables" )
Jon Hall783bbf92015-07-23 14:33:19 -070025 main.caseExplanation = "This test case is mainly for loading " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -070026 "from params file, and pull and build the " +\
27 " latest ONOS package"
kelvin-onlabd48a68c2015-07-13 16:01:36 -070028 stepResult = main.FALSE
29
30 # Test variables
Jon Halla3e02432015-07-24 15:55:42 -070031 try:
Jon Hallf632d202015-07-30 15:45:11 -070032 main.testOnDirectory = re.sub( "(/tests)$", "", main.testDir )
Jon Halla3e02432015-07-24 15:55:42 -070033 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
34 gitBranch = main.params[ 'GIT' ][ 'branch' ]
35 main.dependencyPath = main.testOnDirectory + \
36 main.params[ 'DEPENDENCY' ][ 'path' ]
37 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
38 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
39 if main.ONOSbench.maxNodes:
40 main.maxNodes = int( main.ONOSbench.maxNodes )
41 else:
42 main.maxNodes = 0
43 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
44 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
45 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
46 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
47 main.checkIntentSleep = int( main.params[ 'SLEEP' ][ 'checkintent' ] )
acsmarscfa52272015-08-06 15:21:45 -070048 main.removeIntentSleep = int( main.params[ 'SLEEP' ][ 'removeintent' ] )
Jon Halla3e02432015-07-24 15:55:42 -070049 main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] )
50 main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
acsmars59a4c552015-09-10 18:11:19 -070051 main.checkTopoAttempts = int( main.params[ 'SLEEP' ][ 'topoAttempts' ] )
Jon Halla3e02432015-07-24 15:55:42 -070052 gitPull = main.params[ 'GIT' ][ 'pull' ]
53 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
54 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
55 main.cellData = {} # for creating cell file
56 main.hostsData = {}
57 main.CLIs = []
58 main.ONOSip = []
kelvin-onlabd48a68c2015-07-13 16:01:36 -070059
Jon Halla3e02432015-07-24 15:55:42 -070060 main.ONOSip = main.ONOSbench.getOnosIps()
61 print main.ONOSip
kelvin-onlabd48a68c2015-07-13 16:01:36 -070062
Jon Halla3e02432015-07-24 15:55:42 -070063 # Assigning ONOS cli handles to a list
64 for i in range( 1, main.maxNodes + 1 ):
65 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070066
Jon Halla3e02432015-07-24 15:55:42 -070067 # -- INIT SECTION, ONLY RUNS ONCE -- #
68 main.startUp = imp.load_source( wrapperFile1,
69 main.dependencyPath +
70 wrapperFile1 +
71 ".py" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070072
Jon Halla3e02432015-07-24 15:55:42 -070073 main.intentFunction = imp.load_source( wrapperFile2,
74 main.dependencyPath +
75 wrapperFile2 +
76 ".py" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070077
Jon Halla3e02432015-07-24 15:55:42 -070078 main.topo = imp.load_source( wrapperFile3,
79 main.dependencyPath +
80 wrapperFile3 +
81 ".py" )
82
kelvin-onlabd9e23de2015-08-06 10:34:44 -070083 copyResult1 = main.ONOSbench.scp( main.Mininet1,
84 main.dependencyPath +
85 main.topology,
86 main.Mininet1.home,
87 direction="to" )
Jon Halla3e02432015-07-24 15:55:42 -070088 if main.CLIs:
89 stepResult = main.TRUE
90 else:
91 main.log.error( "Did not properly created list of ONOS CLI handle" )
92 stepResult = main.FALSE
93 except Exception as e:
94 main.log.exception(e)
95 main.cleanup()
96 main.exit()
kelvin-onlabd48a68c2015-07-13 16:01:36 -070097
98 utilities.assert_equals( expect=main.TRUE,
99 actual=stepResult,
100 onpass="Successfully construct " +
101 "test variables ",
102 onfail="Failed to construct test variables" )
103
104 if gitPull == 'True':
105 main.step( "Building ONOS in " + gitBranch + " branch" )
106 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
107 stepResult = onosBuildResult
108 utilities.assert_equals( expect=main.TRUE,
109 actual=stepResult,
110 onpass="Successfully compiled " +
111 "latest ONOS",
112 onfail="Failed to compile " +
113 "latest ONOS" )
114 else:
115 main.log.warn( "Did not pull new code so skipping mvn " +
116 "clean install" )
Jon Hall106be082015-07-22 09:53:00 -0700117 main.ONOSbench.getVersion( report=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700118
119 def CASE2( self, main ):
120 """
121 - Set up cell
122 - Create cell file
123 - Set cell file
124 - Verify cell file
125 - Kill ONOS process
126 - Uninstall ONOS cluster
127 - Verify ONOS start up
128 - Install ONOS cluster
129 - Connect to cli
130 """
131
132 # main.scale[ 0 ] determines the current number of ONOS controller
133 main.numCtrls = int( main.scale[ 0 ] )
134
135 main.case( "Starting up " + str( main.numCtrls ) +
136 " node(s) ONOS cluster" )
Jon Hall783bbf92015-07-23 14:33:19 -0700137 main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700138 " node(s) ONOS cluster"
139
140
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700141
142 #kill off all onos processes
143 main.log.info( "Safety check, killing all ONOS processes" +
144 " before initiating enviornment setup" )
145
146 for i in range( main.maxNodes ):
147 main.ONOSbench.onosDie( main.ONOSip[ i ] )
148
149 print "NODE COUNT = ", main.numCtrls
150
151 tempOnosIp = []
152 for i in range( main.numCtrls ):
153 tempOnosIp.append( main.ONOSip[i] )
154
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700155 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
156 "temp", main.Mininet1.ip_address,
157 main.apps, tempOnosIp )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700158
159 main.step( "Apply cell to environment" )
160 cellResult = main.ONOSbench.setCell( "temp" )
161 verifyResult = main.ONOSbench.verifyCell()
162 stepResult = cellResult and verifyResult
163 utilities.assert_equals( expect=main.TRUE,
164 actual=stepResult,
165 onpass="Successfully applied cell to " + \
166 "environment",
167 onfail="Failed to apply cell to environment " )
168
169 main.step( "Creating ONOS package" )
170 packageResult = main.ONOSbench.onosPackage()
171 stepResult = packageResult
172 utilities.assert_equals( expect=main.TRUE,
173 actual=stepResult,
174 onpass="Successfully created ONOS package",
175 onfail="Failed to create ONOS package" )
176
177 time.sleep( main.startUpSleep )
178 main.step( "Uninstalling ONOS package" )
179 onosUninstallResult = main.TRUE
kelvin-onlab5f0d19e2015-08-04 15:21:00 -0700180 for ip in main.ONOSip:
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700181 onosUninstallResult = onosUninstallResult and \
kelvin-onlab5f0d19e2015-08-04 15:21:00 -0700182 main.ONOSbench.onosUninstall( nodeIp=ip )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700183 stepResult = onosUninstallResult
184 utilities.assert_equals( expect=main.TRUE,
185 actual=stepResult,
186 onpass="Successfully uninstalled ONOS package",
187 onfail="Failed to uninstall ONOS package" )
188
189 time.sleep( main.startUpSleep )
190 main.step( "Installing ONOS package" )
191 onosInstallResult = main.TRUE
192 for i in range( main.numCtrls ):
193 onosInstallResult = onosInstallResult and \
194 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
195 stepResult = onosInstallResult
196 utilities.assert_equals( expect=main.TRUE,
197 actual=stepResult,
198 onpass="Successfully installed ONOS package",
199 onfail="Failed to install ONOS package" )
200
201 time.sleep( main.startUpSleep )
202 main.step( "Starting ONOS service" )
203 stopResult = main.TRUE
204 startResult = main.TRUE
205 onosIsUp = main.TRUE
206
207 for i in range( main.numCtrls ):
208 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
209 if onosIsUp == main.TRUE:
210 main.log.report( "ONOS instance is up and ready" )
211 else:
212 main.log.report( "ONOS instance may not be up, stop and " +
213 "start ONOS again " )
acsmars2ec91d62015-09-16 11:15:48 -0700214
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700215 for i in range( main.numCtrls ):
216 stopResult = stopResult and \
217 main.ONOSbench.onosStop( main.ONOSip[ i ] )
218 for i in range( main.numCtrls ):
219 startResult = startResult and \
220 main.ONOSbench.onosStart( main.ONOSip[ i ] )
221 stepResult = onosIsUp and stopResult and startResult
222 utilities.assert_equals( expect=main.TRUE,
223 actual=stepResult,
224 onpass="ONOS service is ready",
225 onfail="ONOS service did not start properly" )
226
227 main.step( "Start ONOS cli" )
228 cliResult = main.TRUE
229 for i in range( main.numCtrls ):
230 cliResult = cliResult and \
231 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
232 stepResult = cliResult
233 utilities.assert_equals( expect=main.TRUE,
234 actual=stepResult,
235 onpass="Successfully start ONOS cli",
236 onfail="Failed to start ONOS cli" )
237
238 # Remove the first element in main.scale list
239 main.scale.remove( main.scale[ 0 ] )
240
kelvin-onlab016dce22015-08-10 09:54:11 -0700241 main.intentFunction.report( main )
242
Jon Halla3e02432015-07-24 15:55:42 -0700243 def CASE8( self, main ):
244 """
acsmars59a4c552015-09-10 18:11:19 -0700245 Compare ONOS Topology to Mininet Topology
Jon Halla3e02432015-07-24 15:55:42 -0700246 """
247 import json
248
249 main.case( "Compare ONOS Topology view to Mininet topology" )
250 main.caseExplanation = "Compare topology elements between Mininet" +\
251 " and ONOS"
252
acsmars59a4c552015-09-10 18:11:19 -0700253 main.log.info( "Gathering topology information from Mininet" )
254 devicesResults = main.FALSE # Overall Boolean for device correctness
255 linksResults = main.FALSE # Overall Boolean for link correctness
256 hostsResults = main.FALSE # Overall Boolean for host correctness
257 deviceFails = [] # Nodes where devices are incorrect
258 linkFails = [] # Nodes where links are incorrect
259 hostFails = [] # Nodes where hosts are incorrect
260 attempts = main.checkTopoAttempts # Remaining Attempts
Jon Halla3e02432015-07-24 15:55:42 -0700261
262 mnSwitches = main.Mininet1.getSwitches()
263 mnLinks = main.Mininet1.getLinks()
264 mnHosts = main.Mininet1.getHosts()
265
acsmars59a4c552015-09-10 18:11:19 -0700266 main.step( "Conmparing Mininet topology to ONOS topology" )
Jon Halla3e02432015-07-24 15:55:42 -0700267
acsmars59a4c552015-09-10 18:11:19 -0700268 while ( attempts >= 0 ) and\
269 ( not devicesResults or not linksResults or not hostsResults ):
270 time.sleep( 2 )
271 if not devicesResults:
272 devices = main.topo.getAllDevices( main )
273 ports = main.topo.getAllPorts( main )
274 devicesResults = main.TRUE
275 deviceFails = [] # Reset for each attempt
276 if not linksResults:
277 links = main.topo.getAllLinks( main )
278 linksResults = main.TRUE
279 linkFails = [] # Reset for each attempt
280 if not hostsResults:
281 hosts = main.topo.getAllHosts( main )
282 hostsResults = main.TRUE
283 hostFails = [] # Reset for each attempt
Jon Halla3e02432015-07-24 15:55:42 -0700284
acsmars59a4c552015-09-10 18:11:19 -0700285 # Check for matching topology on each node
286 for controller in range( main.numCtrls ):
287 controllerStr = str( controller + 1 ) # ONOS node number
288 # Compare Devices
289 if devices[ controller ] and ports[ controller ] and\
290 "Error" not in devices[ controller ] and\
291 "Error" not in ports[ controller ]:
Jon Halla3e02432015-07-24 15:55:42 -0700292
acsmars2ec91d62015-09-16 11:15:48 -0700293 try:
294 deviceData = json.loads( devices[ controller ] )
295 portData = json.loads( ports[ controller ] )
296 except (TypeError,ValueError):
297 main.log.error("Could not load json:" + str( devices[ controller ] ) + ' or ' + str( ports[ controller ] ))
298 currentDevicesResult = main.FALSE
299 else:
300 currentDevicesResult = main.Mininet1.compareSwitches(
301 mnSwitches,deviceData,portData )
acsmars59a4c552015-09-10 18:11:19 -0700302 else:
303 currentDevicesResult = main.FALSE
304 if not currentDevicesResult:
305 deviceFails.append( controllerStr )
306 devicesResults = devicesResults and currentDevicesResult
307 # Compare Links
308 if links[ controller ] and "Error" not in links[ controller ]:
acsmars2ec91d62015-09-16 11:15:48 -0700309 try:
310 linkData = json.loads( links[ controller ] )
311 except (TypeError,ValueError):
312 main.log.error("Could not load json:" + str( links[ controller ] ) )
313 currentLinksResult = main.FALSE
314 else:
315 currentLinksResult = main.Mininet1.compareLinks(
316 mnSwitches, mnLinks,linkData )
acsmars59a4c552015-09-10 18:11:19 -0700317 else:
318 currentLinksResult = main.FALSE
319 if not currentLinksResult:
320 linkFails.append( controllerStr )
321 linksResults = linksResults and currentLinksResult
322 # Compare Hosts
acsmars2ec91d62015-09-16 11:15:48 -0700323 if hosts[ controller ] and "Error" not in hosts[ controller ]:
324 try:
325 hostData = json.loads( hosts[ controller ] )
326 except (TypeError,ValueError):
327 main.log.error("Could not load json:" + str( hosts[ controller ] ) )
328 currentHostsResult = main.FALSE
329 else:
330 currentHostsResult = main.Mininet1.compareHosts(
331 mnHosts,hostData )
acsmars59a4c552015-09-10 18:11:19 -0700332 else:
333 currentHostsResult = main.FALSE
334 if not currentHostsResult:
335 hostFails.append( controllerStr )
336 hostsResults = hostsResults and currentHostsResult
337 # Decrement Attempts Remaining
338 attempts -= 1
339
340
341 utilities.assert_equals( expect=[],
342 actual=deviceFails,
343 onpass="ONOS correctly discovered all devices",
344 onfail="ONOS incorrectly discovered devices on nodes: " +
345 str( deviceFails ) )
346 utilities.assert_equals( expect=[],
347 actual=linkFails,
348 onpass="ONOS correctly discovered all links",
349 onfail="ONOS incorrectly discovered links on nodes: " +
350 str( linkFails ) )
351 utilities.assert_equals( expect=[],
352 actual=hostFails,
353 onpass="ONOS correctly discovered all hosts",
354 onfail="ONOS incorrectly discovered hosts on nodes: " +
355 str( hostFails ) )
Jon Hall46d48252015-08-03 11:41:16 -0700356 topoResults = hostsResults and linksResults and devicesResults
357 utilities.assert_equals( expect=main.TRUE,
358 actual=topoResults,
359 onpass="ONOS correctly discovered the topology",
360 onfail="ONOS incorrectly discovered the topology" )
Jon Halla3e02432015-07-24 15:55:42 -0700361
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700362 def CASE10( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700363 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700364 Start Mininet topology with OF 1.0 switches
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700365 """
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700366 main.OFProtocol = "1.0"
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700367 main.log.report( "Start Mininet topology with OF 1.0 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700368 main.case( "Start Mininet topology with OF 1.0 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700369 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700370 "switches to test intents, exits out if " +\
371 "topology did not start correctly"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700372
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700373 main.step( "Starting Mininet topology with OF 1.0 switches" )
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700374 args = "--switch ovs,protocols=OpenFlow10"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700375 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700376 main.topology,
377 args=args )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700378 stepResult = topoResult
379 utilities.assert_equals( expect=main.TRUE,
380 actual=stepResult,
381 onpass="Successfully loaded topology",
382 onfail="Failed to load topology" )
383 # Exit if topology did not load properly
384 if not topoResult:
385 main.cleanup()
386 main.exit()
387
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700388 def CASE11( self, main ):
389 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700390 Start Mininet topology with OF 1.3 switches
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700391 """
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700392 main.OFProtocol = "1.3"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700393 main.log.report( "Start Mininet topology with OF 1.3 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700394 main.case( "Start Mininet topology with OF 1.3 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700395 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700396 "switches to test intents, exits out if " +\
397 "topology did not start correctly"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700398
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700399 main.step( "Starting Mininet topology with OF 1.3 switches" )
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700400 args = "--switch ovs,protocols=OpenFlow13"
401 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
402 main.topology,
403 args=args )
404 stepResult = topoResult
405 utilities.assert_equals( expect=main.TRUE,
406 actual=stepResult,
407 onpass="Successfully loaded topology",
408 onfail="Failed to load topology" )
409 # Exit if topology did not load properly
410 if not topoResult:
411 main.cleanup()
412 main.exit()
413
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700414 def CASE12( self, main ):
415 """
416 Assign mastership to controllers
417 """
418 import re
419
420 main.case( "Assign switches to controllers" )
421 main.step( "Assigning switches to controllers" )
Jon Hall783bbf92015-07-23 14:33:19 -0700422 main.caseExplanation = "Assign OF " + main.OFProtocol +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700423 " switches to ONOS nodes"
424
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700425 assignResult = main.TRUE
426 switchList = []
427
428 # Creates a list switch name, use getSwitch() function later...
429 for i in range( 1, ( main.numSwitch + 1 ) ):
430 switchList.append( 's' + str( i ) )
431
432 tempONOSip = []
433 for i in range( main.numCtrls ):
434 tempONOSip.append( main.ONOSip[ i ] )
435
436 assignResult = main.Mininet1.assignSwController( sw=switchList,
437 ip=tempONOSip,
Charles Chan029be652015-08-24 01:46:10 +0800438 port='6653' )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700439 if not assignResult:
440 main.cleanup()
441 main.exit()
442
443 for i in range( 1, ( main.numSwitch + 1 ) ):
444 response = main.Mininet1.getSwController( "s" + str( i ) )
445 print( "Response is " + str( response ) )
446 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
447 assignResult = assignResult and main.TRUE
448 else:
449 assignResult = main.FALSE
450 stepResult = assignResult
451 utilities.assert_equals( expect=main.TRUE,
452 actual=stepResult,
453 onpass="Successfully assigned switches" +
454 "to controller",
455 onfail="Failed to assign switches to " +
456 "controller" )
457 def CASE13( self, main ):
458 """
459 Discover all hosts and store its data to a dictionary
460 """
461 main.case( "Discover all hosts" )
462
463 stepResult = main.TRUE
464 main.step( "Discover all hosts using pingall " )
465 stepResult = main.intentFunction.getHostsData( main )
466 utilities.assert_equals( expect=main.TRUE,
467 actual=stepResult,
468 onpass="Successfully discovered hosts",
469 onfail="Failed to discover hosts" )
470
471 def CASE14( self, main ):
472 """
473 Stop mininet
474 """
475 main.log.report( "Stop Mininet topology" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700476 main.case( "Stop Mininet topology" )
Jon Hall783bbf92015-07-23 14:33:19 -0700477 main.caseExplanation = "Stopping the current mininet topology " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700478 "to start up fresh"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700479
480 main.step( "Stopping Mininet Topology" )
481 topoResult = main.Mininet1.stopNet( )
482 stepResult = topoResult
483 utilities.assert_equals( expect=main.TRUE,
484 actual=stepResult,
485 onpass="Successfully stop mininet",
486 onfail="Failed to stop mininet" )
487 # Exit if topology did not load properly
488 if not topoResult:
489 main.cleanup()
490 main.exit()
491
kelvin-onlabb769f562015-07-15 17:05:10 -0700492 def CASE1000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700493 """
494 Add host intents between 2 host:
495 - Discover hosts
496 - Add host intents
497 - Check intents
498 - Verify flows
499 - Ping hosts
500 - Reroute
501 - Link down
502 - Verify flows
503 - Check topology
504 - Ping hosts
505 - Link up
506 - Verify flows
507 - Check topology
508 - Ping hosts
509 - Remove intents
510 """
511 import time
512 import json
513 import re
514
515 # Assert variables - These variable's name|format must be followed
516 # if you want to use the wrapper function
517 assert main, "There is no main"
518 assert main.CLIs, "There is no main.CLIs"
519 assert main.Mininet1, "Mininet handle should be named Mininet1"
520 assert main.numSwitch, "Placed the total number of switch topology in \
521 main.numSwitch"
522
acsmarse6b410f2015-07-17 14:39:34 -0700523 intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
524
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700525 main.testName = "Host Intents"
526 main.case( main.testName + " Test - " + str( main.numCtrls ) +
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700527 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700528 main.caseExplanation = "This test case tests Host intents using " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700529 str( main.numCtrls ) + " node(s) cluster;\n" +\
530 "Different type of hosts will be tested in " +\
531 "each step such as IPV4, Dual stack, VLAN " +\
532 "etc;\nThe test will use OF " + main.OFProtocol\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700533 + " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700534
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700535 main.step( "IPV4: Add host intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700536 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700537 stepResult = main.intentFunction.hostIntent( main,
538 onosNode='0',
539 name='IPV4',
540 host1='h1',
541 host2='h9',
542 host1Id='00:00:00:00:00:01/-1',
543 host2Id='00:00:00:00:00:09/-1',
544 sw1='s5',
545 sw2='s2',
546 expectedLink=18 )
547
548 utilities.assert_equals( expect=main.TRUE,
549 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700550 onpass="IPV4: Host intent test successful " +
551 "between two IPV4 hosts",
552 onfail="IPV4: Host intent test failed " +
553 "between two IPV4 hosts")
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700554
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700555 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700556 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700557 stepResult = main.intentFunction.hostIntent( main,
558 name='DUALSTACK',
559 host1='h3',
560 host2='h11',
561 host1Id='00:00:00:00:00:03/-1',
562 host2Id='00:00:00:00:00:0B/-1',
563 sw1='s5',
564 sw2='s2',
565 expectedLink=18 )
566
567 utilities.assert_equals( expect=main.TRUE,
568 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700569 onpass="DUALSTACK: Host intent test " +
570 "successful between two " +
571 "dual stack host using IPV4",
572 onfail="DUALSTACK: Host intent test " +
573 "failed between two" +
574 "dual stack host using IPV4" )
575
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700576
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700577 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700578 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700579 stepResult = main.intentFunction.hostIntent( main,
580 name='DUALSTACK2',
581 host1='h1',
582 host2='h11',
583 sw1='s5',
584 sw2='s2',
585 expectedLink=18 )
586
587 utilities.assert_equals( expect=main.TRUE,
588 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700589 onpass="DUALSTACK2: Host intent test " +
590 "successful between two " +
591 "dual stack host using IPV4",
592 onfail="DUALSTACK2: Host intent test " +
593 "failed between two" +
594 "dual stack host using IPV4" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700595
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700596 main.step( "1HOP: Add host intents between h1 and h3" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700597 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700598 stepResult = main.intentFunction.hostIntent( main,
599 name='1HOP',
600 host1='h1',
601 host2='h3' )
602
603 utilities.assert_equals( expect=main.TRUE,
604 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700605 onpass="1HOP: Host intent test " +
606 "successful between two " +
607 "host using IPV4 in the same switch",
608 onfail="1HOP: Host intent test " +
609 "failed between two" +
610 "host using IPV4 in the same switch" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700611
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700612 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700613 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700614 stepResult = main.intentFunction.hostIntent( main,
615 name='VLAN1',
616 host1='h4',
617 host2='h12',
618 host1Id='00:00:00:00:00:04/100',
619 host2Id='00:00:00:00:00:0C/100',
620 sw1='s5',
621 sw2='s2',
622 expectedLink=18 )
623
624 utilities.assert_equals( expect=main.TRUE,
625 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700626 onpass="VLAN1: Host intent test " +
627 "successful between two " +
628 "host using IPV4 in the same VLAN",
629 onfail="VLAN1: Host intent test " +
630 "failed between two" +
631 "host using IPV4 in the same VLAN" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700632
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700633 main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700634 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700635 stepResult = main.intentFunction.hostIntent( main,
636 name='VLAN2',
637 host1='h13',
638 host2='h20' )
639
640 utilities.assert_equals( expect=main.FALSE,
641 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700642 onpass="VLAN2: Host intent negative test " +
643 "successful between two " +
644 "host using IPV4 in different VLAN",
645 onfail="VLAN2: Host intent negative test " +
646 "failed between two" +
647 "host using IPV4 in different VLAN" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700648
acsmarse6b410f2015-07-17 14:39:34 -0700649
650 intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
651 main.intentFunction.checkLeaderChange( intentLeadersOld,
652 intentLeadersNew )
653
kelvin-onlab016dce22015-08-10 09:54:11 -0700654 main.intentFunction.report( main )
655
kelvin-onlabb769f562015-07-15 17:05:10 -0700656 def CASE2000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700657 """
658 Add point intents between 2 hosts:
659 - Get device ids | ports
660 - Add point intents
661 - Check intents
662 - Verify flows
663 - Ping hosts
664 - Reroute
665 - Link down
666 - Verify flows
667 - Check topology
668 - Ping hosts
669 - Link up
670 - Verify flows
671 - Check topology
672 - Ping hosts
673 - Remove intents
674 """
675 import time
676 import json
677 import re
678
679 # Assert variables - These variable's name|format must be followed
680 # if you want to use the wrapper function
681 assert main, "There is no main"
682 assert main.CLIs, "There is no main.CLIs"
683 assert main.Mininet1, "Mininet handle should be named Mininet1"
684 assert main.numSwitch, "Placed the total number of switch topology in \
685 main.numSwitch"
686
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700687 main.testName = "Point Intents"
688 main.case( main.testName + " Test - " + str( main.numCtrls ) +
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700689 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700690 main.caseExplanation = "This test case will test point to point" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700691 " intents using " + str( main.numCtrls ) +\
692 " node(s) cluster;\n" +\
693 "Different type of hosts will be tested in " +\
694 "each step such as IPV4, Dual stack, VLAN etc" +\
695 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700696 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700697
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700698 # No option point intents
699 main.step( "NOOPTION: Add point intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700700 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700701 stepResult = main.intentFunction.pointIntent(
702 main,
703 name="NOOPTION",
704 host1="h1",
705 host2="h9",
706 deviceId1="of:0000000000000005/1",
707 deviceId2="of:0000000000000006/1",
708 sw1="s5",
709 sw2="s2",
710 expectedLink=18 )
711
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700712 utilities.assert_equals( expect=main.TRUE,
713 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700714 onpass="NOOPTION: Point intent test " +
715 "successful using no match action",
716 onfail="NOOPTION: Point intent test " +
717 "failed using no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700718
719 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -0700720 main.step( "IPV4: Add point intents between h1 and h9" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700721 stepResult = main.intentFunction.pointIntent(
722 main,
723 name="IPV4",
724 host1="h1",
725 host2="h9",
726 deviceId1="of:0000000000000005/1",
727 deviceId2="of:0000000000000006/1",
728 port1="",
729 port2="",
730 ethType="IPV4",
731 mac1="00:00:00:00:00:01",
732 mac2="00:00:00:00:00:09",
733 bandwidth="",
734 lambdaAlloc=False,
735 ipProto="",
736 ip1="",
737 ip2="",
738 tcp1="",
739 tcp2="",
740 sw1="s5",
741 sw2="s2",
742 expectedLink=18 )
743
744 utilities.assert_equals( expect=main.TRUE,
745 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700746 onpass="IPV4: Point intent test " +
747 "successful using IPV4 type with " +
748 "MAC addresses",
749 onfail="IPV4: Point intent test " +
750 "failed using IPV4 type with " +
751 "MAC addresses" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700752 main.step( "IPV4_2: Add point intents between h1 and h9" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700753 stepResult = main.TRUE
754 stepResult = main.intentFunction.pointIntent(
755 main,
756 name="IPV4_2",
757 host1="h1",
758 host2="h9",
759 deviceId1="of:0000000000000005/1",
760 deviceId2="of:0000000000000006/1",
kelvin-onlabb769f562015-07-15 17:05:10 -0700761 ipProto="",
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700762 ip1="",
763 ip2="",
764 tcp1="",
765 tcp2="",
766 sw1="s5",
767 sw2="s2",
768 expectedLink=18 )
769
770 utilities.assert_equals( expect=main.TRUE,
771 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700772 onpass="IPV4_2: Point intent test " +
773 "successful using IPV4 type with " +
774 "no MAC addresses",
775 onfail="IPV4_2: Point intent test " +
776 "failed using IPV4 type with " +
777 "no MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700778
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700779 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700780 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -0700781 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
782 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab0ad05d12015-07-23 14:21:15 -0700783 try:
784 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/24"
785 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/24"
786 except KeyError:
787 main.log.debug( "Key Error getting IP addresses of h1 | h9 in" +
788 "main.hostsData" )
789 ip1 = main.Mininet1.getIPAddress( 'h1')
790 ip2 = main.Mininet1.getIPAddress( 'h9')
791
kelvin-onlabb769f562015-07-15 17:05:10 -0700792 ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
kelvin-onlab79ce0492015-07-27 16:14:39 -0700793 # Uneccessary, not including this in the selectors
kelvin-onlabb769f562015-07-15 17:05:10 -0700794 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
795 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
796
797 stepResult = main.intentFunction.pointIntent(
798 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700799 name="SDNIP-ICMP",
kelvin-onlabb769f562015-07-15 17:05:10 -0700800 host1="h1",
801 host2="h9",
802 deviceId1="of:0000000000000005/1",
803 deviceId2="of:0000000000000006/1",
804 mac1=mac1,
805 mac2=mac2,
806 ethType="IPV4",
807 ipProto=ipProto,
808 ip1=ip1,
kelvin-onlab79ce0492015-07-27 16:14:39 -0700809 ip2=ip2 )
kelvin-onlabb769f562015-07-15 17:05:10 -0700810
811 utilities.assert_equals( expect=main.TRUE,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700812 actual=stepResult,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700813 onpass="SDNIP-ICMP: Point intent test " +
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700814 "successful using IPV4 type with " +
815 "IP protocol TCP enabled",
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700816 onfail="SDNIP-ICMP: Point intent test " +
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700817 "failed using IPV4 type with " +
818 "IP protocol TCP enabled" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700819
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700820 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700821 stepResult = main.TRUE
822 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
823 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab58dc39e2015-08-06 08:11:09 -0700824 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
825 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlabb769f562015-07-15 17:05:10 -0700826 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
827 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
828 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
829
kelvin-onlab58dc39e2015-08-06 08:11:09 -0700830 stepResult = main.intentFunction.pointIntentTcp(
kelvin-onlabb769f562015-07-15 17:05:10 -0700831 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700832 name="SDNIP-TCP",
kelvin-onlabb769f562015-07-15 17:05:10 -0700833 host1="h1",
834 host2="h9",
835 deviceId1="of:0000000000000005/1",
836 deviceId2="of:0000000000000006/1",
837 mac1=mac1,
838 mac2=mac2,
839 ethType="IPV4",
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700840 ipProto=ipProto,
841 ip1=ip1,
842 ip2=ip2,
843 tcp1=tcp1,
844 tcp2=tcp2 )
kelvin-onlabb769f562015-07-15 17:05:10 -0700845
846 utilities.assert_equals( expect=main.TRUE,
847 actual=stepResult,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700848 onpass="SDNIP-TCP: Point intent test " +
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700849 "successful using IPV4 type with " +
850 "IP protocol ICMP enabled",
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700851 onfail="SDNIP-TCP: Point intent test " +
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700852 "failed using IPV4 type with " +
853 "IP protocol ICMP enabled" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700854
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700855 main.step( "DUALSTACK1: Add point intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700856 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700857 stepResult = main.intentFunction.pointIntent(
858 main,
859 name="DUALSTACK1",
860 host1="h3",
861 host2="h11",
862 deviceId1="of:0000000000000005",
863 deviceId2="of:0000000000000006",
864 port1="3",
865 port2="3",
866 ethType="IPV4",
867 mac1="00:00:00:00:00:03",
868 mac2="00:00:00:00:00:0B",
869 bandwidth="",
870 lambdaAlloc=False,
871 ipProto="",
872 ip1="",
873 ip2="",
874 tcp1="",
875 tcp2="",
876 sw1="s5",
877 sw2="s2",
878 expectedLink=18 )
879
880 utilities.assert_equals( expect=main.TRUE,
881 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700882 onpass="DUALSTACK1: Point intent test " +
883 "successful using IPV4 type with " +
884 "MAC addresses",
885 onfail="DUALSTACK1: Point intent test " +
886 "failed using IPV4 type with " +
887 "MAC addresses" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700888
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700889 main.step( "VLAN: Add point intents between h5 and h21" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700890 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700891 stepResult = main.intentFunction.pointIntent(
892 main,
893 name="VLAN",
894 host1="h5",
895 host2="h21",
896 deviceId1="of:0000000000000005/5",
897 deviceId2="of:0000000000000007/5",
898 port1="",
899 port2="",
900 ethType="IPV4",
901 mac1="00:00:00:00:00:05",
902 mac2="00:00:00:00:00:15",
903 bandwidth="",
904 lambdaAlloc=False,
905 ipProto="",
906 ip1="",
907 ip2="",
908 tcp1="",
909 tcp2="",
910 sw1="s5",
911 sw2="s2",
912 expectedLink=18 )
913
914 utilities.assert_equals( expect=main.TRUE,
915 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700916 onpass="VLAN1: Point intent test " +
917 "successful using IPV4 type with " +
918 "MAC addresses",
919 onfail="VLAN1: Point intent test " +
920 "failed using IPV4 type with " +
921 "MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700922
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700923 main.step( "1HOP: Add point intents between h1 and h3" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700924 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700925 stepResult = main.intentFunction.hostIntent( main,
926 name='1HOP',
927 host1='h1',
928 host2='h3' )
929
930 utilities.assert_equals( expect=main.TRUE,
931 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700932 onpass="1HOP: Point intent test " +
933 "successful using IPV4 type with " +
934 "no MAC addresses",
935 onfail="1HOP: Point intent test " +
936 "failed using IPV4 type with " +
937 "no MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700938
kelvin-onlab016dce22015-08-10 09:54:11 -0700939 main.intentFunction.report( main )
940
kelvin-onlabb769f562015-07-15 17:05:10 -0700941 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700942 """
943 Add single point to multi point intents
944 - Get device ids
945 - Add single point to multi point intents
946 - Check intents
947 - Verify flows
948 - Ping hosts
949 - Reroute
950 - Link down
951 - Verify flows
952 - Check topology
953 - Ping hosts
954 - Link up
955 - Verify flows
956 - Check topology
957 - Ping hosts
958 - Remove intents
959 """
960 assert main, "There is no main"
961 assert main.CLIs, "There is no main.CLIs"
962 assert main.Mininet1, "Mininet handle should be named Mininet1"
963 assert main.numSwitch, "Placed the total number of switch topology in \
964 main.numSwitch"
965
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700966 main.testName = "Single to Multi Point Intents"
967 main.case( main.testName + " Test - " + str( main.numCtrls ) +
968 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700969 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700970 " multi point intents using " +\
971 str( main.numCtrls ) + " node(s) cluster;\n" +\
972 "Different type of hosts will be tested in " +\
973 "each step such as IPV4, Dual stack, VLAN etc" +\
974 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700975 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700976
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700977 hostNames = [ 'h8', 'h16', 'h24' ]
978 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
979 'of:0000000000000007/8' ]
980 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700981
acsmars2ec91d62015-09-16 11:15:48 -0700982 # This test as written attempts something that is improbable to succeed
983 # Single to Multi Point Raw intent cannot be bi-directional, so pings are not usable to test it
984 # This test should be re-written so that one single-to-multi NOOPTION
985 # intent is installed, with listeners at the destinations, so that one way
986 # packets can be detected
987 #
988 # main.step( "NOOPTION: Add single point to multi point intents" )
989 # stepResult = main.TRUE
990 # stepResult = main.intentFunction.singleToMultiIntent(
991 # main,
992 # name="NOOPTION",
993 # hostNames=hostNames,
994 # devices=devices,
995 # sw1="s5",
996 # sw2="s2",
997 # expectedLink=18 )
998 #
999 # utilities.assert_equals( expect=main.TRUE,
1000 # actual=stepResult,
1001 # onpass="NOOPTION: Successfully added single "
1002 # + " point to multi point intents" +
1003 # " with no match action",
1004 # onfail="NOOPTION: Failed to add single point"
1005 # + " point to multi point intents" +
1006 # " with no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001007
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001008 main.step( "IPV4: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001009 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001010 stepResult = main.intentFunction.singleToMultiIntent(
1011 main,
1012 name="IPV4",
1013 hostNames=hostNames,
1014 devices=devices,
1015 ports=None,
1016 ethType="IPV4",
1017 macs=macs,
1018 bandwidth="",
1019 lambdaAlloc=False,
1020 ipProto="",
1021 ipAddresses="",
1022 tcp="",
1023 sw1="s5",
1024 sw2="s2",
1025 expectedLink=18 )
1026
1027 utilities.assert_equals( expect=main.TRUE,
1028 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001029 onpass="IPV4: Successfully added single "
1030 + " point to multi point intents" +
1031 " with IPV4 type and MAC addresses",
1032 onfail="IPV4: Failed to add single point"
1033 + " point to multi point intents" +
1034 " with IPV4 type and MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001035
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001036 main.step( "IPV4_2: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001037 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001038 hostNames = [ 'h8', 'h16', 'h24' ]
1039 stepResult = main.intentFunction.singleToMultiIntent(
1040 main,
1041 name="IPV4",
1042 hostNames=hostNames,
1043 ethType="IPV4",
1044 lambdaAlloc=False )
1045
1046 utilities.assert_equals( expect=main.TRUE,
1047 actual=stepResult,
1048 onpass="IPV4_2: Successfully added single "
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001049 + " point to multi point intents" +
1050 " with IPV4 type and no MAC addresses",
1051 onfail="IPV4_2: Failed to add single point"
1052 + " point to multi point intents" +
1053 " with IPV4 type and no MAC addresses" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001054
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001055 main.step( "VLAN: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001056 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001057 hostNames = [ 'h4', 'h12', 'h20' ]
1058 devices = [ 'of:0000000000000005/4', 'of:0000000000000006/4', \
1059 'of:0000000000000007/4' ]
1060 macs = [ '00:00:00:00:00:04', '00:00:00:00:00:0C', '00:00:00:00:00:14' ]
1061 stepResult = main.intentFunction.singleToMultiIntent(
1062 main,
1063 name="VLAN",
1064 hostNames=hostNames,
1065 devices=devices,
1066 ports=None,
1067 ethType="IPV4",
1068 macs=macs,
1069 bandwidth="",
1070 lambdaAlloc=False,
1071 ipProto="",
1072 ipAddresses="",
1073 tcp="",
1074 sw1="s5",
1075 sw2="s2",
1076 expectedLink=18 )
1077
1078 utilities.assert_equals( expect=main.TRUE,
1079 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001080 onpass="VLAN: Successfully added single "
1081 + " point to multi point intents" +
1082 " with IPV4 type and MAC addresses" +
1083 " in the same VLAN",
1084 onfail="VLAN: Failed to add single point"
1085 + " point to multi point intents" +
1086 " with IPV4 type and MAC addresses" +
1087 " in the same VLAN")
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001088
kelvin-onlab016dce22015-08-10 09:54:11 -07001089 main.intentFunction.report( main )
1090
kelvin-onlabb769f562015-07-15 17:05:10 -07001091 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001092 """
1093 Add multi point to single point intents
1094 - Get device ids
1095 - Add multi point to single point intents
1096 - Check intents
1097 - Verify flows
1098 - Ping hosts
1099 - Reroute
1100 - Link down
1101 - Verify flows
1102 - Check topology
1103 - Ping hosts
1104 - Link up
1105 - Verify flows
1106 - Check topology
1107 - Ping hosts
1108 - Remove intents
1109 """
1110 assert main, "There is no main"
1111 assert main.CLIs, "There is no main.CLIs"
1112 assert main.Mininet1, "Mininet handle should be named Mininet1"
1113 assert main.numSwitch, "Placed the total number of switch topology in \
1114 main.numSwitch"
1115
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001116 main.testName = "Multi To Single Point Intents"
1117 main.case( main.testName + " Test - " + str( main.numCtrls ) +
1118 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -07001119 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001120 " multi point intents using " +\
1121 str( main.numCtrls ) + " node(s) cluster;\n" +\
1122 "Different type of hosts will be tested in " +\
1123 "each step such as IPV4, Dual stack, VLAN etc" +\
1124 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -07001125 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001126
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001127 hostNames = [ 'h8', 'h16', 'h24' ]
1128 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
1129 'of:0000000000000007/8' ]
1130 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001131
acsmars5b78fcd2015-09-02 15:01:59 -07001132 # This test as written attempts something that is impossible
1133 # Multi to Single Raw intent cannot be bi-directional, so pings are not usable to test it
1134 # This test should be re-written so that one multi-to-single NOOPTION
1135 # intent is installed, with listeners at the destinations, so that one way
1136 # packets can be detected
1137 #
1138 # main.step( "NOOPTION: Add multi point to single point intents" )
1139 # stepResult = main.TRUE
1140 # stepResult = main.intentFunction.multiToSingleIntent(
1141 # main,
1142 # name="NOOPTION",
1143 # hostNames=hostNames,
1144 # devices=devices,
1145 # sw1="s5",
1146 # sw2="s2",
1147 # expectedLink=18 )
1148 #
1149 # utilities.assert_equals( expect=main.TRUE,
1150 # actual=stepResult,
1151 # onpass="NOOPTION: Successfully added multi "
1152 # + " point to single point intents" +
1153 # " with no match action",
1154 # onfail="NOOPTION: Failed to add multi point" +
1155 # " to single point intents" +
1156 # " with no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001157
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001158 main.step( "IPV4: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001159 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001160 stepResult = main.intentFunction.multiToSingleIntent(
1161 main,
1162 name="IPV4",
1163 hostNames=hostNames,
1164 devices=devices,
1165 ports=None,
1166 ethType="IPV4",
1167 macs=macs,
1168 bandwidth="",
1169 lambdaAlloc=False,
1170 ipProto="",
1171 ipAddresses="",
1172 tcp="",
1173 sw1="s5",
1174 sw2="s2",
1175 expectedLink=18 )
1176
1177 utilities.assert_equals( expect=main.TRUE,
1178 actual=stepResult,
1179 onpass="IPV4: Successfully added multi point"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001180 + " to single point intents" +
1181 " with IPV4 type and MAC addresses",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001182 onfail="IPV4: Failed to add multi point" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001183 " to single point intents" +
1184 " with IPV4 type and MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001185
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001186 main.step( "IPV4_2: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001187 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001188 hostNames = [ 'h8', 'h16', 'h24' ]
1189 stepResult = main.intentFunction.multiToSingleIntent(
1190 main,
1191 name="IPV4",
1192 hostNames=hostNames,
1193 ethType="IPV4",
1194 lambdaAlloc=False )
1195
1196 utilities.assert_equals( expect=main.TRUE,
1197 actual=stepResult,
1198 onpass="IPV4_2: Successfully added multi point"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001199 + " to single point intents" +
1200 " with IPV4 type and no MAC addresses",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001201 onfail="IPV4_2: Failed to add multi point" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001202 " to single point intents" +
1203 " with IPV4 type and no MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001204
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001205 main.step( "VLAN: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001206 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001207 hostNames = [ 'h5', 'h13', 'h21' ]
1208 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \
1209 'of:0000000000000007/5' ]
1210 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
1211 stepResult = main.intentFunction.multiToSingleIntent(
1212 main,
1213 name="VLAN",
1214 hostNames=hostNames,
1215 devices=devices,
1216 ports=None,
1217 ethType="IPV4",
1218 macs=macs,
1219 bandwidth="",
1220 lambdaAlloc=False,
1221 ipProto="",
1222 ipAddresses="",
1223 tcp="",
1224 sw1="s5",
1225 sw2="s2",
1226 expectedLink=18 )
1227
1228 utilities.assert_equals( expect=main.TRUE,
1229 actual=stepResult,
1230 onpass="VLAN: Successfully added multi point"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001231 + " to single point intents" +
1232 " with IPV4 type and MAC addresses" +
1233 " in the same VLAN",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001234 onfail="VLAN: Failed to add multi point" +
1235 " to single point intents" )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001236
acsmars1ff5e052015-07-23 11:27:48 -07001237 def CASE5000( self, main ):
1238 """
1239 Will add description in next patch set
acsmars1ff5e052015-07-23 11:27:48 -07001240 """
1241 assert main, "There is no main"
1242 assert main.CLIs, "There is no main.CLIs"
1243 assert main.Mininet1, "Mininet handle should be named Mininet1"
1244 assert main.numSwitch, "Placed the total number of switch topology in \
1245 main.numSwitch"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001246 main.case( "Test host mobility with host intents " )
1247 main.step( " Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07001248 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1249
1250 main.log.info( "Moving h1 from s5 to s6")
1251
1252 main.Mininet1.moveHost( "h1","s5","s6" )
1253
1254 main.intentFunction.getHostsData( main )
1255 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1256
1257 utilities.assert_equals( expect="of:0000000000000006",
1258 actual=h1PostMove,
1259 onpass="Mobility: Successfully moved h1 to s6",
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001260 onfail="Mobility: Failed to moved h1 to s6" +
1261 " to single point intents" +
1262 " with IPV4 type and MAC addresses" +
1263 " in the same VLAN" )
1264
1265 main.step( "IPV4: Add host intents between h1 and h9" )
1266 stepResult = main.TRUE
1267 stepResult = main.intentFunction.hostIntent( main,
1268 onosNode='0',
1269 name='IPV4',
1270 host1='h1',
1271 host2='h9',
1272 host1Id='00:00:00:00:00:01/-1',
1273 host2Id='00:00:00:00:00:09/-1' )
1274
1275 utilities.assert_equals( expect=main.TRUE,
1276 actual=stepResult,
1277 onpass="IPV4: Host intent test successful " +
1278 "between two IPV4 hosts",
1279 onfail="IPV4: Host intent test failed " +
1280 "between two IPV4 hosts")
kelvin-onlab016dce22015-08-10 09:54:11 -07001281
1282 main.intentFunction.report( main )