blob: 6aafd10150d376027e694963843d97d9dd360dee [file] [log] [blame]
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001# Testing the basic intent functionality of ONOS
2
kelvin-onlabd48a68c2015-07-13 16:01:36 -07003class FUNCintent:
4
5 def __init__( self ):
6 self.default = ''
7
8 def CASE1( self, main ):
9 import time
10 import os
11 import imp
Jon Hallf632d202015-07-30 15:45:11 -070012 import re
kelvin-onlabd48a68c2015-07-13 16:01:36 -070013
14 """
15 - Construct tests variables
16 - GIT ( optional )
17 - Checkout ONOS master branch
18 - Pull latest ONOS code
19 - Building ONOS ( optional )
20 - Install ONOS package
21 - Build ONOS package
22 """
23
24 main.case( "Constructing test variables and building ONOS package" )
25 main.step( "Constructing test variables" )
Jon Hall783bbf92015-07-23 14:33:19 -070026 main.caseExplanation = "This test case is mainly for loading " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -070027 "from params file, and pull and build the " +\
28 " latest ONOS package"
kelvin-onlabd48a68c2015-07-13 16:01:36 -070029 stepResult = main.FALSE
30
31 # Test variables
Jon Halla3e02432015-07-24 15:55:42 -070032 try:
Jon Hallf632d202015-07-30 15:45:11 -070033 main.testOnDirectory = re.sub( "(/tests)$", "", main.testDir )
Jon Halla3e02432015-07-24 15:55:42 -070034 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
35 gitBranch = main.params[ 'GIT' ][ 'branch' ]
36 main.dependencyPath = main.testOnDirectory + \
37 main.params[ 'DEPENDENCY' ][ 'path' ]
38 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
39 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
40 if main.ONOSbench.maxNodes:
41 main.maxNodes = int( main.ONOSbench.maxNodes )
42 else:
43 main.maxNodes = 0
44 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
45 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
46 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
47 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
48 main.checkIntentSleep = int( main.params[ 'SLEEP' ][ 'checkintent' ] )
acsmarscfa52272015-08-06 15:21:45 -070049 main.removeIntentSleep = int( main.params[ 'SLEEP' ][ 'removeintent' ] )
Jon Halla3e02432015-07-24 15:55:42 -070050 main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] )
51 main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
52 gitPull = main.params[ 'GIT' ][ 'pull' ]
53 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
54 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
55 main.cellData = {} # for creating cell file
56 main.hostsData = {}
57 main.CLIs = []
58 main.ONOSip = []
kelvin-onlabd48a68c2015-07-13 16:01:36 -070059
Jon Halla3e02432015-07-24 15:55:42 -070060 main.ONOSip = main.ONOSbench.getOnosIps()
61 print main.ONOSip
kelvin-onlabd48a68c2015-07-13 16:01:36 -070062
Jon Halla3e02432015-07-24 15:55:42 -070063 # Assigning ONOS cli handles to a list
64 for i in range( 1, main.maxNodes + 1 ):
65 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070066
Jon Halla3e02432015-07-24 15:55:42 -070067 # -- INIT SECTION, ONLY RUNS ONCE -- #
68 main.startUp = imp.load_source( wrapperFile1,
69 main.dependencyPath +
70 wrapperFile1 +
71 ".py" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070072
Jon Halla3e02432015-07-24 15:55:42 -070073 main.intentFunction = imp.load_source( wrapperFile2,
74 main.dependencyPath +
75 wrapperFile2 +
76 ".py" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070077
Jon Halla3e02432015-07-24 15:55:42 -070078 main.topo = imp.load_source( wrapperFile3,
79 main.dependencyPath +
80 wrapperFile3 +
81 ".py" )
82
kelvin-onlabd9e23de2015-08-06 10:34:44 -070083 copyResult1 = main.ONOSbench.scp( main.Mininet1,
84 main.dependencyPath +
85 main.topology,
86 main.Mininet1.home,
87 direction="to" )
Jon Halla3e02432015-07-24 15:55:42 -070088 if main.CLIs:
89 stepResult = main.TRUE
90 else:
91 main.log.error( "Did not properly created list of ONOS CLI handle" )
92 stepResult = main.FALSE
93 except Exception as e:
94 main.log.exception(e)
95 main.cleanup()
96 main.exit()
kelvin-onlabd48a68c2015-07-13 16:01:36 -070097
98 utilities.assert_equals( expect=main.TRUE,
99 actual=stepResult,
100 onpass="Successfully construct " +
101 "test variables ",
102 onfail="Failed to construct test variables" )
103
104 if gitPull == 'True':
105 main.step( "Building ONOS in " + gitBranch + " branch" )
106 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
107 stepResult = onosBuildResult
108 utilities.assert_equals( expect=main.TRUE,
109 actual=stepResult,
110 onpass="Successfully compiled " +
111 "latest ONOS",
112 onfail="Failed to compile " +
113 "latest ONOS" )
114 else:
115 main.log.warn( "Did not pull new code so skipping mvn " +
116 "clean install" )
Jon Hall106be082015-07-22 09:53:00 -0700117 main.ONOSbench.getVersion( report=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700118
119 def CASE2( self, main ):
120 """
121 - Set up cell
122 - Create cell file
123 - Set cell file
124 - Verify cell file
125 - Kill ONOS process
126 - Uninstall ONOS cluster
127 - Verify ONOS start up
128 - Install ONOS cluster
129 - Connect to cli
130 """
131
132 # main.scale[ 0 ] determines the current number of ONOS controller
133 main.numCtrls = int( main.scale[ 0 ] )
134
135 main.case( "Starting up " + str( main.numCtrls ) +
136 " node(s) ONOS cluster" )
Jon Hall783bbf92015-07-23 14:33:19 -0700137 main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700138 " node(s) ONOS cluster"
139
140
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700141
142 #kill off all onos processes
143 main.log.info( "Safety check, killing all ONOS processes" +
144 " before initiating enviornment setup" )
145
146 for i in range( main.maxNodes ):
147 main.ONOSbench.onosDie( main.ONOSip[ i ] )
148
149 print "NODE COUNT = ", main.numCtrls
150
151 tempOnosIp = []
152 for i in range( main.numCtrls ):
153 tempOnosIp.append( main.ONOSip[i] )
154
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700155 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
156 "temp", main.Mininet1.ip_address,
157 main.apps, tempOnosIp )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700158
159 main.step( "Apply cell to environment" )
160 cellResult = main.ONOSbench.setCell( "temp" )
161 verifyResult = main.ONOSbench.verifyCell()
162 stepResult = cellResult and verifyResult
163 utilities.assert_equals( expect=main.TRUE,
164 actual=stepResult,
165 onpass="Successfully applied cell to " + \
166 "environment",
167 onfail="Failed to apply cell to environment " )
168
169 main.step( "Creating ONOS package" )
170 packageResult = main.ONOSbench.onosPackage()
171 stepResult = packageResult
172 utilities.assert_equals( expect=main.TRUE,
173 actual=stepResult,
174 onpass="Successfully created ONOS package",
175 onfail="Failed to create ONOS package" )
176
177 time.sleep( main.startUpSleep )
178 main.step( "Uninstalling ONOS package" )
179 onosUninstallResult = main.TRUE
kelvin-onlab5f0d19e2015-08-04 15:21:00 -0700180 for ip in main.ONOSip:
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700181 onosUninstallResult = onosUninstallResult and \
kelvin-onlab5f0d19e2015-08-04 15:21:00 -0700182 main.ONOSbench.onosUninstall( nodeIp=ip )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700183 stepResult = onosUninstallResult
184 utilities.assert_equals( expect=main.TRUE,
185 actual=stepResult,
186 onpass="Successfully uninstalled ONOS package",
187 onfail="Failed to uninstall ONOS package" )
188
189 time.sleep( main.startUpSleep )
190 main.step( "Installing ONOS package" )
191 onosInstallResult = main.TRUE
192 for i in range( main.numCtrls ):
193 onosInstallResult = onosInstallResult and \
194 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
195 stepResult = onosInstallResult
196 utilities.assert_equals( expect=main.TRUE,
197 actual=stepResult,
198 onpass="Successfully installed ONOS package",
199 onfail="Failed to install ONOS package" )
200
201 time.sleep( main.startUpSleep )
202 main.step( "Starting ONOS service" )
203 stopResult = main.TRUE
204 startResult = main.TRUE
205 onosIsUp = main.TRUE
206
207 for i in range( main.numCtrls ):
208 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
209 if onosIsUp == main.TRUE:
210 main.log.report( "ONOS instance is up and ready" )
211 else:
212 main.log.report( "ONOS instance may not be up, stop and " +
213 "start ONOS again " )
214 for i in range( main.numCtrls ):
215 stopResult = stopResult and \
216 main.ONOSbench.onosStop( main.ONOSip[ i ] )
217 for i in range( main.numCtrls ):
218 startResult = startResult and \
219 main.ONOSbench.onosStart( main.ONOSip[ i ] )
220 stepResult = onosIsUp and stopResult and startResult
221 utilities.assert_equals( expect=main.TRUE,
222 actual=stepResult,
223 onpass="ONOS service is ready",
224 onfail="ONOS service did not start properly" )
225
226 main.step( "Start ONOS cli" )
227 cliResult = main.TRUE
228 for i in range( main.numCtrls ):
229 cliResult = cliResult and \
230 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
231 stepResult = cliResult
232 utilities.assert_equals( expect=main.TRUE,
233 actual=stepResult,
234 onpass="Successfully start ONOS cli",
235 onfail="Failed to start ONOS cli" )
236
237 # Remove the first element in main.scale list
238 main.scale.remove( main.scale[ 0 ] )
239
kelvin-onlab016dce22015-08-10 09:54:11 -0700240 main.intentFunction.report( main )
241
Jon Halla3e02432015-07-24 15:55:42 -0700242 def CASE8( self, main ):
243 """
244 Compare Topo
245 """
246 import json
247
248 main.case( "Compare ONOS Topology view to Mininet topology" )
249 main.caseExplanation = "Compare topology elements between Mininet" +\
250 " and ONOS"
251
252 main.step( "Gathering topology information" )
253 # TODO: add a paramaterized sleep here
254 devicesResults = main.TRUE
255 linksResults = main.TRUE
256 hostsResults = main.TRUE
257 devices = main.topo.getAllDevices( main )
258 hosts = main.topo.getAllHosts( main )
259 ports = main.topo.getAllPorts( main )
260 links = main.topo.getAllLinks( main )
261 clusters = main.topo.getAllClusters( main )
262
263 mnSwitches = main.Mininet1.getSwitches()
264 mnLinks = main.Mininet1.getLinks()
265 mnHosts = main.Mininet1.getHosts()
266
267 main.step( "Conmparing MN topology to ONOS topology" )
268 for controller in range( main.numCtrls ):
269 controllerStr = str( controller + 1 )
270 if devices[ controller ] and ports[ controller ] and\
271 "Error" not in devices[ controller ] and\
272 "Error" not in ports[ controller ]:
273
274 currentDevicesResult = main.Mininet1.compareSwitches(
275 mnSwitches,
276 json.loads( devices[ controller ] ),
277 json.loads( ports[ controller ] ) )
278 else:
279 currentDevicesResult = main.FALSE
280 utilities.assert_equals( expect=main.TRUE,
281 actual=currentDevicesResult,
282 onpass="ONOS" + controllerStr +
283 " Switches view is correct",
284 onfail="ONOS" + controllerStr +
285 " Switches view is incorrect" )
Jon Hall46d48252015-08-03 11:41:16 -0700286 devicesResults = devicesResults and currentDevicesResult
Jon Halla3e02432015-07-24 15:55:42 -0700287
288 if links[ controller ] and "Error" not in links[ controller ]:
289 currentLinksResult = main.Mininet1.compareLinks(
290 mnSwitches, mnLinks,
291 json.loads( links[ controller ] ) )
292 else:
293 currentLinksResult = main.FALSE
294 utilities.assert_equals( expect=main.TRUE,
295 actual=currentLinksResult,
296 onpass="ONOS" + controllerStr +
297 " links view is correct",
298 onfail="ONOS" + controllerStr +
299 " links view is incorrect" )
Jon Hall46d48252015-08-03 11:41:16 -0700300 linksResults = linksResults and currentLinksResult
Jon Halla3e02432015-07-24 15:55:42 -0700301
302 if hosts[ controller ] or "Error" not in hosts[ controller ]:
303 currentHostsResult = main.Mininet1.compareHosts(
304 mnHosts,
305 json.loads( hosts[ controller ] ) )
306 else:
307 currentHostsResult = main.FALSE
308 utilities.assert_equals( expect=main.TRUE,
309 actual=currentHostsResult,
310 onpass="ONOS" + controllerStr +
311 " hosts exist in Mininet",
312 onfail="ONOS" + controllerStr +
313 " hosts don't match Mininet" )
Jon Hall46d48252015-08-03 11:41:16 -0700314 hostsResults = hostsResults and currentHostsResult
315 topoResults = hostsResults and linksResults and devicesResults
316 utilities.assert_equals( expect=main.TRUE,
317 actual=topoResults,
318 onpass="ONOS correctly discovered the topology",
319 onfail="ONOS incorrectly discovered the topology" )
Jon Halla3e02432015-07-24 15:55:42 -0700320
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700321 def CASE10( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700322 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700323 Start Mininet topology with OF 1.0 switches
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700324 """
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700325 main.OFProtocol = "1.0"
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700326 main.log.report( "Start Mininet topology with OF 1.0 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700327 main.case( "Start Mininet topology with OF 1.0 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700328 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700329 "switches to test intents, exits out if " +\
330 "topology did not start correctly"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700331
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700332 main.step( "Starting Mininet topology with OF 1.0 switches" )
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700333 args = "--switch ovs,protocols=OpenFlow10"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700334 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700335 main.topology,
336 args=args )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700337 stepResult = topoResult
338 utilities.assert_equals( expect=main.TRUE,
339 actual=stepResult,
340 onpass="Successfully loaded topology",
341 onfail="Failed to load topology" )
342 # Exit if topology did not load properly
343 if not topoResult:
344 main.cleanup()
345 main.exit()
346
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700347 def CASE11( self, main ):
348 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700349 Start Mininet topology with OF 1.3 switches
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700350 """
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700351 main.OFProtocol = "1.3"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700352 main.log.report( "Start Mininet topology with OF 1.3 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700353 main.case( "Start Mininet topology with OF 1.3 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700354 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700355 "switches to test intents, exits out if " +\
356 "topology did not start correctly"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700357
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700358 main.step( "Starting Mininet topology with OF 1.3 switches" )
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700359 args = "--switch ovs,protocols=OpenFlow13"
360 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
361 main.topology,
362 args=args )
363 stepResult = topoResult
364 utilities.assert_equals( expect=main.TRUE,
365 actual=stepResult,
366 onpass="Successfully loaded topology",
367 onfail="Failed to load topology" )
368 # Exit if topology did not load properly
369 if not topoResult:
370 main.cleanup()
371 main.exit()
372
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700373 def CASE12( self, main ):
374 """
375 Assign mastership to controllers
376 """
377 import re
378
379 main.case( "Assign switches to controllers" )
380 main.step( "Assigning switches to controllers" )
Jon Hall783bbf92015-07-23 14:33:19 -0700381 main.caseExplanation = "Assign OF " + main.OFProtocol +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700382 " switches to ONOS nodes"
383
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700384 assignResult = main.TRUE
385 switchList = []
386
387 # Creates a list switch name, use getSwitch() function later...
388 for i in range( 1, ( main.numSwitch + 1 ) ):
389 switchList.append( 's' + str( i ) )
390
391 tempONOSip = []
392 for i in range( main.numCtrls ):
393 tempONOSip.append( main.ONOSip[ i ] )
394
395 assignResult = main.Mininet1.assignSwController( sw=switchList,
396 ip=tempONOSip,
397 port='6633' )
398 if not assignResult:
399 main.cleanup()
400 main.exit()
401
402 for i in range( 1, ( main.numSwitch + 1 ) ):
403 response = main.Mininet1.getSwController( "s" + str( i ) )
404 print( "Response is " + str( response ) )
405 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
406 assignResult = assignResult and main.TRUE
407 else:
408 assignResult = main.FALSE
409 stepResult = assignResult
410 utilities.assert_equals( expect=main.TRUE,
411 actual=stepResult,
412 onpass="Successfully assigned switches" +
413 "to controller",
414 onfail="Failed to assign switches to " +
415 "controller" )
416 def CASE13( self, main ):
417 """
418 Discover all hosts and store its data to a dictionary
419 """
420 main.case( "Discover all hosts" )
421
422 stepResult = main.TRUE
423 main.step( "Discover all hosts using pingall " )
424 stepResult = main.intentFunction.getHostsData( main )
425 utilities.assert_equals( expect=main.TRUE,
426 actual=stepResult,
427 onpass="Successfully discovered hosts",
428 onfail="Failed to discover hosts" )
429
430 def CASE14( self, main ):
431 """
432 Stop mininet
433 """
434 main.log.report( "Stop Mininet topology" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700435 main.case( "Stop Mininet topology" )
Jon Hall783bbf92015-07-23 14:33:19 -0700436 main.caseExplanation = "Stopping the current mininet topology " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700437 "to start up fresh"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700438
439 main.step( "Stopping Mininet Topology" )
440 topoResult = main.Mininet1.stopNet( )
441 stepResult = topoResult
442 utilities.assert_equals( expect=main.TRUE,
443 actual=stepResult,
444 onpass="Successfully stop mininet",
445 onfail="Failed to stop mininet" )
446 # Exit if topology did not load properly
447 if not topoResult:
448 main.cleanup()
449 main.exit()
450
kelvin-onlabb769f562015-07-15 17:05:10 -0700451 def CASE1000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700452 """
453 Add host intents between 2 host:
454 - Discover hosts
455 - Add host intents
456 - Check intents
457 - Verify flows
458 - Ping hosts
459 - Reroute
460 - Link down
461 - Verify flows
462 - Check topology
463 - Ping hosts
464 - Link up
465 - Verify flows
466 - Check topology
467 - Ping hosts
468 - Remove intents
469 """
470 import time
471 import json
472 import re
473
474 # Assert variables - These variable's name|format must be followed
475 # if you want to use the wrapper function
476 assert main, "There is no main"
477 assert main.CLIs, "There is no main.CLIs"
478 assert main.Mininet1, "Mininet handle should be named Mininet1"
479 assert main.numSwitch, "Placed the total number of switch topology in \
480 main.numSwitch"
481
acsmarse6b410f2015-07-17 14:39:34 -0700482 intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
483
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700484 main.testName = "Host Intents"
485 main.case( main.testName + " 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-onlab016dce22015-08-10 09:54:11 -0700613 main.intentFunction.report( main )
614
kelvin-onlabb769f562015-07-15 17:05:10 -0700615 def CASE2000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700616 """
617 Add point intents between 2 hosts:
618 - Get device ids | ports
619 - Add point intents
620 - Check intents
621 - Verify flows
622 - Ping hosts
623 - Reroute
624 - Link down
625 - Verify flows
626 - Check topology
627 - Ping hosts
628 - Link up
629 - Verify flows
630 - Check topology
631 - Ping hosts
632 - Remove intents
633 """
634 import time
635 import json
636 import re
637
638 # Assert variables - These variable's name|format must be followed
639 # if you want to use the wrapper function
640 assert main, "There is no main"
641 assert main.CLIs, "There is no main.CLIs"
642 assert main.Mininet1, "Mininet handle should be named Mininet1"
643 assert main.numSwitch, "Placed the total number of switch topology in \
644 main.numSwitch"
645
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700646 main.testName = "Point Intents"
647 main.case( main.testName + " Test - " + str( main.numCtrls ) +
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700648 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700649 main.caseExplanation = "This test case will test point to point" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700650 " intents using " + str( main.numCtrls ) +\
651 " node(s) cluster;\n" +\
652 "Different type of hosts will be tested in " +\
653 "each step such as IPV4, Dual stack, VLAN etc" +\
654 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700655 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700656
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700657 # No option point intents
658 main.step( "NOOPTION: Add point intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700659 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700660 stepResult = main.intentFunction.pointIntent(
661 main,
662 name="NOOPTION",
663 host1="h1",
664 host2="h9",
665 deviceId1="of:0000000000000005/1",
666 deviceId2="of:0000000000000006/1",
667 sw1="s5",
668 sw2="s2",
669 expectedLink=18 )
670
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700671 utilities.assert_equals( expect=main.TRUE,
672 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700673 onpass="NOOPTION: Point intent test " +
674 "successful using no match action",
675 onfail="NOOPTION: Point intent test " +
676 "failed using no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700677
678 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -0700679 main.step( "IPV4: Add point intents between h1 and h9" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700680 stepResult = main.intentFunction.pointIntent(
681 main,
682 name="IPV4",
683 host1="h1",
684 host2="h9",
685 deviceId1="of:0000000000000005/1",
686 deviceId2="of:0000000000000006/1",
687 port1="",
688 port2="",
689 ethType="IPV4",
690 mac1="00:00:00:00:00:01",
691 mac2="00:00:00:00:00:09",
692 bandwidth="",
693 lambdaAlloc=False,
694 ipProto="",
695 ip1="",
696 ip2="",
697 tcp1="",
698 tcp2="",
699 sw1="s5",
700 sw2="s2",
701 expectedLink=18 )
702
703 utilities.assert_equals( expect=main.TRUE,
704 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700705 onpass="IPV4: Point intent test " +
706 "successful using IPV4 type with " +
707 "MAC addresses",
708 onfail="IPV4: Point intent test " +
709 "failed using IPV4 type with " +
710 "MAC addresses" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700711 main.step( "IPV4_2: Add point intents between h1 and h9" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700712 stepResult = main.TRUE
713 stepResult = main.intentFunction.pointIntent(
714 main,
715 name="IPV4_2",
716 host1="h1",
717 host2="h9",
718 deviceId1="of:0000000000000005/1",
719 deviceId2="of:0000000000000006/1",
kelvin-onlabb769f562015-07-15 17:05:10 -0700720 ipProto="",
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700721 ip1="",
722 ip2="",
723 tcp1="",
724 tcp2="",
725 sw1="s5",
726 sw2="s2",
727 expectedLink=18 )
728
729 utilities.assert_equals( expect=main.TRUE,
730 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700731 onpass="IPV4_2: Point intent test " +
732 "successful using IPV4 type with " +
733 "no MAC addresses",
734 onfail="IPV4_2: Point intent test " +
735 "failed using IPV4 type with " +
736 "no MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700737
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700738 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700739 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -0700740 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
741 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab0ad05d12015-07-23 14:21:15 -0700742 try:
743 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/24"
744 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/24"
745 except KeyError:
746 main.log.debug( "Key Error getting IP addresses of h1 | h9 in" +
747 "main.hostsData" )
748 ip1 = main.Mininet1.getIPAddress( 'h1')
749 ip2 = main.Mininet1.getIPAddress( 'h9')
750
kelvin-onlabb769f562015-07-15 17:05:10 -0700751 ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
kelvin-onlab79ce0492015-07-27 16:14:39 -0700752 # Uneccessary, not including this in the selectors
kelvin-onlabb769f562015-07-15 17:05:10 -0700753 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
754 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
755
756 stepResult = main.intentFunction.pointIntent(
757 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700758 name="SDNIP-ICMP",
kelvin-onlabb769f562015-07-15 17:05:10 -0700759 host1="h1",
760 host2="h9",
761 deviceId1="of:0000000000000005/1",
762 deviceId2="of:0000000000000006/1",
763 mac1=mac1,
764 mac2=mac2,
765 ethType="IPV4",
766 ipProto=ipProto,
767 ip1=ip1,
kelvin-onlab79ce0492015-07-27 16:14:39 -0700768 ip2=ip2 )
kelvin-onlabb769f562015-07-15 17:05:10 -0700769
770 utilities.assert_equals( expect=main.TRUE,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700771 actual=stepResult,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700772 onpass="SDNIP-ICMP: Point intent test " +
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700773 "successful using IPV4 type with " +
774 "IP protocol TCP enabled",
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700775 onfail="SDNIP-ICMP: Point intent test " +
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700776 "failed using IPV4 type with " +
777 "IP protocol TCP enabled" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700778
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700779 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700780 stepResult = main.TRUE
781 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
782 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab58dc39e2015-08-06 08:11:09 -0700783 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
784 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlabb769f562015-07-15 17:05:10 -0700785 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
786 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
787 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
788
kelvin-onlab58dc39e2015-08-06 08:11:09 -0700789 stepResult = main.intentFunction.pointIntentTcp(
kelvin-onlabb769f562015-07-15 17:05:10 -0700790 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700791 name="SDNIP-TCP",
kelvin-onlabb769f562015-07-15 17:05:10 -0700792 host1="h1",
793 host2="h9",
794 deviceId1="of:0000000000000005/1",
795 deviceId2="of:0000000000000006/1",
796 mac1=mac1,
797 mac2=mac2,
798 ethType="IPV4",
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700799 ipProto=ipProto,
800 ip1=ip1,
801 ip2=ip2,
802 tcp1=tcp1,
803 tcp2=tcp2 )
kelvin-onlabb769f562015-07-15 17:05:10 -0700804
805 utilities.assert_equals( expect=main.TRUE,
806 actual=stepResult,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700807 onpass="SDNIP-TCP: Point intent test " +
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700808 "successful using IPV4 type with " +
809 "IP protocol ICMP enabled",
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700810 onfail="SDNIP-TCP: Point intent test " +
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700811 "failed using IPV4 type with " +
812 "IP protocol ICMP enabled" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700813
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700814 main.step( "DUALSTACK1: Add point intents between h1 and h9" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700815 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700816 stepResult = main.intentFunction.pointIntent(
817 main,
818 name="DUALSTACK1",
819 host1="h3",
820 host2="h11",
821 deviceId1="of:0000000000000005",
822 deviceId2="of:0000000000000006",
823 port1="3",
824 port2="3",
825 ethType="IPV4",
826 mac1="00:00:00:00:00:03",
827 mac2="00:00:00:00:00:0B",
828 bandwidth="",
829 lambdaAlloc=False,
830 ipProto="",
831 ip1="",
832 ip2="",
833 tcp1="",
834 tcp2="",
835 sw1="s5",
836 sw2="s2",
837 expectedLink=18 )
838
839 utilities.assert_equals( expect=main.TRUE,
840 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700841 onpass="DUALSTACK1: Point intent test " +
842 "successful using IPV4 type with " +
843 "MAC addresses",
844 onfail="DUALSTACK1: Point intent test " +
845 "failed using IPV4 type with " +
846 "MAC addresses" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700847
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700848 main.step( "VLAN: Add point intents between h5 and h21" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700849 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700850 stepResult = main.intentFunction.pointIntent(
851 main,
852 name="VLAN",
853 host1="h5",
854 host2="h21",
855 deviceId1="of:0000000000000005/5",
856 deviceId2="of:0000000000000007/5",
857 port1="",
858 port2="",
859 ethType="IPV4",
860 mac1="00:00:00:00:00:05",
861 mac2="00:00:00:00:00:15",
862 bandwidth="",
863 lambdaAlloc=False,
864 ipProto="",
865 ip1="",
866 ip2="",
867 tcp1="",
868 tcp2="",
869 sw1="s5",
870 sw2="s2",
871 expectedLink=18 )
872
873 utilities.assert_equals( expect=main.TRUE,
874 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700875 onpass="VLAN1: Point intent test " +
876 "successful using IPV4 type with " +
877 "MAC addresses",
878 onfail="VLAN1: Point intent test " +
879 "failed using IPV4 type with " +
880 "MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700881
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700882 main.step( "1HOP: Add point intents between h1 and h3" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700883 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700884 stepResult = main.intentFunction.hostIntent( main,
885 name='1HOP',
886 host1='h1',
887 host2='h3' )
888
889 utilities.assert_equals( expect=main.TRUE,
890 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700891 onpass="1HOP: Point intent test " +
892 "successful using IPV4 type with " +
893 "no MAC addresses",
894 onfail="1HOP: Point intent test " +
895 "failed using IPV4 type with " +
896 "no MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700897
kelvin-onlab016dce22015-08-10 09:54:11 -0700898 main.intentFunction.report( main )
899
kelvin-onlabb769f562015-07-15 17:05:10 -0700900 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700901 """
902 Add single point to multi point intents
903 - Get device ids
904 - Add single point to multi point intents
905 - Check intents
906 - Verify flows
907 - Ping hosts
908 - Reroute
909 - Link down
910 - Verify flows
911 - Check topology
912 - Ping hosts
913 - Link up
914 - Verify flows
915 - Check topology
916 - Ping hosts
917 - Remove intents
918 """
919 assert main, "There is no main"
920 assert main.CLIs, "There is no main.CLIs"
921 assert main.Mininet1, "Mininet handle should be named Mininet1"
922 assert main.numSwitch, "Placed the total number of switch topology in \
923 main.numSwitch"
924
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700925 main.testName = "Single to Multi Point Intents"
926 main.case( main.testName + " Test - " + str( main.numCtrls ) +
927 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700928 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700929 " multi point intents using " +\
930 str( main.numCtrls ) + " node(s) cluster;\n" +\
931 "Different type of hosts will be tested in " +\
932 "each step such as IPV4, Dual stack, VLAN etc" +\
933 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700934 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700935
kelvin-onlabb769f562015-07-15 17:05:10 -0700936 main.step( "NOOPTION: Add single point to multi point intents" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700937 stepResult = main.TRUE
938 hostNames = [ 'h8', 'h16', 'h24' ]
939 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
940 'of:0000000000000007/8' ]
941 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 -0700942 stepResult = main.intentFunction.singleToMultiIntent(
943 main,
944 name="NOOPTION",
945 hostNames=hostNames,
946 devices=devices,
947 sw1="s5",
948 sw2="s2",
949 expectedLink=18 )
950
951 utilities.assert_equals( expect=main.TRUE,
952 actual=stepResult,
953 onpass="NOOPTION: Successfully added single "
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700954 + " point to multi point intents" +
955 " with no match action",
956 onfail="NOOPTION: Failed to add single point"
957 + " point to multi point intents" +
958 " with no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700959
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700960 main.step( "IPV4: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700961 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700962 stepResult = main.intentFunction.singleToMultiIntent(
963 main,
964 name="IPV4",
965 hostNames=hostNames,
966 devices=devices,
967 ports=None,
968 ethType="IPV4",
969 macs=macs,
970 bandwidth="",
971 lambdaAlloc=False,
972 ipProto="",
973 ipAddresses="",
974 tcp="",
975 sw1="s5",
976 sw2="s2",
977 expectedLink=18 )
978
979 utilities.assert_equals( expect=main.TRUE,
980 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700981 onpass="IPV4: Successfully added single "
982 + " point to multi point intents" +
983 " with IPV4 type and MAC addresses",
984 onfail="IPV4: Failed to add single point"
985 + " point to multi point intents" +
986 " with IPV4 type and MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700987
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700988 main.step( "IPV4_2: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -0700989 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700990 hostNames = [ 'h8', 'h16', 'h24' ]
991 stepResult = main.intentFunction.singleToMultiIntent(
992 main,
993 name="IPV4",
994 hostNames=hostNames,
995 ethType="IPV4",
996 lambdaAlloc=False )
997
998 utilities.assert_equals( expect=main.TRUE,
999 actual=stepResult,
1000 onpass="IPV4_2: Successfully added single "
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001001 + " point to multi point intents" +
1002 " with IPV4 type and no MAC addresses",
1003 onfail="IPV4_2: Failed to add single point"
1004 + " point to multi point intents" +
1005 " with IPV4 type and no MAC addresses" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001006
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001007 main.step( "VLAN: Add single point to multi point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001008 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001009 hostNames = [ 'h4', 'h12', 'h20' ]
1010 devices = [ 'of:0000000000000005/4', 'of:0000000000000006/4', \
1011 'of:0000000000000007/4' ]
1012 macs = [ '00:00:00:00:00:04', '00:00:00:00:00:0C', '00:00:00:00:00:14' ]
1013 stepResult = main.intentFunction.singleToMultiIntent(
1014 main,
1015 name="VLAN",
1016 hostNames=hostNames,
1017 devices=devices,
1018 ports=None,
1019 ethType="IPV4",
1020 macs=macs,
1021 bandwidth="",
1022 lambdaAlloc=False,
1023 ipProto="",
1024 ipAddresses="",
1025 tcp="",
1026 sw1="s5",
1027 sw2="s2",
1028 expectedLink=18 )
1029
1030 utilities.assert_equals( expect=main.TRUE,
1031 actual=stepResult,
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001032 onpass="VLAN: Successfully added single "
1033 + " point to multi point intents" +
1034 " with IPV4 type and MAC addresses" +
1035 " in the same VLAN",
1036 onfail="VLAN: Failed to add single point"
1037 + " point to multi point intents" +
1038 " with IPV4 type and MAC addresses" +
1039 " in the same VLAN")
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001040
kelvin-onlab016dce22015-08-10 09:54:11 -07001041 main.intentFunction.report( main )
1042
kelvin-onlabb769f562015-07-15 17:05:10 -07001043 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001044 """
1045 Add multi point to single point intents
1046 - Get device ids
1047 - Add multi point to single point intents
1048 - Check intents
1049 - Verify flows
1050 - Ping hosts
1051 - Reroute
1052 - Link down
1053 - Verify flows
1054 - Check topology
1055 - Ping hosts
1056 - Link up
1057 - Verify flows
1058 - Check topology
1059 - Ping hosts
1060 - Remove intents
1061 """
1062 assert main, "There is no main"
1063 assert main.CLIs, "There is no main.CLIs"
1064 assert main.Mininet1, "Mininet handle should be named Mininet1"
1065 assert main.numSwitch, "Placed the total number of switch topology in \
1066 main.numSwitch"
1067
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001068 main.testName = "Multi To Single Point Intents"
1069 main.case( main.testName + " Test - " + str( main.numCtrls ) +
1070 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -07001071 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001072 " multi point intents using " +\
1073 str( main.numCtrls ) + " node(s) cluster;\n" +\
1074 "Different type of hosts will be tested in " +\
1075 "each step such as IPV4, Dual stack, VLAN etc" +\
1076 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -07001077 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001078
kelvin-onlabb769f562015-07-15 17:05:10 -07001079 main.step( "NOOPTION: Add multi point to single point intents" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001080 stepResult = main.TRUE
1081 hostNames = [ 'h8', 'h16', 'h24' ]
1082 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
1083 'of:0000000000000007/8' ]
1084 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 -07001085 stepResult = main.intentFunction.multiToSingleIntent(
1086 main,
1087 name="NOOPTION",
1088 hostNames=hostNames,
1089 devices=devices,
1090 sw1="s5",
1091 sw2="s2",
1092 expectedLink=18 )
1093
1094 utilities.assert_equals( expect=main.TRUE,
1095 actual=stepResult,
1096 onpass="NOOPTION: Successfully added multi "
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001097 + " point to single point intents" +
1098 " with no match action",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001099 onfail="NOOPTION: Failed to add multi point" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001100 " to single point intents" +
1101 " with no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001102
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001103 main.step( "IPV4: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001104 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001105 stepResult = main.intentFunction.multiToSingleIntent(
1106 main,
1107 name="IPV4",
1108 hostNames=hostNames,
1109 devices=devices,
1110 ports=None,
1111 ethType="IPV4",
1112 macs=macs,
1113 bandwidth="",
1114 lambdaAlloc=False,
1115 ipProto="",
1116 ipAddresses="",
1117 tcp="",
1118 sw1="s5",
1119 sw2="s2",
1120 expectedLink=18 )
1121
1122 utilities.assert_equals( expect=main.TRUE,
1123 actual=stepResult,
1124 onpass="IPV4: Successfully added multi point"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001125 + " to single point intents" +
1126 " with IPV4 type and MAC addresses",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001127 onfail="IPV4: Failed to add multi point" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001128 " to single point intents" +
1129 " with IPV4 type and MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001130
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001131 main.step( "IPV4_2: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001132 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001133 hostNames = [ 'h8', 'h16', 'h24' ]
1134 stepResult = main.intentFunction.multiToSingleIntent(
1135 main,
1136 name="IPV4",
1137 hostNames=hostNames,
1138 ethType="IPV4",
1139 lambdaAlloc=False )
1140
1141 utilities.assert_equals( expect=main.TRUE,
1142 actual=stepResult,
1143 onpass="IPV4_2: Successfully added multi point"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001144 + " to single point intents" +
1145 " with IPV4 type and no MAC addresses",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001146 onfail="IPV4_2: Failed to add multi point" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001147 " to single point intents" +
1148 " with IPV4 type and no MAC addresses" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001149
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001150 main.step( "VLAN: Add multi point to single point intents" )
kelvin-onlabb769f562015-07-15 17:05:10 -07001151 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001152 hostNames = [ 'h5', 'h13', 'h21' ]
1153 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \
1154 'of:0000000000000007/5' ]
1155 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
1156 stepResult = main.intentFunction.multiToSingleIntent(
1157 main,
1158 name="VLAN",
1159 hostNames=hostNames,
1160 devices=devices,
1161 ports=None,
1162 ethType="IPV4",
1163 macs=macs,
1164 bandwidth="",
1165 lambdaAlloc=False,
1166 ipProto="",
1167 ipAddresses="",
1168 tcp="",
1169 sw1="s5",
1170 sw2="s2",
1171 expectedLink=18 )
1172
1173 utilities.assert_equals( expect=main.TRUE,
1174 actual=stepResult,
1175 onpass="VLAN: Successfully added multi point"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001176 + " to single point intents" +
1177 " with IPV4 type and MAC addresses" +
1178 " in the same VLAN",
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001179 onfail="VLAN: Failed to add multi point" +
1180 " to single point intents" )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001181
acsmars1ff5e052015-07-23 11:27:48 -07001182 def CASE5000( self, main ):
1183 """
1184 Will add description in next patch set
acsmars1ff5e052015-07-23 11:27:48 -07001185 """
1186 assert main, "There is no main"
1187 assert main.CLIs, "There is no main.CLIs"
1188 assert main.Mininet1, "Mininet handle should be named Mininet1"
1189 assert main.numSwitch, "Placed the total number of switch topology in \
1190 main.numSwitch"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001191 main.case( "Test host mobility with host intents " )
1192 main.step( " Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07001193 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1194
1195 main.log.info( "Moving h1 from s5 to s6")
1196
1197 main.Mininet1.moveHost( "h1","s5","s6" )
1198
1199 main.intentFunction.getHostsData( main )
1200 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1201
1202 utilities.assert_equals( expect="of:0000000000000006",
1203 actual=h1PostMove,
1204 onpass="Mobility: Successfully moved h1 to s6",
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001205 onfail="Mobility: Failed to moved h1 to s6" +
1206 " to single point intents" +
1207 " with IPV4 type and MAC addresses" +
1208 " in the same VLAN" )
1209
1210 main.step( "IPV4: Add host intents between h1 and h9" )
1211 stepResult = main.TRUE
1212 stepResult = main.intentFunction.hostIntent( main,
1213 onosNode='0',
1214 name='IPV4',
1215 host1='h1',
1216 host2='h9',
1217 host1Id='00:00:00:00:00:01/-1',
1218 host2Id='00:00:00:00:00:09/-1' )
1219
1220 utilities.assert_equals( expect=main.TRUE,
1221 actual=stepResult,
1222 onpass="IPV4: Host intent test successful " +
1223 "between two IPV4 hosts",
1224 onfail="IPV4: Host intent test failed " +
1225 "between two IPV4 hosts")
kelvin-onlab016dce22015-08-10 09:54:11 -07001226
1227 main.intentFunction.report( main )