blob: e5d065413f6a1a58d2836eb47dbbfe49e3218a05 [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
kelvin-onlabd48a68c2015-07-13 16:01:36 -070010 import imp
Jon Hallf632d202015-07-30 15:45:11 -070011 import re
kelvin-onlabd48a68c2015-07-13 16:01:36 -070012
13 """
14 - Construct tests variables
15 - GIT ( optional )
16 - Checkout ONOS master branch
17 - Pull latest ONOS code
18 - Building ONOS ( optional )
19 - Install ONOS package
20 - Build ONOS package
21 """
22
23 main.case( "Constructing test variables and building ONOS package" )
24 main.step( "Constructing test variables" )
Jon Hall783bbf92015-07-23 14:33:19 -070025 main.caseExplanation = "This test case is mainly for loading " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -070026 "from params file, and pull and build the " +\
27 " latest ONOS package"
kelvin-onlabd48a68c2015-07-13 16:01:36 -070028 stepResult = main.FALSE
29
30 # Test variables
Jon Halla3e02432015-07-24 15:55:42 -070031 try:
Jon Hallf632d202015-07-30 15:45:11 -070032 main.testOnDirectory = re.sub( "(/tests)$", "", main.testDir )
Jon Halla3e02432015-07-24 15:55:42 -070033 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
34 gitBranch = main.params[ 'GIT' ][ 'branch' ]
35 main.dependencyPath = main.testOnDirectory + \
36 main.params[ 'DEPENDENCY' ][ 'path' ]
37 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
38 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
39 if main.ONOSbench.maxNodes:
40 main.maxNodes = int( main.ONOSbench.maxNodes )
41 else:
42 main.maxNodes = 0
43 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
44 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
45 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
46 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
47 main.checkIntentSleep = int( main.params[ 'SLEEP' ][ 'checkintent' ] )
acsmarscfa52272015-08-06 15:21:45 -070048 main.removeIntentSleep = int( main.params[ 'SLEEP' ][ 'removeintent' ] )
Jon Halla3e02432015-07-24 15:55:42 -070049 main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] )
50 main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
acsmars59a4c552015-09-10 18:11:19 -070051 main.checkTopoAttempts = int( main.params[ 'SLEEP' ][ 'topoAttempts' ] )
Jon Halla3e02432015-07-24 15:55:42 -070052 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 = []
acsmars5d8cc862015-09-25 09:44:50 -070059 main.assertReturnString = '' # Assembled assert return string
kelvin-onlabd48a68c2015-07-13 16:01:36 -070060
Jon Halla3e02432015-07-24 15:55:42 -070061 main.ONOSip = main.ONOSbench.getOnosIps()
62 print main.ONOSip
kelvin-onlabd48a68c2015-07-13 16:01:36 -070063
Jon Halla3e02432015-07-24 15:55:42 -070064 # Assigning ONOS cli handles to a list
65 for i in range( 1, main.maxNodes + 1 ):
66 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070067
Jon Halla3e02432015-07-24 15:55:42 -070068 # -- INIT SECTION, ONLY RUNS ONCE -- #
69 main.startUp = imp.load_source( wrapperFile1,
70 main.dependencyPath +
71 wrapperFile1 +
72 ".py" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070073
Jon Halla3e02432015-07-24 15:55:42 -070074 main.intentFunction = imp.load_source( wrapperFile2,
75 main.dependencyPath +
76 wrapperFile2 +
77 ".py" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070078
Jon Halla3e02432015-07-24 15:55:42 -070079 main.topo = imp.load_source( wrapperFile3,
80 main.dependencyPath +
81 wrapperFile3 +
82 ".py" )
83
kelvin-onlabd9e23de2015-08-06 10:34:44 -070084 copyResult1 = main.ONOSbench.scp( main.Mininet1,
85 main.dependencyPath +
86 main.topology,
87 main.Mininet1.home,
88 direction="to" )
Jon Halla3e02432015-07-24 15:55:42 -070089 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" +
Jon Hall70b2ff42015-11-17 15:49:44 -0800145 " before initiating environment setup" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700146
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
kelvin-onlab5f0d19e2015-08-04 15:21:00 -0700181 for ip in main.ONOSip:
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700182 onosUninstallResult = onosUninstallResult and \
kelvin-onlab5f0d19e2015-08-04 15:21:00 -0700183 main.ONOSbench.onosUninstall( nodeIp=ip )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700184 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 " )
acsmars2ec91d62015-09-16 11:15:48 -0700215
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700216 for i in range( main.numCtrls ):
217 stopResult = stopResult and \
218 main.ONOSbench.onosStop( main.ONOSip[ i ] )
219 for i in range( main.numCtrls ):
220 startResult = startResult and \
221 main.ONOSbench.onosStart( main.ONOSip[ i ] )
222 stepResult = onosIsUp and stopResult and startResult
223 utilities.assert_equals( expect=main.TRUE,
224 actual=stepResult,
225 onpass="ONOS service is ready",
226 onfail="ONOS service did not start properly" )
227
228 main.step( "Start ONOS cli" )
229 cliResult = main.TRUE
230 for i in range( main.numCtrls ):
231 cliResult = cliResult and \
232 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
233 stepResult = cliResult
234 utilities.assert_equals( expect=main.TRUE,
235 actual=stepResult,
236 onpass="Successfully start ONOS cli",
237 onfail="Failed to start ONOS cli" )
238
239 # Remove the first element in main.scale list
240 main.scale.remove( main.scale[ 0 ] )
241
kelvin-onlab016dce22015-08-10 09:54:11 -0700242 main.intentFunction.report( main )
243
Jon Halla3e02432015-07-24 15:55:42 -0700244 def CASE8( self, main ):
245 """
acsmars59a4c552015-09-10 18:11:19 -0700246 Compare ONOS Topology to Mininet Topology
Jon Halla3e02432015-07-24 15:55:42 -0700247 """
248 import json
249
250 main.case( "Compare ONOS Topology view to Mininet topology" )
251 main.caseExplanation = "Compare topology elements between Mininet" +\
252 " and ONOS"
253
acsmars59a4c552015-09-10 18:11:19 -0700254 main.log.info( "Gathering topology information from Mininet" )
255 devicesResults = main.FALSE # Overall Boolean for device correctness
256 linksResults = main.FALSE # Overall Boolean for link correctness
257 hostsResults = main.FALSE # Overall Boolean for host correctness
258 deviceFails = [] # Nodes where devices are incorrect
259 linkFails = [] # Nodes where links are incorrect
260 hostFails = [] # Nodes where hosts are incorrect
261 attempts = main.checkTopoAttempts # Remaining Attempts
Jon Halla3e02432015-07-24 15:55:42 -0700262
263 mnSwitches = main.Mininet1.getSwitches()
264 mnLinks = main.Mininet1.getLinks()
265 mnHosts = main.Mininet1.getHosts()
266
Jon Hall70b2ff42015-11-17 15:49:44 -0800267 main.step( "Comparing Mininet topology to ONOS topology" )
Jon Halla3e02432015-07-24 15:55:42 -0700268
acsmars59a4c552015-09-10 18:11:19 -0700269 while ( attempts >= 0 ) and\
270 ( not devicesResults or not linksResults or not hostsResults ):
271 time.sleep( 2 )
272 if not devicesResults:
273 devices = main.topo.getAllDevices( main )
274 ports = main.topo.getAllPorts( main )
275 devicesResults = main.TRUE
276 deviceFails = [] # Reset for each attempt
277 if not linksResults:
278 links = main.topo.getAllLinks( main )
279 linksResults = main.TRUE
280 linkFails = [] # Reset for each attempt
281 if not hostsResults:
282 hosts = main.topo.getAllHosts( main )
283 hostsResults = main.TRUE
284 hostFails = [] # Reset for each attempt
Jon Halla3e02432015-07-24 15:55:42 -0700285
acsmars59a4c552015-09-10 18:11:19 -0700286 # Check for matching topology on each node
287 for controller in range( main.numCtrls ):
288 controllerStr = str( controller + 1 ) # ONOS node number
289 # Compare Devices
290 if devices[ controller ] and ports[ controller ] and\
291 "Error" not in devices[ controller ] and\
292 "Error" not in ports[ controller ]:
Jon Halla3e02432015-07-24 15:55:42 -0700293
acsmars2ec91d62015-09-16 11:15:48 -0700294 try:
295 deviceData = json.loads( devices[ controller ] )
296 portData = json.loads( ports[ controller ] )
297 except (TypeError,ValueError):
298 main.log.error("Could not load json:" + str( devices[ controller ] ) + ' or ' + str( ports[ controller ] ))
299 currentDevicesResult = main.FALSE
300 else:
301 currentDevicesResult = main.Mininet1.compareSwitches(
302 mnSwitches,deviceData,portData )
acsmars59a4c552015-09-10 18:11:19 -0700303 else:
304 currentDevicesResult = main.FALSE
305 if not currentDevicesResult:
306 deviceFails.append( controllerStr )
307 devicesResults = devicesResults and currentDevicesResult
308 # Compare Links
309 if links[ controller ] and "Error" not in links[ controller ]:
acsmars2ec91d62015-09-16 11:15:48 -0700310 try:
311 linkData = json.loads( links[ controller ] )
312 except (TypeError,ValueError):
313 main.log.error("Could not load json:" + str( links[ controller ] ) )
314 currentLinksResult = main.FALSE
315 else:
316 currentLinksResult = main.Mininet1.compareLinks(
317 mnSwitches, mnLinks,linkData )
acsmars59a4c552015-09-10 18:11:19 -0700318 else:
319 currentLinksResult = main.FALSE
320 if not currentLinksResult:
321 linkFails.append( controllerStr )
322 linksResults = linksResults and currentLinksResult
323 # Compare Hosts
acsmars2ec91d62015-09-16 11:15:48 -0700324 if hosts[ controller ] and "Error" not in hosts[ controller ]:
325 try:
326 hostData = json.loads( hosts[ controller ] )
327 except (TypeError,ValueError):
328 main.log.error("Could not load json:" + str( hosts[ controller ] ) )
329 currentHostsResult = main.FALSE
330 else:
331 currentHostsResult = main.Mininet1.compareHosts(
332 mnHosts,hostData )
acsmars59a4c552015-09-10 18:11:19 -0700333 else:
334 currentHostsResult = main.FALSE
335 if not currentHostsResult:
336 hostFails.append( controllerStr )
337 hostsResults = hostsResults and currentHostsResult
338 # Decrement Attempts Remaining
339 attempts -= 1
340
341
342 utilities.assert_equals( expect=[],
343 actual=deviceFails,
344 onpass="ONOS correctly discovered all devices",
345 onfail="ONOS incorrectly discovered devices on nodes: " +
346 str( deviceFails ) )
347 utilities.assert_equals( expect=[],
348 actual=linkFails,
349 onpass="ONOS correctly discovered all links",
350 onfail="ONOS incorrectly discovered links on nodes: " +
351 str( linkFails ) )
352 utilities.assert_equals( expect=[],
353 actual=hostFails,
354 onpass="ONOS correctly discovered all hosts",
355 onfail="ONOS incorrectly discovered hosts on nodes: " +
356 str( hostFails ) )
Jon Hall46d48252015-08-03 11:41:16 -0700357 topoResults = hostsResults and linksResults and devicesResults
358 utilities.assert_equals( expect=main.TRUE,
359 actual=topoResults,
360 onpass="ONOS correctly discovered the topology",
361 onfail="ONOS incorrectly discovered the topology" )
Jon Halla3e02432015-07-24 15:55:42 -0700362
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700363 def CASE10( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700364 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700365 Start Mininet topology with OF 1.0 switches
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700366 """
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700367 main.OFProtocol = "1.0"
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700368 main.log.report( "Start Mininet topology with OF 1.0 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700369 main.case( "Start Mininet topology with OF 1.0 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700370 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700371 "switches to test intents, exits out if " +\
372 "topology did not start correctly"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700373
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700374 main.step( "Starting Mininet topology with OF 1.0 switches" )
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700375 args = "--switch ovs,protocols=OpenFlow10"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700376 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700377 main.topology,
378 args=args )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700379 stepResult = topoResult
380 utilities.assert_equals( expect=main.TRUE,
381 actual=stepResult,
382 onpass="Successfully loaded topology",
383 onfail="Failed to load topology" )
384 # Exit if topology did not load properly
385 if not topoResult:
386 main.cleanup()
387 main.exit()
388
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700389 def CASE11( self, main ):
390 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700391 Start Mininet topology with OF 1.3 switches
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700392 """
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700393 main.OFProtocol = "1.3"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700394 main.log.report( "Start Mininet topology with OF 1.3 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700395 main.case( "Start Mininet topology with OF 1.3 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700396 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700397 "switches to test intents, exits out if " +\
398 "topology did not start correctly"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700399
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700400 main.step( "Starting Mininet topology with OF 1.3 switches" )
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700401 args = "--switch ovs,protocols=OpenFlow13"
402 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
403 main.topology,
404 args=args )
405 stepResult = topoResult
406 utilities.assert_equals( expect=main.TRUE,
407 actual=stepResult,
408 onpass="Successfully loaded topology",
409 onfail="Failed to load topology" )
410 # Exit if topology did not load properly
411 if not topoResult:
412 main.cleanup()
413 main.exit()
414
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700415 def CASE12( self, main ):
416 """
417 Assign mastership to controllers
418 """
419 import re
420
421 main.case( "Assign switches to controllers" )
422 main.step( "Assigning switches to controllers" )
Jon Hall783bbf92015-07-23 14:33:19 -0700423 main.caseExplanation = "Assign OF " + main.OFProtocol +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700424 " switches to ONOS nodes"
425
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700426 assignResult = main.TRUE
427 switchList = []
428
429 # Creates a list switch name, use getSwitch() function later...
430 for i in range( 1, ( main.numSwitch + 1 ) ):
431 switchList.append( 's' + str( i ) )
432
433 tempONOSip = []
434 for i in range( main.numCtrls ):
435 tempONOSip.append( main.ONOSip[ i ] )
436
437 assignResult = main.Mininet1.assignSwController( sw=switchList,
438 ip=tempONOSip,
Charles Chan029be652015-08-24 01:46:10 +0800439 port='6653' )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700440 if not assignResult:
441 main.cleanup()
442 main.exit()
443
444 for i in range( 1, ( main.numSwitch + 1 ) ):
445 response = main.Mininet1.getSwController( "s" + str( i ) )
446 print( "Response is " + str( response ) )
447 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
448 assignResult = assignResult and main.TRUE
449 else:
450 assignResult = main.FALSE
451 stepResult = assignResult
452 utilities.assert_equals( expect=main.TRUE,
453 actual=stepResult,
454 onpass="Successfully assigned switches" +
455 "to controller",
456 onfail="Failed to assign switches to " +
457 "controller" )
acsmars5d8cc862015-09-25 09:44:50 -0700458
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700459 def CASE13( self, main ):
460 """
461 Discover all hosts and store its data to a dictionary
462 """
463 main.case( "Discover all hosts" )
464
465 stepResult = main.TRUE
466 main.step( "Discover all hosts using pingall " )
467 stepResult = main.intentFunction.getHostsData( main )
468 utilities.assert_equals( expect=main.TRUE,
469 actual=stepResult,
470 onpass="Successfully discovered hosts",
471 onfail="Failed to discover hosts" )
472
473 def CASE14( self, main ):
474 """
475 Stop mininet
476 """
477 main.log.report( "Stop Mininet topology" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700478 main.case( "Stop Mininet topology" )
Jon Hall783bbf92015-07-23 14:33:19 -0700479 main.caseExplanation = "Stopping the current mininet topology " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700480 "to start up fresh"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700481
482 main.step( "Stopping Mininet Topology" )
483 topoResult = main.Mininet1.stopNet( )
484 stepResult = topoResult
485 utilities.assert_equals( expect=main.TRUE,
486 actual=stepResult,
487 onpass="Successfully stop mininet",
488 onfail="Failed to stop mininet" )
489 # Exit if topology did not load properly
490 if not topoResult:
491 main.cleanup()
492 main.exit()
493
kelvin-onlabb769f562015-07-15 17:05:10 -0700494 def CASE1000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700495 """
496 Add host intents between 2 host:
497 - Discover hosts
498 - Add host intents
499 - Check intents
500 - Verify flows
501 - Ping hosts
502 - Reroute
503 - Link down
504 - Verify flows
505 - Check topology
506 - Ping hosts
507 - Link up
508 - Verify flows
509 - Check topology
510 - Ping hosts
511 - Remove intents
512 """
513 import time
514 import json
515 import re
516
517 # Assert variables - These variable's name|format must be followed
518 # if you want to use the wrapper function
519 assert main, "There is no main"
520 assert main.CLIs, "There is no main.CLIs"
521 assert main.Mininet1, "Mininet handle should be named Mininet1"
522 assert main.numSwitch, "Placed the total number of switch topology in \
523 main.numSwitch"
524
acsmarse6b410f2015-07-17 14:39:34 -0700525 intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
526
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700527 main.testName = "Host Intents"
528 main.case( main.testName + " Test - " + str( main.numCtrls ) +
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700529 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700530 main.caseExplanation = "This test case tests Host intents using " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700531 str( main.numCtrls ) + " node(s) cluster;\n" +\
532 "Different type of hosts will be tested in " +\
533 "each step such as IPV4, Dual stack, VLAN " +\
534 "etc;\nThe test will use OF " + main.OFProtocol\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700535 + " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700536
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700537 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700538 main.assertReturnString = "Assertion Result for IPV4 host intent with mac addresses\n"
kelvin-onlabb769f562015-07-15 17:05:10 -0700539 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700540 stepResult = main.intentFunction.hostIntent( main,
541 onosNode='0',
542 name='IPV4',
543 host1='h1',
544 host2='h9',
545 host1Id='00:00:00:00:00:01/-1',
546 host2Id='00:00:00:00:00:09/-1',
547 sw1='s5',
548 sw2='s2',
549 expectedLink=18 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700550 utilities.assert_equals( expect=main.TRUE,
551 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -0700552 onpass=main.assertReturnString,
553 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700554
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700555 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700556 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
kelvin-onlabb769f562015-07-15 17:05:10 -0700557 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700558 stepResult = main.intentFunction.hostIntent( main,
559 name='DUALSTACK',
560 host1='h3',
561 host2='h11',
562 host1Id='00:00:00:00:00:03/-1',
563 host2Id='00:00:00:00:00:0B/-1',
564 sw1='s5',
565 sw2='s2',
566 expectedLink=18 )
567
568 utilities.assert_equals( expect=main.TRUE,
569 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -0700570 onpass=main.assertReturnString,
571 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700572
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700573 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700574 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
kelvin-onlabb769f562015-07-15 17:05:10 -0700575 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700576 stepResult = main.intentFunction.hostIntent( main,
577 name='DUALSTACK2',
578 host1='h1',
579 host2='h11',
580 sw1='s5',
581 sw2='s2',
582 expectedLink=18 )
583
584 utilities.assert_equals( expect=main.TRUE,
585 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -0700586 onpass=main.assertReturnString,
587 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700588
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700589 main.step( "1HOP: Add host intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -0700590 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
kelvin-onlabb769f562015-07-15 17:05:10 -0700591 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700592 stepResult = main.intentFunction.hostIntent( main,
593 name='1HOP',
594 host1='h1',
595 host2='h3' )
596
597 utilities.assert_equals( expect=main.TRUE,
598 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -0700599 onpass=main.assertReturnString,
600 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700601
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700602 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
acsmars5d8cc862015-09-25 09:44:50 -0700603 main.assertReturnString = "Assertion Result vlan IPV4\n"
kelvin-onlabb769f562015-07-15 17:05:10 -0700604 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700605 stepResult = main.intentFunction.hostIntent( main,
606 name='VLAN1',
607 host1='h4',
608 host2='h12',
609 host1Id='00:00:00:00:00:04/100',
610 host2Id='00:00:00:00:00:0C/100',
611 sw1='s5',
612 sw2='s2',
613 expectedLink=18 )
614
615 utilities.assert_equals( expect=main.TRUE,
616 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -0700617 onpass=main.assertReturnString,
618 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700619
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700620 main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
acsmars5d8cc862015-09-25 09:44:50 -0700621 main.assertReturnString = "Assertion Result different VLAN negative test\n"
kelvin-onlabb769f562015-07-15 17:05:10 -0700622 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700623 stepResult = main.intentFunction.hostIntent( main,
624 name='VLAN2',
625 host1='h13',
626 host2='h20' )
627
628 utilities.assert_equals( expect=main.FALSE,
629 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -0700630 onpass=main.assertReturnString,
631 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700632
acsmarse6b410f2015-07-17 14:39:34 -0700633
634 intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
635 main.intentFunction.checkLeaderChange( intentLeadersOld,
636 intentLeadersNew )
637
kelvin-onlab016dce22015-08-10 09:54:11 -0700638 main.intentFunction.report( main )
639
kelvin-onlabb769f562015-07-15 17:05:10 -0700640 def CASE2000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700641 """
642 Add point intents between 2 hosts:
643 - Get device ids | ports
644 - Add point intents
645 - Check intents
646 - Verify flows
647 - Ping hosts
648 - Reroute
649 - Link down
650 - Verify flows
651 - Check topology
652 - Ping hosts
653 - Link up
654 - Verify flows
655 - Check topology
656 - Ping hosts
657 - Remove intents
658 """
659 import time
660 import json
661 import re
662
663 # Assert variables - These variable's name|format must be followed
664 # if you want to use the wrapper function
665 assert main, "There is no main"
666 assert main.CLIs, "There is no main.CLIs"
667 assert main.Mininet1, "Mininet handle should be named Mininet1"
668 assert main.numSwitch, "Placed the total number of switch topology in \
669 main.numSwitch"
670
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700671 main.testName = "Point Intents"
672 main.case( main.testName + " Test - " + str( main.numCtrls ) +
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700673 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700674 main.caseExplanation = "This test case will test point to point" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700675 " intents using " + str( main.numCtrls ) +\
676 " node(s) cluster;\n" +\
677 "Different type of hosts will be tested in " +\
678 "each step such as IPV4, Dual stack, VLAN etc" +\
679 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700680 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700681
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700682 # No option point intents
683 main.step( "NOOPTION: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700684 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
kelvin-onlabb769f562015-07-15 17:05:10 -0700685 stepResult = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700686 stepResult = main.intentFunction.pointIntent(
687 main,
688 name="NOOPTION",
689 host1="h1",
690 host2="h9",
691 deviceId1="of:0000000000000005/1",
692 deviceId2="of:0000000000000006/1",
693 sw1="s5",
694 sw2="s2",
695 expectedLink=18 )
696
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700697 utilities.assert_equals( expect=main.TRUE,
698 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -0700699 onpass=main.assertReturnString,
700 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700701
702 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -0700703 main.step( "IPV4: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700704 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700705 stepResult = main.intentFunction.pointIntent(
706 main,
707 name="IPV4",
708 host1="h1",
709 host2="h9",
710 deviceId1="of:0000000000000005/1",
711 deviceId2="of:0000000000000006/1",
712 port1="",
713 port2="",
714 ethType="IPV4",
715 mac1="00:00:00:00:00:01",
716 mac2="00:00:00:00:00:09",
717 bandwidth="",
718 lambdaAlloc=False,
719 ipProto="",
720 ip1="",
721 ip2="",
722 tcp1="",
723 tcp2="",
724 sw1="s5",
725 sw2="s2",
726 expectedLink=18 )
727
728 utilities.assert_equals( expect=main.TRUE,
729 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -0700730 onpass=main.assertReturnString,
731 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -0700732 main.step( "IPV4_2: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700733 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700734 stepResult = main.intentFunction.pointIntent(
735 main,
736 name="IPV4_2",
737 host1="h1",
738 host2="h9",
739 deviceId1="of:0000000000000005/1",
740 deviceId2="of:0000000000000006/1",
kelvin-onlabb769f562015-07-15 17:05:10 -0700741 ipProto="",
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700742 ip1="",
743 ip2="",
744 tcp1="",
745 tcp2="",
746 sw1="s5",
747 sw2="s2",
748 expectedLink=18 )
749
750 utilities.assert_equals( expect=main.TRUE,
751 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -0700752 onpass=main.assertReturnString,
753 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700754
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700755 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700756 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
kelvin-onlabb769f562015-07-15 17:05:10 -0700757 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
758 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab0ad05d12015-07-23 14:21:15 -0700759 try:
760 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/24"
761 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/24"
762 except KeyError:
763 main.log.debug( "Key Error getting IP addresses of h1 | h9 in" +
764 "main.hostsData" )
765 ip1 = main.Mininet1.getIPAddress( 'h1')
766 ip2 = main.Mininet1.getIPAddress( 'h9')
767
kelvin-onlabb769f562015-07-15 17:05:10 -0700768 ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
kelvin-onlab79ce0492015-07-27 16:14:39 -0700769 # Uneccessary, not including this in the selectors
kelvin-onlabb769f562015-07-15 17:05:10 -0700770 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
771 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
772
773 stepResult = main.intentFunction.pointIntent(
774 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700775 name="SDNIP-ICMP",
kelvin-onlabb769f562015-07-15 17:05:10 -0700776 host1="h1",
777 host2="h9",
778 deviceId1="of:0000000000000005/1",
779 deviceId2="of:0000000000000006/1",
780 mac1=mac1,
781 mac2=mac2,
782 ethType="IPV4",
783 ipProto=ipProto,
784 ip1=ip1,
kelvin-onlab79ce0492015-07-27 16:14:39 -0700785 ip2=ip2 )
kelvin-onlabb769f562015-07-15 17:05:10 -0700786
787 utilities.assert_equals( expect=main.TRUE,
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700788 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -0700789 onpass=main.assertReturnString,
790 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -0700791
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700792 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700793 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
kelvin-onlabb769f562015-07-15 17:05:10 -0700794 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
795 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab58dc39e2015-08-06 08:11:09 -0700796 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
797 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlabb769f562015-07-15 17:05:10 -0700798 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
799 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
800 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
801
kelvin-onlab58dc39e2015-08-06 08:11:09 -0700802 stepResult = main.intentFunction.pointIntentTcp(
kelvin-onlabb769f562015-07-15 17:05:10 -0700803 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700804 name="SDNIP-TCP",
kelvin-onlabb769f562015-07-15 17:05:10 -0700805 host1="h1",
806 host2="h9",
807 deviceId1="of:0000000000000005/1",
808 deviceId2="of:0000000000000006/1",
809 mac1=mac1,
810 mac2=mac2,
811 ethType="IPV4",
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700812 ipProto=ipProto,
813 ip1=ip1,
814 ip2=ip2,
815 tcp1=tcp1,
816 tcp2=tcp2 )
kelvin-onlabb769f562015-07-15 17:05:10 -0700817
818 utilities.assert_equals( expect=main.TRUE,
819 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -0700820 onpass=main.assertReturnString,
821 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -0700822
acsmars5d8cc862015-09-25 09:44:50 -0700823 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
824 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700825 stepResult = main.intentFunction.pointIntent(
826 main,
827 name="DUALSTACK1",
828 host1="h3",
829 host2="h11",
830 deviceId1="of:0000000000000005",
831 deviceId2="of:0000000000000006",
832 port1="3",
833 port2="3",
834 ethType="IPV4",
835 mac1="00:00:00:00:00:03",
836 mac2="00:00:00:00:00:0B",
837 bandwidth="",
838 lambdaAlloc=False,
839 ipProto="",
840 ip1="",
841 ip2="",
842 tcp1="",
843 tcp2="",
844 sw1="s5",
845 sw2="s2",
846 expectedLink=18 )
847
848 utilities.assert_equals( expect=main.TRUE,
849 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -0700850 onpass=main.assertReturnString,
851 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -0700852
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700853 main.step( "VLAN: Add point intents between h5 and h21" )
acsmars5d8cc862015-09-25 09:44:50 -0700854 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700855 stepResult = main.intentFunction.pointIntent(
856 main,
857 name="VLAN",
858 host1="h5",
859 host2="h21",
860 deviceId1="of:0000000000000005/5",
861 deviceId2="of:0000000000000007/5",
862 port1="",
863 port2="",
864 ethType="IPV4",
865 mac1="00:00:00:00:00:05",
866 mac2="00:00:00:00:00:15",
867 bandwidth="",
868 lambdaAlloc=False,
869 ipProto="",
870 ip1="",
871 ip2="",
872 tcp1="",
873 tcp2="",
874 sw1="s5",
875 sw2="s2",
876 expectedLink=18 )
877
878 utilities.assert_equals( expect=main.TRUE,
879 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -0700880 onpass=main.assertReturnString,
881 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700882
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700883 main.step( "1HOP: Add point intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -0700884 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700885 stepResult = main.intentFunction.hostIntent( main,
886 name='1HOP',
887 host1='h1',
888 host2='h3' )
889
890 utilities.assert_equals( expect=main.TRUE,
891 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -0700892 onpass=main.assertReturnString,
893 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700894
kelvin-onlab016dce22015-08-10 09:54:11 -0700895 main.intentFunction.report( main )
896
kelvin-onlabb769f562015-07-15 17:05:10 -0700897 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700898 """
899 Add single point to multi point intents
900 - Get device ids
901 - Add single point to multi point intents
902 - Check intents
903 - Verify flows
904 - Ping hosts
905 - Reroute
906 - Link down
907 - Verify flows
908 - Check topology
909 - Ping hosts
910 - Link up
911 - Verify flows
912 - Check topology
913 - Ping hosts
914 - Remove intents
915 """
916 assert main, "There is no main"
917 assert main.CLIs, "There is no main.CLIs"
918 assert main.Mininet1, "Mininet handle should be named Mininet1"
919 assert main.numSwitch, "Placed the total number of switch topology in \
920 main.numSwitch"
921
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700922 main.testName = "Single to Multi Point Intents"
923 main.case( main.testName + " Test - " + str( main.numCtrls ) +
924 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700925 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700926 " multi point intents using " +\
927 str( main.numCtrls ) + " node(s) cluster;\n" +\
928 "Different type of hosts will be tested in " +\
929 "each step such as IPV4, Dual stack, VLAN etc" +\
930 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700931 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700932
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700933 hostNames = [ 'h8', 'h16', 'h24' ]
934 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', \
935 'of:0000000000000007/8' ]
936 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 -0700937
acsmars2ec91d62015-09-16 11:15:48 -0700938 # This test as written attempts something that is improbable to succeed
939 # Single to Multi Point Raw intent cannot be bi-directional, so pings are not usable to test it
940 # This test should be re-written so that one single-to-multi NOOPTION
941 # intent is installed, with listeners at the destinations, so that one way
942 # packets can be detected
943 #
944 # main.step( "NOOPTION: Add single point to multi point intents" )
945 # stepResult = main.TRUE
946 # stepResult = main.intentFunction.singleToMultiIntent(
947 # main,
948 # name="NOOPTION",
949 # hostNames=hostNames,
950 # devices=devices,
951 # sw1="s5",
952 # sw2="s2",
953 # expectedLink=18 )
954 #
955 # utilities.assert_equals( expect=main.TRUE,
956 # actual=stepResult,
957 # onpass="NOOPTION: Successfully added single "
958 # + " point to multi point intents" +
959 # " with no match action",
960 # onfail="NOOPTION: Failed to add single point"
961 # + " point to multi point intents" +
962 # " with no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700963
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700964 main.step( "IPV4: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -0700965 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses\n"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700966 stepResult = main.intentFunction.singleToMultiIntent(
967 main,
968 name="IPV4",
969 hostNames=hostNames,
970 devices=devices,
971 ports=None,
972 ethType="IPV4",
973 macs=macs,
974 bandwidth="",
975 lambdaAlloc=False,
976 ipProto="",
977 ipAddresses="",
978 tcp="",
979 sw1="s5",
980 sw2="s2",
981 expectedLink=18 )
982
983 utilities.assert_equals( expect=main.TRUE,
984 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -0700985 onpass=main.assertReturnString,
986 onfail=main.assertReturnString )
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" )
acsmars5d8cc862015-09-25 09:44:50 -0700989 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and no MAC addresses\n"
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,
acsmars5d8cc862015-09-25 09:44:50 -07001000 onpass=main.assertReturnString,
1001 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001002
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001003 main.step( "VLAN: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001004 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses in the same VLAN\n"
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001005 hostNames = [ 'h4', 'h12', 'h20' ]
1006 devices = [ 'of:0000000000000005/4', 'of:0000000000000006/4', \
1007 'of:0000000000000007/4' ]
1008 macs = [ '00:00:00:00:00:04', '00:00:00:00:00:0C', '00:00:00:00:00:14' ]
1009 stepResult = main.intentFunction.singleToMultiIntent(
1010 main,
1011 name="VLAN",
1012 hostNames=hostNames,
1013 devices=devices,
1014 ports=None,
1015 ethType="IPV4",
1016 macs=macs,
1017 bandwidth="",
1018 lambdaAlloc=False,
1019 ipProto="",
1020 ipAddresses="",
1021 tcp="",
1022 sw1="s5",
1023 sw2="s2",
1024 expectedLink=18 )
1025
1026 utilities.assert_equals( expect=main.TRUE,
1027 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -07001028 onpass=main.assertReturnString,
1029 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001030
kelvin-onlab016dce22015-08-10 09:54:11 -07001031 main.intentFunction.report( main )
1032
kelvin-onlabb769f562015-07-15 17:05:10 -07001033 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001034 """
1035 Add multi point to single point intents
1036 - Get device ids
1037 - Add multi point to single point intents
1038 - Check intents
1039 - Verify flows
1040 - Ping hosts
1041 - Reroute
1042 - Link down
1043 - Verify flows
1044 - Check topology
1045 - Ping hosts
1046 - Link up
1047 - Verify flows
1048 - Check topology
1049 - Ping hosts
1050 - Remove intents
1051 """
1052 assert main, "There is no main"
1053 assert main.CLIs, "There is no main.CLIs"
1054 assert main.Mininet1, "Mininet handle should be named Mininet1"
1055 assert main.numSwitch, "Placed the total number of switch topology in \
1056 main.numSwitch"
1057
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001058 main.testName = "Multi To Single Point Intents"
1059 main.case( main.testName + " Test - " + str( main.numCtrls ) +
1060 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -07001061 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001062 " multi point intents using " +\
1063 str( main.numCtrls ) + " node(s) cluster;\n" +\
1064 "Different type of hosts will be tested in " +\
1065 "each step such as IPV4, Dual stack, VLAN etc" +\
1066 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -07001067 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001068
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001069 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
acsmars5b78fcd2015-09-02 15:01:59 -07001074 # This test as written attempts something that is impossible
1075 # Multi to Single Raw intent cannot be bi-directional, so pings are not usable to test it
1076 # This test should be re-written so that one multi-to-single NOOPTION
1077 # intent is installed, with listeners at the destinations, so that one way
1078 # packets can be detected
1079 #
1080 # main.step( "NOOPTION: Add multi point to single point intents" )
1081 # stepResult = main.TRUE
1082 # stepResult = main.intentFunction.multiToSingleIntent(
1083 # main,
1084 # name="NOOPTION",
1085 # hostNames=hostNames,
1086 # devices=devices,
1087 # sw1="s5",
1088 # sw2="s2",
1089 # expectedLink=18 )
1090 #
1091 # utilities.assert_equals( expect=main.TRUE,
1092 # actual=stepResult,
1093 # onpass="NOOPTION: Successfully added multi "
1094 # + " point to single point intents" +
1095 # " with no match action",
1096 # onfail="NOOPTION: Failed to add multi point" +
1097 # " to single point intents" +
1098 # " with no match action" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001099
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001100 main.step( "IPV4: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001101 main.assertReturnString = "Assertion results for IPV4 multi to single point intent with IPV4 type and MAC addresses\n"
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001102 stepResult = main.intentFunction.multiToSingleIntent(
1103 main,
1104 name="IPV4",
1105 hostNames=hostNames,
1106 devices=devices,
1107 ports=None,
1108 ethType="IPV4",
1109 macs=macs,
1110 bandwidth="",
1111 lambdaAlloc=False,
1112 ipProto="",
1113 ipAddresses="",
1114 tcp="",
1115 sw1="s5",
1116 sw2="s2",
1117 expectedLink=18 )
1118
1119 utilities.assert_equals( expect=main.TRUE,
1120 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -07001121 onpass=main.assertReturnString,
1122 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001123
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001124 main.step( "IPV4_2: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001125 main.assertReturnString = "Assertion results for IPV4 multi to single point intent with IPV4 type and no MAC addresses\n"
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001126 hostNames = [ 'h8', 'h16', 'h24' ]
1127 stepResult = main.intentFunction.multiToSingleIntent(
1128 main,
1129 name="IPV4",
1130 hostNames=hostNames,
1131 ethType="IPV4",
1132 lambdaAlloc=False )
1133
1134 utilities.assert_equals( expect=main.TRUE,
1135 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -07001136 onpass=main.assertReturnString,
1137 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001138
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001139 main.step( "VLAN: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001140 main.assertReturnString = "Assertion results for IPV4 multi to single point intent with IPV4 type and no MAC addresses in the same VLAN\n"
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001141 hostNames = [ 'h5', 'h13', 'h21' ]
1142 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', \
1143 'of:0000000000000007/5' ]
1144 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
1145 stepResult = main.intentFunction.multiToSingleIntent(
1146 main,
1147 name="VLAN",
1148 hostNames=hostNames,
1149 devices=devices,
1150 ports=None,
1151 ethType="IPV4",
1152 macs=macs,
1153 bandwidth="",
1154 lambdaAlloc=False,
1155 ipProto="",
1156 ipAddresses="",
1157 tcp="",
1158 sw1="s5",
1159 sw2="s2",
1160 expectedLink=18 )
1161
1162 utilities.assert_equals( expect=main.TRUE,
1163 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -07001164 onpass=main.assertReturnString,
1165 onfail=main.assertReturnString )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001166
acsmars1ff5e052015-07-23 11:27:48 -07001167 def CASE5000( self, main ):
1168 """
acsmars5d8cc862015-09-25 09:44:50 -07001169 Tests Host Mobility
1170 Modifies the topology location of h1
acsmars1ff5e052015-07-23 11:27:48 -07001171 """
1172 assert main, "There is no main"
1173 assert main.CLIs, "There is no main.CLIs"
1174 assert main.Mininet1, "Mininet handle should be named Mininet1"
1175 assert main.numSwitch, "Placed the total number of switch topology in \
1176 main.numSwitch"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001177 main.case( "Test host mobility with host intents " )
1178 main.step( " Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07001179 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1180
1181 main.log.info( "Moving h1 from s5 to s6")
1182
1183 main.Mininet1.moveHost( "h1","s5","s6" )
1184
1185 main.intentFunction.getHostsData( main )
1186 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1187
1188 utilities.assert_equals( expect="of:0000000000000006",
1189 actual=h1PostMove,
1190 onpass="Mobility: Successfully moved h1 to s6",
acsmars5d8cc862015-09-25 09:44:50 -07001191 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001192 " to single point intents" +
1193 " with IPV4 type and MAC addresses" +
1194 " in the same VLAN" )
1195
1196 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001197 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001198 stepResult = main.intentFunction.hostIntent( main,
1199 onosNode='0',
1200 name='IPV4',
1201 host1='h1',
1202 host2='h9',
1203 host1Id='00:00:00:00:00:01/-1',
1204 host2Id='00:00:00:00:00:09/-1' )
1205
1206 utilities.assert_equals( expect=main.TRUE,
1207 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -07001208 onpass=main.assertReturnString,
1209 onfail=main.assertReturnString )
kelvin-onlab016dce22015-08-10 09:54:11 -07001210
1211 main.intentFunction.report( main )