blob: 9660fdc808797fd0f9e348ea05ee039b0e4eb738 [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 = []
Jeremy Songster1f39bf02016-01-20 17:17:25 -080059 main.scapyHostNames = main.params[ 'SCAPY' ][ 'HOSTNAMES' ].split( ',' )
60 main.scapyHosts = [] # List of scapy hosts for iterating
acsmars5d8cc862015-09-25 09:44:50 -070061 main.assertReturnString = '' # Assembled assert return string
kelvin-onlabd48a68c2015-07-13 16:01:36 -070062
Jon Halla3e02432015-07-24 15:55:42 -070063 main.ONOSip = main.ONOSbench.getOnosIps()
64 print main.ONOSip
kelvin-onlabd48a68c2015-07-13 16:01:36 -070065
Jon Halla3e02432015-07-24 15:55:42 -070066 # Assigning ONOS cli handles to a list
67 for i in range( 1, main.maxNodes + 1 ):
68 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070069
Jon Halla3e02432015-07-24 15:55:42 -070070 # -- INIT SECTION, ONLY RUNS ONCE -- #
71 main.startUp = imp.load_source( wrapperFile1,
72 main.dependencyPath +
73 wrapperFile1 +
74 ".py" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070075
Jon Halla3e02432015-07-24 15:55:42 -070076 main.intentFunction = imp.load_source( wrapperFile2,
77 main.dependencyPath +
78 wrapperFile2 +
79 ".py" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070080
Jon Halla3e02432015-07-24 15:55:42 -070081 main.topo = imp.load_source( wrapperFile3,
82 main.dependencyPath +
83 wrapperFile3 +
84 ".py" )
85
kelvin-onlabd9e23de2015-08-06 10:34:44 -070086 copyResult1 = main.ONOSbench.scp( main.Mininet1,
87 main.dependencyPath +
88 main.topology,
Jeremy Songster1f39bf02016-01-20 17:17:25 -080089 main.Mininet1.home + "custom/",
kelvin-onlabd9e23de2015-08-06 10:34:44 -070090 direction="to" )
Jon Halla3e02432015-07-24 15:55:42 -070091 if main.CLIs:
92 stepResult = main.TRUE
93 else:
94 main.log.error( "Did not properly created list of ONOS CLI handle" )
95 stepResult = main.FALSE
96 except Exception as e:
97 main.log.exception(e)
98 main.cleanup()
99 main.exit()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700100
101 utilities.assert_equals( expect=main.TRUE,
102 actual=stepResult,
103 onpass="Successfully construct " +
104 "test variables ",
105 onfail="Failed to construct test variables" )
106
107 if gitPull == 'True':
108 main.step( "Building ONOS in " + gitBranch + " branch" )
109 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
110 stepResult = onosBuildResult
111 utilities.assert_equals( expect=main.TRUE,
112 actual=stepResult,
113 onpass="Successfully compiled " +
114 "latest ONOS",
115 onfail="Failed to compile " +
116 "latest ONOS" )
117 else:
118 main.log.warn( "Did not pull new code so skipping mvn " +
119 "clean install" )
Jon Hall106be082015-07-22 09:53:00 -0700120 main.ONOSbench.getVersion( report=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700121
122 def CASE2( self, main ):
123 """
124 - Set up cell
125 - Create cell file
126 - Set cell file
127 - Verify cell file
128 - Kill ONOS process
129 - Uninstall ONOS cluster
130 - Verify ONOS start up
131 - Install ONOS cluster
132 - Connect to cli
133 """
134
135 # main.scale[ 0 ] determines the current number of ONOS controller
136 main.numCtrls = int( main.scale[ 0 ] )
137
138 main.case( "Starting up " + str( main.numCtrls ) +
139 " node(s) ONOS cluster" )
Jon Hall783bbf92015-07-23 14:33:19 -0700140 main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700141 " node(s) ONOS cluster"
142
143
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700144
145 #kill off all onos processes
146 main.log.info( "Safety check, killing all ONOS processes" +
Jon Hall70b2ff42015-11-17 15:49:44 -0800147 " before initiating environment setup" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700148
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800149 time.sleep( main.startUpSleep )
150 main.step( "Uninstalling ONOS package" )
151 onosUninstallResult = main.TRUE
152 for ip in main.ONOSip:
153 onosUninstallResult = onosUninstallResult and \
154 main.ONOSbench.onosUninstall( nodeIp=ip )
155 stepResult = onosUninstallResult
156 utilities.assert_equals( expect=main.TRUE,
157 actual=stepResult,
158 onpass="Successfully uninstalled ONOS package",
159 onfail="Failed to uninstall ONOS package" )
160
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700161 for i in range( main.maxNodes ):
162 main.ONOSbench.onosDie( main.ONOSip[ i ] )
163
164 print "NODE COUNT = ", main.numCtrls
165
166 tempOnosIp = []
167 for i in range( main.numCtrls ):
168 tempOnosIp.append( main.ONOSip[i] )
169
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700170 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
171 "temp", main.Mininet1.ip_address,
172 main.apps, tempOnosIp )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700173
174 main.step( "Apply cell to environment" )
175 cellResult = main.ONOSbench.setCell( "temp" )
176 verifyResult = main.ONOSbench.verifyCell()
177 stepResult = cellResult and verifyResult
178 utilities.assert_equals( expect=main.TRUE,
179 actual=stepResult,
180 onpass="Successfully applied cell to " + \
181 "environment",
182 onfail="Failed to apply cell to environment " )
183
184 main.step( "Creating ONOS package" )
185 packageResult = main.ONOSbench.onosPackage()
186 stepResult = packageResult
187 utilities.assert_equals( expect=main.TRUE,
188 actual=stepResult,
189 onpass="Successfully created ONOS package",
190 onfail="Failed to create ONOS package" )
191
192 time.sleep( main.startUpSleep )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700193 main.step( "Installing ONOS package" )
194 onosInstallResult = main.TRUE
195 for i in range( main.numCtrls ):
196 onosInstallResult = onosInstallResult and \
197 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
198 stepResult = onosInstallResult
199 utilities.assert_equals( expect=main.TRUE,
200 actual=stepResult,
201 onpass="Successfully installed ONOS package",
202 onfail="Failed to install ONOS package" )
203
204 time.sleep( main.startUpSleep )
205 main.step( "Starting ONOS service" )
206 stopResult = main.TRUE
207 startResult = main.TRUE
208 onosIsUp = main.TRUE
209
210 for i in range( main.numCtrls ):
211 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
212 if onosIsUp == main.TRUE:
213 main.log.report( "ONOS instance is up and ready" )
214 else:
215 main.log.report( "ONOS instance may not be up, stop and " +
216 "start ONOS again " )
acsmars2ec91d62015-09-16 11:15:48 -0700217
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700218 for i in range( main.numCtrls ):
219 stopResult = stopResult and \
220 main.ONOSbench.onosStop( main.ONOSip[ i ] )
221 for i in range( main.numCtrls ):
222 startResult = startResult and \
223 main.ONOSbench.onosStart( main.ONOSip[ i ] )
224 stepResult = onosIsUp and stopResult and startResult
225 utilities.assert_equals( expect=main.TRUE,
226 actual=stepResult,
227 onpass="ONOS service is ready",
228 onfail="ONOS service did not start properly" )
229
230 main.step( "Start ONOS cli" )
231 cliResult = main.TRUE
232 for i in range( main.numCtrls ):
233 cliResult = cliResult and \
234 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
235 stepResult = cliResult
236 utilities.assert_equals( expect=main.TRUE,
237 actual=stepResult,
238 onpass="Successfully start ONOS cli",
239 onfail="Failed to start ONOS cli" )
240
241 # Remove the first element in main.scale list
242 main.scale.remove( main.scale[ 0 ] )
243
kelvin-onlab016dce22015-08-10 09:54:11 -0700244 main.intentFunction.report( main )
245
Jon Halla3e02432015-07-24 15:55:42 -0700246 def CASE8( self, main ):
247 """
acsmars59a4c552015-09-10 18:11:19 -0700248 Compare ONOS Topology to Mininet Topology
Jon Halla3e02432015-07-24 15:55:42 -0700249 """
250 import json
251
252 main.case( "Compare ONOS Topology view to Mininet topology" )
253 main.caseExplanation = "Compare topology elements between Mininet" +\
254 " and ONOS"
255
acsmars59a4c552015-09-10 18:11:19 -0700256 main.log.info( "Gathering topology information from Mininet" )
257 devicesResults = main.FALSE # Overall Boolean for device correctness
258 linksResults = main.FALSE # Overall Boolean for link correctness
259 hostsResults = main.FALSE # Overall Boolean for host correctness
260 deviceFails = [] # Nodes where devices are incorrect
261 linkFails = [] # Nodes where links are incorrect
262 hostFails = [] # Nodes where hosts are incorrect
263 attempts = main.checkTopoAttempts # Remaining Attempts
Jon Halla3e02432015-07-24 15:55:42 -0700264
265 mnSwitches = main.Mininet1.getSwitches()
266 mnLinks = main.Mininet1.getLinks()
267 mnHosts = main.Mininet1.getHosts()
268
Jon Hall70b2ff42015-11-17 15:49:44 -0800269 main.step( "Comparing Mininet topology to ONOS topology" )
Jon Halla3e02432015-07-24 15:55:42 -0700270
acsmars59a4c552015-09-10 18:11:19 -0700271 while ( attempts >= 0 ) and\
272 ( not devicesResults or not linksResults or not hostsResults ):
273 time.sleep( 2 )
274 if not devicesResults:
275 devices = main.topo.getAllDevices( main )
276 ports = main.topo.getAllPorts( main )
277 devicesResults = main.TRUE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800278 deviceFails = [] # Reset for each failed attempt
acsmars59a4c552015-09-10 18:11:19 -0700279 if not linksResults:
280 links = main.topo.getAllLinks( main )
281 linksResults = main.TRUE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800282 linkFails = [] # Reset for each failed attempt
acsmars59a4c552015-09-10 18:11:19 -0700283 if not hostsResults:
284 hosts = main.topo.getAllHosts( main )
285 hostsResults = main.TRUE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800286 hostFails = [] # Reset for each failed attempt
Jon Halla3e02432015-07-24 15:55:42 -0700287
acsmars59a4c552015-09-10 18:11:19 -0700288 # Check for matching topology on each node
289 for controller in range( main.numCtrls ):
290 controllerStr = str( controller + 1 ) # ONOS node number
291 # Compare Devices
292 if devices[ controller ] and ports[ controller ] and\
293 "Error" not in devices[ controller ] and\
294 "Error" not in ports[ controller ]:
Jon Halla3e02432015-07-24 15:55:42 -0700295
acsmars2ec91d62015-09-16 11:15:48 -0700296 try:
297 deviceData = json.loads( devices[ controller ] )
298 portData = json.loads( ports[ controller ] )
299 except (TypeError,ValueError):
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800300 main.log.error( "Could not load json: {0} or {1}".format( str( devices[ controller ] ), str( ports[ controller ] ) ) )
acsmars2ec91d62015-09-16 11:15:48 -0700301 currentDevicesResult = main.FALSE
302 else:
303 currentDevicesResult = main.Mininet1.compareSwitches(
304 mnSwitches,deviceData,portData )
acsmars59a4c552015-09-10 18:11:19 -0700305 else:
306 currentDevicesResult = main.FALSE
307 if not currentDevicesResult:
308 deviceFails.append( controllerStr )
309 devicesResults = devicesResults and currentDevicesResult
310 # Compare Links
311 if links[ controller ] and "Error" not in links[ controller ]:
acsmars2ec91d62015-09-16 11:15:48 -0700312 try:
313 linkData = json.loads( links[ controller ] )
314 except (TypeError,ValueError):
315 main.log.error("Could not load json:" + str( links[ controller ] ) )
316 currentLinksResult = main.FALSE
317 else:
318 currentLinksResult = main.Mininet1.compareLinks(
319 mnSwitches, mnLinks,linkData )
acsmars59a4c552015-09-10 18:11:19 -0700320 else:
321 currentLinksResult = main.FALSE
322 if not currentLinksResult:
323 linkFails.append( controllerStr )
324 linksResults = linksResults and currentLinksResult
325 # Compare Hosts
acsmars2ec91d62015-09-16 11:15:48 -0700326 if hosts[ controller ] and "Error" not in hosts[ controller ]:
327 try:
328 hostData = json.loads( hosts[ controller ] )
329 except (TypeError,ValueError):
330 main.log.error("Could not load json:" + str( hosts[ controller ] ) )
331 currentHostsResult = main.FALSE
332 else:
333 currentHostsResult = main.Mininet1.compareHosts(
334 mnHosts,hostData )
acsmars59a4c552015-09-10 18:11:19 -0700335 else:
336 currentHostsResult = main.FALSE
337 if not currentHostsResult:
338 hostFails.append( controllerStr )
339 hostsResults = hostsResults and currentHostsResult
340 # Decrement Attempts Remaining
341 attempts -= 1
342
343
344 utilities.assert_equals( expect=[],
345 actual=deviceFails,
346 onpass="ONOS correctly discovered all devices",
347 onfail="ONOS incorrectly discovered devices on nodes: " +
348 str( deviceFails ) )
349 utilities.assert_equals( expect=[],
350 actual=linkFails,
351 onpass="ONOS correctly discovered all links",
352 onfail="ONOS incorrectly discovered links on nodes: " +
353 str( linkFails ) )
354 utilities.assert_equals( expect=[],
355 actual=hostFails,
356 onpass="ONOS correctly discovered all hosts",
357 onfail="ONOS incorrectly discovered hosts on nodes: " +
358 str( hostFails ) )
Jon Hall46d48252015-08-03 11:41:16 -0700359 topoResults = hostsResults and linksResults and devicesResults
360 utilities.assert_equals( expect=main.TRUE,
361 actual=topoResults,
362 onpass="ONOS correctly discovered the topology",
363 onfail="ONOS incorrectly discovered the topology" )
Jon Halla3e02432015-07-24 15:55:42 -0700364
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700365 def CASE10( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700366 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700367 Start Mininet topology with OF 1.0 switches
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700368 """
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700369 main.OFProtocol = "1.0"
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700370 main.log.report( "Start Mininet topology with OF 1.0 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700371 main.case( "Start Mininet topology with OF 1.0 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700372 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700373 "switches to test intents, exits out if " +\
374 "topology did not start correctly"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700375
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700376 main.step( "Starting Mininet topology with OF 1.0 switches" )
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700377 args = "--switch ovs,protocols=OpenFlow10"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700378 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700379 main.topology,
380 args=args )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700381 stepResult = topoResult
382 utilities.assert_equals( expect=main.TRUE,
383 actual=stepResult,
384 onpass="Successfully loaded topology",
385 onfail="Failed to load topology" )
386 # Exit if topology did not load properly
387 if not topoResult:
388 main.cleanup()
389 main.exit()
390
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700391 def CASE11( self, main ):
392 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700393 Start Mininet topology with OF 1.3 switches
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700394 """
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700395 main.OFProtocol = "1.3"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700396 main.log.report( "Start Mininet topology with OF 1.3 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700397 main.case( "Start Mininet topology with OF 1.3 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700398 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700399 "switches to test intents, exits out if " +\
400 "topology did not start correctly"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700401
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700402 main.step( "Starting Mininet topology with OF 1.3 switches" )
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700403 args = "--switch ovs,protocols=OpenFlow13"
404 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
405 main.topology,
406 args=args )
407 stepResult = topoResult
408 utilities.assert_equals( expect=main.TRUE,
409 actual=stepResult,
410 onpass="Successfully loaded topology",
411 onfail="Failed to load topology" )
412 # Exit if topology did not load properly
413 if not topoResult:
414 main.cleanup()
415 main.exit()
416
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700417 def CASE12( self, main ):
418 """
419 Assign mastership to controllers
420 """
421 import re
422
423 main.case( "Assign switches to controllers" )
424 main.step( "Assigning switches to controllers" )
Jon Hall783bbf92015-07-23 14:33:19 -0700425 main.caseExplanation = "Assign OF " + main.OFProtocol +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700426 " switches to ONOS nodes"
427
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700428 assignResult = main.TRUE
429 switchList = []
430
431 # Creates a list switch name, use getSwitch() function later...
432 for i in range( 1, ( main.numSwitch + 1 ) ):
433 switchList.append( 's' + str( i ) )
434
435 tempONOSip = []
436 for i in range( main.numCtrls ):
437 tempONOSip.append( main.ONOSip[ i ] )
438
439 assignResult = main.Mininet1.assignSwController( sw=switchList,
440 ip=tempONOSip,
Charles Chan029be652015-08-24 01:46:10 +0800441 port='6653' )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700442 if not assignResult:
443 main.cleanup()
444 main.exit()
445
446 for i in range( 1, ( main.numSwitch + 1 ) ):
447 response = main.Mininet1.getSwController( "s" + str( i ) )
448 print( "Response is " + str( response ) )
449 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
450 assignResult = assignResult and main.TRUE
451 else:
452 assignResult = main.FALSE
453 stepResult = assignResult
454 utilities.assert_equals( expect=main.TRUE,
455 actual=stepResult,
456 onpass="Successfully assigned switches" +
457 "to controller",
458 onfail="Failed to assign switches to " +
459 "controller" )
acsmars5d8cc862015-09-25 09:44:50 -0700460
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800461 def CASE13( self,main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700462 """
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800463 Create Scapy components
464 """
465 main.case( "Create scapy components" )
466 main.step( "Create scapy components" )
467 import json
468 scapyResult = main.TRUE
469 for hostName in main.scapyHostNames:
470 main.Scapy1.createHostComponent( hostName )
471 main.scapyHosts.append( getattr( main, hostName ) )
472
473 main.step( "Start scapy components" )
474 for host in main.scapyHosts:
475 host.startHostCli()
476 host.startScapy()
477 host.updateSelf()
478 main.log.debug( host.name )
479 main.log.debug( host.hostIp )
480 main.log.debug( host.hostMac )
481
482
483 utilities.assert_equals( expect=main.TRUE,
484 actual=scapyResult,
485 onpass="Successfully created Scapy Components",
486 onfail="Failed to discover Scapy Components" )
487
488 def CASE14( self, main ):
489 """
490 Discover all hosts with fwd and pingall and store its data in a dictionary
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700491 """
492 main.case( "Discover all hosts" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800493 main.step( "Pingall hosts and confirm ONOS discovery" )
494 utilities.retry( f=main.intentFunction.fwdPingall, retValue=main.FALSE, args=[ main ] )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700495
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800496 utilities.retry( f=main.intentFunction.confirmHostDiscovery, retValue=main.FALSE,
497 args=[ main ], attempts=main.checkTopoAttempts, sleep=2 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700498 utilities.assert_equals( expect=main.TRUE,
499 actual=stepResult,
500 onpass="Successfully discovered hosts",
501 onfail="Failed to discover hosts" )
502
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800503 main.step( "Populate hostsData" )
504 stepResult = main.intentFunction.populateHostData( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700505 utilities.assert_equals( expect=main.TRUE,
506 actual=stepResult,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800507 onpass="Successfully populated hostsData",
508 onfail="Failed to populate hostsData" )
509
510 def CASE15( self, main ):
511 """
512 Discover all hosts with scapy arp packets and store its data to a dictionary
513 """
514 main.case( "Discover all hosts using scapy" )
515 main.step( "Send packets from each host to the first host and confirm onos discovery" )
516
517 import collections
518 if len( main.scapyHosts ) < 1:
519 main.log.error( "No scapy hosts have been created" )
520 main.skipCase()
521
522 # Send ARP packets from each scapy host component
523 main.intentFunction.sendDiscoveryArp( main, main.scapyHosts )
524
525 stepResult = utilities.retry( f=main.intentFunction.confirmHostDiscovery,
526 retValue=main.FALSE, args=[ main ],
527 attempts=main.checkTopoAttempts, sleep=2 )
528
529 utilities.assert_equals( expect=main.TRUE,
530 actual=stepResult,
531 onpass="ONOS correctly discovered all hosts",
532 onfail="ONOS incorrectly discovered hosts" )
533
534 main.step( "Populate hostsData" )
535 stepResult = main.intentFunction.populateHostData( main )
536 utilities.assert_equals( expect=main.TRUE,
537 actual=stepResult,
538 onpass="Successfully populated hostsData",
539 onfail="Failed to populate hostsData" )
540
541
542 def CASE16( self, main ):
543 """
544 Stop mininet and remove scapy host
545 """
546 main.log.report( "Stop Mininet and Scapy" )
547 main.case( "Stop Mininet and Scapy" )
548 main.caseExplanation = "Stopping the current mininet topology " +\
549 "to start up fresh"
550 main.step( "Stopping and Removing Scapy Host Components" )
551 scapyResult = main.TRUE
552 for host in main.scapyHosts:
553 scapyResult = scapyResult and host.stopScapy()
554 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
555
556 for host in main.scapyHosts:
557 scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
558 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
559
560 main.scapyHosts = []
561 main.scapyHostIPs = []
562
563 utilities.assert_equals( expect=main.TRUE,
564 actual=scapyResult,
565 onpass="Successfully stopped scapy and removed host components",
566 onfail="Failed to stop mininet and scapy" )
567
568 main.step( "Stopping Mininet Topology" )
569 mininetResult = main.Mininet1.stopNet( )
570
571 utilities.assert_equals( expect=main.TRUE,
572 actual=mininetResult,
573 onpass="Successfully stopped mininet and scapy",
574 onfail="Failed to stop mininet and scapy" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700575 # Exit if topology did not load properly
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800576 if not ( mininetResult and scapyResult ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700577 main.cleanup()
578 main.exit()
579
kelvin-onlabb769f562015-07-15 17:05:10 -0700580 def CASE1000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700581 """
582 Add host intents between 2 host:
583 - Discover hosts
584 - Add host intents
585 - Check intents
586 - Verify flows
587 - Ping hosts
588 - Reroute
589 - Link down
590 - Verify flows
591 - Check topology
592 - Ping hosts
593 - Link up
594 - Verify flows
595 - Check topology
596 - Ping hosts
597 - Remove intents
598 """
599 import time
600 import json
601 import re
602
603 # Assert variables - These variable's name|format must be followed
604 # if you want to use the wrapper function
605 assert main, "There is no main"
606 assert main.CLIs, "There is no main.CLIs"
607 assert main.Mininet1, "Mininet handle should be named Mininet1"
608 assert main.numSwitch, "Placed the total number of switch topology in \
609 main.numSwitch"
610
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800611 # Save leader candidates
acsmarse6b410f2015-07-17 14:39:34 -0700612 intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
613
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700614 main.testName = "Host Intents"
615 main.case( main.testName + " Test - " + str( main.numCtrls ) +
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700616 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700617 main.caseExplanation = "This test case tests Host intents using " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700618 str( main.numCtrls ) + " node(s) cluster;\n" +\
619 "Different type of hosts will be tested in " +\
620 "each step such as IPV4, Dual stack, VLAN " +\
621 "etc;\nThe test will use OF " + main.OFProtocol\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700622 + " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700623
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700624 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700625 main.assertReturnString = "Assertion Result for IPV4 host intent with mac addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800626 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
627 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
628 testResult = main.FALSE
629 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700630 name='IPV4',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800631 onosNode='0',
632 host1=host1,
633 host2=host2)
634 if installResult:
635 testResult = main.intentFunction.testHostIntent( main,
636 name='IPV4',
637 intentId = installResult,
638 onosNode='0',
639 host1=host1,
640 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700641 sw1='s5',
642 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800643 expectedLink = 18)
644
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700645 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800646 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700647 onpass=main.assertReturnString,
648 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700649
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700650 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700651 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800652 host1 = { "name":"h3","id":"00:00:00:00:00:03/-1" }
653 host2 = { "name":"h11","id":"00:00:00:00:00:0B/-1 "}
654 testResult = main.FALSE
655 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700656 name='DUALSTACK',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800657 onosNode='0',
658 host1=host1,
659 host2=host2)
660
661 if installResult:
662 testResult = main.intentFunction.testHostIntent( main,
663 name='DUALSTACK',
664 intentId = installResult,
665 onosNode='0',
666 host1=host1,
667 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700668 sw1='s5',
669 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800670 expectedLink = 18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700671
672 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800673 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700674 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800675 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700676
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700677 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700678 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800679 host1 = { "name":"h1" }
680 host2 = { "name":"h11" }
681 testResult = main.FALSE
682 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700683 name='DUALSTACK2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800684 onosNode='0',
685 host1=host1,
686 host2=host2)
687
688 if installResult:
689 testResult = main.intentFunction.testHostIntent( main,
690 name='DUALSTACK2',
691 intentId = installResult,
692 onosNode='0',
693 host1=host1,
694 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700695 sw1='s5',
696 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800697 expectedLink = 18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700698
699 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800700 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700701 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800702 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700703
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700704 main.step( "1HOP: Add host intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -0700705 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800706 host1 = { "name":"h1" }
707 host2 = { "name":"h3" }
708 testResult = main.FALSE
709 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700710 name='1HOP',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800711 onosNode='0',
712 host1=host1,
713 host2=host2)
714
715 if installResult:
716 testResult = main.intentFunction.testHostIntent( main,
717 name='1HOP',
718 intentId = installResult,
719 onosNode='0',
720 host1=host1,
721 host2=host2,
722 sw1='s5',
723 sw2='s2',
724 expectedLink = 18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700725
726 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800727 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700728 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800729 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700730
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700731 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
acsmars5d8cc862015-09-25 09:44:50 -0700732 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800733 host1 = { "name":"h4","id":"00:00:00:00:00:04/100" }
734 host2 = { "name":"h12","id":"00:00:00:00:00:0C/100 "}
735 testResult = main.FALSE
736 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700737 name='VLAN1',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800738 onosNode='0',
739 host1=host1,
740 host2=host2)
741
742 if installResult:
743 testResult = main.intentFunction.testHostIntent( main,
744 name='VLAN1',
745 intentId = installResult,
746 onosNode='0',
747 host1=host1,
748 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700749 sw1='s5',
750 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800751 expectedLink = 18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700752
753 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800754 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700755 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800756 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700757
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700758 main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
acsmars5d8cc862015-09-25 09:44:50 -0700759 main.assertReturnString = "Assertion Result different VLAN negative test\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800760 host1 = { "name":"h13" }
761 host2 = { "name":"h20" }
762 testResult = main.FALSE
763 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700764 name='VLAN2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800765 onosNode='0',
766 host1=host1,
767 host2=host2)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700768
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800769 if installResult:
770 testResult = main.intentFunction.testHostIntent( main,
771 name='VLAN2',
772 intentId = installResult,
773 onosNode='0',
774 host1=host1,
775 host2=host2,
776 sw1='s5',
777 sw2='s2',
778 expectedLink = 18)
779
780 utilities.assert_equals( expect=main.TRUE,
781 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700782 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800783 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700784
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800785 main.step( "Confirm that ONOS leadership is unchanged")
acsmarse6b410f2015-07-17 14:39:34 -0700786 intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
787 main.intentFunction.checkLeaderChange( intentLeadersOld,
788 intentLeadersNew )
789
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800790 utilities.assert_equals( expect=main.TRUE,
791 actual=testResult,
792 onpass="ONOS Leaders Unchanged",
793 onfail="ONOS Leader Mismatch")
794
kelvin-onlab016dce22015-08-10 09:54:11 -0700795 main.intentFunction.report( main )
796
kelvin-onlabb769f562015-07-15 17:05:10 -0700797 def CASE2000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700798 """
799 Add point intents between 2 hosts:
800 - Get device ids | ports
801 - Add point intents
802 - Check intents
803 - Verify flows
804 - Ping hosts
805 - Reroute
806 - Link down
807 - Verify flows
808 - Check topology
809 - Ping hosts
810 - Link up
811 - Verify flows
812 - Check topology
813 - Ping hosts
814 - Remove intents
815 """
816 import time
817 import json
818 import re
819
820 # Assert variables - These variable's name|format must be followed
821 # if you want to use the wrapper function
822 assert main, "There is no main"
823 assert main.CLIs, "There is no main.CLIs"
824 assert main.Mininet1, "Mininet handle should be named Mininet1"
825 assert main.numSwitch, "Placed the total number of switch topology in \
826 main.numSwitch"
827
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700828 main.testName = "Point Intents"
829 main.case( main.testName + " Test - " + str( main.numCtrls ) +
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700830 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700831 main.caseExplanation = "This test case will test point to point" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700832 " intents using " + str( main.numCtrls ) +\
833 " node(s) cluster;\n" +\
834 "Different type of hosts will be tested in " +\
835 "each step such as IPV4, Dual stack, VLAN etc" +\
836 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700837 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700838
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700839 # No option point intents
840 main.step( "NOOPTION: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700841 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800842 senders = [
843 { "name":"h1","device":"of:0000000000000005/1" }
844 ]
845 recipients = [
846 { "name":"h9","device":"of:0000000000000006/1" }
847 ]
848 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700849 main,
850 name="NOOPTION",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800851 senders=senders,
852 recipients=recipients )
853
854 if installResult:
855 testResult = main.intentFunction.testPointIntent(
856 main,
857 intentId=installResult,
858 name="NOOPTION",
859 senders=senders,
860 recipients=recipients,
861 sw1="s5",
862 sw2="s2",
863 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700864
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700865 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800866 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700867 onpass=main.assertReturnString,
868 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700869
870 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -0700871 main.step( "IPV4: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700872 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800873 senders = [
874 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
875 ]
876 recipients = [
877 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09" }
878 ]
879 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700880 main,
881 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800882 senders=senders,
883 recipients=recipients,
884 ethType="IPV4" )
885
886 if installResult:
887 testResult = main.intentFunction.testPointIntent(
888 main,
889 intentId=installResult,
890 name="IPV4",
891 senders=senders,
892 recipients=recipients,
893 sw1="s5",
894 sw2="s2",
895 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700896
897 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800898 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700899 onpass=main.assertReturnString,
900 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -0700901 main.step( "IPV4_2: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700902 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800903 senders = [
904 { "name":"h1","device":"of:0000000000000005/1" }
905 ]
906 recipients = [
907 { "name":"h9","device":"of:0000000000000006/1" }
908 ]
909 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700910 main,
911 name="IPV4_2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800912 senders=senders,
913 recipients=recipients,
914 ethType="IPV4" )
915
916 if installResult:
917 testResult = main.intentFunction.testPointIntent(
918 main,
919 intentId=installResult,
920 name="IPV4_2",
921 senders=senders,
922 recipients=recipients,
923 sw1="s5",
924 sw2="s2",
925 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700926
927 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800928 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700929 onpass=main.assertReturnString,
930 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700931
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700932 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700933 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800934 senders = [
935 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01",
936 "ip":main.h1.hostIp }
937 ]
938 recipients = [
939 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09",
940 "ip":main.h9.hostIp }
941 ]
kelvin-onlabb769f562015-07-15 17:05:10 -0700942 ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
kelvin-onlab79ce0492015-07-27 16:14:39 -0700943 # Uneccessary, not including this in the selectors
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800944 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
945 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
kelvin-onlabb769f562015-07-15 17:05:10 -0700946
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800947 installResult = main.intentFunction.installPointIntent(
948 main,
949 name="SDNIP-ICMP",
950 senders=senders,
951 recipients=recipients,
952 ethType="IPV4",
953 ipProto=ipProto,
954 tcpSrc=tcpSrc,
955 tcpDst=tcpDst )
956
957 if installResult:
958 testResult = main.intentFunction.testPointIntent(
959 main,
960 intentId=installResult,
961 name="SDNIP_ICMP",
962 senders=senders,
963 recipients=recipients,
964 sw1="s5",
965 sw2="s2",
966 expectedLink=18)
kelvin-onlabb769f562015-07-15 17:05:10 -0700967
968 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800969 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700970 onpass=main.assertReturnString,
971 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -0700972
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700973 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700974 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
kelvin-onlabb769f562015-07-15 17:05:10 -0700975 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
976 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab58dc39e2015-08-06 08:11:09 -0700977 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
978 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlabb769f562015-07-15 17:05:10 -0700979 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
980 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
981 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
982
kelvin-onlab58dc39e2015-08-06 08:11:09 -0700983 stepResult = main.intentFunction.pointIntentTcp(
kelvin-onlabb769f562015-07-15 17:05:10 -0700984 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700985 name="SDNIP-TCP",
kelvin-onlabb769f562015-07-15 17:05:10 -0700986 host1="h1",
987 host2="h9",
988 deviceId1="of:0000000000000005/1",
989 deviceId2="of:0000000000000006/1",
990 mac1=mac1,
991 mac2=mac2,
992 ethType="IPV4",
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700993 ipProto=ipProto,
994 ip1=ip1,
995 ip2=ip2,
996 tcp1=tcp1,
997 tcp2=tcp2 )
kelvin-onlabb769f562015-07-15 17:05:10 -0700998
999 utilities.assert_equals( expect=main.TRUE,
1000 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -07001001 onpass=main.assertReturnString,
1002 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001003
acsmars5d8cc862015-09-25 09:44:50 -07001004 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
1005 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001006 senders = [
1007 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1008 ]
1009 recipients = [
1010 { "name":"h11","device":"of:0000000000000006/3","mac":"00:00:00:00:00:0B" }
1011 ]
1012 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001013 main,
1014 name="DUALSTACK1",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001015 senders=senders,
1016 recipients=recipients,
1017 ethType="IPV4" )
1018
1019 if installResult:
1020 testResult = main.intentFunction.testPointIntent(
1021 main,
1022 intentId=installResult,
1023 name="DUALSTACK1",
1024 senders=senders,
1025 recipients=recipients,
1026 sw1="s5",
1027 sw2="s2",
1028 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001029
1030 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001031 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001032 onpass=main.assertReturnString,
1033 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001034
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001035 main.step( "VLAN: Add point intents between h5 and h21" )
acsmars5d8cc862015-09-25 09:44:50 -07001036 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001037 senders = [
1038 { "name":"h5","device":"of:0000000000000005/5","mac":"00:00:00:00:00:05" }
1039 ]
1040 recipients = [
1041 { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15" }
1042 ]
1043 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001044 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001045 name="DUALSTACK1",
1046 senders=senders,
1047 recipients=recipients,
1048 ethType="IPV4" )
1049
1050 if installResult:
1051 testResult = main.intentFunction.testPointIntent(
1052 main,
1053 intentId=installResult,
1054 name="DUALSTACK1",
1055 senders=senders,
1056 recipients=recipients,
1057 sw1="s5",
1058 sw2="s2",
1059 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001060
1061 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001062 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001063 onpass=main.assertReturnString,
1064 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001065
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001066 main.step( "1HOP: Add point intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -07001067 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001068 senders = [
1069 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1070 ]
1071 recipients = [
1072 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1073 ]
1074 installResult = main.intentFunction.installPointIntent(
1075 main,
1076 name="1HOP IPV4",
1077 senders=senders,
1078 recipients=recipients,
1079 ethType="IPV4" )
1080
1081 if installResult:
1082 testResult = main.intentFunction.testPointIntent(
1083 main,
1084 intentId=installResult,
1085 name="1HOP IPV4",
1086 senders=senders,
1087 recipients=recipients,
1088 sw1="s5",
1089 sw2="s2",
1090 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001091
1092 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001093 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001094 onpass=main.assertReturnString,
1095 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001096
kelvin-onlab016dce22015-08-10 09:54:11 -07001097 main.intentFunction.report( main )
1098
kelvin-onlabb769f562015-07-15 17:05:10 -07001099 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001100 """
1101 Add single point to multi point intents
1102 - Get device ids
1103 - Add single point to multi point intents
1104 - Check intents
1105 - Verify flows
1106 - Ping hosts
1107 - Reroute
1108 - Link down
1109 - Verify flows
1110 - Check topology
1111 - Ping hosts
1112 - Link up
1113 - Verify flows
1114 - Check topology
1115 - Ping hosts
1116 - Remove intents
1117 """
1118 assert main, "There is no main"
1119 assert main.CLIs, "There is no main.CLIs"
1120 assert main.Mininet1, "Mininet handle should be named Mininet1"
1121 assert main.numSwitch, "Placed the total number of switch topology in \
1122 main.numSwitch"
1123
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001124 main.testName = "Single to Multi Point Intents"
1125 main.case( main.testName + " Test - " + str( main.numCtrls ) +
1126 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -07001127 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001128 " multi point intents using " +\
1129 str( main.numCtrls ) + " node(s) cluster;\n" +\
1130 "Different type of hosts will be tested in " +\
1131 "each step such as IPV4, Dual stack, VLAN etc" +\
1132 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -07001133 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001134
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001135 main.step( "NOOPTION: Install and test single point to multi point intents" )
1136 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
1137 senders = [
1138 { "name":"h8", "device":"of:0000000000000005/8" }
1139 ]
1140 recipients = [
1141 { "name":"h16", "device":"of:0000000000000006/8" },
1142 { "name":"h24", "device":"of:0000000000000007/8" }
1143 ]
1144 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1145 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1146 testResult = main.FALSE
1147 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001148 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001149 name="NOOPTION",
1150 senders=senders,
1151 recipients=recipients,
1152 sw1="s5",
1153 sw2="s2")
1154
1155 if installResult:
1156 testResult = main.intentFunction.testPointIntent(
1157 main,
1158 intentId=installResult,
1159 name="NOOPTION",
1160 senders=senders,
1161 recipients=recipients,
1162 badSenders=badSenders,
1163 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001164 sw1="s5",
1165 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001166 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001167
1168 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001169 actual=testResult,
1170 onpass=main.assertReturnString,
1171 onfail=main.assertReturnString )
1172
1173 main.step( "IPV4: Install and test single point to multi point intents" )
1174 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses\n"
1175 senders = [
1176 { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" }
1177 ]
1178 recipients = [
1179 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1180 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1181 ]
1182 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1183 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1184 testResult = main.FALSE
1185 installResult = main.intentFunction.installSingleToMultiIntent(
1186 main,
1187 name="IPV4",
1188 senders=senders,
1189 recipients=recipients,
1190 ethType="IPV4",
1191 sw1="s5",
1192 sw2="s2")
1193
1194 if installResult:
1195 testResult = main.intentFunction.testPointIntent(
1196 main,
1197 intentId=installResult,
1198 name="IPV4",
1199 senders=senders,
1200 recipients=recipients,
1201 badSenders=badSenders,
1202 badRecipients=badRecipients,
1203 sw1="s5",
1204 sw2="s2",
1205 expectedLink=18)
1206
1207 utilities.assert_equals( expect=main.TRUE,
1208 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001209 onpass=main.assertReturnString,
1210 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001211
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001212 main.step( "IPV4_2: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001213 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and no MAC addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001214 senders = [
1215 { "name":"h8", "device":"of:0000000000000005/8" }
1216 ]
1217 recipients = [
1218 { "name":"h16", "device":"of:0000000000000006/8" },
1219 { "name":"h24", "device":"of:0000000000000007/8" }
1220 ]
1221 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1222 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1223 testResult = main.FALSE
1224 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001225 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001226 name="IPV4_2",
1227 senders=senders,
1228 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001229 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001230 sw1="s5",
1231 sw2="s2")
1232
1233 if installResult:
1234 testResult = main.intentFunction.testPointIntent(
1235 main,
1236 intentId=installResult,
1237 name="IPV4_2",
1238 senders=senders,
1239 recipients=recipients,
1240 badSenders=badSenders,
1241 badRecipients=badRecipients,
1242 sw1="s5",
1243 sw2="s2",
1244 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001245
1246 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001247 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001248 onpass=main.assertReturnString,
1249 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001250
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001251 main.step( "VLAN: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001252 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses in the same VLAN\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001253 senders = [
1254 { "name":"h4", "device":"of:0000000000000005/4", "mac":"00:00:00:00:00:04" }
1255 ]
1256 recipients = [
1257 { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C" },
1258 { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14" }
1259 ]
1260 badSenders=[ { "name":"h13" } ] # Senders that are not in the intent
1261 badRecipients=[ { "name":"h21" } ] # Recipients that are not in the intent
1262 testResult = main.FALSE
1263 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001264 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001265 name="IPV4",
1266 senders=senders,
1267 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001268 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001269 sw1="s5",
1270 sw2="s2")
1271
1272 if installResult:
1273 testResult = main.intentFunction.testPointIntent(
1274 main,
1275 intentId=installResult,
1276 name="IPV4",
1277 senders=senders,
1278 recipients=recipients,
1279 badSenders=badSenders,
1280 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001281 sw1="s5",
1282 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001283 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001284
1285 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001286 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001287 onpass=main.assertReturnString,
1288 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001289
kelvin-onlab016dce22015-08-10 09:54:11 -07001290 main.intentFunction.report( main )
1291
kelvin-onlabb769f562015-07-15 17:05:10 -07001292 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001293 """
1294 Add multi point to single point intents
1295 - Get device ids
1296 - Add multi point to single point intents
1297 - Check intents
1298 - Verify flows
1299 - Ping hosts
1300 - Reroute
1301 - Link down
1302 - Verify flows
1303 - Check topology
1304 - Ping hosts
1305 - Link up
1306 - Verify flows
1307 - Check topology
1308 - Ping hosts
1309 - Remove intents
1310 """
1311 assert main, "There is no main"
1312 assert main.CLIs, "There is no main.CLIs"
1313 assert main.Mininet1, "Mininet handle should be named Mininet1"
1314 assert main.numSwitch, "Placed the total number of switch topology in \
1315 main.numSwitch"
1316
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001317 main.testName = "Multi To Single Point Intents"
1318 main.case( main.testName + " Test - " + str( main.numCtrls ) +
1319 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -07001320 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001321 " multi point intents using " +\
1322 str( main.numCtrls ) + " node(s) cluster;\n" +\
1323 "Different type of hosts will be tested in " +\
1324 "each step such as IPV4, Dual stack, VLAN etc" +\
1325 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -07001326 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001327
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001328 main.step( "NOOPTION: Add multi point to single point intents" )
1329 main.assertReturnString = "Assertion results for NOOPTION multi to single point intent\n"
1330 senders = [
1331 { "name":"h16", "device":"of:0000000000000006/8" },
1332 { "name":"h24", "device":"of:0000000000000007/8" }
1333 ]
1334 recipients = [
1335 { "name":"h8", "device":"of:0000000000000005/8" }
1336 ]
1337 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1338 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1339 testResult = main.FALSE
1340 installResult = main.intentFunction.installMultiToSingleIntent(
1341 main,
1342 name="NOOPTION",
1343 senders=senders,
1344 recipients=recipients,
1345 sw1="s5",
1346 sw2="s2")
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001347
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001348 if installResult:
1349 testResult = main.intentFunction.testPointIntent(
1350 main,
1351 intentId=installResult,
1352 name="NOOPTION",
1353 senders=senders,
1354 recipients=recipients,
1355 badSenders=badSenders,
1356 badRecipients=badRecipients,
1357 sw1="s5",
1358 sw2="s2",
1359 expectedLink=18)
1360
1361 utilities.assert_equals( expect=main.TRUE,
1362 actual=testResult,
1363 onpass=main.assertReturnString,
1364 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001365
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001366 main.step( "IPV4: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001367 main.assertReturnString = "Assertion results for IPV4 multi to single point intent with IPV4 type and MAC addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001368 senders = [
1369 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1370 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1371 ]
1372 recipients = [
1373 { "name":"h8", "device":"of:0000000000000005/8", "mac":"00:00:00:00:00:08" }
1374 ]
1375 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1376 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1377 testResult = main.FALSE
1378 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001379 main,
1380 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001381 senders=senders,
1382 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001383 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001384 sw1="s5",
1385 sw2="s2")
1386
1387 if installResult:
1388 testResult = main.intentFunction.testPointIntent(
1389 main,
1390 intentId=installResult,
1391 name="IPV4",
1392 senders=senders,
1393 recipients=recipients,
1394 badSenders=badSenders,
1395 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001396 sw1="s5",
1397 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001398 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001399
1400 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001401 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001402 onpass=main.assertReturnString,
1403 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001404
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001405 main.step( "IPV4_2: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001406 main.assertReturnString = "Assertion results for IPV4 multi to single point intent with IPV4 type and no MAC addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001407 senders = [
1408 { "name":"h16", "device":"of:0000000000000006/8" },
1409 { "name":"h24", "device":"of:0000000000000007/8" }
1410 ]
1411 recipients = [
1412 { "name":"h8", "device":"of:0000000000000005/8" }
1413 ]
1414 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1415 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1416 testResult = main.FALSE
1417 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001418 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001419 name="IPV4_2",
1420 senders=senders,
1421 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001422 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001423 sw1="s5",
1424 sw2="s2")
1425
1426 if installResult:
1427 testResult = main.intentFunction.testPointIntent(
1428 main,
1429 intentId=installResult,
1430 name="IPV4_2",
1431 senders=senders,
1432 recipients=recipients,
1433 badSenders=badSenders,
1434 badRecipients=badRecipients,
1435 sw1="s5",
1436 sw2="s2",
1437 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001438
1439 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001440 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001441 onpass=main.assertReturnString,
1442 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001443
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001444 main.step( "VLAN: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001445 main.assertReturnString = "Assertion results for IPV4 multi to single point intent with IPV4 type and no MAC addresses in the same VLAN\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001446 senders = [
1447 { "name":"h13", "device":"of:0000000000000006/5" },
1448 { "name":"h21", "device":"of:0000000000000007/5" }
1449 ]
1450 recipients = [
1451 { "name":"h5", "device":"of:0000000000000005/5" }
1452 ]
1453 badSenders=[ { "name":"h12" } ] # Senders that are not in the intent
1454 badRecipients=[ { "name":"h20" } ] # Recipients that are not in the intent
1455 testResult = main.FALSE
1456 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001457 main,
1458 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001459 senders=senders,
1460 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001461 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001462 sw1="s5",
1463 sw2="s2")
1464
1465 if installResult:
1466 testResult = main.intentFunction.testPointIntent(
1467 main,
1468 intentId=installResult,
1469 name="VLAN",
1470 senders=senders,
1471 recipients=recipients,
1472 badSenders=badSenders,
1473 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001474 sw1="s5",
1475 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001476 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001477
1478 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001479 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001480 onpass=main.assertReturnString,
1481 onfail=main.assertReturnString )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001482
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001483 main.intentFunction.report( main )
1484
acsmars1ff5e052015-07-23 11:27:48 -07001485 def CASE5000( self, main ):
1486 """
acsmars5d8cc862015-09-25 09:44:50 -07001487 Tests Host Mobility
1488 Modifies the topology location of h1
acsmars1ff5e052015-07-23 11:27:48 -07001489 """
1490 assert main, "There is no main"
1491 assert main.CLIs, "There is no main.CLIs"
1492 assert main.Mininet1, "Mininet handle should be named Mininet1"
1493 assert main.numSwitch, "Placed the total number of switch topology in \
1494 main.numSwitch"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001495 main.case( "Test host mobility with host intents " )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001496 main.step( "Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07001497 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1498
1499 main.log.info( "Moving h1 from s5 to s6")
acsmars1ff5e052015-07-23 11:27:48 -07001500 main.Mininet1.moveHost( "h1","s5","s6" )
1501
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001502 # Send discovery ping from moved host
1503 # Moving the host brings down the default interfaces and creates a new one.
1504 # Scapy is restarted on this host to detect the new interface
1505 main.h1.stopScapy()
1506 main.h1.startScapy()
1507
1508 # Discover new host location in ONOS and populate host data.
1509 # Host 1 IP and MAC should be unchanged
1510 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
1511 main.intentFunction.populateHostData( main )
1512
acsmars1ff5e052015-07-23 11:27:48 -07001513 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1514
1515 utilities.assert_equals( expect="of:0000000000000006",
1516 actual=h1PostMove,
1517 onpass="Mobility: Successfully moved h1 to s6",
acsmars5d8cc862015-09-25 09:44:50 -07001518 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001519 " to single point intents" +
1520 " with IPV4 type and MAC addresses" +
1521 " in the same VLAN" )
1522
1523 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001524 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001525 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
1526 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
1527
1528 installResult = main.intentFunction.installHostIntent( main,
1529 name='IPV4 Mobility IPV4',
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001530 onosNode='0',
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001531 host1=host1,
1532 host2=host2)
1533
1534 testResult = main.intentFunction.testHostIntent( main,
1535 name='Host Mobility IPV4',
1536 intentId = installResult,
1537 onosNode='0',
1538 host1=host1,
1539 host2=host2,
1540 sw1="s6",
1541 sw2="s2",
1542 expectedLink=18 )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001543
1544 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001545 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001546 onpass=main.assertReturnString,
1547 onfail=main.assertReturnString )
kelvin-onlab016dce22015-08-10 09:54:11 -07001548
1549 main.intentFunction.report( main )