blob: e1660f17ce28789b01082456feef295c3eb21064 [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
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800541 def CASE16( self, main ):
542 """
543 Stop mininet and remove scapy host
544 """
545 main.log.report( "Stop Mininet and Scapy" )
546 main.case( "Stop Mininet and Scapy" )
547 main.caseExplanation = "Stopping the current mininet topology " +\
548 "to start up fresh"
549 main.step( "Stopping and Removing Scapy Host Components" )
550 scapyResult = main.TRUE
551 for host in main.scapyHosts:
552 scapyResult = scapyResult and host.stopScapy()
553 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
554
555 for host in main.scapyHosts:
556 scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
557 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
558
559 main.scapyHosts = []
560 main.scapyHostIPs = []
561
562 utilities.assert_equals( expect=main.TRUE,
563 actual=scapyResult,
564 onpass="Successfully stopped scapy and removed host components",
565 onfail="Failed to stop mininet and scapy" )
566
567 main.step( "Stopping Mininet Topology" )
568 mininetResult = main.Mininet1.stopNet( )
569
570 utilities.assert_equals( expect=main.TRUE,
571 actual=mininetResult,
572 onpass="Successfully stopped mininet and scapy",
573 onfail="Failed to stop mininet and scapy" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700574 # Exit if topology did not load properly
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800575 if not ( mininetResult and scapyResult ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700576 main.cleanup()
577 main.exit()
578
kelvin-onlabb769f562015-07-15 17:05:10 -0700579 def CASE1000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700580 """
581 Add host intents between 2 host:
582 - Discover hosts
583 - Add host intents
584 - Check intents
585 - Verify flows
586 - Ping hosts
587 - Reroute
588 - Link down
589 - Verify flows
590 - Check topology
591 - Ping hosts
592 - Link up
593 - Verify flows
594 - Check topology
595 - Ping hosts
596 - Remove intents
597 """
598 import time
599 import json
600 import re
601
602 # Assert variables - These variable's name|format must be followed
603 # if you want to use the wrapper function
604 assert main, "There is no main"
605 assert main.CLIs, "There is no main.CLIs"
606 assert main.Mininet1, "Mininet handle should be named Mininet1"
607 assert main.numSwitch, "Placed the total number of switch topology in \
608 main.numSwitch"
609
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800610 # Save leader candidates
acsmarse6b410f2015-07-17 14:39:34 -0700611 intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
612
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700613 main.testName = "Host Intents"
614 main.case( main.testName + " Test - " + str( main.numCtrls ) +
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700615 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700616 main.caseExplanation = "This test case tests Host intents using " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700617 str( main.numCtrls ) + " node(s) cluster;\n" +\
618 "Different type of hosts will be tested in " +\
619 "each step such as IPV4, Dual stack, VLAN " +\
620 "etc;\nThe test will use OF " + main.OFProtocol\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700621 + " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700622
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700623 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700624 main.assertReturnString = "Assertion Result for IPV4 host intent with mac addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800625 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
626 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
627 testResult = main.FALSE
628 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700629 name='IPV4',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800630 onosNode='0',
631 host1=host1,
632 host2=host2)
633 if installResult:
634 testResult = main.intentFunction.testHostIntent( main,
635 name='IPV4',
636 intentId = installResult,
637 onosNode='0',
638 host1=host1,
639 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700640 sw1='s5',
641 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800642 expectedLink = 18)
643
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700644 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800645 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700646 onpass=main.assertReturnString,
647 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700648
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700649 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700650 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800651 host1 = { "name":"h3","id":"00:00:00:00:00:03/-1" }
652 host2 = { "name":"h11","id":"00:00:00:00:00:0B/-1 "}
653 testResult = main.FALSE
654 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700655 name='DUALSTACK',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800656 onosNode='0',
657 host1=host1,
658 host2=host2)
659
660 if installResult:
661 testResult = main.intentFunction.testHostIntent( main,
662 name='DUALSTACK',
663 intentId = installResult,
664 onosNode='0',
665 host1=host1,
666 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700667 sw1='s5',
668 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800669 expectedLink = 18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700670
671 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800672 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700673 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800674 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700675
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700676 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700677 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800678 host1 = { "name":"h1" }
679 host2 = { "name":"h11" }
680 testResult = main.FALSE
681 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700682 name='DUALSTACK2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800683 onosNode='0',
684 host1=host1,
685 host2=host2)
686
687 if installResult:
688 testResult = main.intentFunction.testHostIntent( main,
689 name='DUALSTACK2',
690 intentId = installResult,
691 onosNode='0',
692 host1=host1,
693 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700694 sw1='s5',
695 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800696 expectedLink = 18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700697
698 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800699 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700700 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800701 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700702
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700703 main.step( "1HOP: Add host intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -0700704 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800705 host1 = { "name":"h1" }
706 host2 = { "name":"h3" }
707 testResult = main.FALSE
708 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700709 name='1HOP',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800710 onosNode='0',
711 host1=host1,
712 host2=host2)
713
714 if installResult:
715 testResult = main.intentFunction.testHostIntent( main,
716 name='1HOP',
717 intentId = installResult,
718 onosNode='0',
719 host1=host1,
720 host2=host2,
721 sw1='s5',
722 sw2='s2',
723 expectedLink = 18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700724
725 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800726 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700727 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800728 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700729
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700730 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
acsmars5d8cc862015-09-25 09:44:50 -0700731 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800732 host1 = { "name":"h4","id":"00:00:00:00:00:04/100" }
733 host2 = { "name":"h12","id":"00:00:00:00:00:0C/100 "}
734 testResult = main.FALSE
735 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700736 name='VLAN1',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800737 onosNode='0',
738 host1=host1,
739 host2=host2)
740
741 if installResult:
742 testResult = main.intentFunction.testHostIntent( main,
743 name='VLAN1',
744 intentId = installResult,
745 onosNode='0',
746 host1=host1,
747 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700748 sw1='s5',
749 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800750 expectedLink = 18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700751
752 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800753 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700754 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800755 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700756
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700757 main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
acsmars5d8cc862015-09-25 09:44:50 -0700758 main.assertReturnString = "Assertion Result different VLAN negative test\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800759 host1 = { "name":"h13" }
760 host2 = { "name":"h20" }
761 testResult = main.FALSE
762 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700763 name='VLAN2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800764 onosNode='0',
765 host1=host1,
766 host2=host2)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700767
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800768 if installResult:
769 testResult = main.intentFunction.testHostIntent( main,
770 name='VLAN2',
771 intentId = installResult,
772 onosNode='0',
773 host1=host1,
774 host2=host2,
775 sw1='s5',
776 sw2='s2',
777 expectedLink = 18)
778
779 utilities.assert_equals( expect=main.TRUE,
780 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700781 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800782 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700783
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800784 main.step( "Confirm that ONOS leadership is unchanged")
acsmarse6b410f2015-07-17 14:39:34 -0700785 intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
786 main.intentFunction.checkLeaderChange( intentLeadersOld,
787 intentLeadersNew )
788
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800789 utilities.assert_equals( expect=main.TRUE,
790 actual=testResult,
791 onpass="ONOS Leaders Unchanged",
792 onfail="ONOS Leader Mismatch")
793
kelvin-onlab016dce22015-08-10 09:54:11 -0700794 main.intentFunction.report( main )
795
kelvin-onlabb769f562015-07-15 17:05:10 -0700796 def CASE2000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700797 """
798 Add point intents between 2 hosts:
799 - Get device ids | ports
800 - Add point intents
801 - Check intents
802 - Verify flows
803 - Ping hosts
804 - Reroute
805 - Link down
806 - Verify flows
807 - Check topology
808 - Ping hosts
809 - Link up
810 - Verify flows
811 - Check topology
812 - Ping hosts
813 - Remove intents
814 """
815 import time
816 import json
817 import re
818
819 # Assert variables - These variable's name|format must be followed
820 # if you want to use the wrapper function
821 assert main, "There is no main"
822 assert main.CLIs, "There is no main.CLIs"
823 assert main.Mininet1, "Mininet handle should be named Mininet1"
824 assert main.numSwitch, "Placed the total number of switch topology in \
825 main.numSwitch"
826
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700827 main.testName = "Point Intents"
828 main.case( main.testName + " Test - " + str( main.numCtrls ) +
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700829 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -0700830 main.caseExplanation = "This test case will test point to point" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700831 " intents using " + str( main.numCtrls ) +\
832 " node(s) cluster;\n" +\
833 "Different type of hosts will be tested in " +\
834 "each step such as IPV4, Dual stack, VLAN etc" +\
835 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -0700836 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700837
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700838 # No option point intents
839 main.step( "NOOPTION: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700840 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800841 senders = [
842 { "name":"h1","device":"of:0000000000000005/1" }
843 ]
844 recipients = [
845 { "name":"h9","device":"of:0000000000000006/1" }
846 ]
847 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700848 main,
849 name="NOOPTION",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800850 senders=senders,
851 recipients=recipients )
852
853 if installResult:
854 testResult = main.intentFunction.testPointIntent(
855 main,
856 intentId=installResult,
857 name="NOOPTION",
858 senders=senders,
859 recipients=recipients,
860 sw1="s5",
861 sw2="s2",
862 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700863
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700864 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800865 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700866 onpass=main.assertReturnString,
867 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700868
869 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -0700870 main.step( "IPV4: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700871 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800872 senders = [
873 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
874 ]
875 recipients = [
876 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09" }
877 ]
878 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700879 main,
880 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800881 senders=senders,
882 recipients=recipients,
883 ethType="IPV4" )
884
885 if installResult:
886 testResult = main.intentFunction.testPointIntent(
887 main,
888 intentId=installResult,
889 name="IPV4",
890 senders=senders,
891 recipients=recipients,
892 sw1="s5",
893 sw2="s2",
894 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700895
896 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800897 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700898 onpass=main.assertReturnString,
899 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -0700900 main.step( "IPV4_2: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700901 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800902 senders = [
903 { "name":"h1","device":"of:0000000000000005/1" }
904 ]
905 recipients = [
906 { "name":"h9","device":"of:0000000000000006/1" }
907 ]
908 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700909 main,
910 name="IPV4_2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800911 senders=senders,
912 recipients=recipients,
913 ethType="IPV4" )
914
915 if installResult:
916 testResult = main.intentFunction.testPointIntent(
917 main,
918 intentId=installResult,
919 name="IPV4_2",
920 senders=senders,
921 recipients=recipients,
922 sw1="s5",
923 sw2="s2",
924 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700925
926 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800927 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700928 onpass=main.assertReturnString,
929 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700930
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700931 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700932 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800933 senders = [
934 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01",
935 "ip":main.h1.hostIp }
936 ]
937 recipients = [
938 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09",
939 "ip":main.h9.hostIp }
940 ]
kelvin-onlabb769f562015-07-15 17:05:10 -0700941 ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
kelvin-onlab79ce0492015-07-27 16:14:39 -0700942 # Uneccessary, not including this in the selectors
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800943 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
944 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
kelvin-onlabb769f562015-07-15 17:05:10 -0700945
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800946 installResult = main.intentFunction.installPointIntent(
947 main,
948 name="SDNIP-ICMP",
949 senders=senders,
950 recipients=recipients,
951 ethType="IPV4",
952 ipProto=ipProto,
953 tcpSrc=tcpSrc,
954 tcpDst=tcpDst )
955
956 if installResult:
957 testResult = main.intentFunction.testPointIntent(
958 main,
959 intentId=installResult,
960 name="SDNIP_ICMP",
961 senders=senders,
962 recipients=recipients,
963 sw1="s5",
964 sw2="s2",
965 expectedLink=18)
kelvin-onlabb769f562015-07-15 17:05:10 -0700966
967 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800968 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700969 onpass=main.assertReturnString,
970 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -0700971
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700972 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700973 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
kelvin-onlabb769f562015-07-15 17:05:10 -0700974 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
975 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab58dc39e2015-08-06 08:11:09 -0700976 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
977 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlabb769f562015-07-15 17:05:10 -0700978 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
979 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
980 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
981
kelvin-onlab58dc39e2015-08-06 08:11:09 -0700982 stepResult = main.intentFunction.pointIntentTcp(
kelvin-onlabb769f562015-07-15 17:05:10 -0700983 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700984 name="SDNIP-TCP",
kelvin-onlabb769f562015-07-15 17:05:10 -0700985 host1="h1",
986 host2="h9",
987 deviceId1="of:0000000000000005/1",
988 deviceId2="of:0000000000000006/1",
989 mac1=mac1,
990 mac2=mac2,
991 ethType="IPV4",
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700992 ipProto=ipProto,
993 ip1=ip1,
994 ip2=ip2,
995 tcp1=tcp1,
996 tcp2=tcp2 )
kelvin-onlabb769f562015-07-15 17:05:10 -0700997
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
acsmars5d8cc862015-09-25 09:44:50 -07001003 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
1004 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001005 senders = [
1006 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1007 ]
1008 recipients = [
1009 { "name":"h11","device":"of:0000000000000006/3","mac":"00:00:00:00:00:0B" }
1010 ]
1011 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001012 main,
1013 name="DUALSTACK1",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001014 senders=senders,
1015 recipients=recipients,
1016 ethType="IPV4" )
1017
1018 if installResult:
1019 testResult = main.intentFunction.testPointIntent(
1020 main,
1021 intentId=installResult,
1022 name="DUALSTACK1",
1023 senders=senders,
1024 recipients=recipients,
1025 sw1="s5",
1026 sw2="s2",
1027 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001028
1029 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001030 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001031 onpass=main.assertReturnString,
1032 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001033
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001034 main.step( "VLAN: Add point intents between h5 and h21" )
acsmars5d8cc862015-09-25 09:44:50 -07001035 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001036 senders = [
1037 { "name":"h5","device":"of:0000000000000005/5","mac":"00:00:00:00:00:05" }
1038 ]
1039 recipients = [
1040 { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15" }
1041 ]
1042 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001043 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001044 name="DUALSTACK1",
1045 senders=senders,
1046 recipients=recipients,
1047 ethType="IPV4" )
1048
1049 if installResult:
1050 testResult = main.intentFunction.testPointIntent(
1051 main,
1052 intentId=installResult,
1053 name="DUALSTACK1",
1054 senders=senders,
1055 recipients=recipients,
1056 sw1="s5",
1057 sw2="s2",
1058 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001059
1060 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001061 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001062 onpass=main.assertReturnString,
1063 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001064
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001065 main.step( "1HOP: Add point intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -07001066 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001067 senders = [
1068 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1069 ]
1070 recipients = [
1071 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1072 ]
1073 installResult = main.intentFunction.installPointIntent(
1074 main,
1075 name="1HOP IPV4",
1076 senders=senders,
1077 recipients=recipients,
1078 ethType="IPV4" )
1079
1080 if installResult:
1081 testResult = main.intentFunction.testPointIntent(
1082 main,
1083 intentId=installResult,
1084 name="1HOP IPV4",
1085 senders=senders,
1086 recipients=recipients,
1087 sw1="s5",
1088 sw2="s2",
1089 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001090
1091 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001092 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001093 onpass=main.assertReturnString,
1094 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001095
kelvin-onlab016dce22015-08-10 09:54:11 -07001096 main.intentFunction.report( main )
1097
kelvin-onlabb769f562015-07-15 17:05:10 -07001098 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001099 """
1100 Add single point to multi point intents
1101 - Get device ids
1102 - Add single point to multi point intents
1103 - Check intents
1104 - Verify flows
1105 - Ping hosts
1106 - Reroute
1107 - Link down
1108 - Verify flows
1109 - Check topology
1110 - Ping hosts
1111 - Link up
1112 - Verify flows
1113 - Check topology
1114 - Ping hosts
1115 - Remove intents
1116 """
1117 assert main, "There is no main"
1118 assert main.CLIs, "There is no main.CLIs"
1119 assert main.Mininet1, "Mininet handle should be named Mininet1"
1120 assert main.numSwitch, "Placed the total number of switch topology in \
1121 main.numSwitch"
1122
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001123 main.testName = "Single to Multi Point Intents"
1124 main.case( main.testName + " Test - " + str( main.numCtrls ) +
1125 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -07001126 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001127 " multi point intents using " +\
1128 str( main.numCtrls ) + " node(s) cluster;\n" +\
1129 "Different type of hosts will be tested in " +\
1130 "each step such as IPV4, Dual stack, VLAN etc" +\
1131 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -07001132 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001133
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001134 main.step( "NOOPTION: Install and test single point to multi point intents" )
1135 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
1136 senders = [
1137 { "name":"h8", "device":"of:0000000000000005/8" }
1138 ]
1139 recipients = [
1140 { "name":"h16", "device":"of:0000000000000006/8" },
1141 { "name":"h24", "device":"of:0000000000000007/8" }
1142 ]
1143 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1144 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1145 testResult = main.FALSE
1146 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001147 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001148 name="NOOPTION",
1149 senders=senders,
1150 recipients=recipients,
1151 sw1="s5",
1152 sw2="s2")
1153
1154 if installResult:
1155 testResult = main.intentFunction.testPointIntent(
1156 main,
1157 intentId=installResult,
1158 name="NOOPTION",
1159 senders=senders,
1160 recipients=recipients,
1161 badSenders=badSenders,
1162 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001163 sw1="s5",
1164 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001165 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001166
1167 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001168 actual=testResult,
1169 onpass=main.assertReturnString,
1170 onfail=main.assertReturnString )
1171
1172 main.step( "IPV4: Install and test single point to multi point intents" )
1173 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses\n"
1174 senders = [
1175 { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" }
1176 ]
1177 recipients = [
1178 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1179 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1180 ]
1181 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1182 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1183 testResult = main.FALSE
1184 installResult = main.intentFunction.installSingleToMultiIntent(
1185 main,
1186 name="IPV4",
1187 senders=senders,
1188 recipients=recipients,
1189 ethType="IPV4",
1190 sw1="s5",
1191 sw2="s2")
1192
1193 if installResult:
1194 testResult = main.intentFunction.testPointIntent(
1195 main,
1196 intentId=installResult,
1197 name="IPV4",
1198 senders=senders,
1199 recipients=recipients,
1200 badSenders=badSenders,
1201 badRecipients=badRecipients,
1202 sw1="s5",
1203 sw2="s2",
1204 expectedLink=18)
1205
1206 utilities.assert_equals( expect=main.TRUE,
1207 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001208 onpass=main.assertReturnString,
1209 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001210
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001211 main.step( "IPV4_2: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001212 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 -08001213 senders = [
1214 { "name":"h8", "device":"of:0000000000000005/8" }
1215 ]
1216 recipients = [
1217 { "name":"h16", "device":"of:0000000000000006/8" },
1218 { "name":"h24", "device":"of:0000000000000007/8" }
1219 ]
1220 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1221 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1222 testResult = main.FALSE
1223 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001224 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001225 name="IPV4_2",
1226 senders=senders,
1227 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001228 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001229 sw1="s5",
1230 sw2="s2")
1231
1232 if installResult:
1233 testResult = main.intentFunction.testPointIntent(
1234 main,
1235 intentId=installResult,
1236 name="IPV4_2",
1237 senders=senders,
1238 recipients=recipients,
1239 badSenders=badSenders,
1240 badRecipients=badRecipients,
1241 sw1="s5",
1242 sw2="s2",
1243 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001244
1245 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001246 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001247 onpass=main.assertReturnString,
1248 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001249
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001250 main.step( "VLAN: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001251 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 -08001252 senders = [
1253 { "name":"h4", "device":"of:0000000000000005/4", "mac":"00:00:00:00:00:04" }
1254 ]
1255 recipients = [
1256 { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C" },
1257 { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14" }
1258 ]
1259 badSenders=[ { "name":"h13" } ] # Senders that are not in the intent
1260 badRecipients=[ { "name":"h21" } ] # Recipients that are not in the intent
1261 testResult = main.FALSE
1262 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001263 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001264 name="IPV4",
1265 senders=senders,
1266 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001267 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001268 sw1="s5",
1269 sw2="s2")
1270
1271 if installResult:
1272 testResult = main.intentFunction.testPointIntent(
1273 main,
1274 intentId=installResult,
1275 name="IPV4",
1276 senders=senders,
1277 recipients=recipients,
1278 badSenders=badSenders,
1279 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001280 sw1="s5",
1281 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001282 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001283
1284 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001285 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001286 onpass=main.assertReturnString,
1287 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001288
kelvin-onlab016dce22015-08-10 09:54:11 -07001289 main.intentFunction.report( main )
1290
kelvin-onlabb769f562015-07-15 17:05:10 -07001291 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001292 """
1293 Add multi point to single point intents
1294 - Get device ids
1295 - Add multi point to single point intents
1296 - Check intents
1297 - Verify flows
1298 - Ping hosts
1299 - Reroute
1300 - Link down
1301 - Verify flows
1302 - Check topology
1303 - Ping hosts
1304 - Link up
1305 - Verify flows
1306 - Check topology
1307 - Ping hosts
1308 - Remove intents
1309 """
1310 assert main, "There is no main"
1311 assert main.CLIs, "There is no main.CLIs"
1312 assert main.Mininet1, "Mininet handle should be named Mininet1"
1313 assert main.numSwitch, "Placed the total number of switch topology in \
1314 main.numSwitch"
1315
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001316 main.testName = "Multi To Single Point Intents"
1317 main.case( main.testName + " Test - " + str( main.numCtrls ) +
1318 " NODE(S) - OF " + main.OFProtocol )
Jon Hall783bbf92015-07-23 14:33:19 -07001319 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001320 " multi point intents using " +\
1321 str( main.numCtrls ) + " node(s) cluster;\n" +\
1322 "Different type of hosts will be tested in " +\
1323 "each step such as IPV4, Dual stack, VLAN etc" +\
1324 ";\nThe test will use OF " + main.OFProtocol +\
kelvin-onlab4cfa81c2015-07-24 11:36:23 -07001325 " OVS running in Mininet"
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001326
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001327 main.step( "NOOPTION: Add multi point to single point intents" )
1328 main.assertReturnString = "Assertion results for NOOPTION multi to single point intent\n"
1329 senders = [
1330 { "name":"h16", "device":"of:0000000000000006/8" },
1331 { "name":"h24", "device":"of:0000000000000007/8" }
1332 ]
1333 recipients = [
1334 { "name":"h8", "device":"of:0000000000000005/8" }
1335 ]
1336 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1337 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1338 testResult = main.FALSE
1339 installResult = main.intentFunction.installMultiToSingleIntent(
1340 main,
1341 name="NOOPTION",
1342 senders=senders,
1343 recipients=recipients,
1344 sw1="s5",
Jeremye0cb5eb2016-01-27 17:39:09 -08001345 sw2="s2" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001346
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001347 if installResult:
1348 testResult = main.intentFunction.testPointIntent(
1349 main,
1350 intentId=installResult,
1351 name="NOOPTION",
1352 senders=senders,
1353 recipients=recipients,
1354 badSenders=badSenders,
1355 badRecipients=badRecipients,
1356 sw1="s5",
1357 sw2="s2",
Jeremye0cb5eb2016-01-27 17:39:09 -08001358 expectedLink=18 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001359
1360 utilities.assert_equals( expect=main.TRUE,
1361 actual=testResult,
1362 onpass=main.assertReturnString,
1363 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001364
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001365 main.step( "IPV4: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001366 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 -08001367 senders = [
1368 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1369 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1370 ]
1371 recipients = [
1372 { "name":"h8", "device":"of:0000000000000005/8", "mac":"00:00:00:00:00:08" }
1373 ]
1374 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1375 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1376 testResult = main.FALSE
1377 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001378 main,
1379 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001380 senders=senders,
1381 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001382 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001383 sw1="s5",
1384 sw2="s2")
1385
1386 if installResult:
1387 testResult = main.intentFunction.testPointIntent(
1388 main,
1389 intentId=installResult,
1390 name="IPV4",
1391 senders=senders,
1392 recipients=recipients,
1393 badSenders=badSenders,
1394 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001395 sw1="s5",
1396 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001397 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001398
1399 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001400 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001401 onpass=main.assertReturnString,
1402 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001403
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001404 main.step( "IPV4_2: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001405 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 -08001406 senders = [
1407 { "name":"h16", "device":"of:0000000000000006/8" },
1408 { "name":"h24", "device":"of:0000000000000007/8" }
1409 ]
1410 recipients = [
1411 { "name":"h8", "device":"of:0000000000000005/8" }
1412 ]
1413 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1414 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1415 testResult = main.FALSE
1416 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001417 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001418 name="IPV4_2",
1419 senders=senders,
1420 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001421 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001422 sw1="s5",
1423 sw2="s2")
1424
1425 if installResult:
1426 testResult = main.intentFunction.testPointIntent(
1427 main,
1428 intentId=installResult,
1429 name="IPV4_2",
1430 senders=senders,
1431 recipients=recipients,
1432 badSenders=badSenders,
1433 badRecipients=badRecipients,
1434 sw1="s5",
1435 sw2="s2",
1436 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001437
1438 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001439 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001440 onpass=main.assertReturnString,
1441 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001442
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001443 main.step( "VLAN: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001444 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 -08001445 senders = [
1446 { "name":"h13", "device":"of:0000000000000006/5" },
1447 { "name":"h21", "device":"of:0000000000000007/5" }
1448 ]
1449 recipients = [
1450 { "name":"h5", "device":"of:0000000000000005/5" }
1451 ]
1452 badSenders=[ { "name":"h12" } ] # Senders that are not in the intent
1453 badRecipients=[ { "name":"h20" } ] # Recipients that are not in the intent
1454 testResult = main.FALSE
1455 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001456 main,
1457 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001458 senders=senders,
1459 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001460 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001461 sw1="s5",
1462 sw2="s2")
1463
1464 if installResult:
1465 testResult = main.intentFunction.testPointIntent(
1466 main,
1467 intentId=installResult,
1468 name="VLAN",
1469 senders=senders,
1470 recipients=recipients,
1471 badSenders=badSenders,
1472 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001473 sw1="s5",
1474 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001475 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001476
1477 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001478 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001479 onpass=main.assertReturnString,
1480 onfail=main.assertReturnString )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001481
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001482 main.intentFunction.report( main )
1483
acsmars1ff5e052015-07-23 11:27:48 -07001484 def CASE5000( self, main ):
1485 """
acsmars5d8cc862015-09-25 09:44:50 -07001486 Tests Host Mobility
1487 Modifies the topology location of h1
acsmars1ff5e052015-07-23 11:27:48 -07001488 """
1489 assert main, "There is no main"
1490 assert main.CLIs, "There is no main.CLIs"
1491 assert main.Mininet1, "Mininet handle should be named Mininet1"
1492 assert main.numSwitch, "Placed the total number of switch topology in \
1493 main.numSwitch"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001494 main.case( "Test host mobility with host intents " )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001495 main.step( "Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07001496 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1497
Jeremy2f190ca2016-01-29 15:23:57 -08001498 main.log.info( "Moving h1 from s5 to s6")
acsmars1ff5e052015-07-23 11:27:48 -07001499 main.Mininet1.moveHost( "h1","s5","s6" )
1500
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001501 # Send discovery ping from moved host
1502 # Moving the host brings down the default interfaces and creates a new one.
1503 # Scapy is restarted on this host to detect the new interface
1504 main.h1.stopScapy()
1505 main.h1.startScapy()
1506
1507 # Discover new host location in ONOS and populate host data.
1508 # Host 1 IP and MAC should be unchanged
1509 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
1510 main.intentFunction.populateHostData( main )
1511
acsmars1ff5e052015-07-23 11:27:48 -07001512 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1513
1514 utilities.assert_equals( expect="of:0000000000000006",
1515 actual=h1PostMove,
1516 onpass="Mobility: Successfully moved h1 to s6",
acsmars5d8cc862015-09-25 09:44:50 -07001517 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001518 " to single point intents" +
1519 " with IPV4 type and MAC addresses" +
1520 " in the same VLAN" )
1521
1522 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001523 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001524 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
1525 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
1526
1527 installResult = main.intentFunction.installHostIntent( main,
1528 name='IPV4 Mobility IPV4',
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001529 onosNode='0',
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001530 host1=host1,
Jeremye0cb5eb2016-01-27 17:39:09 -08001531 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -08001532 if installResult:
1533 testResult = main.intentFunction.testHostIntent( main,
1534 name='Host Mobility IPV4',
1535 intentId = installResult,
1536 onosNode='0',
1537 host1=host1,
1538 host2=host2,
1539 sw1="s6",
1540 sw2="s2",
1541 expectedLink=18 )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001542
1543 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001544 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001545 onpass=main.assertReturnString,
1546 onfail=main.assertReturnString )
kelvin-onlab016dce22015-08-10 09:54:11 -07001547
1548 main.intentFunction.report( main )
Jeremye0cb5eb2016-01-27 17:39:09 -08001549
1550 def CASE6000( self, main ):
1551 """
1552 Tests Multi to Single Point Intent and Single to Multi Point Intent End Point Failure
1553 """
1554 assert main, "There is no main"
1555 assert main.CLIs, "There is no main.CLIs"
1556 assert main.Mininet1, "Mininet handle should be named Mininet1"
1557 assert main.numSwitch, "Placed the total number of switch topology in \
1558 main.numSwitch"
1559 main.case( "Test Multi to Single End Point Failure" )
1560 main.step( "Installing Multi to Single Point intents" )
1561
1562 main.assertReturnString = "Assertion results for IPV4 multi to single \
1563 point intent end point failure with no options set\n"
1564 senders = [
1565 { "name":"h16", "device":"of:0000000000000006/8" },
1566 { "name":"h24", "device":"of:0000000000000007/8" }
1567 ]
1568 recipients = [
1569 { "name":"h8", "device":"of:0000000000000005/8" }
1570 ]
1571 isolatedSenders = [
1572 { "name":"h24"}
1573 ]
1574 isolatedRecipients = []
1575 testResult = main.FALSE
1576 installResult = main.intentFunction.installMultiToSingleIntent(
1577 main,
1578 name="NOOPTION",
1579 senders=senders,
1580 recipients=recipients,
1581 sw1="s5",
1582 sw2="s2" )
1583
1584 if installResult:
1585 testResult = main.intentFunction.testEndPointFail(
1586 main,
1587 intentId=installResult,
1588 name="NOOPTION",
1589 senders=senders,
1590 recipients=recipients,
1591 isolatedSenders=isolatedSenders,
1592 isolatedRecipients=isolatedRecipients,
1593 sw1="s6",
1594 sw2="s2",
1595 sw3="s4",
1596 sw4="s1",
1597 sw5="s3",
1598 expectedLink1=16,
1599 expectedLink2=14 )
1600
1601 utilities.assert_equals( expect=main.TRUE,
1602 actual=testResult,
1603 onpass=main.assertReturnString,
1604 onfail=main.assertReturnString )
1605
1606 main.step( "IPV4: Add multi point to single point intents" )
1607 main.assertReturnString = "Assertion results for IPV4 multi to single \
1608 point intent end point failure with IPV4 type and MAC addresses\n"
1609 senders = [
1610 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1611 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1612 ]
1613 recipients = [
1614 { "name":"h8", "device":"of:0000000000000005/8", "mac":"00:00:00:00:00:08" }
1615 ]
1616 isolatedSenders = [
1617 { "name":"h24"}
1618 ]
1619 isolatedRecipients = []
1620 testResult = main.FALSE
1621 installResult = main.intentFunction.installMultiToSingleIntent(
1622 main,
1623 name="IPV4",
1624 senders=senders,
1625 recipients=recipients,
1626 ethType="IPV4",
1627 sw1="s5",
1628 sw2="s2")
1629
1630 if installResult:
1631 testResult = main.intentFunction.testEndPointFail(
1632 main,
1633 intentId=installResult,
1634 name="IPV4",
1635 senders=senders,
1636 recipients=recipients,
1637 isolatedSenders=isolatedSenders,
1638 isolatedRecipients=isolatedRecipients,
1639 sw1="s6",
1640 sw2="s2",
1641 sw3="s4",
1642 sw4="s1",
1643 sw5="s3",
1644 expectedLink1=16,
1645 expectedLink2=14 )
1646 utilities.assert_equals( expect=main.TRUE,
1647 actual=testResult,
1648 onpass=main.assertReturnString,
1649 onfail=main.assertReturnString )
1650
1651 main.step( "IPV4_2: Add multi point to single point intents" )
1652 main.assertReturnString = "Assertion results for IPV4 multi to single \
1653 point intent end point failure with IPV4 type and no MAC addresses\n"
1654 senders = [
1655 { "name":"h16", "device":"of:0000000000000006/8" },
1656 { "name":"h24", "device":"of:0000000000000007/8" }
1657 ]
1658 recipients = [
1659 { "name":"h8", "device":"of:0000000000000005/8" }
1660 ]
1661 isolatedSenders = [
1662 { "name":"h24"}
1663 ]
1664 isolatedRecipients = []
1665 testResult = main.FALSE
1666 installResult = main.intentFunction.installMultiToSingleIntent(
1667 main,
1668 name="IPV4_2",
1669 senders=senders,
1670 recipients=recipients,
1671 ethType="IPV4",
1672 sw1="s5",
1673 sw2="s2")
1674
1675 if installResult:
1676 testResult = main.intentFunction.testEndPointFail(
1677 main,
1678 intentId=installResult,
1679 name="IPV4_2",
1680 senders=senders,
1681 recipients=recipients,
1682 isolatedSenders=isolatedSenders,
1683 isolatedRecipients=isolatedRecipients,
1684 sw1="s6",
1685 sw2="s2",
1686 sw3="s4",
1687 sw4="s1",
1688 sw5="s3",
1689 expectedLink1=16,
1690 expectedLink2=14 )
1691
1692 utilities.assert_equals( expect=main.TRUE,
1693 actual=testResult,
1694 onpass=main.assertReturnString,
1695 onfail=main.assertReturnString )
1696
1697 main.step( "VLAN: Add multi point to single point intents" )
1698 main.assertReturnString = "Assertion results for IPV4 multi to single \
1699 point intent end point failure with IPV4 type and no MAC addresses in the same VLAN\n"
1700 senders = [
1701 { "name":"h13", "device":"of:0000000000000006/5" },
1702 { "name":"h21", "device":"of:0000000000000007/5" }
1703 ]
1704 recipients = [
1705 { "name":"h5", "device":"of:0000000000000005/5" }
1706 ]
1707 isolatedSenders = [
1708 { "name":"h21"}
1709 ]
1710 isolatedRecipients = []
1711 testResult = main.FALSE
1712 installResult = main.intentFunction.installMultiToSingleIntent(
1713 main,
1714 name="VLAN",
1715 senders=senders,
1716 recipients=recipients,
1717 ethType="IPV4",
1718 sw1="s5",
1719 sw2="s2")
1720
1721 if installResult:
1722 testResult = main.intentFunction.testEndPointFail(
1723 main,
1724 intentId=installResult,
1725 name="VLAN",
1726 senders=senders,
1727 recipients=recipients,
1728 isolatedSenders=isolatedSenders,
1729 isolatedRecipients=isolatedRecipients,
1730 sw1="s6",
1731 sw2="s2",
1732 sw3="s4",
1733 sw4="s1",
1734 sw5="s3",
1735 expectedLink1=16,
1736 expectedLink2=14 )
1737
1738 utilities.assert_equals( expect=main.TRUE,
1739 actual=testResult,
1740 onpass=main.assertReturnString,
1741 onfail=main.assertReturnString )
1742
1743 main.step( "NOOPTION: Install and test single point to multi point intents" )
1744 main.assertReturnString = "Assertion results for IPV4 single to multi \
1745 point intent end point failure with no options set\n"
1746 senders = [
1747 { "name":"h8", "device":"of:0000000000000005/8" }
1748 ]
1749 recipients = [
1750 { "name":"h16", "device":"of:0000000000000006/8" },
1751 { "name":"h24", "device":"of:0000000000000007/8" }
1752 ]
1753 isolatedSenders = []
1754 isolatedRecipients = [
1755 { "name":"h24" }
1756 ]
1757 testResult = main.FALSE
1758 installResult = main.intentFunction.installSingleToMultiIntent(
1759 main,
1760 name="NOOPTION",
1761 senders=senders,
1762 recipients=recipients,
1763 sw1="s5",
1764 sw2="s2")
1765
1766 if installResult:
1767 testResult = main.intentFunction.testEndPointFail(
1768 main,
1769 intentId=installResult,
1770 name="NOOPTION",
1771 senders=senders,
1772 recipients=recipients,
1773 isolatedSenders=isolatedSenders,
1774 isolatedRecipients=isolatedRecipients,
1775 sw1="s6",
1776 sw2="s2",
1777 sw3="s4",
1778 sw4="s1",
1779 sw5="s3",
1780 expectedLink1=16,
1781 expectedLink2=14 )
1782
1783 utilities.assert_equals( expect=main.TRUE,
1784 actual=testResult,
1785 onpass=main.assertReturnString,
1786 onfail=main.assertReturnString )
1787
1788 main.step( "IPV4: Install and test single point to multi point intents" )
1789 main.assertReturnString = "Assertion results for IPV4 single to multi \
1790 point intent end point failure with IPV4 type and no MAC addresses\n"
1791 senders = [
1792 { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" }
1793 ]
1794 recipients = [
1795 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1796 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1797 ]
1798 isolatedSenders = []
1799 isolatedRecipients = [
1800 { "name":"h24" }
1801 ]
1802 testResult = main.FALSE
1803 installResult = main.intentFunction.installSingleToMultiIntent(
1804 main,
1805 name="IPV4",
1806 senders=senders,
1807 recipients=recipients,
1808 ethType="IPV4",
1809 sw1="s5",
1810 sw2="s2")
1811
1812 if installResult:
1813 testResult = main.intentFunction.testEndPointFail(
1814 main,
1815 intentId=installResult,
1816 name="IPV4",
1817 senders=senders,
1818 recipients=recipients,
1819 isolatedSenders=isolatedSenders,
1820 isolatedRecipients=isolatedRecipients,
1821 sw1="s6",
1822 sw2="s2",
1823 sw3="s4",
1824 sw4="s1",
1825 sw5="s3",
1826 expectedLink1=16,
1827 expectedLink2=14 )
1828
1829 utilities.assert_equals( expect=main.TRUE,
1830 actual=testResult,
1831 onpass=main.assertReturnString,
1832 onfail=main.assertReturnString )
1833
1834 main.step( "IPV4_2: Add single point to multi point intents" )
1835 main.assertReturnString = "Assertion results for IPV4 single to multi\
1836 point intent endpoint failure with IPV4 type and no MAC addresses\n"
1837 senders = [
1838 { "name":"h8", "device":"of:0000000000000005/8" }
1839 ]
1840 recipients = [
1841 { "name":"h16", "device":"of:0000000000000006/8" },
1842 { "name":"h24", "device":"of:0000000000000007/8" }
1843 ]
1844 isolatedSenders = []
1845 isolatedRecipients = [
1846 { "name":"h24" }
1847 ]
1848 testResult = main.FALSE
1849 installResult = main.intentFunction.installSingleToMultiIntent(
1850 main,
1851 name="IPV4_2",
1852 senders=senders,
1853 recipients=recipients,
1854 ethType="IPV4",
1855 sw1="s5",
1856 sw2="s2")
1857
1858 if installResult:
1859 testResult = main.intentFunction.testEndPointFail(
1860 main,
1861 intentId=installResult,
1862 name="IPV4_2",
1863 senders=senders,
1864 recipients=recipients,
1865 isolatedSenders=isolatedSenders,
1866 isolatedRecipients=isolatedRecipients,
1867 sw1="s6",
1868 sw2="s2",
1869 sw3="s4",
1870 sw4="s1",
1871 sw5="s3",
1872 expectedLink1=16,
1873 expectedLink2=14 )
1874
1875 utilities.assert_equals( expect=main.TRUE,
1876 actual=testResult,
1877 onpass=main.assertReturnString,
1878 onfail=main.assertReturnString )
1879
1880 main.step( "VLAN: Add single point to multi point intents" )
1881 main.assertReturnString = "Assertion results for IPV4 single to multi point\
1882 intent endpoint failure with IPV4 type and MAC addresses in the same VLAN\n"
1883 senders = [
1884 { "name":"h4", "device":"of:0000000000000005/4", "mac":"00:00:00:00:00:04" }
1885 ]
1886 recipients = [
1887 { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C" },
1888 { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14" }
1889 ]
1890 isolatedSenders = []
1891 isolatedRecipients = [
1892 { "name":"h20" }
1893 ]
1894 testResult = main.FALSE
1895 installResult = main.intentFunction.installSingleToMultiIntent(
1896 main,
1897 name="IPV4",
1898 senders=senders,
1899 recipients=recipients,
1900 ethType="IPV4",
1901 sw1="s5",
1902 sw2="s2")
1903
1904 if installResult:
1905 testResult = main.intentFunction.testEndPointFail(
1906 main,
1907 intentId=installResult,
1908 name="IPV4",
1909 senders=senders,
1910 recipients=recipients,
1911 isolatedSenders=isolatedSenders,
1912 isolatedRecipients=isolatedRecipients,
1913 sw1="s6",
1914 sw2="s2",
1915 sw3="s4",
1916 sw4="s1",
1917 sw5="s3",
1918 expectedLink1=16,
1919 expectedLink2=14 )
1920
1921 utilities.assert_equals( expect=main.TRUE,
1922 actual=testResult,
1923 onpass=main.assertReturnString,
1924 onfail=main.assertReturnString )
1925
Jeremy2f190ca2016-01-29 15:23:57 -08001926 main.intentFunction.report( main )