blob: 62974644ce99c8c4f35663a6c82725999810a70f [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
You Wangf5de25b2017-01-06 15:13:01 -0800208 main.step( "Set up ONOS secure SSH" )
209 secureSshResult = main.TRUE
210 for i in range( int( main.numCtrls ) ):
211 secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
212 utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
213 onpass="Test step PASS",
214 onfail="Test step FAIL" )
215
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700216 time.sleep( main.startUpSleep )
217 main.step( "Starting ONOS service" )
218 stopResult = main.TRUE
219 startResult = main.TRUE
220 onosIsUp = main.TRUE
221
222 for i in range( main.numCtrls ):
Jeremy Songster7edb6632016-04-28 15:44:28 -0700223 isUp = main.ONOSbench.isup( main.ONOSip[ i ] )
224 onosIsUp = onosIsUp and isUp
225 if isUp == main.TRUE:
Jeremyd9e4eb12016-04-13 12:09:06 -0700226 main.log.report( "ONOS instance {0} is up and ready".format( i + 1 ) )
227 else:
228 main.log.report( "ONOS instance {0} may not be up, stop and ".format( i + 1 ) +
229 "start ONOS again " )
230 stopResult = stopResult and main.ONOSbench.onosStop( main.ONOSip[ i ] )
231 startResult = startResult and main.ONOSbench.onosStart( main.ONOSip[ i ] )
232 if not startResult or stopResult:
233 main.log.report( "ONOS instance {0} did not start correctly.".format( i + 1) )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700234 stepResult = onosIsUp and stopResult and startResult
235 utilities.assert_equals( expect=main.TRUE,
236 actual=stepResult,
Jeremyd9e4eb12016-04-13 12:09:06 -0700237 onpass="ONOS service is ready on all nodes",
238 onfail="ONOS service did not start properly on all nodes" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700239
240 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 )
alisonda157272016-12-22 01:13:21 -08001122
1123 main.step("Protected: Add point intents between h1 and h9")
1124 main.assertReturnString = "Assertion Result for protected point intent\n"
1125 senders = [
1126 {"name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01"}
1127 ]
1128 recipients = [
1129 {"name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09"}
1130 ]
1131 testResult = main.FALSE
1132 installResult = main.intentFunction.installPointIntent(
1133 main,
1134 name="Protected",
1135 senders=senders,
1136 recipients=recipients,
1137 protected=True )
1138
1139 if installResult:
1140 testResult = main.intentFunction.testPointIntent(
1141 main,
1142 name="Protected",
1143 intentId=installResult,
1144 senders=senders,
1145 recipients=recipients,
1146 sw1="s5",
1147 sw2="s2",
1148 protected=True,
1149 expectedLink=18 )
1150 else:
1151 main.CLIs[ 0 ].removeAllIntents( purge=True )
1152
1153 utilities.assert_equals( expect=main.TRUE,
1154 actual=testResult,
1155 onpass=main.assertReturnString,
1156 onfail=main.assertReturnString )
1157
kelvin-onlabb769f562015-07-15 17:05:10 -07001158 main.step( "IPV4_2: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001159 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001160 senders = [
1161 { "name":"h1","device":"of:0000000000000005/1" }
1162 ]
1163 recipients = [
1164 { "name":"h9","device":"of:0000000000000006/1" }
1165 ]
Jeremy42df2e72016-02-23 16:37:46 -08001166 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001167 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001168 main,
1169 name="IPV4_2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001170 senders=senders,
1171 recipients=recipients,
1172 ethType="IPV4" )
1173
1174 if installResult:
1175 testResult = main.intentFunction.testPointIntent(
1176 main,
1177 intentId=installResult,
1178 name="IPV4_2",
1179 senders=senders,
1180 recipients=recipients,
1181 sw1="s5",
1182 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001183 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001184 else:
1185 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001186
1187 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001188 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001189 onpass=main.assertReturnString,
1190 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001191
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001192 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001193 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001194 senders = [
1195 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01",
Jeremy6f000c62016-02-25 17:02:28 -08001196 "ip":( main.h1.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001197 ]
1198 recipients = [
1199 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09",
Jeremy6f000c62016-02-25 17:02:28 -08001200 "ip":( main.h9.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001201 ]
Jeremy6f000c62016-02-25 17:02:28 -08001202 ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ]
kelvin-onlab79ce0492015-07-27 16:14:39 -07001203 # Uneccessary, not including this in the selectors
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001204 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
1205 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
Jeremy42df2e72016-02-23 16:37:46 -08001206 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001207 installResult = main.intentFunction.installPointIntent(
1208 main,
1209 name="SDNIP-ICMP",
1210 senders=senders,
1211 recipients=recipients,
1212 ethType="IPV4",
1213 ipProto=ipProto,
1214 tcpSrc=tcpSrc,
1215 tcpDst=tcpDst )
1216
1217 if installResult:
1218 testResult = main.intentFunction.testPointIntent(
1219 main,
1220 intentId=installResult,
1221 name="SDNIP_ICMP",
1222 senders=senders,
1223 recipients=recipients,
1224 sw1="s5",
1225 sw2="s2",
Jeremy Songstere405d3d2016-05-17 11:18:57 -07001226 expectedLink=18,
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001227 useTCP=True )
Jeremy42df2e72016-02-23 16:37:46 -08001228 else:
1229 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabb769f562015-07-15 17:05:10 -07001230
1231 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001232 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001233 onpass=main.assertReturnString,
1234 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001235
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001236 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001237 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
kelvin-onlabb769f562015-07-15 17:05:10 -07001238 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
1239 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab58dc39e2015-08-06 08:11:09 -07001240 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
1241 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlabb769f562015-07-15 17:05:10 -07001242 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
1243 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
1244 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
1245
kelvin-onlab58dc39e2015-08-06 08:11:09 -07001246 stepResult = main.intentFunction.pointIntentTcp(
kelvin-onlabb769f562015-07-15 17:05:10 -07001247 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001248 name="SDNIP-TCP",
kelvin-onlabb769f562015-07-15 17:05:10 -07001249 host1="h1",
1250 host2="h9",
1251 deviceId1="of:0000000000000005/1",
1252 deviceId2="of:0000000000000006/1",
1253 mac1=mac1,
1254 mac2=mac2,
1255 ethType="IPV4",
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001256 ipProto=ipProto,
1257 ip1=ip1,
1258 ip2=ip2,
1259 tcp1=tcp1,
1260 tcp2=tcp2 )
kelvin-onlabb769f562015-07-15 17:05:10 -07001261
1262 utilities.assert_equals( expect=main.TRUE,
Jeremy6f000c62016-02-25 17:02:28 -08001263 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -07001264 onpass=main.assertReturnString,
1265 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001266
acsmars5d8cc862015-09-25 09:44:50 -07001267 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
1268 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001269 senders = [
1270 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1271 ]
1272 recipients = [
1273 { "name":"h11","device":"of:0000000000000006/3","mac":"00:00:00:00:00:0B" }
1274 ]
Jeremy42df2e72016-02-23 16:37:46 -08001275 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001276 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001277 main,
1278 name="DUALSTACK1",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001279 senders=senders,
1280 recipients=recipients,
1281 ethType="IPV4" )
1282
1283 if installResult:
1284 testResult = main.intentFunction.testPointIntent(
1285 main,
1286 intentId=installResult,
1287 name="DUALSTACK1",
1288 senders=senders,
1289 recipients=recipients,
1290 sw1="s5",
1291 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001292 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001293 else:
1294 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001295
1296 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001297 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001298 onpass=main.assertReturnString,
1299 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001300
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001301 main.step( "VLAN: Add point intents between h5 and h21" )
acsmars5d8cc862015-09-25 09:44:50 -07001302 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001303 senders = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001304 { "name":"h5","device":"of:0000000000000005/5","mac":"00:00:00:00:00:05", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001305 ]
1306 recipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001307 { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001308 ]
Jeremy42df2e72016-02-23 16:37:46 -08001309 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001310 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001311 main,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001312 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001313 senders=senders,
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001314 recipients=recipients )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001315
1316 if installResult:
1317 testResult = main.intentFunction.testPointIntent(
1318 main,
1319 intentId=installResult,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001320 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001321 senders=senders,
1322 recipients=recipients,
1323 sw1="s5",
1324 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001325 expectedLink=18 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001326
1327 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001328 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001329 onpass=main.assertReturnString,
1330 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001331
Jeremy Songsterff553672016-05-12 17:06:23 -07001332 main.step( "VLAN: Add point intents between h5 and h21" )
1333 main.assertReturnString = "Assertion Result for VLAN IPV4 point intents with VLAN treatment\n"
1334 senders = [
1335 { "name":"h4", "vlan":"100" }
1336 ]
1337 recipients = [
1338 { "name":"h21", "vlan":"200" }
1339 ]
1340 testResult = main.FALSE
Jeremy Songsterff553672016-05-12 17:06:23 -07001341 installResult = main.intentFunction.installPointIntent(
1342 main,
1343 name="VLAN2",
1344 senders=senders,
1345 recipients=recipients,
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001346 setVlan=200 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001347
1348 if installResult:
1349 testResult = main.intentFunction.testPointIntent(
1350 main,
1351 intentId=installResult,
1352 name="VLAN2",
1353 senders=senders,
1354 recipients=recipients,
1355 sw1="s5",
1356 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001357 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001358
1359 utilities.assert_equals( expect=main.TRUE,
1360 actual=testResult,
1361 onpass=main.assertReturnString,
1362 onfail=main.assertReturnString )
1363
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001364 main.step( "1HOP: Add point intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -07001365 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001366 senders = [
1367 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1368 ]
1369 recipients = [
1370 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1371 ]
Jeremy42df2e72016-02-23 16:37:46 -08001372 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001373 installResult = main.intentFunction.installPointIntent(
1374 main,
1375 name="1HOP IPV4",
1376 senders=senders,
1377 recipients=recipients,
1378 ethType="IPV4" )
1379
1380 if installResult:
1381 testResult = main.intentFunction.testPointIntent(
1382 main,
1383 intentId=installResult,
1384 name="1HOP IPV4",
1385 senders=senders,
1386 recipients=recipients,
1387 sw1="s5",
1388 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001389 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001390 else:
1391 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001392
1393 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001394 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001395 onpass=main.assertReturnString,
1396 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001397
Jeremy Songsterc032f162016-08-04 17:14:49 -07001398 main.step( "Add point to point intents using VLAN Encapsulation" )
1399 main.assertReturnString = "Assertion Result for VLAN Encapsulation Point Intent"
1400 senders = [
1401 { "name":"h1","device":"of:0000000000000005/1" }
1402 ]
1403 recipients = [
1404 { "name":"h9","device":"of:0000000000000006/1" }
1405 ]
1406 testResult = main.FALSE
Jeremy Songsterc032f162016-08-04 17:14:49 -07001407 installResult = main.intentFunction.installPointIntent(
1408 main,
1409 name="ENCAPSULATION",
1410 senders=senders,
1411 recipients=recipients,
1412 encap="VLAN" )
1413
1414 if installResult:
1415 testResult = main.intentFunction.testPointIntent(
1416 main,
1417 intentId=installResult,
1418 name="ENCAPSULATION",
1419 senders=senders,
1420 recipients=recipients,
1421 sw1="s5",
1422 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001423 expectedLink=18 )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001424 else:
1425 main.CLIs[ 0 ].removeAllIntents( purge=True )
1426
1427 utilities.assert_equals( expect=main.TRUE,
1428 actual=testResult,
1429 onpass=main.assertReturnString,
1430 onfail=main.assertReturnString )
1431
alison52b25892016-09-19 10:53:48 -07001432 # Testing MPLS would need to update kernel version (Right now is 3.16)
1433 # main.step( "Add point to point intents using MPLS Encapsulation" )
1434 # main.assertReturnString = "Assertion Result for MPLS Encapsulation Point Intent"
1435 # senders = [
1436 # { "name": "h1", "device": "of:0000000000000005/1" }
1437 # ]
1438 # recipients = [
1439 # { "name": "h9", "device": "of:0000000000000006/1" }
1440 # ]
1441 # testResult = main.FALSE
1442 # installResult = main.intentFunction.installPointIntent(
1443 # main,
1444 # name="ENCAPSULATION",
1445 # senders=senders,
1446 # recipients=recipients,
1447 # encap="MPLS" )
1448 #
1449 # if installResult:
1450 # testResult = main.intentFunction.testPointIntent(
1451 # main,
1452 # intentId=installResult,
1453 # name="ENCAPSULATION",
1454 # senders=senders,
1455 # recipients=recipients,
1456 # sw1="s5",
1457 # sw2="s2",
1458 # expectedLink=18 )
1459 # else:
1460 # main.CLIs[ 0 ].removeAllIntents( purge=True )
1461 #
1462 # utilities.assert_equals( expect=main.TRUE,
1463 # actual=testResult,
1464 # onpass=main.assertReturnString,
1465 # onfail=main.assertReturnString )
1466
kelvin-onlab016dce22015-08-10 09:54:11 -07001467 main.intentFunction.report( main )
1468
kelvin-onlabb769f562015-07-15 17:05:10 -07001469 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001470 """
1471 Add single point to multi point intents
1472 - Get device ids
1473 - Add single point to multi point intents
1474 - Check intents
1475 - Verify flows
1476 - Ping hosts
1477 - Reroute
1478 - Link down
1479 - Verify flows
1480 - Check topology
1481 - Ping hosts
1482 - Link up
1483 - Verify flows
1484 - Check topology
1485 - Ping hosts
1486 - Remove intents
1487 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001488 if main.initialized == main.FALSE:
1489 main.log.error( "Test components did not start correctly, skipping further tests" )
1490 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001491 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001492 try:
1493 assert main.CLIs
1494 except AssertionError:
1495 main.log.error( "There is no main.CLIs, skipping test cases" )
1496 main.initialized = main.FALSE
1497 main.skipCase()
1498 try:
1499 assert main.Mininet1
1500 except AssertionError:
1501 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1502 main.initialized = main.FALSE
1503 main.skipCase()
1504 try:
1505 assert main.numSwitch
1506 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001507 main.log.error( "Place the total number of switch topology in "+ \
1508 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001509 main.initialized = main.FALSE
1510 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001511
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001512 main.testName = "Single to Multi Point Intents"
1513 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001514 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001515 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001516 " multi point intents using " +\
1517 str( main.numCtrls ) + " node(s) cluster;\n" +\
1518 "Different type of hosts will be tested in " +\
1519 "each step such as IPV4, Dual stack, VLAN etc" +\
1520 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001521 " OVS running in Mininet and compile intents" +\
1522 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001523
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001524 main.step( "NOOPTION: Install and test single point to multi point intents" )
1525 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
1526 senders = [
1527 { "name":"h8", "device":"of:0000000000000005/8" }
1528 ]
1529 recipients = [
1530 { "name":"h16", "device":"of:0000000000000006/8" },
1531 { "name":"h24", "device":"of:0000000000000007/8" }
1532 ]
1533 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1534 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1535 testResult = main.FALSE
1536 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001537 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001538 name="NOOPTION",
1539 senders=senders,
1540 recipients=recipients,
1541 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001542 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001543
1544 if installResult:
1545 testResult = main.intentFunction.testPointIntent(
1546 main,
1547 intentId=installResult,
1548 name="NOOPTION",
1549 senders=senders,
1550 recipients=recipients,
1551 badSenders=badSenders,
1552 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001553 sw1="s5",
1554 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001555 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001556 else:
1557 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001558
1559 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001560 actual=testResult,
1561 onpass=main.assertReturnString,
1562 onfail=main.assertReturnString )
1563
1564 main.step( "IPV4: Install and test single point to multi point intents" )
1565 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses\n"
1566 senders = [
1567 { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" }
1568 ]
1569 recipients = [
1570 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1571 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1572 ]
1573 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1574 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1575 testResult = main.FALSE
1576 installResult = main.intentFunction.installSingleToMultiIntent(
1577 main,
1578 name="IPV4",
1579 senders=senders,
1580 recipients=recipients,
1581 ethType="IPV4",
1582 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001583 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001584
1585 if installResult:
1586 testResult = main.intentFunction.testPointIntent(
1587 main,
1588 intentId=installResult,
1589 name="IPV4",
1590 senders=senders,
1591 recipients=recipients,
1592 badSenders=badSenders,
1593 badRecipients=badRecipients,
1594 sw1="s5",
1595 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001596 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001597 else:
1598 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001599
1600 utilities.assert_equals( expect=main.TRUE,
1601 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001602 onpass=main.assertReturnString,
1603 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001604
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001605 main.step( "IPV4_2: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001606 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 -08001607 senders = [
1608 { "name":"h8", "device":"of:0000000000000005/8" }
1609 ]
1610 recipients = [
1611 { "name":"h16", "device":"of:0000000000000006/8" },
1612 { "name":"h24", "device":"of:0000000000000007/8" }
1613 ]
1614 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1615 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1616 testResult = main.FALSE
1617 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001618 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001619 name="IPV4_2",
1620 senders=senders,
1621 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001622 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001623 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001624 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001625
1626 if installResult:
1627 testResult = main.intentFunction.testPointIntent(
1628 main,
1629 intentId=installResult,
1630 name="IPV4_2",
1631 senders=senders,
1632 recipients=recipients,
1633 badSenders=badSenders,
1634 badRecipients=badRecipients,
1635 sw1="s5",
1636 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001637 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001638 else:
1639 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001640
1641 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001642 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001643 onpass=main.assertReturnString,
1644 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001645
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001646 main.step( "VLAN: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001647 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 -08001648 senders = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001649 { "name":"h4", "device":"of:0000000000000005/4", "mac":"00:00:00:00:00:04", "vlan":"100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001650 ]
1651 recipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001652 { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C", "vlan":"100" },
1653 { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14", "vlan":"100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001654 ]
1655 badSenders=[ { "name":"h13" } ] # Senders that are not in the intent
1656 badRecipients=[ { "name":"h21" } ] # Recipients that are not in the intent
1657 testResult = main.FALSE
1658 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001659 main,
alison52b25892016-09-19 10:53:48 -07001660 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001661 senders=senders,
1662 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001663 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001664 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001665
1666 if installResult:
1667 testResult = main.intentFunction.testPointIntent(
1668 main,
1669 intentId=installResult,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001670 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001671 senders=senders,
1672 recipients=recipients,
1673 badSenders=badSenders,
1674 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001675 sw1="s5",
1676 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001677 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001678 else:
1679 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001680
1681 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001682 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001683 onpass=main.assertReturnString,
1684 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001685
Jeremy Songsterff553672016-05-12 17:06:23 -07001686 main.step( "VLAN: Add single point to multi point intents" )
1687 main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n"
1688 senders = [
1689 { "name":"h5", "vlan":"200" }
1690 ]
1691 recipients = [
1692 { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C", "vlan":"100" },
1693 { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14", "vlan":"100" }
1694 ]
1695 badSenders=[ { "name":"h13" } ] # Senders that are not in the intent
1696 badRecipients=[ { "name":"h21" } ] # Recipients that are not in the intent
1697 testResult = main.FALSE
Jeremy Songsterff553672016-05-12 17:06:23 -07001698 installResult = main.intentFunction.installSingleToMultiIntent(
1699 main,
1700 name="VLAN2",
1701 senders=senders,
1702 recipients=recipients,
1703 sw1="s5",
1704 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001705 setVlan=100 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001706
1707 if installResult:
1708 testResult = main.intentFunction.testPointIntent(
1709 main,
1710 intentId=installResult,
1711 name="VLAN2",
1712 senders=senders,
1713 recipients=recipients,
1714 badSenders=badSenders,
1715 badRecipients=badRecipients,
1716 sw1="s5",
1717 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001718 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001719 else:
1720 main.CLIs[ 0 ].removeAllIntents( purge=True )
1721
1722 utilities.assert_equals( expect=main.TRUE,
1723 actual=testResult,
1724 onpass=main.assertReturnString,
1725 onfail=main.assertReturnString )
1726
alison52b25892016-09-19 10:53:48 -07001727 # Does not support Single point to multi point encapsulation
1728 # main.step( "ENCAPSULATION: Install and test single point to multi point intents" )
1729 # main.assertReturnString = "Assertion results for VLAN Encapsulation single to multi point intent\n"
1730 # senders = [
1731 # { "name":"h8", "device":"of:0000000000000005/8" }
1732 # ]
1733 # recipients = [
1734 # { "name":"h16", "device":"of:0000000000000006/8" },
1735 # { "name":"h24", "device":"of:0000000000000007/8" }
1736 # ]
1737 # badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1738 # badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1739 # testResult = main.FALSE
1740 # installResult = main.intentFunction.installSingleToMultiIntent(
1741 # main,
1742 # name="ENCAPSULATION",
1743 # senders=senders,
1744 # recipients=recipients,
1745 # sw1="s5",
1746 # sw2="s2",
1747 # encap="VLAN" )
1748 #
1749 # if installResult:
1750 # testResult = main.intentFunction.testPointIntent(
1751 # main,
1752 # intentId=installResult,
1753 # name="ENCAPSULATION",
1754 # senders=senders,
1755 # recipients=recipients,
1756 # badSenders=badSenders,
1757 # badRecipients=badRecipients,
1758 # sw1="s5",
1759 # sw2="s2",
1760 # expectedLink=18 )
1761 # else:
1762 # main.CLIs[ 0 ].removeAllIntents( purge=True )
1763 #
1764 # utilities.assert_equals( expect=main.TRUE,
1765 # actual=testResult,
1766 # onpass=main.assertReturnString,
1767 # onfail=main.assertReturnString )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001768
kelvin-onlab016dce22015-08-10 09:54:11 -07001769 main.intentFunction.report( main )
1770
kelvin-onlabb769f562015-07-15 17:05:10 -07001771 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001772 """
1773 Add multi point to single point intents
1774 - Get device ids
1775 - Add multi point to single point intents
1776 - Check intents
1777 - Verify flows
1778 - Ping hosts
1779 - Reroute
1780 - Link down
1781 - Verify flows
1782 - Check topology
1783 - Ping hosts
1784 - Link up
1785 - Verify flows
1786 - Check topology
1787 - Ping hosts
1788 - Remove intents
1789 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001790 if main.initialized == main.FALSE:
1791 main.log.error( "Test components did not start correctly, skipping further tests" )
1792 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001793 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001794 try:
1795 assert main.CLIs
1796 except AssertionError:
1797 main.log.error( "There is no main.CLIs, skipping test cases" )
1798 main.initialized = main.FALSE
1799 main.skipCase()
1800 try:
1801 assert main.Mininet1
1802 except AssertionError:
1803 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1804 main.initialized = main.FALSE
1805 main.skipCase()
1806 try:
1807 assert main.numSwitch
1808 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001809 main.log.error( "Place the total number of switch topology in "+\
1810 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001811 main.initialized = main.FALSE
1812 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001813
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001814 main.testName = "Multi To Single Point Intents"
1815 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001816 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001817 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001818 " multi point intents using " +\
1819 str( main.numCtrls ) + " node(s) cluster;\n" +\
1820 "Different type of hosts will be tested in " +\
1821 "each step such as IPV4, Dual stack, VLAN etc" +\
1822 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001823 " OVS running in Mininet and compile intents" +\
1824 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001825
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001826 main.step( "NOOPTION: Add multi point to single point intents" )
1827 main.assertReturnString = "Assertion results for NOOPTION multi to single point intent\n"
1828 senders = [
1829 { "name":"h16", "device":"of:0000000000000006/8" },
1830 { "name":"h24", "device":"of:0000000000000007/8" }
1831 ]
1832 recipients = [
1833 { "name":"h8", "device":"of:0000000000000005/8" }
1834 ]
1835 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1836 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1837 testResult = main.FALSE
1838 installResult = main.intentFunction.installMultiToSingleIntent(
1839 main,
1840 name="NOOPTION",
1841 senders=senders,
1842 recipients=recipients,
1843 sw1="s5",
Jeremye0cb5eb2016-01-27 17:39:09 -08001844 sw2="s2" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001845
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001846 if installResult:
1847 testResult = main.intentFunction.testPointIntent(
1848 main,
1849 intentId=installResult,
1850 name="NOOPTION",
1851 senders=senders,
1852 recipients=recipients,
1853 badSenders=badSenders,
1854 badRecipients=badRecipients,
1855 sw1="s5",
1856 sw2="s2",
Jeremye0cb5eb2016-01-27 17:39:09 -08001857 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001858 else:
1859 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001860
1861 utilities.assert_equals( expect=main.TRUE,
1862 actual=testResult,
1863 onpass=main.assertReturnString,
1864 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001865
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001866 main.step( "IPV4: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001867 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 -08001868 senders = [
1869 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1870 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1871 ]
1872 recipients = [
1873 { "name":"h8", "device":"of:0000000000000005/8", "mac":"00:00:00:00:00:08" }
1874 ]
1875 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1876 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1877 testResult = main.FALSE
1878 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001879 main,
1880 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001881 senders=senders,
1882 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001883 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001884 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001885 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001886
1887 if installResult:
1888 testResult = main.intentFunction.testPointIntent(
1889 main,
1890 intentId=installResult,
1891 name="IPV4",
1892 senders=senders,
1893 recipients=recipients,
1894 badSenders=badSenders,
1895 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001896 sw1="s5",
1897 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001898 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001899 else:
1900 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001901
1902 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001903 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001904 onpass=main.assertReturnString,
1905 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001906
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001907 main.step( "IPV4_2: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001908 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 -08001909 senders = [
1910 { "name":"h16", "device":"of:0000000000000006/8" },
1911 { "name":"h24", "device":"of:0000000000000007/8" }
1912 ]
1913 recipients = [
1914 { "name":"h8", "device":"of:0000000000000005/8" }
1915 ]
1916 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1917 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1918 testResult = main.FALSE
1919 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001920 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001921 name="IPV4_2",
1922 senders=senders,
1923 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001924 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001925 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001926 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001927
1928 if installResult:
1929 testResult = main.intentFunction.testPointIntent(
1930 main,
1931 intentId=installResult,
1932 name="IPV4_2",
1933 senders=senders,
1934 recipients=recipients,
1935 badSenders=badSenders,
1936 badRecipients=badRecipients,
1937 sw1="s5",
1938 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001939 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001940 else:
1941 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001942
1943 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001944 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001945 onpass=main.assertReturnString,
1946 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001947
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001948 main.step( "VLAN: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001949 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 -08001950 senders = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001951 { "name":"h13", "device":"of:0000000000000006/5", "vlan":"200" },
1952 { "name":"h21", "device":"of:0000000000000007/5", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001953 ]
1954 recipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001955 { "name":"h5", "device":"of:0000000000000005/5", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001956 ]
1957 badSenders=[ { "name":"h12" } ] # Senders that are not in the intent
1958 badRecipients=[ { "name":"h20" } ] # Recipients that are not in the intent
1959 testResult = main.FALSE
1960 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001961 main,
1962 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001963 senders=senders,
1964 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001965 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001966 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001967
1968 if installResult:
1969 testResult = main.intentFunction.testPointIntent(
1970 main,
1971 intentId=installResult,
1972 name="VLAN",
1973 senders=senders,
1974 recipients=recipients,
1975 badSenders=badSenders,
1976 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001977 sw1="s5",
1978 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001979 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001980 else:
1981 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001982
1983 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001984 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001985 onpass=main.assertReturnString,
1986 onfail=main.assertReturnString )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001987
Jeremy Songsterff553672016-05-12 17:06:23 -07001988 # Right now this fails because of this bug: https://jira.onosproject.org/browse/ONOS-4383
1989 main.step( "VLAN: Add multi point to single point intents" )
1990 main.assertReturnString = "Assertion results for multi to single point intent with VLAN ID treatment\n"
1991 senders = [
1992 { "name":"h13", "device":"of:0000000000000006/5", "vlan":"200" },
1993 { "name":"h21", "device":"of:0000000000000007/5", "vlan":"200" }
1994 ]
1995 recipients = [
1996 { "name":"h4", "vlan":"100" }
1997 ]
1998 badSenders=[ { "name":"h12" } ] # Senders that are not in the intent
1999 badRecipients=[ { "name":"h20" } ] # Recipients that are not in the intent
2000 testResult = main.FALSE
Jeremy Songsterff553672016-05-12 17:06:23 -07002001 installResult = main.intentFunction.installMultiToSingleIntent(
2002 main,
2003 name="VLAN2",
2004 senders=senders,
2005 recipients=recipients,
2006 sw1="s5",
2007 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002008 setVlan=100 )
Jeremy Songsterff553672016-05-12 17:06:23 -07002009
2010 if installResult:
2011 testResult = main.intentFunction.testPointIntent(
2012 main,
2013 intentId=installResult,
2014 name="VLAN2",
2015 senders=senders,
2016 recipients=recipients,
2017 badSenders=badSenders,
2018 badRecipients=badRecipients,
2019 sw1="s5",
2020 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002021 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07002022 else:
2023 main.CLIs[ 0 ].removeAllIntents( purge=True )
2024
2025 utilities.assert_equals( expect=main.TRUE,
2026 actual=testResult,
2027 onpass=main.assertReturnString,
2028 onfail=main.assertReturnString )
2029
Jeremy Songsterc032f162016-08-04 17:14:49 -07002030 main.step( "ENCAPSULATION: Add multi point to single point intents" )
2031 main.assertReturnString = "Assertion results for VLAN Encapsulation multi to single point intent\n"
2032 senders = [
2033 { "name":"h16", "device":"of:0000000000000006/8" },
2034 { "name":"h24", "device":"of:0000000000000007/8" }
2035 ]
2036 recipients = [
2037 { "name":"h8", "device":"of:0000000000000005/8" }
2038 ]
2039 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
2040 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
2041 testResult = main.FALSE
Jeremy Songsterc032f162016-08-04 17:14:49 -07002042 installResult = main.intentFunction.installMultiToSingleIntent(
2043 main,
2044 name="ENCAPSULATION",
2045 senders=senders,
2046 recipients=recipients,
2047 sw1="s5",
2048 sw2="s2",
2049 encap="VLAN" )
2050
2051 if installResult:
2052 testResult = main.intentFunction.testPointIntent(
2053 main,
2054 intentId=installResult,
2055 name="ENCAPSULATION",
2056 senders=senders,
2057 recipients=recipients,
2058 badSenders=badSenders,
2059 badRecipients=badRecipients,
2060 sw1="s5",
2061 sw2="s2",
2062 expectedLink=18 )
2063 else:
2064 main.CLIs[ 0 ].removeAllIntents( purge=True )
2065
2066 utilities.assert_equals( expect=main.TRUE,
2067 actual=testResult,
2068 onpass=main.assertReturnString,
2069 onfail=main.assertReturnString )
2070
alison52b25892016-09-19 10:53:48 -07002071 # Testing MPLS would need to update kernel version (Right now is 3.16)
2072 # main.step( "ENCAPSULATION: Add multi point to single point intents" )
2073 # main.assertReturnString = "Assertion results for MPLS Encapsulation multi to single point intent\n"
2074 # senders = [
2075 # { "name": "h16", "device": "of:0000000000000006/8" },
2076 # { "name": "h24", "device": "of:0000000000000007/8" }
2077 # ]
2078 # recipients = [
2079 # { "name": "h8", "device": "of:0000000000000005/8" }
2080 # ]
2081 # badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
2082 # badRecipients = [ {"name": "h9" } ] # Recipients that are not in the intent
2083 # testResult = main.FALSE
2084 # installResult = main.intentFunction.installMultiToSingleIntent(
2085 # main,
2086 # name="ENCAPSULATION",
2087 # senders=senders,
2088 # recipients=recipients,
2089 # sw1="s5",
2090 # sw2="s2",
2091 # encap="MPLS" )
2092 #
2093 # if installResult:
2094 # testResult = main.intentFunction.testPointIntent(
2095 # main,
2096 # intentId=installResult,
2097 # name="ENCAPSULATION",
2098 # senders=senders,
2099 # recipients=recipients,
2100 # badSenders=badSenders,
2101 # badRecipients=badRecipients,
2102 # sw1="s5",
2103 # sw2="s2",
2104 # expectedLink=18 )
2105 # else:
2106 # main.CLIs[ 0 ].removeAllIntents( purge=True )
2107 #
2108 # utilities.assert_equals( expect=main.TRUE,
2109 # actual=testResult,
2110 # onpass=main.assertReturnString,
2111 # onfail=main.assertReturnString )
2112
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002113 main.intentFunction.report( main )
2114
acsmars1ff5e052015-07-23 11:27:48 -07002115 def CASE5000( self, main ):
2116 """
acsmars5d8cc862015-09-25 09:44:50 -07002117 Tests Host Mobility
2118 Modifies the topology location of h1
acsmars1ff5e052015-07-23 11:27:48 -07002119 """
Jeremyd9e4eb12016-04-13 12:09:06 -07002120 if main.initialized == main.FALSE:
2121 main.log.error( "Test components did not start correctly, skipping further tests" )
2122 main.skipCase()
acsmars1ff5e052015-07-23 11:27:48 -07002123 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07002124 try:
2125 assert main.CLIs
2126 except AssertionError:
2127 main.log.error( "There is no main.CLIs, skipping test cases" )
2128 main.initialized = main.FALSE
2129 main.skipCase()
2130 try:
2131 assert main.Mininet1
2132 except AssertionError:
2133 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
2134 main.initialized = main.FALSE
2135 main.skipCase()
2136 try:
2137 assert main.numSwitch
2138 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002139 main.log.error( "Place the total number of switch topology in "+\
2140 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07002141 main.initialized = main.FALSE
2142 main.skipCase()
alison52b25892016-09-19 10:53:48 -07002143 main.case( "Test host mobility with host intents " + " - " + str( main.numCtrls ) +
2144 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002145 main.step( "Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07002146
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002147 main.log.info( "Moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07002148 main.Mininet1.moveHost( "h1","s5","s6" )
2149
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002150 # Send discovery ping from moved host
2151 # Moving the host brings down the default interfaces and creates a new one.
2152 # Scapy is restarted on this host to detect the new interface
2153 main.h1.stopScapy()
2154 main.h1.startScapy()
2155
2156 # Discover new host location in ONOS and populate host data.
2157 # Host 1 IP and MAC should be unchanged
2158 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
2159 main.intentFunction.populateHostData( main )
2160
acsmars1ff5e052015-07-23 11:27:48 -07002161 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
2162
2163 utilities.assert_equals( expect="of:0000000000000006",
2164 actual=h1PostMove,
2165 onpass="Mobility: Successfully moved h1 to s6",
acsmars5d8cc862015-09-25 09:44:50 -07002166 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07002167 " to single point intents" +
2168 " with IPV4 type and MAC addresses" +
2169 " in the same VLAN" )
2170
2171 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07002172 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002173 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
2174 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
Jeremy42df2e72016-02-23 16:37:46 -08002175 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002176 installResult = main.intentFunction.installHostIntent( main,
alison52b25892016-09-19 10:53:48 -07002177 name="IPV4 Mobility IPV4",
2178 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002179 host1=host1,
Jeremye0cb5eb2016-01-27 17:39:09 -08002180 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -08002181 if installResult:
2182 testResult = main.intentFunction.testHostIntent( main,
alison52b25892016-09-19 10:53:48 -07002183 name="Host Mobility IPV4",
Jeremy2f190ca2016-01-29 15:23:57 -08002184 intentId = installResult,
alison52b25892016-09-19 10:53:48 -07002185 onosNode=0,
Jeremy2f190ca2016-01-29 15:23:57 -08002186 host1=host1,
2187 host2=host2,
2188 sw1="s6",
2189 sw2="s2",
2190 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08002191 else:
2192 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07002193
2194 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002195 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07002196 onpass=main.assertReturnString,
2197 onfail=main.assertReturnString )
kelvin-onlab016dce22015-08-10 09:54:11 -07002198
2199 main.intentFunction.report( main )
Jeremye0cb5eb2016-01-27 17:39:09 -08002200
2201 def CASE6000( self, main ):
2202 """
2203 Tests Multi to Single Point Intent and Single to Multi Point Intent End Point Failure
2204 """
Jeremy Songster9385d412016-06-02 17:57:36 -07002205 # At some later point discussion on this behavior in MPSP and SPMP intents
2206 # will be reoppened and this test case may need to be updated to reflect
2207 # the outcomes of that discussion
Jeremyd9e4eb12016-04-13 12:09:06 -07002208 if main.initialized == main.FALSE:
2209 main.log.error( "Test components did not start correctly, skipping further tests" )
2210 main.skipCase()
Jeremye0cb5eb2016-01-27 17:39:09 -08002211 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07002212 try:
2213 assert main.CLIs
2214 except AssertionError:
2215 main.log.error( "There is no main.CLIs, skipping test cases" )
2216 main.initialized = main.FALSE
2217 main.skipCase()
2218 try:
2219 assert main.Mininet1
2220 except AssertionError:
2221 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
2222 main.initialized = main.FALSE
2223 main.skipCase()
2224 try:
2225 assert main.numSwitch
2226 except AssertionError:
alison52b25892016-09-19 10:53:48 -07002227 main.log.error( "Place the total number of switch topology in " + main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07002228 main.initialized = main.FALSE
2229 main.skipCase()
alison52b25892016-09-19 10:53:48 -07002230 main.case( "Test Multi to Single End Point Failure" + " - " + str( main.numCtrls ) +
2231 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jeremy Songster9385d412016-06-02 17:57:36 -07002232 main.step( "Installing Multi to Single Point intents with no options set" )
2233 main.assertReturnString = "Assertion results for IPV4 multi to single " +\
2234 "point intent end point failure with no options set\n"
Jeremye0cb5eb2016-01-27 17:39:09 -08002235 senders = [
2236 { "name":"h16", "device":"of:0000000000000006/8" },
2237 { "name":"h24", "device":"of:0000000000000007/8" }
2238 ]
2239 recipients = [
2240 { "name":"h8", "device":"of:0000000000000005/8" }
2241 ]
2242 isolatedSenders = [
alison52b25892016-09-19 10:53:48 -07002243 { "name":"h24" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002244 ]
2245 isolatedRecipients = []
2246 testResult = main.FALSE
2247 installResult = main.intentFunction.installMultiToSingleIntent(
2248 main,
2249 name="NOOPTION",
2250 senders=senders,
2251 recipients=recipients,
2252 sw1="s5",
2253 sw2="s2" )
2254
2255 if installResult:
2256 testResult = main.intentFunction.testEndPointFail(
2257 main,
2258 intentId=installResult,
2259 name="NOOPTION",
2260 senders=senders,
2261 recipients=recipients,
2262 isolatedSenders=isolatedSenders,
2263 isolatedRecipients=isolatedRecipients,
2264 sw1="s6",
2265 sw2="s2",
2266 sw3="s4",
2267 sw4="s1",
2268 sw5="s3",
2269 expectedLink1=16,
2270 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002271 else:
2272 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002273
2274 utilities.assert_equals( expect=main.TRUE,
2275 actual=testResult,
2276 onpass=main.assertReturnString,
2277 onfail=main.assertReturnString )
2278
Jeremy Songster9385d412016-06-02 17:57:36 -07002279 main.step( "Installing Multi to Single Point intents with partial failure allowed" )
2280
2281 main.assertReturnString = "Assertion results for IPV4 multi to single " +\
2282 "with partial failures allowed\n"
2283 senders = [
2284 { "name":"h16", "device":"of:0000000000000006/8" },
2285 { "name":"h24", "device":"of:0000000000000007/8" }
2286 ]
2287 recipients = [
2288 { "name":"h8", "device":"of:0000000000000005/8" }
2289 ]
2290 isolatedSenders = [
alison52b25892016-09-19 10:53:48 -07002291 { "name":"h24" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002292 ]
2293 isolatedRecipients = []
2294 testResult = main.FALSE
Jeremy Songster9385d412016-06-02 17:57:36 -07002295 installResult = main.intentFunction.installMultiToSingleIntent(
2296 main,
2297 name="NOOPTION",
2298 senders=senders,
2299 recipients=recipients,
2300 sw1="s5",
2301 sw2="s2",
2302 partial=True )
2303
2304 if installResult:
2305 testResult = main.intentFunction.testEndPointFail(
2306 main,
2307 intentId=installResult,
2308 name="NOOPTION",
2309 senders=senders,
2310 recipients=recipients,
2311 isolatedSenders=isolatedSenders,
2312 isolatedRecipients=isolatedRecipients,
2313 sw1="s6",
2314 sw2="s2",
2315 sw3="s4",
2316 sw4="s1",
2317 sw5="s3",
2318 expectedLink1=16,
2319 expectedLink2=14,
2320 partial=True )
2321 else:
2322 main.CLIs[ 0 ].removeAllIntents( purge=True )
2323
2324 utilities.assert_equals( expect=main.TRUE,
2325 actual=testResult,
2326 onpass=main.assertReturnString,
2327 onfail=main.assertReturnString )
2328
Jeremye0cb5eb2016-01-27 17:39:09 -08002329 main.step( "NOOPTION: Install and test single point to multi point intents" )
Jeremy Songster9385d412016-06-02 17:57:36 -07002330 main.assertReturnString = "Assertion results for IPV4 single to multi " +\
2331 "point intent with no options set\n"
Jeremye0cb5eb2016-01-27 17:39:09 -08002332 senders = [
2333 { "name":"h8", "device":"of:0000000000000005/8" }
2334 ]
2335 recipients = [
2336 { "name":"h16", "device":"of:0000000000000006/8" },
2337 { "name":"h24", "device":"of:0000000000000007/8" }
2338 ]
Jeremy Songster9385d412016-06-02 17:57:36 -07002339 isolatedSenders = []
2340 isolatedRecipients = [
alison52b25892016-09-19 10:53:48 -07002341 { "name":"h24" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002342 ]
2343 testResult = main.FALSE
2344 installResult = main.intentFunction.installSingleToMultiIntent(
2345 main,
2346 name="NOOPTION",
2347 senders=senders,
2348 recipients=recipients,
2349 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002350 sw2="s2" )
Jeremye0cb5eb2016-01-27 17:39:09 -08002351
2352 if installResult:
2353 testResult = main.intentFunction.testEndPointFail(
2354 main,
2355 intentId=installResult,
2356 name="NOOPTION",
2357 senders=senders,
2358 recipients=recipients,
2359 isolatedSenders=isolatedSenders,
2360 isolatedRecipients=isolatedRecipients,
2361 sw1="s6",
2362 sw2="s2",
2363 sw3="s4",
2364 sw4="s1",
2365 sw5="s3",
2366 expectedLink1=16,
2367 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002368 else:
2369 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002370
2371 utilities.assert_equals( expect=main.TRUE,
2372 actual=testResult,
2373 onpass=main.assertReturnString,
2374 onfail=main.assertReturnString )
Jeremy Songster9385d412016-06-02 17:57:36 -07002375 # Right now this functionality doesn't work properly in SPMP intents
2376 main.step( "NOOPTION: Install and test single point to multi point " +\
2377 "intents with partial failures allowed" )
2378 main.assertReturnString = "Assertion results for IPV4 single to multi " +\
2379 "point intent with partial failures allowed\n"
2380 senders = [
2381 { "name":"h8", "device":"of:0000000000000005/8" }
2382 ]
2383 recipients = [
2384 { "name":"h16", "device":"of:0000000000000006/8" },
2385 { "name":"h24", "device":"of:0000000000000007/8" }
2386 ]
2387 isolatedSenders = []
2388 isolatedRecipients = [
alison52b25892016-09-19 10:53:48 -07002389 { "name":"h24" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002390 ]
2391 testResult = main.FALSE
Jeremy Songster9385d412016-06-02 17:57:36 -07002392 installResult = main.intentFunction.installSingleToMultiIntent(
2393 main,
2394 name="NOOPTION",
2395 senders=senders,
2396 recipients=recipients,
2397 sw1="s5",
2398 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002399 partial=True )
Jeremy Songster9385d412016-06-02 17:57:36 -07002400
2401 if installResult:
2402 testResult = main.intentFunction.testEndPointFail(
2403 main,
2404 intentId=installResult,
2405 name="NOOPTION",
2406 senders=senders,
2407 recipients=recipients,
2408 isolatedSenders=isolatedSenders,
2409 isolatedRecipients=isolatedRecipients,
2410 sw1="s6",
2411 sw2="s2",
2412 sw3="s4",
2413 sw4="s1",
2414 sw5="s3",
2415 expectedLink1=16,
2416 expectedLink2=14,
2417 partial=True )
2418 else:
2419 main.CLIs[ 0 ].removeAllIntents( purge=True )
2420
2421 utilities.assert_equals( expect=main.TRUE,
2422 actual=testResult,
2423 onpass=main.assertReturnString,
2424 onfail=main.assertReturnString )
Jeremye0cb5eb2016-01-27 17:39:09 -08002425
Chiyu Chengef109502016-11-21 15:51:38 -08002426 main.intentFunction.report( main )