blob: b7a4a65dee3d2d45a8f034dd48cfb1964b5bf8c0 [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 ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07009 import imp
Jon Hallf632d202015-07-30 15:45:11 -070010 import re
kelvin-onlabd48a68c2015-07-13 16:01:36 -070011
12 """
13 - Construct tests variables
14 - GIT ( optional )
15 - Checkout ONOS master branch
16 - Pull latest ONOS code
17 - Building ONOS ( optional )
18 - Install ONOS package
19 - Build ONOS package
20 """
21
22 main.case( "Constructing test variables and building ONOS package" )
23 main.step( "Constructing test variables" )
Jon Hall783bbf92015-07-23 14:33:19 -070024 main.caseExplanation = "This test case is mainly for loading " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -070025 "from params file, and pull and build the " +\
26 " latest ONOS package"
kelvin-onlabd48a68c2015-07-13 16:01:36 -070027 stepResult = main.FALSE
28
29 # Test variables
Jon Halla3e02432015-07-24 15:55:42 -070030 try:
Jon Hallf632d202015-07-30 15:45:11 -070031 main.testOnDirectory = re.sub( "(/tests)$", "", main.testDir )
Jon Halla3e02432015-07-24 15:55:42 -070032 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
33 gitBranch = main.params[ 'GIT' ][ 'branch' ]
34 main.dependencyPath = main.testOnDirectory + \
35 main.params[ 'DEPENDENCY' ][ 'path' ]
36 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
37 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
38 if main.ONOSbench.maxNodes:
39 main.maxNodes = int( main.ONOSbench.maxNodes )
40 else:
41 main.maxNodes = 0
42 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
43 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
44 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
45 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
46 main.checkIntentSleep = int( main.params[ 'SLEEP' ][ 'checkintent' ] )
acsmarscfa52272015-08-06 15:21:45 -070047 main.removeIntentSleep = int( main.params[ 'SLEEP' ][ 'removeintent' ] )
Jon Halla3e02432015-07-24 15:55:42 -070048 main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] )
49 main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
acsmars59a4c552015-09-10 18:11:19 -070050 main.checkTopoAttempts = int( main.params[ 'SLEEP' ][ 'topoAttempts' ] )
Jeremy Songster306ed7a2016-07-19 10:59:07 -070051 main.flowDurationSleep = int( main.params[ 'SLEEP' ][ 'flowDuration' ] )
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 """
alison52b25892016-09-19 10:53:48 -0700135 import time
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" )
Jon Hallbd60ea02016-08-23 10:03:59 -0700189 packageResult = main.ONOSbench.buckBuild()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700190 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 ] )
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700303 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 ] )
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700318 except( TypeError, ValueError ):
319 main.log.error( "Could not load json:" + str( links[ controller ] ) )
acsmars2ec91d62015-09-16 11:15:48 -0700320 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 ] )
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700333 except( TypeError, ValueError ):
334 main.log.error( "Could not load json:" + str( hosts[ controller ] ) )
acsmars2ec91d62015-09-16 11:15:48 -0700335 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 switchList = []
442
443 # Creates a list switch name, use getSwitch() function later...
444 for i in range( 1, ( main.numSwitch + 1 ) ):
445 switchList.append( 's' + str( i ) )
446
447 tempONOSip = []
448 for i in range( main.numCtrls ):
449 tempONOSip.append( main.ONOSip[ i ] )
450
451 assignResult = main.Mininet1.assignSwController( sw=switchList,
452 ip=tempONOSip,
alison52b25892016-09-19 10:53:48 -0700453 port="6653" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700454 if not assignResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700455 main.log.error( "Problem assigning mastership of switches" )
456 main.initialized = main.FALSE
457 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700458
459 for i in range( 1, ( main.numSwitch + 1 ) ):
460 response = main.Mininet1.getSwController( "s" + str( i ) )
461 print( "Response is " + str( response ) )
462 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
463 assignResult = assignResult and main.TRUE
464 else:
465 assignResult = main.FALSE
466 stepResult = assignResult
467 utilities.assert_equals( expect=main.TRUE,
468 actual=stepResult,
469 onpass="Successfully assigned switches" +
470 "to controller",
471 onfail="Failed to assign switches to " +
472 "controller" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700473 if not stepResult:
474 main.initialized = main.FALSE
acsmars5d8cc862015-09-25 09:44:50 -0700475
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800476 def CASE13( self,main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700477 """
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800478 Create Scapy components
479 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700480 if main.initialized == main.FALSE:
481 main.log.error( "Test components did not start correctly, skipping further tests" )
482 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800483 main.case( "Create scapy components" )
484 main.step( "Create scapy components" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800485 scapyResult = main.TRUE
486 for hostName in main.scapyHostNames:
487 main.Scapy1.createHostComponent( hostName )
488 main.scapyHosts.append( getattr( main, hostName ) )
489
490 main.step( "Start scapy components" )
491 for host in main.scapyHosts:
492 host.startHostCli()
493 host.startScapy()
494 host.updateSelf()
495 main.log.debug( host.name )
496 main.log.debug( host.hostIp )
497 main.log.debug( host.hostMac )
498
499
500 utilities.assert_equals( expect=main.TRUE,
501 actual=scapyResult,
502 onpass="Successfully created Scapy Components",
503 onfail="Failed to discover Scapy Components" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700504 if not scapyResult:
505 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800506
507 def CASE14( self, main ):
508 """
509 Discover all hosts with fwd and pingall and store its data in a dictionary
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700510 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700511 if main.initialized == main.FALSE:
512 main.log.error( "Test components did not start correctly, skipping further tests" )
513 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700514 main.case( "Discover all hosts" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800515 main.step( "Pingall hosts and confirm ONOS discovery" )
516 utilities.retry( f=main.intentFunction.fwdPingall, retValue=main.FALSE, args=[ main ] )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700517
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800518 utilities.retry( f=main.intentFunction.confirmHostDiscovery, retValue=main.FALSE,
519 args=[ main ], attempts=main.checkTopoAttempts, sleep=2 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700520 utilities.assert_equals( expect=main.TRUE,
521 actual=stepResult,
522 onpass="Successfully discovered hosts",
523 onfail="Failed to discover hosts" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700524 if not stepResult:
525 main.initialized = main.FALSE
526 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700527
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800528 main.step( "Populate hostsData" )
529 stepResult = main.intentFunction.populateHostData( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700530 utilities.assert_equals( expect=main.TRUE,
531 actual=stepResult,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800532 onpass="Successfully populated hostsData",
533 onfail="Failed to populate hostsData" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700534 if not stepResult:
535 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800536
537 def CASE15( self, main ):
538 """
539 Discover all hosts with scapy arp packets and store its data to a dictionary
540 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700541 if main.initialized == main.FALSE:
542 main.log.error( "Test components did not start correctly, skipping further tests" )
543 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800544 main.case( "Discover all hosts using scapy" )
545 main.step( "Send packets from each host to the first host and confirm onos discovery" )
546
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800547 if len( main.scapyHosts ) < 1:
548 main.log.error( "No scapy hosts have been created" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700549 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800550 main.skipCase()
551
552 # Send ARP packets from each scapy host component
553 main.intentFunction.sendDiscoveryArp( main, main.scapyHosts )
554
555 stepResult = utilities.retry( f=main.intentFunction.confirmHostDiscovery,
556 retValue=main.FALSE, args=[ main ],
557 attempts=main.checkTopoAttempts, sleep=2 )
558
559 utilities.assert_equals( expect=main.TRUE,
560 actual=stepResult,
561 onpass="ONOS correctly discovered all hosts",
562 onfail="ONOS incorrectly discovered hosts" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700563 if not stepResult:
564 main.initialized = main.FALSE
565 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800566
567 main.step( "Populate hostsData" )
568 stepResult = main.intentFunction.populateHostData( main )
569 utilities.assert_equals( expect=main.TRUE,
570 actual=stepResult,
571 onpass="Successfully populated hostsData",
572 onfail="Failed to populate hostsData" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700573 if not stepResult:
574 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800575
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800576 def CASE16( self, main ):
577 """
Jeremy42df2e72016-02-23 16:37:46 -0800578 Balance Masters
579 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700580 if main.initialized == main.FALSE:
581 main.log.error( "Test components did not start correctly, skipping further tests" )
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700582 main.stop()
Jeremyd9e4eb12016-04-13 12:09:06 -0700583 main.skipCase()
Jeremy42df2e72016-02-23 16:37:46 -0800584 main.case( "Balance mastership of switches" )
585 main.step( "Balancing mastership of switches" )
586
Jeremy42df2e72016-02-23 16:37:46 -0800587 balanceResult = utilities.retry( f=main.CLIs[ 0 ].balanceMasters, retValue=main.FALSE, args=[] )
588
589 utilities.assert_equals( expect=main.TRUE,
Jeremy6e9748f2016-03-25 15:03:39 -0700590 actual=balanceResult,
Jeremy42df2e72016-02-23 16:37:46 -0800591 onpass="Successfully balanced mastership of switches",
592 onfail="Failed to balance mastership of switches" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700593 if not balanceResult:
594 main.initialized = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800595
596 def CASE17( self, main ):
597 """
Jeremy6e9748f2016-03-25 15:03:39 -0700598 Use Flow Objectives
599 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700600 if main.initialized == main.FALSE:
601 main.log.error( "Test components did not start correctly, skipping further tests" )
602 main.skipCase()
Jeremy6e9748f2016-03-25 15:03:39 -0700603 main.case( "Enable intent compilation using Flow Objectives" )
604 main.step( "Enabling Flow Objectives" )
605
606 main.flowCompiler = "Flow Objectives"
607
608 cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator"
609
610 stepResult = main.CLIs[ 0 ].setCfg( component=cmd,
611 propName="useFlowObjectives", value="true" )
612
613 utilities.assert_equals( expect=main.TRUE,
614 actual=stepResult,
615 onpass="Successfully activated Flow Objectives",
616 onfail="Failed to activate Flow Objectives" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700617 if not balanceResult:
618 main.initialized = main.FALSE
Jeremy6e9748f2016-03-25 15:03:39 -0700619
620 def CASE18( self, main ):
621 """
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800622 Stop mininet and remove scapy host
623 """
624 main.log.report( "Stop Mininet and Scapy" )
625 main.case( "Stop Mininet and Scapy" )
626 main.caseExplanation = "Stopping the current mininet topology " +\
627 "to start up fresh"
628 main.step( "Stopping and Removing Scapy Host Components" )
629 scapyResult = main.TRUE
630 for host in main.scapyHosts:
631 scapyResult = scapyResult and host.stopScapy()
632 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
633
634 for host in main.scapyHosts:
635 scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
636 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
637
638 main.scapyHosts = []
639 main.scapyHostIPs = []
640
641 utilities.assert_equals( expect=main.TRUE,
642 actual=scapyResult,
643 onpass="Successfully stopped scapy and removed host components",
644 onfail="Failed to stop mininet and scapy" )
645
646 main.step( "Stopping Mininet Topology" )
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700647 mininetResult = main.Mininet1.stopNet()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800648
649 utilities.assert_equals( expect=main.TRUE,
650 actual=mininetResult,
651 onpass="Successfully stopped mininet and scapy",
652 onfail="Failed to stop mininet and scapy" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700653 # Exit if topology did not load properly
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800654 if not ( mininetResult and scapyResult ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700655 main.cleanup()
656 main.exit()
657
Jeremy Songster17147f22016-05-31 18:30:52 -0700658 def CASE19( self, main ):
659 """
660 Copy the karaf.log files after each testcase cycle
661 """
662 main.log.report( "Copy karaf logs" )
663 main.case( "Copy karaf logs" )
664 main.caseExplanation = "Copying the karaf logs to preserve them through" +\
665 "reinstalling ONOS"
666 main.step( "Copying karaf logs" )
Jeremy Songster31aad312016-06-13 16:32:11 -0700667 stepResult = main.TRUE
668 scpResult = main.TRUE
669 copyResult = main.TRUE
Jeremy Songstercc5414b2016-07-11 10:59:53 -0700670 for i in range( main.numCtrls ):
671 main.node = main.CLIs[ i ]
Jeremy Songster17147f22016-05-31 18:30:52 -0700672 ip = main.ONOSip[ i ]
673 main.node.ip_address = ip
Jeremy Songster31aad312016-06-13 16:32:11 -0700674 scpResult = scpResult and main.ONOSbench.scp( main.node ,
675 "/opt/onos/log/karaf.log",
676 "/tmp/karaf.log",
677 direction="from" )
678 copyResult = copyResult and main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
679 copyFileName=( "karaf.log.node{0}.cycle{1}".format( str( i + 1 ), str( main.cycle ) ) ) )
680 if scpResult and copyResult:
681 stepResult = main.TRUE and stepResult
682 else:
683 stepResult = main.FALSE and stepResult
Jeremy Songster31aad312016-06-13 16:32:11 -0700684 utilities.assert_equals( expect=main.TRUE,
685 actual=stepResult,
686 onpass="Successfully copied remote ONOS logs",
687 onfail="Failed to copy remote ONOS logs" )
Jeremy Songster17147f22016-05-31 18:30:52 -0700688
kelvin-onlabb769f562015-07-15 17:05:10 -0700689 def CASE1000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700690 """
691 Add host intents between 2 host:
692 - Discover hosts
693 - Add host intents
694 - Check intents
695 - Verify flows
696 - Ping hosts
697 - Reroute
698 - Link down
699 - Verify flows
700 - Check topology
701 - Ping hosts
702 - Link up
703 - Verify flows
704 - Check topology
705 - Ping hosts
706 - Remove intents
707 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700708 if main.initialized == main.FALSE:
709 main.log.error( "Test components did not start correctly, skipping further tests" )
710 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700711 # Assert variables - These variable's name|format must be followed
712 # if you want to use the wrapper function
713 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -0700714 try:
715 assert main.CLIs
716 except AssertionError:
717 main.log.error( "There is no main.CLIs, skipping test cases" )
718 main.initialized = main.FALSE
719 main.skipCase()
720 try:
721 assert main.Mininet1
722 except AssertionError:
723 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
724 main.initialized = main.FALSE
725 main.skipCase()
726 try:
727 assert main.numSwitch
728 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700729 main.log.error( "Place the total number of switch topology in " +\
730 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -0700731 main.initialized = main.FALSE
732 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700733
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800734 # Save leader candidates
acsmarse6b410f2015-07-17 14:39:34 -0700735 intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
736
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700737 main.testName = "Host Intents"
738 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -0700739 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -0700740 main.caseExplanation = "This test case tests Host intents using " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700741 str( main.numCtrls ) + " node(s) cluster;\n" +\
742 "Different type of hosts will be tested in " +\
743 "each step such as IPV4, Dual stack, VLAN " +\
Jeremyeb51cb12016-03-28 17:53:35 -0700744 "etc;\nThe test will use OF " + main.OFProtocol +\
745 " OVS running in Mininet and compile intents" +\
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700746 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700747
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700748 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700749 main.assertReturnString = "Assertion Result for IPV4 host intent with mac addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800750 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
751 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
752 testResult = main.FALSE
753 installResult = main.intentFunction.installHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700754 name="IPV4",
755 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800756 host1=host1,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700757 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800758 if installResult:
759 testResult = main.intentFunction.testHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700760 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800761 intentId = installResult,
alison52b25892016-09-19 10:53:48 -0700762 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800763 host1=host1,
764 host2=host2,
alison52b25892016-09-19 10:53:48 -0700765 sw1="s5",
766 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700767 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800768 else:
769 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800770
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700771 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800772 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700773 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700774 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700775
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700776 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700777 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800778 host1 = { "name":"h3","id":"00:00:00:00:00:03/-1" }
779 host2 = { "name":"h11","id":"00:00:00:00:00:0B/-1 "}
780 testResult = main.FALSE
781 installResult = main.intentFunction.installHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700782 name="DUALSTACK",
783 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800784 host1=host1,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700785 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800786
787 if installResult:
788 testResult = main.intentFunction.testHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700789 name="DUALSTACK",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800790 intentId = installResult,
alison52b25892016-09-19 10:53:48 -0700791 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800792 host1=host1,
793 host2=host2,
alison52b25892016-09-19 10:53:48 -0700794 sw1="s5",
795 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700796 expectedLink=18 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700797
798 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800799 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700800 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700801 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700802
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700803 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700804 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800805 host1 = { "name":"h1" }
806 host2 = { "name":"h11" }
807 testResult = main.FALSE
808 installResult = main.intentFunction.installHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700809 name="DUALSTACK2",
810 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800811 host1=host1,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700812 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800813
814 if installResult:
815 testResult = main.intentFunction.testHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700816 name="DUALSTACK2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800817 intentId = installResult,
alison52b25892016-09-19 10:53:48 -0700818 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800819 host1=host1,
820 host2=host2,
alison52b25892016-09-19 10:53:48 -0700821 sw1="s5",
822 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700823 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800824 else:
825 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700826
827 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800828 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700829 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700830 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700831
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700832 main.step( "1HOP: Add host intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -0700833 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800834 host1 = { "name":"h1" }
835 host2 = { "name":"h3" }
836 testResult = main.FALSE
837 installResult = main.intentFunction.installHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700838 name="1HOP",
839 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800840 host1=host1,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700841 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800842
843 if installResult:
844 testResult = main.intentFunction.testHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700845 name="1HOP",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800846 intentId = installResult,
alison52b25892016-09-19 10:53:48 -0700847 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800848 host1=host1,
849 host2=host2,
alison52b25892016-09-19 10:53:48 -0700850 sw1="s5",
851 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700852 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800853 else:
854 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700855
856 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800857 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700858 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700859 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700860
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700861 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
acsmars5d8cc862015-09-25 09:44:50 -0700862 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jeremy Songster832f9e92016-05-05 14:30:49 -0700863 host1 = { "name":"h4","id":"00:00:00:00:00:04/100", "vlan":"100" }
864 host2 = { "name":"h12","id":"00:00:00:00:00:0C/100", "vlan":"100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800865 testResult = main.FALSE
866 installResult = main.intentFunction.installHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700867 name="VLAN1",
868 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800869 host1=host1,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700870 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800871
872 if installResult:
873 testResult = main.intentFunction.testHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700874 name="VLAN1",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800875 intentId = installResult,
alison52b25892016-09-19 10:53:48 -0700876 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800877 host1=host1,
878 host2=host2,
alison52b25892016-09-19 10:53:48 -0700879 sw1="s5",
880 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700881 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800882 else:
883 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700884
885 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800886 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700887 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700888 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700889
Jeremy Songsterff553672016-05-12 17:06:23 -0700890 main.step( "VLAN2: Add vlan host intents between h4 and h13" )
891 main.assertReturnString = "Assertion Result vlan IPV4\n"
892 host1 = { "name":"h5", "vlan":"200" }
893 host2 = { "name":"h12", "vlan":"100" }
894 testResult = main.FALSE
Jeremy Songsterff553672016-05-12 17:06:23 -0700895 installResult = main.intentFunction.installHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700896 name="VLAN2",
897 onosNode=0,
Jeremy Songsterff553672016-05-12 17:06:23 -0700898 host1=host1,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700899 host2=host2 )
Jeremy Songsterff553672016-05-12 17:06:23 -0700900
901 if installResult:
902 testResult = main.intentFunction.testHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700903 name="VLAN2",
Jeremy Songsterff553672016-05-12 17:06:23 -0700904 intentId = installResult,
alison52b25892016-09-19 10:53:48 -0700905 onosNode=0,
Jeremy Songsterff553672016-05-12 17:06:23 -0700906 host1=host1,
907 host2=host2,
alison52b25892016-09-19 10:53:48 -0700908 sw1="s5",
909 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700910 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -0700911 else:
912 main.CLIs[ 0 ].removeAllIntents( purge=True )
913
914 utilities.assert_equals( expect=main.TRUE,
915 actual=testResult,
916 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700917 onfail=main.assertReturnString )
Jeremy Songsterff553672016-05-12 17:06:23 -0700918
Jeremy Songsterc032f162016-08-04 17:14:49 -0700919 main.step( "Encapsulation: Add host intents between h1 and h9" )
920 main.assertReturnString = "Assertion Result for VLAN Encapsulated host intent\n"
921 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
922 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
923 testResult = main.FALSE
Jeremy Songsterc032f162016-08-04 17:14:49 -0700924 installResult = main.intentFunction.installHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700925 name="ENCAPSULATION",
926 onosNode=0,
Jeremy Songsterc032f162016-08-04 17:14:49 -0700927 host1=host1,
928 host2=host2,
929 encap="VLAN" )
930 if installResult:
931 testResult = main.intentFunction.testHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700932 name="ENCAPSULATION",
Jeremy Songsterc032f162016-08-04 17:14:49 -0700933 intentId = installResult,
alison52b25892016-09-19 10:53:48 -0700934 onosNode=0,
Jeremy Songsterc032f162016-08-04 17:14:49 -0700935 host1=host1,
936 host2=host2,
alison52b25892016-09-19 10:53:48 -0700937 sw1="s5",
938 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700939 expectedLink=18 )
Jeremy Songsterc032f162016-08-04 17:14:49 -0700940 else:
941 main.CLIs[ 0 ].removeAllIntents( purge=True )
942
943 utilities.assert_equals( expect=main.TRUE,
944 actual=testResult,
945 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700946 onfail=main.assertReturnString )
Jeremy Songsterc032f162016-08-04 17:14:49 -0700947
alison52b25892016-09-19 10:53:48 -0700948 # Testing MPLS would need to update kernel version (Right now is 3.16)
949 # main.step( "Encapsulation: Add host intents between h1 and h9" )
950 # main.assertReturnString = "Assertion Result for MPLS Encapsulated host intent\n"
951 # host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
952 # host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
953 # testResult = main.FALSE
954 # installResult = main.intentFunction.installHostIntent( main,
955 # name="ENCAPSULATION",
956 # onosNode=0,
957 # host1=host1,
958 # host2=host2,
959 # encap="MPLS" )
960 # if installResult:
961 # testResult = main.intentFunction.testHostIntent( main,
962 # name="ENCAPSULATION",
963 # intentId=installResult,
964 # onosNode=0,
965 # host1=host1,
966 # host2=host2,
967 # sw1="s5",
968 # sw2="s2",
969 # expectedLink=18 )
970 # else:
971 # main.CLIs[ 0 ].removeAllIntents( purge=True )
972 #
973 # utilities.assert_equals( expect=main.TRUE,
974 # actual=testResult,
975 # onpass=main.assertReturnString,
976 # onfail=main.assertReturnString )
977
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700978 main.step( "Confirm that ONOS leadership is unchanged" )
acsmarse6b410f2015-07-17 14:39:34 -0700979 intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
alison52b25892016-09-19 10:53:48 -0700980 testResult = main.intentFunction.checkLeaderChange( intentLeadersOld,
acsmarse6b410f2015-07-17 14:39:34 -0700981 intentLeadersNew )
982
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800983 utilities.assert_equals( expect=main.TRUE,
984 actual=testResult,
985 onpass="ONOS Leaders Unchanged",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700986 onfail="ONOS Leader Mismatch" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800987
kelvin-onlab016dce22015-08-10 09:54:11 -0700988 main.intentFunction.report( main )
989
kelvin-onlabb769f562015-07-15 17:05:10 -0700990 def CASE2000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700991 """
992 Add point intents between 2 hosts:
993 - Get device ids | ports
994 - Add point intents
995 - Check intents
996 - Verify flows
997 - Ping hosts
998 - Reroute
999 - Link down
1000 - Verify flows
1001 - Check topology
1002 - Ping hosts
1003 - Link up
1004 - Verify flows
1005 - Check topology
1006 - Ping hosts
1007 - Remove intents
1008 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001009 if main.initialized == main.FALSE:
1010 main.log.error( "Test components did not start correctly, skipping further tests" )
1011 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001012 # Assert variables - These variable's name|format must be followed
1013 # if you want to use the wrapper function
1014 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001015 try:
1016 assert main.CLIs
1017 except AssertionError:
1018 main.log.error( "There is no main.CLIs, skipping test cases" )
1019 main.initialized = main.FALSE
1020 main.skipCase()
1021 try:
1022 assert main.Mininet1
1023 except AssertionError:
1024 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1025 main.initialized = main.FALSE
1026 main.skipCase()
1027 try:
1028 assert main.numSwitch
1029 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001030 main.log.error( "Place the total number of switch topology in " +\
1031 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001032 main.initialized = main.FALSE
1033 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001034
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001035 main.testName = "Point Intents"
1036 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001037 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001038 main.caseExplanation = "This test case will test point to point" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001039 " intents using " + str( main.numCtrls ) +\
1040 " node(s) cluster;\n" +\
1041 "Different type of hosts will be tested in " +\
1042 "each step such as IPV4, Dual stack, VLAN etc" +\
1043 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001044 " OVS running in Mininet and compile intents" +\
1045 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001046
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001047 # No option point intents
1048 main.step( "NOOPTION: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001049 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001050 senders = [
1051 { "name":"h1","device":"of:0000000000000005/1" }
1052 ]
1053 recipients = [
1054 { "name":"h9","device":"of:0000000000000006/1" }
1055 ]
Jeremy42df2e72016-02-23 16:37:46 -08001056 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001057 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001058 main,
1059 name="NOOPTION",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001060 senders=senders,
1061 recipients=recipients )
1062
1063 if installResult:
1064 testResult = main.intentFunction.testPointIntent(
1065 main,
1066 intentId=installResult,
1067 name="NOOPTION",
1068 senders=senders,
1069 recipients=recipients,
1070 sw1="s5",
1071 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001072 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001073 else:
1074 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001075
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001076 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001077 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001078 onpass=main.assertReturnString,
1079 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001080
kelvin-onlabb769f562015-07-15 17:05:10 -07001081 main.step( "IPV4: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001082 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001083 senders = [
1084 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1085 ]
1086 recipients = [
1087 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09" }
1088 ]
Jeremy42df2e72016-02-23 16:37:46 -08001089 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001090 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001091 main,
1092 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001093 senders=senders,
1094 recipients=recipients,
1095 ethType="IPV4" )
1096
1097 if installResult:
1098 testResult = main.intentFunction.testPointIntent(
1099 main,
1100 intentId=installResult,
1101 name="IPV4",
1102 senders=senders,
1103 recipients=recipients,
1104 sw1="s5",
1105 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001106 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001107 else:
1108 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001109
1110 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001111 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001112 onpass=main.assertReturnString,
1113 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001114 main.step( "IPV4_2: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001115 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001116 senders = [
1117 { "name":"h1","device":"of:0000000000000005/1" }
1118 ]
1119 recipients = [
1120 { "name":"h9","device":"of:0000000000000006/1" }
1121 ]
Jeremy42df2e72016-02-23 16:37:46 -08001122 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001123 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001124 main,
1125 name="IPV4_2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001126 senders=senders,
1127 recipients=recipients,
1128 ethType="IPV4" )
1129
1130 if installResult:
1131 testResult = main.intentFunction.testPointIntent(
1132 main,
1133 intentId=installResult,
1134 name="IPV4_2",
1135 senders=senders,
1136 recipients=recipients,
1137 sw1="s5",
1138 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001139 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001140 else:
1141 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001142
1143 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001144 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001145 onpass=main.assertReturnString,
1146 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001147
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001148 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001149 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001150 senders = [
1151 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01",
Jeremy6f000c62016-02-25 17:02:28 -08001152 "ip":( main.h1.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001153 ]
1154 recipients = [
1155 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09",
Jeremy6f000c62016-02-25 17:02:28 -08001156 "ip":( main.h9.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001157 ]
Jeremy6f000c62016-02-25 17:02:28 -08001158 ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ]
kelvin-onlab79ce0492015-07-27 16:14:39 -07001159 # Uneccessary, not including this in the selectors
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001160 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
1161 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
Jeremy42df2e72016-02-23 16:37:46 -08001162 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001163 installResult = main.intentFunction.installPointIntent(
1164 main,
1165 name="SDNIP-ICMP",
1166 senders=senders,
1167 recipients=recipients,
1168 ethType="IPV4",
1169 ipProto=ipProto,
1170 tcpSrc=tcpSrc,
1171 tcpDst=tcpDst )
1172
1173 if installResult:
1174 testResult = main.intentFunction.testPointIntent(
1175 main,
1176 intentId=installResult,
1177 name="SDNIP_ICMP",
1178 senders=senders,
1179 recipients=recipients,
1180 sw1="s5",
1181 sw2="s2",
Jeremy Songstere405d3d2016-05-17 11:18:57 -07001182 expectedLink=18,
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001183 useTCP=True )
Jeremy42df2e72016-02-23 16:37:46 -08001184 else:
1185 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabb769f562015-07-15 17:05:10 -07001186
1187 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001188 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001189 onpass=main.assertReturnString,
1190 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001191
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001192 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001193 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
kelvin-onlabb769f562015-07-15 17:05:10 -07001194 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
1195 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab58dc39e2015-08-06 08:11:09 -07001196 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
1197 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlabb769f562015-07-15 17:05:10 -07001198 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
1199 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
1200 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
1201
kelvin-onlab58dc39e2015-08-06 08:11:09 -07001202 stepResult = main.intentFunction.pointIntentTcp(
kelvin-onlabb769f562015-07-15 17:05:10 -07001203 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001204 name="SDNIP-TCP",
kelvin-onlabb769f562015-07-15 17:05:10 -07001205 host1="h1",
1206 host2="h9",
1207 deviceId1="of:0000000000000005/1",
1208 deviceId2="of:0000000000000006/1",
1209 mac1=mac1,
1210 mac2=mac2,
1211 ethType="IPV4",
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001212 ipProto=ipProto,
1213 ip1=ip1,
1214 ip2=ip2,
1215 tcp1=tcp1,
1216 tcp2=tcp2 )
kelvin-onlabb769f562015-07-15 17:05:10 -07001217
1218 utilities.assert_equals( expect=main.TRUE,
Jeremy6f000c62016-02-25 17:02:28 -08001219 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -07001220 onpass=main.assertReturnString,
1221 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001222
acsmars5d8cc862015-09-25 09:44:50 -07001223 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
1224 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001225 senders = [
1226 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1227 ]
1228 recipients = [
1229 { "name":"h11","device":"of:0000000000000006/3","mac":"00:00:00:00:00:0B" }
1230 ]
Jeremy42df2e72016-02-23 16:37:46 -08001231 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001232 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001233 main,
1234 name="DUALSTACK1",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001235 senders=senders,
1236 recipients=recipients,
1237 ethType="IPV4" )
1238
1239 if installResult:
1240 testResult = main.intentFunction.testPointIntent(
1241 main,
1242 intentId=installResult,
1243 name="DUALSTACK1",
1244 senders=senders,
1245 recipients=recipients,
1246 sw1="s5",
1247 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001248 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001249 else:
1250 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001251
1252 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001253 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001254 onpass=main.assertReturnString,
1255 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001256
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001257 main.step( "VLAN: Add point intents between h5 and h21" )
acsmars5d8cc862015-09-25 09:44:50 -07001258 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001259 senders = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001260 { "name":"h5","device":"of:0000000000000005/5","mac":"00:00:00:00:00:05", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001261 ]
1262 recipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001263 { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001264 ]
Jeremy42df2e72016-02-23 16:37:46 -08001265 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001266 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001267 main,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001268 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001269 senders=senders,
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001270 recipients=recipients )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001271
1272 if installResult:
1273 testResult = main.intentFunction.testPointIntent(
1274 main,
1275 intentId=installResult,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001276 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001277 senders=senders,
1278 recipients=recipients,
1279 sw1="s5",
1280 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001281 expectedLink=18 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001282
1283 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001284 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001285 onpass=main.assertReturnString,
1286 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001287
Jeremy Songsterff553672016-05-12 17:06:23 -07001288 main.step( "VLAN: Add point intents between h5 and h21" )
1289 main.assertReturnString = "Assertion Result for VLAN IPV4 point intents with VLAN treatment\n"
1290 senders = [
1291 { "name":"h4", "vlan":"100" }
1292 ]
1293 recipients = [
1294 { "name":"h21", "vlan":"200" }
1295 ]
1296 testResult = main.FALSE
Jeremy Songsterff553672016-05-12 17:06:23 -07001297 installResult = main.intentFunction.installPointIntent(
1298 main,
1299 name="VLAN2",
1300 senders=senders,
1301 recipients=recipients,
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001302 setVlan=200 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001303
1304 if installResult:
1305 testResult = main.intentFunction.testPointIntent(
1306 main,
1307 intentId=installResult,
1308 name="VLAN2",
1309 senders=senders,
1310 recipients=recipients,
1311 sw1="s5",
1312 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001313 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001314
1315 utilities.assert_equals( expect=main.TRUE,
1316 actual=testResult,
1317 onpass=main.assertReturnString,
1318 onfail=main.assertReturnString )
1319
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001320 main.step( "1HOP: Add point intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -07001321 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001322 senders = [
1323 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1324 ]
1325 recipients = [
1326 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1327 ]
Jeremy42df2e72016-02-23 16:37:46 -08001328 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001329 installResult = main.intentFunction.installPointIntent(
1330 main,
1331 name="1HOP IPV4",
1332 senders=senders,
1333 recipients=recipients,
1334 ethType="IPV4" )
1335
1336 if installResult:
1337 testResult = main.intentFunction.testPointIntent(
1338 main,
1339 intentId=installResult,
1340 name="1HOP IPV4",
1341 senders=senders,
1342 recipients=recipients,
1343 sw1="s5",
1344 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001345 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001346 else:
1347 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001348
1349 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001350 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001351 onpass=main.assertReturnString,
1352 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001353
Jeremy Songsterc032f162016-08-04 17:14:49 -07001354 main.step( "Add point to point intents using VLAN Encapsulation" )
1355 main.assertReturnString = "Assertion Result for VLAN Encapsulation Point Intent"
1356 senders = [
1357 { "name":"h1","device":"of:0000000000000005/1" }
1358 ]
1359 recipients = [
1360 { "name":"h9","device":"of:0000000000000006/1" }
1361 ]
1362 testResult = main.FALSE
Jeremy Songsterc032f162016-08-04 17:14:49 -07001363 installResult = main.intentFunction.installPointIntent(
1364 main,
1365 name="ENCAPSULATION",
1366 senders=senders,
1367 recipients=recipients,
1368 encap="VLAN" )
1369
1370 if installResult:
1371 testResult = main.intentFunction.testPointIntent(
1372 main,
1373 intentId=installResult,
1374 name="ENCAPSULATION",
1375 senders=senders,
1376 recipients=recipients,
1377 sw1="s5",
1378 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001379 expectedLink=18 )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001380 else:
1381 main.CLIs[ 0 ].removeAllIntents( purge=True )
1382
1383 utilities.assert_equals( expect=main.TRUE,
1384 actual=testResult,
1385 onpass=main.assertReturnString,
1386 onfail=main.assertReturnString )
1387
alison52b25892016-09-19 10:53:48 -07001388 # Testing MPLS would need to update kernel version (Right now is 3.16)
1389 # main.step( "Add point to point intents using MPLS Encapsulation" )
1390 # main.assertReturnString = "Assertion Result for MPLS Encapsulation Point Intent"
1391 # senders = [
1392 # { "name": "h1", "device": "of:0000000000000005/1" }
1393 # ]
1394 # recipients = [
1395 # { "name": "h9", "device": "of:0000000000000006/1" }
1396 # ]
1397 # testResult = main.FALSE
1398 # installResult = main.intentFunction.installPointIntent(
1399 # main,
1400 # name="ENCAPSULATION",
1401 # senders=senders,
1402 # recipients=recipients,
1403 # encap="MPLS" )
1404 #
1405 # if installResult:
1406 # testResult = main.intentFunction.testPointIntent(
1407 # main,
1408 # intentId=installResult,
1409 # name="ENCAPSULATION",
1410 # senders=senders,
1411 # recipients=recipients,
1412 # sw1="s5",
1413 # sw2="s2",
1414 # expectedLink=18 )
1415 # else:
1416 # main.CLIs[ 0 ].removeAllIntents( purge=True )
1417 #
1418 # utilities.assert_equals( expect=main.TRUE,
1419 # actual=testResult,
1420 # onpass=main.assertReturnString,
1421 # onfail=main.assertReturnString )
1422
kelvin-onlab016dce22015-08-10 09:54:11 -07001423 main.intentFunction.report( main )
1424
kelvin-onlabb769f562015-07-15 17:05:10 -07001425 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001426 """
1427 Add single point to multi point intents
1428 - Get device ids
1429 - Add single point to multi point intents
1430 - Check intents
1431 - Verify flows
1432 - Ping hosts
1433 - Reroute
1434 - Link down
1435 - Verify flows
1436 - Check topology
1437 - Ping hosts
1438 - Link up
1439 - Verify flows
1440 - Check topology
1441 - Ping hosts
1442 - Remove intents
1443 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001444 if main.initialized == main.FALSE:
1445 main.log.error( "Test components did not start correctly, skipping further tests" )
1446 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001447 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001448 try:
1449 assert main.CLIs
1450 except AssertionError:
1451 main.log.error( "There is no main.CLIs, skipping test cases" )
1452 main.initialized = main.FALSE
1453 main.skipCase()
1454 try:
1455 assert main.Mininet1
1456 except AssertionError:
1457 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1458 main.initialized = main.FALSE
1459 main.skipCase()
1460 try:
1461 assert main.numSwitch
1462 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001463 main.log.error( "Place the total number of switch topology in "+ \
1464 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001465 main.initialized = main.FALSE
1466 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001467
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001468 main.testName = "Single to Multi Point Intents"
1469 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001470 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001471 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001472 " multi point intents using " +\
1473 str( main.numCtrls ) + " node(s) cluster;\n" +\
1474 "Different type of hosts will be tested in " +\
1475 "each step such as IPV4, Dual stack, VLAN etc" +\
1476 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001477 " OVS running in Mininet and compile intents" +\
1478 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001479
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001480 main.step( "NOOPTION: Install and test single point to multi point intents" )
1481 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
1482 senders = [
1483 { "name":"h8", "device":"of:0000000000000005/8" }
1484 ]
1485 recipients = [
1486 { "name":"h16", "device":"of:0000000000000006/8" },
1487 { "name":"h24", "device":"of:0000000000000007/8" }
1488 ]
1489 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1490 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1491 testResult = main.FALSE
1492 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001493 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001494 name="NOOPTION",
1495 senders=senders,
1496 recipients=recipients,
1497 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001498 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001499
1500 if installResult:
1501 testResult = main.intentFunction.testPointIntent(
1502 main,
1503 intentId=installResult,
1504 name="NOOPTION",
1505 senders=senders,
1506 recipients=recipients,
1507 badSenders=badSenders,
1508 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001509 sw1="s5",
1510 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001511 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001512 else:
1513 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001514
1515 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001516 actual=testResult,
1517 onpass=main.assertReturnString,
1518 onfail=main.assertReturnString )
1519
1520 main.step( "IPV4: Install and test single point to multi point intents" )
1521 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses\n"
1522 senders = [
1523 { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" }
1524 ]
1525 recipients = [
1526 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1527 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1528 ]
1529 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1530 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1531 testResult = main.FALSE
1532 installResult = main.intentFunction.installSingleToMultiIntent(
1533 main,
1534 name="IPV4",
1535 senders=senders,
1536 recipients=recipients,
1537 ethType="IPV4",
1538 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001539 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001540
1541 if installResult:
1542 testResult = main.intentFunction.testPointIntent(
1543 main,
1544 intentId=installResult,
1545 name="IPV4",
1546 senders=senders,
1547 recipients=recipients,
1548 badSenders=badSenders,
1549 badRecipients=badRecipients,
1550 sw1="s5",
1551 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001552 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001553 else:
1554 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001555
1556 utilities.assert_equals( expect=main.TRUE,
1557 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001558 onpass=main.assertReturnString,
1559 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001560
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001561 main.step( "IPV4_2: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001562 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 -08001563 senders = [
1564 { "name":"h8", "device":"of:0000000000000005/8" }
1565 ]
1566 recipients = [
1567 { "name":"h16", "device":"of:0000000000000006/8" },
1568 { "name":"h24", "device":"of:0000000000000007/8" }
1569 ]
1570 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1571 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1572 testResult = main.FALSE
1573 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001574 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001575 name="IPV4_2",
1576 senders=senders,
1577 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001578 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001579 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001580 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001581
1582 if installResult:
1583 testResult = main.intentFunction.testPointIntent(
1584 main,
1585 intentId=installResult,
1586 name="IPV4_2",
1587 senders=senders,
1588 recipients=recipients,
1589 badSenders=badSenders,
1590 badRecipients=badRecipients,
1591 sw1="s5",
1592 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001593 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001594 else:
1595 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001596
1597 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001598 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001599 onpass=main.assertReturnString,
1600 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001601
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001602 main.step( "VLAN: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001603 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 -08001604 senders = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001605 { "name":"h4", "device":"of:0000000000000005/4", "mac":"00:00:00:00:00:04", "vlan":"100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001606 ]
1607 recipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001608 { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C", "vlan":"100" },
1609 { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14", "vlan":"100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001610 ]
1611 badSenders=[ { "name":"h13" } ] # Senders that are not in the intent
1612 badRecipients=[ { "name":"h21" } ] # Recipients that are not in the intent
1613 testResult = main.FALSE
1614 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001615 main,
alison52b25892016-09-19 10:53:48 -07001616 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001617 senders=senders,
1618 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001619 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001620 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001621
1622 if installResult:
1623 testResult = main.intentFunction.testPointIntent(
1624 main,
1625 intentId=installResult,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001626 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001627 senders=senders,
1628 recipients=recipients,
1629 badSenders=badSenders,
1630 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001631 sw1="s5",
1632 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001633 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001634 else:
1635 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001636
1637 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001638 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001639 onpass=main.assertReturnString,
1640 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001641
Jeremy Songsterff553672016-05-12 17:06:23 -07001642 main.step( "VLAN: Add single point to multi point intents" )
1643 main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n"
1644 senders = [
1645 { "name":"h5", "vlan":"200" }
1646 ]
1647 recipients = [
1648 { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C", "vlan":"100" },
1649 { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14", "vlan":"100" }
1650 ]
1651 badSenders=[ { "name":"h13" } ] # Senders that are not in the intent
1652 badRecipients=[ { "name":"h21" } ] # Recipients that are not in the intent
1653 testResult = main.FALSE
Jeremy Songsterff553672016-05-12 17:06:23 -07001654 installResult = main.intentFunction.installSingleToMultiIntent(
1655 main,
1656 name="VLAN2",
1657 senders=senders,
1658 recipients=recipients,
1659 sw1="s5",
1660 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001661 setVlan=100 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001662
1663 if installResult:
1664 testResult = main.intentFunction.testPointIntent(
1665 main,
1666 intentId=installResult,
1667 name="VLAN2",
1668 senders=senders,
1669 recipients=recipients,
1670 badSenders=badSenders,
1671 badRecipients=badRecipients,
1672 sw1="s5",
1673 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001674 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001675 else:
1676 main.CLIs[ 0 ].removeAllIntents( purge=True )
1677
1678 utilities.assert_equals( expect=main.TRUE,
1679 actual=testResult,
1680 onpass=main.assertReturnString,
1681 onfail=main.assertReturnString )
1682
alison52b25892016-09-19 10:53:48 -07001683 # Does not support Single point to multi point encapsulation
1684 # main.step( "ENCAPSULATION: Install and test single point to multi point intents" )
1685 # main.assertReturnString = "Assertion results for VLAN Encapsulation single to multi point intent\n"
1686 # senders = [
1687 # { "name":"h8", "device":"of:0000000000000005/8" }
1688 # ]
1689 # recipients = [
1690 # { "name":"h16", "device":"of:0000000000000006/8" },
1691 # { "name":"h24", "device":"of:0000000000000007/8" }
1692 # ]
1693 # badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1694 # badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1695 # testResult = main.FALSE
1696 # installResult = main.intentFunction.installSingleToMultiIntent(
1697 # main,
1698 # name="ENCAPSULATION",
1699 # senders=senders,
1700 # recipients=recipients,
1701 # sw1="s5",
1702 # sw2="s2",
1703 # encap="VLAN" )
1704 #
1705 # if installResult:
1706 # testResult = main.intentFunction.testPointIntent(
1707 # main,
1708 # intentId=installResult,
1709 # name="ENCAPSULATION",
1710 # senders=senders,
1711 # recipients=recipients,
1712 # badSenders=badSenders,
1713 # badRecipients=badRecipients,
1714 # sw1="s5",
1715 # sw2="s2",
1716 # expectedLink=18 )
1717 # else:
1718 # main.CLIs[ 0 ].removeAllIntents( purge=True )
1719 #
1720 # utilities.assert_equals( expect=main.TRUE,
1721 # actual=testResult,
1722 # onpass=main.assertReturnString,
1723 # onfail=main.assertReturnString )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001724
kelvin-onlab016dce22015-08-10 09:54:11 -07001725 main.intentFunction.report( main )
1726
kelvin-onlabb769f562015-07-15 17:05:10 -07001727 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001728 """
1729 Add multi point to single point intents
1730 - Get device ids
1731 - Add multi point to single point intents
1732 - Check intents
1733 - Verify flows
1734 - Ping hosts
1735 - Reroute
1736 - Link down
1737 - Verify flows
1738 - Check topology
1739 - Ping hosts
1740 - Link up
1741 - Verify flows
1742 - Check topology
1743 - Ping hosts
1744 - Remove intents
1745 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001746 if main.initialized == main.FALSE:
1747 main.log.error( "Test components did not start correctly, skipping further tests" )
1748 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001749 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001750 try:
1751 assert main.CLIs
1752 except AssertionError:
1753 main.log.error( "There is no main.CLIs, skipping test cases" )
1754 main.initialized = main.FALSE
1755 main.skipCase()
1756 try:
1757 assert main.Mininet1
1758 except AssertionError:
1759 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1760 main.initialized = main.FALSE
1761 main.skipCase()
1762 try:
1763 assert main.numSwitch
1764 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001765 main.log.error( "Place the total number of switch topology in "+\
1766 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001767 main.initialized = main.FALSE
1768 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001769
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001770 main.testName = "Multi To Single Point Intents"
1771 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001772 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001773 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001774 " multi point intents using " +\
1775 str( main.numCtrls ) + " node(s) cluster;\n" +\
1776 "Different type of hosts will be tested in " +\
1777 "each step such as IPV4, Dual stack, VLAN etc" +\
1778 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001779 " OVS running in Mininet and compile intents" +\
1780 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001781
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001782 main.step( "NOOPTION: Add multi point to single point intents" )
1783 main.assertReturnString = "Assertion results for NOOPTION multi to single point intent\n"
1784 senders = [
1785 { "name":"h16", "device":"of:0000000000000006/8" },
1786 { "name":"h24", "device":"of:0000000000000007/8" }
1787 ]
1788 recipients = [
1789 { "name":"h8", "device":"of:0000000000000005/8" }
1790 ]
1791 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1792 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1793 testResult = main.FALSE
1794 installResult = main.intentFunction.installMultiToSingleIntent(
1795 main,
1796 name="NOOPTION",
1797 senders=senders,
1798 recipients=recipients,
1799 sw1="s5",
Jeremye0cb5eb2016-01-27 17:39:09 -08001800 sw2="s2" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001801
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001802 if installResult:
1803 testResult = main.intentFunction.testPointIntent(
1804 main,
1805 intentId=installResult,
1806 name="NOOPTION",
1807 senders=senders,
1808 recipients=recipients,
1809 badSenders=badSenders,
1810 badRecipients=badRecipients,
1811 sw1="s5",
1812 sw2="s2",
Jeremye0cb5eb2016-01-27 17:39:09 -08001813 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001814 else:
1815 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001816
1817 utilities.assert_equals( expect=main.TRUE,
1818 actual=testResult,
1819 onpass=main.assertReturnString,
1820 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001821
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001822 main.step( "IPV4: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001823 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 -08001824 senders = [
1825 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1826 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1827 ]
1828 recipients = [
1829 { "name":"h8", "device":"of:0000000000000005/8", "mac":"00:00:00:00:00:08" }
1830 ]
1831 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1832 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1833 testResult = main.FALSE
1834 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001835 main,
1836 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001837 senders=senders,
1838 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001839 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001840 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001841 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001842
1843 if installResult:
1844 testResult = main.intentFunction.testPointIntent(
1845 main,
1846 intentId=installResult,
1847 name="IPV4",
1848 senders=senders,
1849 recipients=recipients,
1850 badSenders=badSenders,
1851 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001852 sw1="s5",
1853 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001854 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001855 else:
1856 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001857
1858 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001859 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001860 onpass=main.assertReturnString,
1861 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001862
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001863 main.step( "IPV4_2: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001864 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 -08001865 senders = [
1866 { "name":"h16", "device":"of:0000000000000006/8" },
1867 { "name":"h24", "device":"of:0000000000000007/8" }
1868 ]
1869 recipients = [
1870 { "name":"h8", "device":"of:0000000000000005/8" }
1871 ]
1872 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1873 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1874 testResult = main.FALSE
1875 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001876 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001877 name="IPV4_2",
1878 senders=senders,
1879 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001880 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001881 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001882 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001883
1884 if installResult:
1885 testResult = main.intentFunction.testPointIntent(
1886 main,
1887 intentId=installResult,
1888 name="IPV4_2",
1889 senders=senders,
1890 recipients=recipients,
1891 badSenders=badSenders,
1892 badRecipients=badRecipients,
1893 sw1="s5",
1894 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001895 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001896 else:
1897 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001898
1899 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001900 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001901 onpass=main.assertReturnString,
1902 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001903
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001904 main.step( "VLAN: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001905 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 -08001906 senders = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001907 { "name":"h13", "device":"of:0000000000000006/5", "vlan":"200" },
1908 { "name":"h21", "device":"of:0000000000000007/5", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001909 ]
1910 recipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001911 { "name":"h5", "device":"of:0000000000000005/5", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001912 ]
1913 badSenders=[ { "name":"h12" } ] # Senders that are not in the intent
1914 badRecipients=[ { "name":"h20" } ] # Recipients that are not in the intent
1915 testResult = main.FALSE
1916 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001917 main,
1918 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001919 senders=senders,
1920 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001921 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001922 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001923
1924 if installResult:
1925 testResult = main.intentFunction.testPointIntent(
1926 main,
1927 intentId=installResult,
1928 name="VLAN",
1929 senders=senders,
1930 recipients=recipients,
1931 badSenders=badSenders,
1932 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001933 sw1="s5",
1934 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001935 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001936 else:
1937 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001938
1939 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001940 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001941 onpass=main.assertReturnString,
1942 onfail=main.assertReturnString )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001943
Jeremy Songsterff553672016-05-12 17:06:23 -07001944 # Right now this fails because of this bug: https://jira.onosproject.org/browse/ONOS-4383
1945 main.step( "VLAN: Add multi point to single point intents" )
1946 main.assertReturnString = "Assertion results for multi to single point intent with VLAN ID treatment\n"
1947 senders = [
1948 { "name":"h13", "device":"of:0000000000000006/5", "vlan":"200" },
1949 { "name":"h21", "device":"of:0000000000000007/5", "vlan":"200" }
1950 ]
1951 recipients = [
1952 { "name":"h4", "vlan":"100" }
1953 ]
1954 badSenders=[ { "name":"h12" } ] # Senders that are not in the intent
1955 badRecipients=[ { "name":"h20" } ] # Recipients that are not in the intent
1956 testResult = main.FALSE
Jeremy Songsterff553672016-05-12 17:06:23 -07001957 installResult = main.intentFunction.installMultiToSingleIntent(
1958 main,
1959 name="VLAN2",
1960 senders=senders,
1961 recipients=recipients,
1962 sw1="s5",
1963 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001964 setVlan=100 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001965
1966 if installResult:
1967 testResult = main.intentFunction.testPointIntent(
1968 main,
1969 intentId=installResult,
1970 name="VLAN2",
1971 senders=senders,
1972 recipients=recipients,
1973 badSenders=badSenders,
1974 badRecipients=badRecipients,
1975 sw1="s5",
1976 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001977 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001978 else:
1979 main.CLIs[ 0 ].removeAllIntents( purge=True )
1980
1981 utilities.assert_equals( expect=main.TRUE,
1982 actual=testResult,
1983 onpass=main.assertReturnString,
1984 onfail=main.assertReturnString )
1985
Jeremy Songsterc032f162016-08-04 17:14:49 -07001986 main.step( "ENCAPSULATION: Add multi point to single point intents" )
1987 main.assertReturnString = "Assertion results for VLAN Encapsulation multi to single point intent\n"
1988 senders = [
1989 { "name":"h16", "device":"of:0000000000000006/8" },
1990 { "name":"h24", "device":"of:0000000000000007/8" }
1991 ]
1992 recipients = [
1993 { "name":"h8", "device":"of:0000000000000005/8" }
1994 ]
1995 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1996 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1997 testResult = main.FALSE
Jeremy Songsterc032f162016-08-04 17:14:49 -07001998 installResult = main.intentFunction.installMultiToSingleIntent(
1999 main,
2000 name="ENCAPSULATION",
2001 senders=senders,
2002 recipients=recipients,
2003 sw1="s5",
2004 sw2="s2",
2005 encap="VLAN" )
2006
2007 if installResult:
2008 testResult = main.intentFunction.testPointIntent(
2009 main,
2010 intentId=installResult,
2011 name="ENCAPSULATION",
2012 senders=senders,
2013 recipients=recipients,
2014 badSenders=badSenders,
2015 badRecipients=badRecipients,
2016 sw1="s5",
2017 sw2="s2",
2018 expectedLink=18 )
2019 else:
2020 main.CLIs[ 0 ].removeAllIntents( purge=True )
2021
2022 utilities.assert_equals( expect=main.TRUE,
2023 actual=testResult,
2024 onpass=main.assertReturnString,
2025 onfail=main.assertReturnString )
2026
alison52b25892016-09-19 10:53:48 -07002027 # Testing MPLS would need to update kernel version (Right now is 3.16)
2028 # main.step( "ENCAPSULATION: Add multi point to single point intents" )
2029 # main.assertReturnString = "Assertion results for MPLS Encapsulation multi to single point intent\n"
2030 # senders = [
2031 # { "name": "h16", "device": "of:0000000000000006/8" },
2032 # { "name": "h24", "device": "of:0000000000000007/8" }
2033 # ]
2034 # recipients = [
2035 # { "name": "h8", "device": "of:0000000000000005/8" }
2036 # ]
2037 # badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
2038 # badRecipients = [ {"name": "h9" } ] # Recipients that are not in the intent
2039 # testResult = main.FALSE
2040 # installResult = main.intentFunction.installMultiToSingleIntent(
2041 # main,
2042 # name="ENCAPSULATION",
2043 # senders=senders,
2044 # recipients=recipients,
2045 # sw1="s5",
2046 # sw2="s2",
2047 # encap="MPLS" )
2048 #
2049 # if installResult:
2050 # testResult = main.intentFunction.testPointIntent(
2051 # main,
2052 # intentId=installResult,
2053 # name="ENCAPSULATION",
2054 # senders=senders,
2055 # recipients=recipients,
2056 # badSenders=badSenders,
2057 # badRecipients=badRecipients,
2058 # sw1="s5",
2059 # sw2="s2",
2060 # expectedLink=18 )
2061 # else:
2062 # main.CLIs[ 0 ].removeAllIntents( purge=True )
2063 #
2064 # utilities.assert_equals( expect=main.TRUE,
2065 # actual=testResult,
2066 # onpass=main.assertReturnString,
2067 # onfail=main.assertReturnString )
2068
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002069 main.intentFunction.report( main )
2070
acsmars1ff5e052015-07-23 11:27:48 -07002071 def CASE5000( self, main ):
2072 """
acsmars5d8cc862015-09-25 09:44:50 -07002073 Tests Host Mobility
2074 Modifies the topology location of h1
acsmars1ff5e052015-07-23 11:27:48 -07002075 """
Jeremyd9e4eb12016-04-13 12:09:06 -07002076 if main.initialized == main.FALSE:
2077 main.log.error( "Test components did not start correctly, skipping further tests" )
2078 main.skipCase()
acsmars1ff5e052015-07-23 11:27:48 -07002079 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07002080 try:
2081 assert main.CLIs
2082 except AssertionError:
2083 main.log.error( "There is no main.CLIs, skipping test cases" )
2084 main.initialized = main.FALSE
2085 main.skipCase()
2086 try:
2087 assert main.Mininet1
2088 except AssertionError:
2089 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
2090 main.initialized = main.FALSE
2091 main.skipCase()
2092 try:
2093 assert main.numSwitch
2094 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002095 main.log.error( "Place the total number of switch topology in "+\
2096 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07002097 main.initialized = main.FALSE
2098 main.skipCase()
alison52b25892016-09-19 10:53:48 -07002099 main.case( "Test host mobility with host intents " + " - " + str( main.numCtrls ) +
2100 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002101 main.step( "Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07002102
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002103 main.log.info( "Moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07002104 main.Mininet1.moveHost( "h1","s5","s6" )
2105
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002106 # Send discovery ping from moved host
2107 # Moving the host brings down the default interfaces and creates a new one.
2108 # Scapy is restarted on this host to detect the new interface
2109 main.h1.stopScapy()
2110 main.h1.startScapy()
2111
2112 # Discover new host location in ONOS and populate host data.
2113 # Host 1 IP and MAC should be unchanged
2114 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
2115 main.intentFunction.populateHostData( main )
2116
acsmars1ff5e052015-07-23 11:27:48 -07002117 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
2118
2119 utilities.assert_equals( expect="of:0000000000000006",
2120 actual=h1PostMove,
2121 onpass="Mobility: Successfully moved h1 to s6",
acsmars5d8cc862015-09-25 09:44:50 -07002122 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07002123 " to single point intents" +
2124 " with IPV4 type and MAC addresses" +
2125 " in the same VLAN" )
2126
2127 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07002128 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002129 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
2130 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
Jeremy42df2e72016-02-23 16:37:46 -08002131 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002132 installResult = main.intentFunction.installHostIntent( main,
alison52b25892016-09-19 10:53:48 -07002133 name="IPV4 Mobility IPV4",
2134 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002135 host1=host1,
Jeremye0cb5eb2016-01-27 17:39:09 -08002136 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -08002137 if installResult:
2138 testResult = main.intentFunction.testHostIntent( main,
alison52b25892016-09-19 10:53:48 -07002139 name="Host Mobility IPV4",
Jeremy2f190ca2016-01-29 15:23:57 -08002140 intentId = installResult,
alison52b25892016-09-19 10:53:48 -07002141 onosNode=0,
Jeremy2f190ca2016-01-29 15:23:57 -08002142 host1=host1,
2143 host2=host2,
2144 sw1="s6",
2145 sw2="s2",
2146 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08002147 else:
2148 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07002149
2150 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002151 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07002152 onpass=main.assertReturnString,
2153 onfail=main.assertReturnString )
kelvin-onlab016dce22015-08-10 09:54:11 -07002154
2155 main.intentFunction.report( main )
Jeremye0cb5eb2016-01-27 17:39:09 -08002156
2157 def CASE6000( self, main ):
2158 """
2159 Tests Multi to Single Point Intent and Single to Multi Point Intent End Point Failure
2160 """
Jeremy Songster9385d412016-06-02 17:57:36 -07002161 # At some later point discussion on this behavior in MPSP and SPMP intents
2162 # will be reoppened and this test case may need to be updated to reflect
2163 # the outcomes of that discussion
Jeremyd9e4eb12016-04-13 12:09:06 -07002164 if main.initialized == main.FALSE:
2165 main.log.error( "Test components did not start correctly, skipping further tests" )
2166 main.skipCase()
Jeremye0cb5eb2016-01-27 17:39:09 -08002167 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07002168 try:
2169 assert main.CLIs
2170 except AssertionError:
2171 main.log.error( "There is no main.CLIs, skipping test cases" )
2172 main.initialized = main.FALSE
2173 main.skipCase()
2174 try:
2175 assert main.Mininet1
2176 except AssertionError:
2177 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
2178 main.initialized = main.FALSE
2179 main.skipCase()
2180 try:
2181 assert main.numSwitch
2182 except AssertionError:
alison52b25892016-09-19 10:53:48 -07002183 main.log.error( "Place the total number of switch topology in " + main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07002184 main.initialized = main.FALSE
2185 main.skipCase()
alison52b25892016-09-19 10:53:48 -07002186 main.case( "Test Multi to Single End Point Failure" + " - " + str( main.numCtrls ) +
2187 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jeremy Songster9385d412016-06-02 17:57:36 -07002188 main.step( "Installing Multi to Single Point intents with no options set" )
2189 main.assertReturnString = "Assertion results for IPV4 multi to single " +\
2190 "point intent end point failure with no options set\n"
Jeremye0cb5eb2016-01-27 17:39:09 -08002191 senders = [
2192 { "name":"h16", "device":"of:0000000000000006/8" },
2193 { "name":"h24", "device":"of:0000000000000007/8" }
2194 ]
2195 recipients = [
2196 { "name":"h8", "device":"of:0000000000000005/8" }
2197 ]
2198 isolatedSenders = [
alison52b25892016-09-19 10:53:48 -07002199 { "name":"h24" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002200 ]
2201 isolatedRecipients = []
2202 testResult = main.FALSE
2203 installResult = main.intentFunction.installMultiToSingleIntent(
2204 main,
2205 name="NOOPTION",
2206 senders=senders,
2207 recipients=recipients,
2208 sw1="s5",
2209 sw2="s2" )
2210
2211 if installResult:
2212 testResult = main.intentFunction.testEndPointFail(
2213 main,
2214 intentId=installResult,
2215 name="NOOPTION",
2216 senders=senders,
2217 recipients=recipients,
2218 isolatedSenders=isolatedSenders,
2219 isolatedRecipients=isolatedRecipients,
2220 sw1="s6",
2221 sw2="s2",
2222 sw3="s4",
2223 sw4="s1",
2224 sw5="s3",
2225 expectedLink1=16,
2226 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002227 else:
2228 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002229
2230 utilities.assert_equals( expect=main.TRUE,
2231 actual=testResult,
2232 onpass=main.assertReturnString,
2233 onfail=main.assertReturnString )
2234
Jeremy Songster9385d412016-06-02 17:57:36 -07002235 main.step( "Installing Multi to Single Point intents with partial failure allowed" )
2236
2237 main.assertReturnString = "Assertion results for IPV4 multi to single " +\
2238 "with partial failures allowed\n"
2239 senders = [
2240 { "name":"h16", "device":"of:0000000000000006/8" },
2241 { "name":"h24", "device":"of:0000000000000007/8" }
2242 ]
2243 recipients = [
2244 { "name":"h8", "device":"of:0000000000000005/8" }
2245 ]
2246 isolatedSenders = [
alison52b25892016-09-19 10:53:48 -07002247 { "name":"h24" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002248 ]
2249 isolatedRecipients = []
2250 testResult = main.FALSE
Jeremy Songster9385d412016-06-02 17:57:36 -07002251 installResult = main.intentFunction.installMultiToSingleIntent(
2252 main,
2253 name="NOOPTION",
2254 senders=senders,
2255 recipients=recipients,
2256 sw1="s5",
2257 sw2="s2",
2258 partial=True )
2259
2260 if installResult:
2261 testResult = main.intentFunction.testEndPointFail(
2262 main,
2263 intentId=installResult,
2264 name="NOOPTION",
2265 senders=senders,
2266 recipients=recipients,
2267 isolatedSenders=isolatedSenders,
2268 isolatedRecipients=isolatedRecipients,
2269 sw1="s6",
2270 sw2="s2",
2271 sw3="s4",
2272 sw4="s1",
2273 sw5="s3",
2274 expectedLink1=16,
2275 expectedLink2=14,
2276 partial=True )
2277 else:
2278 main.CLIs[ 0 ].removeAllIntents( purge=True )
2279
2280 utilities.assert_equals( expect=main.TRUE,
2281 actual=testResult,
2282 onpass=main.assertReturnString,
2283 onfail=main.assertReturnString )
2284
Jeremye0cb5eb2016-01-27 17:39:09 -08002285 main.step( "NOOPTION: Install and test single point to multi point intents" )
Jeremy Songster9385d412016-06-02 17:57:36 -07002286 main.assertReturnString = "Assertion results for IPV4 single to multi " +\
2287 "point intent with no options set\n"
Jeremye0cb5eb2016-01-27 17:39:09 -08002288 senders = [
2289 { "name":"h8", "device":"of:0000000000000005/8" }
2290 ]
2291 recipients = [
2292 { "name":"h16", "device":"of:0000000000000006/8" },
2293 { "name":"h24", "device":"of:0000000000000007/8" }
2294 ]
Jeremy Songster9385d412016-06-02 17:57:36 -07002295 isolatedSenders = []
2296 isolatedRecipients = [
alison52b25892016-09-19 10:53:48 -07002297 { "name":"h24" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002298 ]
2299 testResult = main.FALSE
2300 installResult = main.intentFunction.installSingleToMultiIntent(
2301 main,
2302 name="NOOPTION",
2303 senders=senders,
2304 recipients=recipients,
2305 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002306 sw2="s2" )
Jeremye0cb5eb2016-01-27 17:39:09 -08002307
2308 if installResult:
2309 testResult = main.intentFunction.testEndPointFail(
2310 main,
2311 intentId=installResult,
2312 name="NOOPTION",
2313 senders=senders,
2314 recipients=recipients,
2315 isolatedSenders=isolatedSenders,
2316 isolatedRecipients=isolatedRecipients,
2317 sw1="s6",
2318 sw2="s2",
2319 sw3="s4",
2320 sw4="s1",
2321 sw5="s3",
2322 expectedLink1=16,
2323 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002324 else:
2325 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002326
2327 utilities.assert_equals( expect=main.TRUE,
2328 actual=testResult,
2329 onpass=main.assertReturnString,
2330 onfail=main.assertReturnString )
Jeremy Songster9385d412016-06-02 17:57:36 -07002331 # Right now this functionality doesn't work properly in SPMP intents
2332 main.step( "NOOPTION: Install and test single point to multi point " +\
2333 "intents with partial failures allowed" )
2334 main.assertReturnString = "Assertion results for IPV4 single to multi " +\
2335 "point intent with partial failures allowed\n"
2336 senders = [
2337 { "name":"h8", "device":"of:0000000000000005/8" }
2338 ]
2339 recipients = [
2340 { "name":"h16", "device":"of:0000000000000006/8" },
2341 { "name":"h24", "device":"of:0000000000000007/8" }
2342 ]
2343 isolatedSenders = []
2344 isolatedRecipients = [
alison52b25892016-09-19 10:53:48 -07002345 { "name":"h24" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002346 ]
2347 testResult = main.FALSE
Jeremy Songster9385d412016-06-02 17:57:36 -07002348 installResult = main.intentFunction.installSingleToMultiIntent(
2349 main,
2350 name="NOOPTION",
2351 senders=senders,
2352 recipients=recipients,
2353 sw1="s5",
2354 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002355 partial=True )
Jeremy Songster9385d412016-06-02 17:57:36 -07002356
2357 if installResult:
2358 testResult = main.intentFunction.testEndPointFail(
2359 main,
2360 intentId=installResult,
2361 name="NOOPTION",
2362 senders=senders,
2363 recipients=recipients,
2364 isolatedSenders=isolatedSenders,
2365 isolatedRecipients=isolatedRecipients,
2366 sw1="s6",
2367 sw2="s2",
2368 sw3="s4",
2369 sw4="s1",
2370 sw5="s3",
2371 expectedLink1=16,
2372 expectedLink2=14,
2373 partial=True )
2374 else:
2375 main.CLIs[ 0 ].removeAllIntents( purge=True )
2376
2377 utilities.assert_equals( expect=main.TRUE,
2378 actual=testResult,
2379 onpass=main.assertReturnString,
2380 onfail=main.assertReturnString )
Jeremye0cb5eb2016-01-27 17:39:09 -08002381
Jeremy2f190ca2016-01-29 15:23:57 -08002382 main.intentFunction.report( main )