blob: 9cd16a8cfcd94093080cc3b540d3436a4383fb80 [file] [log] [blame]
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001# Testing the basic intent functionality of ONOS
2
kelvin-onlabd48a68c2015-07-13 16:01:36 -07003class FUNCintent:
4
5 def __init__( self ):
6 self.default = ''
7
8 def CASE1( self, main ):
9 import time
kelvin-onlabd48a68c2015-07-13 16:01:36 -070010 import imp
Jon Hallf632d202015-07-30 15:45:11 -070011 import re
kelvin-onlabd48a68c2015-07-13 16:01:36 -070012
13 """
14 - Construct tests variables
15 - GIT ( optional )
16 - Checkout ONOS master branch
17 - Pull latest ONOS code
18 - Building ONOS ( optional )
19 - Install ONOS package
20 - Build ONOS package
21 """
22
23 main.case( "Constructing test variables and building ONOS package" )
24 main.step( "Constructing test variables" )
Jon Hall783bbf92015-07-23 14:33:19 -070025 main.caseExplanation = "This test case is mainly for loading " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -070026 "from params file, and pull and build the " +\
27 " latest ONOS package"
kelvin-onlabd48a68c2015-07-13 16:01:36 -070028 stepResult = main.FALSE
29
30 # Test variables
Jon Halla3e02432015-07-24 15:55:42 -070031 try:
Jon Hallf632d202015-07-30 15:45:11 -070032 main.testOnDirectory = re.sub( "(/tests)$", "", main.testDir )
Jon Halla3e02432015-07-24 15:55:42 -070033 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
34 gitBranch = main.params[ 'GIT' ][ 'branch' ]
35 main.dependencyPath = main.testOnDirectory + \
36 main.params[ 'DEPENDENCY' ][ 'path' ]
37 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
38 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
39 if main.ONOSbench.maxNodes:
40 main.maxNodes = int( main.ONOSbench.maxNodes )
41 else:
42 main.maxNodes = 0
43 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
44 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
45 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
46 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
47 main.checkIntentSleep = int( main.params[ 'SLEEP' ][ 'checkintent' ] )
acsmarscfa52272015-08-06 15:21:45 -070048 main.removeIntentSleep = int( main.params[ 'SLEEP' ][ 'removeintent' ] )
Jon Halla3e02432015-07-24 15:55:42 -070049 main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] )
50 main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
acsmars59a4c552015-09-10 18:11:19 -070051 main.checkTopoAttempts = int( main.params[ 'SLEEP' ][ 'topoAttempts' ] )
Jon Halla3e02432015-07-24 15:55:42 -070052 gitPull = main.params[ 'GIT' ][ 'pull' ]
53 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
54 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
55 main.cellData = {} # for creating cell file
56 main.hostsData = {}
57 main.CLIs = []
58 main.ONOSip = []
Jeremy Songster1f39bf02016-01-20 17:17:25 -080059 main.scapyHostNames = main.params[ 'SCAPY' ][ 'HOSTNAMES' ].split( ',' )
60 main.scapyHosts = [] # List of scapy hosts for iterating
acsmars5d8cc862015-09-25 09:44:50 -070061 main.assertReturnString = '' # Assembled assert return string
Jeremy Songster17147f22016-05-31 18:30:52 -070062 main.cycle = 0 # How many times FUNCintent has run through its tests
kelvin-onlabd48a68c2015-07-13 16:01:36 -070063
Jon Halla3e02432015-07-24 15:55:42 -070064 main.ONOSip = main.ONOSbench.getOnosIps()
65 print main.ONOSip
kelvin-onlabd48a68c2015-07-13 16:01:36 -070066
Jon Halla3e02432015-07-24 15:55:42 -070067 # Assigning ONOS cli handles to a list
68 for i in range( 1, main.maxNodes + 1 ):
69 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070070
Jon Halla3e02432015-07-24 15:55:42 -070071 # -- INIT SECTION, ONLY RUNS ONCE -- #
72 main.startUp = imp.load_source( wrapperFile1,
73 main.dependencyPath +
74 wrapperFile1 +
75 ".py" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070076
Jon Halla3e02432015-07-24 15:55:42 -070077 main.intentFunction = imp.load_source( wrapperFile2,
78 main.dependencyPath +
79 wrapperFile2 +
80 ".py" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070081
Jon Halla3e02432015-07-24 15:55:42 -070082 main.topo = imp.load_source( wrapperFile3,
83 main.dependencyPath +
84 wrapperFile3 +
85 ".py" )
86
kelvin-onlabd9e23de2015-08-06 10:34:44 -070087 copyResult1 = main.ONOSbench.scp( main.Mininet1,
88 main.dependencyPath +
89 main.topology,
Jeremy Songster1f39bf02016-01-20 17:17:25 -080090 main.Mininet1.home + "custom/",
kelvin-onlabd9e23de2015-08-06 10:34:44 -070091 direction="to" )
Jon Halla3e02432015-07-24 15:55:42 -070092 if main.CLIs:
93 stepResult = main.TRUE
94 else:
95 main.log.error( "Did not properly created list of ONOS CLI handle" )
96 stepResult = main.FALSE
97 except Exception as e:
98 main.log.exception(e)
99 main.cleanup()
100 main.exit()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700101
102 utilities.assert_equals( expect=main.TRUE,
103 actual=stepResult,
104 onpass="Successfully construct " +
105 "test variables ",
106 onfail="Failed to construct test variables" )
107
108 if gitPull == 'True':
109 main.step( "Building ONOS in " + gitBranch + " branch" )
110 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
111 stepResult = onosBuildResult
112 utilities.assert_equals( expect=main.TRUE,
113 actual=stepResult,
114 onpass="Successfully compiled " +
115 "latest ONOS",
116 onfail="Failed to compile " +
117 "latest ONOS" )
118 else:
119 main.log.warn( "Did not pull new code so skipping mvn " +
120 "clean install" )
Jon Hall106be082015-07-22 09:53:00 -0700121 main.ONOSbench.getVersion( report=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700122
123 def CASE2( self, main ):
124 """
125 - Set up cell
126 - Create cell file
127 - Set cell file
128 - Verify cell file
129 - Kill ONOS process
130 - Uninstall ONOS cluster
131 - Verify ONOS start up
132 - Install ONOS cluster
133 - Connect to cli
134 """
135
Jeremy Songster17147f22016-05-31 18:30:52 -0700136 main.cycle += 1
137
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700138 # main.scale[ 0 ] determines the current number of ONOS controller
139 main.numCtrls = int( main.scale[ 0 ] )
Jeremycd872222016-03-29 10:08:34 -0700140 main.flowCompiler = "Flow Rules"
Jeremyd9e4eb12016-04-13 12:09:06 -0700141 main.initialized = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700142
143 main.case( "Starting up " + str( main.numCtrls ) +
144 " node(s) ONOS cluster" )
Jon Hall783bbf92015-07-23 14:33:19 -0700145 main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700146 " node(s) ONOS cluster"
147
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700148 #kill off all onos processes
149 main.log.info( "Safety check, killing all ONOS processes" +
Jon Hall70b2ff42015-11-17 15:49:44 -0800150 " before initiating environment setup" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700151
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800152 time.sleep( main.startUpSleep )
153 main.step( "Uninstalling ONOS package" )
154 onosUninstallResult = main.TRUE
155 for ip in main.ONOSip:
156 onosUninstallResult = onosUninstallResult and \
157 main.ONOSbench.onosUninstall( nodeIp=ip )
158 stepResult = onosUninstallResult
159 utilities.assert_equals( expect=main.TRUE,
160 actual=stepResult,
161 onpass="Successfully uninstalled ONOS package",
162 onfail="Failed to uninstall ONOS package" )
Jeremy42df2e72016-02-23 16:37:46 -0800163 time.sleep( main.startUpSleep )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800164
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700165 for i in range( main.maxNodes ):
166 main.ONOSbench.onosDie( main.ONOSip[ i ] )
167
168 print "NODE COUNT = ", main.numCtrls
169
170 tempOnosIp = []
171 for i in range( main.numCtrls ):
172 tempOnosIp.append( main.ONOSip[i] )
173
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700174 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
175 "temp", main.Mininet1.ip_address,
176 main.apps, tempOnosIp )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700177
178 main.step( "Apply cell to environment" )
179 cellResult = main.ONOSbench.setCell( "temp" )
180 verifyResult = main.ONOSbench.verifyCell()
181 stepResult = cellResult and verifyResult
182 utilities.assert_equals( expect=main.TRUE,
183 actual=stepResult,
184 onpass="Successfully applied cell to " + \
185 "environment",
186 onfail="Failed to apply cell to environment " )
187
188 main.step( "Creating ONOS package" )
189 packageResult = main.ONOSbench.onosPackage()
190 stepResult = packageResult
191 utilities.assert_equals( expect=main.TRUE,
192 actual=stepResult,
193 onpass="Successfully created ONOS package",
194 onfail="Failed to create ONOS package" )
195
196 time.sleep( main.startUpSleep )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700197 main.step( "Installing ONOS package" )
198 onosInstallResult = main.TRUE
199 for i in range( main.numCtrls ):
200 onosInstallResult = onosInstallResult and \
201 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
202 stepResult = onosInstallResult
203 utilities.assert_equals( expect=main.TRUE,
204 actual=stepResult,
205 onpass="Successfully installed ONOS package",
206 onfail="Failed to install ONOS package" )
207
208 time.sleep( main.startUpSleep )
209 main.step( "Starting ONOS service" )
210 stopResult = main.TRUE
211 startResult = main.TRUE
212 onosIsUp = main.TRUE
213
214 for i in range( main.numCtrls ):
Jeremy Songster7edb6632016-04-28 15:44:28 -0700215 isUp = main.ONOSbench.isup( main.ONOSip[ i ] )
216 onosIsUp = onosIsUp and isUp
217 if isUp == main.TRUE:
Jeremyd9e4eb12016-04-13 12:09:06 -0700218 main.log.report( "ONOS instance {0} is up and ready".format( i + 1 ) )
219 else:
220 main.log.report( "ONOS instance {0} may not be up, stop and ".format( i + 1 ) +
221 "start ONOS again " )
222 stopResult = stopResult and main.ONOSbench.onosStop( main.ONOSip[ i ] )
223 startResult = startResult and main.ONOSbench.onosStart( main.ONOSip[ i ] )
224 if not startResult or stopResult:
225 main.log.report( "ONOS instance {0} did not start correctly.".format( i + 1) )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700226 stepResult = onosIsUp and stopResult and startResult
227 utilities.assert_equals( expect=main.TRUE,
228 actual=stepResult,
Jeremyd9e4eb12016-04-13 12:09:06 -0700229 onpass="ONOS service is ready on all nodes",
230 onfail="ONOS service did not start properly on all nodes" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700231
232 main.step( "Start ONOS cli" )
233 cliResult = main.TRUE
234 for i in range( main.numCtrls ):
235 cliResult = cliResult and \
236 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
237 stepResult = cliResult
238 utilities.assert_equals( expect=main.TRUE,
239 actual=stepResult,
240 onpass="Successfully start ONOS cli",
241 onfail="Failed to start ONOS cli" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700242 if not stepResult:
243 main.initialized = main.FALSE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700244
245 # Remove the first element in main.scale list
246 main.scale.remove( main.scale[ 0 ] )
247
kelvin-onlab016dce22015-08-10 09:54:11 -0700248 main.intentFunction.report( main )
249
Jon Halla3e02432015-07-24 15:55:42 -0700250 def CASE8( self, main ):
251 """
acsmars59a4c552015-09-10 18:11:19 -0700252 Compare ONOS Topology to Mininet Topology
Jon Halla3e02432015-07-24 15:55:42 -0700253 """
254 import json
255
256 main.case( "Compare ONOS Topology view to Mininet topology" )
257 main.caseExplanation = "Compare topology elements between Mininet" +\
258 " and ONOS"
259
acsmars59a4c552015-09-10 18:11:19 -0700260 main.log.info( "Gathering topology information from Mininet" )
261 devicesResults = main.FALSE # Overall Boolean for device correctness
262 linksResults = main.FALSE # Overall Boolean for link correctness
263 hostsResults = main.FALSE # Overall Boolean for host correctness
264 deviceFails = [] # Nodes where devices are incorrect
265 linkFails = [] # Nodes where links are incorrect
266 hostFails = [] # Nodes where hosts are incorrect
267 attempts = main.checkTopoAttempts # Remaining Attempts
Jon Halla3e02432015-07-24 15:55:42 -0700268
269 mnSwitches = main.Mininet1.getSwitches()
270 mnLinks = main.Mininet1.getLinks()
271 mnHosts = main.Mininet1.getHosts()
272
Jon Hall70b2ff42015-11-17 15:49:44 -0800273 main.step( "Comparing Mininet topology to ONOS topology" )
Jon Halla3e02432015-07-24 15:55:42 -0700274
acsmars59a4c552015-09-10 18:11:19 -0700275 while ( attempts >= 0 ) and\
276 ( not devicesResults or not linksResults or not hostsResults ):
277 time.sleep( 2 )
278 if not devicesResults:
279 devices = main.topo.getAllDevices( main )
280 ports = main.topo.getAllPorts( main )
281 devicesResults = main.TRUE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800282 deviceFails = [] # Reset for each failed attempt
acsmars59a4c552015-09-10 18:11:19 -0700283 if not linksResults:
284 links = main.topo.getAllLinks( main )
285 linksResults = main.TRUE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800286 linkFails = [] # Reset for each failed attempt
acsmars59a4c552015-09-10 18:11:19 -0700287 if not hostsResults:
288 hosts = main.topo.getAllHosts( main )
289 hostsResults = main.TRUE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800290 hostFails = [] # Reset for each failed attempt
Jon Halla3e02432015-07-24 15:55:42 -0700291
acsmars59a4c552015-09-10 18:11:19 -0700292 # Check for matching topology on each node
293 for controller in range( main.numCtrls ):
294 controllerStr = str( controller + 1 ) # ONOS node number
295 # Compare Devices
296 if devices[ controller ] and ports[ controller ] and\
297 "Error" not in devices[ controller ] and\
298 "Error" not in ports[ controller ]:
Jon Halla3e02432015-07-24 15:55:42 -0700299
acsmars2ec91d62015-09-16 11:15:48 -0700300 try:
301 deviceData = json.loads( devices[ controller ] )
302 portData = json.loads( ports[ controller ] )
303 except (TypeError,ValueError):
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800304 main.log.error( "Could not load json: {0} or {1}".format( str( devices[ controller ] ), str( ports[ controller ] ) ) )
acsmars2ec91d62015-09-16 11:15:48 -0700305 currentDevicesResult = main.FALSE
306 else:
307 currentDevicesResult = main.Mininet1.compareSwitches(
308 mnSwitches,deviceData,portData )
acsmars59a4c552015-09-10 18:11:19 -0700309 else:
310 currentDevicesResult = main.FALSE
311 if not currentDevicesResult:
312 deviceFails.append( controllerStr )
313 devicesResults = devicesResults and currentDevicesResult
314 # Compare Links
315 if links[ controller ] and "Error" not in links[ controller ]:
acsmars2ec91d62015-09-16 11:15:48 -0700316 try:
317 linkData = json.loads( links[ controller ] )
318 except (TypeError,ValueError):
319 main.log.error("Could not load json:" + str( links[ controller ] ) )
320 currentLinksResult = main.FALSE
321 else:
322 currentLinksResult = main.Mininet1.compareLinks(
323 mnSwitches, mnLinks,linkData )
acsmars59a4c552015-09-10 18:11:19 -0700324 else:
325 currentLinksResult = main.FALSE
326 if not currentLinksResult:
327 linkFails.append( controllerStr )
328 linksResults = linksResults and currentLinksResult
329 # Compare Hosts
acsmars2ec91d62015-09-16 11:15:48 -0700330 if hosts[ controller ] and "Error" not in hosts[ controller ]:
331 try:
332 hostData = json.loads( hosts[ controller ] )
333 except (TypeError,ValueError):
334 main.log.error("Could not load json:" + str( hosts[ controller ] ) )
335 currentHostsResult = main.FALSE
336 else:
337 currentHostsResult = main.Mininet1.compareHosts(
338 mnHosts,hostData )
acsmars59a4c552015-09-10 18:11:19 -0700339 else:
340 currentHostsResult = main.FALSE
341 if not currentHostsResult:
342 hostFails.append( controllerStr )
343 hostsResults = hostsResults and currentHostsResult
344 # Decrement Attempts Remaining
345 attempts -= 1
346
347
348 utilities.assert_equals( expect=[],
349 actual=deviceFails,
350 onpass="ONOS correctly discovered all devices",
351 onfail="ONOS incorrectly discovered devices on nodes: " +
352 str( deviceFails ) )
353 utilities.assert_equals( expect=[],
354 actual=linkFails,
355 onpass="ONOS correctly discovered all links",
356 onfail="ONOS incorrectly discovered links on nodes: " +
357 str( linkFails ) )
358 utilities.assert_equals( expect=[],
359 actual=hostFails,
360 onpass="ONOS correctly discovered all hosts",
361 onfail="ONOS incorrectly discovered hosts on nodes: " +
362 str( hostFails ) )
Jon Hall46d48252015-08-03 11:41:16 -0700363 topoResults = hostsResults and linksResults and devicesResults
364 utilities.assert_equals( expect=main.TRUE,
365 actual=topoResults,
366 onpass="ONOS correctly discovered the topology",
367 onfail="ONOS incorrectly discovered the topology" )
Jon Halla3e02432015-07-24 15:55:42 -0700368
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700369 def CASE10( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700370 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700371 Start Mininet topology with OF 1.0 switches
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700372 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700373 if main.initialized == main.FALSE:
374 main.log.error( "Test components did not start correctly, skipping further tests" )
375 main.skipCase()
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700376 main.OFProtocol = "1.0"
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700377 main.log.report( "Start Mininet topology with OF 1.0 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700378 main.case( "Start Mininet topology with OF 1.0 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700379 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700380 "switches to test intents, exits out if " +\
381 "topology did not start correctly"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700382
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700383 main.step( "Starting Mininet topology with OF 1.0 switches" )
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700384 args = "--switch ovs,protocols=OpenFlow10"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700385 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700386 main.topology,
387 args=args )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700388 stepResult = topoResult
389 utilities.assert_equals( expect=main.TRUE,
390 actual=stepResult,
391 onpass="Successfully loaded topology",
392 onfail="Failed to load topology" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700393
394 # Set flag to test cases if topology did not load properly
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700395 if not topoResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700396 main.initialized = main.FALSE
397 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700398
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700399 def CASE11( self, main ):
400 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700401 Start Mininet topology with OF 1.3 switches
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700402 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700403 if main.initialized == main.FALSE:
404 main.log.error( "Test components did not start correctly, skipping further tests" )
405 main.skipCase()
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700406 main.OFProtocol = "1.3"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700407 main.log.report( "Start Mininet topology with OF 1.3 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700408 main.case( "Start Mininet topology with OF 1.3 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700409 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700410 "switches to test intents, exits out if " +\
411 "topology did not start correctly"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700412
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700413 main.step( "Starting Mininet topology with OF 1.3 switches" )
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700414 args = "--switch ovs,protocols=OpenFlow13"
415 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
416 main.topology,
417 args=args )
418 stepResult = topoResult
419 utilities.assert_equals( expect=main.TRUE,
420 actual=stepResult,
421 onpass="Successfully loaded topology",
422 onfail="Failed to load topology" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700423 # Set flag to skip test cases if topology did not load properly
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700424 if not topoResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700425 main.initialized = main.FALSE
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700426
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700427 def CASE12( self, main ):
428 """
429 Assign mastership to controllers
430 """
431 import re
432
Jeremyd9e4eb12016-04-13 12:09:06 -0700433 if main.initialized == main.FALSE:
434 main.log.error( "Test components did not start correctly, skipping further tests" )
435 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700436 main.case( "Assign switches to controllers" )
437 main.step( "Assigning switches to controllers" )
Jon Hall783bbf92015-07-23 14:33:19 -0700438 main.caseExplanation = "Assign OF " + main.OFProtocol +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700439 " switches to ONOS nodes"
440
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700441 assignResult = main.TRUE
442 switchList = []
443
444 # Creates a list switch name, use getSwitch() function later...
445 for i in range( 1, ( main.numSwitch + 1 ) ):
446 switchList.append( 's' + str( i ) )
447
448 tempONOSip = []
449 for i in range( main.numCtrls ):
450 tempONOSip.append( main.ONOSip[ i ] )
451
452 assignResult = main.Mininet1.assignSwController( sw=switchList,
453 ip=tempONOSip,
Charles Chan029be652015-08-24 01:46:10 +0800454 port='6653' )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700455 if not assignResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700456 main.log.error( "Problem assigning mastership of switches" )
457 main.initialized = main.FALSE
458 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700459
460 for i in range( 1, ( main.numSwitch + 1 ) ):
461 response = main.Mininet1.getSwController( "s" + str( i ) )
462 print( "Response is " + str( response ) )
463 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
464 assignResult = assignResult and main.TRUE
465 else:
466 assignResult = main.FALSE
467 stepResult = assignResult
468 utilities.assert_equals( expect=main.TRUE,
469 actual=stepResult,
470 onpass="Successfully assigned switches" +
471 "to controller",
472 onfail="Failed to assign switches to " +
473 "controller" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700474 if not stepResult:
475 main.initialized = main.FALSE
acsmars5d8cc862015-09-25 09:44:50 -0700476
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800477 def CASE13( self,main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700478 """
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800479 Create Scapy components
480 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700481 if main.initialized == main.FALSE:
482 main.log.error( "Test components did not start correctly, skipping further tests" )
483 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800484 main.case( "Create scapy components" )
485 main.step( "Create scapy components" )
486 import json
487 scapyResult = main.TRUE
488 for hostName in main.scapyHostNames:
489 main.Scapy1.createHostComponent( hostName )
490 main.scapyHosts.append( getattr( main, hostName ) )
491
492 main.step( "Start scapy components" )
493 for host in main.scapyHosts:
494 host.startHostCli()
495 host.startScapy()
496 host.updateSelf()
497 main.log.debug( host.name )
498 main.log.debug( host.hostIp )
499 main.log.debug( host.hostMac )
500
501
502 utilities.assert_equals( expect=main.TRUE,
503 actual=scapyResult,
504 onpass="Successfully created Scapy Components",
505 onfail="Failed to discover Scapy Components" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700506 if not scapyResult:
507 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800508
509 def CASE14( self, main ):
510 """
511 Discover all hosts with fwd and pingall and store its data in a dictionary
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700512 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700513 if main.initialized == main.FALSE:
514 main.log.error( "Test components did not start correctly, skipping further tests" )
515 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700516 main.case( "Discover all hosts" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800517 main.step( "Pingall hosts and confirm ONOS discovery" )
518 utilities.retry( f=main.intentFunction.fwdPingall, retValue=main.FALSE, args=[ main ] )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700519
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800520 utilities.retry( f=main.intentFunction.confirmHostDiscovery, retValue=main.FALSE,
521 args=[ main ], attempts=main.checkTopoAttempts, sleep=2 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700522 utilities.assert_equals( expect=main.TRUE,
523 actual=stepResult,
524 onpass="Successfully discovered hosts",
525 onfail="Failed to discover hosts" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700526 if not stepResult:
527 main.initialized = main.FALSE
528 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700529
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800530 main.step( "Populate hostsData" )
531 stepResult = main.intentFunction.populateHostData( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700532 utilities.assert_equals( expect=main.TRUE,
533 actual=stepResult,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800534 onpass="Successfully populated hostsData",
535 onfail="Failed to populate hostsData" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700536 if not stepResult:
537 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800538
539 def CASE15( self, main ):
540 """
541 Discover all hosts with scapy arp packets and store its data to a dictionary
542 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700543 if main.initialized == main.FALSE:
544 main.log.error( "Test components did not start correctly, skipping further tests" )
545 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800546 main.case( "Discover all hosts using scapy" )
547 main.step( "Send packets from each host to the first host and confirm onos discovery" )
548
549 import collections
550 if len( main.scapyHosts ) < 1:
551 main.log.error( "No scapy hosts have been created" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700552 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800553 main.skipCase()
554
555 # Send ARP packets from each scapy host component
556 main.intentFunction.sendDiscoveryArp( main, main.scapyHosts )
557
558 stepResult = utilities.retry( f=main.intentFunction.confirmHostDiscovery,
559 retValue=main.FALSE, args=[ main ],
560 attempts=main.checkTopoAttempts, sleep=2 )
561
562 utilities.assert_equals( expect=main.TRUE,
563 actual=stepResult,
564 onpass="ONOS correctly discovered all hosts",
565 onfail="ONOS incorrectly discovered hosts" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700566 if not stepResult:
567 main.initialized = main.FALSE
568 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800569
570 main.step( "Populate hostsData" )
571 stepResult = main.intentFunction.populateHostData( main )
572 utilities.assert_equals( expect=main.TRUE,
573 actual=stepResult,
574 onpass="Successfully populated hostsData",
575 onfail="Failed to populate hostsData" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700576 if not stepResult:
577 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800578
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800579 def CASE16( self, main ):
580 """
Jeremy42df2e72016-02-23 16:37:46 -0800581 Balance Masters
582 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700583 if main.initialized == main.FALSE:
584 main.log.error( "Test components did not start correctly, skipping further tests" )
585 main.skipCase()
Jeremy42df2e72016-02-23 16:37:46 -0800586 main.case( "Balance mastership of switches" )
587 main.step( "Balancing mastership of switches" )
588
589 balanceResult = main.FALSE
590 balanceResult = utilities.retry( f=main.CLIs[ 0 ].balanceMasters, retValue=main.FALSE, args=[] )
591
592 utilities.assert_equals( expect=main.TRUE,
Jeremy6e9748f2016-03-25 15:03:39 -0700593 actual=balanceResult,
Jeremy42df2e72016-02-23 16:37:46 -0800594 onpass="Successfully balanced mastership of switches",
595 onfail="Failed to balance mastership of switches" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700596 if not balanceResult:
597 main.initialized = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800598
599 def CASE17( self, main ):
600 """
Jeremy6e9748f2016-03-25 15:03:39 -0700601 Use Flow Objectives
602 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700603 if main.initialized == main.FALSE:
604 main.log.error( "Test components did not start correctly, skipping further tests" )
605 main.skipCase()
Jeremy6e9748f2016-03-25 15:03:39 -0700606 main.case( "Enable intent compilation using Flow Objectives" )
607 main.step( "Enabling Flow Objectives" )
608
609 main.flowCompiler = "Flow Objectives"
610
611 cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator"
612
613 stepResult = main.CLIs[ 0 ].setCfg( component=cmd,
614 propName="useFlowObjectives", value="true" )
615
616 utilities.assert_equals( expect=main.TRUE,
617 actual=stepResult,
618 onpass="Successfully activated Flow Objectives",
619 onfail="Failed to activate Flow Objectives" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700620 if not balanceResult:
621 main.initialized = main.FALSE
Jeremy6e9748f2016-03-25 15:03:39 -0700622
623 def CASE18( self, main ):
624 """
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800625 Stop mininet and remove scapy host
626 """
627 main.log.report( "Stop Mininet and Scapy" )
628 main.case( "Stop Mininet and Scapy" )
629 main.caseExplanation = "Stopping the current mininet topology " +\
630 "to start up fresh"
631 main.step( "Stopping and Removing Scapy Host Components" )
632 scapyResult = main.TRUE
633 for host in main.scapyHosts:
634 scapyResult = scapyResult and host.stopScapy()
635 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
636
637 for host in main.scapyHosts:
638 scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
639 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
640
641 main.scapyHosts = []
642 main.scapyHostIPs = []
643
644 utilities.assert_equals( expect=main.TRUE,
645 actual=scapyResult,
646 onpass="Successfully stopped scapy and removed host components",
647 onfail="Failed to stop mininet and scapy" )
648
649 main.step( "Stopping Mininet Topology" )
650 mininetResult = main.Mininet1.stopNet( )
651
652 utilities.assert_equals( expect=main.TRUE,
653 actual=mininetResult,
654 onpass="Successfully stopped mininet and scapy",
655 onfail="Failed to stop mininet and scapy" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700656 # Exit if topology did not load properly
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800657 if not ( mininetResult and scapyResult ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700658 main.cleanup()
659 main.exit()
660
Jeremy Songster17147f22016-05-31 18:30:52 -0700661 def CASE19( self, main ):
662 """
663 Copy the karaf.log files after each testcase cycle
664 """
665 main.log.report( "Copy karaf logs" )
666 main.case( "Copy karaf logs" )
667 main.caseExplanation = "Copying the karaf logs to preserve them through" +\
668 "reinstalling ONOS"
669 main.step( "Copying karaf logs" )
670 i = 0
671 for cli in main.CLIs:
672 main.node = cli
673 ip = main.ONOSip[ i ]
674 main.node.ip_address = ip
675 main.ONOSbench.scp( main.node ,
676 "/opt/onos/log/karaf.log",
677 "/tmp/karaf.log",
678 direction="from" )
679 main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
680 copyFileName=( "karaf.log.node{0}.cycle{1}".format( str( i + 1 ), str( main.cycle ) ) ) )
681 i += 1
682
kelvin-onlabb769f562015-07-15 17:05:10 -0700683 def CASE1000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700684 """
685 Add host intents between 2 host:
686 - Discover hosts
687 - Add host intents
688 - Check intents
689 - Verify flows
690 - Ping hosts
691 - Reroute
692 - Link down
693 - Verify flows
694 - Check topology
695 - Ping hosts
696 - Link up
697 - Verify flows
698 - Check topology
699 - Ping hosts
700 - Remove intents
701 """
702 import time
703 import json
704 import re
Jeremyd9e4eb12016-04-13 12:09:06 -0700705 if main.initialized == main.FALSE:
706 main.log.error( "Test components did not start correctly, skipping further tests" )
707 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700708 # Assert variables - These variable's name|format must be followed
709 # if you want to use the wrapper function
710 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -0700711 try:
712 assert main.CLIs
713 except AssertionError:
714 main.log.error( "There is no main.CLIs, skipping test cases" )
715 main.initialized = main.FALSE
716 main.skipCase()
717 try:
718 assert main.Mininet1
719 except AssertionError:
720 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
721 main.initialized = main.FALSE
722 main.skipCase()
723 try:
724 assert main.numSwitch
725 except AssertionError:
726 main.log.error( "Place the total number of switch topology in \
727 main.numSwitch" )
728 main.initialized = main.FALSE
729 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700730
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800731 # Save leader candidates
acsmarse6b410f2015-07-17 14:39:34 -0700732 intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
733
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700734 main.testName = "Host Intents"
735 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -0700736 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -0700737 main.caseExplanation = "This test case tests Host intents using " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700738 str( main.numCtrls ) + " node(s) cluster;\n" +\
739 "Different type of hosts will be tested in " +\
740 "each step such as IPV4, Dual stack, VLAN " +\
Jeremyeb51cb12016-03-28 17:53:35 -0700741 "etc;\nThe test will use OF " + main.OFProtocol +\
742 " OVS running in Mininet and compile intents" +\
Jeremy6e9748f2016-03-25 15:03:39 -0700743 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700744
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700745 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700746 main.assertReturnString = "Assertion Result for IPV4 host intent with mac addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800747 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
748 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
749 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800750 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800751 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700752 name='IPV4',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800753 onosNode='0',
754 host1=host1,
755 host2=host2)
756 if installResult:
757 testResult = main.intentFunction.testHostIntent( main,
758 name='IPV4',
759 intentId = installResult,
760 onosNode='0',
761 host1=host1,
762 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700763 sw1='s5',
764 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800765 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800766 else:
767 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800768
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700769 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800770 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700771 onpass=main.assertReturnString,
772 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700773
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700774 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700775 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800776 host1 = { "name":"h3","id":"00:00:00:00:00:03/-1" }
777 host2 = { "name":"h11","id":"00:00:00:00:00:0B/-1 "}
778 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800779 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800780 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700781 name='DUALSTACK',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800782 onosNode='0',
783 host1=host1,
784 host2=host2)
785
786 if installResult:
787 testResult = main.intentFunction.testHostIntent( main,
788 name='DUALSTACK',
789 intentId = installResult,
790 onosNode='0',
791 host1=host1,
792 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700793 sw1='s5',
794 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800795 expectedLink = 18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700796
797 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800798 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700799 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800800 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700801
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700802 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700803 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800804 host1 = { "name":"h1" }
805 host2 = { "name":"h11" }
806 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800807 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800808 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700809 name='DUALSTACK2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800810 onosNode='0',
811 host1=host1,
812 host2=host2)
813
814 if installResult:
815 testResult = main.intentFunction.testHostIntent( main,
816 name='DUALSTACK2',
817 intentId = installResult,
818 onosNode='0',
819 host1=host1,
820 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700821 sw1='s5',
822 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800823 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800824 else:
825 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700826
827 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800828 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700829 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800830 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700831
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700832 main.step( "1HOP: Add host intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -0700833 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800834 host1 = { "name":"h1" }
835 host2 = { "name":"h3" }
836 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800837 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800838 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700839 name='1HOP',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800840 onosNode='0',
841 host1=host1,
842 host2=host2)
843
844 if installResult:
845 testResult = main.intentFunction.testHostIntent( main,
846 name='1HOP',
847 intentId = installResult,
848 onosNode='0',
849 host1=host1,
850 host2=host2,
851 sw1='s5',
852 sw2='s2',
853 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800854 else:
855 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700856
857 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800858 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700859 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800860 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700861
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700862 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
acsmars5d8cc862015-09-25 09:44:50 -0700863 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jeremy Songster832f9e92016-05-05 14:30:49 -0700864 host1 = { "name":"h4","id":"00:00:00:00:00:04/100", "vlan":"100" }
865 host2 = { "name":"h12","id":"00:00:00:00:00:0C/100", "vlan":"100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800866 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800867 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800868 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700869 name='VLAN1',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800870 onosNode='0',
871 host1=host1,
872 host2=host2)
873
874 if installResult:
875 testResult = main.intentFunction.testHostIntent( main,
876 name='VLAN1',
877 intentId = installResult,
878 onosNode='0',
879 host1=host1,
880 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700881 sw1='s5',
882 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800883 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800884 else:
885 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700886
887 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800888 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700889 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800890 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700891
Jeremy Songsterff553672016-05-12 17:06:23 -0700892 main.step( "VLAN2: Add vlan host intents between h4 and h13" )
893 main.assertReturnString = "Assertion Result vlan IPV4\n"
894 host1 = { "name":"h5", "vlan":"200" }
895 host2 = { "name":"h12", "vlan":"100" }
896 testResult = main.FALSE
897 installResult = main.FALSE
898 installResult = main.intentFunction.installHostIntent( main,
899 name='VLAN2',
900 onosNode='0',
901 host1=host1,
902 host2=host2)
903
904 if installResult:
905 testResult = main.intentFunction.testHostIntent( main,
906 name='VLAN2',
907 intentId = installResult,
908 onosNode='0',
909 host1=host1,
910 host2=host2,
911 sw1='s5',
912 sw2='s2',
913 expectedLink = 18)
914 else:
915 main.CLIs[ 0 ].removeAllIntents( purge=True )
916
917 utilities.assert_equals( expect=main.TRUE,
918 actual=testResult,
919 onpass=main.assertReturnString,
920 onfail=main.assertReturnString)
921
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800922 main.step( "Confirm that ONOS leadership is unchanged")
acsmarse6b410f2015-07-17 14:39:34 -0700923 intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
924 main.intentFunction.checkLeaderChange( intentLeadersOld,
925 intentLeadersNew )
926
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800927 utilities.assert_equals( expect=main.TRUE,
928 actual=testResult,
929 onpass="ONOS Leaders Unchanged",
930 onfail="ONOS Leader Mismatch")
931
kelvin-onlab016dce22015-08-10 09:54:11 -0700932 main.intentFunction.report( main )
933
kelvin-onlabb769f562015-07-15 17:05:10 -0700934 def CASE2000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700935 """
936 Add point intents between 2 hosts:
937 - Get device ids | ports
938 - Add point intents
939 - Check intents
940 - Verify flows
941 - Ping hosts
942 - Reroute
943 - Link down
944 - Verify flows
945 - Check topology
946 - Ping hosts
947 - Link up
948 - Verify flows
949 - Check topology
950 - Ping hosts
951 - Remove intents
952 """
953 import time
954 import json
955 import re
Jeremyd9e4eb12016-04-13 12:09:06 -0700956 if main.initialized == main.FALSE:
957 main.log.error( "Test components did not start correctly, skipping further tests" )
958 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700959 # Assert variables - These variable's name|format must be followed
960 # if you want to use the wrapper function
961 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -0700962 try:
963 assert main.CLIs
964 except AssertionError:
965 main.log.error( "There is no main.CLIs, skipping test cases" )
966 main.initialized = main.FALSE
967 main.skipCase()
968 try:
969 assert main.Mininet1
970 except AssertionError:
971 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
972 main.initialized = main.FALSE
973 main.skipCase()
974 try:
975 assert main.numSwitch
976 except AssertionError:
977 main.log.error( "Place the total number of switch topology in \
978 main.numSwitch" )
979 main.initialized = main.FALSE
980 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700981
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700982 main.testName = "Point Intents"
983 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -0700984 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -0700985 main.caseExplanation = "This test case will test point to point" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700986 " intents using " + str( main.numCtrls ) +\
987 " node(s) cluster;\n" +\
988 "Different type of hosts will be tested in " +\
989 "each step such as IPV4, Dual stack, VLAN etc" +\
990 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -0700991 " OVS running in Mininet and compile intents" +\
992 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700993
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700994 # No option point intents
995 main.step( "NOOPTION: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700996 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800997 senders = [
998 { "name":"h1","device":"of:0000000000000005/1" }
999 ]
1000 recipients = [
1001 { "name":"h9","device":"of:0000000000000006/1" }
1002 ]
Jeremy42df2e72016-02-23 16:37:46 -08001003 testResult = main.FALSE
1004 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001005 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001006 main,
1007 name="NOOPTION",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001008 senders=senders,
1009 recipients=recipients )
1010
1011 if installResult:
1012 testResult = main.intentFunction.testPointIntent(
1013 main,
1014 intentId=installResult,
1015 name="NOOPTION",
1016 senders=senders,
1017 recipients=recipients,
1018 sw1="s5",
1019 sw2="s2",
1020 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001021 else:
1022 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001023
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001024 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001025 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001026 onpass=main.assertReturnString,
1027 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001028
1029 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -07001030 main.step( "IPV4: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001031 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001032 senders = [
1033 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1034 ]
1035 recipients = [
1036 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09" }
1037 ]
Jeremy42df2e72016-02-23 16:37:46 -08001038 testResult = main.FALSE
1039 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001040 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001041 main,
1042 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001043 senders=senders,
1044 recipients=recipients,
1045 ethType="IPV4" )
1046
1047 if installResult:
1048 testResult = main.intentFunction.testPointIntent(
1049 main,
1050 intentId=installResult,
1051 name="IPV4",
1052 senders=senders,
1053 recipients=recipients,
1054 sw1="s5",
1055 sw2="s2",
1056 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001057 else:
1058 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001059
1060 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001061 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001062 onpass=main.assertReturnString,
1063 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001064 main.step( "IPV4_2: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001065 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001066 senders = [
1067 { "name":"h1","device":"of:0000000000000005/1" }
1068 ]
1069 recipients = [
1070 { "name":"h9","device":"of:0000000000000006/1" }
1071 ]
Jeremy42df2e72016-02-23 16:37:46 -08001072 testResult = main.FALSE
1073 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001074 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001075 main,
1076 name="IPV4_2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001077 senders=senders,
1078 recipients=recipients,
1079 ethType="IPV4" )
1080
1081 if installResult:
1082 testResult = main.intentFunction.testPointIntent(
1083 main,
1084 intentId=installResult,
1085 name="IPV4_2",
1086 senders=senders,
1087 recipients=recipients,
1088 sw1="s5",
1089 sw2="s2",
1090 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001091 else:
1092 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001093
1094 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001095 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001096 onpass=main.assertReturnString,
1097 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001098
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001099 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001100 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001101 senders = [
1102 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01",
Jeremy6f000c62016-02-25 17:02:28 -08001103 "ip":( main.h1.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001104 ]
1105 recipients = [
1106 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09",
Jeremy6f000c62016-02-25 17:02:28 -08001107 "ip":( main.h9.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001108 ]
Jeremy6f000c62016-02-25 17:02:28 -08001109 ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ]
kelvin-onlab79ce0492015-07-27 16:14:39 -07001110 # Uneccessary, not including this in the selectors
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001111 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
1112 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
Jeremy42df2e72016-02-23 16:37:46 -08001113 testResult = main.FALSE
1114 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001115 installResult = main.intentFunction.installPointIntent(
1116 main,
1117 name="SDNIP-ICMP",
1118 senders=senders,
1119 recipients=recipients,
1120 ethType="IPV4",
1121 ipProto=ipProto,
1122 tcpSrc=tcpSrc,
1123 tcpDst=tcpDst )
1124
1125 if installResult:
1126 testResult = main.intentFunction.testPointIntent(
1127 main,
1128 intentId=installResult,
1129 name="SDNIP_ICMP",
1130 senders=senders,
1131 recipients=recipients,
1132 sw1="s5",
1133 sw2="s2",
Jeremy Songstere405d3d2016-05-17 11:18:57 -07001134 expectedLink=18,
1135 useTCP=True)
Jeremy42df2e72016-02-23 16:37:46 -08001136 else:
1137 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabb769f562015-07-15 17:05:10 -07001138
1139 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001140 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001141 onpass=main.assertReturnString,
1142 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001143
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001144 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001145 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
kelvin-onlabb769f562015-07-15 17:05:10 -07001146 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
1147 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab58dc39e2015-08-06 08:11:09 -07001148 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
1149 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlabb769f562015-07-15 17:05:10 -07001150 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
1151 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
1152 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
1153
kelvin-onlab58dc39e2015-08-06 08:11:09 -07001154 stepResult = main.intentFunction.pointIntentTcp(
kelvin-onlabb769f562015-07-15 17:05:10 -07001155 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001156 name="SDNIP-TCP",
kelvin-onlabb769f562015-07-15 17:05:10 -07001157 host1="h1",
1158 host2="h9",
1159 deviceId1="of:0000000000000005/1",
1160 deviceId2="of:0000000000000006/1",
1161 mac1=mac1,
1162 mac2=mac2,
1163 ethType="IPV4",
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001164 ipProto=ipProto,
1165 ip1=ip1,
1166 ip2=ip2,
1167 tcp1=tcp1,
1168 tcp2=tcp2 )
kelvin-onlabb769f562015-07-15 17:05:10 -07001169
1170 utilities.assert_equals( expect=main.TRUE,
Jeremy6f000c62016-02-25 17:02:28 -08001171 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -07001172 onpass=main.assertReturnString,
1173 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001174
acsmars5d8cc862015-09-25 09:44:50 -07001175 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
1176 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001177 senders = [
1178 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1179 ]
1180 recipients = [
1181 { "name":"h11","device":"of:0000000000000006/3","mac":"00:00:00:00:00:0B" }
1182 ]
Jeremy42df2e72016-02-23 16:37:46 -08001183 testResult = main.FALSE
1184 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001185 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001186 main,
1187 name="DUALSTACK1",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001188 senders=senders,
1189 recipients=recipients,
1190 ethType="IPV4" )
1191
1192 if installResult:
1193 testResult = main.intentFunction.testPointIntent(
1194 main,
1195 intentId=installResult,
1196 name="DUALSTACK1",
1197 senders=senders,
1198 recipients=recipients,
1199 sw1="s5",
1200 sw2="s2",
1201 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001202 else:
1203 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001204
1205 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001206 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001207 onpass=main.assertReturnString,
1208 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001209
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001210 main.step( "VLAN: Add point intents between h5 and h21" )
acsmars5d8cc862015-09-25 09:44:50 -07001211 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001212 senders = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001213 { "name":"h5","device":"of:0000000000000005/5","mac":"00:00:00:00:00:05", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001214 ]
1215 recipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001216 { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001217 ]
Jeremy42df2e72016-02-23 16:37:46 -08001218 testResult = main.FALSE
1219 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001220 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001221 main,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001222 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001223 senders=senders,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001224 recipients=recipients)
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001225
1226 if installResult:
1227 testResult = main.intentFunction.testPointIntent(
1228 main,
1229 intentId=installResult,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001230 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001231 senders=senders,
1232 recipients=recipients,
1233 sw1="s5",
1234 sw2="s2",
1235 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001236
1237 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001238 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001239 onpass=main.assertReturnString,
1240 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001241
Jeremy Songsterff553672016-05-12 17:06:23 -07001242 main.step( "VLAN: Add point intents between h5 and h21" )
1243 main.assertReturnString = "Assertion Result for VLAN IPV4 point intents with VLAN treatment\n"
1244 senders = [
1245 { "name":"h4", "vlan":"100" }
1246 ]
1247 recipients = [
1248 { "name":"h21", "vlan":"200" }
1249 ]
1250 testResult = main.FALSE
1251 installResult = main.FALSE
1252 installResult = main.intentFunction.installPointIntent(
1253 main,
1254 name="VLAN2",
1255 senders=senders,
1256 recipients=recipients,
1257 setVlan=200)
1258
1259 if installResult:
1260 testResult = main.intentFunction.testPointIntent(
1261 main,
1262 intentId=installResult,
1263 name="VLAN2",
1264 senders=senders,
1265 recipients=recipients,
1266 sw1="s5",
1267 sw2="s2",
1268 expectedLink=18)
1269
1270 utilities.assert_equals( expect=main.TRUE,
1271 actual=testResult,
1272 onpass=main.assertReturnString,
1273 onfail=main.assertReturnString )
1274
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001275 main.step( "1HOP: Add point intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -07001276 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001277 senders = [
1278 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1279 ]
1280 recipients = [
1281 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1282 ]
Jeremy42df2e72016-02-23 16:37:46 -08001283 testResult = main.FALSE
1284 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001285 installResult = main.intentFunction.installPointIntent(
1286 main,
1287 name="1HOP IPV4",
1288 senders=senders,
1289 recipients=recipients,
1290 ethType="IPV4" )
1291
1292 if installResult:
1293 testResult = main.intentFunction.testPointIntent(
1294 main,
1295 intentId=installResult,
1296 name="1HOP IPV4",
1297 senders=senders,
1298 recipients=recipients,
1299 sw1="s5",
1300 sw2="s2",
1301 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001302 else:
1303 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001304
1305 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001306 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001307 onpass=main.assertReturnString,
1308 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001309
kelvin-onlab016dce22015-08-10 09:54:11 -07001310 main.intentFunction.report( main )
1311
kelvin-onlabb769f562015-07-15 17:05:10 -07001312 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001313 """
1314 Add single point to multi point intents
1315 - Get device ids
1316 - Add single point to multi point intents
1317 - Check intents
1318 - Verify flows
1319 - Ping hosts
1320 - Reroute
1321 - Link down
1322 - Verify flows
1323 - Check topology
1324 - Ping hosts
1325 - Link up
1326 - Verify flows
1327 - Check topology
1328 - Ping hosts
1329 - Remove intents
1330 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001331 if main.initialized == main.FALSE:
1332 main.log.error( "Test components did not start correctly, skipping further tests" )
1333 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001334 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001335 try:
1336 assert main.CLIs
1337 except AssertionError:
1338 main.log.error( "There is no main.CLIs, skipping test cases" )
1339 main.initialized = main.FALSE
1340 main.skipCase()
1341 try:
1342 assert main.Mininet1
1343 except AssertionError:
1344 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1345 main.initialized = main.FALSE
1346 main.skipCase()
1347 try:
1348 assert main.numSwitch
1349 except AssertionError:
1350 main.log.error( "Place the total number of switch topology in \
1351 main.numSwitch" )
1352 main.initialized = main.FALSE
1353 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001354
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001355 main.testName = "Single to Multi Point Intents"
1356 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001357 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001358 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001359 " multi point intents using " +\
1360 str( main.numCtrls ) + " node(s) cluster;\n" +\
1361 "Different type of hosts will be tested in " +\
1362 "each step such as IPV4, Dual stack, VLAN etc" +\
1363 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001364 " OVS running in Mininet and compile intents" +\
1365 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001366
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001367 main.step( "NOOPTION: Install and test single point to multi point intents" )
1368 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
1369 senders = [
1370 { "name":"h8", "device":"of:0000000000000005/8" }
1371 ]
1372 recipients = [
1373 { "name":"h16", "device":"of:0000000000000006/8" },
1374 { "name":"h24", "device":"of:0000000000000007/8" }
1375 ]
1376 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1377 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1378 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001379 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001380 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001381 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001382 name="NOOPTION",
1383 senders=senders,
1384 recipients=recipients,
1385 sw1="s5",
1386 sw2="s2")
1387
1388 if installResult:
1389 testResult = main.intentFunction.testPointIntent(
1390 main,
1391 intentId=installResult,
1392 name="NOOPTION",
1393 senders=senders,
1394 recipients=recipients,
1395 badSenders=badSenders,
1396 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001397 sw1="s5",
1398 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001399 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001400 else:
1401 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001402
1403 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001404 actual=testResult,
1405 onpass=main.assertReturnString,
1406 onfail=main.assertReturnString )
1407
1408 main.step( "IPV4: Install and test single point to multi point intents" )
1409 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses\n"
1410 senders = [
1411 { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" }
1412 ]
1413 recipients = [
1414 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1415 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1416 ]
1417 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1418 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1419 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001420 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001421 installResult = main.intentFunction.installSingleToMultiIntent(
1422 main,
1423 name="IPV4",
1424 senders=senders,
1425 recipients=recipients,
1426 ethType="IPV4",
1427 sw1="s5",
1428 sw2="s2")
1429
1430 if installResult:
1431 testResult = main.intentFunction.testPointIntent(
1432 main,
1433 intentId=installResult,
1434 name="IPV4",
1435 senders=senders,
1436 recipients=recipients,
1437 badSenders=badSenders,
1438 badRecipients=badRecipients,
1439 sw1="s5",
1440 sw2="s2",
1441 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001442 else:
1443 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001444
1445 utilities.assert_equals( expect=main.TRUE,
1446 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001447 onpass=main.assertReturnString,
1448 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001449
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001450 main.step( "IPV4_2: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001451 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 -08001452 senders = [
1453 { "name":"h8", "device":"of:0000000000000005/8" }
1454 ]
1455 recipients = [
1456 { "name":"h16", "device":"of:0000000000000006/8" },
1457 { "name":"h24", "device":"of:0000000000000007/8" }
1458 ]
1459 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1460 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1461 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001462 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001463 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001464 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001465 name="IPV4_2",
1466 senders=senders,
1467 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001468 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001469 sw1="s5",
1470 sw2="s2")
1471
1472 if installResult:
1473 testResult = main.intentFunction.testPointIntent(
1474 main,
1475 intentId=installResult,
1476 name="IPV4_2",
1477 senders=senders,
1478 recipients=recipients,
1479 badSenders=badSenders,
1480 badRecipients=badRecipients,
1481 sw1="s5",
1482 sw2="s2",
1483 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001484 else:
1485 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001486
1487 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001488 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001489 onpass=main.assertReturnString,
1490 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001491
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001492 main.step( "VLAN: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001493 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 -08001494 senders = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001495 { "name":"h4", "device":"of:0000000000000005/4", "mac":"00:00:00:00:00:04", "vlan":"100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001496 ]
1497 recipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001498 { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C", "vlan":"100" },
1499 { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14", "vlan":"100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001500 ]
1501 badSenders=[ { "name":"h13" } ] # Senders that are not in the intent
1502 badRecipients=[ { "name":"h21" } ] # Recipients that are not in the intent
1503 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001504 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001505 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001506 main,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001507 name="VLAN`",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001508 senders=senders,
1509 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001510 sw1="s5",
1511 sw2="s2")
1512
1513 if installResult:
1514 testResult = main.intentFunction.testPointIntent(
1515 main,
1516 intentId=installResult,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001517 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001518 senders=senders,
1519 recipients=recipients,
1520 badSenders=badSenders,
1521 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001522 sw1="s5",
1523 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001524 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001525 else:
1526 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001527
1528 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001529 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001530 onpass=main.assertReturnString,
1531 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001532
Jeremy Songsterff553672016-05-12 17:06:23 -07001533 main.step( "VLAN: Add single point to multi point intents" )
1534 main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n"
1535 senders = [
1536 { "name":"h5", "vlan":"200" }
1537 ]
1538 recipients = [
1539 { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C", "vlan":"100" },
1540 { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14", "vlan":"100" }
1541 ]
1542 badSenders=[ { "name":"h13" } ] # Senders that are not in the intent
1543 badRecipients=[ { "name":"h21" } ] # Recipients that are not in the intent
1544 testResult = main.FALSE
1545 installResult = main.FALSE
1546 installResult = main.intentFunction.installSingleToMultiIntent(
1547 main,
1548 name="VLAN2",
1549 senders=senders,
1550 recipients=recipients,
1551 sw1="s5",
1552 sw2="s2",
1553 setVlan=100)
1554
1555 if installResult:
1556 testResult = main.intentFunction.testPointIntent(
1557 main,
1558 intentId=installResult,
1559 name="VLAN2",
1560 senders=senders,
1561 recipients=recipients,
1562 badSenders=badSenders,
1563 badRecipients=badRecipients,
1564 sw1="s5",
1565 sw2="s2",
1566 expectedLink=18)
1567 else:
1568 main.CLIs[ 0 ].removeAllIntents( purge=True )
1569
1570 utilities.assert_equals( expect=main.TRUE,
1571 actual=testResult,
1572 onpass=main.assertReturnString,
1573 onfail=main.assertReturnString )
1574
kelvin-onlab016dce22015-08-10 09:54:11 -07001575 main.intentFunction.report( main )
1576
kelvin-onlabb769f562015-07-15 17:05:10 -07001577 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001578 """
1579 Add multi point to single point intents
1580 - Get device ids
1581 - Add multi point to single point intents
1582 - Check intents
1583 - Verify flows
1584 - Ping hosts
1585 - Reroute
1586 - Link down
1587 - Verify flows
1588 - Check topology
1589 - Ping hosts
1590 - Link up
1591 - Verify flows
1592 - Check topology
1593 - Ping hosts
1594 - Remove intents
1595 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001596 if main.initialized == main.FALSE:
1597 main.log.error( "Test components did not start correctly, skipping further tests" )
1598 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001599 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001600 try:
1601 assert main.CLIs
1602 except AssertionError:
1603 main.log.error( "There is no main.CLIs, skipping test cases" )
1604 main.initialized = main.FALSE
1605 main.skipCase()
1606 try:
1607 assert main.Mininet1
1608 except AssertionError:
1609 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1610 main.initialized = main.FALSE
1611 main.skipCase()
1612 try:
1613 assert main.numSwitch
1614 except AssertionError:
1615 main.log.error( "Place the total number of switch topology in \
1616 main.numSwitch" )
1617 main.initialized = main.FALSE
1618 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001619
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001620 main.testName = "Multi To Single Point Intents"
1621 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001622 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001623 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001624 " multi point intents using " +\
1625 str( main.numCtrls ) + " node(s) cluster;\n" +\
1626 "Different type of hosts will be tested in " +\
1627 "each step such as IPV4, Dual stack, VLAN etc" +\
1628 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001629 " OVS running in Mininet and compile intents" +\
1630 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001631
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001632 main.step( "NOOPTION: Add multi point to single point intents" )
1633 main.assertReturnString = "Assertion results for NOOPTION multi to single point intent\n"
1634 senders = [
1635 { "name":"h16", "device":"of:0000000000000006/8" },
1636 { "name":"h24", "device":"of:0000000000000007/8" }
1637 ]
1638 recipients = [
1639 { "name":"h8", "device":"of:0000000000000005/8" }
1640 ]
1641 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1642 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1643 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001644 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001645 installResult = main.intentFunction.installMultiToSingleIntent(
1646 main,
1647 name="NOOPTION",
1648 senders=senders,
1649 recipients=recipients,
1650 sw1="s5",
Jeremye0cb5eb2016-01-27 17:39:09 -08001651 sw2="s2" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001652
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001653 if installResult:
1654 testResult = main.intentFunction.testPointIntent(
1655 main,
1656 intentId=installResult,
1657 name="NOOPTION",
1658 senders=senders,
1659 recipients=recipients,
1660 badSenders=badSenders,
1661 badRecipients=badRecipients,
1662 sw1="s5",
1663 sw2="s2",
Jeremye0cb5eb2016-01-27 17:39:09 -08001664 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001665 else:
1666 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001667
1668 utilities.assert_equals( expect=main.TRUE,
1669 actual=testResult,
1670 onpass=main.assertReturnString,
1671 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001672
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001673 main.step( "IPV4: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001674 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 -08001675 senders = [
1676 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1677 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1678 ]
1679 recipients = [
1680 { "name":"h8", "device":"of:0000000000000005/8", "mac":"00:00:00:00:00:08" }
1681 ]
1682 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1683 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1684 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001685 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001686 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001687 main,
1688 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001689 senders=senders,
1690 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001691 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001692 sw1="s5",
1693 sw2="s2")
1694
1695 if installResult:
1696 testResult = main.intentFunction.testPointIntent(
1697 main,
1698 intentId=installResult,
1699 name="IPV4",
1700 senders=senders,
1701 recipients=recipients,
1702 badSenders=badSenders,
1703 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001704 sw1="s5",
1705 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001706 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001707 else:
1708 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001709
1710 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001711 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001712 onpass=main.assertReturnString,
1713 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001714
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001715 main.step( "IPV4_2: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001716 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 -08001717 senders = [
1718 { "name":"h16", "device":"of:0000000000000006/8" },
1719 { "name":"h24", "device":"of:0000000000000007/8" }
1720 ]
1721 recipients = [
1722 { "name":"h8", "device":"of:0000000000000005/8" }
1723 ]
1724 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1725 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1726 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001727 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001728 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001729 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001730 name="IPV4_2",
1731 senders=senders,
1732 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001733 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001734 sw1="s5",
1735 sw2="s2")
1736
1737 if installResult:
1738 testResult = main.intentFunction.testPointIntent(
1739 main,
1740 intentId=installResult,
1741 name="IPV4_2",
1742 senders=senders,
1743 recipients=recipients,
1744 badSenders=badSenders,
1745 badRecipients=badRecipients,
1746 sw1="s5",
1747 sw2="s2",
1748 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001749 else:
1750 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001751
1752 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001753 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001754 onpass=main.assertReturnString,
1755 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001756
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001757 main.step( "VLAN: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001758 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 -08001759 senders = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001760 { "name":"h13", "device":"of:0000000000000006/5", "vlan":"200" },
1761 { "name":"h21", "device":"of:0000000000000007/5", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001762 ]
1763 recipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001764 { "name":"h5", "device":"of:0000000000000005/5", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001765 ]
1766 badSenders=[ { "name":"h12" } ] # Senders that are not in the intent
1767 badRecipients=[ { "name":"h20" } ] # Recipients that are not in the intent
1768 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001769 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001770 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001771 main,
1772 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001773 senders=senders,
1774 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001775 sw1="s5",
1776 sw2="s2")
1777
1778 if installResult:
1779 testResult = main.intentFunction.testPointIntent(
1780 main,
1781 intentId=installResult,
1782 name="VLAN",
1783 senders=senders,
1784 recipients=recipients,
1785 badSenders=badSenders,
1786 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001787 sw1="s5",
1788 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001789 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001790 else:
1791 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001792
1793 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001794 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001795 onpass=main.assertReturnString,
1796 onfail=main.assertReturnString )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001797
Jeremy Songsterff553672016-05-12 17:06:23 -07001798 # Right now this fails because of this bug: https://jira.onosproject.org/browse/ONOS-4383
1799 main.step( "VLAN: Add multi point to single point intents" )
1800 main.assertReturnString = "Assertion results for multi to single point intent with VLAN ID treatment\n"
1801 senders = [
1802 { "name":"h13", "device":"of:0000000000000006/5", "vlan":"200" },
1803 { "name":"h21", "device":"of:0000000000000007/5", "vlan":"200" }
1804 ]
1805 recipients = [
1806 { "name":"h4", "vlan":"100" }
1807 ]
1808 badSenders=[ { "name":"h12" } ] # Senders that are not in the intent
1809 badRecipients=[ { "name":"h20" } ] # Recipients that are not in the intent
1810 testResult = main.FALSE
1811 installResult = main.FALSE
1812 installResult = main.intentFunction.installMultiToSingleIntent(
1813 main,
1814 name="VLAN2",
1815 senders=senders,
1816 recipients=recipients,
1817 sw1="s5",
1818 sw2="s2",
1819 setVlan=100)
1820
1821 if installResult:
1822 testResult = main.intentFunction.testPointIntent(
1823 main,
1824 intentId=installResult,
1825 name="VLAN2",
1826 senders=senders,
1827 recipients=recipients,
1828 badSenders=badSenders,
1829 badRecipients=badRecipients,
1830 sw1="s5",
1831 sw2="s2",
1832 expectedLink=18)
1833 else:
1834 main.CLIs[ 0 ].removeAllIntents( purge=True )
1835
1836 utilities.assert_equals( expect=main.TRUE,
1837 actual=testResult,
1838 onpass=main.assertReturnString,
1839 onfail=main.assertReturnString )
1840
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001841 main.intentFunction.report( main )
1842
acsmars1ff5e052015-07-23 11:27:48 -07001843 def CASE5000( self, main ):
1844 """
acsmars5d8cc862015-09-25 09:44:50 -07001845 Tests Host Mobility
1846 Modifies the topology location of h1
acsmars1ff5e052015-07-23 11:27:48 -07001847 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001848 if main.initialized == main.FALSE:
1849 main.log.error( "Test components did not start correctly, skipping further tests" )
1850 main.skipCase()
acsmars1ff5e052015-07-23 11:27:48 -07001851 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001852 try:
1853 assert main.CLIs
1854 except AssertionError:
1855 main.log.error( "There is no main.CLIs, skipping test cases" )
1856 main.initialized = main.FALSE
1857 main.skipCase()
1858 try:
1859 assert main.Mininet1
1860 except AssertionError:
1861 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1862 main.initialized = main.FALSE
1863 main.skipCase()
1864 try:
1865 assert main.numSwitch
1866 except AssertionError:
1867 main.log.error( "Place the total number of switch topology in \
1868 main.numSwitch" )
1869 main.initialized = main.FALSE
1870 main.skipCase()
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001871 main.case( "Test host mobility with host intents " )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001872 main.step( "Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07001873 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1874
Jeremy2f190ca2016-01-29 15:23:57 -08001875 main.log.info( "Moving h1 from s5 to s6")
acsmars1ff5e052015-07-23 11:27:48 -07001876 main.Mininet1.moveHost( "h1","s5","s6" )
1877
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001878 # Send discovery ping from moved host
1879 # Moving the host brings down the default interfaces and creates a new one.
1880 # Scapy is restarted on this host to detect the new interface
1881 main.h1.stopScapy()
1882 main.h1.startScapy()
1883
1884 # Discover new host location in ONOS and populate host data.
1885 # Host 1 IP and MAC should be unchanged
1886 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
1887 main.intentFunction.populateHostData( main )
1888
acsmars1ff5e052015-07-23 11:27:48 -07001889 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1890
1891 utilities.assert_equals( expect="of:0000000000000006",
1892 actual=h1PostMove,
1893 onpass="Mobility: Successfully moved h1 to s6",
acsmars5d8cc862015-09-25 09:44:50 -07001894 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001895 " to single point intents" +
1896 " with IPV4 type and MAC addresses" +
1897 " in the same VLAN" )
1898
1899 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001900 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001901 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
1902 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
Jeremy42df2e72016-02-23 16:37:46 -08001903 testResult = main.FALSE
1904 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001905 installResult = main.intentFunction.installHostIntent( main,
1906 name='IPV4 Mobility IPV4',
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001907 onosNode='0',
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001908 host1=host1,
Jeremye0cb5eb2016-01-27 17:39:09 -08001909 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -08001910 if installResult:
1911 testResult = main.intentFunction.testHostIntent( main,
1912 name='Host Mobility IPV4',
1913 intentId = installResult,
1914 onosNode='0',
1915 host1=host1,
1916 host2=host2,
1917 sw1="s6",
1918 sw2="s2",
1919 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001920 else:
1921 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001922
1923 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001924 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001925 onpass=main.assertReturnString,
1926 onfail=main.assertReturnString )
kelvin-onlab016dce22015-08-10 09:54:11 -07001927
1928 main.intentFunction.report( main )
Jeremye0cb5eb2016-01-27 17:39:09 -08001929
1930 def CASE6000( self, main ):
1931 """
1932 Tests Multi to Single Point Intent and Single to Multi Point Intent End Point Failure
1933 """
Jeremy Songster9385d412016-06-02 17:57:36 -07001934 # At some later point discussion on this behavior in MPSP and SPMP intents
1935 # will be reoppened and this test case may need to be updated to reflect
1936 # the outcomes of that discussion
Jeremyd9e4eb12016-04-13 12:09:06 -07001937 if main.initialized == main.FALSE:
1938 main.log.error( "Test components did not start correctly, skipping further tests" )
1939 main.skipCase()
Jeremye0cb5eb2016-01-27 17:39:09 -08001940 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001941 try:
1942 assert main.CLIs
1943 except AssertionError:
1944 main.log.error( "There is no main.CLIs, skipping test cases" )
1945 main.initialized = main.FALSE
1946 main.skipCase()
1947 try:
1948 assert main.Mininet1
1949 except AssertionError:
1950 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1951 main.initialized = main.FALSE
1952 main.skipCase()
1953 try:
1954 assert main.numSwitch
1955 except AssertionError:
1956 main.log.error( "Place the total number of switch topology in \
1957 main.numSwitch" )
1958 main.initialized = main.FALSE
1959 main.skipCase()
Jeremye0cb5eb2016-01-27 17:39:09 -08001960 main.case( "Test Multi to Single End Point Failure" )
Jeremy Songster9385d412016-06-02 17:57:36 -07001961 main.step( "Installing Multi to Single Point intents with no options set" )
1962 main.assertReturnString = "Assertion results for IPV4 multi to single " +\
1963 "point intent end point failure with no options set\n"
Jeremye0cb5eb2016-01-27 17:39:09 -08001964 senders = [
1965 { "name":"h16", "device":"of:0000000000000006/8" },
1966 { "name":"h24", "device":"of:0000000000000007/8" }
1967 ]
1968 recipients = [
1969 { "name":"h8", "device":"of:0000000000000005/8" }
1970 ]
1971 isolatedSenders = [
1972 { "name":"h24"}
1973 ]
1974 isolatedRecipients = []
1975 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001976 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08001977 installResult = main.intentFunction.installMultiToSingleIntent(
1978 main,
1979 name="NOOPTION",
1980 senders=senders,
1981 recipients=recipients,
1982 sw1="s5",
1983 sw2="s2" )
1984
1985 if installResult:
1986 testResult = main.intentFunction.testEndPointFail(
1987 main,
1988 intentId=installResult,
1989 name="NOOPTION",
1990 senders=senders,
1991 recipients=recipients,
1992 isolatedSenders=isolatedSenders,
1993 isolatedRecipients=isolatedRecipients,
1994 sw1="s6",
1995 sw2="s2",
1996 sw3="s4",
1997 sw4="s1",
1998 sw5="s3",
1999 expectedLink1=16,
2000 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002001 else:
2002 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002003
2004 utilities.assert_equals( expect=main.TRUE,
2005 actual=testResult,
2006 onpass=main.assertReturnString,
2007 onfail=main.assertReturnString )
2008
Jeremy Songster9385d412016-06-02 17:57:36 -07002009 main.step( "Installing Multi to Single Point intents with partial failure allowed" )
2010
2011 main.assertReturnString = "Assertion results for IPV4 multi to single " +\
2012 "with partial failures allowed\n"
2013 senders = [
2014 { "name":"h16", "device":"of:0000000000000006/8" },
2015 { "name":"h24", "device":"of:0000000000000007/8" }
2016 ]
2017 recipients = [
2018 { "name":"h8", "device":"of:0000000000000005/8" }
2019 ]
2020 isolatedSenders = [
2021 { "name":"h24"}
2022 ]
2023 isolatedRecipients = []
2024 testResult = main.FALSE
2025 installResult = main.FALSE
2026 installResult = main.intentFunction.installMultiToSingleIntent(
2027 main,
2028 name="NOOPTION",
2029 senders=senders,
2030 recipients=recipients,
2031 sw1="s5",
2032 sw2="s2",
2033 partial=True )
2034
2035 if installResult:
2036 testResult = main.intentFunction.testEndPointFail(
2037 main,
2038 intentId=installResult,
2039 name="NOOPTION",
2040 senders=senders,
2041 recipients=recipients,
2042 isolatedSenders=isolatedSenders,
2043 isolatedRecipients=isolatedRecipients,
2044 sw1="s6",
2045 sw2="s2",
2046 sw3="s4",
2047 sw4="s1",
2048 sw5="s3",
2049 expectedLink1=16,
2050 expectedLink2=14,
2051 partial=True )
2052 else:
2053 main.CLIs[ 0 ].removeAllIntents( purge=True )
2054
2055 utilities.assert_equals( expect=main.TRUE,
2056 actual=testResult,
2057 onpass=main.assertReturnString,
2058 onfail=main.assertReturnString )
2059
Jeremye0cb5eb2016-01-27 17:39:09 -08002060 main.step( "NOOPTION: Install and test single point to multi point intents" )
Jeremy Songster9385d412016-06-02 17:57:36 -07002061 main.assertReturnString = "Assertion results for IPV4 single to multi " +\
2062 "point intent with no options set\n"
Jeremye0cb5eb2016-01-27 17:39:09 -08002063 senders = [
2064 { "name":"h8", "device":"of:0000000000000005/8" }
2065 ]
2066 recipients = [
2067 { "name":"h16", "device":"of:0000000000000006/8" },
2068 { "name":"h24", "device":"of:0000000000000007/8" }
2069 ]
Jeremy Songster9385d412016-06-02 17:57:36 -07002070 isolatedSenders = []
2071 isolatedRecipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07002072 { "name":"h24"}
Jeremye0cb5eb2016-01-27 17:39:09 -08002073 ]
2074 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08002075 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08002076 installResult = main.intentFunction.installSingleToMultiIntent(
2077 main,
2078 name="NOOPTION",
2079 senders=senders,
2080 recipients=recipients,
2081 sw1="s5",
2082 sw2="s2")
2083
2084 if installResult:
2085 testResult = main.intentFunction.testEndPointFail(
2086 main,
2087 intentId=installResult,
2088 name="NOOPTION",
2089 senders=senders,
2090 recipients=recipients,
2091 isolatedSenders=isolatedSenders,
2092 isolatedRecipients=isolatedRecipients,
2093 sw1="s6",
2094 sw2="s2",
2095 sw3="s4",
2096 sw4="s1",
2097 sw5="s3",
2098 expectedLink1=16,
2099 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002100 else:
2101 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002102
2103 utilities.assert_equals( expect=main.TRUE,
2104 actual=testResult,
2105 onpass=main.assertReturnString,
2106 onfail=main.assertReturnString )
Jeremy Songster9385d412016-06-02 17:57:36 -07002107 # Right now this functionality doesn't work properly in SPMP intents
2108 main.step( "NOOPTION: Install and test single point to multi point " +\
2109 "intents with partial failures allowed" )
2110 main.assertReturnString = "Assertion results for IPV4 single to multi " +\
2111 "point intent with partial failures allowed\n"
2112 senders = [
2113 { "name":"h8", "device":"of:0000000000000005/8" }
2114 ]
2115 recipients = [
2116 { "name":"h16", "device":"of:0000000000000006/8" },
2117 { "name":"h24", "device":"of:0000000000000007/8" }
2118 ]
2119 isolatedSenders = []
2120 isolatedRecipients = [
2121 { "name":"h24"}
2122 ]
2123 testResult = main.FALSE
2124 installResult = main.FALSE
2125 installResult = main.intentFunction.installSingleToMultiIntent(
2126 main,
2127 name="NOOPTION",
2128 senders=senders,
2129 recipients=recipients,
2130 sw1="s5",
2131 sw2="s2",
2132 partial=True)
2133
2134 if installResult:
2135 testResult = main.intentFunction.testEndPointFail(
2136 main,
2137 intentId=installResult,
2138 name="NOOPTION",
2139 senders=senders,
2140 recipients=recipients,
2141 isolatedSenders=isolatedSenders,
2142 isolatedRecipients=isolatedRecipients,
2143 sw1="s6",
2144 sw2="s2",
2145 sw3="s4",
2146 sw4="s1",
2147 sw5="s3",
2148 expectedLink1=16,
2149 expectedLink2=14,
2150 partial=True )
2151 else:
2152 main.CLIs[ 0 ].removeAllIntents( purge=True )
2153
2154 utilities.assert_equals( expect=main.TRUE,
2155 actual=testResult,
2156 onpass=main.assertReturnString,
2157 onfail=main.assertReturnString )
Jeremye0cb5eb2016-01-27 17:39:09 -08002158
Jeremy2f190ca2016-01-29 15:23:57 -08002159 main.intentFunction.report( main )