blob: 49c29690fc72126fe4afcb33fe629dc91505fdd7 [file] [log] [blame]
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001
2# Testing the basic intent functionality of ONOS
3
4import time
5import json
6
7class FUNCintent:
8
9 def __init__( self ):
10 self.default = ''
11
12 def CASE1( self, main ):
13 import time
14 import os
15 import imp
16
17 """
18 - Construct tests variables
19 - GIT ( optional )
20 - Checkout ONOS master branch
21 - Pull latest ONOS code
22 - Building ONOS ( optional )
23 - Install ONOS package
24 - Build ONOS package
25 """
26
27 main.case( "Constructing test variables and building ONOS package" )
28 main.step( "Constructing test variables" )
Jon Hall783bbf92015-07-23 14:33:19 -070029 main.caseExplanation = "This test case is mainly for loading " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -070030 "from params file, and pull and build the " +\
31 " latest ONOS package"
kelvin-onlabd48a68c2015-07-13 16:01:36 -070032 stepResult = main.FALSE
33
34 # Test variables
Jon Halla3e02432015-07-24 15:55:42 -070035 try:
36 main.testOnDirectory = os.path.dirname( os.getcwd ( ) )
37 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
38 gitBranch = main.params[ 'GIT' ][ 'branch' ]
39 main.dependencyPath = main.testOnDirectory + \
40 main.params[ 'DEPENDENCY' ][ 'path' ]
41 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
42 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
43 if main.ONOSbench.maxNodes:
44 main.maxNodes = int( main.ONOSbench.maxNodes )
45 else:
46 main.maxNodes = 0
47 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
48 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
49 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
50 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
51 main.checkIntentSleep = int( main.params[ 'SLEEP' ][ 'checkintent' ] )
52 main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] )
53 main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
54 gitPull = main.params[ 'GIT' ][ 'pull' ]
55 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
56 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
57 main.cellData = {} # for creating cell file
58 main.hostsData = {}
59 main.CLIs = []
60 main.ONOSip = []
kelvin-onlabd48a68c2015-07-13 16:01:36 -070061
Jon Halla3e02432015-07-24 15:55:42 -070062 main.ONOSip = main.ONOSbench.getOnosIps()
63 print main.ONOSip
kelvin-onlabd48a68c2015-07-13 16:01:36 -070064
Jon Halla3e02432015-07-24 15:55:42 -070065 # Assigning ONOS cli handles to a list
66 for i in range( 1, main.maxNodes + 1 ):
67 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070068
Jon Halla3e02432015-07-24 15:55:42 -070069 # -- INIT SECTION, ONLY RUNS ONCE -- #
70 main.startUp = imp.load_source( wrapperFile1,
71 main.dependencyPath +
72 wrapperFile1 +
73 ".py" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070074
Jon Halla3e02432015-07-24 15:55:42 -070075 main.intentFunction = imp.load_source( wrapperFile2,
76 main.dependencyPath +
77 wrapperFile2 +
78 ".py" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070079
Jon Halla3e02432015-07-24 15:55:42 -070080 main.topo = imp.load_source( wrapperFile3,
81 main.dependencyPath +
82 wrapperFile3 +
83 ".py" )
84
85 copyResult = main.ONOSbench.copyMininetFile( main.topology,
86 main.dependencyPath,
87 main.Mininet1.user_name,
88 main.Mininet1.ip_address )
89 if main.CLIs:
90 stepResult = main.TRUE
91 else:
92 main.log.error( "Did not properly created list of ONOS CLI handle" )
93 stepResult = main.FALSE
94 except Exception as e:
95 main.log.exception(e)
96 main.cleanup()
97 main.exit()
kelvin-onlabd48a68c2015-07-13 16:01:36 -070098
99 utilities.assert_equals( expect=main.TRUE,
100 actual=stepResult,
101 onpass="Successfully construct " +
102 "test variables ",
103 onfail="Failed to construct test variables" )
104
105 if gitPull == 'True':
106 main.step( "Building ONOS in " + gitBranch + " branch" )
107 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
108 stepResult = onosBuildResult
109 utilities.assert_equals( expect=main.TRUE,
110 actual=stepResult,
111 onpass="Successfully compiled " +
112 "latest ONOS",
113 onfail="Failed to compile " +
114 "latest ONOS" )
115 else:
116 main.log.warn( "Did not pull new code so skipping mvn " +
117 "clean install" )
Jon Hall106be082015-07-22 09:53:00 -0700118 main.ONOSbench.getVersion( report=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700119
120 def CASE2( self, main ):
121 """
122 - Set up cell
123 - Create cell file
124 - Set cell file
125 - Verify cell file
126 - Kill ONOS process
127 - Uninstall ONOS cluster
128 - Verify ONOS start up
129 - Install ONOS cluster
130 - Connect to cli
131 """
132
133 # main.scale[ 0 ] determines the current number of ONOS controller
134 main.numCtrls = int( main.scale[ 0 ] )
135
136 main.case( "Starting up " + str( main.numCtrls ) +
137 " node(s) ONOS cluster" )
Jon Hall783bbf92015-07-23 14:33:19 -0700138 main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700139 " node(s) ONOS cluster"
140
141
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700142
143 #kill off all onos processes
144 main.log.info( "Safety check, killing all ONOS processes" +
145 " before initiating enviornment setup" )
146
147 for i in range( main.maxNodes ):
148 main.ONOSbench.onosDie( main.ONOSip[ i ] )
149
150 print "NODE COUNT = ", main.numCtrls
151
152 tempOnosIp = []
153 for i in range( main.numCtrls ):
154 tempOnosIp.append( main.ONOSip[i] )
155
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700156 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
157 "temp", main.Mininet1.ip_address,
158 main.apps, tempOnosIp )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700159
160 main.step( "Apply cell to environment" )
161 cellResult = main.ONOSbench.setCell( "temp" )
162 verifyResult = main.ONOSbench.verifyCell()
163 stepResult = cellResult and verifyResult
164 utilities.assert_equals( expect=main.TRUE,
165 actual=stepResult,
166 onpass="Successfully applied cell to " + \
167 "environment",
168 onfail="Failed to apply cell to environment " )
169
170 main.step( "Creating ONOS package" )
171 packageResult = main.ONOSbench.onosPackage()
172 stepResult = packageResult
173 utilities.assert_equals( expect=main.TRUE,
174 actual=stepResult,
175 onpass="Successfully created ONOS package",
176 onfail="Failed to create ONOS package" )
177
178 time.sleep( main.startUpSleep )
179 main.step( "Uninstalling ONOS package" )
180 onosUninstallResult = main.TRUE
181 for i in range( main.numCtrls ):
182 onosUninstallResult = onosUninstallResult and \
183 main.ONOSbench.onosUninstall( nodeIp=main.ONOSip[ i ] )
184 stepResult = onosUninstallResult
185 utilities.assert_equals( expect=main.TRUE,
186 actual=stepResult,
187 onpass="Successfully uninstalled ONOS package",
188 onfail="Failed to uninstall ONOS package" )
189
190 time.sleep( main.startUpSleep )
191 main.step( "Installing ONOS package" )
192 onosInstallResult = main.TRUE
193 for i in range( main.numCtrls ):
194 onosInstallResult = onosInstallResult and \
195 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
196 stepResult = onosInstallResult
197 utilities.assert_equals( expect=main.TRUE,
198 actual=stepResult,
199 onpass="Successfully installed ONOS package",
200 onfail="Failed to install ONOS package" )
201
202 time.sleep( main.startUpSleep )
203 main.step( "Starting ONOS service" )
204 stopResult = main.TRUE
205 startResult = main.TRUE
206 onosIsUp = main.TRUE
207
208 for i in range( main.numCtrls ):
209 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
210 if onosIsUp == main.TRUE:
211 main.log.report( "ONOS instance is up and ready" )
212 else:
213 main.log.report( "ONOS instance may not be up, stop and " +
214 "start ONOS again " )
215 for i in range( main.numCtrls ):
216 stopResult = stopResult and \
217 main.ONOSbench.onosStop( main.ONOSip[ i ] )
218 for i in range( main.numCtrls ):
219 startResult = startResult and \
220 main.ONOSbench.onosStart( main.ONOSip[ i ] )
221 stepResult = onosIsUp and stopResult and startResult
222 utilities.assert_equals( expect=main.TRUE,
223 actual=stepResult,
224 onpass="ONOS service is ready",
225 onfail="ONOS service did not start properly" )
226
227 main.step( "Start ONOS cli" )
228 cliResult = main.TRUE
229 for i in range( main.numCtrls ):
230 cliResult = cliResult and \
231 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
232 stepResult = cliResult
233 utilities.assert_equals( expect=main.TRUE,
234 actual=stepResult,
235 onpass="Successfully start ONOS cli",
236 onfail="Failed to start ONOS cli" )
237
238 # Remove the first element in main.scale list
239 main.scale.remove( main.scale[ 0 ] )
240
Jon Halla3e02432015-07-24 15:55:42 -0700241 def CASE8( self, main ):
242 """
243 Compare Topo
244 """
245 import json
246
247 main.case( "Compare ONOS Topology view to Mininet topology" )
248 main.caseExplanation = "Compare topology elements between Mininet" +\
249 " and ONOS"
250
251 main.step( "Gathering topology information" )
252 # TODO: add a paramaterized sleep here
253 devicesResults = main.TRUE
254 linksResults = main.TRUE
255 hostsResults = main.TRUE
256 devices = main.topo.getAllDevices( main )
257 hosts = main.topo.getAllHosts( main )
258 ports = main.topo.getAllPorts( main )
259 links = main.topo.getAllLinks( main )
260 clusters = main.topo.getAllClusters( main )
261
262 mnSwitches = main.Mininet1.getSwitches()
263 mnLinks = main.Mininet1.getLinks()
264 mnHosts = main.Mininet1.getHosts()
265
266 main.step( "Conmparing MN topology to ONOS topology" )
267 for controller in range( main.numCtrls ):
268 controllerStr = str( controller + 1 )
269 if devices[ controller ] and ports[ controller ] and\
270 "Error" not in devices[ controller ] and\
271 "Error" not in ports[ controller ]:
272
273 currentDevicesResult = main.Mininet1.compareSwitches(
274 mnSwitches,
275 json.loads( devices[ controller ] ),
276 json.loads( ports[ controller ] ) )
277 else:
278 currentDevicesResult = main.FALSE
279 utilities.assert_equals( expect=main.TRUE,
280 actual=currentDevicesResult,
281 onpass="ONOS" + controllerStr +
282 " Switches view is correct",
283 onfail="ONOS" + controllerStr +
284 " Switches view is incorrect" )
285
286 if links[ controller ] and "Error" not in links[ controller ]:
287 currentLinksResult = main.Mininet1.compareLinks(
288 mnSwitches, mnLinks,
289 json.loads( links[ controller ] ) )
290 else:
291 currentLinksResult = main.FALSE
292 utilities.assert_equals( expect=main.TRUE,
293 actual=currentLinksResult,
294 onpass="ONOS" + controllerStr +
295 " links view is correct",
296 onfail="ONOS" + controllerStr +
297 " links view is incorrect" )
298
299 if hosts[ controller ] or "Error" not in hosts[ controller ]:
300 currentHostsResult = main.Mininet1.compareHosts(
301 mnHosts,
302 json.loads( hosts[ controller ] ) )
303 else:
304 currentHostsResult = main.FALSE
305 utilities.assert_equals( expect=main.TRUE,
306 actual=currentHostsResult,
307 onpass="ONOS" + controllerStr +
308 " hosts exist in Mininet",
309 onfail="ONOS" + controllerStr +
310 " hosts don't match Mininet" )
311
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700312 def CASE9( self, main ):
313 '''
314 Report errors/warnings/exceptions
315 '''
316 main.log.info( "Error report: \n" )
317 main.ONOSbench.logReport( globalONOSip[0],
318 [ "INFO", "FOLLOWER", "WARN", "flow", "ERROR" , "Except" ],
319 "s" )
320 #main.ONOSbench.logReport( globalONOSip[1], [ "INFO" ], "d" )
321
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700322 def CASE10( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700323 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700324 Start Mininet topology with OF 1.0 switches
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700325 """
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700326 main.OFProtocol = "1.0"
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700327 main.log.report( "Start Mininet topology with OF 1.0 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700328 main.case( "Start Mininet topology with OF 1.0 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700329 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700330 "switches to test intents, exits out if " +\
331 "topology did not start correctly"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700332
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700333 main.step( "Starting Mininet topology with OF 1.0 switches" )
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700334 args = "--switch ovs,protocols=OpenFlow10"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700335 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700336 main.topology,
337 args=args )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700338 stepResult = topoResult
339 utilities.assert_equals( expect=main.TRUE,
340 actual=stepResult,
341 onpass="Successfully loaded topology",
342 onfail="Failed to load topology" )
343 # Exit if topology did not load properly
344 if not topoResult:
345 main.cleanup()
346 main.exit()
347
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700348 def CASE11( self, main ):
349 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700350 Start Mininet topology with OF 1.3 switches
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700351 """
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700352 main.OFProtocol = "1.3"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700353 main.log.report( "Start Mininet topology with OF 1.3 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700354 main.case( "Start Mininet topology with OF 1.3 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700355 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700356 "switches to test intents, exits out if " +\
357 "topology did not start correctly"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700358
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700359 main.step( "Starting Mininet topology with OF 1.3 switches" )
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700360 args = "--switch ovs,protocols=OpenFlow13"
361 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
362 main.topology,
363 args=args )
364 stepResult = topoResult
365 utilities.assert_equals( expect=main.TRUE,
366 actual=stepResult,
367 onpass="Successfully loaded topology",
368 onfail="Failed to load topology" )
369 # Exit if topology did not load properly
370 if not topoResult:
371 main.cleanup()
372 main.exit()
373
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700374 def CASE12( self, main ):
375 """
376 Assign mastership to controllers
377 """
378 import re
379
380 main.case( "Assign switches to controllers" )
381 main.step( "Assigning switches to controllers" )
Jon Hall783bbf92015-07-23 14:33:19 -0700382 main.caseExplanation = "Assign OF " + main.OFProtocol +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700383 " switches to ONOS nodes"
384
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700385 assignResult = main.TRUE
386 switchList = []
387
388 # Creates a list switch name, use getSwitch() function later...
389 for i in range( 1, ( main.numSwitch + 1 ) ):
390 switchList.append( 's' + str( i ) )
391
392 tempONOSip = []
393 for i in range( main.numCtrls ):
394 tempONOSip.append( main.ONOSip[ i ] )
395
396 assignResult = main.Mininet1.assignSwController( sw=switchList,
397 ip=tempONOSip,
398 port='6633' )
399 if not assignResult:
400 main.cleanup()
401 main.exit()
402
403 for i in range( 1, ( main.numSwitch + 1 ) ):
404 response = main.Mininet1.getSwController( "s" + str( i ) )
405 print( "Response is " + str( response ) )
406 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
407 assignResult = assignResult and main.TRUE
408 else:
409 assignResult = main.FALSE
410 stepResult = assignResult
411 utilities.assert_equals( expect=main.TRUE,
412 actual=stepResult,
413 onpass="Successfully assigned switches" +
414 "to controller",
415 onfail="Failed to assign switches to " +
416 "controller" )
417 def CASE13( self, main ):
418 """
419 Discover all hosts and store its data to a dictionary
420 """
421 main.case( "Discover all hosts" )
422
423 stepResult = main.TRUE
424 main.step( "Discover all hosts using pingall " )
425 stepResult = main.intentFunction.getHostsData( main )
426 utilities.assert_equals( expect=main.TRUE,
427 actual=stepResult,
428 onpass="Successfully discovered hosts",
429 onfail="Failed to discover hosts" )
430
431 def CASE14( self, main ):
432 """
433 Stop mininet
434 """
435 main.log.report( "Stop Mininet topology" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700436 main.case( "Stop Mininet topology" )
Jon Hall783bbf92015-07-23 14:33:19 -0700437 main.caseExplanation = "Stopping the current mininet topology " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700438 "to start up fresh"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700439
440 main.step( "Stopping Mininet Topology" )
441 topoResult = main.Mininet1.stopNet( )
442 stepResult = topoResult
443 utilities.assert_equals( expect=main.TRUE,
444 actual=stepResult,
445 onpass="Successfully stop mininet",
446 onfail="Failed to stop mininet" )
447 # Exit if topology did not load properly
448 if not topoResult:
449 main.cleanup()
450 main.exit()
451
kelvin-onlabb769f562015-07-15 17:05:10 -0700452 def CASE1000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700453 """
454 Add host intents between 2 host:
455 - Discover hosts
456 - Add host intents
457 - Check intents
458 - Verify flows
459 - Ping hosts
460 - Reroute
461 - Link down
462 - Verify flows
463 - Check topology
464 - Ping hosts
465 - Link up
466 - Verify flows
467 - Check topology
468 - Ping hosts
469 - Remove intents
470 """
471 import time
472 import json
473 import re
474
475 # Assert variables - These variable's name|format must be followed
476 # if you want to use the wrapper function
477 assert main, "There is no main"
478 assert main.CLIs, "There is no main.CLIs"
479 assert main.Mininet1, "Mininet handle should be named Mininet1"
480 assert main.numSwitch, "Placed the total number of switch topology in \
481 main.numSwitch"
482
acsmarse6b410f2015-07-17 14:39:34 -0700483 intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
484
kelvin-onlab825b57d2015-07-24 13:43:59 -0700485 main.case( "Host Intents Test - " + str( main.numCtrls ) +
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700486 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700487 main.caseExplanation = "This test case tests Host intents using " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700488 str( main.numCtrls ) + " node(s) cluster;\n" +\
489 "Different type of hosts will be tested in " +\
490 "each step such as IPV4, Dual stack, VLAN " +\
491 "etc;\nThe test will use OF " + main.OFProtocol\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700492 + " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700493
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700494 main.step( "IPV4: Add host intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700495 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700496 stepResult = main.intentFunction.hostIntent( main,
497 onosNode='0',
498 name='IPV4',
499 host1='h1',
500 host2='h9',
501 host1Id='00:00:00:00:00:01/-1',
502 host2Id='00:00:00:00:00:09/-1',
503 sw1='s5',
504 sw2='s2',
505 expectedLink=18 )
506
507 utilities.assert_equals( expect=main.TRUE,
508 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700509 onpass="IPV4: Host intent test successful " +
510 "between two IPV4 hosts",
511 onfail="IPV4: Host intent test failed " +
512 "between two IPV4 hosts")
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700513
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700514 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700515 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700516 stepResult = main.intentFunction.hostIntent( main,
517 name='DUALSTACK',
518 host1='h3',
519 host2='h11',
520 host1Id='00:00:00:00:00:03/-1',
521 host2Id='00:00:00:00:00:0B/-1',
522 sw1='s5',
523 sw2='s2',
524 expectedLink=18 )
525
526 utilities.assert_equals( expect=main.TRUE,
527 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700528 onpass="DUALSTACK: Host intent test " +
529 "successful between two " +
530 "dual stack host using IPV4",
531 onfail="DUALSTACK: Host intent test " +
532 "failed between two" +
533 "dual stack host using IPV4" )
534
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700535
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700536 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700537 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700538 stepResult = main.intentFunction.hostIntent( main,
539 name='DUALSTACK2',
540 host1='h1',
541 host2='h11',
542 sw1='s5',
543 sw2='s2',
544 expectedLink=18 )
545
546 utilities.assert_equals( expect=main.TRUE,
547 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700548 onpass="DUALSTACK2: Host intent test " +
549 "successful between two " +
550 "dual stack host using IPV4",
551 onfail="DUALSTACK2: Host intent test " +
552 "failed between two" +
553 "dual stack host using IPV4" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700554
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700555 main.step( "1HOP: Add host intents between h1 and h3" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700556 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700557 stepResult = main.intentFunction.hostIntent( main,
558 name='1HOP',
559 host1='h1',
560 host2='h3' )
561
562 utilities.assert_equals( expect=main.TRUE,
563 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700564 onpass="1HOP: Host intent test " +
565 "successful between two " +
566 "host using IPV4 in the same switch",
567 onfail="1HOP: Host intent test " +
568 "failed between two" +
569 "host using IPV4 in the same switch" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700570
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700571 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700572 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700573 stepResult = main.intentFunction.hostIntent( main,
574 name='VLAN1',
575 host1='h4',
576 host2='h12',
577 host1Id='00:00:00:00:00:04/100',
578 host2Id='00:00:00:00:00:0C/100',
579 sw1='s5',
580 sw2='s2',
581 expectedLink=18 )
582
583 utilities.assert_equals( expect=main.TRUE,
584 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700585 onpass="VLAN1: Host intent test " +
586 "successful between two " +
587 "host using IPV4 in the same VLAN",
588 onfail="VLAN1: Host intent test " +
589 "failed between two" +
590 "host using IPV4 in the same VLAN" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700591
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700592 main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700593 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700594 stepResult = main.intentFunction.hostIntent( main,
595 name='VLAN2',
596 host1='h13',
597 host2='h20' )
598
599 utilities.assert_equals( expect=main.FALSE,
600 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700601 onpass="VLAN2: Host intent negative test " +
602 "successful between two " +
603 "host using IPV4 in different VLAN",
604 onfail="VLAN2: Host intent negative test " +
605 "failed between two" +
606 "host using IPV4 in different VLAN" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700607
acsmarse6b410f2015-07-17 14:39:34 -0700608
609 intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
610 main.intentFunction.checkLeaderChange( intentLeadersOld,
611 intentLeadersNew )
612
kelvin-onlabb769f562015-07-15 17:05:10 -0700613 def CASE2000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700614 """
615 Add point intents between 2 hosts:
616 - Get device ids | ports
617 - Add point intents
618 - Check intents
619 - Verify flows
620 - Ping hosts
621 - Reroute
622 - Link down
623 - Verify flows
624 - Check topology
625 - Ping hosts
626 - Link up
627 - Verify flows
628 - Check topology
629 - Ping hosts
630 - Remove intents
631 """
632 import time
633 import json
634 import re
635
636 # Assert variables - These variable's name|format must be followed
637 # if you want to use the wrapper function
638 assert main, "There is no main"
639 assert main.CLIs, "There is no main.CLIs"
640 assert main.Mininet1, "Mininet handle should be named Mininet1"
641 assert main.numSwitch, "Placed the total number of switch topology in \
642 main.numSwitch"
643
kelvin-onlab825b57d2015-07-24 13:43:59 -0700644 main.case( "Point Intents Test - " + str( main.numCtrls ) +
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700645 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700646 main.caseExplanation = "This test case will test point to point" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700647 " intents using " + str( main.numCtrls ) +\
648 " node(s) cluster;\n" +\
649 "Different type of hosts will be tested in " +\
650 "each step such as IPV4, Dual stack, VLAN etc" +\
651 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700652 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700653
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700654 # No option point intents
655 main.step( "NOOPTION: Add point intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700656 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700657 stepResult = main.intentFunction.pointIntent(
658 main,
659 name="NOOPTION",
660 host1="h1",
661 host2="h9",
662 deviceId1="of:0000000000000005/1",
663 deviceId2="of:0000000000000006/1",
664 sw1="s5",
665 sw2="s2",
666 expectedLink=18 )
667
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700668 utilities.assert_equals( expect=main.TRUE,
669 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700670 onpass="NOOPTION: Point intent test " +
671 "successful using no match action",
672 onfail="NOOPTION: Point intent test " +
673 "failed using no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700674
675 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -0700676 main.step( "IPV4: Add point intents between h1 and h9" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700677 stepResult = main.intentFunction.pointIntent(
678 main,
679 name="IPV4",
680 host1="h1",
681 host2="h9",
682 deviceId1="of:0000000000000005/1",
683 deviceId2="of:0000000000000006/1",
684 port1="",
685 port2="",
686 ethType="IPV4",
687 mac1="00:00:00:00:00:01",
688 mac2="00:00:00:00:00:09",
689 bandwidth="",
690 lambdaAlloc=False,
691 ipProto="",
692 ip1="",
693 ip2="",
694 tcp1="",
695 tcp2="",
696 sw1="s5",
697 sw2="s2",
698 expectedLink=18 )
699
700 utilities.assert_equals( expect=main.TRUE,
701 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700702 onpass="IPV4: Point intent test " +
703 "successful using IPV4 type with " +
704 "MAC addresses",
705 onfail="IPV4: Point intent test " +
706 "failed using IPV4 type with " +
707 "MAC addresses" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700708 main.step( "IPV4_2: Add point intents between h1 and h9" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700709 stepResult = main.TRUE
710 stepResult = main.intentFunction.pointIntent(
711 main,
712 name="IPV4_2",
713 host1="h1",
714 host2="h9",
715 deviceId1="of:0000000000000005/1",
716 deviceId2="of:0000000000000006/1",
kelvin-onlabb769f562015-07-15 17:05:10 -0700717 ipProto="",
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700718 ip1="",
719 ip2="",
720 tcp1="",
721 tcp2="",
722 sw1="s5",
723 sw2="s2",
724 expectedLink=18 )
725
726 utilities.assert_equals( expect=main.TRUE,
727 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700728 onpass="IPV4_2: Point intent test " +
729 "successful using IPV4 type with " +
730 "no MAC addresses",
731 onfail="IPV4_2: Point intent test " +
732 "failed using IPV4 type with " +
733 "no MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700734
kelvin-onlabb769f562015-07-15 17:05:10 -0700735 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700736 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -0700737 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
738 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab0ad05d12015-07-23 14:21:15 -0700739 try:
740 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/24"
741 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/24"
742 except KeyError:
743 main.log.debug( "Key Error getting IP addresses of h1 | h9 in" +
744 "main.hostsData" )
745 ip1 = main.Mininet1.getIPAddress( 'h1')
746 ip2 = main.Mininet1.getIPAddress( 'h9')
747
kelvin-onlabb769f562015-07-15 17:05:10 -0700748 ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
kelvin-onlab79ce0492015-07-27 16:14:39 -0700749 # Uneccessary, not including this in the selectors
kelvin-onlabb769f562015-07-15 17:05:10 -0700750 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
751 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
752
753 stepResult = main.intentFunction.pointIntent(
754 main,
755 name="SDNIP-TCP",
756 host1="h1",
757 host2="h9",
758 deviceId1="of:0000000000000005/1",
759 deviceId2="of:0000000000000006/1",
760 mac1=mac1,
761 mac2=mac2,
762 ethType="IPV4",
763 ipProto=ipProto,
764 ip1=ip1,
kelvin-onlab79ce0492015-07-27 16:14:39 -0700765 ip2=ip2 )
kelvin-onlabb769f562015-07-15 17:05:10 -0700766
767 utilities.assert_equals( expect=main.TRUE,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700768 actual=stepResult,
769 onpass="SDNIP-TCP: Point intent test " +
770 "successful using IPV4 type with " +
771 "IP protocol TCP enabled",
772 onfail="SDNIP-TCP: Point intent test " +
773 "failed using IPV4 type with " +
774 "IP protocol TCP enabled" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700775
776 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
777 stepResult = main.TRUE
778 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
779 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
780 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/24"
781 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/24"
782 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
783 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
784 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
785
786 stepResult = main.intentFunction.pointIntent(
787 main,
788 name="SDNIP-ICMP",
789 host1="h1",
790 host2="h9",
791 deviceId1="of:0000000000000005/1",
792 deviceId2="of:0000000000000006/1",
793 mac1=mac1,
794 mac2=mac2,
795 ethType="IPV4",
796 ipProto=ipProto )
797
798 utilities.assert_equals( expect=main.TRUE,
799 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700800 onpass="SDNIP-ICMP: Point intent test " +
801 "successful using IPV4 type with " +
802 "IP protocol ICMP enabled",
803 onfail="SDNIP-ICMP: Point intent test " +
804 "failed using IPV4 type with " +
805 "IP protocol ICMP enabled" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700806
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700807 main.step( "DUALSTACK1: Add point intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700808 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700809 stepResult = main.intentFunction.pointIntent(
810 main,
811 name="DUALSTACK1",
812 host1="h3",
813 host2="h11",
814 deviceId1="of:0000000000000005",
815 deviceId2="of:0000000000000006",
816 port1="3",
817 port2="3",
818 ethType="IPV4",
819 mac1="00:00:00:00:00:03",
820 mac2="00:00:00:00:00:0B",
821 bandwidth="",
822 lambdaAlloc=False,
823 ipProto="",
824 ip1="",
825 ip2="",
826 tcp1="",
827 tcp2="",
828 sw1="s5",
829 sw2="s2",
830 expectedLink=18 )
831
832 utilities.assert_equals( expect=main.TRUE,
833 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700834 onpass="DUALSTACK1: Point intent test " +
835 "successful using IPV4 type with " +
836 "MAC addresses",
837 onfail="DUALSTACK1: Point intent test " +
838 "failed using IPV4 type with " +
839 "MAC addresses" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700840
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700841 main.step( "VLAN: Add point intents between h5 and h21" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700842 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700843 stepResult = main.intentFunction.pointIntent(
844 main,
845 name="VLAN",
846 host1="h5",
847 host2="h21",
848 deviceId1="of:0000000000000005/5",
849 deviceId2="of:0000000000000007/5",
850 port1="",
851 port2="",
852 ethType="IPV4",
853 mac1="00:00:00:00:00:05",
854 mac2="00:00:00:00:00:15",
855 bandwidth="",
856 lambdaAlloc=False,
857 ipProto="",
858 ip1="",
859 ip2="",
860 tcp1="",
861 tcp2="",
862 sw1="s5",
863 sw2="s2",
864 expectedLink=18 )
865
866 utilities.assert_equals( expect=main.TRUE,
867 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700868 onpass="VLAN1: Point intent test " +
869 "successful using IPV4 type with " +
870 "MAC addresses",
871 onfail="VLAN1: Point intent test " +
872 "failed using IPV4 type with " +
873 "MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700874
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700875 main.step( "1HOP: Add point intents between h1 and h3" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700876 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700877 stepResult = main.intentFunction.hostIntent( main,
878 name='1HOP',
879 host1='h1',
880 host2='h3' )
881
882 utilities.assert_equals( expect=main.TRUE,
883 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700884 onpass="1HOP: Point intent test " +
885 "successful using IPV4 type with " +
886 "no MAC addresses",
887 onfail="1HOP: Point intent test " +
888 "failed using IPV4 type with " +
889 "no MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700890
kelvin-onlabb769f562015-07-15 17:05:10 -0700891 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700892 """
893 Add single point to multi point intents
894 - Get device ids
895 - Add single point to multi point intents
896 - Check intents
897 - Verify flows
898 - Ping hosts
899 - Reroute
900 - Link down
901 - Verify flows
902 - Check topology
903 - Ping hosts
904 - Link up
905 - Verify flows
906 - Check topology
907 - Ping hosts
908 - Remove intents
909 """
910 assert main, "There is no main"
911 assert main.CLIs, "There is no main.CLIs"
912 assert main.Mininet1, "Mininet handle should be named Mininet1"
913 assert main.numSwitch, "Placed the total number of switch topology in \
914 main.numSwitch"
915
kelvin-onlab825b57d2015-07-24 13:43:59 -0700916 main.case( "Single To Multi Point Intents Test - " +
kelvin-onlabe5c1ada2015-07-24 11:49:40 -0700917 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700918 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700919 " multi point intents using " +\
920 str( main.numCtrls ) + " node(s) cluster;\n" +\
921 "Different type of hosts will be tested in " +\
922 "each step such as IPV4, Dual stack, VLAN etc" +\
923 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700924 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700925
kelvin-onlabb769f562015-07-15 17:05:10 -0700926 main.step( "NOOPTION: Add single point to multi point intents" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700927 stepResult = main.TRUE
928 hostNames = [ 'h8', 'h16', 'h24' ]
929 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
930 'of:0000000000000007/8' ]
931 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 -0700932 stepResult = main.intentFunction.singleToMultiIntent(
933 main,
934 name="NOOPTION",
935 hostNames=hostNames,
936 devices=devices,
937 sw1="s5",
938 sw2="s2",
939 expectedLink=18 )
940
941 utilities.assert_equals( expect=main.TRUE,
942 actual=stepResult,
943 onpass="NOOPTION: Successfully added single "
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700944 + " point to multi point intents" +
945 " with no match action",
946 onfail="NOOPTION: Failed to add single point"
947 + " point to multi point intents" +
948 " with no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700949
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700950 main.step( "IPV4: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700951 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700952 stepResult = main.intentFunction.singleToMultiIntent(
953 main,
954 name="IPV4",
955 hostNames=hostNames,
956 devices=devices,
957 ports=None,
958 ethType="IPV4",
959 macs=macs,
960 bandwidth="",
961 lambdaAlloc=False,
962 ipProto="",
963 ipAddresses="",
964 tcp="",
965 sw1="s5",
966 sw2="s2",
967 expectedLink=18 )
968
969 utilities.assert_equals( expect=main.TRUE,
970 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700971 onpass="IPV4: Successfully added single "
972 + " point to multi point intents" +
973 " with IPV4 type and MAC addresses",
974 onfail="IPV4: Failed to add single point"
975 + " point to multi point intents" +
976 " with IPV4 type and MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700977
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700978 main.step( "IPV4_2: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700979 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700980 hostNames = [ 'h8', 'h16', 'h24' ]
981 stepResult = main.intentFunction.singleToMultiIntent(
982 main,
983 name="IPV4",
984 hostNames=hostNames,
985 ethType="IPV4",
986 lambdaAlloc=False )
987
988 utilities.assert_equals( expect=main.TRUE,
989 actual=stepResult,
990 onpass="IPV4_2: Successfully added single "
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700991 + " point to multi point intents" +
992 " with IPV4 type and no MAC addresses",
993 onfail="IPV4_2: Failed to add single point"
994 + " point to multi point intents" +
995 " with IPV4 type and no MAC addresses" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700996
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700997 main.step( "VLAN: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700998 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700999 hostNames = [ 'h4', 'h12', 'h20' ]
1000 devices = [ 'of:0000000000000005/4', 'of:0000000000000006/4', \
1001 'of:0000000000000007/4' ]
1002 macs = [ '00:00:00:00:00:04', '00:00:00:00:00:0C', '00:00:00:00:00:14' ]
1003 stepResult = main.intentFunction.singleToMultiIntent(
1004 main,
1005 name="VLAN",
1006 hostNames=hostNames,
1007 devices=devices,
1008 ports=None,
1009 ethType="IPV4",
1010 macs=macs,
1011 bandwidth="",
1012 lambdaAlloc=False,
1013 ipProto="",
1014 ipAddresses="",
1015 tcp="",
1016 sw1="s5",
1017 sw2="s2",
1018 expectedLink=18 )
1019
1020 utilities.assert_equals( expect=main.TRUE,
1021 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001022 onpass="VLAN: Successfully added single "
1023 + " point to multi point intents" +
1024 " with IPV4 type and MAC addresses" +
1025 " in the same VLAN",
1026 onfail="VLAN: Failed to add single point"
1027 + " point to multi point intents" +
1028 " with IPV4 type and MAC addresses" +
1029 " in the same VLAN")
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001030
kelvin-onlabb769f562015-07-15 17:05:10 -07001031 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001032 """
1033 Add multi point to single point intents
1034 - Get device ids
1035 - Add multi point to single point intents
1036 - Check intents
1037 - Verify flows
1038 - Ping hosts
1039 - Reroute
1040 - Link down
1041 - Verify flows
1042 - Check topology
1043 - Ping hosts
1044 - Link up
1045 - Verify flows
1046 - Check topology
1047 - Ping hosts
1048 - Remove intents
1049 """
1050 assert main, "There is no main"
1051 assert main.CLIs, "There is no main.CLIs"
1052 assert main.Mininet1, "Mininet handle should be named Mininet1"
1053 assert main.numSwitch, "Placed the total number of switch topology in \
1054 main.numSwitch"
1055
kelvin-onlab825b57d2015-07-24 13:43:59 -07001056 main.case( "Multi To Single Point Intents Test - " +
kelvin-onlabe5c1ada2015-07-24 11:49:40 -07001057 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -07001058 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001059 " multi point intents using " +\
1060 str( main.numCtrls ) + " node(s) cluster;\n" +\
1061 "Different type of hosts will be tested in " +\
1062 "each step such as IPV4, Dual stack, VLAN etc" +\
1063 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -07001064 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001065
kelvin-onlabb769f562015-07-15 17:05:10 -07001066 main.step( "NOOPTION: Add multi point to single point intents" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001067 stepResult = main.TRUE
1068 hostNames = [ 'h8', 'h16', 'h24' ]
1069 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
1070 'of:0000000000000007/8' ]
1071 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 -07001072 stepResult = main.intentFunction.multiToSingleIntent(
1073 main,
1074 name="NOOPTION",
1075 hostNames=hostNames,
1076 devices=devices,
1077 sw1="s5",
1078 sw2="s2",
1079 expectedLink=18 )
1080
1081 utilities.assert_equals( expect=main.TRUE,
1082 actual=stepResult,
1083 onpass="NOOPTION: Successfully added multi "
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001084 + " point to single point intents" +
1085 " with no match action",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001086 onfail="NOOPTION: Failed to add multi point" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001087 " to single point intents" +
1088 " with no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001089
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001090 main.step( "IPV4: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001091 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001092 stepResult = main.intentFunction.multiToSingleIntent(
1093 main,
1094 name="IPV4",
1095 hostNames=hostNames,
1096 devices=devices,
1097 ports=None,
1098 ethType="IPV4",
1099 macs=macs,
1100 bandwidth="",
1101 lambdaAlloc=False,
1102 ipProto="",
1103 ipAddresses="",
1104 tcp="",
1105 sw1="s5",
1106 sw2="s2",
1107 expectedLink=18 )
1108
1109 utilities.assert_equals( expect=main.TRUE,
1110 actual=stepResult,
1111 onpass="IPV4: Successfully added 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 onfail="IPV4: Failed to add multi point" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001115 " to single point intents" +
1116 " with IPV4 type and MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001117
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001118 main.step( "IPV4_2: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001119 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001120 hostNames = [ 'h8', 'h16', 'h24' ]
1121 stepResult = main.intentFunction.multiToSingleIntent(
1122 main,
1123 name="IPV4",
1124 hostNames=hostNames,
1125 ethType="IPV4",
1126 lambdaAlloc=False )
1127
1128 utilities.assert_equals( expect=main.TRUE,
1129 actual=stepResult,
1130 onpass="IPV4_2: Successfully added 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 onfail="IPV4_2: Failed to add multi point" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001134 " to single point intents" +
1135 " with IPV4 type and no MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001136
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001137 main.step( "VLAN: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001138 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001139 hostNames = [ 'h5', 'h13', 'h21' ]
1140 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \
1141 'of:0000000000000007/5' ]
1142 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
1143 stepResult = main.intentFunction.multiToSingleIntent(
1144 main,
1145 name="VLAN",
1146 hostNames=hostNames,
1147 devices=devices,
1148 ports=None,
1149 ethType="IPV4",
1150 macs=macs,
1151 bandwidth="",
1152 lambdaAlloc=False,
1153 ipProto="",
1154 ipAddresses="",
1155 tcp="",
1156 sw1="s5",
1157 sw2="s2",
1158 expectedLink=18 )
1159
1160 utilities.assert_equals( expect=main.TRUE,
1161 actual=stepResult,
1162 onpass="VLAN: Successfully added multi point"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001163 + " to single point intents" +
1164 " with IPV4 type and MAC addresses" +
1165 " in the same VLAN",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001166 onfail="VLAN: Failed to add multi point" +
1167 " to single point intents" )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001168
acsmars1ff5e052015-07-23 11:27:48 -07001169 def CASE5000( self, main ):
1170 """
1171 Will add description in next patch set
acsmars1ff5e052015-07-23 11:27:48 -07001172 """
1173 assert main, "There is no main"
1174 assert main.CLIs, "There is no main.CLIs"
1175 assert main.Mininet1, "Mininet handle should be named Mininet1"
1176 assert main.numSwitch, "Placed the total number of switch topology in \
1177 main.numSwitch"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001178 main.case( "Test host mobility with host intents " )
1179 main.step( " Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07001180 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1181
1182 main.log.info( "Moving h1 from s5 to s6")
1183
1184 main.Mininet1.moveHost( "h1","s5","s6" )
1185
1186 main.intentFunction.getHostsData( main )
1187 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1188
1189 utilities.assert_equals( expect="of:0000000000000006",
1190 actual=h1PostMove,
1191 onpass="Mobility: Successfully moved h1 to s6",
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001192 onfail="Mobility: Failed to moved h1 to s6" +
1193 " to single point intents" +
1194 " with IPV4 type and MAC addresses" +
1195 " in the same VLAN" )
1196
1197 main.step( "IPV4: Add host intents between h1 and h9" )
1198 stepResult = main.TRUE
1199 stepResult = main.intentFunction.hostIntent( main,
1200 onosNode='0',
1201 name='IPV4',
1202 host1='h1',
1203 host2='h9',
1204 host1Id='00:00:00:00:00:01/-1',
1205 host2Id='00:00:00:00:00:09/-1' )
1206
1207 utilities.assert_equals( expect=main.TRUE,
1208 actual=stepResult,
1209 onpass="IPV4: Host intent test successful " +
1210 "between two IPV4 hosts",
1211 onfail="IPV4: Host intent test failed " +
1212 "between two IPV4 hosts")