blob: eff6b164971f9deb8b2b9ece1f0f3a6849601534 [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' ]
749 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
750 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
751
752 stepResult = main.intentFunction.pointIntent(
753 main,
754 name="SDNIP-TCP",
755 host1="h1",
756 host2="h9",
757 deviceId1="of:0000000000000005/1",
758 deviceId2="of:0000000000000006/1",
759 mac1=mac1,
760 mac2=mac2,
761 ethType="IPV4",
762 ipProto=ipProto,
763 ip1=ip1,
764 ip2=ip2,
765 tcp1=tcp1,
766 tcp2=tcp2 )
767
768 utilities.assert_equals( expect=main.TRUE,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700769 actual=stepResult,
770 onpass="SDNIP-TCP: Point intent test " +
771 "successful using IPV4 type with " +
772 "IP protocol TCP enabled",
773 onfail="SDNIP-TCP: Point intent test " +
774 "failed using IPV4 type with " +
775 "IP protocol TCP enabled" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700776
777 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
778 stepResult = main.TRUE
779 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
780 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
781 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/24"
782 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/24"
783 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
784 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
785 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
786
787 stepResult = main.intentFunction.pointIntent(
788 main,
789 name="SDNIP-ICMP",
790 host1="h1",
791 host2="h9",
792 deviceId1="of:0000000000000005/1",
793 deviceId2="of:0000000000000006/1",
794 mac1=mac1,
795 mac2=mac2,
796 ethType="IPV4",
797 ipProto=ipProto )
798
799 utilities.assert_equals( expect=main.TRUE,
800 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700801 onpass="SDNIP-ICMP: Point intent test " +
802 "successful using IPV4 type with " +
803 "IP protocol ICMP enabled",
804 onfail="SDNIP-ICMP: Point intent test " +
805 "failed using IPV4 type with " +
806 "IP protocol ICMP enabled" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700807
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700808 main.step( "DUALSTACK1: Add point intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700809 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700810 stepResult = main.intentFunction.pointIntent(
811 main,
812 name="DUALSTACK1",
813 host1="h3",
814 host2="h11",
815 deviceId1="of:0000000000000005",
816 deviceId2="of:0000000000000006",
817 port1="3",
818 port2="3",
819 ethType="IPV4",
820 mac1="00:00:00:00:00:03",
821 mac2="00:00:00:00:00:0B",
822 bandwidth="",
823 lambdaAlloc=False,
824 ipProto="",
825 ip1="",
826 ip2="",
827 tcp1="",
828 tcp2="",
829 sw1="s5",
830 sw2="s2",
831 expectedLink=18 )
832
833 utilities.assert_equals( expect=main.TRUE,
834 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700835 onpass="DUALSTACK1: Point intent test " +
836 "successful using IPV4 type with " +
837 "MAC addresses",
838 onfail="DUALSTACK1: Point intent test " +
839 "failed using IPV4 type with " +
840 "MAC addresses" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700841
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700842 main.step( "VLAN: Add point intents between h5 and h21" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700843 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700844 stepResult = main.intentFunction.pointIntent(
845 main,
846 name="VLAN",
847 host1="h5",
848 host2="h21",
849 deviceId1="of:0000000000000005/5",
850 deviceId2="of:0000000000000007/5",
851 port1="",
852 port2="",
853 ethType="IPV4",
854 mac1="00:00:00:00:00:05",
855 mac2="00:00:00:00:00:15",
856 bandwidth="",
857 lambdaAlloc=False,
858 ipProto="",
859 ip1="",
860 ip2="",
861 tcp1="",
862 tcp2="",
863 sw1="s5",
864 sw2="s2",
865 expectedLink=18 )
866
867 utilities.assert_equals( expect=main.TRUE,
868 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700869 onpass="VLAN1: Point intent test " +
870 "successful using IPV4 type with " +
871 "MAC addresses",
872 onfail="VLAN1: Point intent test " +
873 "failed using IPV4 type with " +
874 "MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700875
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700876 main.step( "1HOP: Add point intents between h1 and h3" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700877 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700878 stepResult = main.intentFunction.hostIntent( main,
879 name='1HOP',
880 host1='h1',
881 host2='h3' )
882
883 utilities.assert_equals( expect=main.TRUE,
884 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700885 onpass="1HOP: Point intent test " +
886 "successful using IPV4 type with " +
887 "no MAC addresses",
888 onfail="1HOP: Point intent test " +
889 "failed using IPV4 type with " +
890 "no MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700891
kelvin-onlabb769f562015-07-15 17:05:10 -0700892 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700893 """
894 Add single point to multi point intents
895 - Get device ids
896 - Add single point to multi point intents
897 - Check intents
898 - Verify flows
899 - Ping hosts
900 - Reroute
901 - Link down
902 - Verify flows
903 - Check topology
904 - Ping hosts
905 - Link up
906 - Verify flows
907 - Check topology
908 - Ping hosts
909 - Remove intents
910 """
911 assert main, "There is no main"
912 assert main.CLIs, "There is no main.CLIs"
913 assert main.Mininet1, "Mininet handle should be named Mininet1"
914 assert main.numSwitch, "Placed the total number of switch topology in \
915 main.numSwitch"
916
kelvin-onlab825b57d2015-07-24 13:43:59 -0700917 main.case( "Single To Multi Point Intents Test - " +
kelvin-onlabe5c1ada2015-07-24 11:49:40 -0700918 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700919 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700920 " multi point intents using " +\
921 str( main.numCtrls ) + " node(s) cluster;\n" +\
922 "Different type of hosts will be tested in " +\
923 "each step such as IPV4, Dual stack, VLAN etc" +\
924 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700925 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700926
kelvin-onlabb769f562015-07-15 17:05:10 -0700927 main.step( "NOOPTION: Add single point to multi point intents" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700928 stepResult = main.TRUE
929 hostNames = [ 'h8', 'h16', 'h24' ]
930 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
931 'of:0000000000000007/8' ]
932 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 -0700933 stepResult = main.intentFunction.singleToMultiIntent(
934 main,
935 name="NOOPTION",
936 hostNames=hostNames,
937 devices=devices,
938 sw1="s5",
939 sw2="s2",
940 expectedLink=18 )
941
942 utilities.assert_equals( expect=main.TRUE,
943 actual=stepResult,
944 onpass="NOOPTION: Successfully added single "
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700945 + " point to multi point intents" +
946 " with no match action",
947 onfail="NOOPTION: Failed to add single point"
948 + " point to multi point intents" +
949 " with no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700950
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700951 main.step( "IPV4: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700952 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700953 stepResult = main.intentFunction.singleToMultiIntent(
954 main,
955 name="IPV4",
956 hostNames=hostNames,
957 devices=devices,
958 ports=None,
959 ethType="IPV4",
960 macs=macs,
961 bandwidth="",
962 lambdaAlloc=False,
963 ipProto="",
964 ipAddresses="",
965 tcp="",
966 sw1="s5",
967 sw2="s2",
968 expectedLink=18 )
969
970 utilities.assert_equals( expect=main.TRUE,
971 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700972 onpass="IPV4: Successfully added single "
973 + " point to multi point intents" +
974 " with IPV4 type and MAC addresses",
975 onfail="IPV4: Failed to add single point"
976 + " point to multi point intents" +
977 " with IPV4 type and MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700978
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700979 main.step( "IPV4_2: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700980 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700981 hostNames = [ 'h8', 'h16', 'h24' ]
982 stepResult = main.intentFunction.singleToMultiIntent(
983 main,
984 name="IPV4",
985 hostNames=hostNames,
986 ethType="IPV4",
987 lambdaAlloc=False )
988
989 utilities.assert_equals( expect=main.TRUE,
990 actual=stepResult,
991 onpass="IPV4_2: Successfully added single "
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700992 + " point to multi point intents" +
993 " with IPV4 type and no MAC addresses",
994 onfail="IPV4_2: Failed to add single point"
995 + " point to multi point intents" +
996 " with IPV4 type and no MAC addresses" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700997
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700998 main.step( "VLAN: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700999 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001000 hostNames = [ 'h4', 'h12', 'h20' ]
1001 devices = [ 'of:0000000000000005/4', 'of:0000000000000006/4', \
1002 'of:0000000000000007/4' ]
1003 macs = [ '00:00:00:00:00:04', '00:00:00:00:00:0C', '00:00:00:00:00:14' ]
1004 stepResult = main.intentFunction.singleToMultiIntent(
1005 main,
1006 name="VLAN",
1007 hostNames=hostNames,
1008 devices=devices,
1009 ports=None,
1010 ethType="IPV4",
1011 macs=macs,
1012 bandwidth="",
1013 lambdaAlloc=False,
1014 ipProto="",
1015 ipAddresses="",
1016 tcp="",
1017 sw1="s5",
1018 sw2="s2",
1019 expectedLink=18 )
1020
1021 utilities.assert_equals( expect=main.TRUE,
1022 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001023 onpass="VLAN: Successfully added single "
1024 + " point to multi point intents" +
1025 " with IPV4 type and MAC addresses" +
1026 " in the same VLAN",
1027 onfail="VLAN: Failed to add single point"
1028 + " point to multi point intents" +
1029 " with IPV4 type and MAC addresses" +
1030 " in the same VLAN")
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001031
kelvin-onlabb769f562015-07-15 17:05:10 -07001032 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001033 """
1034 Add multi point to single point intents
1035 - Get device ids
1036 - Add multi point to single point intents
1037 - Check intents
1038 - Verify flows
1039 - Ping hosts
1040 - Reroute
1041 - Link down
1042 - Verify flows
1043 - Check topology
1044 - Ping hosts
1045 - Link up
1046 - Verify flows
1047 - Check topology
1048 - Ping hosts
1049 - Remove intents
1050 """
1051 assert main, "There is no main"
1052 assert main.CLIs, "There is no main.CLIs"
1053 assert main.Mininet1, "Mininet handle should be named Mininet1"
1054 assert main.numSwitch, "Placed the total number of switch topology in \
1055 main.numSwitch"
1056
kelvin-onlab825b57d2015-07-24 13:43:59 -07001057 main.case( "Multi To Single Point Intents Test - " +
kelvin-onlabe5c1ada2015-07-24 11:49:40 -07001058 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -07001059 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001060 " multi point intents using " +\
1061 str( main.numCtrls ) + " node(s) cluster;\n" +\
1062 "Different type of hosts will be tested in " +\
1063 "each step such as IPV4, Dual stack, VLAN etc" +\
1064 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -07001065 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001066
kelvin-onlabb769f562015-07-15 17:05:10 -07001067 main.step( "NOOPTION: Add multi point to single point intents" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001068 stepResult = main.TRUE
1069 hostNames = [ 'h8', 'h16', 'h24' ]
1070 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
1071 'of:0000000000000007/8' ]
1072 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 -07001073 stepResult = main.intentFunction.multiToSingleIntent(
1074 main,
1075 name="NOOPTION",
1076 hostNames=hostNames,
1077 devices=devices,
1078 sw1="s5",
1079 sw2="s2",
1080 expectedLink=18 )
1081
1082 utilities.assert_equals( expect=main.TRUE,
1083 actual=stepResult,
1084 onpass="NOOPTION: Successfully added multi "
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001085 + " point to single point intents" +
1086 " with no match action",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001087 onfail="NOOPTION: Failed to add multi point" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001088 " to single point intents" +
1089 " with no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001090
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001091 main.step( "IPV4: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001092 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001093 stepResult = main.intentFunction.multiToSingleIntent(
1094 main,
1095 name="IPV4",
1096 hostNames=hostNames,
1097 devices=devices,
1098 ports=None,
1099 ethType="IPV4",
1100 macs=macs,
1101 bandwidth="",
1102 lambdaAlloc=False,
1103 ipProto="",
1104 ipAddresses="",
1105 tcp="",
1106 sw1="s5",
1107 sw2="s2",
1108 expectedLink=18 )
1109
1110 utilities.assert_equals( expect=main.TRUE,
1111 actual=stepResult,
1112 onpass="IPV4: Successfully added multi point"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001113 + " to single point intents" +
1114 " with IPV4 type and MAC addresses",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001115 onfail="IPV4: Failed to add multi point" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001116 " to single point intents" +
1117 " with IPV4 type and MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001118
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001119 main.step( "IPV4_2: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001120 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001121 hostNames = [ 'h8', 'h16', 'h24' ]
1122 stepResult = main.intentFunction.multiToSingleIntent(
1123 main,
1124 name="IPV4",
1125 hostNames=hostNames,
1126 ethType="IPV4",
1127 lambdaAlloc=False )
1128
1129 utilities.assert_equals( expect=main.TRUE,
1130 actual=stepResult,
1131 onpass="IPV4_2: Successfully added multi point"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001132 + " to single point intents" +
1133 " with IPV4 type and no MAC addresses",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001134 onfail="IPV4_2: Failed to add multi point" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001135 " to single point intents" +
1136 " with IPV4 type and no MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001137
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001138 main.step( "VLAN: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001139 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001140 hostNames = [ 'h5', 'h13', 'h21' ]
1141 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \
1142 'of:0000000000000007/5' ]
1143 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
1144 stepResult = main.intentFunction.multiToSingleIntent(
1145 main,
1146 name="VLAN",
1147 hostNames=hostNames,
1148 devices=devices,
1149 ports=None,
1150 ethType="IPV4",
1151 macs=macs,
1152 bandwidth="",
1153 lambdaAlloc=False,
1154 ipProto="",
1155 ipAddresses="",
1156 tcp="",
1157 sw1="s5",
1158 sw2="s2",
1159 expectedLink=18 )
1160
1161 utilities.assert_equals( expect=main.TRUE,
1162 actual=stepResult,
1163 onpass="VLAN: Successfully added multi point"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001164 + " to single point intents" +
1165 " with IPV4 type and MAC addresses" +
1166 " in the same VLAN",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001167 onfail="VLAN: Failed to add multi point" +
1168 " to single point intents" )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001169
acsmars1ff5e052015-07-23 11:27:48 -07001170 def CASE5000( self, main ):
1171 """
1172 Will add description in next patch set
acsmars1ff5e052015-07-23 11:27:48 -07001173 """
1174 assert main, "There is no main"
1175 assert main.CLIs, "There is no main.CLIs"
1176 assert main.Mininet1, "Mininet handle should be named Mininet1"
1177 assert main.numSwitch, "Placed the total number of switch topology in \
1178 main.numSwitch"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001179 main.case( "Test host mobility with host intents " )
1180 main.step( " Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07001181 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1182
1183 main.log.info( "Moving h1 from s5 to s6")
1184
1185 main.Mininet1.moveHost( "h1","s5","s6" )
1186
1187 main.intentFunction.getHostsData( main )
1188 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1189
1190 utilities.assert_equals( expect="of:0000000000000006",
1191 actual=h1PostMove,
1192 onpass="Mobility: Successfully moved h1 to s6",
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001193 onfail="Mobility: Failed to moved h1 to s6" +
1194 " to single point intents" +
1195 " with IPV4 type and MAC addresses" +
1196 " in the same VLAN" )
1197
1198 main.step( "IPV4: Add host intents between h1 and h9" )
1199 stepResult = main.TRUE
1200 stepResult = main.intentFunction.hostIntent( main,
1201 onosNode='0',
1202 name='IPV4',
1203 host1='h1',
1204 host2='h9',
1205 host1Id='00:00:00:00:00:01/-1',
1206 host2Id='00:00:00:00:00:09/-1' )
1207
1208 utilities.assert_equals( expect=main.TRUE,
1209 actual=stepResult,
1210 onpass="IPV4: Host intent test successful " +
1211 "between two IPV4 hosts",
1212 onfail="IPV4: Host intent test failed " +
1213 "between two IPV4 hosts")