blob: 137145306a0281a61f5ee3cf8b98114a9cf03ac7 [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
Chiyu Chengef109502016-11-21 15:51:38 -0800232 main.step( "Set up ONOS secure SSH" )
233 secureSshResult = main.TRUE
234 for i in range( int( main.numCtrls ) ):
235 secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
236 utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
237 onpass="Test step PASS",
238 onfail="Test step FAIL" )
239
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700240 main.step( "Start ONOS cli" )
241 cliResult = main.TRUE
242 for i in range( main.numCtrls ):
243 cliResult = cliResult and \
244 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
245 stepResult = cliResult
246 utilities.assert_equals( expect=main.TRUE,
247 actual=stepResult,
248 onpass="Successfully start ONOS cli",
249 onfail="Failed to start ONOS cli" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700250 if not stepResult:
251 main.initialized = main.FALSE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700252
253 # Remove the first element in main.scale list
254 main.scale.remove( main.scale[ 0 ] )
255
kelvin-onlab016dce22015-08-10 09:54:11 -0700256 main.intentFunction.report( main )
257
Jon Halla3e02432015-07-24 15:55:42 -0700258 def CASE8( self, main ):
259 """
acsmars59a4c552015-09-10 18:11:19 -0700260 Compare ONOS Topology to Mininet Topology
Jon Halla3e02432015-07-24 15:55:42 -0700261 """
262 import json
263
264 main.case( "Compare ONOS Topology view to Mininet topology" )
265 main.caseExplanation = "Compare topology elements between Mininet" +\
266 " and ONOS"
267
acsmars59a4c552015-09-10 18:11:19 -0700268 main.log.info( "Gathering topology information from Mininet" )
269 devicesResults = main.FALSE # Overall Boolean for device correctness
270 linksResults = main.FALSE # Overall Boolean for link correctness
271 hostsResults = main.FALSE # Overall Boolean for host correctness
272 deviceFails = [] # Nodes where devices are incorrect
273 linkFails = [] # Nodes where links are incorrect
274 hostFails = [] # Nodes where hosts are incorrect
275 attempts = main.checkTopoAttempts # Remaining Attempts
Jon Halla3e02432015-07-24 15:55:42 -0700276
277 mnSwitches = main.Mininet1.getSwitches()
278 mnLinks = main.Mininet1.getLinks()
279 mnHosts = main.Mininet1.getHosts()
280
Jon Hall70b2ff42015-11-17 15:49:44 -0800281 main.step( "Comparing Mininet topology to ONOS topology" )
Jon Halla3e02432015-07-24 15:55:42 -0700282
acsmars59a4c552015-09-10 18:11:19 -0700283 while ( attempts >= 0 ) and\
284 ( not devicesResults or not linksResults or not hostsResults ):
285 time.sleep( 2 )
286 if not devicesResults:
287 devices = main.topo.getAllDevices( main )
288 ports = main.topo.getAllPorts( main )
289 devicesResults = main.TRUE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800290 deviceFails = [] # Reset for each failed attempt
acsmars59a4c552015-09-10 18:11:19 -0700291 if not linksResults:
292 links = main.topo.getAllLinks( main )
293 linksResults = main.TRUE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800294 linkFails = [] # Reset for each failed attempt
acsmars59a4c552015-09-10 18:11:19 -0700295 if not hostsResults:
296 hosts = main.topo.getAllHosts( main )
297 hostsResults = main.TRUE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800298 hostFails = [] # Reset for each failed attempt
Jon Halla3e02432015-07-24 15:55:42 -0700299
acsmars59a4c552015-09-10 18:11:19 -0700300 # Check for matching topology on each node
301 for controller in range( main.numCtrls ):
302 controllerStr = str( controller + 1 ) # ONOS node number
303 # Compare Devices
304 if devices[ controller ] and ports[ controller ] and\
305 "Error" not in devices[ controller ] and\
306 "Error" not in ports[ controller ]:
Jon Halla3e02432015-07-24 15:55:42 -0700307
acsmars2ec91d62015-09-16 11:15:48 -0700308 try:
309 deviceData = json.loads( devices[ controller ] )
310 portData = json.loads( ports[ controller ] )
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700311 except( TypeError, ValueError ):
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800312 main.log.error( "Could not load json: {0} or {1}".format( str( devices[ controller ] ), str( ports[ controller ] ) ) )
acsmars2ec91d62015-09-16 11:15:48 -0700313 currentDevicesResult = main.FALSE
314 else:
315 currentDevicesResult = main.Mininet1.compareSwitches(
316 mnSwitches,deviceData,portData )
acsmars59a4c552015-09-10 18:11:19 -0700317 else:
318 currentDevicesResult = main.FALSE
319 if not currentDevicesResult:
320 deviceFails.append( controllerStr )
321 devicesResults = devicesResults and currentDevicesResult
322 # Compare Links
323 if links[ controller ] and "Error" not in links[ controller ]:
acsmars2ec91d62015-09-16 11:15:48 -0700324 try:
325 linkData = json.loads( links[ controller ] )
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700326 except( TypeError, ValueError ):
327 main.log.error( "Could not load json:" + str( links[ controller ] ) )
acsmars2ec91d62015-09-16 11:15:48 -0700328 currentLinksResult = main.FALSE
329 else:
330 currentLinksResult = main.Mininet1.compareLinks(
331 mnSwitches, mnLinks,linkData )
acsmars59a4c552015-09-10 18:11:19 -0700332 else:
333 currentLinksResult = main.FALSE
334 if not currentLinksResult:
335 linkFails.append( controllerStr )
336 linksResults = linksResults and currentLinksResult
337 # Compare Hosts
acsmars2ec91d62015-09-16 11:15:48 -0700338 if hosts[ controller ] and "Error" not in hosts[ controller ]:
339 try:
340 hostData = json.loads( hosts[ controller ] )
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700341 except( TypeError, ValueError ):
342 main.log.error( "Could not load json:" + str( hosts[ controller ] ) )
acsmars2ec91d62015-09-16 11:15:48 -0700343 currentHostsResult = main.FALSE
344 else:
345 currentHostsResult = main.Mininet1.compareHosts(
346 mnHosts,hostData )
acsmars59a4c552015-09-10 18:11:19 -0700347 else:
348 currentHostsResult = main.FALSE
349 if not currentHostsResult:
350 hostFails.append( controllerStr )
351 hostsResults = hostsResults and currentHostsResult
352 # Decrement Attempts Remaining
353 attempts -= 1
354
355
356 utilities.assert_equals( expect=[],
357 actual=deviceFails,
358 onpass="ONOS correctly discovered all devices",
359 onfail="ONOS incorrectly discovered devices on nodes: " +
360 str( deviceFails ) )
361 utilities.assert_equals( expect=[],
362 actual=linkFails,
363 onpass="ONOS correctly discovered all links",
364 onfail="ONOS incorrectly discovered links on nodes: " +
365 str( linkFails ) )
366 utilities.assert_equals( expect=[],
367 actual=hostFails,
368 onpass="ONOS correctly discovered all hosts",
369 onfail="ONOS incorrectly discovered hosts on nodes: " +
370 str( hostFails ) )
Jon Hall46d48252015-08-03 11:41:16 -0700371 topoResults = hostsResults and linksResults and devicesResults
372 utilities.assert_equals( expect=main.TRUE,
373 actual=topoResults,
374 onpass="ONOS correctly discovered the topology",
375 onfail="ONOS incorrectly discovered the topology" )
Jon Halla3e02432015-07-24 15:55:42 -0700376
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700377 def CASE10( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700378 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700379 Start Mininet topology with OF 1.0 switches
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700380 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700381 if main.initialized == main.FALSE:
382 main.log.error( "Test components did not start correctly, skipping further tests" )
383 main.skipCase()
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700384 main.OFProtocol = "1.0"
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700385 main.log.report( "Start Mininet topology with OF 1.0 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700386 main.case( "Start Mininet topology with OF 1.0 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700387 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700388 "switches to test intents, exits out if " +\
389 "topology did not start correctly"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700390
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700391 main.step( "Starting Mininet topology with OF 1.0 switches" )
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700392 args = "--switch ovs,protocols=OpenFlow10"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700393 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700394 main.topology,
395 args=args )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700396 stepResult = topoResult
397 utilities.assert_equals( expect=main.TRUE,
398 actual=stepResult,
399 onpass="Successfully loaded topology",
400 onfail="Failed to load topology" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700401
402 # Set flag to test cases if topology did not load properly
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700403 if not topoResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700404 main.initialized = main.FALSE
405 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700406
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700407 def CASE11( self, main ):
408 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700409 Start Mininet topology with OF 1.3 switches
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700410 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700411 if main.initialized == main.FALSE:
412 main.log.error( "Test components did not start correctly, skipping further tests" )
413 main.skipCase()
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700414 main.OFProtocol = "1.3"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700415 main.log.report( "Start Mininet topology with OF 1.3 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700416 main.case( "Start Mininet topology with OF 1.3 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700417 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700418 "switches to test intents, exits out if " +\
419 "topology did not start correctly"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700420
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700421 main.step( "Starting Mininet topology with OF 1.3 switches" )
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700422 args = "--switch ovs,protocols=OpenFlow13"
423 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
424 main.topology,
425 args=args )
426 stepResult = topoResult
427 utilities.assert_equals( expect=main.TRUE,
428 actual=stepResult,
429 onpass="Successfully loaded topology",
430 onfail="Failed to load topology" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700431 # Set flag to skip test cases if topology did not load properly
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700432 if not topoResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700433 main.initialized = main.FALSE
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700434
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700435 def CASE12( self, main ):
436 """
437 Assign mastership to controllers
438 """
439 import re
440
Jeremyd9e4eb12016-04-13 12:09:06 -0700441 if main.initialized == main.FALSE:
442 main.log.error( "Test components did not start correctly, skipping further tests" )
443 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700444 main.case( "Assign switches to controllers" )
445 main.step( "Assigning switches to controllers" )
Jon Hall783bbf92015-07-23 14:33:19 -0700446 main.caseExplanation = "Assign OF " + main.OFProtocol +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700447 " switches to ONOS nodes"
448
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700449 switchList = []
450
451 # Creates a list switch name, use getSwitch() function later...
452 for i in range( 1, ( main.numSwitch + 1 ) ):
453 switchList.append( 's' + str( i ) )
454
455 tempONOSip = []
456 for i in range( main.numCtrls ):
457 tempONOSip.append( main.ONOSip[ i ] )
458
459 assignResult = main.Mininet1.assignSwController( sw=switchList,
460 ip=tempONOSip,
alison52b25892016-09-19 10:53:48 -0700461 port="6653" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700462 if not assignResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700463 main.log.error( "Problem assigning mastership of switches" )
464 main.initialized = main.FALSE
465 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700466
467 for i in range( 1, ( main.numSwitch + 1 ) ):
468 response = main.Mininet1.getSwController( "s" + str( i ) )
469 print( "Response is " + str( response ) )
470 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
471 assignResult = assignResult and main.TRUE
472 else:
473 assignResult = main.FALSE
474 stepResult = assignResult
475 utilities.assert_equals( expect=main.TRUE,
476 actual=stepResult,
477 onpass="Successfully assigned switches" +
478 "to controller",
479 onfail="Failed to assign switches to " +
480 "controller" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700481 if not stepResult:
482 main.initialized = main.FALSE
acsmars5d8cc862015-09-25 09:44:50 -0700483
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800484 def CASE13( self,main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700485 """
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800486 Create Scapy components
487 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700488 if main.initialized == main.FALSE:
489 main.log.error( "Test components did not start correctly, skipping further tests" )
490 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800491 main.case( "Create scapy components" )
492 main.step( "Create scapy components" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800493 scapyResult = main.TRUE
494 for hostName in main.scapyHostNames:
495 main.Scapy1.createHostComponent( hostName )
496 main.scapyHosts.append( getattr( main, hostName ) )
497
498 main.step( "Start scapy components" )
499 for host in main.scapyHosts:
500 host.startHostCli()
501 host.startScapy()
502 host.updateSelf()
503 main.log.debug( host.name )
504 main.log.debug( host.hostIp )
505 main.log.debug( host.hostMac )
506
507
508 utilities.assert_equals( expect=main.TRUE,
509 actual=scapyResult,
510 onpass="Successfully created Scapy Components",
511 onfail="Failed to discover Scapy Components" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700512 if not scapyResult:
513 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800514
515 def CASE14( self, main ):
516 """
517 Discover all hosts with fwd and pingall and store its data in a dictionary
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700518 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700519 if main.initialized == main.FALSE:
520 main.log.error( "Test components did not start correctly, skipping further tests" )
521 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700522 main.case( "Discover all hosts" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800523 main.step( "Pingall hosts and confirm ONOS discovery" )
524 utilities.retry( f=main.intentFunction.fwdPingall, retValue=main.FALSE, args=[ main ] )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700525
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800526 utilities.retry( f=main.intentFunction.confirmHostDiscovery, retValue=main.FALSE,
527 args=[ main ], attempts=main.checkTopoAttempts, sleep=2 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700528 utilities.assert_equals( expect=main.TRUE,
529 actual=stepResult,
530 onpass="Successfully discovered hosts",
531 onfail="Failed to discover hosts" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700532 if not stepResult:
533 main.initialized = main.FALSE
534 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700535
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800536 main.step( "Populate hostsData" )
537 stepResult = main.intentFunction.populateHostData( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700538 utilities.assert_equals( expect=main.TRUE,
539 actual=stepResult,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800540 onpass="Successfully populated hostsData",
541 onfail="Failed to populate hostsData" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700542 if not stepResult:
543 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800544
545 def CASE15( self, main ):
546 """
547 Discover all hosts with scapy arp packets and store its data to a dictionary
548 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700549 if main.initialized == main.FALSE:
550 main.log.error( "Test components did not start correctly, skipping further tests" )
551 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800552 main.case( "Discover all hosts using scapy" )
553 main.step( "Send packets from each host to the first host and confirm onos discovery" )
554
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800555 if len( main.scapyHosts ) < 1:
556 main.log.error( "No scapy hosts have been created" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700557 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800558 main.skipCase()
559
560 # Send ARP packets from each scapy host component
561 main.intentFunction.sendDiscoveryArp( main, main.scapyHosts )
562
563 stepResult = utilities.retry( f=main.intentFunction.confirmHostDiscovery,
564 retValue=main.FALSE, args=[ main ],
565 attempts=main.checkTopoAttempts, sleep=2 )
566
567 utilities.assert_equals( expect=main.TRUE,
568 actual=stepResult,
569 onpass="ONOS correctly discovered all hosts",
570 onfail="ONOS incorrectly discovered hosts" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700571 if not stepResult:
572 main.initialized = main.FALSE
573 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800574
575 main.step( "Populate hostsData" )
576 stepResult = main.intentFunction.populateHostData( main )
577 utilities.assert_equals( expect=main.TRUE,
578 actual=stepResult,
579 onpass="Successfully populated hostsData",
580 onfail="Failed to populate hostsData" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700581 if not stepResult:
582 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800583
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800584 def CASE16( self, main ):
585 """
Jeremy42df2e72016-02-23 16:37:46 -0800586 Balance Masters
587 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700588 if main.initialized == main.FALSE:
589 main.log.error( "Test components did not start correctly, skipping further tests" )
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700590 main.stop()
Jeremyd9e4eb12016-04-13 12:09:06 -0700591 main.skipCase()
Jeremy42df2e72016-02-23 16:37:46 -0800592 main.case( "Balance mastership of switches" )
593 main.step( "Balancing mastership of switches" )
594
Jeremy42df2e72016-02-23 16:37:46 -0800595 balanceResult = utilities.retry( f=main.CLIs[ 0 ].balanceMasters, retValue=main.FALSE, args=[] )
596
597 utilities.assert_equals( expect=main.TRUE,
Jeremy6e9748f2016-03-25 15:03:39 -0700598 actual=balanceResult,
Jeremy42df2e72016-02-23 16:37:46 -0800599 onpass="Successfully balanced mastership of switches",
600 onfail="Failed to balance mastership of switches" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700601 if not balanceResult:
602 main.initialized = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800603
604 def CASE17( self, main ):
605 """
Jeremy6e9748f2016-03-25 15:03:39 -0700606 Use Flow Objectives
607 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700608 if main.initialized == main.FALSE:
609 main.log.error( "Test components did not start correctly, skipping further tests" )
610 main.skipCase()
Jeremy6e9748f2016-03-25 15:03:39 -0700611 main.case( "Enable intent compilation using Flow Objectives" )
612 main.step( "Enabling Flow Objectives" )
613
614 main.flowCompiler = "Flow Objectives"
615
616 cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator"
617
618 stepResult = main.CLIs[ 0 ].setCfg( component=cmd,
619 propName="useFlowObjectives", value="true" )
620
621 utilities.assert_equals( expect=main.TRUE,
622 actual=stepResult,
623 onpass="Successfully activated Flow Objectives",
624 onfail="Failed to activate Flow Objectives" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700625 if not balanceResult:
626 main.initialized = main.FALSE
Jeremy6e9748f2016-03-25 15:03:39 -0700627
628 def CASE18( self, main ):
629 """
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800630 Stop mininet and remove scapy host
631 """
632 main.log.report( "Stop Mininet and Scapy" )
633 main.case( "Stop Mininet and Scapy" )
634 main.caseExplanation = "Stopping the current mininet topology " +\
635 "to start up fresh"
636 main.step( "Stopping and Removing Scapy Host Components" )
637 scapyResult = main.TRUE
638 for host in main.scapyHosts:
639 scapyResult = scapyResult and host.stopScapy()
640 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
641
642 for host in main.scapyHosts:
643 scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
644 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
645
646 main.scapyHosts = []
647 main.scapyHostIPs = []
648
649 utilities.assert_equals( expect=main.TRUE,
650 actual=scapyResult,
651 onpass="Successfully stopped scapy and removed host components",
652 onfail="Failed to stop mininet and scapy" )
653
654 main.step( "Stopping Mininet Topology" )
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700655 mininetResult = main.Mininet1.stopNet()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800656
657 utilities.assert_equals( expect=main.TRUE,
658 actual=mininetResult,
659 onpass="Successfully stopped mininet and scapy",
660 onfail="Failed to stop mininet and scapy" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700661 # Exit if topology did not load properly
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800662 if not ( mininetResult and scapyResult ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700663 main.cleanup()
664 main.exit()
665
Jeremy Songster17147f22016-05-31 18:30:52 -0700666 def CASE19( self, main ):
667 """
668 Copy the karaf.log files after each testcase cycle
669 """
670 main.log.report( "Copy karaf logs" )
671 main.case( "Copy karaf logs" )
672 main.caseExplanation = "Copying the karaf logs to preserve them through" +\
673 "reinstalling ONOS"
674 main.step( "Copying karaf logs" )
Jeremy Songster31aad312016-06-13 16:32:11 -0700675 stepResult = main.TRUE
676 scpResult = main.TRUE
677 copyResult = main.TRUE
Jeremy Songstercc5414b2016-07-11 10:59:53 -0700678 for i in range( main.numCtrls ):
679 main.node = main.CLIs[ i ]
Jeremy Songster17147f22016-05-31 18:30:52 -0700680 ip = main.ONOSip[ i ]
681 main.node.ip_address = ip
Jeremy Songster31aad312016-06-13 16:32:11 -0700682 scpResult = scpResult and main.ONOSbench.scp( main.node ,
683 "/opt/onos/log/karaf.log",
684 "/tmp/karaf.log",
685 direction="from" )
686 copyResult = copyResult and main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
687 copyFileName=( "karaf.log.node{0}.cycle{1}".format( str( i + 1 ), str( main.cycle ) ) ) )
688 if scpResult and copyResult:
689 stepResult = main.TRUE and stepResult
690 else:
691 stepResult = main.FALSE and stepResult
Jeremy Songster31aad312016-06-13 16:32:11 -0700692 utilities.assert_equals( expect=main.TRUE,
693 actual=stepResult,
694 onpass="Successfully copied remote ONOS logs",
695 onfail="Failed to copy remote ONOS logs" )
Jeremy Songster17147f22016-05-31 18:30:52 -0700696
kelvin-onlabb769f562015-07-15 17:05:10 -0700697 def CASE1000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700698 """
699 Add host intents between 2 host:
700 - Discover hosts
701 - Add host intents
702 - Check intents
703 - Verify flows
704 - Ping hosts
705 - Reroute
706 - Link down
707 - Verify flows
708 - Check topology
709 - Ping hosts
710 - Link up
711 - Verify flows
712 - Check topology
713 - Ping hosts
714 - Remove intents
715 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700716 if main.initialized == main.FALSE:
717 main.log.error( "Test components did not start correctly, skipping further tests" )
718 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700719 # Assert variables - These variable's name|format must be followed
720 # if you want to use the wrapper function
721 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -0700722 try:
723 assert main.CLIs
724 except AssertionError:
725 main.log.error( "There is no main.CLIs, skipping test cases" )
726 main.initialized = main.FALSE
727 main.skipCase()
728 try:
729 assert main.Mininet1
730 except AssertionError:
731 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
732 main.initialized = main.FALSE
733 main.skipCase()
734 try:
735 assert main.numSwitch
736 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700737 main.log.error( "Place the total number of switch topology in " +\
738 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -0700739 main.initialized = main.FALSE
740 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700741
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800742 # Save leader candidates
acsmarse6b410f2015-07-17 14:39:34 -0700743 intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
744
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700745 main.testName = "Host Intents"
746 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -0700747 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -0700748 main.caseExplanation = "This test case tests Host intents using " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700749 str( main.numCtrls ) + " node(s) cluster;\n" +\
750 "Different type of hosts will be tested in " +\
751 "each step such as IPV4, Dual stack, VLAN " +\
Jeremyeb51cb12016-03-28 17:53:35 -0700752 "etc;\nThe test will use OF " + main.OFProtocol +\
753 " OVS running in Mininet and compile intents" +\
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700754 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700755
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700756 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700757 main.assertReturnString = "Assertion Result for IPV4 host intent with mac addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800758 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
759 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
760 testResult = main.FALSE
761 installResult = main.intentFunction.installHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700762 name="IPV4",
763 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800764 host1=host1,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700765 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800766 if installResult:
767 testResult = main.intentFunction.testHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700768 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800769 intentId = installResult,
alison52b25892016-09-19 10:53:48 -0700770 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800771 host1=host1,
772 host2=host2,
alison52b25892016-09-19 10:53:48 -0700773 sw1="s5",
774 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700775 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800776 else:
777 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800778
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700779 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800780 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700781 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700782 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700783
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700784 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700785 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800786 host1 = { "name":"h3","id":"00:00:00:00:00:03/-1" }
787 host2 = { "name":"h11","id":"00:00:00:00:00:0B/-1 "}
788 testResult = main.FALSE
789 installResult = main.intentFunction.installHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700790 name="DUALSTACK",
791 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800792 host1=host1,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700793 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800794
795 if installResult:
796 testResult = main.intentFunction.testHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700797 name="DUALSTACK",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800798 intentId = installResult,
alison52b25892016-09-19 10:53:48 -0700799 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800800 host1=host1,
801 host2=host2,
alison52b25892016-09-19 10:53:48 -0700802 sw1="s5",
803 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700804 expectedLink=18 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700805
806 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800807 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700808 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700809 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700810
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700811 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700812 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800813 host1 = { "name":"h1" }
814 host2 = { "name":"h11" }
815 testResult = main.FALSE
816 installResult = main.intentFunction.installHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700817 name="DUALSTACK2",
818 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800819 host1=host1,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700820 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800821
822 if installResult:
823 testResult = main.intentFunction.testHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700824 name="DUALSTACK2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800825 intentId = installResult,
alison52b25892016-09-19 10:53:48 -0700826 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800827 host1=host1,
828 host2=host2,
alison52b25892016-09-19 10:53:48 -0700829 sw1="s5",
830 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700831 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800832 else:
833 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700834
835 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800836 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700837 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700838 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700839
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700840 main.step( "1HOP: Add host intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -0700841 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800842 host1 = { "name":"h1" }
843 host2 = { "name":"h3" }
844 testResult = main.FALSE
845 installResult = main.intentFunction.installHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700846 name="1HOP",
847 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800848 host1=host1,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700849 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800850
851 if installResult:
852 testResult = main.intentFunction.testHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700853 name="1HOP",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800854 intentId = installResult,
alison52b25892016-09-19 10:53:48 -0700855 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800856 host1=host1,
857 host2=host2,
alison52b25892016-09-19 10:53:48 -0700858 sw1="s5",
859 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700860 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800861 else:
862 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700863
864 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800865 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700866 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700867 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700868
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700869 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
acsmars5d8cc862015-09-25 09:44:50 -0700870 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jeremy Songster832f9e92016-05-05 14:30:49 -0700871 host1 = { "name":"h4","id":"00:00:00:00:00:04/100", "vlan":"100" }
872 host2 = { "name":"h12","id":"00:00:00:00:00:0C/100", "vlan":"100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800873 testResult = main.FALSE
874 installResult = main.intentFunction.installHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700875 name="VLAN1",
876 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800877 host1=host1,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700878 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800879
880 if installResult:
881 testResult = main.intentFunction.testHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700882 name="VLAN1",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800883 intentId = installResult,
alison52b25892016-09-19 10:53:48 -0700884 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800885 host1=host1,
886 host2=host2,
alison52b25892016-09-19 10:53:48 -0700887 sw1="s5",
888 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700889 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800890 else:
891 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700892
893 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800894 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700895 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700896 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700897
Jeremy Songsterff553672016-05-12 17:06:23 -0700898 main.step( "VLAN2: Add vlan host intents between h4 and h13" )
899 main.assertReturnString = "Assertion Result vlan IPV4\n"
900 host1 = { "name":"h5", "vlan":"200" }
901 host2 = { "name":"h12", "vlan":"100" }
902 testResult = main.FALSE
Jeremy Songsterff553672016-05-12 17:06:23 -0700903 installResult = main.intentFunction.installHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700904 name="VLAN2",
905 onosNode=0,
Jeremy Songsterff553672016-05-12 17:06:23 -0700906 host1=host1,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700907 host2=host2 )
Jeremy Songsterff553672016-05-12 17:06:23 -0700908
909 if installResult:
910 testResult = main.intentFunction.testHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700911 name="VLAN2",
Jeremy Songsterff553672016-05-12 17:06:23 -0700912 intentId = installResult,
alison52b25892016-09-19 10:53:48 -0700913 onosNode=0,
Jeremy Songsterff553672016-05-12 17:06:23 -0700914 host1=host1,
915 host2=host2,
alison52b25892016-09-19 10:53:48 -0700916 sw1="s5",
917 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700918 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -0700919 else:
920 main.CLIs[ 0 ].removeAllIntents( purge=True )
921
922 utilities.assert_equals( expect=main.TRUE,
923 actual=testResult,
924 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700925 onfail=main.assertReturnString )
Jeremy Songsterff553672016-05-12 17:06:23 -0700926
Jeremy Songsterc032f162016-08-04 17:14:49 -0700927 main.step( "Encapsulation: Add host intents between h1 and h9" )
928 main.assertReturnString = "Assertion Result for VLAN Encapsulated host intent\n"
929 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
930 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
931 testResult = main.FALSE
Jeremy Songsterc032f162016-08-04 17:14:49 -0700932 installResult = main.intentFunction.installHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700933 name="ENCAPSULATION",
934 onosNode=0,
Jeremy Songsterc032f162016-08-04 17:14:49 -0700935 host1=host1,
936 host2=host2,
937 encap="VLAN" )
938 if installResult:
939 testResult = main.intentFunction.testHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700940 name="ENCAPSULATION",
Jeremy Songsterc032f162016-08-04 17:14:49 -0700941 intentId = installResult,
alison52b25892016-09-19 10:53:48 -0700942 onosNode=0,
Jeremy Songsterc032f162016-08-04 17:14:49 -0700943 host1=host1,
944 host2=host2,
alison52b25892016-09-19 10:53:48 -0700945 sw1="s5",
946 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700947 expectedLink=18 )
Jeremy Songsterc032f162016-08-04 17:14:49 -0700948 else:
949 main.CLIs[ 0 ].removeAllIntents( purge=True )
950
951 utilities.assert_equals( expect=main.TRUE,
952 actual=testResult,
953 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700954 onfail=main.assertReturnString )
Jeremy Songsterc032f162016-08-04 17:14:49 -0700955
alison52b25892016-09-19 10:53:48 -0700956 # Testing MPLS would need to update kernel version (Right now is 3.16)
957 # main.step( "Encapsulation: Add host intents between h1 and h9" )
958 # main.assertReturnString = "Assertion Result for MPLS Encapsulated host intent\n"
959 # host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
960 # host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
961 # testResult = main.FALSE
962 # installResult = main.intentFunction.installHostIntent( main,
963 # name="ENCAPSULATION",
964 # onosNode=0,
965 # host1=host1,
966 # host2=host2,
967 # encap="MPLS" )
968 # if installResult:
969 # testResult = main.intentFunction.testHostIntent( main,
970 # name="ENCAPSULATION",
971 # intentId=installResult,
972 # onosNode=0,
973 # host1=host1,
974 # host2=host2,
975 # sw1="s5",
976 # sw2="s2",
977 # expectedLink=18 )
978 # else:
979 # main.CLIs[ 0 ].removeAllIntents( purge=True )
980 #
981 # utilities.assert_equals( expect=main.TRUE,
982 # actual=testResult,
983 # onpass=main.assertReturnString,
984 # onfail=main.assertReturnString )
985
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700986 main.step( "Confirm that ONOS leadership is unchanged" )
acsmarse6b410f2015-07-17 14:39:34 -0700987 intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
alison52b25892016-09-19 10:53:48 -0700988 testResult = main.intentFunction.checkLeaderChange( intentLeadersOld,
acsmarse6b410f2015-07-17 14:39:34 -0700989 intentLeadersNew )
990
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800991 utilities.assert_equals( expect=main.TRUE,
992 actual=testResult,
993 onpass="ONOS Leaders Unchanged",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700994 onfail="ONOS Leader Mismatch" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800995
kelvin-onlab016dce22015-08-10 09:54:11 -0700996 main.intentFunction.report( main )
997
kelvin-onlabb769f562015-07-15 17:05:10 -0700998 def CASE2000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700999 """
1000 Add point intents between 2 hosts:
1001 - Get device ids | ports
1002 - Add point intents
1003 - Check intents
1004 - Verify flows
1005 - Ping hosts
1006 - Reroute
1007 - Link down
1008 - Verify flows
1009 - Check topology
1010 - Ping hosts
1011 - Link up
1012 - Verify flows
1013 - Check topology
1014 - Ping hosts
1015 - Remove intents
1016 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001017 if main.initialized == main.FALSE:
1018 main.log.error( "Test components did not start correctly, skipping further tests" )
1019 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001020 # Assert variables - These variable's name|format must be followed
1021 # if you want to use the wrapper function
1022 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001023 try:
1024 assert main.CLIs
1025 except AssertionError:
1026 main.log.error( "There is no main.CLIs, skipping test cases" )
1027 main.initialized = main.FALSE
1028 main.skipCase()
1029 try:
1030 assert main.Mininet1
1031 except AssertionError:
1032 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1033 main.initialized = main.FALSE
1034 main.skipCase()
1035 try:
1036 assert main.numSwitch
1037 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001038 main.log.error( "Place the total number of switch topology in " +\
1039 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001040 main.initialized = main.FALSE
1041 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001042
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001043 main.testName = "Point Intents"
1044 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001045 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001046 main.caseExplanation = "This test case will test point to point" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001047 " intents using " + str( main.numCtrls ) +\
1048 " node(s) cluster;\n" +\
1049 "Different type of hosts will be tested in " +\
1050 "each step such as IPV4, Dual stack, VLAN etc" +\
1051 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001052 " OVS running in Mininet and compile intents" +\
1053 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001054
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001055 # No option point intents
1056 main.step( "NOOPTION: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001057 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001058 senders = [
1059 { "name":"h1","device":"of:0000000000000005/1" }
1060 ]
1061 recipients = [
1062 { "name":"h9","device":"of:0000000000000006/1" }
1063 ]
Jeremy42df2e72016-02-23 16:37:46 -08001064 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001065 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001066 main,
1067 name="NOOPTION",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001068 senders=senders,
1069 recipients=recipients )
1070
1071 if installResult:
1072 testResult = main.intentFunction.testPointIntent(
1073 main,
1074 intentId=installResult,
1075 name="NOOPTION",
1076 senders=senders,
1077 recipients=recipients,
1078 sw1="s5",
1079 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001080 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001081 else:
1082 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001083
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001084 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001085 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001086 onpass=main.assertReturnString,
1087 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001088
kelvin-onlabb769f562015-07-15 17:05:10 -07001089 main.step( "IPV4: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001090 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001091 senders = [
1092 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1093 ]
1094 recipients = [
1095 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09" }
1096 ]
Jeremy42df2e72016-02-23 16:37:46 -08001097 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001098 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001099 main,
1100 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001101 senders=senders,
1102 recipients=recipients,
1103 ethType="IPV4" )
1104
1105 if installResult:
1106 testResult = main.intentFunction.testPointIntent(
1107 main,
1108 intentId=installResult,
1109 name="IPV4",
1110 senders=senders,
1111 recipients=recipients,
1112 sw1="s5",
1113 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001114 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001115 else:
1116 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001117
1118 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001119 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001120 onpass=main.assertReturnString,
1121 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001122 main.step( "IPV4_2: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001123 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001124 senders = [
1125 { "name":"h1","device":"of:0000000000000005/1" }
1126 ]
1127 recipients = [
1128 { "name":"h9","device":"of:0000000000000006/1" }
1129 ]
Jeremy42df2e72016-02-23 16:37:46 -08001130 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001131 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001132 main,
1133 name="IPV4_2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001134 senders=senders,
1135 recipients=recipients,
1136 ethType="IPV4" )
1137
1138 if installResult:
1139 testResult = main.intentFunction.testPointIntent(
1140 main,
1141 intentId=installResult,
1142 name="IPV4_2",
1143 senders=senders,
1144 recipients=recipients,
1145 sw1="s5",
1146 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001147 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001148 else:
1149 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001150
1151 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001152 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001153 onpass=main.assertReturnString,
1154 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001155
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001156 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001157 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001158 senders = [
1159 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01",
Jeremy6f000c62016-02-25 17:02:28 -08001160 "ip":( main.h1.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001161 ]
1162 recipients = [
1163 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09",
Jeremy6f000c62016-02-25 17:02:28 -08001164 "ip":( main.h9.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001165 ]
Jeremy6f000c62016-02-25 17:02:28 -08001166 ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ]
kelvin-onlab79ce0492015-07-27 16:14:39 -07001167 # Uneccessary, not including this in the selectors
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001168 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
1169 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
Jeremy42df2e72016-02-23 16:37:46 -08001170 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001171 installResult = main.intentFunction.installPointIntent(
1172 main,
1173 name="SDNIP-ICMP",
1174 senders=senders,
1175 recipients=recipients,
1176 ethType="IPV4",
1177 ipProto=ipProto,
1178 tcpSrc=tcpSrc,
1179 tcpDst=tcpDst )
1180
1181 if installResult:
1182 testResult = main.intentFunction.testPointIntent(
1183 main,
1184 intentId=installResult,
1185 name="SDNIP_ICMP",
1186 senders=senders,
1187 recipients=recipients,
1188 sw1="s5",
1189 sw2="s2",
Jeremy Songstere405d3d2016-05-17 11:18:57 -07001190 expectedLink=18,
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001191 useTCP=True )
Jeremy42df2e72016-02-23 16:37:46 -08001192 else:
1193 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabb769f562015-07-15 17:05:10 -07001194
1195 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001196 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001197 onpass=main.assertReturnString,
1198 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001199
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001200 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001201 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
kelvin-onlabb769f562015-07-15 17:05:10 -07001202 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
1203 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab58dc39e2015-08-06 08:11:09 -07001204 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
1205 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlabb769f562015-07-15 17:05:10 -07001206 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
1207 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
1208 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
1209
kelvin-onlab58dc39e2015-08-06 08:11:09 -07001210 stepResult = main.intentFunction.pointIntentTcp(
kelvin-onlabb769f562015-07-15 17:05:10 -07001211 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001212 name="SDNIP-TCP",
kelvin-onlabb769f562015-07-15 17:05:10 -07001213 host1="h1",
1214 host2="h9",
1215 deviceId1="of:0000000000000005/1",
1216 deviceId2="of:0000000000000006/1",
1217 mac1=mac1,
1218 mac2=mac2,
1219 ethType="IPV4",
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001220 ipProto=ipProto,
1221 ip1=ip1,
1222 ip2=ip2,
1223 tcp1=tcp1,
1224 tcp2=tcp2 )
kelvin-onlabb769f562015-07-15 17:05:10 -07001225
1226 utilities.assert_equals( expect=main.TRUE,
Jeremy6f000c62016-02-25 17:02:28 -08001227 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -07001228 onpass=main.assertReturnString,
1229 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001230
acsmars5d8cc862015-09-25 09:44:50 -07001231 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
1232 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001233 senders = [
1234 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1235 ]
1236 recipients = [
1237 { "name":"h11","device":"of:0000000000000006/3","mac":"00:00:00:00:00:0B" }
1238 ]
Jeremy42df2e72016-02-23 16:37:46 -08001239 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001240 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001241 main,
1242 name="DUALSTACK1",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001243 senders=senders,
1244 recipients=recipients,
1245 ethType="IPV4" )
1246
1247 if installResult:
1248 testResult = main.intentFunction.testPointIntent(
1249 main,
1250 intentId=installResult,
1251 name="DUALSTACK1",
1252 senders=senders,
1253 recipients=recipients,
1254 sw1="s5",
1255 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001256 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001257 else:
1258 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001259
1260 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001261 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001262 onpass=main.assertReturnString,
1263 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001264
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001265 main.step( "VLAN: Add point intents between h5 and h21" )
acsmars5d8cc862015-09-25 09:44:50 -07001266 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001267 senders = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001268 { "name":"h5","device":"of:0000000000000005/5","mac":"00:00:00:00:00:05", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001269 ]
1270 recipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001271 { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001272 ]
Jeremy42df2e72016-02-23 16:37:46 -08001273 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001274 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001275 main,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001276 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001277 senders=senders,
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001278 recipients=recipients )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001279
1280 if installResult:
1281 testResult = main.intentFunction.testPointIntent(
1282 main,
1283 intentId=installResult,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001284 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001285 senders=senders,
1286 recipients=recipients,
1287 sw1="s5",
1288 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001289 expectedLink=18 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001290
1291 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001292 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001293 onpass=main.assertReturnString,
1294 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001295
Jeremy Songsterff553672016-05-12 17:06:23 -07001296 main.step( "VLAN: Add point intents between h5 and h21" )
1297 main.assertReturnString = "Assertion Result for VLAN IPV4 point intents with VLAN treatment\n"
1298 senders = [
1299 { "name":"h4", "vlan":"100" }
1300 ]
1301 recipients = [
1302 { "name":"h21", "vlan":"200" }
1303 ]
1304 testResult = main.FALSE
Jeremy Songsterff553672016-05-12 17:06:23 -07001305 installResult = main.intentFunction.installPointIntent(
1306 main,
1307 name="VLAN2",
1308 senders=senders,
1309 recipients=recipients,
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001310 setVlan=200 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001311
1312 if installResult:
1313 testResult = main.intentFunction.testPointIntent(
1314 main,
1315 intentId=installResult,
1316 name="VLAN2",
1317 senders=senders,
1318 recipients=recipients,
1319 sw1="s5",
1320 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001321 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001322
1323 utilities.assert_equals( expect=main.TRUE,
1324 actual=testResult,
1325 onpass=main.assertReturnString,
1326 onfail=main.assertReturnString )
1327
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001328 main.step( "1HOP: Add point intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -07001329 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001330 senders = [
1331 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1332 ]
1333 recipients = [
1334 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1335 ]
Jeremy42df2e72016-02-23 16:37:46 -08001336 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001337 installResult = main.intentFunction.installPointIntent(
1338 main,
1339 name="1HOP IPV4",
1340 senders=senders,
1341 recipients=recipients,
1342 ethType="IPV4" )
1343
1344 if installResult:
1345 testResult = main.intentFunction.testPointIntent(
1346 main,
1347 intentId=installResult,
1348 name="1HOP IPV4",
1349 senders=senders,
1350 recipients=recipients,
1351 sw1="s5",
1352 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001353 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001354 else:
1355 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001356
1357 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001358 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001359 onpass=main.assertReturnString,
1360 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001361
Jeremy Songsterc032f162016-08-04 17:14:49 -07001362 main.step( "Add point to point intents using VLAN Encapsulation" )
1363 main.assertReturnString = "Assertion Result for VLAN Encapsulation Point Intent"
1364 senders = [
1365 { "name":"h1","device":"of:0000000000000005/1" }
1366 ]
1367 recipients = [
1368 { "name":"h9","device":"of:0000000000000006/1" }
1369 ]
1370 testResult = main.FALSE
Jeremy Songsterc032f162016-08-04 17:14:49 -07001371 installResult = main.intentFunction.installPointIntent(
1372 main,
1373 name="ENCAPSULATION",
1374 senders=senders,
1375 recipients=recipients,
1376 encap="VLAN" )
1377
1378 if installResult:
1379 testResult = main.intentFunction.testPointIntent(
1380 main,
1381 intentId=installResult,
1382 name="ENCAPSULATION",
1383 senders=senders,
1384 recipients=recipients,
1385 sw1="s5",
1386 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001387 expectedLink=18 )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001388 else:
1389 main.CLIs[ 0 ].removeAllIntents( purge=True )
1390
1391 utilities.assert_equals( expect=main.TRUE,
1392 actual=testResult,
1393 onpass=main.assertReturnString,
1394 onfail=main.assertReturnString )
1395
alison52b25892016-09-19 10:53:48 -07001396 # Testing MPLS would need to update kernel version (Right now is 3.16)
1397 # main.step( "Add point to point intents using MPLS Encapsulation" )
1398 # main.assertReturnString = "Assertion Result for MPLS Encapsulation Point Intent"
1399 # senders = [
1400 # { "name": "h1", "device": "of:0000000000000005/1" }
1401 # ]
1402 # recipients = [
1403 # { "name": "h9", "device": "of:0000000000000006/1" }
1404 # ]
1405 # testResult = main.FALSE
1406 # installResult = main.intentFunction.installPointIntent(
1407 # main,
1408 # name="ENCAPSULATION",
1409 # senders=senders,
1410 # recipients=recipients,
1411 # encap="MPLS" )
1412 #
1413 # if installResult:
1414 # testResult = main.intentFunction.testPointIntent(
1415 # main,
1416 # intentId=installResult,
1417 # name="ENCAPSULATION",
1418 # senders=senders,
1419 # recipients=recipients,
1420 # sw1="s5",
1421 # sw2="s2",
1422 # expectedLink=18 )
1423 # else:
1424 # main.CLIs[ 0 ].removeAllIntents( purge=True )
1425 #
1426 # utilities.assert_equals( expect=main.TRUE,
1427 # actual=testResult,
1428 # onpass=main.assertReturnString,
1429 # onfail=main.assertReturnString )
1430
kelvin-onlab016dce22015-08-10 09:54:11 -07001431 main.intentFunction.report( main )
1432
kelvin-onlabb769f562015-07-15 17:05:10 -07001433 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001434 """
1435 Add single point to multi point intents
1436 - Get device ids
1437 - Add single point to multi point intents
1438 - Check intents
1439 - Verify flows
1440 - Ping hosts
1441 - Reroute
1442 - Link down
1443 - Verify flows
1444 - Check topology
1445 - Ping hosts
1446 - Link up
1447 - Verify flows
1448 - Check topology
1449 - Ping hosts
1450 - Remove intents
1451 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001452 if main.initialized == main.FALSE:
1453 main.log.error( "Test components did not start correctly, skipping further tests" )
1454 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001455 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001456 try:
1457 assert main.CLIs
1458 except AssertionError:
1459 main.log.error( "There is no main.CLIs, skipping test cases" )
1460 main.initialized = main.FALSE
1461 main.skipCase()
1462 try:
1463 assert main.Mininet1
1464 except AssertionError:
1465 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1466 main.initialized = main.FALSE
1467 main.skipCase()
1468 try:
1469 assert main.numSwitch
1470 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001471 main.log.error( "Place the total number of switch topology in "+ \
1472 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001473 main.initialized = main.FALSE
1474 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001475
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001476 main.testName = "Single to Multi Point Intents"
1477 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001478 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001479 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001480 " multi point intents using " +\
1481 str( main.numCtrls ) + " node(s) cluster;\n" +\
1482 "Different type of hosts will be tested in " +\
1483 "each step such as IPV4, Dual stack, VLAN etc" +\
1484 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001485 " OVS running in Mininet and compile intents" +\
1486 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001487
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001488 main.step( "NOOPTION: Install and test single point to multi point intents" )
1489 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
1490 senders = [
1491 { "name":"h8", "device":"of:0000000000000005/8" }
1492 ]
1493 recipients = [
1494 { "name":"h16", "device":"of:0000000000000006/8" },
1495 { "name":"h24", "device":"of:0000000000000007/8" }
1496 ]
1497 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1498 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1499 testResult = main.FALSE
1500 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001501 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001502 name="NOOPTION",
1503 senders=senders,
1504 recipients=recipients,
1505 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001506 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001507
1508 if installResult:
1509 testResult = main.intentFunction.testPointIntent(
1510 main,
1511 intentId=installResult,
1512 name="NOOPTION",
1513 senders=senders,
1514 recipients=recipients,
1515 badSenders=badSenders,
1516 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001517 sw1="s5",
1518 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001519 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001520 else:
1521 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001522
1523 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001524 actual=testResult,
1525 onpass=main.assertReturnString,
1526 onfail=main.assertReturnString )
1527
1528 main.step( "IPV4: Install and test single point to multi point intents" )
1529 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses\n"
1530 senders = [
1531 { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" }
1532 ]
1533 recipients = [
1534 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1535 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1536 ]
1537 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1538 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1539 testResult = main.FALSE
1540 installResult = main.intentFunction.installSingleToMultiIntent(
1541 main,
1542 name="IPV4",
1543 senders=senders,
1544 recipients=recipients,
1545 ethType="IPV4",
1546 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001547 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001548
1549 if installResult:
1550 testResult = main.intentFunction.testPointIntent(
1551 main,
1552 intentId=installResult,
1553 name="IPV4",
1554 senders=senders,
1555 recipients=recipients,
1556 badSenders=badSenders,
1557 badRecipients=badRecipients,
1558 sw1="s5",
1559 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001560 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001561 else:
1562 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001563
1564 utilities.assert_equals( expect=main.TRUE,
1565 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001566 onpass=main.assertReturnString,
1567 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001568
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001569 main.step( "IPV4_2: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001570 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 -08001571 senders = [
1572 { "name":"h8", "device":"of:0000000000000005/8" }
1573 ]
1574 recipients = [
1575 { "name":"h16", "device":"of:0000000000000006/8" },
1576 { "name":"h24", "device":"of:0000000000000007/8" }
1577 ]
1578 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1579 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1580 testResult = main.FALSE
1581 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001582 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001583 name="IPV4_2",
1584 senders=senders,
1585 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001586 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001587 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001588 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001589
1590 if installResult:
1591 testResult = main.intentFunction.testPointIntent(
1592 main,
1593 intentId=installResult,
1594 name="IPV4_2",
1595 senders=senders,
1596 recipients=recipients,
1597 badSenders=badSenders,
1598 badRecipients=badRecipients,
1599 sw1="s5",
1600 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001601 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001602 else:
1603 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001604
1605 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001606 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001607 onpass=main.assertReturnString,
1608 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001609
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001610 main.step( "VLAN: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001611 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 -08001612 senders = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001613 { "name":"h4", "device":"of:0000000000000005/4", "mac":"00:00:00:00:00:04", "vlan":"100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001614 ]
1615 recipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001616 { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C", "vlan":"100" },
1617 { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14", "vlan":"100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001618 ]
1619 badSenders=[ { "name":"h13" } ] # Senders that are not in the intent
1620 badRecipients=[ { "name":"h21" } ] # Recipients that are not in the intent
1621 testResult = main.FALSE
1622 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001623 main,
alison52b25892016-09-19 10:53:48 -07001624 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001625 senders=senders,
1626 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001627 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001628 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001629
1630 if installResult:
1631 testResult = main.intentFunction.testPointIntent(
1632 main,
1633 intentId=installResult,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001634 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001635 senders=senders,
1636 recipients=recipients,
1637 badSenders=badSenders,
1638 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001639 sw1="s5",
1640 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001641 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001642 else:
1643 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001644
1645 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001646 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001647 onpass=main.assertReturnString,
1648 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001649
Jeremy Songsterff553672016-05-12 17:06:23 -07001650 main.step( "VLAN: Add single point to multi point intents" )
1651 main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n"
1652 senders = [
1653 { "name":"h5", "vlan":"200" }
1654 ]
1655 recipients = [
1656 { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C", "vlan":"100" },
1657 { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14", "vlan":"100" }
1658 ]
1659 badSenders=[ { "name":"h13" } ] # Senders that are not in the intent
1660 badRecipients=[ { "name":"h21" } ] # Recipients that are not in the intent
1661 testResult = main.FALSE
Jeremy Songsterff553672016-05-12 17:06:23 -07001662 installResult = main.intentFunction.installSingleToMultiIntent(
1663 main,
1664 name="VLAN2",
1665 senders=senders,
1666 recipients=recipients,
1667 sw1="s5",
1668 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001669 setVlan=100 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001670
1671 if installResult:
1672 testResult = main.intentFunction.testPointIntent(
1673 main,
1674 intentId=installResult,
1675 name="VLAN2",
1676 senders=senders,
1677 recipients=recipients,
1678 badSenders=badSenders,
1679 badRecipients=badRecipients,
1680 sw1="s5",
1681 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001682 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001683 else:
1684 main.CLIs[ 0 ].removeAllIntents( purge=True )
1685
1686 utilities.assert_equals( expect=main.TRUE,
1687 actual=testResult,
1688 onpass=main.assertReturnString,
1689 onfail=main.assertReturnString )
1690
alison52b25892016-09-19 10:53:48 -07001691 # Does not support Single point to multi point encapsulation
1692 # main.step( "ENCAPSULATION: Install and test single point to multi point intents" )
1693 # main.assertReturnString = "Assertion results for VLAN Encapsulation single to multi point intent\n"
1694 # senders = [
1695 # { "name":"h8", "device":"of:0000000000000005/8" }
1696 # ]
1697 # recipients = [
1698 # { "name":"h16", "device":"of:0000000000000006/8" },
1699 # { "name":"h24", "device":"of:0000000000000007/8" }
1700 # ]
1701 # badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1702 # badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1703 # testResult = main.FALSE
1704 # installResult = main.intentFunction.installSingleToMultiIntent(
1705 # main,
1706 # name="ENCAPSULATION",
1707 # senders=senders,
1708 # recipients=recipients,
1709 # sw1="s5",
1710 # sw2="s2",
1711 # encap="VLAN" )
1712 #
1713 # if installResult:
1714 # testResult = main.intentFunction.testPointIntent(
1715 # main,
1716 # intentId=installResult,
1717 # name="ENCAPSULATION",
1718 # senders=senders,
1719 # recipients=recipients,
1720 # badSenders=badSenders,
1721 # badRecipients=badRecipients,
1722 # sw1="s5",
1723 # sw2="s2",
1724 # expectedLink=18 )
1725 # else:
1726 # main.CLIs[ 0 ].removeAllIntents( purge=True )
1727 #
1728 # utilities.assert_equals( expect=main.TRUE,
1729 # actual=testResult,
1730 # onpass=main.assertReturnString,
1731 # onfail=main.assertReturnString )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001732
kelvin-onlab016dce22015-08-10 09:54:11 -07001733 main.intentFunction.report( main )
1734
kelvin-onlabb769f562015-07-15 17:05:10 -07001735 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001736 """
1737 Add multi point to single point intents
1738 - Get device ids
1739 - Add multi point to single point intents
1740 - Check intents
1741 - Verify flows
1742 - Ping hosts
1743 - Reroute
1744 - Link down
1745 - Verify flows
1746 - Check topology
1747 - Ping hosts
1748 - Link up
1749 - Verify flows
1750 - Check topology
1751 - Ping hosts
1752 - Remove intents
1753 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001754 if main.initialized == main.FALSE:
1755 main.log.error( "Test components did not start correctly, skipping further tests" )
1756 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001757 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001758 try:
1759 assert main.CLIs
1760 except AssertionError:
1761 main.log.error( "There is no main.CLIs, skipping test cases" )
1762 main.initialized = main.FALSE
1763 main.skipCase()
1764 try:
1765 assert main.Mininet1
1766 except AssertionError:
1767 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1768 main.initialized = main.FALSE
1769 main.skipCase()
1770 try:
1771 assert main.numSwitch
1772 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001773 main.log.error( "Place the total number of switch topology in "+\
1774 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001775 main.initialized = main.FALSE
1776 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001777
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001778 main.testName = "Multi To Single Point Intents"
1779 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001780 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001781 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001782 " multi point intents using " +\
1783 str( main.numCtrls ) + " node(s) cluster;\n" +\
1784 "Different type of hosts will be tested in " +\
1785 "each step such as IPV4, Dual stack, VLAN etc" +\
1786 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001787 " OVS running in Mininet and compile intents" +\
1788 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001789
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001790 main.step( "NOOPTION: Add multi point to single point intents" )
1791 main.assertReturnString = "Assertion results for NOOPTION multi to single point intent\n"
1792 senders = [
1793 { "name":"h16", "device":"of:0000000000000006/8" },
1794 { "name":"h24", "device":"of:0000000000000007/8" }
1795 ]
1796 recipients = [
1797 { "name":"h8", "device":"of:0000000000000005/8" }
1798 ]
1799 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1800 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1801 testResult = main.FALSE
1802 installResult = main.intentFunction.installMultiToSingleIntent(
1803 main,
1804 name="NOOPTION",
1805 senders=senders,
1806 recipients=recipients,
1807 sw1="s5",
Jeremye0cb5eb2016-01-27 17:39:09 -08001808 sw2="s2" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001809
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001810 if installResult:
1811 testResult = main.intentFunction.testPointIntent(
1812 main,
1813 intentId=installResult,
1814 name="NOOPTION",
1815 senders=senders,
1816 recipients=recipients,
1817 badSenders=badSenders,
1818 badRecipients=badRecipients,
1819 sw1="s5",
1820 sw2="s2",
Jeremye0cb5eb2016-01-27 17:39:09 -08001821 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001822 else:
1823 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001824
1825 utilities.assert_equals( expect=main.TRUE,
1826 actual=testResult,
1827 onpass=main.assertReturnString,
1828 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001829
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001830 main.step( "IPV4: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001831 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 -08001832 senders = [
1833 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1834 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1835 ]
1836 recipients = [
1837 { "name":"h8", "device":"of:0000000000000005/8", "mac":"00:00:00:00:00:08" }
1838 ]
1839 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1840 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1841 testResult = main.FALSE
1842 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001843 main,
1844 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001845 senders=senders,
1846 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001847 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001848 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001849 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001850
1851 if installResult:
1852 testResult = main.intentFunction.testPointIntent(
1853 main,
1854 intentId=installResult,
1855 name="IPV4",
1856 senders=senders,
1857 recipients=recipients,
1858 badSenders=badSenders,
1859 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001860 sw1="s5",
1861 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001862 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001863 else:
1864 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001865
1866 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001867 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001868 onpass=main.assertReturnString,
1869 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001870
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001871 main.step( "IPV4_2: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001872 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 -08001873 senders = [
1874 { "name":"h16", "device":"of:0000000000000006/8" },
1875 { "name":"h24", "device":"of:0000000000000007/8" }
1876 ]
1877 recipients = [
1878 { "name":"h8", "device":"of:0000000000000005/8" }
1879 ]
1880 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1881 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1882 testResult = main.FALSE
1883 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001884 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001885 name="IPV4_2",
1886 senders=senders,
1887 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001888 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001889 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001890 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001891
1892 if installResult:
1893 testResult = main.intentFunction.testPointIntent(
1894 main,
1895 intentId=installResult,
1896 name="IPV4_2",
1897 senders=senders,
1898 recipients=recipients,
1899 badSenders=badSenders,
1900 badRecipients=badRecipients,
1901 sw1="s5",
1902 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001903 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001904 else:
1905 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001906
1907 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001908 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001909 onpass=main.assertReturnString,
1910 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001911
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001912 main.step( "VLAN: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001913 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 -08001914 senders = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001915 { "name":"h13", "device":"of:0000000000000006/5", "vlan":"200" },
1916 { "name":"h21", "device":"of:0000000000000007/5", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001917 ]
1918 recipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001919 { "name":"h5", "device":"of:0000000000000005/5", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001920 ]
1921 badSenders=[ { "name":"h12" } ] # Senders that are not in the intent
1922 badRecipients=[ { "name":"h20" } ] # Recipients that are not in the intent
1923 testResult = main.FALSE
1924 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001925 main,
1926 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001927 senders=senders,
1928 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001929 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001930 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001931
1932 if installResult:
1933 testResult = main.intentFunction.testPointIntent(
1934 main,
1935 intentId=installResult,
1936 name="VLAN",
1937 senders=senders,
1938 recipients=recipients,
1939 badSenders=badSenders,
1940 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001941 sw1="s5",
1942 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001943 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001944 else:
1945 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001946
1947 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001948 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001949 onpass=main.assertReturnString,
1950 onfail=main.assertReturnString )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001951
Jeremy Songsterff553672016-05-12 17:06:23 -07001952 # Right now this fails because of this bug: https://jira.onosproject.org/browse/ONOS-4383
1953 main.step( "VLAN: Add multi point to single point intents" )
1954 main.assertReturnString = "Assertion results for multi to single point intent with VLAN ID treatment\n"
1955 senders = [
1956 { "name":"h13", "device":"of:0000000000000006/5", "vlan":"200" },
1957 { "name":"h21", "device":"of:0000000000000007/5", "vlan":"200" }
1958 ]
1959 recipients = [
1960 { "name":"h4", "vlan":"100" }
1961 ]
1962 badSenders=[ { "name":"h12" } ] # Senders that are not in the intent
1963 badRecipients=[ { "name":"h20" } ] # Recipients that are not in the intent
1964 testResult = main.FALSE
Jeremy Songsterff553672016-05-12 17:06:23 -07001965 installResult = main.intentFunction.installMultiToSingleIntent(
1966 main,
1967 name="VLAN2",
1968 senders=senders,
1969 recipients=recipients,
1970 sw1="s5",
1971 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001972 setVlan=100 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001973
1974 if installResult:
1975 testResult = main.intentFunction.testPointIntent(
1976 main,
1977 intentId=installResult,
1978 name="VLAN2",
1979 senders=senders,
1980 recipients=recipients,
1981 badSenders=badSenders,
1982 badRecipients=badRecipients,
1983 sw1="s5",
1984 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001985 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001986 else:
1987 main.CLIs[ 0 ].removeAllIntents( purge=True )
1988
1989 utilities.assert_equals( expect=main.TRUE,
1990 actual=testResult,
1991 onpass=main.assertReturnString,
1992 onfail=main.assertReturnString )
1993
Jeremy Songsterc032f162016-08-04 17:14:49 -07001994 main.step( "ENCAPSULATION: Add multi point to single point intents" )
1995 main.assertReturnString = "Assertion results for VLAN Encapsulation multi to single point intent\n"
1996 senders = [
1997 { "name":"h16", "device":"of:0000000000000006/8" },
1998 { "name":"h24", "device":"of:0000000000000007/8" }
1999 ]
2000 recipients = [
2001 { "name":"h8", "device":"of:0000000000000005/8" }
2002 ]
2003 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
2004 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
2005 testResult = main.FALSE
Jeremy Songsterc032f162016-08-04 17:14:49 -07002006 installResult = main.intentFunction.installMultiToSingleIntent(
2007 main,
2008 name="ENCAPSULATION",
2009 senders=senders,
2010 recipients=recipients,
2011 sw1="s5",
2012 sw2="s2",
2013 encap="VLAN" )
2014
2015 if installResult:
2016 testResult = main.intentFunction.testPointIntent(
2017 main,
2018 intentId=installResult,
2019 name="ENCAPSULATION",
2020 senders=senders,
2021 recipients=recipients,
2022 badSenders=badSenders,
2023 badRecipients=badRecipients,
2024 sw1="s5",
2025 sw2="s2",
2026 expectedLink=18 )
2027 else:
2028 main.CLIs[ 0 ].removeAllIntents( purge=True )
2029
2030 utilities.assert_equals( expect=main.TRUE,
2031 actual=testResult,
2032 onpass=main.assertReturnString,
2033 onfail=main.assertReturnString )
2034
alison52b25892016-09-19 10:53:48 -07002035 # Testing MPLS would need to update kernel version (Right now is 3.16)
2036 # main.step( "ENCAPSULATION: Add multi point to single point intents" )
2037 # main.assertReturnString = "Assertion results for MPLS Encapsulation multi to single point intent\n"
2038 # senders = [
2039 # { "name": "h16", "device": "of:0000000000000006/8" },
2040 # { "name": "h24", "device": "of:0000000000000007/8" }
2041 # ]
2042 # recipients = [
2043 # { "name": "h8", "device": "of:0000000000000005/8" }
2044 # ]
2045 # badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
2046 # badRecipients = [ {"name": "h9" } ] # Recipients that are not in the intent
2047 # testResult = main.FALSE
2048 # installResult = main.intentFunction.installMultiToSingleIntent(
2049 # main,
2050 # name="ENCAPSULATION",
2051 # senders=senders,
2052 # recipients=recipients,
2053 # sw1="s5",
2054 # sw2="s2",
2055 # encap="MPLS" )
2056 #
2057 # if installResult:
2058 # testResult = main.intentFunction.testPointIntent(
2059 # main,
2060 # intentId=installResult,
2061 # name="ENCAPSULATION",
2062 # senders=senders,
2063 # recipients=recipients,
2064 # badSenders=badSenders,
2065 # badRecipients=badRecipients,
2066 # sw1="s5",
2067 # sw2="s2",
2068 # expectedLink=18 )
2069 # else:
2070 # main.CLIs[ 0 ].removeAllIntents( purge=True )
2071 #
2072 # utilities.assert_equals( expect=main.TRUE,
2073 # actual=testResult,
2074 # onpass=main.assertReturnString,
2075 # onfail=main.assertReturnString )
2076
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002077 main.intentFunction.report( main )
2078
acsmars1ff5e052015-07-23 11:27:48 -07002079 def CASE5000( self, main ):
2080 """
acsmars5d8cc862015-09-25 09:44:50 -07002081 Tests Host Mobility
2082 Modifies the topology location of h1
acsmars1ff5e052015-07-23 11:27:48 -07002083 """
Jeremyd9e4eb12016-04-13 12:09:06 -07002084 if main.initialized == main.FALSE:
2085 main.log.error( "Test components did not start correctly, skipping further tests" )
2086 main.skipCase()
acsmars1ff5e052015-07-23 11:27:48 -07002087 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07002088 try:
2089 assert main.CLIs
2090 except AssertionError:
2091 main.log.error( "There is no main.CLIs, skipping test cases" )
2092 main.initialized = main.FALSE
2093 main.skipCase()
2094 try:
2095 assert main.Mininet1
2096 except AssertionError:
2097 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
2098 main.initialized = main.FALSE
2099 main.skipCase()
2100 try:
2101 assert main.numSwitch
2102 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002103 main.log.error( "Place the total number of switch topology in "+\
2104 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07002105 main.initialized = main.FALSE
2106 main.skipCase()
alison52b25892016-09-19 10:53:48 -07002107 main.case( "Test host mobility with host intents " + " - " + str( main.numCtrls ) +
2108 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002109 main.step( "Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07002110
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002111 main.log.info( "Moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07002112 main.Mininet1.moveHost( "h1","s5","s6" )
2113
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002114 # Send discovery ping from moved host
2115 # Moving the host brings down the default interfaces and creates a new one.
2116 # Scapy is restarted on this host to detect the new interface
2117 main.h1.stopScapy()
2118 main.h1.startScapy()
2119
2120 # Discover new host location in ONOS and populate host data.
2121 # Host 1 IP and MAC should be unchanged
2122 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
2123 main.intentFunction.populateHostData( main )
2124
acsmars1ff5e052015-07-23 11:27:48 -07002125 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
2126
2127 utilities.assert_equals( expect="of:0000000000000006",
2128 actual=h1PostMove,
2129 onpass="Mobility: Successfully moved h1 to s6",
acsmars5d8cc862015-09-25 09:44:50 -07002130 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07002131 " to single point intents" +
2132 " with IPV4 type and MAC addresses" +
2133 " in the same VLAN" )
2134
2135 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07002136 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002137 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
2138 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
Jeremy42df2e72016-02-23 16:37:46 -08002139 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002140 installResult = main.intentFunction.installHostIntent( main,
alison52b25892016-09-19 10:53:48 -07002141 name="IPV4 Mobility IPV4",
2142 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002143 host1=host1,
Jeremye0cb5eb2016-01-27 17:39:09 -08002144 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -08002145 if installResult:
2146 testResult = main.intentFunction.testHostIntent( main,
alison52b25892016-09-19 10:53:48 -07002147 name="Host Mobility IPV4",
Jeremy2f190ca2016-01-29 15:23:57 -08002148 intentId = installResult,
alison52b25892016-09-19 10:53:48 -07002149 onosNode=0,
Jeremy2f190ca2016-01-29 15:23:57 -08002150 host1=host1,
2151 host2=host2,
2152 sw1="s6",
2153 sw2="s2",
2154 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08002155 else:
2156 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07002157
2158 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002159 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07002160 onpass=main.assertReturnString,
2161 onfail=main.assertReturnString )
kelvin-onlab016dce22015-08-10 09:54:11 -07002162
2163 main.intentFunction.report( main )
Jeremye0cb5eb2016-01-27 17:39:09 -08002164
2165 def CASE6000( self, main ):
2166 """
2167 Tests Multi to Single Point Intent and Single to Multi Point Intent End Point Failure
2168 """
Jeremy Songster9385d412016-06-02 17:57:36 -07002169 # At some later point discussion on this behavior in MPSP and SPMP intents
2170 # will be reoppened and this test case may need to be updated to reflect
2171 # the outcomes of that discussion
Jeremyd9e4eb12016-04-13 12:09:06 -07002172 if main.initialized == main.FALSE:
2173 main.log.error( "Test components did not start correctly, skipping further tests" )
2174 main.skipCase()
Jeremye0cb5eb2016-01-27 17:39:09 -08002175 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07002176 try:
2177 assert main.CLIs
2178 except AssertionError:
2179 main.log.error( "There is no main.CLIs, skipping test cases" )
2180 main.initialized = main.FALSE
2181 main.skipCase()
2182 try:
2183 assert main.Mininet1
2184 except AssertionError:
2185 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
2186 main.initialized = main.FALSE
2187 main.skipCase()
2188 try:
2189 assert main.numSwitch
2190 except AssertionError:
alison52b25892016-09-19 10:53:48 -07002191 main.log.error( "Place the total number of switch topology in " + main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07002192 main.initialized = main.FALSE
2193 main.skipCase()
alison52b25892016-09-19 10:53:48 -07002194 main.case( "Test Multi to Single End Point Failure" + " - " + str( main.numCtrls ) +
2195 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jeremy Songster9385d412016-06-02 17:57:36 -07002196 main.step( "Installing Multi to Single Point intents with no options set" )
2197 main.assertReturnString = "Assertion results for IPV4 multi to single " +\
2198 "point intent end point failure with no options set\n"
Jeremye0cb5eb2016-01-27 17:39:09 -08002199 senders = [
2200 { "name":"h16", "device":"of:0000000000000006/8" },
2201 { "name":"h24", "device":"of:0000000000000007/8" }
2202 ]
2203 recipients = [
2204 { "name":"h8", "device":"of:0000000000000005/8" }
2205 ]
2206 isolatedSenders = [
alison52b25892016-09-19 10:53:48 -07002207 { "name":"h24" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002208 ]
2209 isolatedRecipients = []
2210 testResult = main.FALSE
2211 installResult = main.intentFunction.installMultiToSingleIntent(
2212 main,
2213 name="NOOPTION",
2214 senders=senders,
2215 recipients=recipients,
2216 sw1="s5",
2217 sw2="s2" )
2218
2219 if installResult:
2220 testResult = main.intentFunction.testEndPointFail(
2221 main,
2222 intentId=installResult,
2223 name="NOOPTION",
2224 senders=senders,
2225 recipients=recipients,
2226 isolatedSenders=isolatedSenders,
2227 isolatedRecipients=isolatedRecipients,
2228 sw1="s6",
2229 sw2="s2",
2230 sw3="s4",
2231 sw4="s1",
2232 sw5="s3",
2233 expectedLink1=16,
2234 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002235 else:
2236 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002237
2238 utilities.assert_equals( expect=main.TRUE,
2239 actual=testResult,
2240 onpass=main.assertReturnString,
2241 onfail=main.assertReturnString )
2242
Jeremy Songster9385d412016-06-02 17:57:36 -07002243 main.step( "Installing Multi to Single Point intents with partial failure allowed" )
2244
2245 main.assertReturnString = "Assertion results for IPV4 multi to single " +\
2246 "with partial failures allowed\n"
2247 senders = [
2248 { "name":"h16", "device":"of:0000000000000006/8" },
2249 { "name":"h24", "device":"of:0000000000000007/8" }
2250 ]
2251 recipients = [
2252 { "name":"h8", "device":"of:0000000000000005/8" }
2253 ]
2254 isolatedSenders = [
alison52b25892016-09-19 10:53:48 -07002255 { "name":"h24" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002256 ]
2257 isolatedRecipients = []
2258 testResult = main.FALSE
Jeremy Songster9385d412016-06-02 17:57:36 -07002259 installResult = main.intentFunction.installMultiToSingleIntent(
2260 main,
2261 name="NOOPTION",
2262 senders=senders,
2263 recipients=recipients,
2264 sw1="s5",
2265 sw2="s2",
2266 partial=True )
2267
2268 if installResult:
2269 testResult = main.intentFunction.testEndPointFail(
2270 main,
2271 intentId=installResult,
2272 name="NOOPTION",
2273 senders=senders,
2274 recipients=recipients,
2275 isolatedSenders=isolatedSenders,
2276 isolatedRecipients=isolatedRecipients,
2277 sw1="s6",
2278 sw2="s2",
2279 sw3="s4",
2280 sw4="s1",
2281 sw5="s3",
2282 expectedLink1=16,
2283 expectedLink2=14,
2284 partial=True )
2285 else:
2286 main.CLIs[ 0 ].removeAllIntents( purge=True )
2287
2288 utilities.assert_equals( expect=main.TRUE,
2289 actual=testResult,
2290 onpass=main.assertReturnString,
2291 onfail=main.assertReturnString )
2292
Jeremye0cb5eb2016-01-27 17:39:09 -08002293 main.step( "NOOPTION: Install and test single point to multi point intents" )
Jeremy Songster9385d412016-06-02 17:57:36 -07002294 main.assertReturnString = "Assertion results for IPV4 single to multi " +\
2295 "point intent with no options set\n"
Jeremye0cb5eb2016-01-27 17:39:09 -08002296 senders = [
2297 { "name":"h8", "device":"of:0000000000000005/8" }
2298 ]
2299 recipients = [
2300 { "name":"h16", "device":"of:0000000000000006/8" },
2301 { "name":"h24", "device":"of:0000000000000007/8" }
2302 ]
Jeremy Songster9385d412016-06-02 17:57:36 -07002303 isolatedSenders = []
2304 isolatedRecipients = [
alison52b25892016-09-19 10:53:48 -07002305 { "name":"h24" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002306 ]
2307 testResult = main.FALSE
2308 installResult = main.intentFunction.installSingleToMultiIntent(
2309 main,
2310 name="NOOPTION",
2311 senders=senders,
2312 recipients=recipients,
2313 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002314 sw2="s2" )
Jeremye0cb5eb2016-01-27 17:39:09 -08002315
2316 if installResult:
2317 testResult = main.intentFunction.testEndPointFail(
2318 main,
2319 intentId=installResult,
2320 name="NOOPTION",
2321 senders=senders,
2322 recipients=recipients,
2323 isolatedSenders=isolatedSenders,
2324 isolatedRecipients=isolatedRecipients,
2325 sw1="s6",
2326 sw2="s2",
2327 sw3="s4",
2328 sw4="s1",
2329 sw5="s3",
2330 expectedLink1=16,
2331 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002332 else:
2333 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002334
2335 utilities.assert_equals( expect=main.TRUE,
2336 actual=testResult,
2337 onpass=main.assertReturnString,
2338 onfail=main.assertReturnString )
Jeremy Songster9385d412016-06-02 17:57:36 -07002339 # Right now this functionality doesn't work properly in SPMP intents
2340 main.step( "NOOPTION: Install and test single point to multi point " +\
2341 "intents with partial failures allowed" )
2342 main.assertReturnString = "Assertion results for IPV4 single to multi " +\
2343 "point intent with partial failures allowed\n"
2344 senders = [
2345 { "name":"h8", "device":"of:0000000000000005/8" }
2346 ]
2347 recipients = [
2348 { "name":"h16", "device":"of:0000000000000006/8" },
2349 { "name":"h24", "device":"of:0000000000000007/8" }
2350 ]
2351 isolatedSenders = []
2352 isolatedRecipients = [
alison52b25892016-09-19 10:53:48 -07002353 { "name":"h24" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002354 ]
2355 testResult = main.FALSE
Jeremy Songster9385d412016-06-02 17:57:36 -07002356 installResult = main.intentFunction.installSingleToMultiIntent(
2357 main,
2358 name="NOOPTION",
2359 senders=senders,
2360 recipients=recipients,
2361 sw1="s5",
2362 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002363 partial=True )
Jeremy Songster9385d412016-06-02 17:57:36 -07002364
2365 if installResult:
2366 testResult = main.intentFunction.testEndPointFail(
2367 main,
2368 intentId=installResult,
2369 name="NOOPTION",
2370 senders=senders,
2371 recipients=recipients,
2372 isolatedSenders=isolatedSenders,
2373 isolatedRecipients=isolatedRecipients,
2374 sw1="s6",
2375 sw2="s2",
2376 sw3="s4",
2377 sw4="s1",
2378 sw5="s3",
2379 expectedLink1=16,
2380 expectedLink2=14,
2381 partial=True )
2382 else:
2383 main.CLIs[ 0 ].removeAllIntents( purge=True )
2384
2385 utilities.assert_equals( expect=main.TRUE,
2386 actual=testResult,
2387 onpass=main.assertReturnString,
2388 onfail=main.assertReturnString )
Jeremye0cb5eb2016-01-27 17:39:09 -08002389
Chiyu Chengef109502016-11-21 15:51:38 -08002390 main.intentFunction.report( main )