blob: ba0f2a9ce12749e79ab1ffea5f09091ffedb50f4 [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 Songster17147f22016-05-31 18:30:52 -0700673 i = 0
674 for cli in main.CLIs:
675 main.node = cli
676 ip = main.ONOSip[ i ]
677 main.node.ip_address = ip
Jeremy Songster31aad312016-06-13 16:32:11 -0700678 scpResult = scpResult and main.ONOSbench.scp( main.node ,
679 "/opt/onos/log/karaf.log",
680 "/tmp/karaf.log",
681 direction="from" )
682 copyResult = copyResult and main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
683 copyFileName=( "karaf.log.node{0}.cycle{1}".format( str( i + 1 ), str( main.cycle ) ) ) )
684 if scpResult and copyResult:
685 stepResult = main.TRUE and stepResult
686 else:
687 stepResult = main.FALSE and stepResult
Jeremy Songster17147f22016-05-31 18:30:52 -0700688 i += 1
Jeremy Songster31aad312016-06-13 16:32:11 -0700689 utilities.assert_equals( expect=main.TRUE,
690 actual=stepResult,
691 onpass="Successfully copied remote ONOS logs",
692 onfail="Failed to copy remote ONOS logs" )
Jeremy Songster17147f22016-05-31 18:30:52 -0700693
kelvin-onlabb769f562015-07-15 17:05:10 -0700694 def CASE1000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700695 """
696 Add host intents between 2 host:
697 - Discover hosts
698 - Add host intents
699 - Check intents
700 - Verify flows
701 - Ping hosts
702 - Reroute
703 - Link down
704 - Verify flows
705 - Check topology
706 - Ping hosts
707 - Link up
708 - Verify flows
709 - Check topology
710 - Ping hosts
711 - Remove intents
712 """
713 import time
714 import json
715 import re
Jeremyd9e4eb12016-04-13 12:09:06 -0700716 if main.initialized == main.FALSE:
717 main.log.error( "Test components did not start correctly, skipping further tests" )
718 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700719 # Assert variables - These variable's name|format must be followed
720 # if you want to use the wrapper function
721 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -0700722 try:
723 assert main.CLIs
724 except AssertionError:
725 main.log.error( "There is no main.CLIs, skipping test cases" )
726 main.initialized = main.FALSE
727 main.skipCase()
728 try:
729 assert main.Mininet1
730 except AssertionError:
731 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
732 main.initialized = main.FALSE
733 main.skipCase()
734 try:
735 assert main.numSwitch
736 except AssertionError:
737 main.log.error( "Place the total number of switch topology in \
738 main.numSwitch" )
739 main.initialized = main.FALSE
740 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700741
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800742 # Save leader candidates
acsmarse6b410f2015-07-17 14:39:34 -0700743 intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
744
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700745 main.testName = "Host Intents"
746 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -0700747 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -0700748 main.caseExplanation = "This test case tests Host intents using " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700749 str( main.numCtrls ) + " node(s) cluster;\n" +\
750 "Different type of hosts will be tested in " +\
751 "each step such as IPV4, Dual stack, VLAN " +\
Jeremyeb51cb12016-03-28 17:53:35 -0700752 "etc;\nThe test will use OF " + main.OFProtocol +\
753 " OVS running in Mininet and compile intents" +\
Jeremy6e9748f2016-03-25 15:03:39 -0700754 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700755
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700756 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700757 main.assertReturnString = "Assertion Result for IPV4 host intent with mac addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800758 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
759 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
760 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800761 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800762 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700763 name='IPV4',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800764 onosNode='0',
765 host1=host1,
766 host2=host2)
767 if installResult:
768 testResult = main.intentFunction.testHostIntent( main,
769 name='IPV4',
770 intentId = installResult,
771 onosNode='0',
772 host1=host1,
773 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700774 sw1='s5',
775 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800776 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800777 else:
778 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800779
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700780 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800781 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700782 onpass=main.assertReturnString,
783 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700784
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700785 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700786 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800787 host1 = { "name":"h3","id":"00:00:00:00:00:03/-1" }
788 host2 = { "name":"h11","id":"00:00:00:00:00:0B/-1 "}
789 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800790 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800791 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700792 name='DUALSTACK',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800793 onosNode='0',
794 host1=host1,
795 host2=host2)
796
797 if installResult:
798 testResult = main.intentFunction.testHostIntent( main,
799 name='DUALSTACK',
800 intentId = installResult,
801 onosNode='0',
802 host1=host1,
803 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700804 sw1='s5',
805 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800806 expectedLink = 18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700807
808 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800809 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700810 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800811 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700812
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700813 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700814 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800815 host1 = { "name":"h1" }
816 host2 = { "name":"h11" }
817 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800818 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800819 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700820 name='DUALSTACK2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800821 onosNode='0',
822 host1=host1,
823 host2=host2)
824
825 if installResult:
826 testResult = main.intentFunction.testHostIntent( main,
827 name='DUALSTACK2',
828 intentId = installResult,
829 onosNode='0',
830 host1=host1,
831 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700832 sw1='s5',
833 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800834 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800835 else:
836 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700837
838 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800839 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700840 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800841 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700842
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700843 main.step( "1HOP: Add host intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -0700844 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800845 host1 = { "name":"h1" }
846 host2 = { "name":"h3" }
847 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800848 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800849 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700850 name='1HOP',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800851 onosNode='0',
852 host1=host1,
853 host2=host2)
854
855 if installResult:
856 testResult = main.intentFunction.testHostIntent( main,
857 name='1HOP',
858 intentId = installResult,
859 onosNode='0',
860 host1=host1,
861 host2=host2,
862 sw1='s5',
863 sw2='s2',
864 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800865 else:
866 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700867
868 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800869 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700870 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800871 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700872
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700873 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
acsmars5d8cc862015-09-25 09:44:50 -0700874 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jeremy Songster832f9e92016-05-05 14:30:49 -0700875 host1 = { "name":"h4","id":"00:00:00:00:00:04/100", "vlan":"100" }
876 host2 = { "name":"h12","id":"00:00:00:00:00:0C/100", "vlan":"100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800877 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800878 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800879 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700880 name='VLAN1',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800881 onosNode='0',
882 host1=host1,
883 host2=host2)
884
885 if installResult:
886 testResult = main.intentFunction.testHostIntent( main,
887 name='VLAN1',
888 intentId = installResult,
889 onosNode='0',
890 host1=host1,
891 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700892 sw1='s5',
893 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800894 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800895 else:
896 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700897
898 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800899 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700900 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800901 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700902
Jeremy Songsterff553672016-05-12 17:06:23 -0700903 main.step( "VLAN2: Add vlan host intents between h4 and h13" )
904 main.assertReturnString = "Assertion Result vlan IPV4\n"
905 host1 = { "name":"h5", "vlan":"200" }
906 host2 = { "name":"h12", "vlan":"100" }
907 testResult = main.FALSE
908 installResult = main.FALSE
909 installResult = main.intentFunction.installHostIntent( main,
910 name='VLAN2',
911 onosNode='0',
912 host1=host1,
913 host2=host2)
914
915 if installResult:
916 testResult = main.intentFunction.testHostIntent( main,
917 name='VLAN2',
918 intentId = installResult,
919 onosNode='0',
920 host1=host1,
921 host2=host2,
922 sw1='s5',
923 sw2='s2',
924 expectedLink = 18)
925 else:
926 main.CLIs[ 0 ].removeAllIntents( purge=True )
927
928 utilities.assert_equals( expect=main.TRUE,
929 actual=testResult,
930 onpass=main.assertReturnString,
931 onfail=main.assertReturnString)
932
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800933 main.step( "Confirm that ONOS leadership is unchanged")
acsmarse6b410f2015-07-17 14:39:34 -0700934 intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
935 main.intentFunction.checkLeaderChange( intentLeadersOld,
936 intentLeadersNew )
937
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800938 utilities.assert_equals( expect=main.TRUE,
939 actual=testResult,
940 onpass="ONOS Leaders Unchanged",
941 onfail="ONOS Leader Mismatch")
942
kelvin-onlab016dce22015-08-10 09:54:11 -0700943 main.intentFunction.report( main )
944
kelvin-onlabb769f562015-07-15 17:05:10 -0700945 def CASE2000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700946 """
947 Add point intents between 2 hosts:
948 - Get device ids | ports
949 - Add point intents
950 - Check intents
951 - Verify flows
952 - Ping hosts
953 - Reroute
954 - Link down
955 - Verify flows
956 - Check topology
957 - Ping hosts
958 - Link up
959 - Verify flows
960 - Check topology
961 - Ping hosts
962 - Remove intents
963 """
964 import time
965 import json
966 import re
Jeremyd9e4eb12016-04-13 12:09:06 -0700967 if main.initialized == main.FALSE:
968 main.log.error( "Test components did not start correctly, skipping further tests" )
969 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700970 # Assert variables - These variable's name|format must be followed
971 # if you want to use the wrapper function
972 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -0700973 try:
974 assert main.CLIs
975 except AssertionError:
976 main.log.error( "There is no main.CLIs, skipping test cases" )
977 main.initialized = main.FALSE
978 main.skipCase()
979 try:
980 assert main.Mininet1
981 except AssertionError:
982 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
983 main.initialized = main.FALSE
984 main.skipCase()
985 try:
986 assert main.numSwitch
987 except AssertionError:
988 main.log.error( "Place the total number of switch topology in \
989 main.numSwitch" )
990 main.initialized = main.FALSE
991 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700992
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700993 main.testName = "Point Intents"
994 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -0700995 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -0700996 main.caseExplanation = "This test case will test point to point" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700997 " intents using " + str( main.numCtrls ) +\
998 " node(s) cluster;\n" +\
999 "Different type of hosts will be tested in " +\
1000 "each step such as IPV4, Dual stack, VLAN etc" +\
1001 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001002 " OVS running in Mininet and compile intents" +\
1003 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001004
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001005 # No option point intents
1006 main.step( "NOOPTION: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001007 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001008 senders = [
1009 { "name":"h1","device":"of:0000000000000005/1" }
1010 ]
1011 recipients = [
1012 { "name":"h9","device":"of:0000000000000006/1" }
1013 ]
Jeremy42df2e72016-02-23 16:37:46 -08001014 testResult = main.FALSE
1015 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001016 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001017 main,
1018 name="NOOPTION",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001019 senders=senders,
1020 recipients=recipients )
1021
1022 if installResult:
1023 testResult = main.intentFunction.testPointIntent(
1024 main,
1025 intentId=installResult,
1026 name="NOOPTION",
1027 senders=senders,
1028 recipients=recipients,
1029 sw1="s5",
1030 sw2="s2",
1031 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001032 else:
1033 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001034
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001035 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001036 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001037 onpass=main.assertReturnString,
1038 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001039
1040 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -07001041 main.step( "IPV4: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001042 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001043 senders = [
1044 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1045 ]
1046 recipients = [
1047 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09" }
1048 ]
Jeremy42df2e72016-02-23 16:37:46 -08001049 testResult = main.FALSE
1050 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001051 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001052 main,
1053 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001054 senders=senders,
1055 recipients=recipients,
1056 ethType="IPV4" )
1057
1058 if installResult:
1059 testResult = main.intentFunction.testPointIntent(
1060 main,
1061 intentId=installResult,
1062 name="IPV4",
1063 senders=senders,
1064 recipients=recipients,
1065 sw1="s5",
1066 sw2="s2",
1067 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001068 else:
1069 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001070
1071 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001072 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001073 onpass=main.assertReturnString,
1074 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001075 main.step( "IPV4_2: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001076 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001077 senders = [
1078 { "name":"h1","device":"of:0000000000000005/1" }
1079 ]
1080 recipients = [
1081 { "name":"h9","device":"of:0000000000000006/1" }
1082 ]
Jeremy42df2e72016-02-23 16:37:46 -08001083 testResult = main.FALSE
1084 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001085 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001086 main,
1087 name="IPV4_2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001088 senders=senders,
1089 recipients=recipients,
1090 ethType="IPV4" )
1091
1092 if installResult:
1093 testResult = main.intentFunction.testPointIntent(
1094 main,
1095 intentId=installResult,
1096 name="IPV4_2",
1097 senders=senders,
1098 recipients=recipients,
1099 sw1="s5",
1100 sw2="s2",
1101 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001102 else:
1103 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001104
1105 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001106 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001107 onpass=main.assertReturnString,
1108 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001109
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001110 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001111 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001112 senders = [
1113 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01",
Jeremy6f000c62016-02-25 17:02:28 -08001114 "ip":( main.h1.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001115 ]
1116 recipients = [
1117 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09",
Jeremy6f000c62016-02-25 17:02:28 -08001118 "ip":( main.h9.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001119 ]
Jeremy6f000c62016-02-25 17:02:28 -08001120 ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ]
kelvin-onlab79ce0492015-07-27 16:14:39 -07001121 # Uneccessary, not including this in the selectors
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001122 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
1123 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
Jeremy42df2e72016-02-23 16:37:46 -08001124 testResult = main.FALSE
1125 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001126 installResult = main.intentFunction.installPointIntent(
1127 main,
1128 name="SDNIP-ICMP",
1129 senders=senders,
1130 recipients=recipients,
1131 ethType="IPV4",
1132 ipProto=ipProto,
1133 tcpSrc=tcpSrc,
1134 tcpDst=tcpDst )
1135
1136 if installResult:
1137 testResult = main.intentFunction.testPointIntent(
1138 main,
1139 intentId=installResult,
1140 name="SDNIP_ICMP",
1141 senders=senders,
1142 recipients=recipients,
1143 sw1="s5",
1144 sw2="s2",
Jeremy Songstere405d3d2016-05-17 11:18:57 -07001145 expectedLink=18,
1146 useTCP=True)
Jeremy42df2e72016-02-23 16:37:46 -08001147 else:
1148 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabb769f562015-07-15 17:05:10 -07001149
1150 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001151 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001152 onpass=main.assertReturnString,
1153 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001154
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001155 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001156 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
kelvin-onlabb769f562015-07-15 17:05:10 -07001157 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
1158 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab58dc39e2015-08-06 08:11:09 -07001159 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
1160 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlabb769f562015-07-15 17:05:10 -07001161 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
1162 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
1163 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
1164
kelvin-onlab58dc39e2015-08-06 08:11:09 -07001165 stepResult = main.intentFunction.pointIntentTcp(
kelvin-onlabb769f562015-07-15 17:05:10 -07001166 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001167 name="SDNIP-TCP",
kelvin-onlabb769f562015-07-15 17:05:10 -07001168 host1="h1",
1169 host2="h9",
1170 deviceId1="of:0000000000000005/1",
1171 deviceId2="of:0000000000000006/1",
1172 mac1=mac1,
1173 mac2=mac2,
1174 ethType="IPV4",
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001175 ipProto=ipProto,
1176 ip1=ip1,
1177 ip2=ip2,
1178 tcp1=tcp1,
1179 tcp2=tcp2 )
kelvin-onlabb769f562015-07-15 17:05:10 -07001180
1181 utilities.assert_equals( expect=main.TRUE,
Jeremy6f000c62016-02-25 17:02:28 -08001182 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -07001183 onpass=main.assertReturnString,
1184 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001185
acsmars5d8cc862015-09-25 09:44:50 -07001186 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
1187 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001188 senders = [
1189 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1190 ]
1191 recipients = [
1192 { "name":"h11","device":"of:0000000000000006/3","mac":"00:00:00:00:00:0B" }
1193 ]
Jeremy42df2e72016-02-23 16:37:46 -08001194 testResult = main.FALSE
1195 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001196 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001197 main,
1198 name="DUALSTACK1",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001199 senders=senders,
1200 recipients=recipients,
1201 ethType="IPV4" )
1202
1203 if installResult:
1204 testResult = main.intentFunction.testPointIntent(
1205 main,
1206 intentId=installResult,
1207 name="DUALSTACK1",
1208 senders=senders,
1209 recipients=recipients,
1210 sw1="s5",
1211 sw2="s2",
1212 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001213 else:
1214 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001215
1216 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001217 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001218 onpass=main.assertReturnString,
1219 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001220
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001221 main.step( "VLAN: Add point intents between h5 and h21" )
acsmars5d8cc862015-09-25 09:44:50 -07001222 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001223 senders = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001224 { "name":"h5","device":"of:0000000000000005/5","mac":"00:00:00:00:00:05", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001225 ]
1226 recipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001227 { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001228 ]
Jeremy42df2e72016-02-23 16:37:46 -08001229 testResult = main.FALSE
1230 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001231 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001232 main,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001233 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001234 senders=senders,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001235 recipients=recipients)
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001236
1237 if installResult:
1238 testResult = main.intentFunction.testPointIntent(
1239 main,
1240 intentId=installResult,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001241 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001242 senders=senders,
1243 recipients=recipients,
1244 sw1="s5",
1245 sw2="s2",
1246 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001247
1248 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001249 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001250 onpass=main.assertReturnString,
1251 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001252
Jeremy Songsterff553672016-05-12 17:06:23 -07001253 main.step( "VLAN: Add point intents between h5 and h21" )
1254 main.assertReturnString = "Assertion Result for VLAN IPV4 point intents with VLAN treatment\n"
1255 senders = [
1256 { "name":"h4", "vlan":"100" }
1257 ]
1258 recipients = [
1259 { "name":"h21", "vlan":"200" }
1260 ]
1261 testResult = main.FALSE
1262 installResult = main.FALSE
1263 installResult = main.intentFunction.installPointIntent(
1264 main,
1265 name="VLAN2",
1266 senders=senders,
1267 recipients=recipients,
1268 setVlan=200)
1269
1270 if installResult:
1271 testResult = main.intentFunction.testPointIntent(
1272 main,
1273 intentId=installResult,
1274 name="VLAN2",
1275 senders=senders,
1276 recipients=recipients,
1277 sw1="s5",
1278 sw2="s2",
1279 expectedLink=18)
1280
1281 utilities.assert_equals( expect=main.TRUE,
1282 actual=testResult,
1283 onpass=main.assertReturnString,
1284 onfail=main.assertReturnString )
1285
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001286 main.step( "1HOP: Add point intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -07001287 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001288 senders = [
1289 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1290 ]
1291 recipients = [
1292 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1293 ]
Jeremy42df2e72016-02-23 16:37:46 -08001294 testResult = main.FALSE
1295 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001296 installResult = main.intentFunction.installPointIntent(
1297 main,
1298 name="1HOP IPV4",
1299 senders=senders,
1300 recipients=recipients,
1301 ethType="IPV4" )
1302
1303 if installResult:
1304 testResult = main.intentFunction.testPointIntent(
1305 main,
1306 intentId=installResult,
1307 name="1HOP IPV4",
1308 senders=senders,
1309 recipients=recipients,
1310 sw1="s5",
1311 sw2="s2",
1312 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001313 else:
1314 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001315
1316 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001317 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001318 onpass=main.assertReturnString,
1319 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001320
kelvin-onlab016dce22015-08-10 09:54:11 -07001321 main.intentFunction.report( main )
1322
kelvin-onlabb769f562015-07-15 17:05:10 -07001323 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001324 """
1325 Add single point to multi point intents
1326 - Get device ids
1327 - Add single point to multi point intents
1328 - Check intents
1329 - Verify flows
1330 - Ping hosts
1331 - Reroute
1332 - Link down
1333 - Verify flows
1334 - Check topology
1335 - Ping hosts
1336 - Link up
1337 - Verify flows
1338 - Check topology
1339 - Ping hosts
1340 - Remove intents
1341 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001342 if main.initialized == main.FALSE:
1343 main.log.error( "Test components did not start correctly, skipping further tests" )
1344 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001345 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001346 try:
1347 assert main.CLIs
1348 except AssertionError:
1349 main.log.error( "There is no main.CLIs, skipping test cases" )
1350 main.initialized = main.FALSE
1351 main.skipCase()
1352 try:
1353 assert main.Mininet1
1354 except AssertionError:
1355 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1356 main.initialized = main.FALSE
1357 main.skipCase()
1358 try:
1359 assert main.numSwitch
1360 except AssertionError:
1361 main.log.error( "Place the total number of switch topology in \
1362 main.numSwitch" )
1363 main.initialized = main.FALSE
1364 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001365
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001366 main.testName = "Single to Multi Point Intents"
1367 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001368 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001369 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001370 " multi point intents using " +\
1371 str( main.numCtrls ) + " node(s) cluster;\n" +\
1372 "Different type of hosts will be tested in " +\
1373 "each step such as IPV4, Dual stack, VLAN etc" +\
1374 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001375 " OVS running in Mininet and compile intents" +\
1376 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001377
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001378 main.step( "NOOPTION: Install and test single point to multi point intents" )
1379 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
1380 senders = [
1381 { "name":"h8", "device":"of:0000000000000005/8" }
1382 ]
1383 recipients = [
1384 { "name":"h16", "device":"of:0000000000000006/8" },
1385 { "name":"h24", "device":"of:0000000000000007/8" }
1386 ]
1387 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1388 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1389 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001390 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001391 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001392 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001393 name="NOOPTION",
1394 senders=senders,
1395 recipients=recipients,
1396 sw1="s5",
1397 sw2="s2")
1398
1399 if installResult:
1400 testResult = main.intentFunction.testPointIntent(
1401 main,
1402 intentId=installResult,
1403 name="NOOPTION",
1404 senders=senders,
1405 recipients=recipients,
1406 badSenders=badSenders,
1407 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001408 sw1="s5",
1409 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001410 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001411 else:
1412 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001413
1414 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001415 actual=testResult,
1416 onpass=main.assertReturnString,
1417 onfail=main.assertReturnString )
1418
1419 main.step( "IPV4: Install and test single point to multi point intents" )
1420 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses\n"
1421 senders = [
1422 { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" }
1423 ]
1424 recipients = [
1425 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1426 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1427 ]
1428 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1429 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1430 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001431 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001432 installResult = main.intentFunction.installSingleToMultiIntent(
1433 main,
1434 name="IPV4",
1435 senders=senders,
1436 recipients=recipients,
1437 ethType="IPV4",
1438 sw1="s5",
1439 sw2="s2")
1440
1441 if installResult:
1442 testResult = main.intentFunction.testPointIntent(
1443 main,
1444 intentId=installResult,
1445 name="IPV4",
1446 senders=senders,
1447 recipients=recipients,
1448 badSenders=badSenders,
1449 badRecipients=badRecipients,
1450 sw1="s5",
1451 sw2="s2",
1452 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001453 else:
1454 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001455
1456 utilities.assert_equals( expect=main.TRUE,
1457 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001458 onpass=main.assertReturnString,
1459 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001460
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001461 main.step( "IPV4_2: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001462 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 -08001463 senders = [
1464 { "name":"h8", "device":"of:0000000000000005/8" }
1465 ]
1466 recipients = [
1467 { "name":"h16", "device":"of:0000000000000006/8" },
1468 { "name":"h24", "device":"of:0000000000000007/8" }
1469 ]
1470 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1471 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1472 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001473 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001474 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001475 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001476 name="IPV4_2",
1477 senders=senders,
1478 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001479 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001480 sw1="s5",
1481 sw2="s2")
1482
1483 if installResult:
1484 testResult = main.intentFunction.testPointIntent(
1485 main,
1486 intentId=installResult,
1487 name="IPV4_2",
1488 senders=senders,
1489 recipients=recipients,
1490 badSenders=badSenders,
1491 badRecipients=badRecipients,
1492 sw1="s5",
1493 sw2="s2",
1494 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001495 else:
1496 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001497
1498 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001499 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001500 onpass=main.assertReturnString,
1501 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001502
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001503 main.step( "VLAN: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001504 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 -08001505 senders = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001506 { "name":"h4", "device":"of:0000000000000005/4", "mac":"00:00:00:00:00:04", "vlan":"100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001507 ]
1508 recipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001509 { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C", "vlan":"100" },
1510 { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14", "vlan":"100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001511 ]
1512 badSenders=[ { "name":"h13" } ] # Senders that are not in the intent
1513 badRecipients=[ { "name":"h21" } ] # Recipients that are not in the intent
1514 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001515 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001516 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001517 main,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001518 name="VLAN`",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001519 senders=senders,
1520 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001521 sw1="s5",
1522 sw2="s2")
1523
1524 if installResult:
1525 testResult = main.intentFunction.testPointIntent(
1526 main,
1527 intentId=installResult,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001528 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001529 senders=senders,
1530 recipients=recipients,
1531 badSenders=badSenders,
1532 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001533 sw1="s5",
1534 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001535 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001536 else:
1537 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001538
1539 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001540 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001541 onpass=main.assertReturnString,
1542 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001543
Jeremy Songsterff553672016-05-12 17:06:23 -07001544 main.step( "VLAN: Add single point to multi point intents" )
1545 main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n"
1546 senders = [
1547 { "name":"h5", "vlan":"200" }
1548 ]
1549 recipients = [
1550 { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C", "vlan":"100" },
1551 { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14", "vlan":"100" }
1552 ]
1553 badSenders=[ { "name":"h13" } ] # Senders that are not in the intent
1554 badRecipients=[ { "name":"h21" } ] # Recipients that are not in the intent
1555 testResult = main.FALSE
1556 installResult = main.FALSE
1557 installResult = main.intentFunction.installSingleToMultiIntent(
1558 main,
1559 name="VLAN2",
1560 senders=senders,
1561 recipients=recipients,
1562 sw1="s5",
1563 sw2="s2",
1564 setVlan=100)
1565
1566 if installResult:
1567 testResult = main.intentFunction.testPointIntent(
1568 main,
1569 intentId=installResult,
1570 name="VLAN2",
1571 senders=senders,
1572 recipients=recipients,
1573 badSenders=badSenders,
1574 badRecipients=badRecipients,
1575 sw1="s5",
1576 sw2="s2",
1577 expectedLink=18)
1578 else:
1579 main.CLIs[ 0 ].removeAllIntents( purge=True )
1580
1581 utilities.assert_equals( expect=main.TRUE,
1582 actual=testResult,
1583 onpass=main.assertReturnString,
1584 onfail=main.assertReturnString )
1585
kelvin-onlab016dce22015-08-10 09:54:11 -07001586 main.intentFunction.report( main )
1587
kelvin-onlabb769f562015-07-15 17:05:10 -07001588 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001589 """
1590 Add multi point to single point intents
1591 - Get device ids
1592 - Add multi point to single point intents
1593 - Check intents
1594 - Verify flows
1595 - Ping hosts
1596 - Reroute
1597 - Link down
1598 - Verify flows
1599 - Check topology
1600 - Ping hosts
1601 - Link up
1602 - Verify flows
1603 - Check topology
1604 - Ping hosts
1605 - Remove intents
1606 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001607 if main.initialized == main.FALSE:
1608 main.log.error( "Test components did not start correctly, skipping further tests" )
1609 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001610 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001611 try:
1612 assert main.CLIs
1613 except AssertionError:
1614 main.log.error( "There is no main.CLIs, skipping test cases" )
1615 main.initialized = main.FALSE
1616 main.skipCase()
1617 try:
1618 assert main.Mininet1
1619 except AssertionError:
1620 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1621 main.initialized = main.FALSE
1622 main.skipCase()
1623 try:
1624 assert main.numSwitch
1625 except AssertionError:
1626 main.log.error( "Place the total number of switch topology in \
1627 main.numSwitch" )
1628 main.initialized = main.FALSE
1629 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001630
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001631 main.testName = "Multi To Single Point Intents"
1632 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001633 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001634 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001635 " multi point intents using " +\
1636 str( main.numCtrls ) + " node(s) cluster;\n" +\
1637 "Different type of hosts will be tested in " +\
1638 "each step such as IPV4, Dual stack, VLAN etc" +\
1639 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001640 " OVS running in Mininet and compile intents" +\
1641 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001642
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001643 main.step( "NOOPTION: Add multi point to single point intents" )
1644 main.assertReturnString = "Assertion results for NOOPTION multi to single point intent\n"
1645 senders = [
1646 { "name":"h16", "device":"of:0000000000000006/8" },
1647 { "name":"h24", "device":"of:0000000000000007/8" }
1648 ]
1649 recipients = [
1650 { "name":"h8", "device":"of:0000000000000005/8" }
1651 ]
1652 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1653 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1654 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001655 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001656 installResult = main.intentFunction.installMultiToSingleIntent(
1657 main,
1658 name="NOOPTION",
1659 senders=senders,
1660 recipients=recipients,
1661 sw1="s5",
Jeremye0cb5eb2016-01-27 17:39:09 -08001662 sw2="s2" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001663
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001664 if installResult:
1665 testResult = main.intentFunction.testPointIntent(
1666 main,
1667 intentId=installResult,
1668 name="NOOPTION",
1669 senders=senders,
1670 recipients=recipients,
1671 badSenders=badSenders,
1672 badRecipients=badRecipients,
1673 sw1="s5",
1674 sw2="s2",
Jeremye0cb5eb2016-01-27 17:39:09 -08001675 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001676 else:
1677 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001678
1679 utilities.assert_equals( expect=main.TRUE,
1680 actual=testResult,
1681 onpass=main.assertReturnString,
1682 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001683
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001684 main.step( "IPV4: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001685 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 -08001686 senders = [
1687 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1688 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1689 ]
1690 recipients = [
1691 { "name":"h8", "device":"of:0000000000000005/8", "mac":"00:00:00:00:00:08" }
1692 ]
1693 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1694 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1695 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001696 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001697 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001698 main,
1699 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001700 senders=senders,
1701 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001702 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001703 sw1="s5",
1704 sw2="s2")
1705
1706 if installResult:
1707 testResult = main.intentFunction.testPointIntent(
1708 main,
1709 intentId=installResult,
1710 name="IPV4",
1711 senders=senders,
1712 recipients=recipients,
1713 badSenders=badSenders,
1714 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001715 sw1="s5",
1716 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001717 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001718 else:
1719 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001720
1721 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001722 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001723 onpass=main.assertReturnString,
1724 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001725
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001726 main.step( "IPV4_2: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001727 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 -08001728 senders = [
1729 { "name":"h16", "device":"of:0000000000000006/8" },
1730 { "name":"h24", "device":"of:0000000000000007/8" }
1731 ]
1732 recipients = [
1733 { "name":"h8", "device":"of:0000000000000005/8" }
1734 ]
1735 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1736 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1737 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001738 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001739 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001740 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001741 name="IPV4_2",
1742 senders=senders,
1743 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001744 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001745 sw1="s5",
1746 sw2="s2")
1747
1748 if installResult:
1749 testResult = main.intentFunction.testPointIntent(
1750 main,
1751 intentId=installResult,
1752 name="IPV4_2",
1753 senders=senders,
1754 recipients=recipients,
1755 badSenders=badSenders,
1756 badRecipients=badRecipients,
1757 sw1="s5",
1758 sw2="s2",
1759 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001760 else:
1761 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001762
1763 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001764 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001765 onpass=main.assertReturnString,
1766 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001767
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001768 main.step( "VLAN: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001769 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 -08001770 senders = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001771 { "name":"h13", "device":"of:0000000000000006/5", "vlan":"200" },
1772 { "name":"h21", "device":"of:0000000000000007/5", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001773 ]
1774 recipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001775 { "name":"h5", "device":"of:0000000000000005/5", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001776 ]
1777 badSenders=[ { "name":"h12" } ] # Senders that are not in the intent
1778 badRecipients=[ { "name":"h20" } ] # Recipients that are not in the intent
1779 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001780 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001781 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001782 main,
1783 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001784 senders=senders,
1785 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001786 sw1="s5",
1787 sw2="s2")
1788
1789 if installResult:
1790 testResult = main.intentFunction.testPointIntent(
1791 main,
1792 intentId=installResult,
1793 name="VLAN",
1794 senders=senders,
1795 recipients=recipients,
1796 badSenders=badSenders,
1797 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001798 sw1="s5",
1799 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001800 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001801 else:
1802 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001803
1804 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001805 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001806 onpass=main.assertReturnString,
1807 onfail=main.assertReturnString )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001808
Jeremy Songsterff553672016-05-12 17:06:23 -07001809 # Right now this fails because of this bug: https://jira.onosproject.org/browse/ONOS-4383
1810 main.step( "VLAN: Add multi point to single point intents" )
1811 main.assertReturnString = "Assertion results for multi to single point intent with VLAN ID treatment\n"
1812 senders = [
1813 { "name":"h13", "device":"of:0000000000000006/5", "vlan":"200" },
1814 { "name":"h21", "device":"of:0000000000000007/5", "vlan":"200" }
1815 ]
1816 recipients = [
1817 { "name":"h4", "vlan":"100" }
1818 ]
1819 badSenders=[ { "name":"h12" } ] # Senders that are not in the intent
1820 badRecipients=[ { "name":"h20" } ] # Recipients that are not in the intent
1821 testResult = main.FALSE
1822 installResult = main.FALSE
1823 installResult = main.intentFunction.installMultiToSingleIntent(
1824 main,
1825 name="VLAN2",
1826 senders=senders,
1827 recipients=recipients,
1828 sw1="s5",
1829 sw2="s2",
1830 setVlan=100)
1831
1832 if installResult:
1833 testResult = main.intentFunction.testPointIntent(
1834 main,
1835 intentId=installResult,
1836 name="VLAN2",
1837 senders=senders,
1838 recipients=recipients,
1839 badSenders=badSenders,
1840 badRecipients=badRecipients,
1841 sw1="s5",
1842 sw2="s2",
1843 expectedLink=18)
1844 else:
1845 main.CLIs[ 0 ].removeAllIntents( purge=True )
1846
1847 utilities.assert_equals( expect=main.TRUE,
1848 actual=testResult,
1849 onpass=main.assertReturnString,
1850 onfail=main.assertReturnString )
1851
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001852 main.intentFunction.report( main )
1853
acsmars1ff5e052015-07-23 11:27:48 -07001854 def CASE5000( self, main ):
1855 """
acsmars5d8cc862015-09-25 09:44:50 -07001856 Tests Host Mobility
1857 Modifies the topology location of h1
acsmars1ff5e052015-07-23 11:27:48 -07001858 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001859 if main.initialized == main.FALSE:
1860 main.log.error( "Test components did not start correctly, skipping further tests" )
1861 main.skipCase()
acsmars1ff5e052015-07-23 11:27:48 -07001862 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001863 try:
1864 assert main.CLIs
1865 except AssertionError:
1866 main.log.error( "There is no main.CLIs, skipping test cases" )
1867 main.initialized = main.FALSE
1868 main.skipCase()
1869 try:
1870 assert main.Mininet1
1871 except AssertionError:
1872 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1873 main.initialized = main.FALSE
1874 main.skipCase()
1875 try:
1876 assert main.numSwitch
1877 except AssertionError:
1878 main.log.error( "Place the total number of switch topology in \
1879 main.numSwitch" )
1880 main.initialized = main.FALSE
1881 main.skipCase()
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001882 main.case( "Test host mobility with host intents " )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001883 main.step( "Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07001884 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1885
Jeremy2f190ca2016-01-29 15:23:57 -08001886 main.log.info( "Moving h1 from s5 to s6")
acsmars1ff5e052015-07-23 11:27:48 -07001887 main.Mininet1.moveHost( "h1","s5","s6" )
1888
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001889 # Send discovery ping from moved host
1890 # Moving the host brings down the default interfaces and creates a new one.
1891 # Scapy is restarted on this host to detect the new interface
1892 main.h1.stopScapy()
1893 main.h1.startScapy()
1894
1895 # Discover new host location in ONOS and populate host data.
1896 # Host 1 IP and MAC should be unchanged
1897 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
1898 main.intentFunction.populateHostData( main )
1899
acsmars1ff5e052015-07-23 11:27:48 -07001900 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1901
1902 utilities.assert_equals( expect="of:0000000000000006",
1903 actual=h1PostMove,
1904 onpass="Mobility: Successfully moved h1 to s6",
acsmars5d8cc862015-09-25 09:44:50 -07001905 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001906 " to single point intents" +
1907 " with IPV4 type and MAC addresses" +
1908 " in the same VLAN" )
1909
1910 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001911 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001912 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
1913 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
Jeremy42df2e72016-02-23 16:37:46 -08001914 testResult = main.FALSE
1915 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001916 installResult = main.intentFunction.installHostIntent( main,
1917 name='IPV4 Mobility IPV4',
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001918 onosNode='0',
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001919 host1=host1,
Jeremye0cb5eb2016-01-27 17:39:09 -08001920 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -08001921 if installResult:
1922 testResult = main.intentFunction.testHostIntent( main,
1923 name='Host Mobility IPV4',
1924 intentId = installResult,
1925 onosNode='0',
1926 host1=host1,
1927 host2=host2,
1928 sw1="s6",
1929 sw2="s2",
1930 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001931 else:
1932 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001933
1934 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001935 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001936 onpass=main.assertReturnString,
1937 onfail=main.assertReturnString )
kelvin-onlab016dce22015-08-10 09:54:11 -07001938
1939 main.intentFunction.report( main )
Jeremye0cb5eb2016-01-27 17:39:09 -08001940
1941 def CASE6000( self, main ):
1942 """
1943 Tests Multi to Single Point Intent and Single to Multi Point Intent End Point Failure
1944 """
Jeremy Songster9385d412016-06-02 17:57:36 -07001945 # At some later point discussion on this behavior in MPSP and SPMP intents
1946 # will be reoppened and this test case may need to be updated to reflect
1947 # the outcomes of that discussion
Jeremyd9e4eb12016-04-13 12:09:06 -07001948 if main.initialized == main.FALSE:
1949 main.log.error( "Test components did not start correctly, skipping further tests" )
1950 main.skipCase()
Jeremye0cb5eb2016-01-27 17:39:09 -08001951 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001952 try:
1953 assert main.CLIs
1954 except AssertionError:
1955 main.log.error( "There is no main.CLIs, skipping test cases" )
1956 main.initialized = main.FALSE
1957 main.skipCase()
1958 try:
1959 assert main.Mininet1
1960 except AssertionError:
1961 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1962 main.initialized = main.FALSE
1963 main.skipCase()
1964 try:
1965 assert main.numSwitch
1966 except AssertionError:
1967 main.log.error( "Place the total number of switch topology in \
1968 main.numSwitch" )
1969 main.initialized = main.FALSE
1970 main.skipCase()
Jeremye0cb5eb2016-01-27 17:39:09 -08001971 main.case( "Test Multi to Single End Point Failure" )
Jeremy Songster9385d412016-06-02 17:57:36 -07001972 main.step( "Installing Multi to Single Point intents with no options set" )
1973 main.assertReturnString = "Assertion results for IPV4 multi to single " +\
1974 "point intent end point failure with no options set\n"
Jeremye0cb5eb2016-01-27 17:39:09 -08001975 senders = [
1976 { "name":"h16", "device":"of:0000000000000006/8" },
1977 { "name":"h24", "device":"of:0000000000000007/8" }
1978 ]
1979 recipients = [
1980 { "name":"h8", "device":"of:0000000000000005/8" }
1981 ]
1982 isolatedSenders = [
1983 { "name":"h24"}
1984 ]
1985 isolatedRecipients = []
1986 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001987 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08001988 installResult = main.intentFunction.installMultiToSingleIntent(
1989 main,
1990 name="NOOPTION",
1991 senders=senders,
1992 recipients=recipients,
1993 sw1="s5",
1994 sw2="s2" )
1995
1996 if installResult:
1997 testResult = main.intentFunction.testEndPointFail(
1998 main,
1999 intentId=installResult,
2000 name="NOOPTION",
2001 senders=senders,
2002 recipients=recipients,
2003 isolatedSenders=isolatedSenders,
2004 isolatedRecipients=isolatedRecipients,
2005 sw1="s6",
2006 sw2="s2",
2007 sw3="s4",
2008 sw4="s1",
2009 sw5="s3",
2010 expectedLink1=16,
2011 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002012 else:
2013 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002014
2015 utilities.assert_equals( expect=main.TRUE,
2016 actual=testResult,
2017 onpass=main.assertReturnString,
2018 onfail=main.assertReturnString )
2019
Jeremy Songster9385d412016-06-02 17:57:36 -07002020 main.step( "Installing Multi to Single Point intents with partial failure allowed" )
2021
2022 main.assertReturnString = "Assertion results for IPV4 multi to single " +\
2023 "with partial failures allowed\n"
2024 senders = [
2025 { "name":"h16", "device":"of:0000000000000006/8" },
2026 { "name":"h24", "device":"of:0000000000000007/8" }
2027 ]
2028 recipients = [
2029 { "name":"h8", "device":"of:0000000000000005/8" }
2030 ]
2031 isolatedSenders = [
2032 { "name":"h24"}
2033 ]
2034 isolatedRecipients = []
2035 testResult = main.FALSE
2036 installResult = main.FALSE
2037 installResult = main.intentFunction.installMultiToSingleIntent(
2038 main,
2039 name="NOOPTION",
2040 senders=senders,
2041 recipients=recipients,
2042 sw1="s5",
2043 sw2="s2",
2044 partial=True )
2045
2046 if installResult:
2047 testResult = main.intentFunction.testEndPointFail(
2048 main,
2049 intentId=installResult,
2050 name="NOOPTION",
2051 senders=senders,
2052 recipients=recipients,
2053 isolatedSenders=isolatedSenders,
2054 isolatedRecipients=isolatedRecipients,
2055 sw1="s6",
2056 sw2="s2",
2057 sw3="s4",
2058 sw4="s1",
2059 sw5="s3",
2060 expectedLink1=16,
2061 expectedLink2=14,
2062 partial=True )
2063 else:
2064 main.CLIs[ 0 ].removeAllIntents( purge=True )
2065
2066 utilities.assert_equals( expect=main.TRUE,
2067 actual=testResult,
2068 onpass=main.assertReturnString,
2069 onfail=main.assertReturnString )
2070
Jeremye0cb5eb2016-01-27 17:39:09 -08002071 main.step( "NOOPTION: Install and test single point to multi point intents" )
Jeremy Songster9385d412016-06-02 17:57:36 -07002072 main.assertReturnString = "Assertion results for IPV4 single to multi " +\
2073 "point intent with no options set\n"
Jeremye0cb5eb2016-01-27 17:39:09 -08002074 senders = [
2075 { "name":"h8", "device":"of:0000000000000005/8" }
2076 ]
2077 recipients = [
2078 { "name":"h16", "device":"of:0000000000000006/8" },
2079 { "name":"h24", "device":"of:0000000000000007/8" }
2080 ]
Jeremy Songster9385d412016-06-02 17:57:36 -07002081 isolatedSenders = []
2082 isolatedRecipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07002083 { "name":"h24"}
Jeremye0cb5eb2016-01-27 17:39:09 -08002084 ]
2085 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08002086 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08002087 installResult = main.intentFunction.installSingleToMultiIntent(
2088 main,
2089 name="NOOPTION",
2090 senders=senders,
2091 recipients=recipients,
2092 sw1="s5",
2093 sw2="s2")
2094
2095 if installResult:
2096 testResult = main.intentFunction.testEndPointFail(
2097 main,
2098 intentId=installResult,
2099 name="NOOPTION",
2100 senders=senders,
2101 recipients=recipients,
2102 isolatedSenders=isolatedSenders,
2103 isolatedRecipients=isolatedRecipients,
2104 sw1="s6",
2105 sw2="s2",
2106 sw3="s4",
2107 sw4="s1",
2108 sw5="s3",
2109 expectedLink1=16,
2110 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002111 else:
2112 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002113
2114 utilities.assert_equals( expect=main.TRUE,
2115 actual=testResult,
2116 onpass=main.assertReturnString,
2117 onfail=main.assertReturnString )
Jeremy Songster9385d412016-06-02 17:57:36 -07002118 # Right now this functionality doesn't work properly in SPMP intents
2119 main.step( "NOOPTION: Install and test single point to multi point " +\
2120 "intents with partial failures allowed" )
2121 main.assertReturnString = "Assertion results for IPV4 single to multi " +\
2122 "point intent with partial failures allowed\n"
2123 senders = [
2124 { "name":"h8", "device":"of:0000000000000005/8" }
2125 ]
2126 recipients = [
2127 { "name":"h16", "device":"of:0000000000000006/8" },
2128 { "name":"h24", "device":"of:0000000000000007/8" }
2129 ]
2130 isolatedSenders = []
2131 isolatedRecipients = [
2132 { "name":"h24"}
2133 ]
2134 testResult = main.FALSE
2135 installResult = main.FALSE
2136 installResult = main.intentFunction.installSingleToMultiIntent(
2137 main,
2138 name="NOOPTION",
2139 senders=senders,
2140 recipients=recipients,
2141 sw1="s5",
2142 sw2="s2",
2143 partial=True)
2144
2145 if installResult:
2146 testResult = main.intentFunction.testEndPointFail(
2147 main,
2148 intentId=installResult,
2149 name="NOOPTION",
2150 senders=senders,
2151 recipients=recipients,
2152 isolatedSenders=isolatedSenders,
2153 isolatedRecipients=isolatedRecipients,
2154 sw1="s6",
2155 sw2="s2",
2156 sw3="s4",
2157 sw4="s1",
2158 sw5="s3",
2159 expectedLink1=16,
2160 expectedLink2=14,
2161 partial=True )
2162 else:
2163 main.CLIs[ 0 ].removeAllIntents( purge=True )
2164
2165 utilities.assert_equals( expect=main.TRUE,
2166 actual=testResult,
2167 onpass=main.assertReturnString,
2168 onfail=main.assertReturnString )
Jeremye0cb5eb2016-01-27 17:39:09 -08002169
Jeremy2f190ca2016-01-29 15:23:57 -08002170 main.intentFunction.report( main )