blob: 9ef8884b115e0ccced198ff5a1c523bf05a96239 [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
178 for i in range( main.numCtrls ):
179 onosUninstallResult = onosUninstallResult and \
180 main.ONOSbench.onosUninstall( nodeIp=main.ONOSip[ i ] )
181 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" )
282
283 if links[ controller ] and "Error" not in links[ controller ]:
284 currentLinksResult = main.Mininet1.compareLinks(
285 mnSwitches, mnLinks,
286 json.loads( links[ controller ] ) )
287 else:
288 currentLinksResult = main.FALSE
289 utilities.assert_equals( expect=main.TRUE,
290 actual=currentLinksResult,
291 onpass="ONOS" + controllerStr +
292 " links view is correct",
293 onfail="ONOS" + controllerStr +
294 " links view is incorrect" )
295
296 if hosts[ controller ] or "Error" not in hosts[ controller ]:
297 currentHostsResult = main.Mininet1.compareHosts(
298 mnHosts,
299 json.loads( hosts[ controller ] ) )
300 else:
301 currentHostsResult = main.FALSE
302 utilities.assert_equals( expect=main.TRUE,
303 actual=currentHostsResult,
304 onpass="ONOS" + controllerStr +
305 " hosts exist in Mininet",
306 onfail="ONOS" + controllerStr +
307 " hosts don't match Mininet" )
308
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700309 def CASE9( self, main ):
310 '''
311 Report errors/warnings/exceptions
312 '''
313 main.log.info( "Error report: \n" )
314 main.ONOSbench.logReport( globalONOSip[0],
315 [ "INFO", "FOLLOWER", "WARN", "flow", "ERROR" , "Except" ],
316 "s" )
317 #main.ONOSbench.logReport( globalONOSip[1], [ "INFO" ], "d" )
318
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700319 def CASE10( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700320 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700321 Start Mininet topology with OF 1.0 switches
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700322 """
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700323 main.OFProtocol = "1.0"
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700324 main.log.report( "Start Mininet topology with OF 1.0 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700325 main.case( "Start Mininet topology with OF 1.0 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700326 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700327 "switches to test intents, exits out if " +\
328 "topology did not start correctly"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700329
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700330 main.step( "Starting Mininet topology with OF 1.0 switches" )
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700331 args = "--switch ovs,protocols=OpenFlow10"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700332 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700333 main.topology,
334 args=args )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700335 stepResult = topoResult
336 utilities.assert_equals( expect=main.TRUE,
337 actual=stepResult,
338 onpass="Successfully loaded topology",
339 onfail="Failed to load topology" )
340 # Exit if topology did not load properly
341 if not topoResult:
342 main.cleanup()
343 main.exit()
344
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700345 def CASE11( self, main ):
346 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700347 Start Mininet topology with OF 1.3 switches
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700348 """
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700349 main.OFProtocol = "1.3"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700350 main.log.report( "Start Mininet topology with OF 1.3 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700351 main.case( "Start Mininet topology with OF 1.3 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700352 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700353 "switches to test intents, exits out if " +\
354 "topology did not start correctly"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700355
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700356 main.step( "Starting Mininet topology with OF 1.3 switches" )
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700357 args = "--switch ovs,protocols=OpenFlow13"
358 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
359 main.topology,
360 args=args )
361 stepResult = topoResult
362 utilities.assert_equals( expect=main.TRUE,
363 actual=stepResult,
364 onpass="Successfully loaded topology",
365 onfail="Failed to load topology" )
366 # Exit if topology did not load properly
367 if not topoResult:
368 main.cleanup()
369 main.exit()
370
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700371 def CASE12( self, main ):
372 """
373 Assign mastership to controllers
374 """
375 import re
376
377 main.case( "Assign switches to controllers" )
378 main.step( "Assigning switches to controllers" )
Jon Hall783bbf92015-07-23 14:33:19 -0700379 main.caseExplanation = "Assign OF " + main.OFProtocol +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700380 " switches to ONOS nodes"
381
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700382 assignResult = main.TRUE
383 switchList = []
384
385 # Creates a list switch name, use getSwitch() function later...
386 for i in range( 1, ( main.numSwitch + 1 ) ):
387 switchList.append( 's' + str( i ) )
388
389 tempONOSip = []
390 for i in range( main.numCtrls ):
391 tempONOSip.append( main.ONOSip[ i ] )
392
393 assignResult = main.Mininet1.assignSwController( sw=switchList,
394 ip=tempONOSip,
395 port='6633' )
396 if not assignResult:
397 main.cleanup()
398 main.exit()
399
400 for i in range( 1, ( main.numSwitch + 1 ) ):
401 response = main.Mininet1.getSwController( "s" + str( i ) )
402 print( "Response is " + str( response ) )
403 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
404 assignResult = assignResult and main.TRUE
405 else:
406 assignResult = main.FALSE
407 stepResult = assignResult
408 utilities.assert_equals( expect=main.TRUE,
409 actual=stepResult,
410 onpass="Successfully assigned switches" +
411 "to controller",
412 onfail="Failed to assign switches to " +
413 "controller" )
414 def CASE13( self, main ):
415 """
416 Discover all hosts and store its data to a dictionary
417 """
418 main.case( "Discover all hosts" )
419
420 stepResult = main.TRUE
421 main.step( "Discover all hosts using pingall " )
422 stepResult = main.intentFunction.getHostsData( main )
423 utilities.assert_equals( expect=main.TRUE,
424 actual=stepResult,
425 onpass="Successfully discovered hosts",
426 onfail="Failed to discover hosts" )
427
428 def CASE14( self, main ):
429 """
430 Stop mininet
431 """
432 main.log.report( "Stop Mininet topology" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700433 main.case( "Stop Mininet topology" )
Jon Hall783bbf92015-07-23 14:33:19 -0700434 main.caseExplanation = "Stopping the current mininet topology " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700435 "to start up fresh"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700436
437 main.step( "Stopping Mininet Topology" )
438 topoResult = main.Mininet1.stopNet( )
439 stepResult = topoResult
440 utilities.assert_equals( expect=main.TRUE,
441 actual=stepResult,
442 onpass="Successfully stop mininet",
443 onfail="Failed to stop mininet" )
444 # Exit if topology did not load properly
445 if not topoResult:
446 main.cleanup()
447 main.exit()
448
kelvin-onlabb769f562015-07-15 17:05:10 -0700449 def CASE1000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700450 """
451 Add host intents between 2 host:
452 - Discover hosts
453 - Add host intents
454 - Check intents
455 - Verify flows
456 - Ping hosts
457 - Reroute
458 - Link down
459 - Verify flows
460 - Check topology
461 - Ping hosts
462 - Link up
463 - Verify flows
464 - Check topology
465 - Ping hosts
466 - Remove intents
467 """
468 import time
469 import json
470 import re
471
472 # Assert variables - These variable's name|format must be followed
473 # if you want to use the wrapper function
474 assert main, "There is no main"
475 assert main.CLIs, "There is no main.CLIs"
476 assert main.Mininet1, "Mininet handle should be named Mininet1"
477 assert main.numSwitch, "Placed the total number of switch topology in \
478 main.numSwitch"
479
acsmarse6b410f2015-07-17 14:39:34 -0700480 intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
481
kelvin-onlab825b57d2015-07-24 13:43:59 -0700482 main.case( "Host Intents Test - " + str( main.numCtrls ) +
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700483 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700484 main.caseExplanation = "This test case tests Host intents using " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700485 str( main.numCtrls ) + " node(s) cluster;\n" +\
486 "Different type of hosts will be tested in " +\
487 "each step such as IPV4, Dual stack, VLAN " +\
488 "etc;\nThe test will use OF " + main.OFProtocol\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700489 + " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700490
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700491 main.step( "IPV4: Add host intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700492 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700493 stepResult = main.intentFunction.hostIntent( main,
494 onosNode='0',
495 name='IPV4',
496 host1='h1',
497 host2='h9',
498 host1Id='00:00:00:00:00:01/-1',
499 host2Id='00:00:00:00:00:09/-1',
500 sw1='s5',
501 sw2='s2',
502 expectedLink=18 )
503
504 utilities.assert_equals( expect=main.TRUE,
505 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700506 onpass="IPV4: Host intent test successful " +
507 "between two IPV4 hosts",
508 onfail="IPV4: Host intent test failed " +
509 "between two IPV4 hosts")
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700510
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700511 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700512 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700513 stepResult = main.intentFunction.hostIntent( main,
514 name='DUALSTACK',
515 host1='h3',
516 host2='h11',
517 host1Id='00:00:00:00:00:03/-1',
518 host2Id='00:00:00:00:00:0B/-1',
519 sw1='s5',
520 sw2='s2',
521 expectedLink=18 )
522
523 utilities.assert_equals( expect=main.TRUE,
524 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700525 onpass="DUALSTACK: Host intent test " +
526 "successful between two " +
527 "dual stack host using IPV4",
528 onfail="DUALSTACK: Host intent test " +
529 "failed between two" +
530 "dual stack host using IPV4" )
531
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700532
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700533 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700534 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700535 stepResult = main.intentFunction.hostIntent( main,
536 name='DUALSTACK2',
537 host1='h1',
538 host2='h11',
539 sw1='s5',
540 sw2='s2',
541 expectedLink=18 )
542
543 utilities.assert_equals( expect=main.TRUE,
544 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700545 onpass="DUALSTACK2: Host intent test " +
546 "successful between two " +
547 "dual stack host using IPV4",
548 onfail="DUALSTACK2: Host intent test " +
549 "failed between two" +
550 "dual stack host using IPV4" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700551
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700552 main.step( "1HOP: Add host intents between h1 and h3" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700553 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700554 stepResult = main.intentFunction.hostIntent( main,
555 name='1HOP',
556 host1='h1',
557 host2='h3' )
558
559 utilities.assert_equals( expect=main.TRUE,
560 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700561 onpass="1HOP: Host intent test " +
562 "successful between two " +
563 "host using IPV4 in the same switch",
564 onfail="1HOP: Host intent test " +
565 "failed between two" +
566 "host using IPV4 in the same switch" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700567
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700568 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
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='VLAN1',
572 host1='h4',
573 host2='h12',
574 host1Id='00:00:00:00:00:04/100',
575 host2Id='00:00:00:00:00:0C/100',
576 sw1='s5',
577 sw2='s2',
578 expectedLink=18 )
579
580 utilities.assert_equals( expect=main.TRUE,
581 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700582 onpass="VLAN1: Host intent test " +
583 "successful between two " +
584 "host using IPV4 in the same VLAN",
585 onfail="VLAN1: Host intent test " +
586 "failed between two" +
587 "host using IPV4 in the same VLAN" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700588
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700589 main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700590 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700591 stepResult = main.intentFunction.hostIntent( main,
592 name='VLAN2',
593 host1='h13',
594 host2='h20' )
595
596 utilities.assert_equals( expect=main.FALSE,
597 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700598 onpass="VLAN2: Host intent negative test " +
599 "successful between two " +
600 "host using IPV4 in different VLAN",
601 onfail="VLAN2: Host intent negative test " +
602 "failed between two" +
603 "host using IPV4 in different VLAN" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700604
acsmarse6b410f2015-07-17 14:39:34 -0700605
606 intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
607 main.intentFunction.checkLeaderChange( intentLeadersOld,
608 intentLeadersNew )
609
kelvin-onlabb769f562015-07-15 17:05:10 -0700610 def CASE2000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700611 """
612 Add point intents between 2 hosts:
613 - Get device ids | ports
614 - Add point intents
615 - Check intents
616 - Verify flows
617 - Ping hosts
618 - Reroute
619 - Link down
620 - Verify flows
621 - Check topology
622 - Ping hosts
623 - Link up
624 - Verify flows
625 - Check topology
626 - Ping hosts
627 - Remove intents
628 """
629 import time
630 import json
631 import re
632
633 # Assert variables - These variable's name|format must be followed
634 # if you want to use the wrapper function
635 assert main, "There is no main"
636 assert main.CLIs, "There is no main.CLIs"
637 assert main.Mininet1, "Mininet handle should be named Mininet1"
638 assert main.numSwitch, "Placed the total number of switch topology in \
639 main.numSwitch"
640
kelvin-onlab825b57d2015-07-24 13:43:59 -0700641 main.case( "Point Intents Test - " + str( main.numCtrls ) +
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700642 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700643 main.caseExplanation = "This test case will test point to point" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700644 " intents using " + str( main.numCtrls ) +\
645 " node(s) cluster;\n" +\
646 "Different type of hosts will be tested in " +\
647 "each step such as IPV4, Dual stack, VLAN etc" +\
648 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700649 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700650
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700651 # No option point intents
652 main.step( "NOOPTION: Add point intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700653 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700654 stepResult = main.intentFunction.pointIntent(
655 main,
656 name="NOOPTION",
657 host1="h1",
658 host2="h9",
659 deviceId1="of:0000000000000005/1",
660 deviceId2="of:0000000000000006/1",
661 sw1="s5",
662 sw2="s2",
663 expectedLink=18 )
664
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700665 utilities.assert_equals( expect=main.TRUE,
666 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700667 onpass="NOOPTION: Point intent test " +
668 "successful using no match action",
669 onfail="NOOPTION: Point intent test " +
670 "failed using no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700671
672 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -0700673 main.step( "IPV4: Add point intents between h1 and h9" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700674 stepResult = main.intentFunction.pointIntent(
675 main,
676 name="IPV4",
677 host1="h1",
678 host2="h9",
679 deviceId1="of:0000000000000005/1",
680 deviceId2="of:0000000000000006/1",
681 port1="",
682 port2="",
683 ethType="IPV4",
684 mac1="00:00:00:00:00:01",
685 mac2="00:00:00:00:00:09",
686 bandwidth="",
687 lambdaAlloc=False,
688 ipProto="",
689 ip1="",
690 ip2="",
691 tcp1="",
692 tcp2="",
693 sw1="s5",
694 sw2="s2",
695 expectedLink=18 )
696
697 utilities.assert_equals( expect=main.TRUE,
698 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700699 onpass="IPV4: Point intent test " +
700 "successful using IPV4 type with " +
701 "MAC addresses",
702 onfail="IPV4: Point intent test " +
703 "failed using IPV4 type with " +
704 "MAC addresses" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700705 main.step( "IPV4_2: Add point intents between h1 and h9" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700706 stepResult = main.TRUE
707 stepResult = main.intentFunction.pointIntent(
708 main,
709 name="IPV4_2",
710 host1="h1",
711 host2="h9",
712 deviceId1="of:0000000000000005/1",
713 deviceId2="of:0000000000000006/1",
kelvin-onlabb769f562015-07-15 17:05:10 -0700714 ipProto="",
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700715 ip1="",
716 ip2="",
717 tcp1="",
718 tcp2="",
719 sw1="s5",
720 sw2="s2",
721 expectedLink=18 )
722
723 utilities.assert_equals( expect=main.TRUE,
724 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700725 onpass="IPV4_2: Point intent test " +
726 "successful using IPV4 type with " +
727 "no MAC addresses",
728 onfail="IPV4_2: Point intent test " +
729 "failed using IPV4 type with " +
730 "no MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700731
kelvin-onlabb769f562015-07-15 17:05:10 -0700732 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700733 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -0700734 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
735 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab0ad05d12015-07-23 14:21:15 -0700736 try:
737 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/24"
738 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/24"
739 except KeyError:
740 main.log.debug( "Key Error getting IP addresses of h1 | h9 in" +
741 "main.hostsData" )
742 ip1 = main.Mininet1.getIPAddress( 'h1')
743 ip2 = main.Mininet1.getIPAddress( 'h9')
744
kelvin-onlabb769f562015-07-15 17:05:10 -0700745 ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
kelvin-onlab79ce0492015-07-27 16:14:39 -0700746 # Uneccessary, not including this in the selectors
kelvin-onlabb769f562015-07-15 17:05:10 -0700747 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
748 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
749
750 stepResult = main.intentFunction.pointIntent(
751 main,
752 name="SDNIP-TCP",
753 host1="h1",
754 host2="h9",
755 deviceId1="of:0000000000000005/1",
756 deviceId2="of:0000000000000006/1",
757 mac1=mac1,
758 mac2=mac2,
759 ethType="IPV4",
760 ipProto=ipProto,
761 ip1=ip1,
kelvin-onlab79ce0492015-07-27 16:14:39 -0700762 ip2=ip2 )
kelvin-onlabb769f562015-07-15 17:05:10 -0700763
764 utilities.assert_equals( expect=main.TRUE,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700765 actual=stepResult,
766 onpass="SDNIP-TCP: Point intent test " +
767 "successful using IPV4 type with " +
768 "IP protocol TCP enabled",
769 onfail="SDNIP-TCP: Point intent test " +
770 "failed using IPV4 type with " +
771 "IP protocol TCP enabled" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700772
773 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
774 stepResult = main.TRUE
775 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
776 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
777 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/24"
778 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/24"
779 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
780 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
781 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
782
783 stepResult = main.intentFunction.pointIntent(
784 main,
785 name="SDNIP-ICMP",
786 host1="h1",
787 host2="h9",
788 deviceId1="of:0000000000000005/1",
789 deviceId2="of:0000000000000006/1",
790 mac1=mac1,
791 mac2=mac2,
792 ethType="IPV4",
793 ipProto=ipProto )
794
795 utilities.assert_equals( expect=main.TRUE,
796 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700797 onpass="SDNIP-ICMP: Point intent test " +
798 "successful using IPV4 type with " +
799 "IP protocol ICMP enabled",
800 onfail="SDNIP-ICMP: Point intent test " +
801 "failed using IPV4 type with " +
802 "IP protocol ICMP enabled" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700803
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700804 main.step( "DUALSTACK1: Add point intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700805 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700806 stepResult = main.intentFunction.pointIntent(
807 main,
808 name="DUALSTACK1",
809 host1="h3",
810 host2="h11",
811 deviceId1="of:0000000000000005",
812 deviceId2="of:0000000000000006",
813 port1="3",
814 port2="3",
815 ethType="IPV4",
816 mac1="00:00:00:00:00:03",
817 mac2="00:00:00:00:00:0B",
818 bandwidth="",
819 lambdaAlloc=False,
820 ipProto="",
821 ip1="",
822 ip2="",
823 tcp1="",
824 tcp2="",
825 sw1="s5",
826 sw2="s2",
827 expectedLink=18 )
828
829 utilities.assert_equals( expect=main.TRUE,
830 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700831 onpass="DUALSTACK1: Point intent test " +
832 "successful using IPV4 type with " +
833 "MAC addresses",
834 onfail="DUALSTACK1: Point intent test " +
835 "failed using IPV4 type with " +
836 "MAC addresses" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700837
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700838 main.step( "VLAN: Add point intents between h5 and h21" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700839 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700840 stepResult = main.intentFunction.pointIntent(
841 main,
842 name="VLAN",
843 host1="h5",
844 host2="h21",
845 deviceId1="of:0000000000000005/5",
846 deviceId2="of:0000000000000007/5",
847 port1="",
848 port2="",
849 ethType="IPV4",
850 mac1="00:00:00:00:00:05",
851 mac2="00:00:00:00:00:15",
852 bandwidth="",
853 lambdaAlloc=False,
854 ipProto="",
855 ip1="",
856 ip2="",
857 tcp1="",
858 tcp2="",
859 sw1="s5",
860 sw2="s2",
861 expectedLink=18 )
862
863 utilities.assert_equals( expect=main.TRUE,
864 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700865 onpass="VLAN1: Point intent test " +
866 "successful using IPV4 type with " +
867 "MAC addresses",
868 onfail="VLAN1: Point intent test " +
869 "failed using IPV4 type with " +
870 "MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700871
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700872 main.step( "1HOP: Add point intents between h1 and h3" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700873 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700874 stepResult = main.intentFunction.hostIntent( main,
875 name='1HOP',
876 host1='h1',
877 host2='h3' )
878
879 utilities.assert_equals( expect=main.TRUE,
880 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700881 onpass="1HOP: Point intent test " +
882 "successful using IPV4 type with " +
883 "no MAC addresses",
884 onfail="1HOP: Point intent test " +
885 "failed using IPV4 type with " +
886 "no MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700887
kelvin-onlabb769f562015-07-15 17:05:10 -0700888 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700889 """
890 Add single point to multi point intents
891 - Get device ids
892 - Add single point to multi point intents
893 - Check intents
894 - Verify flows
895 - Ping hosts
896 - Reroute
897 - Link down
898 - Verify flows
899 - Check topology
900 - Ping hosts
901 - Link up
902 - Verify flows
903 - Check topology
904 - Ping hosts
905 - Remove intents
906 """
907 assert main, "There is no main"
908 assert main.CLIs, "There is no main.CLIs"
909 assert main.Mininet1, "Mininet handle should be named Mininet1"
910 assert main.numSwitch, "Placed the total number of switch topology in \
911 main.numSwitch"
912
kelvin-onlab825b57d2015-07-24 13:43:59 -0700913 main.case( "Single To Multi Point Intents Test - " +
kelvin-onlabe5c1ada2015-07-24 11:49:40 -0700914 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700915 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700916 " multi point intents using " +\
917 str( main.numCtrls ) + " node(s) cluster;\n" +\
918 "Different type of hosts will be tested in " +\
919 "each step such as IPV4, Dual stack, VLAN etc" +\
920 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700921 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700922
kelvin-onlabb769f562015-07-15 17:05:10 -0700923 main.step( "NOOPTION: Add single point to multi point intents" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700924 stepResult = main.TRUE
925 hostNames = [ 'h8', 'h16', 'h24' ]
926 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
927 'of:0000000000000007/8' ]
928 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 -0700929 stepResult = main.intentFunction.singleToMultiIntent(
930 main,
931 name="NOOPTION",
932 hostNames=hostNames,
933 devices=devices,
934 sw1="s5",
935 sw2="s2",
936 expectedLink=18 )
937
938 utilities.assert_equals( expect=main.TRUE,
939 actual=stepResult,
940 onpass="NOOPTION: Successfully added single "
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700941 + " point to multi point intents" +
942 " with no match action",
943 onfail="NOOPTION: Failed to add single point"
944 + " point to multi point intents" +
945 " with no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700946
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700947 main.step( "IPV4: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700948 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700949 stepResult = main.intentFunction.singleToMultiIntent(
950 main,
951 name="IPV4",
952 hostNames=hostNames,
953 devices=devices,
954 ports=None,
955 ethType="IPV4",
956 macs=macs,
957 bandwidth="",
958 lambdaAlloc=False,
959 ipProto="",
960 ipAddresses="",
961 tcp="",
962 sw1="s5",
963 sw2="s2",
964 expectedLink=18 )
965
966 utilities.assert_equals( expect=main.TRUE,
967 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700968 onpass="IPV4: Successfully added single "
969 + " point to multi point intents" +
970 " with IPV4 type and MAC addresses",
971 onfail="IPV4: Failed to add single point"
972 + " point to multi point intents" +
973 " with IPV4 type and MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700974
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700975 main.step( "IPV4_2: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700976 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700977 hostNames = [ 'h8', 'h16', 'h24' ]
978 stepResult = main.intentFunction.singleToMultiIntent(
979 main,
980 name="IPV4",
981 hostNames=hostNames,
982 ethType="IPV4",
983 lambdaAlloc=False )
984
985 utilities.assert_equals( expect=main.TRUE,
986 actual=stepResult,
987 onpass="IPV4_2: Successfully added single "
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700988 + " point to multi point intents" +
989 " with IPV4 type and no MAC addresses",
990 onfail="IPV4_2: Failed to add single point"
991 + " point to multi point intents" +
992 " with IPV4 type and no MAC addresses" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700993
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700994 main.step( "VLAN: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700995 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700996 hostNames = [ 'h4', 'h12', 'h20' ]
997 devices = [ 'of:0000000000000005/4', 'of:0000000000000006/4', \
998 'of:0000000000000007/4' ]
999 macs = [ '00:00:00:00:00:04', '00:00:00:00:00:0C', '00:00:00:00:00:14' ]
1000 stepResult = main.intentFunction.singleToMultiIntent(
1001 main,
1002 name="VLAN",
1003 hostNames=hostNames,
1004 devices=devices,
1005 ports=None,
1006 ethType="IPV4",
1007 macs=macs,
1008 bandwidth="",
1009 lambdaAlloc=False,
1010 ipProto="",
1011 ipAddresses="",
1012 tcp="",
1013 sw1="s5",
1014 sw2="s2",
1015 expectedLink=18 )
1016
1017 utilities.assert_equals( expect=main.TRUE,
1018 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001019 onpass="VLAN: Successfully added single "
1020 + " point to multi point intents" +
1021 " with IPV4 type and MAC addresses" +
1022 " in the same VLAN",
1023 onfail="VLAN: Failed to add single point"
1024 + " point to multi point intents" +
1025 " with IPV4 type and MAC addresses" +
1026 " in the same VLAN")
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001027
kelvin-onlabb769f562015-07-15 17:05:10 -07001028 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001029 """
1030 Add multi point to single point intents
1031 - Get device ids
1032 - Add multi point to single point intents
1033 - Check intents
1034 - Verify flows
1035 - Ping hosts
1036 - Reroute
1037 - Link down
1038 - Verify flows
1039 - Check topology
1040 - Ping hosts
1041 - Link up
1042 - Verify flows
1043 - Check topology
1044 - Ping hosts
1045 - Remove intents
1046 """
1047 assert main, "There is no main"
1048 assert main.CLIs, "There is no main.CLIs"
1049 assert main.Mininet1, "Mininet handle should be named Mininet1"
1050 assert main.numSwitch, "Placed the total number of switch topology in \
1051 main.numSwitch"
1052
kelvin-onlab825b57d2015-07-24 13:43:59 -07001053 main.case( "Multi To Single Point Intents Test - " +
kelvin-onlabe5c1ada2015-07-24 11:49:40 -07001054 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -07001055 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001056 " multi point intents using " +\
1057 str( main.numCtrls ) + " node(s) cluster;\n" +\
1058 "Different type of hosts will be tested in " +\
1059 "each step such as IPV4, Dual stack, VLAN etc" +\
1060 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -07001061 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001062
kelvin-onlabb769f562015-07-15 17:05:10 -07001063 main.step( "NOOPTION: Add multi point to single point intents" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001064 stepResult = main.TRUE
1065 hostNames = [ 'h8', 'h16', 'h24' ]
1066 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
1067 'of:0000000000000007/8' ]
1068 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 -07001069 stepResult = main.intentFunction.multiToSingleIntent(
1070 main,
1071 name="NOOPTION",
1072 hostNames=hostNames,
1073 devices=devices,
1074 sw1="s5",
1075 sw2="s2",
1076 expectedLink=18 )
1077
1078 utilities.assert_equals( expect=main.TRUE,
1079 actual=stepResult,
1080 onpass="NOOPTION: Successfully added multi "
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001081 + " point to single point intents" +
1082 " with no match action",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001083 onfail="NOOPTION: Failed to add multi point" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001084 " to single point intents" +
1085 " with no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001086
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001087 main.step( "IPV4: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001088 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001089 stepResult = main.intentFunction.multiToSingleIntent(
1090 main,
1091 name="IPV4",
1092 hostNames=hostNames,
1093 devices=devices,
1094 ports=None,
1095 ethType="IPV4",
1096 macs=macs,
1097 bandwidth="",
1098 lambdaAlloc=False,
1099 ipProto="",
1100 ipAddresses="",
1101 tcp="",
1102 sw1="s5",
1103 sw2="s2",
1104 expectedLink=18 )
1105
1106 utilities.assert_equals( expect=main.TRUE,
1107 actual=stepResult,
1108 onpass="IPV4: Successfully added multi point"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001109 + " to single point intents" +
1110 " with IPV4 type and MAC addresses",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001111 onfail="IPV4: Failed to add multi point" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001112 " to single point intents" +
1113 " with IPV4 type and MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001114
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001115 main.step( "IPV4_2: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001116 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001117 hostNames = [ 'h8', 'h16', 'h24' ]
1118 stepResult = main.intentFunction.multiToSingleIntent(
1119 main,
1120 name="IPV4",
1121 hostNames=hostNames,
1122 ethType="IPV4",
1123 lambdaAlloc=False )
1124
1125 utilities.assert_equals( expect=main.TRUE,
1126 actual=stepResult,
1127 onpass="IPV4_2: Successfully added multi point"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001128 + " to single point intents" +
1129 " with IPV4 type and no MAC addresses",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001130 onfail="IPV4_2: Failed to add multi point" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001131 " to single point intents" +
1132 " with IPV4 type and no MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001133
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001134 main.step( "VLAN: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001135 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001136 hostNames = [ 'h5', 'h13', 'h21' ]
1137 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \
1138 'of:0000000000000007/5' ]
1139 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
1140 stepResult = main.intentFunction.multiToSingleIntent(
1141 main,
1142 name="VLAN",
1143 hostNames=hostNames,
1144 devices=devices,
1145 ports=None,
1146 ethType="IPV4",
1147 macs=macs,
1148 bandwidth="",
1149 lambdaAlloc=False,
1150 ipProto="",
1151 ipAddresses="",
1152 tcp="",
1153 sw1="s5",
1154 sw2="s2",
1155 expectedLink=18 )
1156
1157 utilities.assert_equals( expect=main.TRUE,
1158 actual=stepResult,
1159 onpass="VLAN: Successfully added multi point"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001160 + " to single point intents" +
1161 " with IPV4 type and MAC addresses" +
1162 " in the same VLAN",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001163 onfail="VLAN: Failed to add multi point" +
1164 " to single point intents" )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001165
acsmars1ff5e052015-07-23 11:27:48 -07001166 def CASE5000( self, main ):
1167 """
1168 Will add description in next patch set
acsmars1ff5e052015-07-23 11:27:48 -07001169 """
1170 assert main, "There is no main"
1171 assert main.CLIs, "There is no main.CLIs"
1172 assert main.Mininet1, "Mininet handle should be named Mininet1"
1173 assert main.numSwitch, "Placed the total number of switch topology in \
1174 main.numSwitch"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001175 main.case( "Test host mobility with host intents " )
1176 main.step( " Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07001177 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1178
1179 main.log.info( "Moving h1 from s5 to s6")
1180
1181 main.Mininet1.moveHost( "h1","s5","s6" )
1182
1183 main.intentFunction.getHostsData( main )
1184 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1185
1186 utilities.assert_equals( expect="of:0000000000000006",
1187 actual=h1PostMove,
1188 onpass="Mobility: Successfully moved h1 to s6",
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001189 onfail="Mobility: Failed to moved h1 to s6" +
1190 " to single point intents" +
1191 " with IPV4 type and MAC addresses" +
1192 " in the same VLAN" )
1193
1194 main.step( "IPV4: Add host intents between h1 and h9" )
1195 stepResult = main.TRUE
1196 stepResult = main.intentFunction.hostIntent( main,
1197 onosNode='0',
1198 name='IPV4',
1199 host1='h1',
1200 host2='h9',
1201 host1Id='00:00:00:00:00:01/-1',
1202 host2Id='00:00:00:00:00:09/-1' )
1203
1204 utilities.assert_equals( expect=main.TRUE,
1205 actual=stepResult,
1206 onpass="IPV4: Host intent test successful " +
1207 "between two IPV4 hosts",
1208 onfail="IPV4: Host intent test failed " +
1209 "between two IPV4 hosts")