blob: 6b690d98af35342df191457d9734f55f116422ba [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' ] )
Jeremy Songster306ed7a2016-07-19 10:59:07 -070052 main.flowDurationSleep = int( main.params[ 'SLEEP' ][ 'flowDuration' ] )
Jon Halla3e02432015-07-24 15:55:42 -070053 gitPull = main.params[ 'GIT' ][ 'pull' ]
54 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
55 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
56 main.cellData = {} # for creating cell file
57 main.hostsData = {}
58 main.CLIs = []
59 main.ONOSip = []
Jeremy Songster1f39bf02016-01-20 17:17:25 -080060 main.scapyHostNames = main.params[ 'SCAPY' ][ 'HOSTNAMES' ].split( ',' )
61 main.scapyHosts = [] # List of scapy hosts for iterating
acsmars5d8cc862015-09-25 09:44:50 -070062 main.assertReturnString = '' # Assembled assert return string
Jeremy Songster17147f22016-05-31 18:30:52 -070063 main.cycle = 0 # How many times FUNCintent has run through its tests
kelvin-onlabd48a68c2015-07-13 16:01:36 -070064
Jon Halla3e02432015-07-24 15:55:42 -070065 main.ONOSip = main.ONOSbench.getOnosIps()
66 print main.ONOSip
kelvin-onlabd48a68c2015-07-13 16:01:36 -070067
Jon Halla3e02432015-07-24 15:55:42 -070068 # Assigning ONOS cli handles to a list
69 for i in range( 1, main.maxNodes + 1 ):
70 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070071
Jon Halla3e02432015-07-24 15:55:42 -070072 # -- INIT SECTION, ONLY RUNS ONCE -- #
73 main.startUp = imp.load_source( wrapperFile1,
74 main.dependencyPath +
75 wrapperFile1 +
76 ".py" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070077
Jon Halla3e02432015-07-24 15:55:42 -070078 main.intentFunction = imp.load_source( wrapperFile2,
79 main.dependencyPath +
80 wrapperFile2 +
81 ".py" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070082
Jon Halla3e02432015-07-24 15:55:42 -070083 main.topo = imp.load_source( wrapperFile3,
84 main.dependencyPath +
85 wrapperFile3 +
86 ".py" )
87
kelvin-onlabd9e23de2015-08-06 10:34:44 -070088 copyResult1 = main.ONOSbench.scp( main.Mininet1,
89 main.dependencyPath +
90 main.topology,
Jeremy Songster1f39bf02016-01-20 17:17:25 -080091 main.Mininet1.home + "custom/",
kelvin-onlabd9e23de2015-08-06 10:34:44 -070092 direction="to" )
Jon Halla3e02432015-07-24 15:55:42 -070093 if main.CLIs:
94 stepResult = main.TRUE
95 else:
96 main.log.error( "Did not properly created list of ONOS CLI handle" )
97 stepResult = main.FALSE
98 except Exception as e:
99 main.log.exception(e)
100 main.cleanup()
101 main.exit()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700102
103 utilities.assert_equals( expect=main.TRUE,
104 actual=stepResult,
105 onpass="Successfully construct " +
106 "test variables ",
107 onfail="Failed to construct test variables" )
108
109 if gitPull == 'True':
110 main.step( "Building ONOS in " + gitBranch + " branch" )
111 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
112 stepResult = onosBuildResult
113 utilities.assert_equals( expect=main.TRUE,
114 actual=stepResult,
115 onpass="Successfully compiled " +
116 "latest ONOS",
117 onfail="Failed to compile " +
118 "latest ONOS" )
119 else:
120 main.log.warn( "Did not pull new code so skipping mvn " +
121 "clean install" )
Jon Hall106be082015-07-22 09:53:00 -0700122 main.ONOSbench.getVersion( report=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700123
124 def CASE2( self, main ):
125 """
126 - Set up cell
127 - Create cell file
128 - Set cell file
129 - Verify cell file
130 - Kill ONOS process
131 - Uninstall ONOS cluster
132 - Verify ONOS start up
133 - Install ONOS cluster
134 - Connect to cli
135 """
136
Jeremy Songster17147f22016-05-31 18:30:52 -0700137 main.cycle += 1
138
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700139 # main.scale[ 0 ] determines the current number of ONOS controller
140 main.numCtrls = int( main.scale[ 0 ] )
Jeremycd872222016-03-29 10:08:34 -0700141 main.flowCompiler = "Flow Rules"
Jeremyd9e4eb12016-04-13 12:09:06 -0700142 main.initialized = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700143
144 main.case( "Starting up " + str( main.numCtrls ) +
145 " node(s) ONOS cluster" )
Jon Hall783bbf92015-07-23 14:33:19 -0700146 main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700147 " node(s) ONOS cluster"
148
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700149 #kill off all onos processes
150 main.log.info( "Safety check, killing all ONOS processes" +
Jon Hall70b2ff42015-11-17 15:49:44 -0800151 " before initiating environment setup" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700152
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800153 time.sleep( main.startUpSleep )
154 main.step( "Uninstalling ONOS package" )
155 onosUninstallResult = main.TRUE
156 for ip in main.ONOSip:
157 onosUninstallResult = onosUninstallResult and \
158 main.ONOSbench.onosUninstall( nodeIp=ip )
159 stepResult = onosUninstallResult
160 utilities.assert_equals( expect=main.TRUE,
161 actual=stepResult,
162 onpass="Successfully uninstalled ONOS package",
163 onfail="Failed to uninstall ONOS package" )
Jeremy42df2e72016-02-23 16:37:46 -0800164 time.sleep( main.startUpSleep )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800165
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700166 for i in range( main.maxNodes ):
167 main.ONOSbench.onosDie( main.ONOSip[ i ] )
168
169 print "NODE COUNT = ", main.numCtrls
170
171 tempOnosIp = []
172 for i in range( main.numCtrls ):
173 tempOnosIp.append( main.ONOSip[i] )
174
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700175 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
176 "temp", main.Mininet1.ip_address,
177 main.apps, tempOnosIp )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700178
179 main.step( "Apply cell to environment" )
180 cellResult = main.ONOSbench.setCell( "temp" )
181 verifyResult = main.ONOSbench.verifyCell()
182 stepResult = cellResult and verifyResult
183 utilities.assert_equals( expect=main.TRUE,
184 actual=stepResult,
185 onpass="Successfully applied cell to " + \
186 "environment",
187 onfail="Failed to apply cell to environment " )
188
189 main.step( "Creating ONOS package" )
Jon Hallbd60ea02016-08-23 10:03:59 -0700190 packageResult = main.ONOSbench.buckBuild()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700191 stepResult = packageResult
192 utilities.assert_equals( expect=main.TRUE,
193 actual=stepResult,
194 onpass="Successfully created ONOS package",
195 onfail="Failed to create ONOS package" )
196
197 time.sleep( main.startUpSleep )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700198 main.step( "Installing ONOS package" )
199 onosInstallResult = main.TRUE
200 for i in range( main.numCtrls ):
201 onosInstallResult = onosInstallResult and \
202 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
203 stepResult = onosInstallResult
204 utilities.assert_equals( expect=main.TRUE,
205 actual=stepResult,
206 onpass="Successfully installed ONOS package",
207 onfail="Failed to install ONOS package" )
208
209 time.sleep( main.startUpSleep )
210 main.step( "Starting ONOS service" )
211 stopResult = main.TRUE
212 startResult = main.TRUE
213 onosIsUp = main.TRUE
214
215 for i in range( main.numCtrls ):
Jeremy Songster7edb6632016-04-28 15:44:28 -0700216 isUp = main.ONOSbench.isup( main.ONOSip[ i ] )
217 onosIsUp = onosIsUp and isUp
218 if isUp == main.TRUE:
Jeremyd9e4eb12016-04-13 12:09:06 -0700219 main.log.report( "ONOS instance {0} is up and ready".format( i + 1 ) )
220 else:
221 main.log.report( "ONOS instance {0} may not be up, stop and ".format( i + 1 ) +
222 "start ONOS again " )
223 stopResult = stopResult and main.ONOSbench.onosStop( main.ONOSip[ i ] )
224 startResult = startResult and main.ONOSbench.onosStart( main.ONOSip[ i ] )
225 if not startResult or stopResult:
226 main.log.report( "ONOS instance {0} did not start correctly.".format( i + 1) )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700227 stepResult = onosIsUp and stopResult and startResult
228 utilities.assert_equals( expect=main.TRUE,
229 actual=stepResult,
Jeremyd9e4eb12016-04-13 12:09:06 -0700230 onpass="ONOS service is ready on all nodes",
231 onfail="ONOS service did not start properly on all nodes" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700232
233 main.step( "Start ONOS cli" )
234 cliResult = main.TRUE
235 for i in range( main.numCtrls ):
236 cliResult = cliResult and \
237 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
238 stepResult = cliResult
239 utilities.assert_equals( expect=main.TRUE,
240 actual=stepResult,
241 onpass="Successfully start ONOS cli",
242 onfail="Failed to start ONOS cli" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700243 if not stepResult:
244 main.initialized = main.FALSE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700245
246 # Remove the first element in main.scale list
247 main.scale.remove( main.scale[ 0 ] )
248
kelvin-onlab016dce22015-08-10 09:54:11 -0700249 main.intentFunction.report( main )
250
Jon Halla3e02432015-07-24 15:55:42 -0700251 def CASE8( self, main ):
252 """
acsmars59a4c552015-09-10 18:11:19 -0700253 Compare ONOS Topology to Mininet Topology
Jon Halla3e02432015-07-24 15:55:42 -0700254 """
255 import json
256
257 main.case( "Compare ONOS Topology view to Mininet topology" )
258 main.caseExplanation = "Compare topology elements between Mininet" +\
259 " and ONOS"
260
acsmars59a4c552015-09-10 18:11:19 -0700261 main.log.info( "Gathering topology information from Mininet" )
262 devicesResults = main.FALSE # Overall Boolean for device correctness
263 linksResults = main.FALSE # Overall Boolean for link correctness
264 hostsResults = main.FALSE # Overall Boolean for host correctness
265 deviceFails = [] # Nodes where devices are incorrect
266 linkFails = [] # Nodes where links are incorrect
267 hostFails = [] # Nodes where hosts are incorrect
268 attempts = main.checkTopoAttempts # Remaining Attempts
Jon Halla3e02432015-07-24 15:55:42 -0700269
270 mnSwitches = main.Mininet1.getSwitches()
271 mnLinks = main.Mininet1.getLinks()
272 mnHosts = main.Mininet1.getHosts()
273
Jon Hall70b2ff42015-11-17 15:49:44 -0800274 main.step( "Comparing Mininet topology to ONOS topology" )
Jon Halla3e02432015-07-24 15:55:42 -0700275
acsmars59a4c552015-09-10 18:11:19 -0700276 while ( attempts >= 0 ) and\
277 ( not devicesResults or not linksResults or not hostsResults ):
278 time.sleep( 2 )
279 if not devicesResults:
280 devices = main.topo.getAllDevices( main )
281 ports = main.topo.getAllPorts( main )
282 devicesResults = main.TRUE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800283 deviceFails = [] # Reset for each failed attempt
acsmars59a4c552015-09-10 18:11:19 -0700284 if not linksResults:
285 links = main.topo.getAllLinks( main )
286 linksResults = main.TRUE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800287 linkFails = [] # Reset for each failed attempt
acsmars59a4c552015-09-10 18:11:19 -0700288 if not hostsResults:
289 hosts = main.topo.getAllHosts( main )
290 hostsResults = main.TRUE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800291 hostFails = [] # Reset for each failed attempt
Jon Halla3e02432015-07-24 15:55:42 -0700292
acsmars59a4c552015-09-10 18:11:19 -0700293 # Check for matching topology on each node
294 for controller in range( main.numCtrls ):
295 controllerStr = str( controller + 1 ) # ONOS node number
296 # Compare Devices
297 if devices[ controller ] and ports[ controller ] and\
298 "Error" not in devices[ controller ] and\
299 "Error" not in ports[ controller ]:
Jon Halla3e02432015-07-24 15:55:42 -0700300
acsmars2ec91d62015-09-16 11:15:48 -0700301 try:
302 deviceData = json.loads( devices[ controller ] )
303 portData = json.loads( ports[ controller ] )
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700304 except( TypeError, ValueError ):
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800305 main.log.error( "Could not load json: {0} or {1}".format( str( devices[ controller ] ), str( ports[ controller ] ) ) )
acsmars2ec91d62015-09-16 11:15:48 -0700306 currentDevicesResult = main.FALSE
307 else:
308 currentDevicesResult = main.Mininet1.compareSwitches(
309 mnSwitches,deviceData,portData )
acsmars59a4c552015-09-10 18:11:19 -0700310 else:
311 currentDevicesResult = main.FALSE
312 if not currentDevicesResult:
313 deviceFails.append( controllerStr )
314 devicesResults = devicesResults and currentDevicesResult
315 # Compare Links
316 if links[ controller ] and "Error" not in links[ controller ]:
acsmars2ec91d62015-09-16 11:15:48 -0700317 try:
318 linkData = json.loads( links[ controller ] )
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700319 except( TypeError, ValueError ):
320 main.log.error( "Could not load json:" + str( links[ controller ] ) )
acsmars2ec91d62015-09-16 11:15:48 -0700321 currentLinksResult = main.FALSE
322 else:
323 currentLinksResult = main.Mininet1.compareLinks(
324 mnSwitches, mnLinks,linkData )
acsmars59a4c552015-09-10 18:11:19 -0700325 else:
326 currentLinksResult = main.FALSE
327 if not currentLinksResult:
328 linkFails.append( controllerStr )
329 linksResults = linksResults and currentLinksResult
330 # Compare Hosts
acsmars2ec91d62015-09-16 11:15:48 -0700331 if hosts[ controller ] and "Error" not in hosts[ controller ]:
332 try:
333 hostData = json.loads( hosts[ controller ] )
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700334 except( TypeError, ValueError ):
335 main.log.error( "Could not load json:" + str( hosts[ controller ] ) )
acsmars2ec91d62015-09-16 11:15:48 -0700336 currentHostsResult = main.FALSE
337 else:
338 currentHostsResult = main.Mininet1.compareHosts(
339 mnHosts,hostData )
acsmars59a4c552015-09-10 18:11:19 -0700340 else:
341 currentHostsResult = main.FALSE
342 if not currentHostsResult:
343 hostFails.append( controllerStr )
344 hostsResults = hostsResults and currentHostsResult
345 # Decrement Attempts Remaining
346 attempts -= 1
347
348
349 utilities.assert_equals( expect=[],
350 actual=deviceFails,
351 onpass="ONOS correctly discovered all devices",
352 onfail="ONOS incorrectly discovered devices on nodes: " +
353 str( deviceFails ) )
354 utilities.assert_equals( expect=[],
355 actual=linkFails,
356 onpass="ONOS correctly discovered all links",
357 onfail="ONOS incorrectly discovered links on nodes: " +
358 str( linkFails ) )
359 utilities.assert_equals( expect=[],
360 actual=hostFails,
361 onpass="ONOS correctly discovered all hosts",
362 onfail="ONOS incorrectly discovered hosts on nodes: " +
363 str( hostFails ) )
Jon Hall46d48252015-08-03 11:41:16 -0700364 topoResults = hostsResults and linksResults and devicesResults
365 utilities.assert_equals( expect=main.TRUE,
366 actual=topoResults,
367 onpass="ONOS correctly discovered the topology",
368 onfail="ONOS incorrectly discovered the topology" )
Jon Halla3e02432015-07-24 15:55:42 -0700369
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700370 def CASE10( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700371 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700372 Start Mininet topology with OF 1.0 switches
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700373 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700374 if main.initialized == main.FALSE:
375 main.log.error( "Test components did not start correctly, skipping further tests" )
376 main.skipCase()
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700377 main.OFProtocol = "1.0"
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700378 main.log.report( "Start Mininet topology with OF 1.0 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700379 main.case( "Start Mininet topology with OF 1.0 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700380 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700381 "switches to test intents, exits out if " +\
382 "topology did not start correctly"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700383
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700384 main.step( "Starting Mininet topology with OF 1.0 switches" )
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700385 args = "--switch ovs,protocols=OpenFlow10"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700386 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700387 main.topology,
388 args=args )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700389 stepResult = topoResult
390 utilities.assert_equals( expect=main.TRUE,
391 actual=stepResult,
392 onpass="Successfully loaded topology",
393 onfail="Failed to load topology" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700394
395 # Set flag to test cases if topology did not load properly
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700396 if not topoResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700397 main.initialized = main.FALSE
398 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700399
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700400 def CASE11( self, main ):
401 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700402 Start Mininet topology with OF 1.3 switches
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700403 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700404 if main.initialized == main.FALSE:
405 main.log.error( "Test components did not start correctly, skipping further tests" )
406 main.skipCase()
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700407 main.OFProtocol = "1.3"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700408 main.log.report( "Start Mininet topology with OF 1.3 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700409 main.case( "Start Mininet topology with OF 1.3 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700410 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700411 "switches to test intents, exits out if " +\
412 "topology did not start correctly"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700413
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700414 main.step( "Starting Mininet topology with OF 1.3 switches" )
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700415 args = "--switch ovs,protocols=OpenFlow13"
416 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
417 main.topology,
418 args=args )
419 stepResult = topoResult
420 utilities.assert_equals( expect=main.TRUE,
421 actual=stepResult,
422 onpass="Successfully loaded topology",
423 onfail="Failed to load topology" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700424 # Set flag to skip test cases if topology did not load properly
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700425 if not topoResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700426 main.initialized = main.FALSE
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700427
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700428 def CASE12( self, main ):
429 """
430 Assign mastership to controllers
431 """
432 import re
433
Jeremyd9e4eb12016-04-13 12:09:06 -0700434 if main.initialized == main.FALSE:
435 main.log.error( "Test components did not start correctly, skipping further tests" )
436 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700437 main.case( "Assign switches to controllers" )
438 main.step( "Assigning switches to controllers" )
Jon Hall783bbf92015-07-23 14:33:19 -0700439 main.caseExplanation = "Assign OF " + main.OFProtocol +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700440 " switches to ONOS nodes"
441
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700442 assignResult = main.TRUE
443 switchList = []
444
445 # Creates a list switch name, use getSwitch() function later...
446 for i in range( 1, ( main.numSwitch + 1 ) ):
447 switchList.append( 's' + str( i ) )
448
449 tempONOSip = []
450 for i in range( main.numCtrls ):
451 tempONOSip.append( main.ONOSip[ i ] )
452
453 assignResult = main.Mininet1.assignSwController( sw=switchList,
454 ip=tempONOSip,
Charles Chan029be652015-08-24 01:46:10 +0800455 port='6653' )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700456 if not assignResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700457 main.log.error( "Problem assigning mastership of switches" )
458 main.initialized = main.FALSE
459 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700460
461 for i in range( 1, ( main.numSwitch + 1 ) ):
462 response = main.Mininet1.getSwController( "s" + str( i ) )
463 print( "Response is " + str( response ) )
464 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
465 assignResult = assignResult and main.TRUE
466 else:
467 assignResult = main.FALSE
468 stepResult = assignResult
469 utilities.assert_equals( expect=main.TRUE,
470 actual=stepResult,
471 onpass="Successfully assigned switches" +
472 "to controller",
473 onfail="Failed to assign switches to " +
474 "controller" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700475 if not stepResult:
476 main.initialized = main.FALSE
acsmars5d8cc862015-09-25 09:44:50 -0700477
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800478 def CASE13( self,main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700479 """
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800480 Create Scapy components
481 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700482 if main.initialized == main.FALSE:
483 main.log.error( "Test components did not start correctly, skipping further tests" )
484 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800485 main.case( "Create scapy components" )
486 main.step( "Create scapy components" )
487 import json
488 scapyResult = main.TRUE
489 for hostName in main.scapyHostNames:
490 main.Scapy1.createHostComponent( hostName )
491 main.scapyHosts.append( getattr( main, hostName ) )
492
493 main.step( "Start scapy components" )
494 for host in main.scapyHosts:
495 host.startHostCli()
496 host.startScapy()
497 host.updateSelf()
498 main.log.debug( host.name )
499 main.log.debug( host.hostIp )
500 main.log.debug( host.hostMac )
501
502
503 utilities.assert_equals( expect=main.TRUE,
504 actual=scapyResult,
505 onpass="Successfully created Scapy Components",
506 onfail="Failed to discover Scapy Components" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700507 if not scapyResult:
508 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800509
510 def CASE14( self, main ):
511 """
512 Discover all hosts with fwd and pingall and store its data in a dictionary
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700513 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700514 if main.initialized == main.FALSE:
515 main.log.error( "Test components did not start correctly, skipping further tests" )
516 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700517 main.case( "Discover all hosts" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800518 main.step( "Pingall hosts and confirm ONOS discovery" )
519 utilities.retry( f=main.intentFunction.fwdPingall, retValue=main.FALSE, args=[ main ] )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700520
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800521 utilities.retry( f=main.intentFunction.confirmHostDiscovery, retValue=main.FALSE,
522 args=[ main ], attempts=main.checkTopoAttempts, sleep=2 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700523 utilities.assert_equals( expect=main.TRUE,
524 actual=stepResult,
525 onpass="Successfully discovered hosts",
526 onfail="Failed to discover hosts" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700527 if not stepResult:
528 main.initialized = main.FALSE
529 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700530
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800531 main.step( "Populate hostsData" )
532 stepResult = main.intentFunction.populateHostData( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700533 utilities.assert_equals( expect=main.TRUE,
534 actual=stepResult,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800535 onpass="Successfully populated hostsData",
536 onfail="Failed to populate hostsData" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700537 if not stepResult:
538 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800539
540 def CASE15( self, main ):
541 """
542 Discover all hosts with scapy arp packets and store its data to a dictionary
543 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700544 if main.initialized == main.FALSE:
545 main.log.error( "Test components did not start correctly, skipping further tests" )
546 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800547 main.case( "Discover all hosts using scapy" )
548 main.step( "Send packets from each host to the first host and confirm onos discovery" )
549
550 import collections
551 if len( main.scapyHosts ) < 1:
552 main.log.error( "No scapy hosts have been created" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700553 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800554 main.skipCase()
555
556 # Send ARP packets from each scapy host component
557 main.intentFunction.sendDiscoveryArp( main, main.scapyHosts )
558
559 stepResult = utilities.retry( f=main.intentFunction.confirmHostDiscovery,
560 retValue=main.FALSE, args=[ main ],
561 attempts=main.checkTopoAttempts, sleep=2 )
562
563 utilities.assert_equals( expect=main.TRUE,
564 actual=stepResult,
565 onpass="ONOS correctly discovered all hosts",
566 onfail="ONOS incorrectly discovered hosts" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700567 if not stepResult:
568 main.initialized = main.FALSE
569 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800570
571 main.step( "Populate hostsData" )
572 stepResult = main.intentFunction.populateHostData( main )
573 utilities.assert_equals( expect=main.TRUE,
574 actual=stepResult,
575 onpass="Successfully populated hostsData",
576 onfail="Failed to populate hostsData" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700577 if not stepResult:
578 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800579
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800580 def CASE16( self, main ):
581 """
Jeremy42df2e72016-02-23 16:37:46 -0800582 Balance Masters
583 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700584 if main.initialized == main.FALSE:
585 main.log.error( "Test components did not start correctly, skipping further tests" )
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700586 main.stop()
Jeremyd9e4eb12016-04-13 12:09:06 -0700587 main.skipCase()
Jeremy42df2e72016-02-23 16:37:46 -0800588 main.case( "Balance mastership of switches" )
589 main.step( "Balancing mastership of switches" )
590
591 balanceResult = main.FALSE
592 balanceResult = utilities.retry( f=main.CLIs[ 0 ].balanceMasters, retValue=main.FALSE, args=[] )
593
594 utilities.assert_equals( expect=main.TRUE,
Jeremy6e9748f2016-03-25 15:03:39 -0700595 actual=balanceResult,
Jeremy42df2e72016-02-23 16:37:46 -0800596 onpass="Successfully balanced mastership of switches",
597 onfail="Failed to balance mastership of switches" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700598 if not balanceResult:
599 main.initialized = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800600
601 def CASE17( self, main ):
602 """
Jeremy6e9748f2016-03-25 15:03:39 -0700603 Use Flow Objectives
604 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700605 if main.initialized == main.FALSE:
606 main.log.error( "Test components did not start correctly, skipping further tests" )
607 main.skipCase()
Jeremy6e9748f2016-03-25 15:03:39 -0700608 main.case( "Enable intent compilation using Flow Objectives" )
609 main.step( "Enabling Flow Objectives" )
610
611 main.flowCompiler = "Flow Objectives"
612
613 cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator"
614
615 stepResult = main.CLIs[ 0 ].setCfg( component=cmd,
616 propName="useFlowObjectives", value="true" )
617
618 utilities.assert_equals( expect=main.TRUE,
619 actual=stepResult,
620 onpass="Successfully activated Flow Objectives",
621 onfail="Failed to activate Flow Objectives" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700622 if not balanceResult:
623 main.initialized = main.FALSE
Jeremy6e9748f2016-03-25 15:03:39 -0700624
625 def CASE18( self, main ):
626 """
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800627 Stop mininet and remove scapy host
628 """
629 main.log.report( "Stop Mininet and Scapy" )
630 main.case( "Stop Mininet and Scapy" )
631 main.caseExplanation = "Stopping the current mininet topology " +\
632 "to start up fresh"
633 main.step( "Stopping and Removing Scapy Host Components" )
634 scapyResult = main.TRUE
635 for host in main.scapyHosts:
636 scapyResult = scapyResult and host.stopScapy()
637 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
638
639 for host in main.scapyHosts:
640 scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
641 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
642
643 main.scapyHosts = []
644 main.scapyHostIPs = []
645
646 utilities.assert_equals( expect=main.TRUE,
647 actual=scapyResult,
648 onpass="Successfully stopped scapy and removed host components",
649 onfail="Failed to stop mininet and scapy" )
650
651 main.step( "Stopping Mininet Topology" )
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700652 mininetResult = main.Mininet1.stopNet()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800653
654 utilities.assert_equals( expect=main.TRUE,
655 actual=mininetResult,
656 onpass="Successfully stopped mininet and scapy",
657 onfail="Failed to stop mininet and scapy" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700658 # Exit if topology did not load properly
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800659 if not ( mininetResult and scapyResult ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700660 main.cleanup()
661 main.exit()
662
Jeremy Songster17147f22016-05-31 18:30:52 -0700663 def CASE19( self, main ):
664 """
665 Copy the karaf.log files after each testcase cycle
666 """
667 main.log.report( "Copy karaf logs" )
668 main.case( "Copy karaf logs" )
669 main.caseExplanation = "Copying the karaf logs to preserve them through" +\
670 "reinstalling ONOS"
671 main.step( "Copying karaf logs" )
Jeremy Songster31aad312016-06-13 16:32:11 -0700672 stepResult = main.TRUE
673 scpResult = main.TRUE
674 copyResult = main.TRUE
Jeremy Songstercc5414b2016-07-11 10:59:53 -0700675 for i in range( main.numCtrls ):
676 main.node = main.CLIs[ i ]
Jeremy Songster17147f22016-05-31 18:30:52 -0700677 ip = main.ONOSip[ i ]
678 main.node.ip_address = ip
Jeremy Songster31aad312016-06-13 16:32:11 -0700679 scpResult = scpResult and main.ONOSbench.scp( main.node ,
680 "/opt/onos/log/karaf.log",
681 "/tmp/karaf.log",
682 direction="from" )
683 copyResult = copyResult and main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
684 copyFileName=( "karaf.log.node{0}.cycle{1}".format( str( i + 1 ), str( main.cycle ) ) ) )
685 if scpResult and copyResult:
686 stepResult = main.TRUE and stepResult
687 else:
688 stepResult = main.FALSE and stepResult
Jeremy Songster31aad312016-06-13 16:32:11 -0700689 utilities.assert_equals( expect=main.TRUE,
690 actual=stepResult,
691 onpass="Successfully copied remote ONOS logs",
692 onfail="Failed to copy remote ONOS logs" )
Jeremy Songster17147f22016-05-31 18:30:52 -0700693
kelvin-onlabb769f562015-07-15 17:05:10 -0700694 def CASE1000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700695 """
696 Add host intents between 2 host:
697 - Discover hosts
698 - Add host intents
699 - Check intents
700 - Verify flows
701 - Ping hosts
702 - Reroute
703 - Link down
704 - Verify flows
705 - Check topology
706 - Ping hosts
707 - Link up
708 - Verify flows
709 - Check topology
710 - Ping hosts
711 - Remove intents
712 """
713 import time
714 import json
715 import re
Jeremyd9e4eb12016-04-13 12:09:06 -0700716 if main.initialized == main.FALSE:
717 main.log.error( "Test components did not start correctly, skipping further tests" )
718 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700719 # Assert variables - These variable's name|format must be followed
720 # if you want to use the wrapper function
721 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -0700722 try:
723 assert main.CLIs
724 except AssertionError:
725 main.log.error( "There is no main.CLIs, skipping test cases" )
726 main.initialized = main.FALSE
727 main.skipCase()
728 try:
729 assert main.Mininet1
730 except AssertionError:
731 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
732 main.initialized = main.FALSE
733 main.skipCase()
734 try:
735 assert main.numSwitch
736 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700737 main.log.error( "Place the total number of switch topology in " +\
738 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -0700739 main.initialized = main.FALSE
740 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700741
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800742 # Save leader candidates
acsmarse6b410f2015-07-17 14:39:34 -0700743 intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
744
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700745 main.testName = "Host Intents"
746 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -0700747 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -0700748 main.caseExplanation = "This test case tests Host intents using " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700749 str( main.numCtrls ) + " node(s) cluster;\n" +\
750 "Different type of hosts will be tested in " +\
751 "each step such as IPV4, Dual stack, VLAN " +\
Jeremyeb51cb12016-03-28 17:53:35 -0700752 "etc;\nThe test will use OF " + main.OFProtocol +\
753 " OVS running in Mininet and compile intents" +\
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700754 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700755
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700756 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700757 main.assertReturnString = "Assertion Result for IPV4 host intent with mac addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800758 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
759 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
760 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800761 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800762 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700763 name='IPV4',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800764 onosNode='0',
765 host1=host1,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700766 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800767 if installResult:
768 testResult = main.intentFunction.testHostIntent( main,
769 name='IPV4',
770 intentId = installResult,
771 onosNode='0',
772 host1=host1,
773 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700774 sw1='s5',
775 sw2='s2',
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700776 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800777 else:
778 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800779
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700780 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800781 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700782 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700783 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700784
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700785 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700786 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800787 host1 = { "name":"h3","id":"00:00:00:00:00:03/-1" }
788 host2 = { "name":"h11","id":"00:00:00:00:00:0B/-1 "}
789 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800790 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800791 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700792 name='DUALSTACK',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800793 onosNode='0',
794 host1=host1,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700795 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800796
797 if installResult:
798 testResult = main.intentFunction.testHostIntent( main,
799 name='DUALSTACK',
800 intentId = installResult,
801 onosNode='0',
802 host1=host1,
803 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700804 sw1='s5',
805 sw2='s2',
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700806 expectedLink=18 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700807
808 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800809 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700810 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700811 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700812
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700813 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700814 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800815 host1 = { "name":"h1" }
816 host2 = { "name":"h11" }
817 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800818 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800819 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700820 name='DUALSTACK2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800821 onosNode='0',
822 host1=host1,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700823 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800824
825 if installResult:
826 testResult = main.intentFunction.testHostIntent( main,
827 name='DUALSTACK2',
828 intentId = installResult,
829 onosNode='0',
830 host1=host1,
831 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700832 sw1='s5',
833 sw2='s2',
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700834 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800835 else:
836 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700837
838 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800839 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700840 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700841 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700842
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700843 main.step( "1HOP: Add host intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -0700844 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800845 host1 = { "name":"h1" }
846 host2 = { "name":"h3" }
847 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800848 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800849 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700850 name='1HOP',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800851 onosNode='0',
852 host1=host1,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700853 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800854
855 if installResult:
856 testResult = main.intentFunction.testHostIntent( main,
857 name='1HOP',
858 intentId = installResult,
859 onosNode='0',
860 host1=host1,
861 host2=host2,
862 sw1='s5',
863 sw2='s2',
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700864 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800865 else:
866 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700867
868 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800869 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700870 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700871 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700872
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700873 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
acsmars5d8cc862015-09-25 09:44:50 -0700874 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jeremy Songster832f9e92016-05-05 14:30:49 -0700875 host1 = { "name":"h4","id":"00:00:00:00:00:04/100", "vlan":"100" }
876 host2 = { "name":"h12","id":"00:00:00:00:00:0C/100", "vlan":"100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800877 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800878 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800879 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700880 name='VLAN1',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800881 onosNode='0',
882 host1=host1,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700883 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800884
885 if installResult:
886 testResult = main.intentFunction.testHostIntent( main,
887 name='VLAN1',
888 intentId = installResult,
889 onosNode='0',
890 host1=host1,
891 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700892 sw1='s5',
893 sw2='s2',
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700894 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800895 else:
896 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700897
898 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800899 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700900 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700901 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700902
Jeremy Songsterff553672016-05-12 17:06:23 -0700903 main.step( "VLAN2: Add vlan host intents between h4 and h13" )
904 main.assertReturnString = "Assertion Result vlan IPV4\n"
905 host1 = { "name":"h5", "vlan":"200" }
906 host2 = { "name":"h12", "vlan":"100" }
907 testResult = main.FALSE
908 installResult = main.FALSE
909 installResult = main.intentFunction.installHostIntent( main,
910 name='VLAN2',
911 onosNode='0',
912 host1=host1,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700913 host2=host2 )
Jeremy Songsterff553672016-05-12 17:06:23 -0700914
915 if installResult:
916 testResult = main.intentFunction.testHostIntent( main,
917 name='VLAN2',
918 intentId = installResult,
919 onosNode='0',
920 host1=host1,
921 host2=host2,
922 sw1='s5',
923 sw2='s2',
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700924 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -0700925 else:
926 main.CLIs[ 0 ].removeAllIntents( purge=True )
927
928 utilities.assert_equals( expect=main.TRUE,
929 actual=testResult,
930 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700931 onfail=main.assertReturnString )
Jeremy Songsterff553672016-05-12 17:06:23 -0700932
Jeremy Songsterc032f162016-08-04 17:14:49 -0700933 main.step( "Encapsulation: Add host intents between h1 and h9" )
934 main.assertReturnString = "Assertion Result for VLAN Encapsulated host intent\n"
935 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
936 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
937 testResult = main.FALSE
938 installResult = main.FALSE
939 installResult = main.intentFunction.installHostIntent( main,
940 name='ENCAPSULATION',
941 onosNode='0',
942 host1=host1,
943 host2=host2,
944 encap="VLAN" )
945 if installResult:
946 testResult = main.intentFunction.testHostIntent( main,
947 name='ENCAPSULATION',
948 intentId = installResult,
949 onosNode='0',
950 host1=host1,
951 host2=host2,
952 sw1='s5',
953 sw2='s2',
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700954 expectedLink=18 )
Jeremy Songsterc032f162016-08-04 17:14:49 -0700955 else:
956 main.CLIs[ 0 ].removeAllIntents( purge=True )
957
958 utilities.assert_equals( expect=main.TRUE,
959 actual=testResult,
960 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700961 onfail=main.assertReturnString )
Jeremy Songsterc032f162016-08-04 17:14:49 -0700962
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700963 main.step( "Confirm that ONOS leadership is unchanged" )
acsmarse6b410f2015-07-17 14:39:34 -0700964 intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
965 main.intentFunction.checkLeaderChange( intentLeadersOld,
966 intentLeadersNew )
967
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800968 utilities.assert_equals( expect=main.TRUE,
969 actual=testResult,
970 onpass="ONOS Leaders Unchanged",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700971 onfail="ONOS Leader Mismatch" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800972
kelvin-onlab016dce22015-08-10 09:54:11 -0700973 main.intentFunction.report( main )
974
kelvin-onlabb769f562015-07-15 17:05:10 -0700975 def CASE2000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700976 """
977 Add point intents between 2 hosts:
978 - Get device ids | ports
979 - Add point intents
980 - Check intents
981 - Verify flows
982 - Ping hosts
983 - Reroute
984 - Link down
985 - Verify flows
986 - Check topology
987 - Ping hosts
988 - Link up
989 - Verify flows
990 - Check topology
991 - Ping hosts
992 - Remove intents
993 """
994 import time
995 import json
996 import re
Jeremyd9e4eb12016-04-13 12:09:06 -0700997 if main.initialized == main.FALSE:
998 main.log.error( "Test components did not start correctly, skipping further tests" )
999 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001000 # Assert variables - These variable's name|format must be followed
1001 # if you want to use the wrapper function
1002 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001003 try:
1004 assert main.CLIs
1005 except AssertionError:
1006 main.log.error( "There is no main.CLIs, skipping test cases" )
1007 main.initialized = main.FALSE
1008 main.skipCase()
1009 try:
1010 assert main.Mininet1
1011 except AssertionError:
1012 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1013 main.initialized = main.FALSE
1014 main.skipCase()
1015 try:
1016 assert main.numSwitch
1017 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001018 main.log.error( "Place the total number of switch topology in " +\
1019 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001020 main.initialized = main.FALSE
1021 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001022
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001023 main.testName = "Point Intents"
1024 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001025 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001026 main.caseExplanation = "This test case will test point to point" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001027 " intents using " + str( main.numCtrls ) +\
1028 " node(s) cluster;\n" +\
1029 "Different type of hosts will be tested in " +\
1030 "each step such as IPV4, Dual stack, VLAN etc" +\
1031 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001032 " OVS running in Mininet and compile intents" +\
1033 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001034
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001035 # No option point intents
1036 main.step( "NOOPTION: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001037 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001038 senders = [
1039 { "name":"h1","device":"of:0000000000000005/1" }
1040 ]
1041 recipients = [
1042 { "name":"h9","device":"of:0000000000000006/1" }
1043 ]
Jeremy42df2e72016-02-23 16:37:46 -08001044 testResult = main.FALSE
1045 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001046 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001047 main,
1048 name="NOOPTION",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001049 senders=senders,
1050 recipients=recipients )
1051
1052 if installResult:
1053 testResult = main.intentFunction.testPointIntent(
1054 main,
1055 intentId=installResult,
1056 name="NOOPTION",
1057 senders=senders,
1058 recipients=recipients,
1059 sw1="s5",
1060 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001061 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001062 else:
1063 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001064
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001065 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001066 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001067 onpass=main.assertReturnString,
1068 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001069
1070 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -07001071 main.step( "IPV4: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001072 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001073 senders = [
1074 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1075 ]
1076 recipients = [
1077 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09" }
1078 ]
Jeremy42df2e72016-02-23 16:37:46 -08001079 testResult = main.FALSE
1080 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001081 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001082 main,
1083 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001084 senders=senders,
1085 recipients=recipients,
1086 ethType="IPV4" )
1087
1088 if installResult:
1089 testResult = main.intentFunction.testPointIntent(
1090 main,
1091 intentId=installResult,
1092 name="IPV4",
1093 senders=senders,
1094 recipients=recipients,
1095 sw1="s5",
1096 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001097 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001098 else:
1099 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001100
1101 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001102 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001103 onpass=main.assertReturnString,
1104 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001105 main.step( "IPV4_2: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001106 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001107 senders = [
1108 { "name":"h1","device":"of:0000000000000005/1" }
1109 ]
1110 recipients = [
1111 { "name":"h9","device":"of:0000000000000006/1" }
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,
1117 name="IPV4_2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001118 senders=senders,
1119 recipients=recipients,
1120 ethType="IPV4" )
1121
1122 if installResult:
1123 testResult = main.intentFunction.testPointIntent(
1124 main,
1125 intentId=installResult,
1126 name="IPV4_2",
1127 senders=senders,
1128 recipients=recipients,
1129 sw1="s5",
1130 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001131 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001132 else:
1133 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001134
1135 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001136 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001137 onpass=main.assertReturnString,
1138 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001139
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001140 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001141 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001142 senders = [
1143 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01",
Jeremy6f000c62016-02-25 17:02:28 -08001144 "ip":( main.h1.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001145 ]
1146 recipients = [
1147 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09",
Jeremy6f000c62016-02-25 17:02:28 -08001148 "ip":( main.h9.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001149 ]
Jeremy6f000c62016-02-25 17:02:28 -08001150 ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ]
kelvin-onlab79ce0492015-07-27 16:14:39 -07001151 # Uneccessary, not including this in the selectors
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001152 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
1153 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
Jeremy42df2e72016-02-23 16:37:46 -08001154 testResult = main.FALSE
1155 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001156 installResult = main.intentFunction.installPointIntent(
1157 main,
1158 name="SDNIP-ICMP",
1159 senders=senders,
1160 recipients=recipients,
1161 ethType="IPV4",
1162 ipProto=ipProto,
1163 tcpSrc=tcpSrc,
1164 tcpDst=tcpDst )
1165
1166 if installResult:
1167 testResult = main.intentFunction.testPointIntent(
1168 main,
1169 intentId=installResult,
1170 name="SDNIP_ICMP",
1171 senders=senders,
1172 recipients=recipients,
1173 sw1="s5",
1174 sw2="s2",
Jeremy Songstere405d3d2016-05-17 11:18:57 -07001175 expectedLink=18,
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001176 useTCP=True )
Jeremy42df2e72016-02-23 16:37:46 -08001177 else:
1178 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabb769f562015-07-15 17:05:10 -07001179
1180 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001181 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001182 onpass=main.assertReturnString,
1183 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001184
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001185 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001186 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
kelvin-onlabb769f562015-07-15 17:05:10 -07001187 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
1188 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab58dc39e2015-08-06 08:11:09 -07001189 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
1190 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlabb769f562015-07-15 17:05:10 -07001191 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
1192 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
1193 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
1194
kelvin-onlab58dc39e2015-08-06 08:11:09 -07001195 stepResult = main.intentFunction.pointIntentTcp(
kelvin-onlabb769f562015-07-15 17:05:10 -07001196 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001197 name="SDNIP-TCP",
kelvin-onlabb769f562015-07-15 17:05:10 -07001198 host1="h1",
1199 host2="h9",
1200 deviceId1="of:0000000000000005/1",
1201 deviceId2="of:0000000000000006/1",
1202 mac1=mac1,
1203 mac2=mac2,
1204 ethType="IPV4",
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001205 ipProto=ipProto,
1206 ip1=ip1,
1207 ip2=ip2,
1208 tcp1=tcp1,
1209 tcp2=tcp2 )
kelvin-onlabb769f562015-07-15 17:05:10 -07001210
1211 utilities.assert_equals( expect=main.TRUE,
Jeremy6f000c62016-02-25 17:02:28 -08001212 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -07001213 onpass=main.assertReturnString,
1214 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001215
acsmars5d8cc862015-09-25 09:44:50 -07001216 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
1217 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001218 senders = [
1219 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1220 ]
1221 recipients = [
1222 { "name":"h11","device":"of:0000000000000006/3","mac":"00:00:00:00:00:0B" }
1223 ]
Jeremy42df2e72016-02-23 16:37:46 -08001224 testResult = main.FALSE
1225 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001226 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001227 main,
1228 name="DUALSTACK1",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001229 senders=senders,
1230 recipients=recipients,
1231 ethType="IPV4" )
1232
1233 if installResult:
1234 testResult = main.intentFunction.testPointIntent(
1235 main,
1236 intentId=installResult,
1237 name="DUALSTACK1",
1238 senders=senders,
1239 recipients=recipients,
1240 sw1="s5",
1241 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001242 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001243 else:
1244 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001245
1246 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001247 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001248 onpass=main.assertReturnString,
1249 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001250
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001251 main.step( "VLAN: Add point intents between h5 and h21" )
acsmars5d8cc862015-09-25 09:44:50 -07001252 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001253 senders = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001254 { "name":"h5","device":"of:0000000000000005/5","mac":"00:00:00:00:00:05", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001255 ]
1256 recipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001257 { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001258 ]
Jeremy42df2e72016-02-23 16:37:46 -08001259 testResult = main.FALSE
1260 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001261 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001262 main,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001263 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001264 senders=senders,
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001265 recipients=recipients )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001266
1267 if installResult:
1268 testResult = main.intentFunction.testPointIntent(
1269 main,
1270 intentId=installResult,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001271 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001272 senders=senders,
1273 recipients=recipients,
1274 sw1="s5",
1275 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001276 expectedLink=18 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001277
1278 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001279 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001280 onpass=main.assertReturnString,
1281 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001282
Jeremy Songsterff553672016-05-12 17:06:23 -07001283 main.step( "VLAN: Add point intents between h5 and h21" )
1284 main.assertReturnString = "Assertion Result for VLAN IPV4 point intents with VLAN treatment\n"
1285 senders = [
1286 { "name":"h4", "vlan":"100" }
1287 ]
1288 recipients = [
1289 { "name":"h21", "vlan":"200" }
1290 ]
1291 testResult = main.FALSE
1292 installResult = main.FALSE
1293 installResult = main.intentFunction.installPointIntent(
1294 main,
1295 name="VLAN2",
1296 senders=senders,
1297 recipients=recipients,
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001298 setVlan=200 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001299
1300 if installResult:
1301 testResult = main.intentFunction.testPointIntent(
1302 main,
1303 intentId=installResult,
1304 name="VLAN2",
1305 senders=senders,
1306 recipients=recipients,
1307 sw1="s5",
1308 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001309 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001310
1311 utilities.assert_equals( expect=main.TRUE,
1312 actual=testResult,
1313 onpass=main.assertReturnString,
1314 onfail=main.assertReturnString )
1315
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001316 main.step( "1HOP: Add point intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -07001317 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001318 senders = [
1319 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1320 ]
1321 recipients = [
1322 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1323 ]
Jeremy42df2e72016-02-23 16:37:46 -08001324 testResult = main.FALSE
1325 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001326 installResult = main.intentFunction.installPointIntent(
1327 main,
1328 name="1HOP IPV4",
1329 senders=senders,
1330 recipients=recipients,
1331 ethType="IPV4" )
1332
1333 if installResult:
1334 testResult = main.intentFunction.testPointIntent(
1335 main,
1336 intentId=installResult,
1337 name="1HOP IPV4",
1338 senders=senders,
1339 recipients=recipients,
1340 sw1="s5",
1341 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001342 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001343 else:
1344 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001345
1346 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001347 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001348 onpass=main.assertReturnString,
1349 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001350
Jeremy Songsterc032f162016-08-04 17:14:49 -07001351 main.step( "Add point to point intents using VLAN Encapsulation" )
1352 main.assertReturnString = "Assertion Result for VLAN Encapsulation Point Intent"
1353 senders = [
1354 { "name":"h1","device":"of:0000000000000005/1" }
1355 ]
1356 recipients = [
1357 { "name":"h9","device":"of:0000000000000006/1" }
1358 ]
1359 testResult = main.FALSE
1360 installResult = main.FALSE
1361 installResult = main.intentFunction.installPointIntent(
1362 main,
1363 name="ENCAPSULATION",
1364 senders=senders,
1365 recipients=recipients,
1366 encap="VLAN" )
1367
1368 if installResult:
1369 testResult = main.intentFunction.testPointIntent(
1370 main,
1371 intentId=installResult,
1372 name="ENCAPSULATION",
1373 senders=senders,
1374 recipients=recipients,
1375 sw1="s5",
1376 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001377 expectedLink=18 )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001378 else:
1379 main.CLIs[ 0 ].removeAllIntents( purge=True )
1380
1381 utilities.assert_equals( expect=main.TRUE,
1382 actual=testResult,
1383 onpass=main.assertReturnString,
1384 onfail=main.assertReturnString )
1385
kelvin-onlab016dce22015-08-10 09:54:11 -07001386 main.intentFunction.report( main )
1387
kelvin-onlabb769f562015-07-15 17:05:10 -07001388 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001389 """
1390 Add single point to multi point intents
1391 - Get device ids
1392 - Add single point to multi point intents
1393 - Check intents
1394 - Verify flows
1395 - Ping hosts
1396 - Reroute
1397 - Link down
1398 - Verify flows
1399 - Check topology
1400 - Ping hosts
1401 - Link up
1402 - Verify flows
1403 - Check topology
1404 - Ping hosts
1405 - Remove intents
1406 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001407 if main.initialized == main.FALSE:
1408 main.log.error( "Test components did not start correctly, skipping further tests" )
1409 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001410 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001411 try:
1412 assert main.CLIs
1413 except AssertionError:
1414 main.log.error( "There is no main.CLIs, skipping test cases" )
1415 main.initialized = main.FALSE
1416 main.skipCase()
1417 try:
1418 assert main.Mininet1
1419 except AssertionError:
1420 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1421 main.initialized = main.FALSE
1422 main.skipCase()
1423 try:
1424 assert main.numSwitch
1425 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001426 main.log.error( "Place the total number of switch topology in "+ \
1427 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001428 main.initialized = main.FALSE
1429 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001430
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001431 main.testName = "Single to Multi Point Intents"
1432 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001433 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001434 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001435 " multi point intents using " +\
1436 str( main.numCtrls ) + " node(s) cluster;\n" +\
1437 "Different type of hosts will be tested in " +\
1438 "each step such as IPV4, Dual stack, VLAN etc" +\
1439 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001440 " OVS running in Mininet and compile intents" +\
1441 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001442
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001443 main.step( "NOOPTION: Install and test single point to multi point intents" )
1444 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
1445 senders = [
1446 { "name":"h8", "device":"of:0000000000000005/8" }
1447 ]
1448 recipients = [
1449 { "name":"h16", "device":"of:0000000000000006/8" },
1450 { "name":"h24", "device":"of:0000000000000007/8" }
1451 ]
1452 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1453 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1454 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001455 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001456 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001457 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001458 name="NOOPTION",
1459 senders=senders,
1460 recipients=recipients,
1461 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001462 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001463
1464 if installResult:
1465 testResult = main.intentFunction.testPointIntent(
1466 main,
1467 intentId=installResult,
1468 name="NOOPTION",
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 Songstere7f3b342016-08-17 14:56:49 -07001475 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001476 else:
1477 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001478
1479 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001480 actual=testResult,
1481 onpass=main.assertReturnString,
1482 onfail=main.assertReturnString )
1483
1484 main.step( "IPV4: Install and test single point to multi point intents" )
1485 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses\n"
1486 senders = [
1487 { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" }
1488 ]
1489 recipients = [
1490 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1491 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1492 ]
1493 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1494 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1495 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001496 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001497 installResult = main.intentFunction.installSingleToMultiIntent(
1498 main,
1499 name="IPV4",
1500 senders=senders,
1501 recipients=recipients,
1502 ethType="IPV4",
1503 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001504 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001505
1506 if installResult:
1507 testResult = main.intentFunction.testPointIntent(
1508 main,
1509 intentId=installResult,
1510 name="IPV4",
1511 senders=senders,
1512 recipients=recipients,
1513 badSenders=badSenders,
1514 badRecipients=badRecipients,
1515 sw1="s5",
1516 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001517 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001518 else:
1519 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001520
1521 utilities.assert_equals( expect=main.TRUE,
1522 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001523 onpass=main.assertReturnString,
1524 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001525
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001526 main.step( "IPV4_2: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001527 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 -08001528 senders = [
1529 { "name":"h8", "device":"of:0000000000000005/8" }
1530 ]
1531 recipients = [
1532 { "name":"h16", "device":"of:0000000000000006/8" },
1533 { "name":"h24", "device":"of:0000000000000007/8" }
1534 ]
1535 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1536 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1537 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001538 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001539 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001540 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001541 name="IPV4_2",
1542 senders=senders,
1543 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001544 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001545 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001546 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001547
1548 if installResult:
1549 testResult = main.intentFunction.testPointIntent(
1550 main,
1551 intentId=installResult,
1552 name="IPV4_2",
1553 senders=senders,
1554 recipients=recipients,
1555 badSenders=badSenders,
1556 badRecipients=badRecipients,
1557 sw1="s5",
1558 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001559 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001560 else:
1561 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001562
1563 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001564 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001565 onpass=main.assertReturnString,
1566 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001567
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001568 main.step( "VLAN: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001569 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 -08001570 senders = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001571 { "name":"h4", "device":"of:0000000000000005/4", "mac":"00:00:00:00:00:04", "vlan":"100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001572 ]
1573 recipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001574 { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C", "vlan":"100" },
1575 { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14", "vlan":"100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001576 ]
1577 badSenders=[ { "name":"h13" } ] # Senders that are not in the intent
1578 badRecipients=[ { "name":"h21" } ] # Recipients that are not in the intent
1579 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001580 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001581 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001582 main,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001583 name="VLAN`",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001584 senders=senders,
1585 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001586 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001587 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001588
1589 if installResult:
1590 testResult = main.intentFunction.testPointIntent(
1591 main,
1592 intentId=installResult,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001593 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001594 senders=senders,
1595 recipients=recipients,
1596 badSenders=badSenders,
1597 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001598 sw1="s5",
1599 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001600 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001601 else:
1602 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001603
1604 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001605 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001606 onpass=main.assertReturnString,
1607 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001608
Jeremy Songsterff553672016-05-12 17:06:23 -07001609 main.step( "VLAN: Add single point to multi point intents" )
1610 main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n"
1611 senders = [
1612 { "name":"h5", "vlan":"200" }
1613 ]
1614 recipients = [
1615 { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C", "vlan":"100" },
1616 { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14", "vlan":"100" }
1617 ]
1618 badSenders=[ { "name":"h13" } ] # Senders that are not in the intent
1619 badRecipients=[ { "name":"h21" } ] # Recipients that are not in the intent
1620 testResult = main.FALSE
1621 installResult = main.FALSE
1622 installResult = main.intentFunction.installSingleToMultiIntent(
1623 main,
1624 name="VLAN2",
1625 senders=senders,
1626 recipients=recipients,
1627 sw1="s5",
1628 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001629 setVlan=100 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001630
1631 if installResult:
1632 testResult = main.intentFunction.testPointIntent(
1633 main,
1634 intentId=installResult,
1635 name="VLAN2",
1636 senders=senders,
1637 recipients=recipients,
1638 badSenders=badSenders,
1639 badRecipients=badRecipients,
1640 sw1="s5",
1641 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001642 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001643 else:
1644 main.CLIs[ 0 ].removeAllIntents( purge=True )
1645
1646 utilities.assert_equals( expect=main.TRUE,
1647 actual=testResult,
1648 onpass=main.assertReturnString,
1649 onfail=main.assertReturnString )
1650
Jeremy Songsterc032f162016-08-04 17:14:49 -07001651 main.step( "ENCAPSULATION: Install and test single point to multi point intents" )
1652 main.assertReturnString = "Assertion results for VLAN Encapsulation single to multi point intent\n"
1653 senders = [
1654 { "name":"h8", "device":"of:0000000000000005/8" }
1655 ]
1656 recipients = [
1657 { "name":"h16", "device":"of:0000000000000006/8" },
1658 { "name":"h24", "device":"of:0000000000000007/8" }
1659 ]
1660 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1661 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1662 testResult = main.FALSE
1663 installResult = main.FALSE
1664 installResult = main.intentFunction.installSingleToMultiIntent(
1665 main,
1666 name="ENCAPSULATION",
1667 senders=senders,
1668 recipients=recipients,
1669 sw1="s5",
1670 sw2="s2",
1671 encap="VLAN" )
1672
1673 if installResult:
1674 testResult = main.intentFunction.testPointIntent(
1675 main,
1676 intentId=installResult,
1677 name="ENCAPSULATION",
1678 senders=senders,
1679 recipients=recipients,
1680 badSenders=badSenders,
1681 badRecipients=badRecipients,
1682 sw1="s5",
1683 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001684 expectedLink=18 )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001685 else:
1686 main.CLIs[ 0 ].removeAllIntents( purge=True )
1687
1688 utilities.assert_equals( expect=main.TRUE,
1689 actual=testResult,
1690 onpass=main.assertReturnString,
1691 onfail=main.assertReturnString )
1692
kelvin-onlab016dce22015-08-10 09:54:11 -07001693 main.intentFunction.report( main )
1694
kelvin-onlabb769f562015-07-15 17:05:10 -07001695 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001696 """
1697 Add multi point to single point intents
1698 - Get device ids
1699 - Add multi point to single point intents
1700 - Check intents
1701 - Verify flows
1702 - Ping hosts
1703 - Reroute
1704 - Link down
1705 - Verify flows
1706 - Check topology
1707 - Ping hosts
1708 - Link up
1709 - Verify flows
1710 - Check topology
1711 - Ping hosts
1712 - Remove intents
1713 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001714 if main.initialized == main.FALSE:
1715 main.log.error( "Test components did not start correctly, skipping further tests" )
1716 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001717 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001718 try:
1719 assert main.CLIs
1720 except AssertionError:
1721 main.log.error( "There is no main.CLIs, skipping test cases" )
1722 main.initialized = main.FALSE
1723 main.skipCase()
1724 try:
1725 assert main.Mininet1
1726 except AssertionError:
1727 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1728 main.initialized = main.FALSE
1729 main.skipCase()
1730 try:
1731 assert main.numSwitch
1732 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001733 main.log.error( "Place the total number of switch topology in "+\
1734 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001735 main.initialized = main.FALSE
1736 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001737
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001738 main.testName = "Multi To Single Point Intents"
1739 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001740 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001741 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001742 " multi point intents using " +\
1743 str( main.numCtrls ) + " node(s) cluster;\n" +\
1744 "Different type of hosts will be tested in " +\
1745 "each step such as IPV4, Dual stack, VLAN etc" +\
1746 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001747 " OVS running in Mininet and compile intents" +\
1748 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001749
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001750 main.step( "NOOPTION: Add multi point to single point intents" )
1751 main.assertReturnString = "Assertion results for NOOPTION multi to single point intent\n"
1752 senders = [
1753 { "name":"h16", "device":"of:0000000000000006/8" },
1754 { "name":"h24", "device":"of:0000000000000007/8" }
1755 ]
1756 recipients = [
1757 { "name":"h8", "device":"of:0000000000000005/8" }
1758 ]
1759 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1760 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1761 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001762 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001763 installResult = main.intentFunction.installMultiToSingleIntent(
1764 main,
1765 name="NOOPTION",
1766 senders=senders,
1767 recipients=recipients,
1768 sw1="s5",
Jeremye0cb5eb2016-01-27 17:39:09 -08001769 sw2="s2" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001770
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001771 if installResult:
1772 testResult = main.intentFunction.testPointIntent(
1773 main,
1774 intentId=installResult,
1775 name="NOOPTION",
1776 senders=senders,
1777 recipients=recipients,
1778 badSenders=badSenders,
1779 badRecipients=badRecipients,
1780 sw1="s5",
1781 sw2="s2",
Jeremye0cb5eb2016-01-27 17:39:09 -08001782 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001783 else:
1784 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001785
1786 utilities.assert_equals( expect=main.TRUE,
1787 actual=testResult,
1788 onpass=main.assertReturnString,
1789 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001790
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001791 main.step( "IPV4: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001792 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 -08001793 senders = [
1794 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1795 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1796 ]
1797 recipients = [
1798 { "name":"h8", "device":"of:0000000000000005/8", "mac":"00:00:00:00:00:08" }
1799 ]
1800 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1801 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1802 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001803 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001804 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001805 main,
1806 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001807 senders=senders,
1808 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001809 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001810 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001811 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001812
1813 if installResult:
1814 testResult = main.intentFunction.testPointIntent(
1815 main,
1816 intentId=installResult,
1817 name="IPV4",
1818 senders=senders,
1819 recipients=recipients,
1820 badSenders=badSenders,
1821 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001822 sw1="s5",
1823 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001824 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001825 else:
1826 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001827
1828 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001829 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001830 onpass=main.assertReturnString,
1831 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001832
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001833 main.step( "IPV4_2: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001834 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 -08001835 senders = [
1836 { "name":"h16", "device":"of:0000000000000006/8" },
1837 { "name":"h24", "device":"of:0000000000000007/8" }
1838 ]
1839 recipients = [
1840 { "name":"h8", "device":"of:0000000000000005/8" }
1841 ]
1842 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1843 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1844 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001845 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001846 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001847 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001848 name="IPV4_2",
1849 senders=senders,
1850 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001851 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001852 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001853 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001854
1855 if installResult:
1856 testResult = main.intentFunction.testPointIntent(
1857 main,
1858 intentId=installResult,
1859 name="IPV4_2",
1860 senders=senders,
1861 recipients=recipients,
1862 badSenders=badSenders,
1863 badRecipients=badRecipients,
1864 sw1="s5",
1865 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001866 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001867 else:
1868 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001869
1870 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001871 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001872 onpass=main.assertReturnString,
1873 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001874
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001875 main.step( "VLAN: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001876 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 -08001877 senders = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001878 { "name":"h13", "device":"of:0000000000000006/5", "vlan":"200" },
1879 { "name":"h21", "device":"of:0000000000000007/5", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001880 ]
1881 recipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001882 { "name":"h5", "device":"of:0000000000000005/5", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001883 ]
1884 badSenders=[ { "name":"h12" } ] # Senders that are not in the intent
1885 badRecipients=[ { "name":"h20" } ] # Recipients that are not in the intent
1886 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001887 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001888 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001889 main,
1890 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001891 senders=senders,
1892 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001893 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001894 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001895
1896 if installResult:
1897 testResult = main.intentFunction.testPointIntent(
1898 main,
1899 intentId=installResult,
1900 name="VLAN",
1901 senders=senders,
1902 recipients=recipients,
1903 badSenders=badSenders,
1904 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001905 sw1="s5",
1906 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001907 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001908 else:
1909 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001910
1911 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001912 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001913 onpass=main.assertReturnString,
1914 onfail=main.assertReturnString )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001915
Jeremy Songsterff553672016-05-12 17:06:23 -07001916 # Right now this fails because of this bug: https://jira.onosproject.org/browse/ONOS-4383
1917 main.step( "VLAN: Add multi point to single point intents" )
1918 main.assertReturnString = "Assertion results for multi to single point intent with VLAN ID treatment\n"
1919 senders = [
1920 { "name":"h13", "device":"of:0000000000000006/5", "vlan":"200" },
1921 { "name":"h21", "device":"of:0000000000000007/5", "vlan":"200" }
1922 ]
1923 recipients = [
1924 { "name":"h4", "vlan":"100" }
1925 ]
1926 badSenders=[ { "name":"h12" } ] # Senders that are not in the intent
1927 badRecipients=[ { "name":"h20" } ] # Recipients that are not in the intent
1928 testResult = main.FALSE
1929 installResult = main.FALSE
1930 installResult = main.intentFunction.installMultiToSingleIntent(
1931 main,
1932 name="VLAN2",
1933 senders=senders,
1934 recipients=recipients,
1935 sw1="s5",
1936 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001937 setVlan=100 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001938
1939 if installResult:
1940 testResult = main.intentFunction.testPointIntent(
1941 main,
1942 intentId=installResult,
1943 name="VLAN2",
1944 senders=senders,
1945 recipients=recipients,
1946 badSenders=badSenders,
1947 badRecipients=badRecipients,
1948 sw1="s5",
1949 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001950 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001951 else:
1952 main.CLIs[ 0 ].removeAllIntents( purge=True )
1953
1954 utilities.assert_equals( expect=main.TRUE,
1955 actual=testResult,
1956 onpass=main.assertReturnString,
1957 onfail=main.assertReturnString )
1958
Jeremy Songsterc032f162016-08-04 17:14:49 -07001959 main.step( "ENCAPSULATION: Add multi point to single point intents" )
1960 main.assertReturnString = "Assertion results for VLAN Encapsulation multi to single point intent\n"
1961 senders = [
1962 { "name":"h16", "device":"of:0000000000000006/8" },
1963 { "name":"h24", "device":"of:0000000000000007/8" }
1964 ]
1965 recipients = [
1966 { "name":"h8", "device":"of:0000000000000005/8" }
1967 ]
1968 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1969 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1970 testResult = main.FALSE
1971 installResult = main.FALSE
1972 installResult = main.intentFunction.installMultiToSingleIntent(
1973 main,
1974 name="ENCAPSULATION",
1975 senders=senders,
1976 recipients=recipients,
1977 sw1="s5",
1978 sw2="s2",
1979 encap="VLAN" )
1980
1981 if installResult:
1982 testResult = main.intentFunction.testPointIntent(
1983 main,
1984 intentId=installResult,
1985 name="ENCAPSULATION",
1986 senders=senders,
1987 recipients=recipients,
1988 badSenders=badSenders,
1989 badRecipients=badRecipients,
1990 sw1="s5",
1991 sw2="s2",
1992 expectedLink=18 )
1993 else:
1994 main.CLIs[ 0 ].removeAllIntents( purge=True )
1995
1996 utilities.assert_equals( expect=main.TRUE,
1997 actual=testResult,
1998 onpass=main.assertReturnString,
1999 onfail=main.assertReturnString )
2000
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002001 main.intentFunction.report( main )
2002
acsmars1ff5e052015-07-23 11:27:48 -07002003 def CASE5000( self, main ):
2004 """
acsmars5d8cc862015-09-25 09:44:50 -07002005 Tests Host Mobility
2006 Modifies the topology location of h1
acsmars1ff5e052015-07-23 11:27:48 -07002007 """
Jeremyd9e4eb12016-04-13 12:09:06 -07002008 if main.initialized == main.FALSE:
2009 main.log.error( "Test components did not start correctly, skipping further tests" )
2010 main.skipCase()
acsmars1ff5e052015-07-23 11:27:48 -07002011 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07002012 try:
2013 assert main.CLIs
2014 except AssertionError:
2015 main.log.error( "There is no main.CLIs, skipping test cases" )
2016 main.initialized = main.FALSE
2017 main.skipCase()
2018 try:
2019 assert main.Mininet1
2020 except AssertionError:
2021 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
2022 main.initialized = main.FALSE
2023 main.skipCase()
2024 try:
2025 assert main.numSwitch
2026 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002027 main.log.error( "Place the total number of switch topology in "+\
2028 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07002029 main.initialized = main.FALSE
2030 main.skipCase()
kelvin-onlabf34a58a2015-07-23 16:41:52 -07002031 main.case( "Test host mobility with host intents " )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002032 main.step( "Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07002033 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
2034
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002035 main.log.info( "Moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07002036 main.Mininet1.moveHost( "h1","s5","s6" )
2037
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002038 # Send discovery ping from moved host
2039 # Moving the host brings down the default interfaces and creates a new one.
2040 # Scapy is restarted on this host to detect the new interface
2041 main.h1.stopScapy()
2042 main.h1.startScapy()
2043
2044 # Discover new host location in ONOS and populate host data.
2045 # Host 1 IP and MAC should be unchanged
2046 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
2047 main.intentFunction.populateHostData( main )
2048
acsmars1ff5e052015-07-23 11:27:48 -07002049 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
2050
2051 utilities.assert_equals( expect="of:0000000000000006",
2052 actual=h1PostMove,
2053 onpass="Mobility: Successfully moved h1 to s6",
acsmars5d8cc862015-09-25 09:44:50 -07002054 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07002055 " to single point intents" +
2056 " with IPV4 type and MAC addresses" +
2057 " in the same VLAN" )
2058
2059 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07002060 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002061 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
2062 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
Jeremy42df2e72016-02-23 16:37:46 -08002063 testResult = main.FALSE
2064 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002065 installResult = main.intentFunction.installHostIntent( main,
2066 name='IPV4 Mobility IPV4',
kelvin-onlabf34a58a2015-07-23 16:41:52 -07002067 onosNode='0',
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002068 host1=host1,
Jeremye0cb5eb2016-01-27 17:39:09 -08002069 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -08002070 if installResult:
2071 testResult = main.intentFunction.testHostIntent( main,
2072 name='Host Mobility IPV4',
2073 intentId = installResult,
2074 onosNode='0',
2075 host1=host1,
2076 host2=host2,
2077 sw1="s6",
2078 sw2="s2",
2079 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08002080 else:
2081 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07002082
2083 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002084 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07002085 onpass=main.assertReturnString,
2086 onfail=main.assertReturnString )
kelvin-onlab016dce22015-08-10 09:54:11 -07002087
2088 main.intentFunction.report( main )
Jeremye0cb5eb2016-01-27 17:39:09 -08002089
2090 def CASE6000( self, main ):
2091 """
2092 Tests Multi to Single Point Intent and Single to Multi Point Intent End Point Failure
2093 """
Jeremy Songster9385d412016-06-02 17:57:36 -07002094 # At some later point discussion on this behavior in MPSP and SPMP intents
2095 # will be reoppened and this test case may need to be updated to reflect
2096 # the outcomes of that discussion
Jeremyd9e4eb12016-04-13 12:09:06 -07002097 if main.initialized == main.FALSE:
2098 main.log.error( "Test components did not start correctly, skipping further tests" )
2099 main.skipCase()
Jeremye0cb5eb2016-01-27 17:39:09 -08002100 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07002101 try:
2102 assert main.CLIs
2103 except AssertionError:
2104 main.log.error( "There is no main.CLIs, skipping test cases" )
2105 main.initialized = main.FALSE
2106 main.skipCase()
2107 try:
2108 assert main.Mininet1
2109 except AssertionError:
2110 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
2111 main.initialized = main.FALSE
2112 main.skipCase()
2113 try:
2114 assert main.numSwitch
2115 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002116 main.log.error( "Place the total number of switch topology in "+\
2117 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07002118 main.initialized = main.FALSE
2119 main.skipCase()
Jeremye0cb5eb2016-01-27 17:39:09 -08002120 main.case( "Test Multi to Single End Point Failure" )
Jeremy Songster9385d412016-06-02 17:57:36 -07002121 main.step( "Installing Multi to Single Point intents with no options set" )
2122 main.assertReturnString = "Assertion results for IPV4 multi to single " +\
2123 "point intent end point failure with no options set\n"
Jeremye0cb5eb2016-01-27 17:39:09 -08002124 senders = [
2125 { "name":"h16", "device":"of:0000000000000006/8" },
2126 { "name":"h24", "device":"of:0000000000000007/8" }
2127 ]
2128 recipients = [
2129 { "name":"h8", "device":"of:0000000000000005/8" }
2130 ]
2131 isolatedSenders = [
2132 { "name":"h24"}
2133 ]
2134 isolatedRecipients = []
2135 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08002136 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08002137 installResult = main.intentFunction.installMultiToSingleIntent(
2138 main,
2139 name="NOOPTION",
2140 senders=senders,
2141 recipients=recipients,
2142 sw1="s5",
2143 sw2="s2" )
2144
2145 if installResult:
2146 testResult = main.intentFunction.testEndPointFail(
2147 main,
2148 intentId=installResult,
2149 name="NOOPTION",
2150 senders=senders,
2151 recipients=recipients,
2152 isolatedSenders=isolatedSenders,
2153 isolatedRecipients=isolatedRecipients,
2154 sw1="s6",
2155 sw2="s2",
2156 sw3="s4",
2157 sw4="s1",
2158 sw5="s3",
2159 expectedLink1=16,
2160 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002161 else:
2162 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002163
2164 utilities.assert_equals( expect=main.TRUE,
2165 actual=testResult,
2166 onpass=main.assertReturnString,
2167 onfail=main.assertReturnString )
2168
Jeremy Songster9385d412016-06-02 17:57:36 -07002169 main.step( "Installing Multi to Single Point intents with partial failure allowed" )
2170
2171 main.assertReturnString = "Assertion results for IPV4 multi to single " +\
2172 "with partial failures allowed\n"
2173 senders = [
2174 { "name":"h16", "device":"of:0000000000000006/8" },
2175 { "name":"h24", "device":"of:0000000000000007/8" }
2176 ]
2177 recipients = [
2178 { "name":"h8", "device":"of:0000000000000005/8" }
2179 ]
2180 isolatedSenders = [
2181 { "name":"h24"}
2182 ]
2183 isolatedRecipients = []
2184 testResult = main.FALSE
2185 installResult = main.FALSE
2186 installResult = main.intentFunction.installMultiToSingleIntent(
2187 main,
2188 name="NOOPTION",
2189 senders=senders,
2190 recipients=recipients,
2191 sw1="s5",
2192 sw2="s2",
2193 partial=True )
2194
2195 if installResult:
2196 testResult = main.intentFunction.testEndPointFail(
2197 main,
2198 intentId=installResult,
2199 name="NOOPTION",
2200 senders=senders,
2201 recipients=recipients,
2202 isolatedSenders=isolatedSenders,
2203 isolatedRecipients=isolatedRecipients,
2204 sw1="s6",
2205 sw2="s2",
2206 sw3="s4",
2207 sw4="s1",
2208 sw5="s3",
2209 expectedLink1=16,
2210 expectedLink2=14,
2211 partial=True )
2212 else:
2213 main.CLIs[ 0 ].removeAllIntents( purge=True )
2214
2215 utilities.assert_equals( expect=main.TRUE,
2216 actual=testResult,
2217 onpass=main.assertReturnString,
2218 onfail=main.assertReturnString )
2219
Jeremye0cb5eb2016-01-27 17:39:09 -08002220 main.step( "NOOPTION: Install and test single point to multi point intents" )
Jeremy Songster9385d412016-06-02 17:57:36 -07002221 main.assertReturnString = "Assertion results for IPV4 single to multi " +\
2222 "point intent with no options set\n"
Jeremye0cb5eb2016-01-27 17:39:09 -08002223 senders = [
2224 { "name":"h8", "device":"of:0000000000000005/8" }
2225 ]
2226 recipients = [
2227 { "name":"h16", "device":"of:0000000000000006/8" },
2228 { "name":"h24", "device":"of:0000000000000007/8" }
2229 ]
Jeremy Songster9385d412016-06-02 17:57:36 -07002230 isolatedSenders = []
2231 isolatedRecipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07002232 { "name":"h24"}
Jeremye0cb5eb2016-01-27 17:39:09 -08002233 ]
2234 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08002235 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08002236 installResult = main.intentFunction.installSingleToMultiIntent(
2237 main,
2238 name="NOOPTION",
2239 senders=senders,
2240 recipients=recipients,
2241 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002242 sw2="s2" )
Jeremye0cb5eb2016-01-27 17:39:09 -08002243
2244 if installResult:
2245 testResult = main.intentFunction.testEndPointFail(
2246 main,
2247 intentId=installResult,
2248 name="NOOPTION",
2249 senders=senders,
2250 recipients=recipients,
2251 isolatedSenders=isolatedSenders,
2252 isolatedRecipients=isolatedRecipients,
2253 sw1="s6",
2254 sw2="s2",
2255 sw3="s4",
2256 sw4="s1",
2257 sw5="s3",
2258 expectedLink1=16,
2259 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002260 else:
2261 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002262
2263 utilities.assert_equals( expect=main.TRUE,
2264 actual=testResult,
2265 onpass=main.assertReturnString,
2266 onfail=main.assertReturnString )
Jeremy Songster9385d412016-06-02 17:57:36 -07002267 # Right now this functionality doesn't work properly in SPMP intents
2268 main.step( "NOOPTION: Install and test single point to multi point " +\
2269 "intents with partial failures allowed" )
2270 main.assertReturnString = "Assertion results for IPV4 single to multi " +\
2271 "point intent with partial failures allowed\n"
2272 senders = [
2273 { "name":"h8", "device":"of:0000000000000005/8" }
2274 ]
2275 recipients = [
2276 { "name":"h16", "device":"of:0000000000000006/8" },
2277 { "name":"h24", "device":"of:0000000000000007/8" }
2278 ]
2279 isolatedSenders = []
2280 isolatedRecipients = [
2281 { "name":"h24"}
2282 ]
2283 testResult = main.FALSE
2284 installResult = main.FALSE
2285 installResult = main.intentFunction.installSingleToMultiIntent(
2286 main,
2287 name="NOOPTION",
2288 senders=senders,
2289 recipients=recipients,
2290 sw1="s5",
2291 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002292 partial=True )
Jeremy Songster9385d412016-06-02 17:57:36 -07002293
2294 if installResult:
2295 testResult = main.intentFunction.testEndPointFail(
2296 main,
2297 intentId=installResult,
2298 name="NOOPTION",
2299 senders=senders,
2300 recipients=recipients,
2301 isolatedSenders=isolatedSenders,
2302 isolatedRecipients=isolatedRecipients,
2303 sw1="s6",
2304 sw2="s2",
2305 sw3="s4",
2306 sw4="s1",
2307 sw5="s3",
2308 expectedLink1=16,
2309 expectedLink2=14,
2310 partial=True )
2311 else:
2312 main.CLIs[ 0 ].removeAllIntents( purge=True )
2313
2314 utilities.assert_equals( expect=main.TRUE,
2315 actual=testResult,
2316 onpass=main.assertReturnString,
2317 onfail=main.assertReturnString )
Jeremye0cb5eb2016-01-27 17:39:09 -08002318
Jeremy2f190ca2016-01-29 15:23:57 -08002319 main.intentFunction.report( main )