blob: 811178346d6f45ced2afd6ad0f3eee0ab8afa1bc [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
10 import os
11 import imp
Jon Hallf632d202015-07-30 15:45:11 -070012 import re
kelvin-onlabd48a68c2015-07-13 16:01:36 -070013
14 """
15 - Construct tests variables
16 - GIT ( optional )
17 - Checkout ONOS master branch
18 - Pull latest ONOS code
19 - Building ONOS ( optional )
20 - Install ONOS package
21 - Build ONOS package
22 """
23
24 main.case( "Constructing test variables and building ONOS package" )
25 main.step( "Constructing test variables" )
Jon Hall783bbf92015-07-23 14:33:19 -070026 main.caseExplanation = "This test case is mainly for loading " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -070027 "from params file, and pull and build the " +\
28 " latest ONOS package"
kelvin-onlabd48a68c2015-07-13 16:01:36 -070029 stepResult = main.FALSE
30
31 # Test variables
Jon Halla3e02432015-07-24 15:55:42 -070032 try:
Jon Hallf632d202015-07-30 15:45:11 -070033 main.testOnDirectory = re.sub( "(/tests)$", "", main.testDir )
Jon Halla3e02432015-07-24 15:55:42 -070034 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
35 gitBranch = main.params[ 'GIT' ][ 'branch' ]
36 main.dependencyPath = main.testOnDirectory + \
37 main.params[ 'DEPENDENCY' ][ 'path' ]
38 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
39 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
40 if main.ONOSbench.maxNodes:
41 main.maxNodes = int( main.ONOSbench.maxNodes )
42 else:
43 main.maxNodes = 0
44 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
45 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
46 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
47 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
48 main.checkIntentSleep = int( main.params[ 'SLEEP' ][ 'checkintent' ] )
49 main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] )
50 main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
51 gitPull = main.params[ 'GIT' ][ 'pull' ]
52 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
53 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
54 main.cellData = {} # for creating cell file
55 main.hostsData = {}
56 main.CLIs = []
57 main.ONOSip = []
kelvin-onlabd48a68c2015-07-13 16:01:36 -070058
Jon Halla3e02432015-07-24 15:55:42 -070059 main.ONOSip = main.ONOSbench.getOnosIps()
60 print main.ONOSip
kelvin-onlabd48a68c2015-07-13 16:01:36 -070061
Jon Halla3e02432015-07-24 15:55:42 -070062 # Assigning ONOS cli handles to a list
63 for i in range( 1, main.maxNodes + 1 ):
64 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070065
Jon Halla3e02432015-07-24 15:55:42 -070066 # -- INIT SECTION, ONLY RUNS ONCE -- #
67 main.startUp = imp.load_source( wrapperFile1,
68 main.dependencyPath +
69 wrapperFile1 +
70 ".py" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070071
Jon Halla3e02432015-07-24 15:55:42 -070072 main.intentFunction = imp.load_source( wrapperFile2,
73 main.dependencyPath +
74 wrapperFile2 +
75 ".py" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070076
Jon Halla3e02432015-07-24 15:55:42 -070077 main.topo = imp.load_source( wrapperFile3,
78 main.dependencyPath +
79 wrapperFile3 +
80 ".py" )
81
82 copyResult = main.ONOSbench.copyMininetFile( main.topology,
83 main.dependencyPath,
84 main.Mininet1.user_name,
85 main.Mininet1.ip_address )
86 if main.CLIs:
87 stepResult = main.TRUE
88 else:
89 main.log.error( "Did not properly created list of ONOS CLI handle" )
90 stepResult = main.FALSE
91 except Exception as e:
92 main.log.exception(e)
93 main.cleanup()
94 main.exit()
kelvin-onlabd48a68c2015-07-13 16:01:36 -070095
96 utilities.assert_equals( expect=main.TRUE,
97 actual=stepResult,
98 onpass="Successfully construct " +
99 "test variables ",
100 onfail="Failed to construct test variables" )
101
102 if gitPull == 'True':
103 main.step( "Building ONOS in " + gitBranch + " branch" )
104 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
105 stepResult = onosBuildResult
106 utilities.assert_equals( expect=main.TRUE,
107 actual=stepResult,
108 onpass="Successfully compiled " +
109 "latest ONOS",
110 onfail="Failed to compile " +
111 "latest ONOS" )
112 else:
113 main.log.warn( "Did not pull new code so skipping mvn " +
114 "clean install" )
Jon Hall106be082015-07-22 09:53:00 -0700115 main.ONOSbench.getVersion( report=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700116
117 def CASE2( self, main ):
118 """
119 - Set up cell
120 - Create cell file
121 - Set cell file
122 - Verify cell file
123 - Kill ONOS process
124 - Uninstall ONOS cluster
125 - Verify ONOS start up
126 - Install ONOS cluster
127 - Connect to cli
128 """
129
130 # main.scale[ 0 ] determines the current number of ONOS controller
131 main.numCtrls = int( main.scale[ 0 ] )
132
133 main.case( "Starting up " + str( main.numCtrls ) +
134 " node(s) ONOS cluster" )
Jon Hall783bbf92015-07-23 14:33:19 -0700135 main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700136 " node(s) ONOS cluster"
137
138
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700139
140 #kill off all onos processes
141 main.log.info( "Safety check, killing all ONOS processes" +
142 " before initiating enviornment setup" )
143
144 for i in range( main.maxNodes ):
145 main.ONOSbench.onosDie( main.ONOSip[ i ] )
146
147 print "NODE COUNT = ", main.numCtrls
148
149 tempOnosIp = []
150 for i in range( main.numCtrls ):
151 tempOnosIp.append( main.ONOSip[i] )
152
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700153 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
154 "temp", main.Mininet1.ip_address,
155 main.apps, tempOnosIp )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700156
157 main.step( "Apply cell to environment" )
158 cellResult = main.ONOSbench.setCell( "temp" )
159 verifyResult = main.ONOSbench.verifyCell()
160 stepResult = cellResult and verifyResult
161 utilities.assert_equals( expect=main.TRUE,
162 actual=stepResult,
163 onpass="Successfully applied cell to " + \
164 "environment",
165 onfail="Failed to apply cell to environment " )
166
167 main.step( "Creating ONOS package" )
168 packageResult = main.ONOSbench.onosPackage()
169 stepResult = packageResult
170 utilities.assert_equals( expect=main.TRUE,
171 actual=stepResult,
172 onpass="Successfully created ONOS package",
173 onfail="Failed to create ONOS package" )
174
175 time.sleep( main.startUpSleep )
176 main.step( "Uninstalling ONOS package" )
177 onosUninstallResult = main.TRUE
kelvin-onlab5f0d19e2015-08-04 15:21:00 -0700178 for ip in main.ONOSip:
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700179 onosUninstallResult = onosUninstallResult and \
kelvin-onlab5f0d19e2015-08-04 15:21:00 -0700180 main.ONOSbench.onosUninstall( nodeIp=ip )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700181 stepResult = onosUninstallResult
182 utilities.assert_equals( expect=main.TRUE,
183 actual=stepResult,
184 onpass="Successfully uninstalled ONOS package",
185 onfail="Failed to uninstall ONOS package" )
186
187 time.sleep( main.startUpSleep )
188 main.step( "Installing ONOS package" )
189 onosInstallResult = main.TRUE
190 for i in range( main.numCtrls ):
191 onosInstallResult = onosInstallResult and \
192 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
193 stepResult = onosInstallResult
194 utilities.assert_equals( expect=main.TRUE,
195 actual=stepResult,
196 onpass="Successfully installed ONOS package",
197 onfail="Failed to install ONOS package" )
198
199 time.sleep( main.startUpSleep )
200 main.step( "Starting ONOS service" )
201 stopResult = main.TRUE
202 startResult = main.TRUE
203 onosIsUp = main.TRUE
204
205 for i in range( main.numCtrls ):
206 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
207 if onosIsUp == main.TRUE:
208 main.log.report( "ONOS instance is up and ready" )
209 else:
210 main.log.report( "ONOS instance may not be up, stop and " +
211 "start ONOS again " )
212 for i in range( main.numCtrls ):
213 stopResult = stopResult and \
214 main.ONOSbench.onosStop( main.ONOSip[ i ] )
215 for i in range( main.numCtrls ):
216 startResult = startResult and \
217 main.ONOSbench.onosStart( main.ONOSip[ i ] )
218 stepResult = onosIsUp and stopResult and startResult
219 utilities.assert_equals( expect=main.TRUE,
220 actual=stepResult,
221 onpass="ONOS service is ready",
222 onfail="ONOS service did not start properly" )
223
224 main.step( "Start ONOS cli" )
225 cliResult = main.TRUE
226 for i in range( main.numCtrls ):
227 cliResult = cliResult and \
228 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
229 stepResult = cliResult
230 utilities.assert_equals( expect=main.TRUE,
231 actual=stepResult,
232 onpass="Successfully start ONOS cli",
233 onfail="Failed to start ONOS cli" )
234
235 # Remove the first element in main.scale list
236 main.scale.remove( main.scale[ 0 ] )
237
Jon Halla3e02432015-07-24 15:55:42 -0700238 def CASE8( self, main ):
239 """
240 Compare Topo
241 """
242 import json
243
244 main.case( "Compare ONOS Topology view to Mininet topology" )
245 main.caseExplanation = "Compare topology elements between Mininet" +\
246 " and ONOS"
247
248 main.step( "Gathering topology information" )
249 # TODO: add a paramaterized sleep here
250 devicesResults = main.TRUE
251 linksResults = main.TRUE
252 hostsResults = main.TRUE
253 devices = main.topo.getAllDevices( main )
254 hosts = main.topo.getAllHosts( main )
255 ports = main.topo.getAllPorts( main )
256 links = main.topo.getAllLinks( main )
257 clusters = main.topo.getAllClusters( main )
258
259 mnSwitches = main.Mininet1.getSwitches()
260 mnLinks = main.Mininet1.getLinks()
261 mnHosts = main.Mininet1.getHosts()
262
263 main.step( "Conmparing MN topology to ONOS topology" )
264 for controller in range( main.numCtrls ):
265 controllerStr = str( controller + 1 )
266 if devices[ controller ] and ports[ controller ] and\
267 "Error" not in devices[ controller ] and\
268 "Error" not in ports[ controller ]:
269
270 currentDevicesResult = main.Mininet1.compareSwitches(
271 mnSwitches,
272 json.loads( devices[ controller ] ),
273 json.loads( ports[ controller ] ) )
274 else:
275 currentDevicesResult = main.FALSE
276 utilities.assert_equals( expect=main.TRUE,
277 actual=currentDevicesResult,
278 onpass="ONOS" + controllerStr +
279 " Switches view is correct",
280 onfail="ONOS" + controllerStr +
281 " Switches view is incorrect" )
Jon Hall46d48252015-08-03 11:41:16 -0700282 devicesResults = devicesResults and currentDevicesResult
Jon Halla3e02432015-07-24 15:55:42 -0700283
284 if links[ controller ] and "Error" not in links[ controller ]:
285 currentLinksResult = main.Mininet1.compareLinks(
286 mnSwitches, mnLinks,
287 json.loads( links[ controller ] ) )
288 else:
289 currentLinksResult = main.FALSE
290 utilities.assert_equals( expect=main.TRUE,
291 actual=currentLinksResult,
292 onpass="ONOS" + controllerStr +
293 " links view is correct",
294 onfail="ONOS" + controllerStr +
295 " links view is incorrect" )
Jon Hall46d48252015-08-03 11:41:16 -0700296 linksResults = linksResults and currentLinksResult
Jon Halla3e02432015-07-24 15:55:42 -0700297
298 if hosts[ controller ] or "Error" not in hosts[ controller ]:
299 currentHostsResult = main.Mininet1.compareHosts(
300 mnHosts,
301 json.loads( hosts[ controller ] ) )
302 else:
303 currentHostsResult = main.FALSE
304 utilities.assert_equals( expect=main.TRUE,
305 actual=currentHostsResult,
306 onpass="ONOS" + controllerStr +
307 " hosts exist in Mininet",
308 onfail="ONOS" + controllerStr +
309 " hosts don't match Mininet" )
Jon Hall46d48252015-08-03 11:41:16 -0700310 hostsResults = hostsResults and currentHostsResult
311 topoResults = hostsResults and linksResults and devicesResults
312 utilities.assert_equals( expect=main.TRUE,
313 actual=topoResults,
314 onpass="ONOS correctly discovered the topology",
315 onfail="ONOS incorrectly discovered the topology" )
Jon Halla3e02432015-07-24 15:55:42 -0700316
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700317
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700318 def CASE9( self, main ):
319 '''
320 Report errors/warnings/exceptions
321 '''
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700322 main.case( main.testName + " Report - " + str( main.numCtrls ) +
323 " NODE(S) - OF " + main.OFProtocol )
324
325 main.ONOSbench.logReport( main.ONOSip[ 0 ],
326 [ "INFO",
327 "FOLLOWER",
328 "WARN",
329 "flow",
330 "ERROR",
331 "Except" ],
332 "s" )
333
334 main.step( "ERROR report: \n" )
kelvin-onlab5f0d19e2015-08-04 15:21:00 -0700335 for i in range( main.numCtrls ):
336 main.ONOSbench.logReport( main.ONOSip[ i ],
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700337 [ "ERROR" ],
338 "d" )
339
340 main.step( "EXCEPTIONS report: \n" )
341 for i in range( main.numCtrls ):
342 main.ONOSbench.logReport( main.ONOSip[ i ],
343 [ "Except" ],
344 "d" )
345
346 main.step( "WARNING report: \n" )
347 for i in range( main.numCtrls ):
348 main.ONOSbench.logReport( main.ONOSip[ i ],
349 [ "WARN" ],
350 "d" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700351
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700352 def CASE10( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700353 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700354 Start Mininet topology with OF 1.0 switches
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700355 """
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700356 main.OFProtocol = "1.0"
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700357 main.log.report( "Start Mininet topology with OF 1.0 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700358 main.case( "Start Mininet topology with OF 1.0 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700359 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700360 "switches to test intents, exits out if " +\
361 "topology did not start correctly"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700362
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700363 main.step( "Starting Mininet topology with OF 1.0 switches" )
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700364 args = "--switch ovs,protocols=OpenFlow10"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700365 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700366 main.topology,
367 args=args )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700368 stepResult = topoResult
369 utilities.assert_equals( expect=main.TRUE,
370 actual=stepResult,
371 onpass="Successfully loaded topology",
372 onfail="Failed to load topology" )
373 # Exit if topology did not load properly
374 if not topoResult:
375 main.cleanup()
376 main.exit()
377
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700378 def CASE11( self, main ):
379 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700380 Start Mininet topology with OF 1.3 switches
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700381 """
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700382 main.OFProtocol = "1.3"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700383 main.log.report( "Start Mininet topology with OF 1.3 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700384 main.case( "Start Mininet topology with OF 1.3 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700385 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700386 "switches to test intents, exits out if " +\
387 "topology did not start correctly"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700388
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700389 main.step( "Starting Mininet topology with OF 1.3 switches" )
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700390 args = "--switch ovs,protocols=OpenFlow13"
391 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
392 main.topology,
393 args=args )
394 stepResult = topoResult
395 utilities.assert_equals( expect=main.TRUE,
396 actual=stepResult,
397 onpass="Successfully loaded topology",
398 onfail="Failed to load topology" )
399 # Exit if topology did not load properly
400 if not topoResult:
401 main.cleanup()
402 main.exit()
403
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700404 def CASE12( self, main ):
405 """
406 Assign mastership to controllers
407 """
408 import re
409
410 main.case( "Assign switches to controllers" )
411 main.step( "Assigning switches to controllers" )
Jon Hall783bbf92015-07-23 14:33:19 -0700412 main.caseExplanation = "Assign OF " + main.OFProtocol +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700413 " switches to ONOS nodes"
414
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700415 assignResult = main.TRUE
416 switchList = []
417
418 # Creates a list switch name, use getSwitch() function later...
419 for i in range( 1, ( main.numSwitch + 1 ) ):
420 switchList.append( 's' + str( i ) )
421
422 tempONOSip = []
423 for i in range( main.numCtrls ):
424 tempONOSip.append( main.ONOSip[ i ] )
425
426 assignResult = main.Mininet1.assignSwController( sw=switchList,
427 ip=tempONOSip,
428 port='6633' )
429 if not assignResult:
430 main.cleanup()
431 main.exit()
432
433 for i in range( 1, ( main.numSwitch + 1 ) ):
434 response = main.Mininet1.getSwController( "s" + str( i ) )
435 print( "Response is " + str( response ) )
436 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
437 assignResult = assignResult and main.TRUE
438 else:
439 assignResult = main.FALSE
440 stepResult = assignResult
441 utilities.assert_equals( expect=main.TRUE,
442 actual=stepResult,
443 onpass="Successfully assigned switches" +
444 "to controller",
445 onfail="Failed to assign switches to " +
446 "controller" )
447 def CASE13( self, main ):
448 """
449 Discover all hosts and store its data to a dictionary
450 """
451 main.case( "Discover all hosts" )
452
453 stepResult = main.TRUE
454 main.step( "Discover all hosts using pingall " )
455 stepResult = main.intentFunction.getHostsData( main )
456 utilities.assert_equals( expect=main.TRUE,
457 actual=stepResult,
458 onpass="Successfully discovered hosts",
459 onfail="Failed to discover hosts" )
460
461 def CASE14( self, main ):
462 """
463 Stop mininet
464 """
465 main.log.report( "Stop Mininet topology" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700466 main.case( "Stop Mininet topology" )
Jon Hall783bbf92015-07-23 14:33:19 -0700467 main.caseExplanation = "Stopping the current mininet topology " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700468 "to start up fresh"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700469
470 main.step( "Stopping Mininet Topology" )
471 topoResult = main.Mininet1.stopNet( )
472 stepResult = topoResult
473 utilities.assert_equals( expect=main.TRUE,
474 actual=stepResult,
475 onpass="Successfully stop mininet",
476 onfail="Failed to stop mininet" )
477 # Exit if topology did not load properly
478 if not topoResult:
479 main.cleanup()
480 main.exit()
481
kelvin-onlabb769f562015-07-15 17:05:10 -0700482 def CASE1000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700483 """
484 Add host intents between 2 host:
485 - Discover hosts
486 - Add host intents
487 - Check intents
488 - Verify flows
489 - Ping hosts
490 - Reroute
491 - Link down
492 - Verify flows
493 - Check topology
494 - Ping hosts
495 - Link up
496 - Verify flows
497 - Check topology
498 - Ping hosts
499 - Remove intents
500 """
501 import time
502 import json
503 import re
504
505 # Assert variables - These variable's name|format must be followed
506 # if you want to use the wrapper function
507 assert main, "There is no main"
508 assert main.CLIs, "There is no main.CLIs"
509 assert main.Mininet1, "Mininet handle should be named Mininet1"
510 assert main.numSwitch, "Placed the total number of switch topology in \
511 main.numSwitch"
512
acsmarse6b410f2015-07-17 14:39:34 -0700513 intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
514
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700515 main.testName = "Host Intents"
516 main.case( main.testName + " Test - " + str( main.numCtrls ) +
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700517 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700518 main.caseExplanation = "This test case tests Host intents using " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700519 str( main.numCtrls ) + " node(s) cluster;\n" +\
520 "Different type of hosts will be tested in " +\
521 "each step such as IPV4, Dual stack, VLAN " +\
522 "etc;\nThe test will use OF " + main.OFProtocol\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700523 + " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700524
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700525 main.step( "IPV4: Add host intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700526 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700527 stepResult = main.intentFunction.hostIntent( main,
528 onosNode='0',
529 name='IPV4',
530 host1='h1',
531 host2='h9',
532 host1Id='00:00:00:00:00:01/-1',
533 host2Id='00:00:00:00:00:09/-1',
534 sw1='s5',
535 sw2='s2',
536 expectedLink=18 )
537
538 utilities.assert_equals( expect=main.TRUE,
539 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700540 onpass="IPV4: Host intent test successful " +
541 "between two IPV4 hosts",
542 onfail="IPV4: Host intent test failed " +
543 "between two IPV4 hosts")
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700544
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700545 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700546 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700547 stepResult = main.intentFunction.hostIntent( main,
548 name='DUALSTACK',
549 host1='h3',
550 host2='h11',
551 host1Id='00:00:00:00:00:03/-1',
552 host2Id='00:00:00:00:00:0B/-1',
553 sw1='s5',
554 sw2='s2',
555 expectedLink=18 )
556
557 utilities.assert_equals( expect=main.TRUE,
558 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700559 onpass="DUALSTACK: Host intent test " +
560 "successful between two " +
561 "dual stack host using IPV4",
562 onfail="DUALSTACK: Host intent test " +
563 "failed between two" +
564 "dual stack host using IPV4" )
565
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700566
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700567 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700568 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700569 stepResult = main.intentFunction.hostIntent( main,
570 name='DUALSTACK2',
571 host1='h1',
572 host2='h11',
573 sw1='s5',
574 sw2='s2',
575 expectedLink=18 )
576
577 utilities.assert_equals( expect=main.TRUE,
578 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700579 onpass="DUALSTACK2: Host intent test " +
580 "successful between two " +
581 "dual stack host using IPV4",
582 onfail="DUALSTACK2: Host intent test " +
583 "failed between two" +
584 "dual stack host using IPV4" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700585
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700586 main.step( "1HOP: Add host intents between h1 and h3" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700587 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700588 stepResult = main.intentFunction.hostIntent( main,
589 name='1HOP',
590 host1='h1',
591 host2='h3' )
592
593 utilities.assert_equals( expect=main.TRUE,
594 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700595 onpass="1HOP: Host intent test " +
596 "successful between two " +
597 "host using IPV4 in the same switch",
598 onfail="1HOP: Host intent test " +
599 "failed between two" +
600 "host using IPV4 in the same switch" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700601
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700602 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700603 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700604 stepResult = main.intentFunction.hostIntent( main,
605 name='VLAN1',
606 host1='h4',
607 host2='h12',
608 host1Id='00:00:00:00:00:04/100',
609 host2Id='00:00:00:00:00:0C/100',
610 sw1='s5',
611 sw2='s2',
612 expectedLink=18 )
613
614 utilities.assert_equals( expect=main.TRUE,
615 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700616 onpass="VLAN1: Host intent test " +
617 "successful between two " +
618 "host using IPV4 in the same VLAN",
619 onfail="VLAN1: Host intent test " +
620 "failed between two" +
621 "host using IPV4 in the same VLAN" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700622
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700623 main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700624 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700625 stepResult = main.intentFunction.hostIntent( main,
626 name='VLAN2',
627 host1='h13',
628 host2='h20' )
629
630 utilities.assert_equals( expect=main.FALSE,
631 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700632 onpass="VLAN2: Host intent negative test " +
633 "successful between two " +
634 "host using IPV4 in different VLAN",
635 onfail="VLAN2: Host intent negative test " +
636 "failed between two" +
637 "host using IPV4 in different VLAN" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700638
acsmarse6b410f2015-07-17 14:39:34 -0700639
640 intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
641 main.intentFunction.checkLeaderChange( intentLeadersOld,
642 intentLeadersNew )
643
kelvin-onlabb769f562015-07-15 17:05:10 -0700644 def CASE2000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700645 """
646 Add point intents between 2 hosts:
647 - Get device ids | ports
648 - Add point intents
649 - Check intents
650 - Verify flows
651 - Ping hosts
652 - Reroute
653 - Link down
654 - Verify flows
655 - Check topology
656 - Ping hosts
657 - Link up
658 - Verify flows
659 - Check topology
660 - Ping hosts
661 - Remove intents
662 """
663 import time
664 import json
665 import re
666
667 # Assert variables - These variable's name|format must be followed
668 # if you want to use the wrapper function
669 assert main, "There is no main"
670 assert main.CLIs, "There is no main.CLIs"
671 assert main.Mininet1, "Mininet handle should be named Mininet1"
672 assert main.numSwitch, "Placed the total number of switch topology in \
673 main.numSwitch"
674
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700675 main.testName = "Point Intents"
676 main.case( main.testName + " Test - " + str( main.numCtrls ) +
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700677 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700678 main.caseExplanation = "This test case will test point to point" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700679 " intents using " + str( main.numCtrls ) +\
680 " node(s) cluster;\n" +\
681 "Different type of hosts will be tested in " +\
682 "each step such as IPV4, Dual stack, VLAN etc" +\
683 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700684 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700685
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700686 # No option point intents
687 main.step( "NOOPTION: Add point intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700688 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700689 stepResult = main.intentFunction.pointIntent(
690 main,
691 name="NOOPTION",
692 host1="h1",
693 host2="h9",
694 deviceId1="of:0000000000000005/1",
695 deviceId2="of:0000000000000006/1",
696 sw1="s5",
697 sw2="s2",
698 expectedLink=18 )
699
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700700 utilities.assert_equals( expect=main.TRUE,
701 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700702 onpass="NOOPTION: Point intent test " +
703 "successful using no match action",
704 onfail="NOOPTION: Point intent test " +
705 "failed using no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700706
707 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -0700708 main.step( "IPV4: Add point intents between h1 and h9" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700709 stepResult = main.intentFunction.pointIntent(
710 main,
711 name="IPV4",
712 host1="h1",
713 host2="h9",
714 deviceId1="of:0000000000000005/1",
715 deviceId2="of:0000000000000006/1",
716 port1="",
717 port2="",
718 ethType="IPV4",
719 mac1="00:00:00:00:00:01",
720 mac2="00:00:00:00:00:09",
721 bandwidth="",
722 lambdaAlloc=False,
723 ipProto="",
724 ip1="",
725 ip2="",
726 tcp1="",
727 tcp2="",
728 sw1="s5",
729 sw2="s2",
730 expectedLink=18 )
731
732 utilities.assert_equals( expect=main.TRUE,
733 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700734 onpass="IPV4: Point intent test " +
735 "successful using IPV4 type with " +
736 "MAC addresses",
737 onfail="IPV4: Point intent test " +
738 "failed using IPV4 type with " +
739 "MAC addresses" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700740 main.step( "IPV4_2: Add point intents between h1 and h9" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700741 stepResult = main.TRUE
742 stepResult = main.intentFunction.pointIntent(
743 main,
744 name="IPV4_2",
745 host1="h1",
746 host2="h9",
747 deviceId1="of:0000000000000005/1",
748 deviceId2="of:0000000000000006/1",
kelvin-onlabb769f562015-07-15 17:05:10 -0700749 ipProto="",
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700750 ip1="",
751 ip2="",
752 tcp1="",
753 tcp2="",
754 sw1="s5",
755 sw2="s2",
756 expectedLink=18 )
757
758 utilities.assert_equals( expect=main.TRUE,
759 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700760 onpass="IPV4_2: Point intent test " +
761 "successful using IPV4 type with " +
762 "no MAC addresses",
763 onfail="IPV4_2: Point intent test " +
764 "failed using IPV4 type with " +
765 "no MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700766
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700767 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700768 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -0700769 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
770 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab0ad05d12015-07-23 14:21:15 -0700771 try:
772 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/24"
773 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/24"
774 except KeyError:
775 main.log.debug( "Key Error getting IP addresses of h1 | h9 in" +
776 "main.hostsData" )
777 ip1 = main.Mininet1.getIPAddress( 'h1')
778 ip2 = main.Mininet1.getIPAddress( 'h9')
779
kelvin-onlabb769f562015-07-15 17:05:10 -0700780 ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
kelvin-onlab79ce0492015-07-27 16:14:39 -0700781 # Uneccessary, not including this in the selectors
kelvin-onlabb769f562015-07-15 17:05:10 -0700782 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
783 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
784
785 stepResult = main.intentFunction.pointIntent(
786 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700787 name="SDNIP-ICMP",
kelvin-onlabb769f562015-07-15 17:05:10 -0700788 host1="h1",
789 host2="h9",
790 deviceId1="of:0000000000000005/1",
791 deviceId2="of:0000000000000006/1",
792 mac1=mac1,
793 mac2=mac2,
794 ethType="IPV4",
795 ipProto=ipProto,
796 ip1=ip1,
kelvin-onlab79ce0492015-07-27 16:14:39 -0700797 ip2=ip2 )
kelvin-onlabb769f562015-07-15 17:05:10 -0700798
799 utilities.assert_equals( expect=main.TRUE,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700800 actual=stepResult,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700801 onpass="SDNIP-ICMP: Point intent test " +
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700802 "successful using IPV4 type with " +
803 "IP protocol TCP enabled",
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700804 onfail="SDNIP-ICMP: Point intent test " +
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700805 "failed using IPV4 type with " +
806 "IP protocol TCP enabled" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700807
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700808 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700809 stepResult = main.TRUE
810 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
811 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
812 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/24"
813 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/24"
814 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
815 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
816 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
817
818 stepResult = main.intentFunction.pointIntent(
819 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700820 name="SDNIP-TCP",
kelvin-onlabb769f562015-07-15 17:05:10 -0700821 host1="h1",
822 host2="h9",
823 deviceId1="of:0000000000000005/1",
824 deviceId2="of:0000000000000006/1",
825 mac1=mac1,
826 mac2=mac2,
827 ethType="IPV4",
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700828 ipProto=ipProto,
829 ip1=ip1,
830 ip2=ip2,
831 tcp1=tcp1,
832 tcp2=tcp2 )
kelvin-onlabb769f562015-07-15 17:05:10 -0700833
834 utilities.assert_equals( expect=main.TRUE,
835 actual=stepResult,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700836 onpass="SDNIP-TCP: Point intent test " +
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700837 "successful using IPV4 type with " +
838 "IP protocol ICMP enabled",
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700839 onfail="SDNIP-TCP: Point intent test " +
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700840 "failed using IPV4 type with " +
841 "IP protocol ICMP enabled" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700842
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700843 main.step( "DUALSTACK1: Add point intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700844 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700845 stepResult = main.intentFunction.pointIntent(
846 main,
847 name="DUALSTACK1",
848 host1="h3",
849 host2="h11",
850 deviceId1="of:0000000000000005",
851 deviceId2="of:0000000000000006",
852 port1="3",
853 port2="3",
854 ethType="IPV4",
855 mac1="00:00:00:00:00:03",
856 mac2="00:00:00:00:00:0B",
857 bandwidth="",
858 lambdaAlloc=False,
859 ipProto="",
860 ip1="",
861 ip2="",
862 tcp1="",
863 tcp2="",
864 sw1="s5",
865 sw2="s2",
866 expectedLink=18 )
867
868 utilities.assert_equals( expect=main.TRUE,
869 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700870 onpass="DUALSTACK1: Point intent test " +
871 "successful using IPV4 type with " +
872 "MAC addresses",
873 onfail="DUALSTACK1: Point intent test " +
874 "failed using IPV4 type with " +
875 "MAC addresses" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700876
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700877 main.step( "VLAN: Add point intents between h5 and h21" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700878 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700879 stepResult = main.intentFunction.pointIntent(
880 main,
881 name="VLAN",
882 host1="h5",
883 host2="h21",
884 deviceId1="of:0000000000000005/5",
885 deviceId2="of:0000000000000007/5",
886 port1="",
887 port2="",
888 ethType="IPV4",
889 mac1="00:00:00:00:00:05",
890 mac2="00:00:00:00:00:15",
891 bandwidth="",
892 lambdaAlloc=False,
893 ipProto="",
894 ip1="",
895 ip2="",
896 tcp1="",
897 tcp2="",
898 sw1="s5",
899 sw2="s2",
900 expectedLink=18 )
901
902 utilities.assert_equals( expect=main.TRUE,
903 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700904 onpass="VLAN1: Point intent test " +
905 "successful using IPV4 type with " +
906 "MAC addresses",
907 onfail="VLAN1: Point intent test " +
908 "failed using IPV4 type with " +
909 "MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700910
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700911 main.step( "1HOP: Add point intents between h1 and h3" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700912 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700913 stepResult = main.intentFunction.hostIntent( main,
914 name='1HOP',
915 host1='h1',
916 host2='h3' )
917
918 utilities.assert_equals( expect=main.TRUE,
919 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700920 onpass="1HOP: Point intent test " +
921 "successful using IPV4 type with " +
922 "no MAC addresses",
923 onfail="1HOP: Point intent test " +
924 "failed using IPV4 type with " +
925 "no MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700926
kelvin-onlabb769f562015-07-15 17:05:10 -0700927 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700928 """
929 Add single point to multi point intents
930 - Get device ids
931 - Add single point to multi point intents
932 - Check intents
933 - Verify flows
934 - Ping hosts
935 - Reroute
936 - Link down
937 - Verify flows
938 - Check topology
939 - Ping hosts
940 - Link up
941 - Verify flows
942 - Check topology
943 - Ping hosts
944 - Remove intents
945 """
946 assert main, "There is no main"
947 assert main.CLIs, "There is no main.CLIs"
948 assert main.Mininet1, "Mininet handle should be named Mininet1"
949 assert main.numSwitch, "Placed the total number of switch topology in \
950 main.numSwitch"
951
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700952 main.testName = "Single to Multi Point Intents"
953 main.case( main.testName + " Test - " + str( main.numCtrls ) +
954 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700955 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700956 " multi point intents using " +\
957 str( main.numCtrls ) + " node(s) cluster;\n" +\
958 "Different type of hosts will be tested in " +\
959 "each step such as IPV4, Dual stack, VLAN etc" +\
960 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700961 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700962
kelvin-onlabb769f562015-07-15 17:05:10 -0700963 main.step( "NOOPTION: Add single point to multi point intents" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700964 stepResult = main.TRUE
965 hostNames = [ 'h8', 'h16', 'h24' ]
966 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
967 'of:0000000000000007/8' ]
968 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 -0700969 stepResult = main.intentFunction.singleToMultiIntent(
970 main,
971 name="NOOPTION",
972 hostNames=hostNames,
973 devices=devices,
974 sw1="s5",
975 sw2="s2",
976 expectedLink=18 )
977
978 utilities.assert_equals( expect=main.TRUE,
979 actual=stepResult,
980 onpass="NOOPTION: Successfully added single "
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700981 + " point to multi point intents" +
982 " with no match action",
983 onfail="NOOPTION: Failed to add single point"
984 + " point to multi point intents" +
985 " with no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700986
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700987 main.step( "IPV4: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700988 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700989 stepResult = main.intentFunction.singleToMultiIntent(
990 main,
991 name="IPV4",
992 hostNames=hostNames,
993 devices=devices,
994 ports=None,
995 ethType="IPV4",
996 macs=macs,
997 bandwidth="",
998 lambdaAlloc=False,
999 ipProto="",
1000 ipAddresses="",
1001 tcp="",
1002 sw1="s5",
1003 sw2="s2",
1004 expectedLink=18 )
1005
1006 utilities.assert_equals( expect=main.TRUE,
1007 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001008 onpass="IPV4: Successfully added single "
1009 + " point to multi point intents" +
1010 " with IPV4 type and MAC addresses",
1011 onfail="IPV4: Failed to add single point"
1012 + " point to multi point intents" +
1013 " with IPV4 type and MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001014
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001015 main.step( "IPV4_2: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001016 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001017 hostNames = [ 'h8', 'h16', 'h24' ]
1018 stepResult = main.intentFunction.singleToMultiIntent(
1019 main,
1020 name="IPV4",
1021 hostNames=hostNames,
1022 ethType="IPV4",
1023 lambdaAlloc=False )
1024
1025 utilities.assert_equals( expect=main.TRUE,
1026 actual=stepResult,
1027 onpass="IPV4_2: Successfully added single "
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001028 + " point to multi point intents" +
1029 " with IPV4 type and no MAC addresses",
1030 onfail="IPV4_2: Failed to add single point"
1031 + " point to multi point intents" +
1032 " with IPV4 type and no MAC addresses" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001033
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001034 main.step( "VLAN: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001035 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001036 hostNames = [ 'h4', 'h12', 'h20' ]
1037 devices = [ 'of:0000000000000005/4', 'of:0000000000000006/4', \
1038 'of:0000000000000007/4' ]
1039 macs = [ '00:00:00:00:00:04', '00:00:00:00:00:0C', '00:00:00:00:00:14' ]
1040 stepResult = main.intentFunction.singleToMultiIntent(
1041 main,
1042 name="VLAN",
1043 hostNames=hostNames,
1044 devices=devices,
1045 ports=None,
1046 ethType="IPV4",
1047 macs=macs,
1048 bandwidth="",
1049 lambdaAlloc=False,
1050 ipProto="",
1051 ipAddresses="",
1052 tcp="",
1053 sw1="s5",
1054 sw2="s2",
1055 expectedLink=18 )
1056
1057 utilities.assert_equals( expect=main.TRUE,
1058 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001059 onpass="VLAN: Successfully added single "
1060 + " point to multi point intents" +
1061 " with IPV4 type and MAC addresses" +
1062 " in the same VLAN",
1063 onfail="VLAN: Failed to add single point"
1064 + " point to multi point intents" +
1065 " with IPV4 type and MAC addresses" +
1066 " in the same VLAN")
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001067
kelvin-onlabb769f562015-07-15 17:05:10 -07001068 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001069 """
1070 Add multi point to single point intents
1071 - Get device ids
1072 - Add multi point to single point intents
1073 - Check intents
1074 - Verify flows
1075 - Ping hosts
1076 - Reroute
1077 - Link down
1078 - Verify flows
1079 - Check topology
1080 - Ping hosts
1081 - Link up
1082 - Verify flows
1083 - Check topology
1084 - Ping hosts
1085 - Remove intents
1086 """
1087 assert main, "There is no main"
1088 assert main.CLIs, "There is no main.CLIs"
1089 assert main.Mininet1, "Mininet handle should be named Mininet1"
1090 assert main.numSwitch, "Placed the total number of switch topology in \
1091 main.numSwitch"
1092
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001093 main.testName = "Multi To Single Point Intents"
1094 main.case( main.testName + " Test - " + str( main.numCtrls ) +
1095 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -07001096 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001097 " multi point intents using " +\
1098 str( main.numCtrls ) + " node(s) cluster;\n" +\
1099 "Different type of hosts will be tested in " +\
1100 "each step such as IPV4, Dual stack, VLAN etc" +\
1101 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -07001102 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001103
kelvin-onlabb769f562015-07-15 17:05:10 -07001104 main.step( "NOOPTION: Add multi point to single point intents" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001105 stepResult = main.TRUE
1106 hostNames = [ 'h8', 'h16', 'h24' ]
1107 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
1108 'of:0000000000000007/8' ]
1109 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 -07001110 stepResult = main.intentFunction.multiToSingleIntent(
1111 main,
1112 name="NOOPTION",
1113 hostNames=hostNames,
1114 devices=devices,
1115 sw1="s5",
1116 sw2="s2",
1117 expectedLink=18 )
1118
1119 utilities.assert_equals( expect=main.TRUE,
1120 actual=stepResult,
1121 onpass="NOOPTION: Successfully added multi "
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001122 + " point to single point intents" +
1123 " with no match action",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001124 onfail="NOOPTION: Failed to add multi point" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001125 " to single point intents" +
1126 " with no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001127
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001128 main.step( "IPV4: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001129 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001130 stepResult = main.intentFunction.multiToSingleIntent(
1131 main,
1132 name="IPV4",
1133 hostNames=hostNames,
1134 devices=devices,
1135 ports=None,
1136 ethType="IPV4",
1137 macs=macs,
1138 bandwidth="",
1139 lambdaAlloc=False,
1140 ipProto="",
1141 ipAddresses="",
1142 tcp="",
1143 sw1="s5",
1144 sw2="s2",
1145 expectedLink=18 )
1146
1147 utilities.assert_equals( expect=main.TRUE,
1148 actual=stepResult,
1149 onpass="IPV4: Successfully added multi point"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001150 + " to single point intents" +
1151 " with IPV4 type and MAC addresses",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001152 onfail="IPV4: Failed to add multi point" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001153 " to single point intents" +
1154 " with IPV4 type and MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001155
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001156 main.step( "IPV4_2: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001157 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001158 hostNames = [ 'h8', 'h16', 'h24' ]
1159 stepResult = main.intentFunction.multiToSingleIntent(
1160 main,
1161 name="IPV4",
1162 hostNames=hostNames,
1163 ethType="IPV4",
1164 lambdaAlloc=False )
1165
1166 utilities.assert_equals( expect=main.TRUE,
1167 actual=stepResult,
1168 onpass="IPV4_2: Successfully added multi point"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001169 + " to single point intents" +
1170 " with IPV4 type and no MAC addresses",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001171 onfail="IPV4_2: Failed to add multi point" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001172 " to single point intents" +
1173 " with IPV4 type and no MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001174
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001175 main.step( "VLAN: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001176 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001177 hostNames = [ 'h5', 'h13', 'h21' ]
1178 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \
1179 'of:0000000000000007/5' ]
1180 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
1181 stepResult = main.intentFunction.multiToSingleIntent(
1182 main,
1183 name="VLAN",
1184 hostNames=hostNames,
1185 devices=devices,
1186 ports=None,
1187 ethType="IPV4",
1188 macs=macs,
1189 bandwidth="",
1190 lambdaAlloc=False,
1191 ipProto="",
1192 ipAddresses="",
1193 tcp="",
1194 sw1="s5",
1195 sw2="s2",
1196 expectedLink=18 )
1197
1198 utilities.assert_equals( expect=main.TRUE,
1199 actual=stepResult,
1200 onpass="VLAN: Successfully added multi point"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001201 + " to single point intents" +
1202 " with IPV4 type and MAC addresses" +
1203 " in the same VLAN",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001204 onfail="VLAN: Failed to add multi point" +
1205 " to single point intents" )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001206
acsmars1ff5e052015-07-23 11:27:48 -07001207 def CASE5000( self, main ):
1208 """
1209 Will add description in next patch set
acsmars1ff5e052015-07-23 11:27:48 -07001210 """
1211 assert main, "There is no main"
1212 assert main.CLIs, "There is no main.CLIs"
1213 assert main.Mininet1, "Mininet handle should be named Mininet1"
1214 assert main.numSwitch, "Placed the total number of switch topology in \
1215 main.numSwitch"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001216 main.case( "Test host mobility with host intents " )
1217 main.step( " Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07001218 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1219
1220 main.log.info( "Moving h1 from s5 to s6")
1221
1222 main.Mininet1.moveHost( "h1","s5","s6" )
1223
1224 main.intentFunction.getHostsData( main )
1225 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1226
1227 utilities.assert_equals( expect="of:0000000000000006",
1228 actual=h1PostMove,
1229 onpass="Mobility: Successfully moved h1 to s6",
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001230 onfail="Mobility: Failed to moved h1 to s6" +
1231 " to single point intents" +
1232 " with IPV4 type and MAC addresses" +
1233 " in the same VLAN" )
1234
1235 main.step( "IPV4: Add host intents between h1 and h9" )
1236 stepResult = main.TRUE
1237 stepResult = main.intentFunction.hostIntent( main,
1238 onosNode='0',
1239 name='IPV4',
1240 host1='h1',
1241 host2='h9',
1242 host1Id='00:00:00:00:00:01/-1',
1243 host2Id='00:00:00:00:00:09/-1' )
1244
1245 utilities.assert_equals( expect=main.TRUE,
1246 actual=stepResult,
1247 onpass="IPV4: Host intent test successful " +
1248 "between two IPV4 hosts",
1249 onfail="IPV4: Host intent test failed " +
1250 "between two IPV4 hosts")