blob: 167a8471baffa4ded0ea75f102cc3ee503ad689f [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" )
Jeremy Songster31aad312016-06-13 16:32:11 -0700670 stepResult = main.TRUE
671 scpResult = main.TRUE
672 copyResult = main.TRUE
Jeremy Songstercc5414b2016-07-11 10:59:53 -0700673 for i in range( main.numCtrls ):
674 main.node = main.CLIs[ i ]
Jeremy Songster17147f22016-05-31 18:30:52 -0700675 ip = main.ONOSip[ i ]
676 main.node.ip_address = ip
Jeremy Songster31aad312016-06-13 16:32:11 -0700677 scpResult = scpResult and main.ONOSbench.scp( main.node ,
678 "/opt/onos/log/karaf.log",
679 "/tmp/karaf.log",
680 direction="from" )
681 copyResult = copyResult and main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
682 copyFileName=( "karaf.log.node{0}.cycle{1}".format( str( i + 1 ), str( main.cycle ) ) ) )
683 if scpResult and copyResult:
684 stepResult = main.TRUE and stepResult
685 else:
686 stepResult = main.FALSE and stepResult
Jeremy Songster31aad312016-06-13 16:32:11 -0700687 utilities.assert_equals( expect=main.TRUE,
688 actual=stepResult,
689 onpass="Successfully copied remote ONOS logs",
690 onfail="Failed to copy remote ONOS logs" )
Jeremy Songster17147f22016-05-31 18:30:52 -0700691
kelvin-onlabb769f562015-07-15 17:05:10 -0700692 def CASE1000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700693 """
694 Add host intents between 2 host:
695 - Discover hosts
696 - Add host intents
697 - Check intents
698 - Verify flows
699 - Ping hosts
700 - Reroute
701 - Link down
702 - Verify flows
703 - Check topology
704 - Ping hosts
705 - Link up
706 - Verify flows
707 - Check topology
708 - Ping hosts
709 - Remove intents
710 """
711 import time
712 import json
713 import re
Jeremyd9e4eb12016-04-13 12:09:06 -0700714 if main.initialized == main.FALSE:
715 main.log.error( "Test components did not start correctly, skipping further tests" )
716 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700717 # Assert variables - These variable's name|format must be followed
718 # if you want to use the wrapper function
719 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -0700720 try:
721 assert main.CLIs
722 except AssertionError:
723 main.log.error( "There is no main.CLIs, skipping test cases" )
724 main.initialized = main.FALSE
725 main.skipCase()
726 try:
727 assert main.Mininet1
728 except AssertionError:
729 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
730 main.initialized = main.FALSE
731 main.skipCase()
732 try:
733 assert main.numSwitch
734 except AssertionError:
735 main.log.error( "Place the total number of switch topology in \
736 main.numSwitch" )
737 main.initialized = main.FALSE
738 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700739
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800740 # Save leader candidates
acsmarse6b410f2015-07-17 14:39:34 -0700741 intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
742
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700743 main.testName = "Host Intents"
744 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -0700745 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -0700746 main.caseExplanation = "This test case tests Host intents using " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700747 str( main.numCtrls ) + " node(s) cluster;\n" +\
748 "Different type of hosts will be tested in " +\
749 "each step such as IPV4, Dual stack, VLAN " +\
Jeremyeb51cb12016-03-28 17:53:35 -0700750 "etc;\nThe test will use OF " + main.OFProtocol +\
751 " OVS running in Mininet and compile intents" +\
Jeremy6e9748f2016-03-25 15:03:39 -0700752 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700753
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700754 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700755 main.assertReturnString = "Assertion Result for IPV4 host intent with mac addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800756 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
757 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
758 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800759 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800760 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700761 name='IPV4',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800762 onosNode='0',
763 host1=host1,
764 host2=host2)
765 if installResult:
766 testResult = main.intentFunction.testHostIntent( main,
767 name='IPV4',
768 intentId = installResult,
769 onosNode='0',
770 host1=host1,
771 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700772 sw1='s5',
773 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800774 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800775 else:
776 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800777
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700778 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800779 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700780 onpass=main.assertReturnString,
781 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700782
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700783 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700784 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800785 host1 = { "name":"h3","id":"00:00:00:00:00:03/-1" }
786 host2 = { "name":"h11","id":"00:00:00:00:00:0B/-1 "}
787 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800788 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800789 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700790 name='DUALSTACK',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800791 onosNode='0',
792 host1=host1,
793 host2=host2)
794
795 if installResult:
796 testResult = main.intentFunction.testHostIntent( main,
797 name='DUALSTACK',
798 intentId = installResult,
799 onosNode='0',
800 host1=host1,
801 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700802 sw1='s5',
803 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800804 expectedLink = 18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700805
806 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800807 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700808 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800809 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700810
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700811 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700812 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800813 host1 = { "name":"h1" }
814 host2 = { "name":"h11" }
815 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800816 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800817 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700818 name='DUALSTACK2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800819 onosNode='0',
820 host1=host1,
821 host2=host2)
822
823 if installResult:
824 testResult = main.intentFunction.testHostIntent( main,
825 name='DUALSTACK2',
826 intentId = installResult,
827 onosNode='0',
828 host1=host1,
829 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700830 sw1='s5',
831 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800832 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800833 else:
834 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700835
836 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800837 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700838 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800839 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700840
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700841 main.step( "1HOP: Add host intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -0700842 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800843 host1 = { "name":"h1" }
844 host2 = { "name":"h3" }
845 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800846 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800847 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700848 name='1HOP',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800849 onosNode='0',
850 host1=host1,
851 host2=host2)
852
853 if installResult:
854 testResult = main.intentFunction.testHostIntent( main,
855 name='1HOP',
856 intentId = installResult,
857 onosNode='0',
858 host1=host1,
859 host2=host2,
860 sw1='s5',
861 sw2='s2',
862 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800863 else:
864 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700865
866 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800867 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700868 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800869 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700870
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700871 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
acsmars5d8cc862015-09-25 09:44:50 -0700872 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jeremy Songster832f9e92016-05-05 14:30:49 -0700873 host1 = { "name":"h4","id":"00:00:00:00:00:04/100", "vlan":"100" }
874 host2 = { "name":"h12","id":"00:00:00:00:00:0C/100", "vlan":"100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800875 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800876 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800877 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700878 name='VLAN1',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800879 onosNode='0',
880 host1=host1,
881 host2=host2)
882
883 if installResult:
884 testResult = main.intentFunction.testHostIntent( main,
885 name='VLAN1',
886 intentId = installResult,
887 onosNode='0',
888 host1=host1,
889 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700890 sw1='s5',
891 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800892 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800893 else:
894 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700895
896 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800897 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700898 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800899 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700900
Jeremy Songsterff553672016-05-12 17:06:23 -0700901 main.step( "VLAN2: Add vlan host intents between h4 and h13" )
902 main.assertReturnString = "Assertion Result vlan IPV4\n"
903 host1 = { "name":"h5", "vlan":"200" }
904 host2 = { "name":"h12", "vlan":"100" }
905 testResult = main.FALSE
906 installResult = main.FALSE
907 installResult = main.intentFunction.installHostIntent( main,
908 name='VLAN2',
909 onosNode='0',
910 host1=host1,
911 host2=host2)
912
913 if installResult:
914 testResult = main.intentFunction.testHostIntent( main,
915 name='VLAN2',
916 intentId = installResult,
917 onosNode='0',
918 host1=host1,
919 host2=host2,
920 sw1='s5',
921 sw2='s2',
922 expectedLink = 18)
923 else:
924 main.CLIs[ 0 ].removeAllIntents( purge=True )
925
926 utilities.assert_equals( expect=main.TRUE,
927 actual=testResult,
928 onpass=main.assertReturnString,
929 onfail=main.assertReturnString)
930
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800931 main.step( "Confirm that ONOS leadership is unchanged")
acsmarse6b410f2015-07-17 14:39:34 -0700932 intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
933 main.intentFunction.checkLeaderChange( intentLeadersOld,
934 intentLeadersNew )
935
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800936 utilities.assert_equals( expect=main.TRUE,
937 actual=testResult,
938 onpass="ONOS Leaders Unchanged",
939 onfail="ONOS Leader Mismatch")
940
kelvin-onlab016dce22015-08-10 09:54:11 -0700941 main.intentFunction.report( main )
942
kelvin-onlabb769f562015-07-15 17:05:10 -0700943 def CASE2000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700944 """
945 Add point intents between 2 hosts:
946 - Get device ids | ports
947 - Add point intents
948 - Check intents
949 - Verify flows
950 - Ping hosts
951 - Reroute
952 - Link down
953 - Verify flows
954 - Check topology
955 - Ping hosts
956 - Link up
957 - Verify flows
958 - Check topology
959 - Ping hosts
960 - Remove intents
961 """
962 import time
963 import json
964 import re
Jeremyd9e4eb12016-04-13 12:09:06 -0700965 if main.initialized == main.FALSE:
966 main.log.error( "Test components did not start correctly, skipping further tests" )
967 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700968 # Assert variables - These variable's name|format must be followed
969 # if you want to use the wrapper function
970 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -0700971 try:
972 assert main.CLIs
973 except AssertionError:
974 main.log.error( "There is no main.CLIs, skipping test cases" )
975 main.initialized = main.FALSE
976 main.skipCase()
977 try:
978 assert main.Mininet1
979 except AssertionError:
980 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
981 main.initialized = main.FALSE
982 main.skipCase()
983 try:
984 assert main.numSwitch
985 except AssertionError:
986 main.log.error( "Place the total number of switch topology in \
987 main.numSwitch" )
988 main.initialized = main.FALSE
989 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700990
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700991 main.testName = "Point Intents"
992 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -0700993 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -0700994 main.caseExplanation = "This test case will test point to point" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700995 " intents using " + str( main.numCtrls ) +\
996 " node(s) cluster;\n" +\
997 "Different type of hosts will be tested in " +\
998 "each step such as IPV4, Dual stack, VLAN etc" +\
999 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001000 " OVS running in Mininet and compile intents" +\
1001 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001002
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001003 # No option point intents
1004 main.step( "NOOPTION: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001005 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001006 senders = [
1007 { "name":"h1","device":"of:0000000000000005/1" }
1008 ]
1009 recipients = [
1010 { "name":"h9","device":"of:0000000000000006/1" }
1011 ]
Jeremy42df2e72016-02-23 16:37:46 -08001012 testResult = main.FALSE
1013 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001014 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001015 main,
1016 name="NOOPTION",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001017 senders=senders,
1018 recipients=recipients )
1019
1020 if installResult:
1021 testResult = main.intentFunction.testPointIntent(
1022 main,
1023 intentId=installResult,
1024 name="NOOPTION",
1025 senders=senders,
1026 recipients=recipients,
1027 sw1="s5",
1028 sw2="s2",
1029 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001030 else:
1031 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001032
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001033 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001034 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001035 onpass=main.assertReturnString,
1036 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001037
1038 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -07001039 main.step( "IPV4: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001040 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001041 senders = [
1042 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1043 ]
1044 recipients = [
1045 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09" }
1046 ]
Jeremy42df2e72016-02-23 16:37:46 -08001047 testResult = main.FALSE
1048 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001049 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001050 main,
1051 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001052 senders=senders,
1053 recipients=recipients,
1054 ethType="IPV4" )
1055
1056 if installResult:
1057 testResult = main.intentFunction.testPointIntent(
1058 main,
1059 intentId=installResult,
1060 name="IPV4",
1061 senders=senders,
1062 recipients=recipients,
1063 sw1="s5",
1064 sw2="s2",
1065 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001066 else:
1067 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001068
1069 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001070 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001071 onpass=main.assertReturnString,
1072 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001073 main.step( "IPV4_2: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001074 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001075 senders = [
1076 { "name":"h1","device":"of:0000000000000005/1" }
1077 ]
1078 recipients = [
1079 { "name":"h9","device":"of:0000000000000006/1" }
1080 ]
Jeremy42df2e72016-02-23 16:37:46 -08001081 testResult = main.FALSE
1082 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001083 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001084 main,
1085 name="IPV4_2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001086 senders=senders,
1087 recipients=recipients,
1088 ethType="IPV4" )
1089
1090 if installResult:
1091 testResult = main.intentFunction.testPointIntent(
1092 main,
1093 intentId=installResult,
1094 name="IPV4_2",
1095 senders=senders,
1096 recipients=recipients,
1097 sw1="s5",
1098 sw2="s2",
1099 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001100 else:
1101 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001102
1103 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001104 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001105 onpass=main.assertReturnString,
1106 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001107
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001108 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001109 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001110 senders = [
1111 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01",
Jeremy6f000c62016-02-25 17:02:28 -08001112 "ip":( main.h1.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001113 ]
1114 recipients = [
1115 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09",
Jeremy6f000c62016-02-25 17:02:28 -08001116 "ip":( main.h9.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001117 ]
Jeremy6f000c62016-02-25 17:02:28 -08001118 ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ]
kelvin-onlab79ce0492015-07-27 16:14:39 -07001119 # Uneccessary, not including this in the selectors
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001120 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
1121 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
Jeremy42df2e72016-02-23 16:37:46 -08001122 testResult = main.FALSE
1123 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001124 installResult = main.intentFunction.installPointIntent(
1125 main,
1126 name="SDNIP-ICMP",
1127 senders=senders,
1128 recipients=recipients,
1129 ethType="IPV4",
1130 ipProto=ipProto,
1131 tcpSrc=tcpSrc,
1132 tcpDst=tcpDst )
1133
1134 if installResult:
1135 testResult = main.intentFunction.testPointIntent(
1136 main,
1137 intentId=installResult,
1138 name="SDNIP_ICMP",
1139 senders=senders,
1140 recipients=recipients,
1141 sw1="s5",
1142 sw2="s2",
Jeremy Songstere405d3d2016-05-17 11:18:57 -07001143 expectedLink=18,
1144 useTCP=True)
Jeremy42df2e72016-02-23 16:37:46 -08001145 else:
1146 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabb769f562015-07-15 17:05:10 -07001147
1148 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001149 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001150 onpass=main.assertReturnString,
1151 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001152
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001153 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001154 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
kelvin-onlabb769f562015-07-15 17:05:10 -07001155 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
1156 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab58dc39e2015-08-06 08:11:09 -07001157 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
1158 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlabb769f562015-07-15 17:05:10 -07001159 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
1160 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
1161 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
1162
kelvin-onlab58dc39e2015-08-06 08:11:09 -07001163 stepResult = main.intentFunction.pointIntentTcp(
kelvin-onlabb769f562015-07-15 17:05:10 -07001164 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001165 name="SDNIP-TCP",
kelvin-onlabb769f562015-07-15 17:05:10 -07001166 host1="h1",
1167 host2="h9",
1168 deviceId1="of:0000000000000005/1",
1169 deviceId2="of:0000000000000006/1",
1170 mac1=mac1,
1171 mac2=mac2,
1172 ethType="IPV4",
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001173 ipProto=ipProto,
1174 ip1=ip1,
1175 ip2=ip2,
1176 tcp1=tcp1,
1177 tcp2=tcp2 )
kelvin-onlabb769f562015-07-15 17:05:10 -07001178
1179 utilities.assert_equals( expect=main.TRUE,
Jeremy6f000c62016-02-25 17:02:28 -08001180 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -07001181 onpass=main.assertReturnString,
1182 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001183
acsmars5d8cc862015-09-25 09:44:50 -07001184 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
1185 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001186 senders = [
1187 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1188 ]
1189 recipients = [
1190 { "name":"h11","device":"of:0000000000000006/3","mac":"00:00:00:00:00:0B" }
1191 ]
Jeremy42df2e72016-02-23 16:37:46 -08001192 testResult = main.FALSE
1193 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001194 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001195 main,
1196 name="DUALSTACK1",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001197 senders=senders,
1198 recipients=recipients,
1199 ethType="IPV4" )
1200
1201 if installResult:
1202 testResult = main.intentFunction.testPointIntent(
1203 main,
1204 intentId=installResult,
1205 name="DUALSTACK1",
1206 senders=senders,
1207 recipients=recipients,
1208 sw1="s5",
1209 sw2="s2",
1210 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001211 else:
1212 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001213
1214 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001215 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001216 onpass=main.assertReturnString,
1217 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001218
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001219 main.step( "VLAN: Add point intents between h5 and h21" )
acsmars5d8cc862015-09-25 09:44:50 -07001220 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001221 senders = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001222 { "name":"h5","device":"of:0000000000000005/5","mac":"00:00:00:00:00:05", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001223 ]
1224 recipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001225 { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001226 ]
Jeremy42df2e72016-02-23 16:37:46 -08001227 testResult = main.FALSE
1228 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001229 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001230 main,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001231 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001232 senders=senders,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001233 recipients=recipients)
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001234
1235 if installResult:
1236 testResult = main.intentFunction.testPointIntent(
1237 main,
1238 intentId=installResult,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001239 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001240 senders=senders,
1241 recipients=recipients,
1242 sw1="s5",
1243 sw2="s2",
1244 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001245
1246 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001247 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001248 onpass=main.assertReturnString,
1249 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001250
Jeremy Songsterff553672016-05-12 17:06:23 -07001251 main.step( "VLAN: Add point intents between h5 and h21" )
1252 main.assertReturnString = "Assertion Result for VLAN IPV4 point intents with VLAN treatment\n"
1253 senders = [
1254 { "name":"h4", "vlan":"100" }
1255 ]
1256 recipients = [
1257 { "name":"h21", "vlan":"200" }
1258 ]
1259 testResult = main.FALSE
1260 installResult = main.FALSE
1261 installResult = main.intentFunction.installPointIntent(
1262 main,
1263 name="VLAN2",
1264 senders=senders,
1265 recipients=recipients,
1266 setVlan=200)
1267
1268 if installResult:
1269 testResult = main.intentFunction.testPointIntent(
1270 main,
1271 intentId=installResult,
1272 name="VLAN2",
1273 senders=senders,
1274 recipients=recipients,
1275 sw1="s5",
1276 sw2="s2",
1277 expectedLink=18)
1278
1279 utilities.assert_equals( expect=main.TRUE,
1280 actual=testResult,
1281 onpass=main.assertReturnString,
1282 onfail=main.assertReturnString )
1283
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001284 main.step( "1HOP: Add point intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -07001285 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001286 senders = [
1287 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1288 ]
1289 recipients = [
1290 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1291 ]
Jeremy42df2e72016-02-23 16:37:46 -08001292 testResult = main.FALSE
1293 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001294 installResult = main.intentFunction.installPointIntent(
1295 main,
1296 name="1HOP IPV4",
1297 senders=senders,
1298 recipients=recipients,
1299 ethType="IPV4" )
1300
1301 if installResult:
1302 testResult = main.intentFunction.testPointIntent(
1303 main,
1304 intentId=installResult,
1305 name="1HOP IPV4",
1306 senders=senders,
1307 recipients=recipients,
1308 sw1="s5",
1309 sw2="s2",
1310 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001311 else:
1312 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001313
1314 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001315 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001316 onpass=main.assertReturnString,
1317 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001318
kelvin-onlab016dce22015-08-10 09:54:11 -07001319 main.intentFunction.report( main )
1320
kelvin-onlabb769f562015-07-15 17:05:10 -07001321 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001322 """
1323 Add single point to multi point intents
1324 - Get device ids
1325 - Add single point to multi point intents
1326 - Check intents
1327 - Verify flows
1328 - Ping hosts
1329 - Reroute
1330 - Link down
1331 - Verify flows
1332 - Check topology
1333 - Ping hosts
1334 - Link up
1335 - Verify flows
1336 - Check topology
1337 - Ping hosts
1338 - Remove intents
1339 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001340 if main.initialized == main.FALSE:
1341 main.log.error( "Test components did not start correctly, skipping further tests" )
1342 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001343 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001344 try:
1345 assert main.CLIs
1346 except AssertionError:
1347 main.log.error( "There is no main.CLIs, skipping test cases" )
1348 main.initialized = main.FALSE
1349 main.skipCase()
1350 try:
1351 assert main.Mininet1
1352 except AssertionError:
1353 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1354 main.initialized = main.FALSE
1355 main.skipCase()
1356 try:
1357 assert main.numSwitch
1358 except AssertionError:
1359 main.log.error( "Place the total number of switch topology in \
1360 main.numSwitch" )
1361 main.initialized = main.FALSE
1362 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001363
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001364 main.testName = "Single to Multi Point Intents"
1365 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001366 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001367 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001368 " multi point intents using " +\
1369 str( main.numCtrls ) + " node(s) cluster;\n" +\
1370 "Different type of hosts will be tested in " +\
1371 "each step such as IPV4, Dual stack, VLAN etc" +\
1372 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001373 " OVS running in Mininet and compile intents" +\
1374 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001375
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001376 main.step( "NOOPTION: Install and test single point to multi point intents" )
1377 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
1378 senders = [
1379 { "name":"h8", "device":"of:0000000000000005/8" }
1380 ]
1381 recipients = [
1382 { "name":"h16", "device":"of:0000000000000006/8" },
1383 { "name":"h24", "device":"of:0000000000000007/8" }
1384 ]
1385 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1386 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1387 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001388 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001389 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001390 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001391 name="NOOPTION",
1392 senders=senders,
1393 recipients=recipients,
1394 sw1="s5",
1395 sw2="s2")
1396
1397 if installResult:
1398 testResult = main.intentFunction.testPointIntent(
1399 main,
1400 intentId=installResult,
1401 name="NOOPTION",
1402 senders=senders,
1403 recipients=recipients,
1404 badSenders=badSenders,
1405 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001406 sw1="s5",
1407 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001408 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001409 else:
1410 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001411
1412 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001413 actual=testResult,
1414 onpass=main.assertReturnString,
1415 onfail=main.assertReturnString )
1416
1417 main.step( "IPV4: Install and test single point to multi point intents" )
1418 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses\n"
1419 senders = [
1420 { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" }
1421 ]
1422 recipients = [
1423 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1424 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1425 ]
1426 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1427 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1428 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001429 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001430 installResult = main.intentFunction.installSingleToMultiIntent(
1431 main,
1432 name="IPV4",
1433 senders=senders,
1434 recipients=recipients,
1435 ethType="IPV4",
1436 sw1="s5",
1437 sw2="s2")
1438
1439 if installResult:
1440 testResult = main.intentFunction.testPointIntent(
1441 main,
1442 intentId=installResult,
1443 name="IPV4",
1444 senders=senders,
1445 recipients=recipients,
1446 badSenders=badSenders,
1447 badRecipients=badRecipients,
1448 sw1="s5",
1449 sw2="s2",
1450 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001451 else:
1452 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001453
1454 utilities.assert_equals( expect=main.TRUE,
1455 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001456 onpass=main.assertReturnString,
1457 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001458
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001459 main.step( "IPV4_2: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001460 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 -08001461 senders = [
1462 { "name":"h8", "device":"of:0000000000000005/8" }
1463 ]
1464 recipients = [
1465 { "name":"h16", "device":"of:0000000000000006/8" },
1466 { "name":"h24", "device":"of:0000000000000007/8" }
1467 ]
1468 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1469 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1470 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001471 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001472 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001473 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001474 name="IPV4_2",
1475 senders=senders,
1476 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001477 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001478 sw1="s5",
1479 sw2="s2")
1480
1481 if installResult:
1482 testResult = main.intentFunction.testPointIntent(
1483 main,
1484 intentId=installResult,
1485 name="IPV4_2",
1486 senders=senders,
1487 recipients=recipients,
1488 badSenders=badSenders,
1489 badRecipients=badRecipients,
1490 sw1="s5",
1491 sw2="s2",
1492 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001493 else:
1494 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001495
1496 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001497 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001498 onpass=main.assertReturnString,
1499 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001500
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001501 main.step( "VLAN: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001502 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 -08001503 senders = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001504 { "name":"h4", "device":"of:0000000000000005/4", "mac":"00:00:00:00:00:04", "vlan":"100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001505 ]
1506 recipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001507 { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C", "vlan":"100" },
1508 { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14", "vlan":"100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001509 ]
1510 badSenders=[ { "name":"h13" } ] # Senders that are not in the intent
1511 badRecipients=[ { "name":"h21" } ] # Recipients that are not in the intent
1512 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001513 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001514 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001515 main,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001516 name="VLAN`",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001517 senders=senders,
1518 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001519 sw1="s5",
1520 sw2="s2")
1521
1522 if installResult:
1523 testResult = main.intentFunction.testPointIntent(
1524 main,
1525 intentId=installResult,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001526 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001527 senders=senders,
1528 recipients=recipients,
1529 badSenders=badSenders,
1530 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001531 sw1="s5",
1532 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001533 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001534 else:
1535 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001536
1537 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001538 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001539 onpass=main.assertReturnString,
1540 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001541
Jeremy Songsterff553672016-05-12 17:06:23 -07001542 main.step( "VLAN: Add single point to multi point intents" )
1543 main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n"
1544 senders = [
1545 { "name":"h5", "vlan":"200" }
1546 ]
1547 recipients = [
1548 { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C", "vlan":"100" },
1549 { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14", "vlan":"100" }
1550 ]
1551 badSenders=[ { "name":"h13" } ] # Senders that are not in the intent
1552 badRecipients=[ { "name":"h21" } ] # Recipients that are not in the intent
1553 testResult = main.FALSE
1554 installResult = main.FALSE
1555 installResult = main.intentFunction.installSingleToMultiIntent(
1556 main,
1557 name="VLAN2",
1558 senders=senders,
1559 recipients=recipients,
1560 sw1="s5",
1561 sw2="s2",
1562 setVlan=100)
1563
1564 if installResult:
1565 testResult = main.intentFunction.testPointIntent(
1566 main,
1567 intentId=installResult,
1568 name="VLAN2",
1569 senders=senders,
1570 recipients=recipients,
1571 badSenders=badSenders,
1572 badRecipients=badRecipients,
1573 sw1="s5",
1574 sw2="s2",
1575 expectedLink=18)
1576 else:
1577 main.CLIs[ 0 ].removeAllIntents( purge=True )
1578
1579 utilities.assert_equals( expect=main.TRUE,
1580 actual=testResult,
1581 onpass=main.assertReturnString,
1582 onfail=main.assertReturnString )
1583
kelvin-onlab016dce22015-08-10 09:54:11 -07001584 main.intentFunction.report( main )
1585
kelvin-onlabb769f562015-07-15 17:05:10 -07001586 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001587 """
1588 Add multi point to single point intents
1589 - Get device ids
1590 - Add multi point to single point intents
1591 - Check intents
1592 - Verify flows
1593 - Ping hosts
1594 - Reroute
1595 - Link down
1596 - Verify flows
1597 - Check topology
1598 - Ping hosts
1599 - Link up
1600 - Verify flows
1601 - Check topology
1602 - Ping hosts
1603 - Remove intents
1604 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001605 if main.initialized == main.FALSE:
1606 main.log.error( "Test components did not start correctly, skipping further tests" )
1607 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001608 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001609 try:
1610 assert main.CLIs
1611 except AssertionError:
1612 main.log.error( "There is no main.CLIs, skipping test cases" )
1613 main.initialized = main.FALSE
1614 main.skipCase()
1615 try:
1616 assert main.Mininet1
1617 except AssertionError:
1618 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1619 main.initialized = main.FALSE
1620 main.skipCase()
1621 try:
1622 assert main.numSwitch
1623 except AssertionError:
1624 main.log.error( "Place the total number of switch topology in \
1625 main.numSwitch" )
1626 main.initialized = main.FALSE
1627 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001628
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001629 main.testName = "Multi To Single Point Intents"
1630 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001631 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001632 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001633 " multi point intents using " +\
1634 str( main.numCtrls ) + " node(s) cluster;\n" +\
1635 "Different type of hosts will be tested in " +\
1636 "each step such as IPV4, Dual stack, VLAN etc" +\
1637 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001638 " OVS running in Mininet and compile intents" +\
1639 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001640
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001641 main.step( "NOOPTION: Add multi point to single point intents" )
1642 main.assertReturnString = "Assertion results for NOOPTION multi to single point intent\n"
1643 senders = [
1644 { "name":"h16", "device":"of:0000000000000006/8" },
1645 { "name":"h24", "device":"of:0000000000000007/8" }
1646 ]
1647 recipients = [
1648 { "name":"h8", "device":"of:0000000000000005/8" }
1649 ]
1650 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1651 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1652 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001653 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001654 installResult = main.intentFunction.installMultiToSingleIntent(
1655 main,
1656 name="NOOPTION",
1657 senders=senders,
1658 recipients=recipients,
1659 sw1="s5",
Jeremye0cb5eb2016-01-27 17:39:09 -08001660 sw2="s2" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001661
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001662 if installResult:
1663 testResult = main.intentFunction.testPointIntent(
1664 main,
1665 intentId=installResult,
1666 name="NOOPTION",
1667 senders=senders,
1668 recipients=recipients,
1669 badSenders=badSenders,
1670 badRecipients=badRecipients,
1671 sw1="s5",
1672 sw2="s2",
Jeremye0cb5eb2016-01-27 17:39:09 -08001673 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001674 else:
1675 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001676
1677 utilities.assert_equals( expect=main.TRUE,
1678 actual=testResult,
1679 onpass=main.assertReturnString,
1680 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001681
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001682 main.step( "IPV4: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001683 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 -08001684 senders = [
1685 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1686 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1687 ]
1688 recipients = [
1689 { "name":"h8", "device":"of:0000000000000005/8", "mac":"00:00:00:00:00:08" }
1690 ]
1691 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1692 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1693 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001694 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001695 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001696 main,
1697 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001698 senders=senders,
1699 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001700 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001701 sw1="s5",
1702 sw2="s2")
1703
1704 if installResult:
1705 testResult = main.intentFunction.testPointIntent(
1706 main,
1707 intentId=installResult,
1708 name="IPV4",
1709 senders=senders,
1710 recipients=recipients,
1711 badSenders=badSenders,
1712 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001713 sw1="s5",
1714 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001715 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001716 else:
1717 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001718
1719 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001720 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001721 onpass=main.assertReturnString,
1722 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001723
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001724 main.step( "IPV4_2: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001725 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 -08001726 senders = [
1727 { "name":"h16", "device":"of:0000000000000006/8" },
1728 { "name":"h24", "device":"of:0000000000000007/8" }
1729 ]
1730 recipients = [
1731 { "name":"h8", "device":"of:0000000000000005/8" }
1732 ]
1733 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1734 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1735 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001736 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001737 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001738 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001739 name="IPV4_2",
1740 senders=senders,
1741 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001742 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001743 sw1="s5",
1744 sw2="s2")
1745
1746 if installResult:
1747 testResult = main.intentFunction.testPointIntent(
1748 main,
1749 intentId=installResult,
1750 name="IPV4_2",
1751 senders=senders,
1752 recipients=recipients,
1753 badSenders=badSenders,
1754 badRecipients=badRecipients,
1755 sw1="s5",
1756 sw2="s2",
1757 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001758 else:
1759 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001760
1761 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001762 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001763 onpass=main.assertReturnString,
1764 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001765
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001766 main.step( "VLAN: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001767 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 -08001768 senders = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001769 { "name":"h13", "device":"of:0000000000000006/5", "vlan":"200" },
1770 { "name":"h21", "device":"of:0000000000000007/5", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001771 ]
1772 recipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001773 { "name":"h5", "device":"of:0000000000000005/5", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001774 ]
1775 badSenders=[ { "name":"h12" } ] # Senders that are not in the intent
1776 badRecipients=[ { "name":"h20" } ] # Recipients that are not in the intent
1777 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001778 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001779 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001780 main,
1781 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001782 senders=senders,
1783 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001784 sw1="s5",
1785 sw2="s2")
1786
1787 if installResult:
1788 testResult = main.intentFunction.testPointIntent(
1789 main,
1790 intentId=installResult,
1791 name="VLAN",
1792 senders=senders,
1793 recipients=recipients,
1794 badSenders=badSenders,
1795 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001796 sw1="s5",
1797 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001798 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001799 else:
1800 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001801
1802 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001803 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001804 onpass=main.assertReturnString,
1805 onfail=main.assertReturnString )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001806
Jeremy Songsterff553672016-05-12 17:06:23 -07001807 # Right now this fails because of this bug: https://jira.onosproject.org/browse/ONOS-4383
1808 main.step( "VLAN: Add multi point to single point intents" )
1809 main.assertReturnString = "Assertion results for multi to single point intent with VLAN ID treatment\n"
1810 senders = [
1811 { "name":"h13", "device":"of:0000000000000006/5", "vlan":"200" },
1812 { "name":"h21", "device":"of:0000000000000007/5", "vlan":"200" }
1813 ]
1814 recipients = [
1815 { "name":"h4", "vlan":"100" }
1816 ]
1817 badSenders=[ { "name":"h12" } ] # Senders that are not in the intent
1818 badRecipients=[ { "name":"h20" } ] # Recipients that are not in the intent
1819 testResult = main.FALSE
1820 installResult = main.FALSE
1821 installResult = main.intentFunction.installMultiToSingleIntent(
1822 main,
1823 name="VLAN2",
1824 senders=senders,
1825 recipients=recipients,
1826 sw1="s5",
1827 sw2="s2",
1828 setVlan=100)
1829
1830 if installResult:
1831 testResult = main.intentFunction.testPointIntent(
1832 main,
1833 intentId=installResult,
1834 name="VLAN2",
1835 senders=senders,
1836 recipients=recipients,
1837 badSenders=badSenders,
1838 badRecipients=badRecipients,
1839 sw1="s5",
1840 sw2="s2",
1841 expectedLink=18)
1842 else:
1843 main.CLIs[ 0 ].removeAllIntents( purge=True )
1844
1845 utilities.assert_equals( expect=main.TRUE,
1846 actual=testResult,
1847 onpass=main.assertReturnString,
1848 onfail=main.assertReturnString )
1849
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001850 main.intentFunction.report( main )
1851
acsmars1ff5e052015-07-23 11:27:48 -07001852 def CASE5000( self, main ):
1853 """
acsmars5d8cc862015-09-25 09:44:50 -07001854 Tests Host Mobility
1855 Modifies the topology location of h1
acsmars1ff5e052015-07-23 11:27:48 -07001856 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001857 if main.initialized == main.FALSE:
1858 main.log.error( "Test components did not start correctly, skipping further tests" )
1859 main.skipCase()
acsmars1ff5e052015-07-23 11:27:48 -07001860 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001861 try:
1862 assert main.CLIs
1863 except AssertionError:
1864 main.log.error( "There is no main.CLIs, skipping test cases" )
1865 main.initialized = main.FALSE
1866 main.skipCase()
1867 try:
1868 assert main.Mininet1
1869 except AssertionError:
1870 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1871 main.initialized = main.FALSE
1872 main.skipCase()
1873 try:
1874 assert main.numSwitch
1875 except AssertionError:
1876 main.log.error( "Place the total number of switch topology in \
1877 main.numSwitch" )
1878 main.initialized = main.FALSE
1879 main.skipCase()
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001880 main.case( "Test host mobility with host intents " )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001881 main.step( "Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07001882 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1883
Jeremy2f190ca2016-01-29 15:23:57 -08001884 main.log.info( "Moving h1 from s5 to s6")
acsmars1ff5e052015-07-23 11:27:48 -07001885 main.Mininet1.moveHost( "h1","s5","s6" )
1886
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001887 # Send discovery ping from moved host
1888 # Moving the host brings down the default interfaces and creates a new one.
1889 # Scapy is restarted on this host to detect the new interface
1890 main.h1.stopScapy()
1891 main.h1.startScapy()
1892
1893 # Discover new host location in ONOS and populate host data.
1894 # Host 1 IP and MAC should be unchanged
1895 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
1896 main.intentFunction.populateHostData( main )
1897
acsmars1ff5e052015-07-23 11:27:48 -07001898 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1899
1900 utilities.assert_equals( expect="of:0000000000000006",
1901 actual=h1PostMove,
1902 onpass="Mobility: Successfully moved h1 to s6",
acsmars5d8cc862015-09-25 09:44:50 -07001903 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001904 " to single point intents" +
1905 " with IPV4 type and MAC addresses" +
1906 " in the same VLAN" )
1907
1908 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001909 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001910 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
1911 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
Jeremy42df2e72016-02-23 16:37:46 -08001912 testResult = main.FALSE
1913 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001914 installResult = main.intentFunction.installHostIntent( main,
1915 name='IPV4 Mobility IPV4',
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001916 onosNode='0',
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001917 host1=host1,
Jeremye0cb5eb2016-01-27 17:39:09 -08001918 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -08001919 if installResult:
1920 testResult = main.intentFunction.testHostIntent( main,
1921 name='Host Mobility IPV4',
1922 intentId = installResult,
1923 onosNode='0',
1924 host1=host1,
1925 host2=host2,
1926 sw1="s6",
1927 sw2="s2",
1928 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001929 else:
1930 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001931
1932 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001933 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001934 onpass=main.assertReturnString,
1935 onfail=main.assertReturnString )
kelvin-onlab016dce22015-08-10 09:54:11 -07001936
1937 main.intentFunction.report( main )
Jeremye0cb5eb2016-01-27 17:39:09 -08001938
1939 def CASE6000( self, main ):
1940 """
1941 Tests Multi to Single Point Intent and Single to Multi Point Intent End Point Failure
1942 """
Jeremy Songster9385d412016-06-02 17:57:36 -07001943 # At some later point discussion on this behavior in MPSP and SPMP intents
1944 # will be reoppened and this test case may need to be updated to reflect
1945 # the outcomes of that discussion
Jeremyd9e4eb12016-04-13 12:09:06 -07001946 if main.initialized == main.FALSE:
1947 main.log.error( "Test components did not start correctly, skipping further tests" )
1948 main.skipCase()
Jeremye0cb5eb2016-01-27 17:39:09 -08001949 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001950 try:
1951 assert main.CLIs
1952 except AssertionError:
1953 main.log.error( "There is no main.CLIs, skipping test cases" )
1954 main.initialized = main.FALSE
1955 main.skipCase()
1956 try:
1957 assert main.Mininet1
1958 except AssertionError:
1959 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1960 main.initialized = main.FALSE
1961 main.skipCase()
1962 try:
1963 assert main.numSwitch
1964 except AssertionError:
1965 main.log.error( "Place the total number of switch topology in \
1966 main.numSwitch" )
1967 main.initialized = main.FALSE
1968 main.skipCase()
Jeremye0cb5eb2016-01-27 17:39:09 -08001969 main.case( "Test Multi to Single End Point Failure" )
Jeremy Songster9385d412016-06-02 17:57:36 -07001970 main.step( "Installing Multi to Single Point intents with no options set" )
1971 main.assertReturnString = "Assertion results for IPV4 multi to single " +\
1972 "point intent end point failure with no options set\n"
Jeremye0cb5eb2016-01-27 17:39:09 -08001973 senders = [
1974 { "name":"h16", "device":"of:0000000000000006/8" },
1975 { "name":"h24", "device":"of:0000000000000007/8" }
1976 ]
1977 recipients = [
1978 { "name":"h8", "device":"of:0000000000000005/8" }
1979 ]
1980 isolatedSenders = [
1981 { "name":"h24"}
1982 ]
1983 isolatedRecipients = []
1984 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001985 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08001986 installResult = main.intentFunction.installMultiToSingleIntent(
1987 main,
1988 name="NOOPTION",
1989 senders=senders,
1990 recipients=recipients,
1991 sw1="s5",
1992 sw2="s2" )
1993
1994 if installResult:
1995 testResult = main.intentFunction.testEndPointFail(
1996 main,
1997 intentId=installResult,
1998 name="NOOPTION",
1999 senders=senders,
2000 recipients=recipients,
2001 isolatedSenders=isolatedSenders,
2002 isolatedRecipients=isolatedRecipients,
2003 sw1="s6",
2004 sw2="s2",
2005 sw3="s4",
2006 sw4="s1",
2007 sw5="s3",
2008 expectedLink1=16,
2009 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002010 else:
2011 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002012
2013 utilities.assert_equals( expect=main.TRUE,
2014 actual=testResult,
2015 onpass=main.assertReturnString,
2016 onfail=main.assertReturnString )
2017
Jeremy Songster9385d412016-06-02 17:57:36 -07002018 main.step( "Installing Multi to Single Point intents with partial failure allowed" )
2019
2020 main.assertReturnString = "Assertion results for IPV4 multi to single " +\
2021 "with partial failures allowed\n"
2022 senders = [
2023 { "name":"h16", "device":"of:0000000000000006/8" },
2024 { "name":"h24", "device":"of:0000000000000007/8" }
2025 ]
2026 recipients = [
2027 { "name":"h8", "device":"of:0000000000000005/8" }
2028 ]
2029 isolatedSenders = [
2030 { "name":"h24"}
2031 ]
2032 isolatedRecipients = []
2033 testResult = main.FALSE
2034 installResult = main.FALSE
2035 installResult = main.intentFunction.installMultiToSingleIntent(
2036 main,
2037 name="NOOPTION",
2038 senders=senders,
2039 recipients=recipients,
2040 sw1="s5",
2041 sw2="s2",
2042 partial=True )
2043
2044 if installResult:
2045 testResult = main.intentFunction.testEndPointFail(
2046 main,
2047 intentId=installResult,
2048 name="NOOPTION",
2049 senders=senders,
2050 recipients=recipients,
2051 isolatedSenders=isolatedSenders,
2052 isolatedRecipients=isolatedRecipients,
2053 sw1="s6",
2054 sw2="s2",
2055 sw3="s4",
2056 sw4="s1",
2057 sw5="s3",
2058 expectedLink1=16,
2059 expectedLink2=14,
2060 partial=True )
2061 else:
2062 main.CLIs[ 0 ].removeAllIntents( purge=True )
2063
2064 utilities.assert_equals( expect=main.TRUE,
2065 actual=testResult,
2066 onpass=main.assertReturnString,
2067 onfail=main.assertReturnString )
2068
Jeremye0cb5eb2016-01-27 17:39:09 -08002069 main.step( "NOOPTION: Install and test single point to multi point intents" )
Jeremy Songster9385d412016-06-02 17:57:36 -07002070 main.assertReturnString = "Assertion results for IPV4 single to multi " +\
2071 "point intent with no options set\n"
Jeremye0cb5eb2016-01-27 17:39:09 -08002072 senders = [
2073 { "name":"h8", "device":"of:0000000000000005/8" }
2074 ]
2075 recipients = [
2076 { "name":"h16", "device":"of:0000000000000006/8" },
2077 { "name":"h24", "device":"of:0000000000000007/8" }
2078 ]
Jeremy Songster9385d412016-06-02 17:57:36 -07002079 isolatedSenders = []
2080 isolatedRecipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07002081 { "name":"h24"}
Jeremye0cb5eb2016-01-27 17:39:09 -08002082 ]
2083 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08002084 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08002085 installResult = main.intentFunction.installSingleToMultiIntent(
2086 main,
2087 name="NOOPTION",
2088 senders=senders,
2089 recipients=recipients,
2090 sw1="s5",
2091 sw2="s2")
2092
2093 if installResult:
2094 testResult = main.intentFunction.testEndPointFail(
2095 main,
2096 intentId=installResult,
2097 name="NOOPTION",
2098 senders=senders,
2099 recipients=recipients,
2100 isolatedSenders=isolatedSenders,
2101 isolatedRecipients=isolatedRecipients,
2102 sw1="s6",
2103 sw2="s2",
2104 sw3="s4",
2105 sw4="s1",
2106 sw5="s3",
2107 expectedLink1=16,
2108 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002109 else:
2110 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002111
2112 utilities.assert_equals( expect=main.TRUE,
2113 actual=testResult,
2114 onpass=main.assertReturnString,
2115 onfail=main.assertReturnString )
Jeremy Songster9385d412016-06-02 17:57:36 -07002116 # Right now this functionality doesn't work properly in SPMP intents
2117 main.step( "NOOPTION: Install and test single point to multi point " +\
2118 "intents with partial failures allowed" )
2119 main.assertReturnString = "Assertion results for IPV4 single to multi " +\
2120 "point intent with partial failures allowed\n"
2121 senders = [
2122 { "name":"h8", "device":"of:0000000000000005/8" }
2123 ]
2124 recipients = [
2125 { "name":"h16", "device":"of:0000000000000006/8" },
2126 { "name":"h24", "device":"of:0000000000000007/8" }
2127 ]
2128 isolatedSenders = []
2129 isolatedRecipients = [
2130 { "name":"h24"}
2131 ]
2132 testResult = main.FALSE
2133 installResult = main.FALSE
2134 installResult = main.intentFunction.installSingleToMultiIntent(
2135 main,
2136 name="NOOPTION",
2137 senders=senders,
2138 recipients=recipients,
2139 sw1="s5",
2140 sw2="s2",
2141 partial=True)
2142
2143 if installResult:
2144 testResult = main.intentFunction.testEndPointFail(
2145 main,
2146 intentId=installResult,
2147 name="NOOPTION",
2148 senders=senders,
2149 recipients=recipients,
2150 isolatedSenders=isolatedSenders,
2151 isolatedRecipients=isolatedRecipients,
2152 sw1="s6",
2153 sw2="s2",
2154 sw3="s4",
2155 sw4="s1",
2156 sw5="s3",
2157 expectedLink1=16,
2158 expectedLink2=14,
2159 partial=True )
2160 else:
2161 main.CLIs[ 0 ].removeAllIntents( purge=True )
2162
2163 utilities.assert_equals( expect=main.TRUE,
2164 actual=testResult,
2165 onpass=main.assertReturnString,
2166 onfail=main.assertReturnString )
Jeremye0cb5eb2016-01-27 17:39:09 -08002167
Jeremy2f190ca2016-01-29 15:23:57 -08002168 main.intentFunction.report( main )