blob: 5bcfe62251a435a0128e0dcf3321b39ba36fd57f [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" )
190 packageResult = main.ONOSbench.onosPackage()
191 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 ] )
304 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 ] )
319 except (TypeError,ValueError):
320 main.log.error("Could not load json:" + str( links[ controller ] ) )
321 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 ] )
334 except (TypeError,ValueError):
335 main.log.error("Could not load json:" + str( hosts[ controller ] ) )
336 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" )
586 main.skipCase()
Jeremy42df2e72016-02-23 16:37:46 -0800587 main.case( "Balance mastership of switches" )
588 main.step( "Balancing mastership of switches" )
589
590 balanceResult = main.FALSE
591 balanceResult = utilities.retry( f=main.CLIs[ 0 ].balanceMasters, retValue=main.FALSE, args=[] )
592
593 utilities.assert_equals( expect=main.TRUE,
Jeremy6e9748f2016-03-25 15:03:39 -0700594 actual=balanceResult,
Jeremy42df2e72016-02-23 16:37:46 -0800595 onpass="Successfully balanced mastership of switches",
596 onfail="Failed to balance mastership of switches" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700597 if not balanceResult:
598 main.initialized = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800599
600 def CASE17( self, main ):
601 """
Jeremy6e9748f2016-03-25 15:03:39 -0700602 Use Flow Objectives
603 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700604 if main.initialized == main.FALSE:
605 main.log.error( "Test components did not start correctly, skipping further tests" )
606 main.skipCase()
Jeremy6e9748f2016-03-25 15:03:39 -0700607 main.case( "Enable intent compilation using Flow Objectives" )
608 main.step( "Enabling Flow Objectives" )
609
610 main.flowCompiler = "Flow Objectives"
611
612 cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator"
613
614 stepResult = main.CLIs[ 0 ].setCfg( component=cmd,
615 propName="useFlowObjectives", value="true" )
616
617 utilities.assert_equals( expect=main.TRUE,
618 actual=stepResult,
619 onpass="Successfully activated Flow Objectives",
620 onfail="Failed to activate Flow Objectives" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700621 if not balanceResult:
622 main.initialized = main.FALSE
Jeremy6e9748f2016-03-25 15:03:39 -0700623
624 def CASE18( self, main ):
625 """
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800626 Stop mininet and remove scapy host
627 """
628 main.log.report( "Stop Mininet and Scapy" )
629 main.case( "Stop Mininet and Scapy" )
630 main.caseExplanation = "Stopping the current mininet topology " +\
631 "to start up fresh"
632 main.step( "Stopping and Removing Scapy Host Components" )
633 scapyResult = main.TRUE
634 for host in main.scapyHosts:
635 scapyResult = scapyResult and host.stopScapy()
636 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
637
638 for host in main.scapyHosts:
639 scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
640 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
641
642 main.scapyHosts = []
643 main.scapyHostIPs = []
644
645 utilities.assert_equals( expect=main.TRUE,
646 actual=scapyResult,
647 onpass="Successfully stopped scapy and removed host components",
648 onfail="Failed to stop mininet and scapy" )
649
650 main.step( "Stopping Mininet Topology" )
651 mininetResult = main.Mininet1.stopNet( )
652
653 utilities.assert_equals( expect=main.TRUE,
654 actual=mininetResult,
655 onpass="Successfully stopped mininet and scapy",
656 onfail="Failed to stop mininet and scapy" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700657 # Exit if topology did not load properly
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800658 if not ( mininetResult and scapyResult ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700659 main.cleanup()
660 main.exit()
661
Jeremy Songster17147f22016-05-31 18:30:52 -0700662 def CASE19( self, main ):
663 """
664 Copy the karaf.log files after each testcase cycle
665 """
666 main.log.report( "Copy karaf logs" )
667 main.case( "Copy karaf logs" )
668 main.caseExplanation = "Copying the karaf logs to preserve them through" +\
669 "reinstalling ONOS"
670 main.step( "Copying karaf logs" )
Jeremy Songster31aad312016-06-13 16:32:11 -0700671 stepResult = main.TRUE
672 scpResult = main.TRUE
673 copyResult = main.TRUE
Jeremy Songstercc5414b2016-07-11 10:59:53 -0700674 for i in range( main.numCtrls ):
675 main.node = main.CLIs[ i ]
Jeremy Songster17147f22016-05-31 18:30:52 -0700676 ip = main.ONOSip[ i ]
677 main.node.ip_address = ip
Jeremy Songster31aad312016-06-13 16:32:11 -0700678 scpResult = scpResult and main.ONOSbench.scp( main.node ,
679 "/opt/onos/log/karaf.log",
680 "/tmp/karaf.log",
681 direction="from" )
682 copyResult = copyResult and main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
683 copyFileName=( "karaf.log.node{0}.cycle{1}".format( str( i + 1 ), str( main.cycle ) ) ) )
684 if scpResult and copyResult:
685 stepResult = main.TRUE and stepResult
686 else:
687 stepResult = main.FALSE and stepResult
Jeremy Songster31aad312016-06-13 16:32:11 -0700688 utilities.assert_equals( expect=main.TRUE,
689 actual=stepResult,
690 onpass="Successfully copied remote ONOS logs",
691 onfail="Failed to copy remote ONOS logs" )
Jeremy Songster17147f22016-05-31 18:30:52 -0700692
kelvin-onlabb769f562015-07-15 17:05:10 -0700693 def CASE1000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700694 """
695 Add host intents between 2 host:
696 - Discover hosts
697 - Add host intents
698 - Check intents
699 - Verify flows
700 - Ping hosts
701 - Reroute
702 - Link down
703 - Verify flows
704 - Check topology
705 - Ping hosts
706 - Link up
707 - Verify flows
708 - Check topology
709 - Ping hosts
710 - Remove intents
711 """
712 import time
713 import json
714 import re
Jeremyd9e4eb12016-04-13 12:09:06 -0700715 if main.initialized == main.FALSE:
716 main.log.error( "Test components did not start correctly, skipping further tests" )
717 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700718 # Assert variables - These variable's name|format must be followed
719 # if you want to use the wrapper function
720 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -0700721 try:
722 assert main.CLIs
723 except AssertionError:
724 main.log.error( "There is no main.CLIs, skipping test cases" )
725 main.initialized = main.FALSE
726 main.skipCase()
727 try:
728 assert main.Mininet1
729 except AssertionError:
730 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
731 main.initialized = main.FALSE
732 main.skipCase()
733 try:
734 assert main.numSwitch
735 except AssertionError:
736 main.log.error( "Place the total number of switch topology in \
737 main.numSwitch" )
738 main.initialized = main.FALSE
739 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700740
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800741 # Save leader candidates
acsmarse6b410f2015-07-17 14:39:34 -0700742 intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
743
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700744 main.testName = "Host Intents"
745 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -0700746 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -0700747 main.caseExplanation = "This test case tests Host intents using " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700748 str( main.numCtrls ) + " node(s) cluster;\n" +\
749 "Different type of hosts will be tested in " +\
750 "each step such as IPV4, Dual stack, VLAN " +\
Jeremyeb51cb12016-03-28 17:53:35 -0700751 "etc;\nThe test will use OF " + main.OFProtocol +\
752 " OVS running in Mininet and compile intents" +\
Jeremy6e9748f2016-03-25 15:03:39 -0700753 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700754
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700755 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700756 main.assertReturnString = "Assertion Result for IPV4 host intent with mac addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800757 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
758 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
759 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800760 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800761 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700762 name='IPV4',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800763 onosNode='0',
764 host1=host1,
765 host2=host2)
766 if installResult:
767 testResult = main.intentFunction.testHostIntent( main,
768 name='IPV4',
769 intentId = installResult,
770 onosNode='0',
771 host1=host1,
772 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700773 sw1='s5',
774 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800775 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800776 else:
777 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800778
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700779 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800780 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700781 onpass=main.assertReturnString,
782 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700783
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700784 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700785 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800786 host1 = { "name":"h3","id":"00:00:00:00:00:03/-1" }
787 host2 = { "name":"h11","id":"00:00:00:00:00:0B/-1 "}
788 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800789 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800790 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700791 name='DUALSTACK',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800792 onosNode='0',
793 host1=host1,
794 host2=host2)
795
796 if installResult:
797 testResult = main.intentFunction.testHostIntent( main,
798 name='DUALSTACK',
799 intentId = installResult,
800 onosNode='0',
801 host1=host1,
802 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700803 sw1='s5',
804 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800805 expectedLink = 18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700806
807 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800808 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700809 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800810 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700811
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700812 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700813 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800814 host1 = { "name":"h1" }
815 host2 = { "name":"h11" }
816 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800817 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800818 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700819 name='DUALSTACK2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800820 onosNode='0',
821 host1=host1,
822 host2=host2)
823
824 if installResult:
825 testResult = main.intentFunction.testHostIntent( main,
826 name='DUALSTACK2',
827 intentId = installResult,
828 onosNode='0',
829 host1=host1,
830 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700831 sw1='s5',
832 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800833 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800834 else:
835 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700836
837 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800838 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700839 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800840 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700841
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700842 main.step( "1HOP: Add host intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -0700843 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800844 host1 = { "name":"h1" }
845 host2 = { "name":"h3" }
846 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800847 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800848 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700849 name='1HOP',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800850 onosNode='0',
851 host1=host1,
852 host2=host2)
853
854 if installResult:
855 testResult = main.intentFunction.testHostIntent( main,
856 name='1HOP',
857 intentId = installResult,
858 onosNode='0',
859 host1=host1,
860 host2=host2,
861 sw1='s5',
862 sw2='s2',
863 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800864 else:
865 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700866
867 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800868 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700869 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800870 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700871
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700872 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
acsmars5d8cc862015-09-25 09:44:50 -0700873 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jeremy Songster832f9e92016-05-05 14:30:49 -0700874 host1 = { "name":"h4","id":"00:00:00:00:00:04/100", "vlan":"100" }
875 host2 = { "name":"h12","id":"00:00:00:00:00:0C/100", "vlan":"100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800876 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800877 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800878 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700879 name='VLAN1',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800880 onosNode='0',
881 host1=host1,
882 host2=host2)
883
884 if installResult:
885 testResult = main.intentFunction.testHostIntent( main,
886 name='VLAN1',
887 intentId = installResult,
888 onosNode='0',
889 host1=host1,
890 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700891 sw1='s5',
892 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800893 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800894 else:
895 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700896
897 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800898 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700899 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800900 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700901
Jeremy Songsterff553672016-05-12 17:06:23 -0700902 main.step( "VLAN2: Add vlan host intents between h4 and h13" )
903 main.assertReturnString = "Assertion Result vlan IPV4\n"
904 host1 = { "name":"h5", "vlan":"200" }
905 host2 = { "name":"h12", "vlan":"100" }
906 testResult = main.FALSE
907 installResult = main.FALSE
908 installResult = main.intentFunction.installHostIntent( main,
909 name='VLAN2',
910 onosNode='0',
911 host1=host1,
912 host2=host2)
913
914 if installResult:
915 testResult = main.intentFunction.testHostIntent( main,
916 name='VLAN2',
917 intentId = installResult,
918 onosNode='0',
919 host1=host1,
920 host2=host2,
921 sw1='s5',
922 sw2='s2',
923 expectedLink = 18)
924 else:
925 main.CLIs[ 0 ].removeAllIntents( purge=True )
926
927 utilities.assert_equals( expect=main.TRUE,
928 actual=testResult,
929 onpass=main.assertReturnString,
930 onfail=main.assertReturnString)
931
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800932 main.step( "Confirm that ONOS leadership is unchanged")
acsmarse6b410f2015-07-17 14:39:34 -0700933 intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
934 main.intentFunction.checkLeaderChange( intentLeadersOld,
935 intentLeadersNew )
936
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800937 utilities.assert_equals( expect=main.TRUE,
938 actual=testResult,
939 onpass="ONOS Leaders Unchanged",
940 onfail="ONOS Leader Mismatch")
941
kelvin-onlab016dce22015-08-10 09:54:11 -0700942 main.intentFunction.report( main )
943
kelvin-onlabb769f562015-07-15 17:05:10 -0700944 def CASE2000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700945 """
946 Add point intents between 2 hosts:
947 - Get device ids | ports
948 - Add point intents
949 - Check intents
950 - Verify flows
951 - Ping hosts
952 - Reroute
953 - Link down
954 - Verify flows
955 - Check topology
956 - Ping hosts
957 - Link up
958 - Verify flows
959 - Check topology
960 - Ping hosts
961 - Remove intents
962 """
963 import time
964 import json
965 import re
Jeremyd9e4eb12016-04-13 12:09:06 -0700966 if main.initialized == main.FALSE:
967 main.log.error( "Test components did not start correctly, skipping further tests" )
968 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700969 # Assert variables - These variable's name|format must be followed
970 # if you want to use the wrapper function
971 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -0700972 try:
973 assert main.CLIs
974 except AssertionError:
975 main.log.error( "There is no main.CLIs, skipping test cases" )
976 main.initialized = main.FALSE
977 main.skipCase()
978 try:
979 assert main.Mininet1
980 except AssertionError:
981 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
982 main.initialized = main.FALSE
983 main.skipCase()
984 try:
985 assert main.numSwitch
986 except AssertionError:
987 main.log.error( "Place the total number of switch topology in \
988 main.numSwitch" )
989 main.initialized = main.FALSE
990 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700991
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700992 main.testName = "Point Intents"
993 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -0700994 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -0700995 main.caseExplanation = "This test case will test point to point" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700996 " intents using " + str( main.numCtrls ) +\
997 " node(s) cluster;\n" +\
998 "Different type of hosts will be tested in " +\
999 "each step such as IPV4, Dual stack, VLAN etc" +\
1000 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001001 " OVS running in Mininet and compile intents" +\
1002 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001003
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001004 # No option point intents
1005 main.step( "NOOPTION: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001006 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001007 senders = [
1008 { "name":"h1","device":"of:0000000000000005/1" }
1009 ]
1010 recipients = [
1011 { "name":"h9","device":"of:0000000000000006/1" }
1012 ]
Jeremy42df2e72016-02-23 16:37:46 -08001013 testResult = main.FALSE
1014 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001015 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001016 main,
1017 name="NOOPTION",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001018 senders=senders,
1019 recipients=recipients )
1020
1021 if installResult:
1022 testResult = main.intentFunction.testPointIntent(
1023 main,
1024 intentId=installResult,
1025 name="NOOPTION",
1026 senders=senders,
1027 recipients=recipients,
1028 sw1="s5",
1029 sw2="s2",
1030 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001031 else:
1032 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001033
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001034 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001035 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001036 onpass=main.assertReturnString,
1037 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001038
1039 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -07001040 main.step( "IPV4: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001041 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001042 senders = [
1043 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1044 ]
1045 recipients = [
1046 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09" }
1047 ]
Jeremy42df2e72016-02-23 16:37:46 -08001048 testResult = main.FALSE
1049 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001050 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001051 main,
1052 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001053 senders=senders,
1054 recipients=recipients,
1055 ethType="IPV4" )
1056
1057 if installResult:
1058 testResult = main.intentFunction.testPointIntent(
1059 main,
1060 intentId=installResult,
1061 name="IPV4",
1062 senders=senders,
1063 recipients=recipients,
1064 sw1="s5",
1065 sw2="s2",
1066 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001067 else:
1068 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001069
1070 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001071 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001072 onpass=main.assertReturnString,
1073 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001074 main.step( "IPV4_2: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001075 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001076 senders = [
1077 { "name":"h1","device":"of:0000000000000005/1" }
1078 ]
1079 recipients = [
1080 { "name":"h9","device":"of:0000000000000006/1" }
1081 ]
Jeremy42df2e72016-02-23 16:37:46 -08001082 testResult = main.FALSE
1083 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001084 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001085 main,
1086 name="IPV4_2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001087 senders=senders,
1088 recipients=recipients,
1089 ethType="IPV4" )
1090
1091 if installResult:
1092 testResult = main.intentFunction.testPointIntent(
1093 main,
1094 intentId=installResult,
1095 name="IPV4_2",
1096 senders=senders,
1097 recipients=recipients,
1098 sw1="s5",
1099 sw2="s2",
1100 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001101 else:
1102 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001103
1104 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001105 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001106 onpass=main.assertReturnString,
1107 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001108
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001109 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001110 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001111 senders = [
1112 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01",
Jeremy6f000c62016-02-25 17:02:28 -08001113 "ip":( main.h1.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001114 ]
1115 recipients = [
1116 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09",
Jeremy6f000c62016-02-25 17:02:28 -08001117 "ip":( main.h9.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001118 ]
Jeremy6f000c62016-02-25 17:02:28 -08001119 ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ]
kelvin-onlab79ce0492015-07-27 16:14:39 -07001120 # Uneccessary, not including this in the selectors
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001121 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
1122 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
Jeremy42df2e72016-02-23 16:37:46 -08001123 testResult = main.FALSE
1124 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001125 installResult = main.intentFunction.installPointIntent(
1126 main,
1127 name="SDNIP-ICMP",
1128 senders=senders,
1129 recipients=recipients,
1130 ethType="IPV4",
1131 ipProto=ipProto,
1132 tcpSrc=tcpSrc,
1133 tcpDst=tcpDst )
1134
1135 if installResult:
1136 testResult = main.intentFunction.testPointIntent(
1137 main,
1138 intentId=installResult,
1139 name="SDNIP_ICMP",
1140 senders=senders,
1141 recipients=recipients,
1142 sw1="s5",
1143 sw2="s2",
Jeremy Songstere405d3d2016-05-17 11:18:57 -07001144 expectedLink=18,
1145 useTCP=True)
Jeremy42df2e72016-02-23 16:37:46 -08001146 else:
1147 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabb769f562015-07-15 17:05:10 -07001148
1149 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001150 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001151 onpass=main.assertReturnString,
1152 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001153
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001154 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001155 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
kelvin-onlabb769f562015-07-15 17:05:10 -07001156 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
1157 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab58dc39e2015-08-06 08:11:09 -07001158 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
1159 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlabb769f562015-07-15 17:05:10 -07001160 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
1161 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
1162 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
1163
kelvin-onlab58dc39e2015-08-06 08:11:09 -07001164 stepResult = main.intentFunction.pointIntentTcp(
kelvin-onlabb769f562015-07-15 17:05:10 -07001165 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001166 name="SDNIP-TCP",
kelvin-onlabb769f562015-07-15 17:05:10 -07001167 host1="h1",
1168 host2="h9",
1169 deviceId1="of:0000000000000005/1",
1170 deviceId2="of:0000000000000006/1",
1171 mac1=mac1,
1172 mac2=mac2,
1173 ethType="IPV4",
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001174 ipProto=ipProto,
1175 ip1=ip1,
1176 ip2=ip2,
1177 tcp1=tcp1,
1178 tcp2=tcp2 )
kelvin-onlabb769f562015-07-15 17:05:10 -07001179
1180 utilities.assert_equals( expect=main.TRUE,
Jeremy6f000c62016-02-25 17:02:28 -08001181 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -07001182 onpass=main.assertReturnString,
1183 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001184
acsmars5d8cc862015-09-25 09:44:50 -07001185 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
1186 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001187 senders = [
1188 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1189 ]
1190 recipients = [
1191 { "name":"h11","device":"of:0000000000000006/3","mac":"00:00:00:00:00:0B" }
1192 ]
Jeremy42df2e72016-02-23 16:37:46 -08001193 testResult = main.FALSE
1194 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001195 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001196 main,
1197 name="DUALSTACK1",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001198 senders=senders,
1199 recipients=recipients,
1200 ethType="IPV4" )
1201
1202 if installResult:
1203 testResult = main.intentFunction.testPointIntent(
1204 main,
1205 intentId=installResult,
1206 name="DUALSTACK1",
1207 senders=senders,
1208 recipients=recipients,
1209 sw1="s5",
1210 sw2="s2",
1211 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001212 else:
1213 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001214
1215 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001216 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001217 onpass=main.assertReturnString,
1218 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001219
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001220 main.step( "VLAN: Add point intents between h5 and h21" )
acsmars5d8cc862015-09-25 09:44:50 -07001221 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001222 senders = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001223 { "name":"h5","device":"of:0000000000000005/5","mac":"00:00:00:00:00:05", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001224 ]
1225 recipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001226 { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001227 ]
Jeremy42df2e72016-02-23 16:37:46 -08001228 testResult = main.FALSE
1229 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001230 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001231 main,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001232 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001233 senders=senders,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001234 recipients=recipients)
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001235
1236 if installResult:
1237 testResult = main.intentFunction.testPointIntent(
1238 main,
1239 intentId=installResult,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001240 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001241 senders=senders,
1242 recipients=recipients,
1243 sw1="s5",
1244 sw2="s2",
1245 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001246
1247 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001248 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001249 onpass=main.assertReturnString,
1250 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001251
Jeremy Songsterff553672016-05-12 17:06:23 -07001252 main.step( "VLAN: Add point intents between h5 and h21" )
1253 main.assertReturnString = "Assertion Result for VLAN IPV4 point intents with VLAN treatment\n"
1254 senders = [
1255 { "name":"h4", "vlan":"100" }
1256 ]
1257 recipients = [
1258 { "name":"h21", "vlan":"200" }
1259 ]
1260 testResult = main.FALSE
1261 installResult = main.FALSE
1262 installResult = main.intentFunction.installPointIntent(
1263 main,
1264 name="VLAN2",
1265 senders=senders,
1266 recipients=recipients,
1267 setVlan=200)
1268
1269 if installResult:
1270 testResult = main.intentFunction.testPointIntent(
1271 main,
1272 intentId=installResult,
1273 name="VLAN2",
1274 senders=senders,
1275 recipients=recipients,
1276 sw1="s5",
1277 sw2="s2",
1278 expectedLink=18)
1279
1280 utilities.assert_equals( expect=main.TRUE,
1281 actual=testResult,
1282 onpass=main.assertReturnString,
1283 onfail=main.assertReturnString )
1284
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001285 main.step( "1HOP: Add point intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -07001286 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001287 senders = [
1288 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1289 ]
1290 recipients = [
1291 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1292 ]
Jeremy42df2e72016-02-23 16:37:46 -08001293 testResult = main.FALSE
1294 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001295 installResult = main.intentFunction.installPointIntent(
1296 main,
1297 name="1HOP IPV4",
1298 senders=senders,
1299 recipients=recipients,
1300 ethType="IPV4" )
1301
1302 if installResult:
1303 testResult = main.intentFunction.testPointIntent(
1304 main,
1305 intentId=installResult,
1306 name="1HOP IPV4",
1307 senders=senders,
1308 recipients=recipients,
1309 sw1="s5",
1310 sw2="s2",
1311 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001312 else:
1313 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001314
1315 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001316 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001317 onpass=main.assertReturnString,
1318 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001319
kelvin-onlab016dce22015-08-10 09:54:11 -07001320 main.intentFunction.report( main )
1321
kelvin-onlabb769f562015-07-15 17:05:10 -07001322 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001323 """
1324 Add single point to multi point intents
1325 - Get device ids
1326 - Add single point to multi point intents
1327 - Check intents
1328 - Verify flows
1329 - Ping hosts
1330 - Reroute
1331 - Link down
1332 - Verify flows
1333 - Check topology
1334 - Ping hosts
1335 - Link up
1336 - Verify flows
1337 - Check topology
1338 - Ping hosts
1339 - Remove intents
1340 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001341 if main.initialized == main.FALSE:
1342 main.log.error( "Test components did not start correctly, skipping further tests" )
1343 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001344 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001345 try:
1346 assert main.CLIs
1347 except AssertionError:
1348 main.log.error( "There is no main.CLIs, skipping test cases" )
1349 main.initialized = main.FALSE
1350 main.skipCase()
1351 try:
1352 assert main.Mininet1
1353 except AssertionError:
1354 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1355 main.initialized = main.FALSE
1356 main.skipCase()
1357 try:
1358 assert main.numSwitch
1359 except AssertionError:
1360 main.log.error( "Place the total number of switch topology in \
1361 main.numSwitch" )
1362 main.initialized = main.FALSE
1363 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001364
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001365 main.testName = "Single to Multi Point Intents"
1366 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001367 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001368 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001369 " multi point intents using " +\
1370 str( main.numCtrls ) + " node(s) cluster;\n" +\
1371 "Different type of hosts will be tested in " +\
1372 "each step such as IPV4, Dual stack, VLAN etc" +\
1373 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001374 " OVS running in Mininet and compile intents" +\
1375 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001376
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001377 main.step( "NOOPTION: Install and test single point to multi point intents" )
1378 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
1379 senders = [
1380 { "name":"h8", "device":"of:0000000000000005/8" }
1381 ]
1382 recipients = [
1383 { "name":"h16", "device":"of:0000000000000006/8" },
1384 { "name":"h24", "device":"of:0000000000000007/8" }
1385 ]
1386 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1387 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1388 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001389 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001390 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001391 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001392 name="NOOPTION",
1393 senders=senders,
1394 recipients=recipients,
1395 sw1="s5",
1396 sw2="s2")
1397
1398 if installResult:
1399 testResult = main.intentFunction.testPointIntent(
1400 main,
1401 intentId=installResult,
1402 name="NOOPTION",
1403 senders=senders,
1404 recipients=recipients,
1405 badSenders=badSenders,
1406 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001407 sw1="s5",
1408 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001409 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001410 else:
1411 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001412
1413 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001414 actual=testResult,
1415 onpass=main.assertReturnString,
1416 onfail=main.assertReturnString )
1417
1418 main.step( "IPV4: Install and test single point to multi point intents" )
1419 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses\n"
1420 senders = [
1421 { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" }
1422 ]
1423 recipients = [
1424 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1425 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1426 ]
1427 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1428 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1429 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001430 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001431 installResult = main.intentFunction.installSingleToMultiIntent(
1432 main,
1433 name="IPV4",
1434 senders=senders,
1435 recipients=recipients,
1436 ethType="IPV4",
1437 sw1="s5",
1438 sw2="s2")
1439
1440 if installResult:
1441 testResult = main.intentFunction.testPointIntent(
1442 main,
1443 intentId=installResult,
1444 name="IPV4",
1445 senders=senders,
1446 recipients=recipients,
1447 badSenders=badSenders,
1448 badRecipients=badRecipients,
1449 sw1="s5",
1450 sw2="s2",
1451 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001452 else:
1453 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001454
1455 utilities.assert_equals( expect=main.TRUE,
1456 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001457 onpass=main.assertReturnString,
1458 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001459
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001460 main.step( "IPV4_2: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001461 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 -08001462 senders = [
1463 { "name":"h8", "device":"of:0000000000000005/8" }
1464 ]
1465 recipients = [
1466 { "name":"h16", "device":"of:0000000000000006/8" },
1467 { "name":"h24", "device":"of:0000000000000007/8" }
1468 ]
1469 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1470 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1471 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001472 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001473 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001474 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001475 name="IPV4_2",
1476 senders=senders,
1477 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001478 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001479 sw1="s5",
1480 sw2="s2")
1481
1482 if installResult:
1483 testResult = main.intentFunction.testPointIntent(
1484 main,
1485 intentId=installResult,
1486 name="IPV4_2",
1487 senders=senders,
1488 recipients=recipients,
1489 badSenders=badSenders,
1490 badRecipients=badRecipients,
1491 sw1="s5",
1492 sw2="s2",
1493 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001494 else:
1495 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001496
1497 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001498 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001499 onpass=main.assertReturnString,
1500 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001501
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001502 main.step( "VLAN: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001503 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 -08001504 senders = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001505 { "name":"h4", "device":"of:0000000000000005/4", "mac":"00:00:00:00:00:04", "vlan":"100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001506 ]
1507 recipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001508 { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C", "vlan":"100" },
1509 { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14", "vlan":"100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001510 ]
1511 badSenders=[ { "name":"h13" } ] # Senders that are not in the intent
1512 badRecipients=[ { "name":"h21" } ] # Recipients that are not in the intent
1513 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001514 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001515 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001516 main,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001517 name="VLAN`",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001518 senders=senders,
1519 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001520 sw1="s5",
1521 sw2="s2")
1522
1523 if installResult:
1524 testResult = main.intentFunction.testPointIntent(
1525 main,
1526 intentId=installResult,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001527 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001528 senders=senders,
1529 recipients=recipients,
1530 badSenders=badSenders,
1531 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001532 sw1="s5",
1533 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001534 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001535 else:
1536 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001537
1538 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001539 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001540 onpass=main.assertReturnString,
1541 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001542
Jeremy Songsterff553672016-05-12 17:06:23 -07001543 main.step( "VLAN: Add single point to multi point intents" )
1544 main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n"
1545 senders = [
1546 { "name":"h5", "vlan":"200" }
1547 ]
1548 recipients = [
1549 { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C", "vlan":"100" },
1550 { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14", "vlan":"100" }
1551 ]
1552 badSenders=[ { "name":"h13" } ] # Senders that are not in the intent
1553 badRecipients=[ { "name":"h21" } ] # Recipients that are not in the intent
1554 testResult = main.FALSE
1555 installResult = main.FALSE
1556 installResult = main.intentFunction.installSingleToMultiIntent(
1557 main,
1558 name="VLAN2",
1559 senders=senders,
1560 recipients=recipients,
1561 sw1="s5",
1562 sw2="s2",
1563 setVlan=100)
1564
1565 if installResult:
1566 testResult = main.intentFunction.testPointIntent(
1567 main,
1568 intentId=installResult,
1569 name="VLAN2",
1570 senders=senders,
1571 recipients=recipients,
1572 badSenders=badSenders,
1573 badRecipients=badRecipients,
1574 sw1="s5",
1575 sw2="s2",
1576 expectedLink=18)
1577 else:
1578 main.CLIs[ 0 ].removeAllIntents( purge=True )
1579
1580 utilities.assert_equals( expect=main.TRUE,
1581 actual=testResult,
1582 onpass=main.assertReturnString,
1583 onfail=main.assertReturnString )
1584
kelvin-onlab016dce22015-08-10 09:54:11 -07001585 main.intentFunction.report( main )
1586
kelvin-onlabb769f562015-07-15 17:05:10 -07001587 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001588 """
1589 Add multi point to single point intents
1590 - Get device ids
1591 - Add multi point to single point intents
1592 - Check intents
1593 - Verify flows
1594 - Ping hosts
1595 - Reroute
1596 - Link down
1597 - Verify flows
1598 - Check topology
1599 - Ping hosts
1600 - Link up
1601 - Verify flows
1602 - Check topology
1603 - Ping hosts
1604 - Remove intents
1605 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001606 if main.initialized == main.FALSE:
1607 main.log.error( "Test components did not start correctly, skipping further tests" )
1608 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001609 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001610 try:
1611 assert main.CLIs
1612 except AssertionError:
1613 main.log.error( "There is no main.CLIs, skipping test cases" )
1614 main.initialized = main.FALSE
1615 main.skipCase()
1616 try:
1617 assert main.Mininet1
1618 except AssertionError:
1619 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1620 main.initialized = main.FALSE
1621 main.skipCase()
1622 try:
1623 assert main.numSwitch
1624 except AssertionError:
1625 main.log.error( "Place the total number of switch topology in \
1626 main.numSwitch" )
1627 main.initialized = main.FALSE
1628 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001629
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001630 main.testName = "Multi To Single Point Intents"
1631 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001632 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001633 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001634 " multi point intents using " +\
1635 str( main.numCtrls ) + " node(s) cluster;\n" +\
1636 "Different type of hosts will be tested in " +\
1637 "each step such as IPV4, Dual stack, VLAN etc" +\
1638 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001639 " OVS running in Mininet and compile intents" +\
1640 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001641
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001642 main.step( "NOOPTION: Add multi point to single point intents" )
1643 main.assertReturnString = "Assertion results for NOOPTION multi to single point intent\n"
1644 senders = [
1645 { "name":"h16", "device":"of:0000000000000006/8" },
1646 { "name":"h24", "device":"of:0000000000000007/8" }
1647 ]
1648 recipients = [
1649 { "name":"h8", "device":"of:0000000000000005/8" }
1650 ]
1651 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1652 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1653 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001654 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001655 installResult = main.intentFunction.installMultiToSingleIntent(
1656 main,
1657 name="NOOPTION",
1658 senders=senders,
1659 recipients=recipients,
1660 sw1="s5",
Jeremye0cb5eb2016-01-27 17:39:09 -08001661 sw2="s2" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001662
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001663 if installResult:
1664 testResult = main.intentFunction.testPointIntent(
1665 main,
1666 intentId=installResult,
1667 name="NOOPTION",
1668 senders=senders,
1669 recipients=recipients,
1670 badSenders=badSenders,
1671 badRecipients=badRecipients,
1672 sw1="s5",
1673 sw2="s2",
Jeremye0cb5eb2016-01-27 17:39:09 -08001674 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001675 else:
1676 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001677
1678 utilities.assert_equals( expect=main.TRUE,
1679 actual=testResult,
1680 onpass=main.assertReturnString,
1681 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001682
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001683 main.step( "IPV4: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001684 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 -08001685 senders = [
1686 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1687 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1688 ]
1689 recipients = [
1690 { "name":"h8", "device":"of:0000000000000005/8", "mac":"00:00:00:00:00:08" }
1691 ]
1692 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1693 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1694 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001695 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001696 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001697 main,
1698 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001699 senders=senders,
1700 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001701 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001702 sw1="s5",
1703 sw2="s2")
1704
1705 if installResult:
1706 testResult = main.intentFunction.testPointIntent(
1707 main,
1708 intentId=installResult,
1709 name="IPV4",
1710 senders=senders,
1711 recipients=recipients,
1712 badSenders=badSenders,
1713 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001714 sw1="s5",
1715 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001716 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001717 else:
1718 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001719
1720 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001721 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001722 onpass=main.assertReturnString,
1723 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001724
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001725 main.step( "IPV4_2: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001726 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 -08001727 senders = [
1728 { "name":"h16", "device":"of:0000000000000006/8" },
1729 { "name":"h24", "device":"of:0000000000000007/8" }
1730 ]
1731 recipients = [
1732 { "name":"h8", "device":"of:0000000000000005/8" }
1733 ]
1734 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1735 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1736 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001737 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001738 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001739 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001740 name="IPV4_2",
1741 senders=senders,
1742 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001743 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001744 sw1="s5",
1745 sw2="s2")
1746
1747 if installResult:
1748 testResult = main.intentFunction.testPointIntent(
1749 main,
1750 intentId=installResult,
1751 name="IPV4_2",
1752 senders=senders,
1753 recipients=recipients,
1754 badSenders=badSenders,
1755 badRecipients=badRecipients,
1756 sw1="s5",
1757 sw2="s2",
1758 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001759 else:
1760 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001761
1762 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001763 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001764 onpass=main.assertReturnString,
1765 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001766
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001767 main.step( "VLAN: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001768 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 -08001769 senders = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001770 { "name":"h13", "device":"of:0000000000000006/5", "vlan":"200" },
1771 { "name":"h21", "device":"of:0000000000000007/5", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001772 ]
1773 recipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001774 { "name":"h5", "device":"of:0000000000000005/5", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001775 ]
1776 badSenders=[ { "name":"h12" } ] # Senders that are not in the intent
1777 badRecipients=[ { "name":"h20" } ] # Recipients that are not in the intent
1778 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001779 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001780 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001781 main,
1782 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001783 senders=senders,
1784 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001785 sw1="s5",
1786 sw2="s2")
1787
1788 if installResult:
1789 testResult = main.intentFunction.testPointIntent(
1790 main,
1791 intentId=installResult,
1792 name="VLAN",
1793 senders=senders,
1794 recipients=recipients,
1795 badSenders=badSenders,
1796 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001797 sw1="s5",
1798 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001799 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001800 else:
1801 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001802
1803 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001804 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001805 onpass=main.assertReturnString,
1806 onfail=main.assertReturnString )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001807
Jeremy Songsterff553672016-05-12 17:06:23 -07001808 # Right now this fails because of this bug: https://jira.onosproject.org/browse/ONOS-4383
1809 main.step( "VLAN: Add multi point to single point intents" )
1810 main.assertReturnString = "Assertion results for multi to single point intent with VLAN ID treatment\n"
1811 senders = [
1812 { "name":"h13", "device":"of:0000000000000006/5", "vlan":"200" },
1813 { "name":"h21", "device":"of:0000000000000007/5", "vlan":"200" }
1814 ]
1815 recipients = [
1816 { "name":"h4", "vlan":"100" }
1817 ]
1818 badSenders=[ { "name":"h12" } ] # Senders that are not in the intent
1819 badRecipients=[ { "name":"h20" } ] # Recipients that are not in the intent
1820 testResult = main.FALSE
1821 installResult = main.FALSE
1822 installResult = main.intentFunction.installMultiToSingleIntent(
1823 main,
1824 name="VLAN2",
1825 senders=senders,
1826 recipients=recipients,
1827 sw1="s5",
1828 sw2="s2",
1829 setVlan=100)
1830
1831 if installResult:
1832 testResult = main.intentFunction.testPointIntent(
1833 main,
1834 intentId=installResult,
1835 name="VLAN2",
1836 senders=senders,
1837 recipients=recipients,
1838 badSenders=badSenders,
1839 badRecipients=badRecipients,
1840 sw1="s5",
1841 sw2="s2",
1842 expectedLink=18)
1843 else:
1844 main.CLIs[ 0 ].removeAllIntents( purge=True )
1845
1846 utilities.assert_equals( expect=main.TRUE,
1847 actual=testResult,
1848 onpass=main.assertReturnString,
1849 onfail=main.assertReturnString )
1850
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001851 main.intentFunction.report( main )
1852
acsmars1ff5e052015-07-23 11:27:48 -07001853 def CASE5000( self, main ):
1854 """
acsmars5d8cc862015-09-25 09:44:50 -07001855 Tests Host Mobility
1856 Modifies the topology location of h1
acsmars1ff5e052015-07-23 11:27:48 -07001857 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001858 if main.initialized == main.FALSE:
1859 main.log.error( "Test components did not start correctly, skipping further tests" )
1860 main.skipCase()
acsmars1ff5e052015-07-23 11:27:48 -07001861 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001862 try:
1863 assert main.CLIs
1864 except AssertionError:
1865 main.log.error( "There is no main.CLIs, skipping test cases" )
1866 main.initialized = main.FALSE
1867 main.skipCase()
1868 try:
1869 assert main.Mininet1
1870 except AssertionError:
1871 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1872 main.initialized = main.FALSE
1873 main.skipCase()
1874 try:
1875 assert main.numSwitch
1876 except AssertionError:
1877 main.log.error( "Place the total number of switch topology in \
1878 main.numSwitch" )
1879 main.initialized = main.FALSE
1880 main.skipCase()
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001881 main.case( "Test host mobility with host intents " )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001882 main.step( "Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07001883 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1884
Jeremy2f190ca2016-01-29 15:23:57 -08001885 main.log.info( "Moving h1 from s5 to s6")
acsmars1ff5e052015-07-23 11:27:48 -07001886 main.Mininet1.moveHost( "h1","s5","s6" )
1887
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001888 # Send discovery ping from moved host
1889 # Moving the host brings down the default interfaces and creates a new one.
1890 # Scapy is restarted on this host to detect the new interface
1891 main.h1.stopScapy()
1892 main.h1.startScapy()
1893
1894 # Discover new host location in ONOS and populate host data.
1895 # Host 1 IP and MAC should be unchanged
1896 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
1897 main.intentFunction.populateHostData( main )
1898
acsmars1ff5e052015-07-23 11:27:48 -07001899 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1900
1901 utilities.assert_equals( expect="of:0000000000000006",
1902 actual=h1PostMove,
1903 onpass="Mobility: Successfully moved h1 to s6",
acsmars5d8cc862015-09-25 09:44:50 -07001904 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001905 " to single point intents" +
1906 " with IPV4 type and MAC addresses" +
1907 " in the same VLAN" )
1908
1909 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001910 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001911 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
1912 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
Jeremy42df2e72016-02-23 16:37:46 -08001913 testResult = main.FALSE
1914 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001915 installResult = main.intentFunction.installHostIntent( main,
1916 name='IPV4 Mobility IPV4',
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001917 onosNode='0',
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001918 host1=host1,
Jeremye0cb5eb2016-01-27 17:39:09 -08001919 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -08001920 if installResult:
1921 testResult = main.intentFunction.testHostIntent( main,
1922 name='Host Mobility IPV4',
1923 intentId = installResult,
1924 onosNode='0',
1925 host1=host1,
1926 host2=host2,
1927 sw1="s6",
1928 sw2="s2",
1929 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001930 else:
1931 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001932
1933 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001934 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001935 onpass=main.assertReturnString,
1936 onfail=main.assertReturnString )
kelvin-onlab016dce22015-08-10 09:54:11 -07001937
1938 main.intentFunction.report( main )
Jeremye0cb5eb2016-01-27 17:39:09 -08001939
1940 def CASE6000( self, main ):
1941 """
1942 Tests Multi to Single Point Intent and Single to Multi Point Intent End Point Failure
1943 """
Jeremy Songster9385d412016-06-02 17:57:36 -07001944 # At some later point discussion on this behavior in MPSP and SPMP intents
1945 # will be reoppened and this test case may need to be updated to reflect
1946 # the outcomes of that discussion
Jeremyd9e4eb12016-04-13 12:09:06 -07001947 if main.initialized == main.FALSE:
1948 main.log.error( "Test components did not start correctly, skipping further tests" )
1949 main.skipCase()
Jeremye0cb5eb2016-01-27 17:39:09 -08001950 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001951 try:
1952 assert main.CLIs
1953 except AssertionError:
1954 main.log.error( "There is no main.CLIs, skipping test cases" )
1955 main.initialized = main.FALSE
1956 main.skipCase()
1957 try:
1958 assert main.Mininet1
1959 except AssertionError:
1960 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1961 main.initialized = main.FALSE
1962 main.skipCase()
1963 try:
1964 assert main.numSwitch
1965 except AssertionError:
1966 main.log.error( "Place the total number of switch topology in \
1967 main.numSwitch" )
1968 main.initialized = main.FALSE
1969 main.skipCase()
Jeremye0cb5eb2016-01-27 17:39:09 -08001970 main.case( "Test Multi to Single End Point Failure" )
Jeremy Songster9385d412016-06-02 17:57:36 -07001971 main.step( "Installing Multi to Single Point intents with no options set" )
1972 main.assertReturnString = "Assertion results for IPV4 multi to single " +\
1973 "point intent end point failure with no options set\n"
Jeremye0cb5eb2016-01-27 17:39:09 -08001974 senders = [
1975 { "name":"h16", "device":"of:0000000000000006/8" },
1976 { "name":"h24", "device":"of:0000000000000007/8" }
1977 ]
1978 recipients = [
1979 { "name":"h8", "device":"of:0000000000000005/8" }
1980 ]
1981 isolatedSenders = [
1982 { "name":"h24"}
1983 ]
1984 isolatedRecipients = []
1985 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001986 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08001987 installResult = main.intentFunction.installMultiToSingleIntent(
1988 main,
1989 name="NOOPTION",
1990 senders=senders,
1991 recipients=recipients,
1992 sw1="s5",
1993 sw2="s2" )
1994
1995 if installResult:
1996 testResult = main.intentFunction.testEndPointFail(
1997 main,
1998 intentId=installResult,
1999 name="NOOPTION",
2000 senders=senders,
2001 recipients=recipients,
2002 isolatedSenders=isolatedSenders,
2003 isolatedRecipients=isolatedRecipients,
2004 sw1="s6",
2005 sw2="s2",
2006 sw3="s4",
2007 sw4="s1",
2008 sw5="s3",
2009 expectedLink1=16,
2010 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002011 else:
2012 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002013
2014 utilities.assert_equals( expect=main.TRUE,
2015 actual=testResult,
2016 onpass=main.assertReturnString,
2017 onfail=main.assertReturnString )
2018
Jeremy Songster9385d412016-06-02 17:57:36 -07002019 main.step( "Installing Multi to Single Point intents with partial failure allowed" )
2020
2021 main.assertReturnString = "Assertion results for IPV4 multi to single " +\
2022 "with partial failures allowed\n"
2023 senders = [
2024 { "name":"h16", "device":"of:0000000000000006/8" },
2025 { "name":"h24", "device":"of:0000000000000007/8" }
2026 ]
2027 recipients = [
2028 { "name":"h8", "device":"of:0000000000000005/8" }
2029 ]
2030 isolatedSenders = [
2031 { "name":"h24"}
2032 ]
2033 isolatedRecipients = []
2034 testResult = main.FALSE
2035 installResult = main.FALSE
2036 installResult = main.intentFunction.installMultiToSingleIntent(
2037 main,
2038 name="NOOPTION",
2039 senders=senders,
2040 recipients=recipients,
2041 sw1="s5",
2042 sw2="s2",
2043 partial=True )
2044
2045 if installResult:
2046 testResult = main.intentFunction.testEndPointFail(
2047 main,
2048 intentId=installResult,
2049 name="NOOPTION",
2050 senders=senders,
2051 recipients=recipients,
2052 isolatedSenders=isolatedSenders,
2053 isolatedRecipients=isolatedRecipients,
2054 sw1="s6",
2055 sw2="s2",
2056 sw3="s4",
2057 sw4="s1",
2058 sw5="s3",
2059 expectedLink1=16,
2060 expectedLink2=14,
2061 partial=True )
2062 else:
2063 main.CLIs[ 0 ].removeAllIntents( purge=True )
2064
2065 utilities.assert_equals( expect=main.TRUE,
2066 actual=testResult,
2067 onpass=main.assertReturnString,
2068 onfail=main.assertReturnString )
2069
Jeremye0cb5eb2016-01-27 17:39:09 -08002070 main.step( "NOOPTION: Install and test single point to multi point intents" )
Jeremy Songster9385d412016-06-02 17:57:36 -07002071 main.assertReturnString = "Assertion results for IPV4 single to multi " +\
2072 "point intent with no options set\n"
Jeremye0cb5eb2016-01-27 17:39:09 -08002073 senders = [
2074 { "name":"h8", "device":"of:0000000000000005/8" }
2075 ]
2076 recipients = [
2077 { "name":"h16", "device":"of:0000000000000006/8" },
2078 { "name":"h24", "device":"of:0000000000000007/8" }
2079 ]
Jeremy Songster9385d412016-06-02 17:57:36 -07002080 isolatedSenders = []
2081 isolatedRecipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07002082 { "name":"h24"}
Jeremye0cb5eb2016-01-27 17:39:09 -08002083 ]
2084 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08002085 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08002086 installResult = main.intentFunction.installSingleToMultiIntent(
2087 main,
2088 name="NOOPTION",
2089 senders=senders,
2090 recipients=recipients,
2091 sw1="s5",
2092 sw2="s2")
2093
2094 if installResult:
2095 testResult = main.intentFunction.testEndPointFail(
2096 main,
2097 intentId=installResult,
2098 name="NOOPTION",
2099 senders=senders,
2100 recipients=recipients,
2101 isolatedSenders=isolatedSenders,
2102 isolatedRecipients=isolatedRecipients,
2103 sw1="s6",
2104 sw2="s2",
2105 sw3="s4",
2106 sw4="s1",
2107 sw5="s3",
2108 expectedLink1=16,
2109 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002110 else:
2111 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002112
2113 utilities.assert_equals( expect=main.TRUE,
2114 actual=testResult,
2115 onpass=main.assertReturnString,
2116 onfail=main.assertReturnString )
Jeremy Songster9385d412016-06-02 17:57:36 -07002117 # Right now this functionality doesn't work properly in SPMP intents
2118 main.step( "NOOPTION: Install and test single point to multi point " +\
2119 "intents with partial failures allowed" )
2120 main.assertReturnString = "Assertion results for IPV4 single to multi " +\
2121 "point intent with partial failures allowed\n"
2122 senders = [
2123 { "name":"h8", "device":"of:0000000000000005/8" }
2124 ]
2125 recipients = [
2126 { "name":"h16", "device":"of:0000000000000006/8" },
2127 { "name":"h24", "device":"of:0000000000000007/8" }
2128 ]
2129 isolatedSenders = []
2130 isolatedRecipients = [
2131 { "name":"h24"}
2132 ]
2133 testResult = main.FALSE
2134 installResult = main.FALSE
2135 installResult = main.intentFunction.installSingleToMultiIntent(
2136 main,
2137 name="NOOPTION",
2138 senders=senders,
2139 recipients=recipients,
2140 sw1="s5",
2141 sw2="s2",
2142 partial=True)
2143
2144 if installResult:
2145 testResult = main.intentFunction.testEndPointFail(
2146 main,
2147 intentId=installResult,
2148 name="NOOPTION",
2149 senders=senders,
2150 recipients=recipients,
2151 isolatedSenders=isolatedSenders,
2152 isolatedRecipients=isolatedRecipients,
2153 sw1="s6",
2154 sw2="s2",
2155 sw3="s4",
2156 sw4="s1",
2157 sw5="s3",
2158 expectedLink1=16,
2159 expectedLink2=14,
2160 partial=True )
2161 else:
2162 main.CLIs[ 0 ].removeAllIntents( purge=True )
2163
2164 utilities.assert_equals( expect=main.TRUE,
2165 actual=testResult,
2166 onpass=main.assertReturnString,
2167 onfail=main.assertReturnString )
Jeremye0cb5eb2016-01-27 17:39:09 -08002168
Jeremy2f190ca2016-01-29 15:23:57 -08002169 main.intentFunction.report( main )