blob: ac72b6b585bffc541cd0aa3f5112b1cb05d3f4c3 [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 ] )
Jeremycd872222016-03-29 10:08:34 -0700137 main.flowCompiler = "Flow Rules"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700138
139 main.case( "Starting up " + str( main.numCtrls ) +
140 " node(s) ONOS cluster" )
Jon Hall783bbf92015-07-23 14:33:19 -0700141 main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700142 " node(s) ONOS cluster"
143
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700144 #kill off all onos processes
145 main.log.info( "Safety check, killing all ONOS processes" +
Jon Hall70b2ff42015-11-17 15:49:44 -0800146 " before initiating environment setup" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700147
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800148 time.sleep( main.startUpSleep )
149 main.step( "Uninstalling ONOS package" )
150 onosUninstallResult = main.TRUE
151 for ip in main.ONOSip:
152 onosUninstallResult = onosUninstallResult and \
153 main.ONOSbench.onosUninstall( nodeIp=ip )
154 stepResult = onosUninstallResult
155 utilities.assert_equals( expect=main.TRUE,
156 actual=stepResult,
157 onpass="Successfully uninstalled ONOS package",
158 onfail="Failed to uninstall ONOS package" )
Jeremy42df2e72016-02-23 16:37:46 -0800159 time.sleep( main.startUpSleep )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800160
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 """
Jeremy42df2e72016-02-23 16:37:46 -0800543 Balance Masters
544 """
545 main.case( "Balance mastership of switches" )
546 main.step( "Balancing mastership of switches" )
547
548 balanceResult = main.FALSE
549 balanceResult = utilities.retry( f=main.CLIs[ 0 ].balanceMasters, retValue=main.FALSE, args=[] )
550
551 utilities.assert_equals( expect=main.TRUE,
Jeremy6e9748f2016-03-25 15:03:39 -0700552 actual=balanceResult,
Jeremy42df2e72016-02-23 16:37:46 -0800553 onpass="Successfully balanced mastership of switches",
554 onfail="Failed to balance mastership of switches" )
555
556 def CASE17( self, main ):
557 """
Jeremy6e9748f2016-03-25 15:03:39 -0700558 Use Flow Objectives
559 """
560 main.case( "Enable intent compilation using Flow Objectives" )
561 main.step( "Enabling Flow Objectives" )
562
563 main.flowCompiler = "Flow Objectives"
564
565 cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator"
566
567 stepResult = main.CLIs[ 0 ].setCfg( component=cmd,
568 propName="useFlowObjectives", value="true" )
569
570 utilities.assert_equals( expect=main.TRUE,
571 actual=stepResult,
572 onpass="Successfully activated Flow Objectives",
573 onfail="Failed to activate Flow Objectives" )
574
575 def CASE18( self, main ):
576 """
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800577 Stop mininet and remove scapy host
578 """
579 main.log.report( "Stop Mininet and Scapy" )
580 main.case( "Stop Mininet and Scapy" )
581 main.caseExplanation = "Stopping the current mininet topology " +\
582 "to start up fresh"
583 main.step( "Stopping and Removing Scapy Host Components" )
584 scapyResult = main.TRUE
585 for host in main.scapyHosts:
586 scapyResult = scapyResult and host.stopScapy()
587 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
588
589 for host in main.scapyHosts:
590 scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
591 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
592
593 main.scapyHosts = []
594 main.scapyHostIPs = []
595
596 utilities.assert_equals( expect=main.TRUE,
597 actual=scapyResult,
598 onpass="Successfully stopped scapy and removed host components",
599 onfail="Failed to stop mininet and scapy" )
600
601 main.step( "Stopping Mininet Topology" )
602 mininetResult = main.Mininet1.stopNet( )
603
604 utilities.assert_equals( expect=main.TRUE,
605 actual=mininetResult,
606 onpass="Successfully stopped mininet and scapy",
607 onfail="Failed to stop mininet and scapy" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700608 # Exit if topology did not load properly
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800609 if not ( mininetResult and scapyResult ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700610 main.cleanup()
611 main.exit()
612
kelvin-onlabb769f562015-07-15 17:05:10 -0700613 def CASE1000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700614 """
615 Add host intents between 2 host:
616 - Discover hosts
617 - Add host intents
618 - Check intents
619 - Verify flows
620 - Ping hosts
621 - Reroute
622 - Link down
623 - Verify flows
624 - Check topology
625 - Ping hosts
626 - Link up
627 - Verify flows
628 - Check topology
629 - Ping hosts
630 - Remove intents
631 """
632 import time
633 import json
634 import re
635
636 # Assert variables - These variable's name|format must be followed
637 # if you want to use the wrapper function
638 assert main, "There is no main"
639 assert main.CLIs, "There is no main.CLIs"
640 assert main.Mininet1, "Mininet handle should be named Mininet1"
641 assert main.numSwitch, "Placed the total number of switch topology in \
642 main.numSwitch"
643
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800644 # Save leader candidates
acsmarse6b410f2015-07-17 14:39:34 -0700645 intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
646
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700647 main.testName = "Host Intents"
648 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -0700649 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -0700650 main.caseExplanation = "This test case tests Host intents using " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700651 str( main.numCtrls ) + " node(s) cluster;\n" +\
652 "Different type of hosts will be tested in " +\
653 "each step such as IPV4, Dual stack, VLAN " +\
654 "etc;\nThe test will use OF " + main.OFProtocol\
Jeremy6e9748f2016-03-25 15:03:39 -0700655 + " OVS running in Mininet and compile intents" +\
656 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700657
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700658 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700659 main.assertReturnString = "Assertion Result for IPV4 host intent with mac addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800660 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
661 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
662 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800663 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800664 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700665 name='IPV4',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800666 onosNode='0',
667 host1=host1,
668 host2=host2)
669 if installResult:
670 testResult = main.intentFunction.testHostIntent( main,
671 name='IPV4',
672 intentId = installResult,
673 onosNode='0',
674 host1=host1,
675 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700676 sw1='s5',
677 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800678 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800679 else:
680 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800681
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700682 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800683 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700684 onpass=main.assertReturnString,
685 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700686
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700687 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700688 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800689 host1 = { "name":"h3","id":"00:00:00:00:00:03/-1" }
690 host2 = { "name":"h11","id":"00:00:00:00:00:0B/-1 "}
691 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800692 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800693 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700694 name='DUALSTACK',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800695 onosNode='0',
696 host1=host1,
697 host2=host2)
698
699 if installResult:
700 testResult = main.intentFunction.testHostIntent( main,
701 name='DUALSTACK',
702 intentId = installResult,
703 onosNode='0',
704 host1=host1,
705 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700706 sw1='s5',
707 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800708 expectedLink = 18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700709
710 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800711 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700712 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800713 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700714
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700715 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700716 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800717 host1 = { "name":"h1" }
718 host2 = { "name":"h11" }
719 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800720 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800721 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700722 name='DUALSTACK2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800723 onosNode='0',
724 host1=host1,
725 host2=host2)
726
727 if installResult:
728 testResult = main.intentFunction.testHostIntent( main,
729 name='DUALSTACK2',
730 intentId = installResult,
731 onosNode='0',
732 host1=host1,
733 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700734 sw1='s5',
735 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800736 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800737 else:
738 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700739
740 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800741 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700742 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800743 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700744
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700745 main.step( "1HOP: Add host intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -0700746 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800747 host1 = { "name":"h1" }
748 host2 = { "name":"h3" }
749 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800750 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800751 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700752 name='1HOP',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800753 onosNode='0',
754 host1=host1,
755 host2=host2)
756
757 if installResult:
758 testResult = main.intentFunction.testHostIntent( main,
759 name='1HOP',
760 intentId = installResult,
761 onosNode='0',
762 host1=host1,
763 host2=host2,
764 sw1='s5',
765 sw2='s2',
766 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800767 else:
768 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700769
770 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800771 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700772 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800773 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700774
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700775 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
acsmars5d8cc862015-09-25 09:44:50 -0700776 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800777 host1 = { "name":"h4","id":"00:00:00:00:00:04/100" }
778 host2 = { "name":"h12","id":"00:00:00:00:00:0C/100 "}
779 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800780 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800781 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700782 name='VLAN1',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800783 onosNode='0',
784 host1=host1,
785 host2=host2)
786
787 if installResult:
788 testResult = main.intentFunction.testHostIntent( main,
789 name='VLAN1',
790 intentId = installResult,
791 onosNode='0',
792 host1=host1,
793 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700794 sw1='s5',
795 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800796 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800797 else:
798 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700799
800 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800801 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700802 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800803 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700804
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700805 main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
acsmars5d8cc862015-09-25 09:44:50 -0700806 main.assertReturnString = "Assertion Result different VLAN negative test\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800807 host1 = { "name":"h13" }
808 host2 = { "name":"h20" }
809 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800810 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800811 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700812 name='VLAN2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800813 onosNode='0',
814 host1=host1,
815 host2=host2)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700816
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800817 if installResult:
818 testResult = main.intentFunction.testHostIntent( main,
819 name='VLAN2',
820 intentId = installResult,
821 onosNode='0',
822 host1=host1,
823 host2=host2,
824 sw1='s5',
825 sw2='s2',
826 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800827 else:
828 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800829
830 utilities.assert_equals( expect=main.TRUE,
831 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700832 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800833 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700834
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800835 main.step( "Confirm that ONOS leadership is unchanged")
acsmarse6b410f2015-07-17 14:39:34 -0700836 intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
837 main.intentFunction.checkLeaderChange( intentLeadersOld,
838 intentLeadersNew )
839
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800840 utilities.assert_equals( expect=main.TRUE,
841 actual=testResult,
842 onpass="ONOS Leaders Unchanged",
843 onfail="ONOS Leader Mismatch")
844
kelvin-onlab016dce22015-08-10 09:54:11 -0700845 main.intentFunction.report( main )
846
kelvin-onlabb769f562015-07-15 17:05:10 -0700847 def CASE2000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700848 """
849 Add point intents between 2 hosts:
850 - Get device ids | ports
851 - Add point intents
852 - Check intents
853 - Verify flows
854 - Ping hosts
855 - Reroute
856 - Link down
857 - Verify flows
858 - Check topology
859 - Ping hosts
860 - Link up
861 - Verify flows
862 - Check topology
863 - Ping hosts
864 - Remove intents
865 """
866 import time
867 import json
868 import re
869
870 # Assert variables - These variable's name|format must be followed
871 # if you want to use the wrapper function
872 assert main, "There is no main"
873 assert main.CLIs, "There is no main.CLIs"
874 assert main.Mininet1, "Mininet handle should be named Mininet1"
875 assert main.numSwitch, "Placed the total number of switch topology in \
876 main.numSwitch"
877
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700878 main.testName = "Point Intents"
879 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -0700880 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -0700881 main.caseExplanation = "This test case will test point to point" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700882 " intents using " + str( main.numCtrls ) +\
883 " node(s) cluster;\n" +\
884 "Different type of hosts will be tested in " +\
885 "each step such as IPV4, Dual stack, VLAN etc" +\
886 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -0700887 " OVS running in Mininet and compile intents" +\
888 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700889
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700890 # No option point intents
891 main.step( "NOOPTION: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700892 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800893 senders = [
894 { "name":"h1","device":"of:0000000000000005/1" }
895 ]
896 recipients = [
897 { "name":"h9","device":"of:0000000000000006/1" }
898 ]
Jeremy42df2e72016-02-23 16:37:46 -0800899 testResult = main.FALSE
900 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800901 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700902 main,
903 name="NOOPTION",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800904 senders=senders,
905 recipients=recipients )
906
907 if installResult:
908 testResult = main.intentFunction.testPointIntent(
909 main,
910 intentId=installResult,
911 name="NOOPTION",
912 senders=senders,
913 recipients=recipients,
914 sw1="s5",
915 sw2="s2",
916 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -0800917 else:
918 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700919
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700920 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800921 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700922 onpass=main.assertReturnString,
923 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700924
925 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -0700926 main.step( "IPV4: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700927 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800928 senders = [
929 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
930 ]
931 recipients = [
932 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09" }
933 ]
Jeremy42df2e72016-02-23 16:37:46 -0800934 testResult = main.FALSE
935 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800936 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700937 main,
938 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800939 senders=senders,
940 recipients=recipients,
941 ethType="IPV4" )
942
943 if installResult:
944 testResult = main.intentFunction.testPointIntent(
945 main,
946 intentId=installResult,
947 name="IPV4",
948 senders=senders,
949 recipients=recipients,
950 sw1="s5",
951 sw2="s2",
952 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -0800953 else:
954 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700955
956 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800957 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700958 onpass=main.assertReturnString,
959 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -0700960 main.step( "IPV4_2: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700961 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800962 senders = [
963 { "name":"h1","device":"of:0000000000000005/1" }
964 ]
965 recipients = [
966 { "name":"h9","device":"of:0000000000000006/1" }
967 ]
Jeremy42df2e72016-02-23 16:37:46 -0800968 testResult = main.FALSE
969 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800970 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700971 main,
972 name="IPV4_2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800973 senders=senders,
974 recipients=recipients,
975 ethType="IPV4" )
976
977 if installResult:
978 testResult = main.intentFunction.testPointIntent(
979 main,
980 intentId=installResult,
981 name="IPV4_2",
982 senders=senders,
983 recipients=recipients,
984 sw1="s5",
985 sw2="s2",
986 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -0800987 else:
988 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700989
990 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800991 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700992 onpass=main.assertReturnString,
993 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700994
kelvin-onlabb55e58e2015-08-04 00:13:48 -0700995 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700996 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800997 senders = [
998 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01",
999 "ip":main.h1.hostIp }
1000 ]
1001 recipients = [
1002 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09",
1003 "ip":main.h9.hostIp }
1004 ]
kelvin-onlabb769f562015-07-15 17:05:10 -07001005 ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
kelvin-onlab79ce0492015-07-27 16:14:39 -07001006 # Uneccessary, not including this in the selectors
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001007 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
1008 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
Jeremy42df2e72016-02-23 16:37:46 -08001009 testResult = main.FALSE
1010 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001011 installResult = main.intentFunction.installPointIntent(
1012 main,
1013 name="SDNIP-ICMP",
1014 senders=senders,
1015 recipients=recipients,
1016 ethType="IPV4",
1017 ipProto=ipProto,
1018 tcpSrc=tcpSrc,
1019 tcpDst=tcpDst )
1020
1021 if installResult:
1022 testResult = main.intentFunction.testPointIntent(
1023 main,
1024 intentId=installResult,
1025 name="SDNIP_ICMP",
1026 senders=senders,
1027 recipients=recipients,
1028 sw1="s5",
1029 sw2="s2",
1030 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001031 else:
1032 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabb769f562015-07-15 17:05:10 -07001033
1034 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001035 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001036 onpass=main.assertReturnString,
1037 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001038
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001039 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001040 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
kelvin-onlabb769f562015-07-15 17:05:10 -07001041 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
1042 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab58dc39e2015-08-06 08:11:09 -07001043 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
1044 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlabb769f562015-07-15 17:05:10 -07001045 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
1046 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
1047 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
1048
kelvin-onlab58dc39e2015-08-06 08:11:09 -07001049 stepResult = main.intentFunction.pointIntentTcp(
kelvin-onlabb769f562015-07-15 17:05:10 -07001050 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001051 name="SDNIP-TCP",
kelvin-onlabb769f562015-07-15 17:05:10 -07001052 host1="h1",
1053 host2="h9",
1054 deviceId1="of:0000000000000005/1",
1055 deviceId2="of:0000000000000006/1",
1056 mac1=mac1,
1057 mac2=mac2,
1058 ethType="IPV4",
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001059 ipProto=ipProto,
1060 ip1=ip1,
1061 ip2=ip2,
1062 tcp1=tcp1,
1063 tcp2=tcp2 )
kelvin-onlabb769f562015-07-15 17:05:10 -07001064
1065 utilities.assert_equals( expect=main.TRUE,
1066 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -07001067 onpass=main.assertReturnString,
1068 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001069
acsmars5d8cc862015-09-25 09:44:50 -07001070 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
1071 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001072 senders = [
1073 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1074 ]
1075 recipients = [
1076 { "name":"h11","device":"of:0000000000000006/3","mac":"00:00:00:00:00:0B" }
1077 ]
Jeremy42df2e72016-02-23 16:37:46 -08001078 testResult = main.FALSE
1079 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001080 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001081 main,
1082 name="DUALSTACK1",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001083 senders=senders,
1084 recipients=recipients,
1085 ethType="IPV4" )
1086
1087 if installResult:
1088 testResult = main.intentFunction.testPointIntent(
1089 main,
1090 intentId=installResult,
1091 name="DUALSTACK1",
1092 senders=senders,
1093 recipients=recipients,
1094 sw1="s5",
1095 sw2="s2",
1096 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001097 else:
1098 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001099
1100 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001101 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001102 onpass=main.assertReturnString,
1103 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001104
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001105 main.step( "VLAN: Add point intents between h5 and h21" )
acsmars5d8cc862015-09-25 09:44:50 -07001106 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001107 senders = [
1108 { "name":"h5","device":"of:0000000000000005/5","mac":"00:00:00:00:00:05" }
1109 ]
1110 recipients = [
1111 { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15" }
1112 ]
Jeremy42df2e72016-02-23 16:37:46 -08001113 testResult = main.FALSE
1114 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001115 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001116 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001117 name="DUALSTACK1",
1118 senders=senders,
1119 recipients=recipients,
1120 ethType="IPV4" )
1121
1122 if installResult:
1123 testResult = main.intentFunction.testPointIntent(
1124 main,
1125 intentId=installResult,
1126 name="DUALSTACK1",
1127 senders=senders,
1128 recipients=recipients,
1129 sw1="s5",
1130 sw2="s2",
1131 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001132
1133 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001134 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001135 onpass=main.assertReturnString,
1136 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001137
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001138 main.step( "1HOP: Add point intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -07001139 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001140 senders = [
1141 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1142 ]
1143 recipients = [
1144 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1145 ]
Jeremy42df2e72016-02-23 16:37:46 -08001146 testResult = main.FALSE
1147 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001148 installResult = main.intentFunction.installPointIntent(
1149 main,
1150 name="1HOP IPV4",
1151 senders=senders,
1152 recipients=recipients,
1153 ethType="IPV4" )
1154
1155 if installResult:
1156 testResult = main.intentFunction.testPointIntent(
1157 main,
1158 intentId=installResult,
1159 name="1HOP IPV4",
1160 senders=senders,
1161 recipients=recipients,
1162 sw1="s5",
1163 sw2="s2",
1164 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001165 else:
1166 main.CLIs[ 0 ].removeAllIntents( purge=True )
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,
acsmars5d8cc862015-09-25 09:44:50 -07001170 onpass=main.assertReturnString,
1171 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001172
kelvin-onlab016dce22015-08-10 09:54:11 -07001173 main.intentFunction.report( main )
1174
kelvin-onlabb769f562015-07-15 17:05:10 -07001175 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001176 """
1177 Add single point to multi point intents
1178 - Get device ids
1179 - Add single point to multi point intents
1180 - Check intents
1181 - Verify flows
1182 - Ping hosts
1183 - Reroute
1184 - Link down
1185 - Verify flows
1186 - Check topology
1187 - Ping hosts
1188 - Link up
1189 - Verify flows
1190 - Check topology
1191 - Ping hosts
1192 - Remove intents
1193 """
1194 assert main, "There is no main"
1195 assert main.CLIs, "There is no main.CLIs"
1196 assert main.Mininet1, "Mininet handle should be named Mininet1"
1197 assert main.numSwitch, "Placed the total number of switch topology in \
1198 main.numSwitch"
1199
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001200 main.testName = "Single to Multi Point Intents"
1201 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001202 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001203 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001204 " multi point intents using " +\
1205 str( main.numCtrls ) + " node(s) cluster;\n" +\
1206 "Different type of hosts will be tested in " +\
1207 "each step such as IPV4, Dual stack, VLAN etc" +\
1208 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001209 " OVS running in Mininet and compile intents" +\
1210 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001211
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001212 main.step( "NOOPTION: Install and test single point to multi point intents" )
1213 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
1214 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
Jeremy42df2e72016-02-23 16:37:46 -08001224 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001225 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001226 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001227 name="NOOPTION",
1228 senders=senders,
1229 recipients=recipients,
1230 sw1="s5",
1231 sw2="s2")
1232
1233 if installResult:
1234 testResult = main.intentFunction.testPointIntent(
1235 main,
1236 intentId=installResult,
1237 name="NOOPTION",
1238 senders=senders,
1239 recipients=recipients,
1240 badSenders=badSenders,
1241 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001242 sw1="s5",
1243 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001244 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001245 else:
1246 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001247
1248 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001249 actual=testResult,
1250 onpass=main.assertReturnString,
1251 onfail=main.assertReturnString )
1252
1253 main.step( "IPV4: Install and test single point to multi point intents" )
1254 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses\n"
1255 senders = [
1256 { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" }
1257 ]
1258 recipients = [
1259 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1260 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1261 ]
1262 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1263 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1264 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001265 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001266 installResult = main.intentFunction.installSingleToMultiIntent(
1267 main,
1268 name="IPV4",
1269 senders=senders,
1270 recipients=recipients,
1271 ethType="IPV4",
1272 sw1="s5",
1273 sw2="s2")
1274
1275 if installResult:
1276 testResult = main.intentFunction.testPointIntent(
1277 main,
1278 intentId=installResult,
1279 name="IPV4",
1280 senders=senders,
1281 recipients=recipients,
1282 badSenders=badSenders,
1283 badRecipients=badRecipients,
1284 sw1="s5",
1285 sw2="s2",
1286 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001287 else:
1288 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001289
1290 utilities.assert_equals( expect=main.TRUE,
1291 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001292 onpass=main.assertReturnString,
1293 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001294
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001295 main.step( "IPV4_2: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001296 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 -08001297 senders = [
1298 { "name":"h8", "device":"of:0000000000000005/8" }
1299 ]
1300 recipients = [
1301 { "name":"h16", "device":"of:0000000000000006/8" },
1302 { "name":"h24", "device":"of:0000000000000007/8" }
1303 ]
1304 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1305 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1306 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001307 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001308 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001309 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001310 name="IPV4_2",
1311 senders=senders,
1312 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001313 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001314 sw1="s5",
1315 sw2="s2")
1316
1317 if installResult:
1318 testResult = main.intentFunction.testPointIntent(
1319 main,
1320 intentId=installResult,
1321 name="IPV4_2",
1322 senders=senders,
1323 recipients=recipients,
1324 badSenders=badSenders,
1325 badRecipients=badRecipients,
1326 sw1="s5",
1327 sw2="s2",
1328 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001329 else:
1330 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001331
1332 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001333 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001334 onpass=main.assertReturnString,
1335 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001336
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001337 main.step( "VLAN: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001338 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 -08001339 senders = [
1340 { "name":"h4", "device":"of:0000000000000005/4", "mac":"00:00:00:00:00:04" }
1341 ]
1342 recipients = [
1343 { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C" },
1344 { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14" }
1345 ]
1346 badSenders=[ { "name":"h13" } ] # Senders that are not in the intent
1347 badRecipients=[ { "name":"h21" } ] # Recipients that are not in the intent
1348 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001349 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001350 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001351 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001352 name="IPV4",
1353 senders=senders,
1354 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001355 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001356 sw1="s5",
1357 sw2="s2")
1358
1359 if installResult:
1360 testResult = main.intentFunction.testPointIntent(
1361 main,
1362 intentId=installResult,
1363 name="IPV4",
1364 senders=senders,
1365 recipients=recipients,
1366 badSenders=badSenders,
1367 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001368 sw1="s5",
1369 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001370 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001371 else:
1372 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001373
1374 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001375 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001376 onpass=main.assertReturnString,
1377 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001378
kelvin-onlab016dce22015-08-10 09:54:11 -07001379 main.intentFunction.report( main )
1380
kelvin-onlabb769f562015-07-15 17:05:10 -07001381 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001382 """
1383 Add multi point to single point intents
1384 - Get device ids
1385 - Add multi point to single point intents
1386 - Check intents
1387 - Verify flows
1388 - Ping hosts
1389 - Reroute
1390 - Link down
1391 - Verify flows
1392 - Check topology
1393 - Ping hosts
1394 - Link up
1395 - Verify flows
1396 - Check topology
1397 - Ping hosts
1398 - Remove intents
1399 """
1400 assert main, "There is no main"
1401 assert main.CLIs, "There is no main.CLIs"
1402 assert main.Mininet1, "Mininet handle should be named Mininet1"
1403 assert main.numSwitch, "Placed the total number of switch topology in \
1404 main.numSwitch"
1405
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001406 main.testName = "Multi To Single Point Intents"
1407 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001408 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001409 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001410 " multi point intents using " +\
1411 str( main.numCtrls ) + " node(s) cluster;\n" +\
1412 "Different type of hosts will be tested in " +\
1413 "each step such as IPV4, Dual stack, VLAN etc" +\
1414 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001415 " OVS running in Mininet and compile intents" +\
1416 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001417
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001418 main.step( "NOOPTION: Add multi point to single point intents" )
1419 main.assertReturnString = "Assertion results for NOOPTION multi to single point intent\n"
1420 senders = [
1421 { "name":"h16", "device":"of:0000000000000006/8" },
1422 { "name":"h24", "device":"of:0000000000000007/8" }
1423 ]
1424 recipients = [
1425 { "name":"h8", "device":"of:0000000000000005/8" }
1426 ]
1427 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1428 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1429 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001430 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001431 installResult = main.intentFunction.installMultiToSingleIntent(
1432 main,
1433 name="NOOPTION",
1434 senders=senders,
1435 recipients=recipients,
1436 sw1="s5",
Jeremye0cb5eb2016-01-27 17:39:09 -08001437 sw2="s2" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001438
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001439 if installResult:
1440 testResult = main.intentFunction.testPointIntent(
1441 main,
1442 intentId=installResult,
1443 name="NOOPTION",
1444 senders=senders,
1445 recipients=recipients,
1446 badSenders=badSenders,
1447 badRecipients=badRecipients,
1448 sw1="s5",
1449 sw2="s2",
Jeremye0cb5eb2016-01-27 17:39:09 -08001450 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001451 else:
1452 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001453
1454 utilities.assert_equals( expect=main.TRUE,
1455 actual=testResult,
1456 onpass=main.assertReturnString,
1457 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001458
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001459 main.step( "IPV4: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001460 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 -08001461 senders = [
1462 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1463 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1464 ]
1465 recipients = [
1466 { "name":"h8", "device":"of:0000000000000005/8", "mac":"00:00:00:00:00:08" }
1467 ]
1468 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1469 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1470 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001471 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001472 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001473 main,
1474 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001475 senders=senders,
1476 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001477 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001478 sw1="s5",
1479 sw2="s2")
1480
1481 if installResult:
1482 testResult = main.intentFunction.testPointIntent(
1483 main,
1484 intentId=installResult,
1485 name="IPV4",
1486 senders=senders,
1487 recipients=recipients,
1488 badSenders=badSenders,
1489 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001490 sw1="s5",
1491 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001492 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001493 else:
1494 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001495
1496 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001497 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001498 onpass=main.assertReturnString,
1499 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001500
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001501 main.step( "IPV4_2: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001502 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 -08001503 senders = [
1504 { "name":"h16", "device":"of:0000000000000006/8" },
1505 { "name":"h24", "device":"of:0000000000000007/8" }
1506 ]
1507 recipients = [
1508 { "name":"h8", "device":"of:0000000000000005/8" }
1509 ]
1510 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1511 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1512 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001513 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001514 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001515 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001516 name="IPV4_2",
1517 senders=senders,
1518 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001519 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001520 sw1="s5",
1521 sw2="s2")
1522
1523 if installResult:
1524 testResult = main.intentFunction.testPointIntent(
1525 main,
1526 intentId=installResult,
1527 name="IPV4_2",
1528 senders=senders,
1529 recipients=recipients,
1530 badSenders=badSenders,
1531 badRecipients=badRecipients,
1532 sw1="s5",
1533 sw2="s2",
1534 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001535 else:
1536 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001537
1538 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001539 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001540 onpass=main.assertReturnString,
1541 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001542
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001543 main.step( "VLAN: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001544 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 -08001545 senders = [
1546 { "name":"h13", "device":"of:0000000000000006/5" },
1547 { "name":"h21", "device":"of:0000000000000007/5" }
1548 ]
1549 recipients = [
1550 { "name":"h5", "device":"of:0000000000000005/5" }
1551 ]
1552 badSenders=[ { "name":"h12" } ] # Senders that are not in the intent
1553 badRecipients=[ { "name":"h20" } ] # Recipients that are not in the intent
1554 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001555 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001556 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001557 main,
1558 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001559 senders=senders,
1560 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001561 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001562 sw1="s5",
1563 sw2="s2")
1564
1565 if installResult:
1566 testResult = main.intentFunction.testPointIntent(
1567 main,
1568 intentId=installResult,
1569 name="VLAN",
1570 senders=senders,
1571 recipients=recipients,
1572 badSenders=badSenders,
1573 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001574 sw1="s5",
1575 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001576 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001577 else:
1578 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001579
1580 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001581 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001582 onpass=main.assertReturnString,
1583 onfail=main.assertReturnString )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001584
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001585 main.intentFunction.report( main )
1586
acsmars1ff5e052015-07-23 11:27:48 -07001587 def CASE5000( self, main ):
1588 """
acsmars5d8cc862015-09-25 09:44:50 -07001589 Tests Host Mobility
1590 Modifies the topology location of h1
acsmars1ff5e052015-07-23 11:27:48 -07001591 """
1592 assert main, "There is no main"
1593 assert main.CLIs, "There is no main.CLIs"
1594 assert main.Mininet1, "Mininet handle should be named Mininet1"
1595 assert main.numSwitch, "Placed the total number of switch topology in \
1596 main.numSwitch"
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001597 main.case( "Test host mobility with host intents " )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001598 main.step( "Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07001599 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1600
Jeremy2f190ca2016-01-29 15:23:57 -08001601 main.log.info( "Moving h1 from s5 to s6")
acsmars1ff5e052015-07-23 11:27:48 -07001602 main.Mininet1.moveHost( "h1","s5","s6" )
1603
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001604 # Send discovery ping from moved host
1605 # Moving the host brings down the default interfaces and creates a new one.
1606 # Scapy is restarted on this host to detect the new interface
1607 main.h1.stopScapy()
1608 main.h1.startScapy()
1609
1610 # Discover new host location in ONOS and populate host data.
1611 # Host 1 IP and MAC should be unchanged
1612 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
1613 main.intentFunction.populateHostData( main )
1614
acsmars1ff5e052015-07-23 11:27:48 -07001615 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1616
1617 utilities.assert_equals( expect="of:0000000000000006",
1618 actual=h1PostMove,
1619 onpass="Mobility: Successfully moved h1 to s6",
acsmars5d8cc862015-09-25 09:44:50 -07001620 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001621 " to single point intents" +
1622 " with IPV4 type and MAC addresses" +
1623 " in the same VLAN" )
1624
1625 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001626 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001627 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
1628 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
Jeremy42df2e72016-02-23 16:37:46 -08001629 testResult = main.FALSE
1630 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001631 installResult = main.intentFunction.installHostIntent( main,
1632 name='IPV4 Mobility IPV4',
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001633 onosNode='0',
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001634 host1=host1,
Jeremye0cb5eb2016-01-27 17:39:09 -08001635 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -08001636 if installResult:
1637 testResult = main.intentFunction.testHostIntent( main,
1638 name='Host Mobility IPV4',
1639 intentId = installResult,
1640 onosNode='0',
1641 host1=host1,
1642 host2=host2,
1643 sw1="s6",
1644 sw2="s2",
1645 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001646 else:
1647 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001648
1649 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001650 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001651 onpass=main.assertReturnString,
1652 onfail=main.assertReturnString )
kelvin-onlab016dce22015-08-10 09:54:11 -07001653
1654 main.intentFunction.report( main )
Jeremye0cb5eb2016-01-27 17:39:09 -08001655
1656 def CASE6000( self, main ):
1657 """
1658 Tests Multi to Single Point Intent and Single to Multi Point Intent End Point Failure
1659 """
1660 assert main, "There is no main"
1661 assert main.CLIs, "There is no main.CLIs"
1662 assert main.Mininet1, "Mininet handle should be named Mininet1"
1663 assert main.numSwitch, "Placed the total number of switch topology in \
1664 main.numSwitch"
1665 main.case( "Test Multi to Single End Point Failure" )
1666 main.step( "Installing Multi to Single Point intents" )
1667
1668 main.assertReturnString = "Assertion results for IPV4 multi to single \
1669 point intent end point failure with no options set\n"
1670 senders = [
1671 { "name":"h16", "device":"of:0000000000000006/8" },
1672 { "name":"h24", "device":"of:0000000000000007/8" }
1673 ]
1674 recipients = [
1675 { "name":"h8", "device":"of:0000000000000005/8" }
1676 ]
1677 isolatedSenders = [
1678 { "name":"h24"}
1679 ]
1680 isolatedRecipients = []
1681 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001682 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08001683 installResult = main.intentFunction.installMultiToSingleIntent(
1684 main,
1685 name="NOOPTION",
1686 senders=senders,
1687 recipients=recipients,
1688 sw1="s5",
1689 sw2="s2" )
1690
1691 if installResult:
1692 testResult = main.intentFunction.testEndPointFail(
1693 main,
1694 intentId=installResult,
1695 name="NOOPTION",
1696 senders=senders,
1697 recipients=recipients,
1698 isolatedSenders=isolatedSenders,
1699 isolatedRecipients=isolatedRecipients,
1700 sw1="s6",
1701 sw2="s2",
1702 sw3="s4",
1703 sw4="s1",
1704 sw5="s3",
1705 expectedLink1=16,
1706 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08001707 else:
1708 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08001709
1710 utilities.assert_equals( expect=main.TRUE,
1711 actual=testResult,
1712 onpass=main.assertReturnString,
1713 onfail=main.assertReturnString )
1714
1715 main.step( "IPV4: Add multi point to single point intents" )
1716 main.assertReturnString = "Assertion results for IPV4 multi to single \
1717 point intent end point failure with IPV4 type and MAC addresses\n"
1718 senders = [
1719 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1720 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1721 ]
1722 recipients = [
1723 { "name":"h8", "device":"of:0000000000000005/8", "mac":"00:00:00:00:00:08" }
1724 ]
1725 isolatedSenders = [
1726 { "name":"h24"}
1727 ]
1728 isolatedRecipients = []
1729 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001730 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08001731 installResult = main.intentFunction.installMultiToSingleIntent(
1732 main,
1733 name="IPV4",
1734 senders=senders,
1735 recipients=recipients,
1736 ethType="IPV4",
1737 sw1="s5",
1738 sw2="s2")
1739
1740 if installResult:
1741 testResult = main.intentFunction.testEndPointFail(
1742 main,
1743 intentId=installResult,
1744 name="IPV4",
1745 senders=senders,
1746 recipients=recipients,
1747 isolatedSenders=isolatedSenders,
1748 isolatedRecipients=isolatedRecipients,
1749 sw1="s6",
1750 sw2="s2",
1751 sw3="s4",
1752 sw4="s1",
1753 sw5="s3",
1754 expectedLink1=16,
1755 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08001756 else:
1757 main.CLIs[ 0 ].removeAllIntents( purge=True )
1758
Jeremye0cb5eb2016-01-27 17:39:09 -08001759 utilities.assert_equals( expect=main.TRUE,
1760 actual=testResult,
1761 onpass=main.assertReturnString,
1762 onfail=main.assertReturnString )
1763
1764 main.step( "IPV4_2: Add multi point to single point intents" )
1765 main.assertReturnString = "Assertion results for IPV4 multi to single \
1766 point intent end point failure with IPV4 type and no MAC addresses\n"
1767 senders = [
1768 { "name":"h16", "device":"of:0000000000000006/8" },
1769 { "name":"h24", "device":"of:0000000000000007/8" }
1770 ]
1771 recipients = [
1772 { "name":"h8", "device":"of:0000000000000005/8" }
1773 ]
1774 isolatedSenders = [
1775 { "name":"h24"}
1776 ]
1777 isolatedRecipients = []
1778 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001779 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08001780 installResult = main.intentFunction.installMultiToSingleIntent(
1781 main,
1782 name="IPV4_2",
1783 senders=senders,
1784 recipients=recipients,
1785 ethType="IPV4",
1786 sw1="s5",
1787 sw2="s2")
1788
1789 if installResult:
1790 testResult = main.intentFunction.testEndPointFail(
1791 main,
1792 intentId=installResult,
1793 name="IPV4_2",
1794 senders=senders,
1795 recipients=recipients,
1796 isolatedSenders=isolatedSenders,
1797 isolatedRecipients=isolatedRecipients,
1798 sw1="s6",
1799 sw2="s2",
1800 sw3="s4",
1801 sw4="s1",
1802 sw5="s3",
1803 expectedLink1=16,
1804 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08001805 else:
1806 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08001807
1808 utilities.assert_equals( expect=main.TRUE,
1809 actual=testResult,
1810 onpass=main.assertReturnString,
1811 onfail=main.assertReturnString )
1812
1813 main.step( "VLAN: Add multi point to single point intents" )
1814 main.assertReturnString = "Assertion results for IPV4 multi to single \
1815 point intent end point failure with IPV4 type and no MAC addresses in the same VLAN\n"
1816 senders = [
1817 { "name":"h13", "device":"of:0000000000000006/5" },
1818 { "name":"h21", "device":"of:0000000000000007/5" }
1819 ]
1820 recipients = [
1821 { "name":"h5", "device":"of:0000000000000005/5" }
1822 ]
1823 isolatedSenders = [
1824 { "name":"h21"}
1825 ]
1826 isolatedRecipients = []
1827 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001828 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08001829 installResult = main.intentFunction.installMultiToSingleIntent(
1830 main,
1831 name="VLAN",
1832 senders=senders,
1833 recipients=recipients,
1834 ethType="IPV4",
1835 sw1="s5",
1836 sw2="s2")
1837
1838 if installResult:
1839 testResult = main.intentFunction.testEndPointFail(
1840 main,
1841 intentId=installResult,
1842 name="VLAN",
1843 senders=senders,
1844 recipients=recipients,
1845 isolatedSenders=isolatedSenders,
1846 isolatedRecipients=isolatedRecipients,
1847 sw1="s6",
1848 sw2="s2",
1849 sw3="s4",
1850 sw4="s1",
1851 sw5="s3",
1852 expectedLink1=16,
1853 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08001854 else:
1855 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08001856
1857 utilities.assert_equals( expect=main.TRUE,
1858 actual=testResult,
1859 onpass=main.assertReturnString,
1860 onfail=main.assertReturnString )
1861
1862 main.step( "NOOPTION: Install and test single point to multi point intents" )
1863 main.assertReturnString = "Assertion results for IPV4 single to multi \
1864 point intent end point failure with no options set\n"
1865 senders = [
1866 { "name":"h8", "device":"of:0000000000000005/8" }
1867 ]
1868 recipients = [
1869 { "name":"h16", "device":"of:0000000000000006/8" },
1870 { "name":"h24", "device":"of:0000000000000007/8" }
1871 ]
1872 isolatedSenders = []
1873 isolatedRecipients = [
1874 { "name":"h24" }
1875 ]
1876 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001877 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08001878 installResult = main.intentFunction.installSingleToMultiIntent(
1879 main,
1880 name="NOOPTION",
1881 senders=senders,
1882 recipients=recipients,
1883 sw1="s5",
1884 sw2="s2")
1885
1886 if installResult:
1887 testResult = main.intentFunction.testEndPointFail(
1888 main,
1889 intentId=installResult,
1890 name="NOOPTION",
1891 senders=senders,
1892 recipients=recipients,
1893 isolatedSenders=isolatedSenders,
1894 isolatedRecipients=isolatedRecipients,
1895 sw1="s6",
1896 sw2="s2",
1897 sw3="s4",
1898 sw4="s1",
1899 sw5="s3",
1900 expectedLink1=16,
1901 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08001902 else:
1903 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08001904
1905 utilities.assert_equals( expect=main.TRUE,
1906 actual=testResult,
1907 onpass=main.assertReturnString,
1908 onfail=main.assertReturnString )
1909
1910 main.step( "IPV4: Install and test single point to multi point intents" )
1911 main.assertReturnString = "Assertion results for IPV4 single to multi \
1912 point intent end point failure with IPV4 type and no MAC addresses\n"
1913 senders = [
1914 { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" }
1915 ]
1916 recipients = [
1917 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1918 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1919 ]
1920 isolatedSenders = []
1921 isolatedRecipients = [
1922 { "name":"h24" }
1923 ]
1924 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001925 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08001926 installResult = main.intentFunction.installSingleToMultiIntent(
1927 main,
1928 name="IPV4",
1929 senders=senders,
1930 recipients=recipients,
1931 ethType="IPV4",
1932 sw1="s5",
1933 sw2="s2")
1934
1935 if installResult:
1936 testResult = main.intentFunction.testEndPointFail(
1937 main,
1938 intentId=installResult,
1939 name="IPV4",
1940 senders=senders,
1941 recipients=recipients,
1942 isolatedSenders=isolatedSenders,
1943 isolatedRecipients=isolatedRecipients,
1944 sw1="s6",
1945 sw2="s2",
1946 sw3="s4",
1947 sw4="s1",
1948 sw5="s3",
1949 expectedLink1=16,
1950 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08001951 else:
1952 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08001953
1954 utilities.assert_equals( expect=main.TRUE,
1955 actual=testResult,
1956 onpass=main.assertReturnString,
1957 onfail=main.assertReturnString )
1958
1959 main.step( "IPV4_2: Add single point to multi point intents" )
1960 main.assertReturnString = "Assertion results for IPV4 single to multi\
1961 point intent endpoint failure with IPV4 type and no MAC addresses\n"
1962 senders = [
1963 { "name":"h8", "device":"of:0000000000000005/8" }
1964 ]
1965 recipients = [
1966 { "name":"h16", "device":"of:0000000000000006/8" },
1967 { "name":"h24", "device":"of:0000000000000007/8" }
1968 ]
1969 isolatedSenders = []
1970 isolatedRecipients = [
1971 { "name":"h24" }
1972 ]
1973 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001974 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08001975 installResult = main.intentFunction.installSingleToMultiIntent(
1976 main,
1977 name="IPV4_2",
1978 senders=senders,
1979 recipients=recipients,
1980 ethType="IPV4",
1981 sw1="s5",
1982 sw2="s2")
1983
1984 if installResult:
1985 testResult = main.intentFunction.testEndPointFail(
1986 main,
1987 intentId=installResult,
1988 name="IPV4_2",
1989 senders=senders,
1990 recipients=recipients,
1991 isolatedSenders=isolatedSenders,
1992 isolatedRecipients=isolatedRecipients,
1993 sw1="s6",
1994 sw2="s2",
1995 sw3="s4",
1996 sw4="s1",
1997 sw5="s3",
1998 expectedLink1=16,
1999 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002000 else:
2001 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002002
2003 utilities.assert_equals( expect=main.TRUE,
2004 actual=testResult,
2005 onpass=main.assertReturnString,
2006 onfail=main.assertReturnString )
2007
2008 main.step( "VLAN: Add single point to multi point intents" )
2009 main.assertReturnString = "Assertion results for IPV4 single to multi point\
2010 intent endpoint failure with IPV4 type and MAC addresses in the same VLAN\n"
2011 senders = [
2012 { "name":"h4", "device":"of:0000000000000005/4", "mac":"00:00:00:00:00:04" }
2013 ]
2014 recipients = [
2015 { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C" },
2016 { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14" }
2017 ]
2018 isolatedSenders = []
2019 isolatedRecipients = [
2020 { "name":"h20" }
2021 ]
2022 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08002023 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08002024 installResult = main.intentFunction.installSingleToMultiIntent(
2025 main,
2026 name="IPV4",
2027 senders=senders,
2028 recipients=recipients,
2029 ethType="IPV4",
2030 sw1="s5",
2031 sw2="s2")
2032
2033 if installResult:
2034 testResult = main.intentFunction.testEndPointFail(
2035 main,
2036 intentId=installResult,
2037 name="IPV4",
2038 senders=senders,
2039 recipients=recipients,
2040 isolatedSenders=isolatedSenders,
2041 isolatedRecipients=isolatedRecipients,
2042 sw1="s6",
2043 sw2="s2",
2044 sw3="s4",
2045 sw4="s1",
2046 sw5="s3",
2047 expectedLink1=16,
2048 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002049 else:
2050 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002051
2052 utilities.assert_equals( expect=main.TRUE,
2053 actual=testResult,
2054 onpass=main.assertReturnString,
2055 onfail=main.assertReturnString )
2056
Jeremy2f190ca2016-01-29 15:23:57 -08002057 main.intentFunction.report( main )