blob: 21bc88634195f4e02b5b46a4858cfe95b8665d4b [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' ] )
acsmarscfa52272015-08-06 15:21:45 -070049 main.removeIntentSleep = int( main.params[ 'SLEEP' ][ 'removeintent' ] )
Jon Halla3e02432015-07-24 15:55:42 -070050 main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] )
51 main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
52 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
83 copyResult = main.ONOSbench.copyMininetFile( main.topology,
84 main.dependencyPath,
85 main.Mininet1.user_name,
86 main.Mininet1.ip_address )
87 if main.CLIs:
88 stepResult = main.TRUE
89 else:
90 main.log.error( "Did not properly created list of ONOS CLI handle" )
91 stepResult = main.FALSE
92 except Exception as e:
93 main.log.exception(e)
94 main.cleanup()
95 main.exit()
kelvin-onlabd48a68c2015-07-13 16:01:36 -070096
97 utilities.assert_equals( expect=main.TRUE,
98 actual=stepResult,
99 onpass="Successfully construct " +
100 "test variables ",
101 onfail="Failed to construct test variables" )
102
103 if gitPull == 'True':
104 main.step( "Building ONOS in " + gitBranch + " branch" )
105 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
106 stepResult = onosBuildResult
107 utilities.assert_equals( expect=main.TRUE,
108 actual=stepResult,
109 onpass="Successfully compiled " +
110 "latest ONOS",
111 onfail="Failed to compile " +
112 "latest ONOS" )
113 else:
114 main.log.warn( "Did not pull new code so skipping mvn " +
115 "clean install" )
Jon Hall106be082015-07-22 09:53:00 -0700116 main.ONOSbench.getVersion( report=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700117
118 def CASE2( self, main ):
119 """
120 - Set up cell
121 - Create cell file
122 - Set cell file
123 - Verify cell file
124 - Kill ONOS process
125 - Uninstall ONOS cluster
126 - Verify ONOS start up
127 - Install ONOS cluster
128 - Connect to cli
129 """
130
131 # main.scale[ 0 ] determines the current number of ONOS controller
132 main.numCtrls = int( main.scale[ 0 ] )
133
134 main.case( "Starting up " + str( main.numCtrls ) +
135 " node(s) ONOS cluster" )
Jon Hall783bbf92015-07-23 14:33:19 -0700136 main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700137 " node(s) ONOS cluster"
138
139
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700140
141 #kill off all onos processes
142 main.log.info( "Safety check, killing all ONOS processes" +
143 " before initiating enviornment setup" )
144
145 for i in range( main.maxNodes ):
146 main.ONOSbench.onosDie( main.ONOSip[ i ] )
147
148 print "NODE COUNT = ", main.numCtrls
149
150 tempOnosIp = []
151 for i in range( main.numCtrls ):
152 tempOnosIp.append( main.ONOSip[i] )
153
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700154 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
155 "temp", main.Mininet1.ip_address,
156 main.apps, tempOnosIp )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700157
158 main.step( "Apply cell to environment" )
159 cellResult = main.ONOSbench.setCell( "temp" )
160 verifyResult = main.ONOSbench.verifyCell()
161 stepResult = cellResult and verifyResult
162 utilities.assert_equals( expect=main.TRUE,
163 actual=stepResult,
164 onpass="Successfully applied cell to " + \
165 "environment",
166 onfail="Failed to apply cell to environment " )
167
168 main.step( "Creating ONOS package" )
169 packageResult = main.ONOSbench.onosPackage()
170 stepResult = packageResult
171 utilities.assert_equals( expect=main.TRUE,
172 actual=stepResult,
173 onpass="Successfully created ONOS package",
174 onfail="Failed to create ONOS package" )
175
176 time.sleep( main.startUpSleep )
177 main.step( "Uninstalling ONOS package" )
178 onosUninstallResult = main.TRUE
kelvin-onlab5f0d19e2015-08-04 15:21:00 -0700179 for ip in main.ONOSip:
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700180 onosUninstallResult = onosUninstallResult and \
kelvin-onlab5f0d19e2015-08-04 15:21:00 -0700181 main.ONOSbench.onosUninstall( nodeIp=ip )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700182 stepResult = onosUninstallResult
183 utilities.assert_equals( expect=main.TRUE,
184 actual=stepResult,
185 onpass="Successfully uninstalled ONOS package",
186 onfail="Failed to uninstall ONOS package" )
187
188 time.sleep( main.startUpSleep )
189 main.step( "Installing ONOS package" )
190 onosInstallResult = main.TRUE
191 for i in range( main.numCtrls ):
192 onosInstallResult = onosInstallResult and \
193 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
194 stepResult = onosInstallResult
195 utilities.assert_equals( expect=main.TRUE,
196 actual=stepResult,
197 onpass="Successfully installed ONOS package",
198 onfail="Failed to install ONOS package" )
199
200 time.sleep( main.startUpSleep )
201 main.step( "Starting ONOS service" )
202 stopResult = main.TRUE
203 startResult = main.TRUE
204 onosIsUp = main.TRUE
205
206 for i in range( main.numCtrls ):
207 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
208 if onosIsUp == main.TRUE:
209 main.log.report( "ONOS instance is up and ready" )
210 else:
211 main.log.report( "ONOS instance may not be up, stop and " +
212 "start ONOS again " )
213 for i in range( main.numCtrls ):
214 stopResult = stopResult and \
215 main.ONOSbench.onosStop( main.ONOSip[ i ] )
216 for i in range( main.numCtrls ):
217 startResult = startResult and \
218 main.ONOSbench.onosStart( main.ONOSip[ i ] )
219 stepResult = onosIsUp and stopResult and startResult
220 utilities.assert_equals( expect=main.TRUE,
221 actual=stepResult,
222 onpass="ONOS service is ready",
223 onfail="ONOS service did not start properly" )
224
225 main.step( "Start ONOS cli" )
226 cliResult = main.TRUE
227 for i in range( main.numCtrls ):
228 cliResult = cliResult and \
229 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
230 stepResult = cliResult
231 utilities.assert_equals( expect=main.TRUE,
232 actual=stepResult,
233 onpass="Successfully start ONOS cli",
234 onfail="Failed to start ONOS cli" )
235
236 # Remove the first element in main.scale list
237 main.scale.remove( main.scale[ 0 ] )
238
Jon Halla3e02432015-07-24 15:55:42 -0700239 def CASE8( self, main ):
240 """
241 Compare Topo
242 """
243 import json
244
245 main.case( "Compare ONOS Topology view to Mininet topology" )
246 main.caseExplanation = "Compare topology elements between Mininet" +\
247 " and ONOS"
248
249 main.step( "Gathering topology information" )
250 # TODO: add a paramaterized sleep here
251 devicesResults = main.TRUE
252 linksResults = main.TRUE
253 hostsResults = main.TRUE
254 devices = main.topo.getAllDevices( main )
255 hosts = main.topo.getAllHosts( main )
256 ports = main.topo.getAllPorts( main )
257 links = main.topo.getAllLinks( main )
258 clusters = main.topo.getAllClusters( main )
259
260 mnSwitches = main.Mininet1.getSwitches()
261 mnLinks = main.Mininet1.getLinks()
262 mnHosts = main.Mininet1.getHosts()
263
264 main.step( "Conmparing MN topology to ONOS topology" )
265 for controller in range( main.numCtrls ):
266 controllerStr = str( controller + 1 )
267 if devices[ controller ] and ports[ controller ] and\
268 "Error" not in devices[ controller ] and\
269 "Error" not in ports[ controller ]:
270
271 currentDevicesResult = main.Mininet1.compareSwitches(
272 mnSwitches,
273 json.loads( devices[ controller ] ),
274 json.loads( ports[ controller ] ) )
275 else:
276 currentDevicesResult = main.FALSE
277 utilities.assert_equals( expect=main.TRUE,
278 actual=currentDevicesResult,
279 onpass="ONOS" + controllerStr +
280 " Switches view is correct",
281 onfail="ONOS" + controllerStr +
282 " Switches view is incorrect" )
Jon Hall46d48252015-08-03 11:41:16 -0700283 devicesResults = devicesResults and currentDevicesResult
Jon Halla3e02432015-07-24 15:55:42 -0700284
285 if links[ controller ] and "Error" not in links[ controller ]:
286 currentLinksResult = main.Mininet1.compareLinks(
287 mnSwitches, mnLinks,
288 json.loads( links[ controller ] ) )
289 else:
290 currentLinksResult = main.FALSE
291 utilities.assert_equals( expect=main.TRUE,
292 actual=currentLinksResult,
293 onpass="ONOS" + controllerStr +
294 " links view is correct",
295 onfail="ONOS" + controllerStr +
296 " links view is incorrect" )
Jon Hall46d48252015-08-03 11:41:16 -0700297 linksResults = linksResults and currentLinksResult
Jon Halla3e02432015-07-24 15:55:42 -0700298
299 if hosts[ controller ] or "Error" not in hosts[ controller ]:
300 currentHostsResult = main.Mininet1.compareHosts(
301 mnHosts,
302 json.loads( hosts[ controller ] ) )
303 else:
304 currentHostsResult = main.FALSE
305 utilities.assert_equals( expect=main.TRUE,
306 actual=currentHostsResult,
307 onpass="ONOS" + controllerStr +
308 " hosts exist in Mininet",
309 onfail="ONOS" + controllerStr +
310 " hosts don't match Mininet" )
Jon Hall46d48252015-08-03 11:41:16 -0700311 hostsResults = hostsResults and currentHostsResult
312 topoResults = hostsResults and linksResults and devicesResults
313 utilities.assert_equals( expect=main.TRUE,
314 actual=topoResults,
315 onpass="ONOS correctly discovered the topology",
316 onfail="ONOS incorrectly discovered the topology" )
Jon Halla3e02432015-07-24 15:55:42 -0700317
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700318
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700319 def CASE9( self, main ):
320 '''
321 Report errors/warnings/exceptions
322 '''
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700323 main.case( main.testName + " Report - " + str( main.numCtrls ) +
324 " NODE(S) - OF " + main.OFProtocol )
325
326 main.ONOSbench.logReport( main.ONOSip[ 0 ],
327 [ "INFO",
328 "FOLLOWER",
329 "WARN",
330 "flow",
331 "ERROR",
332 "Except" ],
333 "s" )
334
335 main.step( "ERROR report: \n" )
kelvin-onlab5f0d19e2015-08-04 15:21:00 -0700336 for i in range( main.numCtrls ):
337 main.ONOSbench.logReport( main.ONOSip[ i ],
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700338 [ "ERROR" ],
339 "d" )
340
341 main.step( "EXCEPTIONS report: \n" )
342 for i in range( main.numCtrls ):
343 main.ONOSbench.logReport( main.ONOSip[ i ],
344 [ "Except" ],
345 "d" )
346
347 main.step( "WARNING report: \n" )
348 for i in range( main.numCtrls ):
349 main.ONOSbench.logReport( main.ONOSip[ i ],
350 [ "WARN" ],
351 "d" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700352
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700353 def CASE10( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700354 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700355 Start Mininet topology with OF 1.0 switches
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700356 """
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700357 main.OFProtocol = "1.0"
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700358 main.log.report( "Start Mininet topology with OF 1.0 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700359 main.case( "Start Mininet topology with OF 1.0 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700360 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700361 "switches to test intents, exits out if " +\
362 "topology did not start correctly"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700363
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700364 main.step( "Starting Mininet topology with OF 1.0 switches" )
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700365 args = "--switch ovs,protocols=OpenFlow10"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700366 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700367 main.topology,
368 args=args )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700369 stepResult = topoResult
370 utilities.assert_equals( expect=main.TRUE,
371 actual=stepResult,
372 onpass="Successfully loaded topology",
373 onfail="Failed to load topology" )
374 # Exit if topology did not load properly
375 if not topoResult:
376 main.cleanup()
377 main.exit()
378
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700379 def CASE11( self, main ):
380 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700381 Start Mininet topology with OF 1.3 switches
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700382 """
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700383 main.OFProtocol = "1.3"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700384 main.log.report( "Start Mininet topology with OF 1.3 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700385 main.case( "Start Mininet topology with OF 1.3 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700386 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700387 "switches to test intents, exits out if " +\
388 "topology did not start correctly"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700389
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700390 main.step( "Starting Mininet topology with OF 1.3 switches" )
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700391 args = "--switch ovs,protocols=OpenFlow13"
392 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
393 main.topology,
394 args=args )
395 stepResult = topoResult
396 utilities.assert_equals( expect=main.TRUE,
397 actual=stepResult,
398 onpass="Successfully loaded topology",
399 onfail="Failed to load topology" )
400 # Exit if topology did not load properly
401 if not topoResult:
402 main.cleanup()
403 main.exit()
404
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700405 def CASE12( self, main ):
406 """
407 Assign mastership to controllers
408 """
409 import re
410
411 main.case( "Assign switches to controllers" )
412 main.step( "Assigning switches to controllers" )
Jon Hall783bbf92015-07-23 14:33:19 -0700413 main.caseExplanation = "Assign OF " + main.OFProtocol +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700414 " switches to ONOS nodes"
415
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700416 assignResult = main.TRUE
417 switchList = []
418
419 # Creates a list switch name, use getSwitch() function later...
420 for i in range( 1, ( main.numSwitch + 1 ) ):
421 switchList.append( 's' + str( i ) )
422
423 tempONOSip = []
424 for i in range( main.numCtrls ):
425 tempONOSip.append( main.ONOSip[ i ] )
426
427 assignResult = main.Mininet1.assignSwController( sw=switchList,
428 ip=tempONOSip,
429 port='6633' )
430 if not assignResult:
431 main.cleanup()
432 main.exit()
433
434 for i in range( 1, ( main.numSwitch + 1 ) ):
435 response = main.Mininet1.getSwController( "s" + str( i ) )
436 print( "Response is " + str( response ) )
437 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
438 assignResult = assignResult and main.TRUE
439 else:
440 assignResult = main.FALSE
441 stepResult = assignResult
442 utilities.assert_equals( expect=main.TRUE,
443 actual=stepResult,
444 onpass="Successfully assigned switches" +
445 "to controller",
446 onfail="Failed to assign switches to " +
447 "controller" )
448 def CASE13( self, main ):
449 """
450 Discover all hosts and store its data to a dictionary
451 """
452 main.case( "Discover all hosts" )
453
454 stepResult = main.TRUE
455 main.step( "Discover all hosts using pingall " )
456 stepResult = main.intentFunction.getHostsData( main )
457 utilities.assert_equals( expect=main.TRUE,
458 actual=stepResult,
459 onpass="Successfully discovered hosts",
460 onfail="Failed to discover hosts" )
461
462 def CASE14( self, main ):
463 """
464 Stop mininet
465 """
466 main.log.report( "Stop Mininet topology" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700467 main.case( "Stop Mininet topology" )
Jon Hall783bbf92015-07-23 14:33:19 -0700468 main.caseExplanation = "Stopping the current mininet topology " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700469 "to start up fresh"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700470
471 main.step( "Stopping Mininet Topology" )
472 topoResult = main.Mininet1.stopNet( )
473 stepResult = topoResult
474 utilities.assert_equals( expect=main.TRUE,
475 actual=stepResult,
476 onpass="Successfully stop mininet",
477 onfail="Failed to stop mininet" )
478 # Exit if topology did not load properly
479 if not topoResult:
480 main.cleanup()
481 main.exit()
482
kelvin-onlabb769f562015-07-15 17:05:10 -0700483 def CASE1000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700484 """
485 Add host intents between 2 host:
486 - Discover hosts
487 - Add host intents
488 - Check intents
489 - Verify flows
490 - Ping hosts
491 - Reroute
492 - Link down
493 - Verify flows
494 - Check topology
495 - Ping hosts
496 - Link up
497 - Verify flows
498 - Check topology
499 - Ping hosts
500 - Remove intents
501 """
502 import time
503 import json
504 import re
505
506 # Assert variables - These variable's name|format must be followed
507 # if you want to use the wrapper function
508 assert main, "There is no main"
509 assert main.CLIs, "There is no main.CLIs"
510 assert main.Mininet1, "Mininet handle should be named Mininet1"
511 assert main.numSwitch, "Placed the total number of switch topology in \
512 main.numSwitch"
513
acsmarse6b410f2015-07-17 14:39:34 -0700514 intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
515
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700516 main.testName = "Host Intents"
517 main.case( main.testName + " Test - " + str( main.numCtrls ) +
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700518 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700519 main.caseExplanation = "This test case tests Host intents using " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700520 str( main.numCtrls ) + " node(s) cluster;\n" +\
521 "Different type of hosts will be tested in " +\
522 "each step such as IPV4, Dual stack, VLAN " +\
523 "etc;\nThe test will use OF " + main.OFProtocol\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700524 + " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700525
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700526 main.step( "IPV4: Add host intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700527 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700528 stepResult = main.intentFunction.hostIntent( main,
529 onosNode='0',
530 name='IPV4',
531 host1='h1',
532 host2='h9',
533 host1Id='00:00:00:00:00:01/-1',
534 host2Id='00:00:00:00:00:09/-1',
535 sw1='s5',
536 sw2='s2',
537 expectedLink=18 )
538
539 utilities.assert_equals( expect=main.TRUE,
540 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700541 onpass="IPV4: Host intent test successful " +
542 "between two IPV4 hosts",
543 onfail="IPV4: Host intent test failed " +
544 "between two IPV4 hosts")
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700545
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700546 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700547 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700548 stepResult = main.intentFunction.hostIntent( main,
549 name='DUALSTACK',
550 host1='h3',
551 host2='h11',
552 host1Id='00:00:00:00:00:03/-1',
553 host2Id='00:00:00:00:00:0B/-1',
554 sw1='s5',
555 sw2='s2',
556 expectedLink=18 )
557
558 utilities.assert_equals( expect=main.TRUE,
559 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700560 onpass="DUALSTACK: Host intent test " +
561 "successful between two " +
562 "dual stack host using IPV4",
563 onfail="DUALSTACK: Host intent test " +
564 "failed between two" +
565 "dual stack host using IPV4" )
566
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700567
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700568 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700569 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700570 stepResult = main.intentFunction.hostIntent( main,
571 name='DUALSTACK2',
572 host1='h1',
573 host2='h11',
574 sw1='s5',
575 sw2='s2',
576 expectedLink=18 )
577
578 utilities.assert_equals( expect=main.TRUE,
579 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700580 onpass="DUALSTACK2: Host intent test " +
581 "successful between two " +
582 "dual stack host using IPV4",
583 onfail="DUALSTACK2: Host intent test " +
584 "failed between two" +
585 "dual stack host using IPV4" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700586
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700587 main.step( "1HOP: Add host intents between h1 and h3" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700588 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700589 stepResult = main.intentFunction.hostIntent( main,
590 name='1HOP',
591 host1='h1',
592 host2='h3' )
593
594 utilities.assert_equals( expect=main.TRUE,
595 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700596 onpass="1HOP: Host intent test " +
597 "successful between two " +
598 "host using IPV4 in the same switch",
599 onfail="1HOP: Host intent test " +
600 "failed between two" +
601 "host using IPV4 in the same switch" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700602
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700603 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700604 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700605 stepResult = main.intentFunction.hostIntent( main,
606 name='VLAN1',
607 host1='h4',
608 host2='h12',
609 host1Id='00:00:00:00:00:04/100',
610 host2Id='00:00:00:00:00:0C/100',
611 sw1='s5',
612 sw2='s2',
613 expectedLink=18 )
614
615 utilities.assert_equals( expect=main.TRUE,
616 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700617 onpass="VLAN1: Host intent test " +
618 "successful between two " +
619 "host using IPV4 in the same VLAN",
620 onfail="VLAN1: Host intent test " +
621 "failed between two" +
622 "host using IPV4 in the same VLAN" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700623
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700624 main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700625 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700626 stepResult = main.intentFunction.hostIntent( main,
627 name='VLAN2',
628 host1='h13',
629 host2='h20' )
630
631 utilities.assert_equals( expect=main.FALSE,
632 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700633 onpass="VLAN2: Host intent negative test " +
634 "successful between two " +
635 "host using IPV4 in different VLAN",
636 onfail="VLAN2: Host intent negative test " +
637 "failed between two" +
638 "host using IPV4 in different VLAN" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700639
acsmarse6b410f2015-07-17 14:39:34 -0700640
641 intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
642 main.intentFunction.checkLeaderChange( intentLeadersOld,
643 intentLeadersNew )
644
kelvin-onlabb769f562015-07-15 17:05:10 -0700645 def CASE2000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700646 """
647 Add point intents between 2 hosts:
648 - Get device ids | ports
649 - Add point intents
650 - Check intents
651 - Verify flows
652 - Ping hosts
653 - Reroute
654 - Link down
655 - Verify flows
656 - Check topology
657 - Ping hosts
658 - Link up
659 - Verify flows
660 - Check topology
661 - Ping hosts
662 - Remove intents
663 """
664 import time
665 import json
666 import re
667
668 # Assert variables - These variable's name|format must be followed
669 # if you want to use the wrapper function
670 assert main, "There is no main"
671 assert main.CLIs, "There is no main.CLIs"
672 assert main.Mininet1, "Mininet handle should be named Mininet1"
673 assert main.numSwitch, "Placed the total number of switch topology in \
674 main.numSwitch"
675
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700676 main.testName = "Point Intents"
677 main.case( main.testName + " Test - " + str( main.numCtrls ) +
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700678 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700679 main.caseExplanation = "This test case will test point to point" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700680 " intents using " + str( main.numCtrls ) +\
681 " node(s) cluster;\n" +\
682 "Different type of hosts will be tested in " +\
683 "each step such as IPV4, Dual stack, VLAN etc" +\
684 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700685 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700686
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700687 # No option point intents
688 main.step( "NOOPTION: Add point intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700689 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700690 stepResult = main.intentFunction.pointIntent(
691 main,
692 name="NOOPTION",
693 host1="h1",
694 host2="h9",
695 deviceId1="of:0000000000000005/1",
696 deviceId2="of:0000000000000006/1",
697 sw1="s5",
698 sw2="s2",
699 expectedLink=18 )
700
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700701 utilities.assert_equals( expect=main.TRUE,
702 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700703 onpass="NOOPTION: Point intent test " +
704 "successful using no match action",
705 onfail="NOOPTION: Point intent test " +
706 "failed using no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700707
708 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -0700709 main.step( "IPV4: Add point intents between h1 and h9" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700710 stepResult = main.intentFunction.pointIntent(
711 main,
712 name="IPV4",
713 host1="h1",
714 host2="h9",
715 deviceId1="of:0000000000000005/1",
716 deviceId2="of:0000000000000006/1",
717 port1="",
718 port2="",
719 ethType="IPV4",
720 mac1="00:00:00:00:00:01",
721 mac2="00:00:00:00:00:09",
722 bandwidth="",
723 lambdaAlloc=False,
724 ipProto="",
725 ip1="",
726 ip2="",
727 tcp1="",
728 tcp2="",
729 sw1="s5",
730 sw2="s2",
731 expectedLink=18 )
732
733 utilities.assert_equals( expect=main.TRUE,
734 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700735 onpass="IPV4: Point intent test " +
736 "successful using IPV4 type with " +
737 "MAC addresses",
738 onfail="IPV4: Point intent test " +
739 "failed using IPV4 type with " +
740 "MAC addresses" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700741 main.step( "IPV4_2: Add point intents between h1 and h9" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700742 stepResult = main.TRUE
743 stepResult = main.intentFunction.pointIntent(
744 main,
745 name="IPV4_2",
746 host1="h1",
747 host2="h9",
748 deviceId1="of:0000000000000005/1",
749 deviceId2="of:0000000000000006/1",
kelvin-onlabb769f562015-07-15 17:05:10 -0700750 ipProto="",
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700751 ip1="",
752 ip2="",
753 tcp1="",
754 tcp2="",
755 sw1="s5",
756 sw2="s2",
757 expectedLink=18 )
758
759 utilities.assert_equals( expect=main.TRUE,
760 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700761 onpass="IPV4_2: Point intent test " +
762 "successful using IPV4 type with " +
763 "no MAC addresses",
764 onfail="IPV4_2: Point intent test " +
765 "failed using IPV4 type with " +
766 "no MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700767
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700768 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700769 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -0700770 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
771 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab0ad05d12015-07-23 14:21:15 -0700772 try:
773 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/24"
774 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/24"
775 except KeyError:
776 main.log.debug( "Key Error getting IP addresses of h1 | h9 in" +
777 "main.hostsData" )
778 ip1 = main.Mininet1.getIPAddress( 'h1')
779 ip2 = main.Mininet1.getIPAddress( 'h9')
780
kelvin-onlabb769f562015-07-15 17:05:10 -0700781 ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
kelvin-onlab79ce0492015-07-27 16:14:39 -0700782 # Uneccessary, not including this in the selectors
kelvin-onlabb769f562015-07-15 17:05:10 -0700783 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
784 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
785
786 stepResult = main.intentFunction.pointIntent(
787 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700788 name="SDNIP-ICMP",
kelvin-onlabb769f562015-07-15 17:05:10 -0700789 host1="h1",
790 host2="h9",
791 deviceId1="of:0000000000000005/1",
792 deviceId2="of:0000000000000006/1",
793 mac1=mac1,
794 mac2=mac2,
795 ethType="IPV4",
796 ipProto=ipProto,
797 ip1=ip1,
kelvin-onlab79ce0492015-07-27 16:14:39 -0700798 ip2=ip2 )
kelvin-onlabb769f562015-07-15 17:05:10 -0700799
800 utilities.assert_equals( expect=main.TRUE,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700801 actual=stepResult,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700802 onpass="SDNIP-ICMP: Point intent test " +
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700803 "successful using IPV4 type with " +
804 "IP protocol TCP enabled",
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700805 onfail="SDNIP-ICMP: Point intent test " +
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700806 "failed using IPV4 type with " +
807 "IP protocol TCP enabled" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700808
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700809 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700810 stepResult = main.TRUE
811 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
812 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab58dc39e2015-08-06 08:11:09 -0700813 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
814 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlabb769f562015-07-15 17:05:10 -0700815 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
816 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
817 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
818
kelvin-onlab58dc39e2015-08-06 08:11:09 -0700819 stepResult = main.intentFunction.pointIntentTcp(
kelvin-onlabb769f562015-07-15 17:05:10 -0700820 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700821 name="SDNIP-TCP",
kelvin-onlabb769f562015-07-15 17:05:10 -0700822 host1="h1",
823 host2="h9",
824 deviceId1="of:0000000000000005/1",
825 deviceId2="of:0000000000000006/1",
826 mac1=mac1,
827 mac2=mac2,
828 ethType="IPV4",
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700829 ipProto=ipProto,
830 ip1=ip1,
831 ip2=ip2,
832 tcp1=tcp1,
833 tcp2=tcp2 )
kelvin-onlabb769f562015-07-15 17:05:10 -0700834
835 utilities.assert_equals( expect=main.TRUE,
836 actual=stepResult,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700837 onpass="SDNIP-TCP: Point intent test " +
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700838 "successful using IPV4 type with " +
839 "IP protocol ICMP enabled",
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700840 onfail="SDNIP-TCP: Point intent test " +
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700841 "failed using IPV4 type with " +
842 "IP protocol ICMP enabled" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700843
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700844 main.step( "DUALSTACK1: Add point intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700845 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700846 stepResult = main.intentFunction.pointIntent(
847 main,
848 name="DUALSTACK1",
849 host1="h3",
850 host2="h11",
851 deviceId1="of:0000000000000005",
852 deviceId2="of:0000000000000006",
853 port1="3",
854 port2="3",
855 ethType="IPV4",
856 mac1="00:00:00:00:00:03",
857 mac2="00:00:00:00:00:0B",
858 bandwidth="",
859 lambdaAlloc=False,
860 ipProto="",
861 ip1="",
862 ip2="",
863 tcp1="",
864 tcp2="",
865 sw1="s5",
866 sw2="s2",
867 expectedLink=18 )
868
869 utilities.assert_equals( expect=main.TRUE,
870 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700871 onpass="DUALSTACK1: Point intent test " +
872 "successful using IPV4 type with " +
873 "MAC addresses",
874 onfail="DUALSTACK1: Point intent test " +
875 "failed using IPV4 type with " +
876 "MAC addresses" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700877
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700878 main.step( "VLAN: Add point intents between h5 and h21" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700879 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700880 stepResult = main.intentFunction.pointIntent(
881 main,
882 name="VLAN",
883 host1="h5",
884 host2="h21",
885 deviceId1="of:0000000000000005/5",
886 deviceId2="of:0000000000000007/5",
887 port1="",
888 port2="",
889 ethType="IPV4",
890 mac1="00:00:00:00:00:05",
891 mac2="00:00:00:00:00:15",
892 bandwidth="",
893 lambdaAlloc=False,
894 ipProto="",
895 ip1="",
896 ip2="",
897 tcp1="",
898 tcp2="",
899 sw1="s5",
900 sw2="s2",
901 expectedLink=18 )
902
903 utilities.assert_equals( expect=main.TRUE,
904 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700905 onpass="VLAN1: Point intent test " +
906 "successful using IPV4 type with " +
907 "MAC addresses",
908 onfail="VLAN1: Point intent test " +
909 "failed using IPV4 type with " +
910 "MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700911
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700912 main.step( "1HOP: Add point intents between h1 and h3" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700913 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700914 stepResult = main.intentFunction.hostIntent( main,
915 name='1HOP',
916 host1='h1',
917 host2='h3' )
918
919 utilities.assert_equals( expect=main.TRUE,
920 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700921 onpass="1HOP: Point intent test " +
922 "successful using IPV4 type with " +
923 "no MAC addresses",
924 onfail="1HOP: Point intent test " +
925 "failed using IPV4 type with " +
926 "no MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700927
kelvin-onlabb769f562015-07-15 17:05:10 -0700928 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700929 """
930 Add single point to multi point intents
931 - Get device ids
932 - Add single point to multi point intents
933 - Check intents
934 - Verify flows
935 - Ping hosts
936 - Reroute
937 - Link down
938 - Verify flows
939 - Check topology
940 - Ping hosts
941 - Link up
942 - Verify flows
943 - Check topology
944 - Ping hosts
945 - Remove intents
946 """
947 assert main, "There is no main"
948 assert main.CLIs, "There is no main.CLIs"
949 assert main.Mininet1, "Mininet handle should be named Mininet1"
950 assert main.numSwitch, "Placed the total number of switch topology in \
951 main.numSwitch"
952
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700953 main.testName = "Single to Multi Point Intents"
954 main.case( main.testName + " Test - " + str( main.numCtrls ) +
955 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700956 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700957 " multi point intents using " +\
958 str( main.numCtrls ) + " node(s) cluster;\n" +\
959 "Different type of hosts will be tested in " +\
960 "each step such as IPV4, Dual stack, VLAN etc" +\
961 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700962 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700963
kelvin-onlabb769f562015-07-15 17:05:10 -0700964 main.step( "NOOPTION: Add single point to multi point intents" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700965 stepResult = main.TRUE
966 hostNames = [ 'h8', 'h16', 'h24' ]
967 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
968 'of:0000000000000007/8' ]
969 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 -0700970 stepResult = main.intentFunction.singleToMultiIntent(
971 main,
972 name="NOOPTION",
973 hostNames=hostNames,
974 devices=devices,
975 sw1="s5",
976 sw2="s2",
977 expectedLink=18 )
978
979 utilities.assert_equals( expect=main.TRUE,
980 actual=stepResult,
981 onpass="NOOPTION: Successfully added single "
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700982 + " point to multi point intents" +
983 " with no match action",
984 onfail="NOOPTION: Failed to add single point"
985 + " point to multi point intents" +
986 " with no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700987
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700988 main.step( "IPV4: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700989 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700990 stepResult = main.intentFunction.singleToMultiIntent(
991 main,
992 name="IPV4",
993 hostNames=hostNames,
994 devices=devices,
995 ports=None,
996 ethType="IPV4",
997 macs=macs,
998 bandwidth="",
999 lambdaAlloc=False,
1000 ipProto="",
1001 ipAddresses="",
1002 tcp="",
1003 sw1="s5",
1004 sw2="s2",
1005 expectedLink=18 )
1006
1007 utilities.assert_equals( expect=main.TRUE,
1008 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001009 onpass="IPV4: Successfully added single "
1010 + " point to multi point intents" +
1011 " with IPV4 type and MAC addresses",
1012 onfail="IPV4: Failed to add single point"
1013 + " point to multi point intents" +
1014 " with IPV4 type and MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001015
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001016 main.step( "IPV4_2: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001017 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001018 hostNames = [ 'h8', 'h16', 'h24' ]
1019 stepResult = main.intentFunction.singleToMultiIntent(
1020 main,
1021 name="IPV4",
1022 hostNames=hostNames,
1023 ethType="IPV4",
1024 lambdaAlloc=False )
1025
1026 utilities.assert_equals( expect=main.TRUE,
1027 actual=stepResult,
1028 onpass="IPV4_2: Successfully added single "
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001029 + " point to multi point intents" +
1030 " with IPV4 type and no MAC addresses",
1031 onfail="IPV4_2: Failed to add single point"
1032 + " point to multi point intents" +
1033 " with IPV4 type and no MAC addresses" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001034
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001035 main.step( "VLAN: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001036 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001037 hostNames = [ 'h4', 'h12', 'h20' ]
1038 devices = [ 'of:0000000000000005/4', 'of:0000000000000006/4', \
1039 'of:0000000000000007/4' ]
1040 macs = [ '00:00:00:00:00:04', '00:00:00:00:00:0C', '00:00:00:00:00:14' ]
1041 stepResult = main.intentFunction.singleToMultiIntent(
1042 main,
1043 name="VLAN",
1044 hostNames=hostNames,
1045 devices=devices,
1046 ports=None,
1047 ethType="IPV4",
1048 macs=macs,
1049 bandwidth="",
1050 lambdaAlloc=False,
1051 ipProto="",
1052 ipAddresses="",
1053 tcp="",
1054 sw1="s5",
1055 sw2="s2",
1056 expectedLink=18 )
1057
1058 utilities.assert_equals( expect=main.TRUE,
1059 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001060 onpass="VLAN: Successfully added single "
1061 + " point to multi point intents" +
1062 " with IPV4 type and MAC addresses" +
1063 " in the same VLAN",
1064 onfail="VLAN: Failed to add single point"
1065 + " point to multi point intents" +
1066 " with IPV4 type and MAC addresses" +
1067 " in the same VLAN")
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001068
kelvin-onlabb769f562015-07-15 17:05:10 -07001069 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001070 """
1071 Add multi point to single point intents
1072 - Get device ids
1073 - Add multi point to single point intents
1074 - Check intents
1075 - Verify flows
1076 - Ping hosts
1077 - Reroute
1078 - Link down
1079 - Verify flows
1080 - Check topology
1081 - Ping hosts
1082 - Link up
1083 - Verify flows
1084 - Check topology
1085 - Ping hosts
1086 - Remove intents
1087 """
1088 assert main, "There is no main"
1089 assert main.CLIs, "There is no main.CLIs"
1090 assert main.Mininet1, "Mininet handle should be named Mininet1"
1091 assert main.numSwitch, "Placed the total number of switch topology in \
1092 main.numSwitch"
1093
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001094 main.testName = "Multi To Single Point Intents"
1095 main.case( main.testName + " Test - " + str( main.numCtrls ) +
1096 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -07001097 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001098 " multi point intents using " +\
1099 str( main.numCtrls ) + " node(s) cluster;\n" +\
1100 "Different type of hosts will be tested in " +\
1101 "each step such as IPV4, Dual stack, VLAN etc" +\
1102 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -07001103 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001104
kelvin-onlabb769f562015-07-15 17:05:10 -07001105 main.step( "NOOPTION: Add multi point to single point intents" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001106 stepResult = main.TRUE
1107 hostNames = [ 'h8', 'h16', 'h24' ]
1108 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
1109 'of:0000000000000007/8' ]
1110 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 -07001111 stepResult = main.intentFunction.multiToSingleIntent(
1112 main,
1113 name="NOOPTION",
1114 hostNames=hostNames,
1115 devices=devices,
1116 sw1="s5",
1117 sw2="s2",
1118 expectedLink=18 )
1119
1120 utilities.assert_equals( expect=main.TRUE,
1121 actual=stepResult,
1122 onpass="NOOPTION: Successfully added multi "
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001123 + " point to single point intents" +
1124 " with no match action",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001125 onfail="NOOPTION: Failed to add multi point" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001126 " to single point intents" +
1127 " with no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001128
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001129 main.step( "IPV4: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001130 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001131 stepResult = main.intentFunction.multiToSingleIntent(
1132 main,
1133 name="IPV4",
1134 hostNames=hostNames,
1135 devices=devices,
1136 ports=None,
1137 ethType="IPV4",
1138 macs=macs,
1139 bandwidth="",
1140 lambdaAlloc=False,
1141 ipProto="",
1142 ipAddresses="",
1143 tcp="",
1144 sw1="s5",
1145 sw2="s2",
1146 expectedLink=18 )
1147
1148 utilities.assert_equals( expect=main.TRUE,
1149 actual=stepResult,
1150 onpass="IPV4: Successfully added multi point"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001151 + " to single point intents" +
1152 " with IPV4 type and MAC addresses",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001153 onfail="IPV4: Failed to add multi point" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001154 " to single point intents" +
1155 " with IPV4 type and MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001156
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001157 main.step( "IPV4_2: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001158 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001159 hostNames = [ 'h8', 'h16', 'h24' ]
1160 stepResult = main.intentFunction.multiToSingleIntent(
1161 main,
1162 name="IPV4",
1163 hostNames=hostNames,
1164 ethType="IPV4",
1165 lambdaAlloc=False )
1166
1167 utilities.assert_equals( expect=main.TRUE,
1168 actual=stepResult,
1169 onpass="IPV4_2: Successfully added multi point"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001170 + " to single point intents" +
1171 " with IPV4 type and no MAC addresses",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001172 onfail="IPV4_2: Failed to add multi point" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001173 " to single point intents" +
1174 " with IPV4 type and no MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001175
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001176 main.step( "VLAN: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001177 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001178 hostNames = [ 'h5', 'h13', 'h21' ]
1179 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \
1180 'of:0000000000000007/5' ]
1181 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
1182 stepResult = main.intentFunction.multiToSingleIntent(
1183 main,
1184 name="VLAN",
1185 hostNames=hostNames,
1186 devices=devices,
1187 ports=None,
1188 ethType="IPV4",
1189 macs=macs,
1190 bandwidth="",
1191 lambdaAlloc=False,
1192 ipProto="",
1193 ipAddresses="",
1194 tcp="",
1195 sw1="s5",
1196 sw2="s2",
1197 expectedLink=18 )
1198
1199 utilities.assert_equals( expect=main.TRUE,
1200 actual=stepResult,
1201 onpass="VLAN: Successfully added multi point"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001202 + " to single point intents" +
1203 " with IPV4 type and MAC addresses" +
1204 " in the same VLAN",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001205 onfail="VLAN: Failed to add multi point" +
1206 " to single point intents" )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001207
acsmars1ff5e052015-07-23 11:27:48 -07001208 def CASE5000( self, main ):
1209 """
1210 Will add description in next patch set
acsmars1ff5e052015-07-23 11:27:48 -07001211 """
1212 assert main, "There is no main"
1213 assert main.CLIs, "There is no main.CLIs"
1214 assert main.Mininet1, "Mininet handle should be named Mininet1"
1215 assert main.numSwitch, "Placed the total number of switch topology in \
1216 main.numSwitch"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001217 main.case( "Test host mobility with host intents " )
1218 main.step( " Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07001219 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1220
1221 main.log.info( "Moving h1 from s5 to s6")
1222
1223 main.Mininet1.moveHost( "h1","s5","s6" )
1224
1225 main.intentFunction.getHostsData( main )
1226 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1227
1228 utilities.assert_equals( expect="of:0000000000000006",
1229 actual=h1PostMove,
1230 onpass="Mobility: Successfully moved h1 to s6",
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001231 onfail="Mobility: Failed to moved h1 to s6" +
1232 " to single point intents" +
1233 " with IPV4 type and MAC addresses" +
1234 " in the same VLAN" )
1235
1236 main.step( "IPV4: Add host intents between h1 and h9" )
1237 stepResult = main.TRUE
1238 stepResult = main.intentFunction.hostIntent( main,
1239 onosNode='0',
1240 name='IPV4',
1241 host1='h1',
1242 host2='h9',
1243 host1Id='00:00:00:00:00:01/-1',
1244 host2Id='00:00:00:00:00:09/-1' )
1245
1246 utilities.assert_equals( expect=main.TRUE,
1247 actual=stepResult,
1248 onpass="IPV4: Host intent test successful " +
1249 "between two IPV4 hosts",
1250 onfail="IPV4: Host intent test failed " +
1251 "between two IPV4 hosts")