blob: d1e91a7b584dec756ac5bbedd612b9aaf1c1414e [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-onlabd48a68c2015-07-13 16:01:36 -0700317 def CASE9( self, main ):
318 '''
319 Report errors/warnings/exceptions
320 '''
321 main.log.info( "Error report: \n" )
kelvin-onlab5f0d19e2015-08-04 15:21:00 -0700322 for i in range( main.numCtrls ):
323 main.ONOSbench.logReport( main.ONOSip[ i ],
324 [ "INFO", "FOLLOWER", "WARN", "flow", "ERROR" , "Except" ],
325 "s" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700326
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700327 def CASE10( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700328 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700329 Start Mininet topology with OF 1.0 switches
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700330 """
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700331 main.OFProtocol = "1.0"
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700332 main.log.report( "Start Mininet topology with OF 1.0 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700333 main.case( "Start Mininet topology with OF 1.0 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700334 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700335 "switches to test intents, exits out if " +\
336 "topology did not start correctly"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700337
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700338 main.step( "Starting Mininet topology with OF 1.0 switches" )
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700339 args = "--switch ovs,protocols=OpenFlow10"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700340 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700341 main.topology,
342 args=args )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700343 stepResult = topoResult
344 utilities.assert_equals( expect=main.TRUE,
345 actual=stepResult,
346 onpass="Successfully loaded topology",
347 onfail="Failed to load topology" )
348 # Exit if topology did not load properly
349 if not topoResult:
350 main.cleanup()
351 main.exit()
352
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700353 def CASE11( self, main ):
354 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700355 Start Mininet topology with OF 1.3 switches
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700356 """
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700357 main.OFProtocol = "1.3"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700358 main.log.report( "Start Mininet topology with OF 1.3 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700359 main.case( "Start Mininet topology with OF 1.3 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700360 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700361 "switches to test intents, exits out if " +\
362 "topology did not start correctly"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700363
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700364 main.step( "Starting Mininet topology with OF 1.3 switches" )
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700365 args = "--switch ovs,protocols=OpenFlow13"
366 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
367 main.topology,
368 args=args )
369 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-onlabd48a68c2015-07-13 16:01:36 -0700379 def CASE12( self, main ):
380 """
381 Assign mastership to controllers
382 """
383 import re
384
385 main.case( "Assign switches to controllers" )
386 main.step( "Assigning switches to controllers" )
Jon Hall783bbf92015-07-23 14:33:19 -0700387 main.caseExplanation = "Assign OF " + main.OFProtocol +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700388 " switches to ONOS nodes"
389
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700390 assignResult = main.TRUE
391 switchList = []
392
393 # Creates a list switch name, use getSwitch() function later...
394 for i in range( 1, ( main.numSwitch + 1 ) ):
395 switchList.append( 's' + str( i ) )
396
397 tempONOSip = []
398 for i in range( main.numCtrls ):
399 tempONOSip.append( main.ONOSip[ i ] )
400
401 assignResult = main.Mininet1.assignSwController( sw=switchList,
402 ip=tempONOSip,
403 port='6633' )
404 if not assignResult:
405 main.cleanup()
406 main.exit()
407
408 for i in range( 1, ( main.numSwitch + 1 ) ):
409 response = main.Mininet1.getSwController( "s" + str( i ) )
410 print( "Response is " + str( response ) )
411 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
412 assignResult = assignResult and main.TRUE
413 else:
414 assignResult = main.FALSE
415 stepResult = assignResult
416 utilities.assert_equals( expect=main.TRUE,
417 actual=stepResult,
418 onpass="Successfully assigned switches" +
419 "to controller",
420 onfail="Failed to assign switches to " +
421 "controller" )
422 def CASE13( self, main ):
423 """
424 Discover all hosts and store its data to a dictionary
425 """
426 main.case( "Discover all hosts" )
427
428 stepResult = main.TRUE
429 main.step( "Discover all hosts using pingall " )
430 stepResult = main.intentFunction.getHostsData( main )
431 utilities.assert_equals( expect=main.TRUE,
432 actual=stepResult,
433 onpass="Successfully discovered hosts",
434 onfail="Failed to discover hosts" )
435
436 def CASE14( self, main ):
437 """
438 Stop mininet
439 """
440 main.log.report( "Stop Mininet topology" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700441 main.case( "Stop Mininet topology" )
Jon Hall783bbf92015-07-23 14:33:19 -0700442 main.caseExplanation = "Stopping the current mininet topology " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700443 "to start up fresh"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700444
445 main.step( "Stopping Mininet Topology" )
446 topoResult = main.Mininet1.stopNet( )
447 stepResult = topoResult
448 utilities.assert_equals( expect=main.TRUE,
449 actual=stepResult,
450 onpass="Successfully stop mininet",
451 onfail="Failed to stop mininet" )
452 # Exit if topology did not load properly
453 if not topoResult:
454 main.cleanup()
455 main.exit()
456
kelvin-onlabb769f562015-07-15 17:05:10 -0700457 def CASE1000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700458 """
459 Add host intents between 2 host:
460 - Discover hosts
461 - Add host intents
462 - Check intents
463 - Verify flows
464 - Ping hosts
465 - Reroute
466 - Link down
467 - Verify flows
468 - Check topology
469 - Ping hosts
470 - Link up
471 - Verify flows
472 - Check topology
473 - Ping hosts
474 - Remove intents
475 """
476 import time
477 import json
478 import re
479
480 # Assert variables - These variable's name|format must be followed
481 # if you want to use the wrapper function
482 assert main, "There is no main"
483 assert main.CLIs, "There is no main.CLIs"
484 assert main.Mininet1, "Mininet handle should be named Mininet1"
485 assert main.numSwitch, "Placed the total number of switch topology in \
486 main.numSwitch"
487
acsmarse6b410f2015-07-17 14:39:34 -0700488 intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
489
kelvin-onlab825b57d2015-07-24 13:43:59 -0700490 main.case( "Host Intents Test - " + str( main.numCtrls ) +
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700491 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700492 main.caseExplanation = "This test case tests Host intents using " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700493 str( main.numCtrls ) + " node(s) cluster;\n" +\
494 "Different type of hosts will be tested in " +\
495 "each step such as IPV4, Dual stack, VLAN " +\
496 "etc;\nThe test will use OF " + main.OFProtocol\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700497 + " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700498
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700499 main.step( "IPV4: Add host intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700500 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700501 stepResult = main.intentFunction.hostIntent( main,
502 onosNode='0',
503 name='IPV4',
504 host1='h1',
505 host2='h9',
506 host1Id='00:00:00:00:00:01/-1',
507 host2Id='00:00:00:00:00:09/-1',
508 sw1='s5',
509 sw2='s2',
510 expectedLink=18 )
511
512 utilities.assert_equals( expect=main.TRUE,
513 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700514 onpass="IPV4: Host intent test successful " +
515 "between two IPV4 hosts",
516 onfail="IPV4: Host intent test failed " +
517 "between two IPV4 hosts")
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700518
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700519 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700520 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700521 stepResult = main.intentFunction.hostIntent( main,
522 name='DUALSTACK',
523 host1='h3',
524 host2='h11',
525 host1Id='00:00:00:00:00:03/-1',
526 host2Id='00:00:00:00:00:0B/-1',
527 sw1='s5',
528 sw2='s2',
529 expectedLink=18 )
530
531 utilities.assert_equals( expect=main.TRUE,
532 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700533 onpass="DUALSTACK: Host intent test " +
534 "successful between two " +
535 "dual stack host using IPV4",
536 onfail="DUALSTACK: Host intent test " +
537 "failed between two" +
538 "dual stack host using IPV4" )
539
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700540
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700541 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700542 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700543 stepResult = main.intentFunction.hostIntent( main,
544 name='DUALSTACK2',
545 host1='h1',
546 host2='h11',
547 sw1='s5',
548 sw2='s2',
549 expectedLink=18 )
550
551 utilities.assert_equals( expect=main.TRUE,
552 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700553 onpass="DUALSTACK2: Host intent test " +
554 "successful between two " +
555 "dual stack host using IPV4",
556 onfail="DUALSTACK2: Host intent test " +
557 "failed between two" +
558 "dual stack host using IPV4" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700559
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700560 main.step( "1HOP: Add host intents between h1 and h3" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700561 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700562 stepResult = main.intentFunction.hostIntent( main,
563 name='1HOP',
564 host1='h1',
565 host2='h3' )
566
567 utilities.assert_equals( expect=main.TRUE,
568 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700569 onpass="1HOP: Host intent test " +
570 "successful between two " +
571 "host using IPV4 in the same switch",
572 onfail="1HOP: Host intent test " +
573 "failed between two" +
574 "host using IPV4 in the same switch" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700575
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700576 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700577 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700578 stepResult = main.intentFunction.hostIntent( main,
579 name='VLAN1',
580 host1='h4',
581 host2='h12',
582 host1Id='00:00:00:00:00:04/100',
583 host2Id='00:00:00:00:00:0C/100',
584 sw1='s5',
585 sw2='s2',
586 expectedLink=18 )
587
588 utilities.assert_equals( expect=main.TRUE,
589 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700590 onpass="VLAN1: Host intent test " +
591 "successful between two " +
592 "host using IPV4 in the same VLAN",
593 onfail="VLAN1: Host intent test " +
594 "failed between two" +
595 "host using IPV4 in the same VLAN" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700596
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700597 main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700598 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700599 stepResult = main.intentFunction.hostIntent( main,
600 name='VLAN2',
601 host1='h13',
602 host2='h20' )
603
604 utilities.assert_equals( expect=main.FALSE,
605 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700606 onpass="VLAN2: Host intent negative test " +
607 "successful between two " +
608 "host using IPV4 in different VLAN",
609 onfail="VLAN2: Host intent negative test " +
610 "failed between two" +
611 "host using IPV4 in different VLAN" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700612
acsmarse6b410f2015-07-17 14:39:34 -0700613
614 intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
615 main.intentFunction.checkLeaderChange( intentLeadersOld,
616 intentLeadersNew )
617
kelvin-onlabb769f562015-07-15 17:05:10 -0700618 def CASE2000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700619 """
620 Add point intents between 2 hosts:
621 - Get device ids | ports
622 - Add point intents
623 - Check intents
624 - Verify flows
625 - Ping hosts
626 - Reroute
627 - Link down
628 - Verify flows
629 - Check topology
630 - Ping hosts
631 - Link up
632 - Verify flows
633 - Check topology
634 - Ping hosts
635 - Remove intents
636 """
637 import time
638 import json
639 import re
640
641 # Assert variables - These variable's name|format must be followed
642 # if you want to use the wrapper function
643 assert main, "There is no main"
644 assert main.CLIs, "There is no main.CLIs"
645 assert main.Mininet1, "Mininet handle should be named Mininet1"
646 assert main.numSwitch, "Placed the total number of switch topology in \
647 main.numSwitch"
648
kelvin-onlab825b57d2015-07-24 13:43:59 -0700649 main.case( "Point Intents Test - " + str( main.numCtrls ) +
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700650 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700651 main.caseExplanation = "This test case will test point to point" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700652 " intents using " + str( main.numCtrls ) +\
653 " node(s) cluster;\n" +\
654 "Different type of hosts will be tested in " +\
655 "each step such as IPV4, Dual stack, VLAN etc" +\
656 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700657 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700658
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700659 # No option point intents
660 main.step( "NOOPTION: Add point intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700661 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700662 stepResult = main.intentFunction.pointIntent(
663 main,
664 name="NOOPTION",
665 host1="h1",
666 host2="h9",
667 deviceId1="of:0000000000000005/1",
668 deviceId2="of:0000000000000006/1",
669 sw1="s5",
670 sw2="s2",
671 expectedLink=18 )
672
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700673 utilities.assert_equals( expect=main.TRUE,
674 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700675 onpass="NOOPTION: Point intent test " +
676 "successful using no match action",
677 onfail="NOOPTION: Point intent test " +
678 "failed using no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700679
680 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -0700681 main.step( "IPV4: Add point intents between h1 and h9" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700682 stepResult = main.intentFunction.pointIntent(
683 main,
684 name="IPV4",
685 host1="h1",
686 host2="h9",
687 deviceId1="of:0000000000000005/1",
688 deviceId2="of:0000000000000006/1",
689 port1="",
690 port2="",
691 ethType="IPV4",
692 mac1="00:00:00:00:00:01",
693 mac2="00:00:00:00:00:09",
694 bandwidth="",
695 lambdaAlloc=False,
696 ipProto="",
697 ip1="",
698 ip2="",
699 tcp1="",
700 tcp2="",
701 sw1="s5",
702 sw2="s2",
703 expectedLink=18 )
704
705 utilities.assert_equals( expect=main.TRUE,
706 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700707 onpass="IPV4: Point intent test " +
708 "successful using IPV4 type with " +
709 "MAC addresses",
710 onfail="IPV4: Point intent test " +
711 "failed using IPV4 type with " +
712 "MAC addresses" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700713 main.step( "IPV4_2: Add point intents between h1 and h9" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700714 stepResult = main.TRUE
715 stepResult = main.intentFunction.pointIntent(
716 main,
717 name="IPV4_2",
718 host1="h1",
719 host2="h9",
720 deviceId1="of:0000000000000005/1",
721 deviceId2="of:0000000000000006/1",
kelvin-onlabb769f562015-07-15 17:05:10 -0700722 ipProto="",
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700723 ip1="",
724 ip2="",
725 tcp1="",
726 tcp2="",
727 sw1="s5",
728 sw2="s2",
729 expectedLink=18 )
730
731 utilities.assert_equals( expect=main.TRUE,
732 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700733 onpass="IPV4_2: Point intent test " +
734 "successful using IPV4 type with " +
735 "no MAC addresses",
736 onfail="IPV4_2: Point intent test " +
737 "failed using IPV4 type with " +
738 "no MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700739
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700740 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700741 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -0700742 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
743 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab0ad05d12015-07-23 14:21:15 -0700744 try:
745 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/24"
746 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/24"
747 except KeyError:
748 main.log.debug( "Key Error getting IP addresses of h1 | h9 in" +
749 "main.hostsData" )
750 ip1 = main.Mininet1.getIPAddress( 'h1')
751 ip2 = main.Mininet1.getIPAddress( 'h9')
752
kelvin-onlabb769f562015-07-15 17:05:10 -0700753 ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
kelvin-onlab79ce0492015-07-27 16:14:39 -0700754 # Uneccessary, not including this in the selectors
kelvin-onlabb769f562015-07-15 17:05:10 -0700755 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
756 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
757
758 stepResult = main.intentFunction.pointIntent(
759 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700760 name="SDNIP-ICMP",
kelvin-onlabb769f562015-07-15 17:05:10 -0700761 host1="h1",
762 host2="h9",
763 deviceId1="of:0000000000000005/1",
764 deviceId2="of:0000000000000006/1",
765 mac1=mac1,
766 mac2=mac2,
767 ethType="IPV4",
768 ipProto=ipProto,
769 ip1=ip1,
kelvin-onlab79ce0492015-07-27 16:14:39 -0700770 ip2=ip2 )
kelvin-onlabb769f562015-07-15 17:05:10 -0700771
772 utilities.assert_equals( expect=main.TRUE,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700773 actual=stepResult,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700774 onpass="SDNIP-ICMP: Point intent test " +
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700775 "successful using IPV4 type with " +
776 "IP protocol TCP enabled",
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700777 onfail="SDNIP-ICMP: Point intent test " +
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700778 "failed using IPV4 type with " +
779 "IP protocol TCP enabled" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700780
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700781 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700782 stepResult = main.TRUE
783 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
784 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
785 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/24"
786 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/24"
787 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
788 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
789 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
790
791 stepResult = main.intentFunction.pointIntent(
792 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700793 name="SDNIP-TCP",
kelvin-onlabb769f562015-07-15 17:05:10 -0700794 host1="h1",
795 host2="h9",
796 deviceId1="of:0000000000000005/1",
797 deviceId2="of:0000000000000006/1",
798 mac1=mac1,
799 mac2=mac2,
800 ethType="IPV4",
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700801 ipProto=ipProto,
802 ip1=ip1,
803 ip2=ip2,
804 tcp1=tcp1,
805 tcp2=tcp2 )
kelvin-onlabb769f562015-07-15 17:05:10 -0700806
807 utilities.assert_equals( expect=main.TRUE,
808 actual=stepResult,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700809 onpass="SDNIP-TCP: Point intent test " +
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700810 "successful using IPV4 type with " +
811 "IP protocol ICMP enabled",
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700812 onfail="SDNIP-TCP: Point intent test " +
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700813 "failed using IPV4 type with " +
814 "IP protocol ICMP enabled" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700815
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700816 main.step( "DUALSTACK1: Add point intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700817 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700818 stepResult = main.intentFunction.pointIntent(
819 main,
820 name="DUALSTACK1",
821 host1="h3",
822 host2="h11",
823 deviceId1="of:0000000000000005",
824 deviceId2="of:0000000000000006",
825 port1="3",
826 port2="3",
827 ethType="IPV4",
828 mac1="00:00:00:00:00:03",
829 mac2="00:00:00:00:00:0B",
830 bandwidth="",
831 lambdaAlloc=False,
832 ipProto="",
833 ip1="",
834 ip2="",
835 tcp1="",
836 tcp2="",
837 sw1="s5",
838 sw2="s2",
839 expectedLink=18 )
840
841 utilities.assert_equals( expect=main.TRUE,
842 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700843 onpass="DUALSTACK1: Point intent test " +
844 "successful using IPV4 type with " +
845 "MAC addresses",
846 onfail="DUALSTACK1: Point intent test " +
847 "failed using IPV4 type with " +
848 "MAC addresses" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700849
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700850 main.step( "VLAN: Add point intents between h5 and h21" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700851 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700852 stepResult = main.intentFunction.pointIntent(
853 main,
854 name="VLAN",
855 host1="h5",
856 host2="h21",
857 deviceId1="of:0000000000000005/5",
858 deviceId2="of:0000000000000007/5",
859 port1="",
860 port2="",
861 ethType="IPV4",
862 mac1="00:00:00:00:00:05",
863 mac2="00:00:00:00:00:15",
864 bandwidth="",
865 lambdaAlloc=False,
866 ipProto="",
867 ip1="",
868 ip2="",
869 tcp1="",
870 tcp2="",
871 sw1="s5",
872 sw2="s2",
873 expectedLink=18 )
874
875 utilities.assert_equals( expect=main.TRUE,
876 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700877 onpass="VLAN1: Point intent test " +
878 "successful using IPV4 type with " +
879 "MAC addresses",
880 onfail="VLAN1: Point intent test " +
881 "failed using IPV4 type with " +
882 "MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700883
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700884 main.step( "1HOP: Add point intents between h1 and h3" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700885 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700886 stepResult = main.intentFunction.hostIntent( main,
887 name='1HOP',
888 host1='h1',
889 host2='h3' )
890
891 utilities.assert_equals( expect=main.TRUE,
892 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700893 onpass="1HOP: Point intent test " +
894 "successful using IPV4 type with " +
895 "no MAC addresses",
896 onfail="1HOP: Point intent test " +
897 "failed using IPV4 type with " +
898 "no MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700899
kelvin-onlabb769f562015-07-15 17:05:10 -0700900 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700901 """
902 Add single point to multi point intents
903 - Get device ids
904 - Add single point to multi point intents
905 - Check intents
906 - Verify flows
907 - Ping hosts
908 - Reroute
909 - Link down
910 - Verify flows
911 - Check topology
912 - Ping hosts
913 - Link up
914 - Verify flows
915 - Check topology
916 - Ping hosts
917 - Remove intents
918 """
919 assert main, "There is no main"
920 assert main.CLIs, "There is no main.CLIs"
921 assert main.Mininet1, "Mininet handle should be named Mininet1"
922 assert main.numSwitch, "Placed the total number of switch topology in \
923 main.numSwitch"
924
kelvin-onlab825b57d2015-07-24 13:43:59 -0700925 main.case( "Single To Multi Point Intents Test - " +
kelvin-onlabe5c1ada2015-07-24 11:49:40 -0700926 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700927 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700928 " multi point intents using " +\
929 str( main.numCtrls ) + " node(s) cluster;\n" +\
930 "Different type of hosts will be tested in " +\
931 "each step such as IPV4, Dual stack, VLAN etc" +\
932 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700933 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700934
kelvin-onlabb769f562015-07-15 17:05:10 -0700935 main.step( "NOOPTION: Add single point to multi point intents" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700936 stepResult = main.TRUE
937 hostNames = [ 'h8', 'h16', 'h24' ]
938 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
939 'of:0000000000000007/8' ]
940 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 -0700941 stepResult = main.intentFunction.singleToMultiIntent(
942 main,
943 name="NOOPTION",
944 hostNames=hostNames,
945 devices=devices,
946 sw1="s5",
947 sw2="s2",
948 expectedLink=18 )
949
950 utilities.assert_equals( expect=main.TRUE,
951 actual=stepResult,
952 onpass="NOOPTION: Successfully added single "
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700953 + " point to multi point intents" +
954 " with no match action",
955 onfail="NOOPTION: Failed to add single point"
956 + " point to multi point intents" +
957 " with no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700958
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700959 main.step( "IPV4: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700960 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700961 stepResult = main.intentFunction.singleToMultiIntent(
962 main,
963 name="IPV4",
964 hostNames=hostNames,
965 devices=devices,
966 ports=None,
967 ethType="IPV4",
968 macs=macs,
969 bandwidth="",
970 lambdaAlloc=False,
971 ipProto="",
972 ipAddresses="",
973 tcp="",
974 sw1="s5",
975 sw2="s2",
976 expectedLink=18 )
977
978 utilities.assert_equals( expect=main.TRUE,
979 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700980 onpass="IPV4: Successfully added single "
981 + " point to multi point intents" +
982 " with IPV4 type and MAC addresses",
983 onfail="IPV4: Failed to add single point"
984 + " point to multi point intents" +
985 " with IPV4 type and MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700986
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700987 main.step( "IPV4_2: 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 hostNames = [ 'h8', 'h16', 'h24' ]
990 stepResult = main.intentFunction.singleToMultiIntent(
991 main,
992 name="IPV4",
993 hostNames=hostNames,
994 ethType="IPV4",
995 lambdaAlloc=False )
996
997 utilities.assert_equals( expect=main.TRUE,
998 actual=stepResult,
999 onpass="IPV4_2: Successfully added single "
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001000 + " point to multi point intents" +
1001 " with IPV4 type and no MAC addresses",
1002 onfail="IPV4_2: Failed to add single point"
1003 + " point to multi point intents" +
1004 " with IPV4 type and no MAC addresses" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001005
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001006 main.step( "VLAN: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001007 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001008 hostNames = [ 'h4', 'h12', 'h20' ]
1009 devices = [ 'of:0000000000000005/4', 'of:0000000000000006/4', \
1010 'of:0000000000000007/4' ]
1011 macs = [ '00:00:00:00:00:04', '00:00:00:00:00:0C', '00:00:00:00:00:14' ]
1012 stepResult = main.intentFunction.singleToMultiIntent(
1013 main,
1014 name="VLAN",
1015 hostNames=hostNames,
1016 devices=devices,
1017 ports=None,
1018 ethType="IPV4",
1019 macs=macs,
1020 bandwidth="",
1021 lambdaAlloc=False,
1022 ipProto="",
1023 ipAddresses="",
1024 tcp="",
1025 sw1="s5",
1026 sw2="s2",
1027 expectedLink=18 )
1028
1029 utilities.assert_equals( expect=main.TRUE,
1030 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001031 onpass="VLAN: Successfully added single "
1032 + " point to multi point intents" +
1033 " with IPV4 type and MAC addresses" +
1034 " in the same VLAN",
1035 onfail="VLAN: Failed to add single point"
1036 + " point to multi point intents" +
1037 " with IPV4 type and MAC addresses" +
1038 " in the same VLAN")
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001039
kelvin-onlabb769f562015-07-15 17:05:10 -07001040 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001041 """
1042 Add multi point to single point intents
1043 - Get device ids
1044 - Add multi point to single point intents
1045 - Check intents
1046 - Verify flows
1047 - Ping hosts
1048 - Reroute
1049 - Link down
1050 - Verify flows
1051 - Check topology
1052 - Ping hosts
1053 - Link up
1054 - Verify flows
1055 - Check topology
1056 - Ping hosts
1057 - Remove intents
1058 """
1059 assert main, "There is no main"
1060 assert main.CLIs, "There is no main.CLIs"
1061 assert main.Mininet1, "Mininet handle should be named Mininet1"
1062 assert main.numSwitch, "Placed the total number of switch topology in \
1063 main.numSwitch"
1064
kelvin-onlab825b57d2015-07-24 13:43:59 -07001065 main.case( "Multi To Single Point Intents Test - " +
kelvin-onlabe5c1ada2015-07-24 11:49:40 -07001066 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -07001067 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001068 " multi point intents using " +\
1069 str( main.numCtrls ) + " node(s) cluster;\n" +\
1070 "Different type of hosts will be tested in " +\
1071 "each step such as IPV4, Dual stack, VLAN etc" +\
1072 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -07001073 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001074
kelvin-onlabb769f562015-07-15 17:05:10 -07001075 main.step( "NOOPTION: Add multi point to single point intents" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001076 stepResult = main.TRUE
1077 hostNames = [ 'h8', 'h16', 'h24' ]
1078 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
1079 'of:0000000000000007/8' ]
1080 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 -07001081 stepResult = main.intentFunction.multiToSingleIntent(
1082 main,
1083 name="NOOPTION",
1084 hostNames=hostNames,
1085 devices=devices,
1086 sw1="s5",
1087 sw2="s2",
1088 expectedLink=18 )
1089
1090 utilities.assert_equals( expect=main.TRUE,
1091 actual=stepResult,
1092 onpass="NOOPTION: Successfully added multi "
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001093 + " point to single point intents" +
1094 " with no match action",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001095 onfail="NOOPTION: Failed to add multi point" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001096 " to single point intents" +
1097 " with no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001098
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001099 main.step( "IPV4: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001100 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001101 stepResult = main.intentFunction.multiToSingleIntent(
1102 main,
1103 name="IPV4",
1104 hostNames=hostNames,
1105 devices=devices,
1106 ports=None,
1107 ethType="IPV4",
1108 macs=macs,
1109 bandwidth="",
1110 lambdaAlloc=False,
1111 ipProto="",
1112 ipAddresses="",
1113 tcp="",
1114 sw1="s5",
1115 sw2="s2",
1116 expectedLink=18 )
1117
1118 utilities.assert_equals( expect=main.TRUE,
1119 actual=stepResult,
1120 onpass="IPV4: Successfully added multi point"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001121 + " to single point intents" +
1122 " with IPV4 type and MAC addresses",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001123 onfail="IPV4: Failed to add multi point" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001124 " to single point intents" +
1125 " with IPV4 type and MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001126
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001127 main.step( "IPV4_2: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001128 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001129 hostNames = [ 'h8', 'h16', 'h24' ]
1130 stepResult = main.intentFunction.multiToSingleIntent(
1131 main,
1132 name="IPV4",
1133 hostNames=hostNames,
1134 ethType="IPV4",
1135 lambdaAlloc=False )
1136
1137 utilities.assert_equals( expect=main.TRUE,
1138 actual=stepResult,
1139 onpass="IPV4_2: Successfully added multi point"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001140 + " to single point intents" +
1141 " with IPV4 type and no MAC addresses",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001142 onfail="IPV4_2: Failed to add multi point" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001143 " to single point intents" +
1144 " with IPV4 type and no MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001145
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001146 main.step( "VLAN: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001147 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001148 hostNames = [ 'h5', 'h13', 'h21' ]
1149 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \
1150 'of:0000000000000007/5' ]
1151 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
1152 stepResult = main.intentFunction.multiToSingleIntent(
1153 main,
1154 name="VLAN",
1155 hostNames=hostNames,
1156 devices=devices,
1157 ports=None,
1158 ethType="IPV4",
1159 macs=macs,
1160 bandwidth="",
1161 lambdaAlloc=False,
1162 ipProto="",
1163 ipAddresses="",
1164 tcp="",
1165 sw1="s5",
1166 sw2="s2",
1167 expectedLink=18 )
1168
1169 utilities.assert_equals( expect=main.TRUE,
1170 actual=stepResult,
1171 onpass="VLAN: Successfully added multi point"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001172 + " to single point intents" +
1173 " with IPV4 type and MAC addresses" +
1174 " in the same VLAN",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001175 onfail="VLAN: Failed to add multi point" +
1176 " to single point intents" )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001177
acsmars1ff5e052015-07-23 11:27:48 -07001178 def CASE5000( self, main ):
1179 """
1180 Will add description in next patch set
acsmars1ff5e052015-07-23 11:27:48 -07001181 """
1182 assert main, "There is no main"
1183 assert main.CLIs, "There is no main.CLIs"
1184 assert main.Mininet1, "Mininet handle should be named Mininet1"
1185 assert main.numSwitch, "Placed the total number of switch topology in \
1186 main.numSwitch"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001187 main.case( "Test host mobility with host intents " )
1188 main.step( " Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07001189 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1190
1191 main.log.info( "Moving h1 from s5 to s6")
1192
1193 main.Mininet1.moveHost( "h1","s5","s6" )
1194
1195 main.intentFunction.getHostsData( main )
1196 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1197
1198 utilities.assert_equals( expect="of:0000000000000006",
1199 actual=h1PostMove,
1200 onpass="Mobility: Successfully moved h1 to s6",
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001201 onfail="Mobility: Failed to moved h1 to s6" +
1202 " to single point intents" +
1203 " with IPV4 type and MAC addresses" +
1204 " in the same VLAN" )
1205
1206 main.step( "IPV4: Add host intents between h1 and h9" )
1207 stepResult = main.TRUE
1208 stepResult = main.intentFunction.hostIntent( main,
1209 onosNode='0',
1210 name='IPV4',
1211 host1='h1',
1212 host2='h9',
1213 host1Id='00:00:00:00:00:01/-1',
1214 host2Id='00:00:00:00:00:09/-1' )
1215
1216 utilities.assert_equals( expect=main.TRUE,
1217 actual=stepResult,
1218 onpass="IPV4: Host intent test successful " +
1219 "between two IPV4 hosts",
1220 onfail="IPV4: Host intent test failed " +
1221 "between two IPV4 hosts")