blob: 8c9f07de9299e2d515ff8cae5b516b2d793aa330 [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' ] )
Shreyaca8990f2017-03-16 11:43:11 -070050 main.checkConnectionSleep = int( main.params[ 'SLEEP' ][ 'checkConnection' ] )
51 main.checkFlowCountSleep = int( main.params[ 'SLEEP' ][ 'checkFlowCount' ] )
52 main.checkIntentHostSleep = int( main.params[ 'SLEEP' ][ 'checkIntentHost' ] )
53 main.checkIntentPointSleep = int( main.params[ 'SLEEP' ][ 'checkIntentPoint' ] )
acsmars59a4c552015-09-10 18:11:19 -070054 main.checkTopoAttempts = int( main.params[ 'SLEEP' ][ 'topoAttempts' ] )
Jeremy Songster306ed7a2016-07-19 10:59:07 -070055 main.flowDurationSleep = int( main.params[ 'SLEEP' ][ 'flowDuration' ] )
Jon Halla3e02432015-07-24 15:55:42 -070056 gitPull = main.params[ 'GIT' ][ 'pull' ]
57 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
58 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
59 main.cellData = {} # for creating cell file
60 main.hostsData = {}
61 main.CLIs = []
62 main.ONOSip = []
Jeremy Songster1f39bf02016-01-20 17:17:25 -080063 main.scapyHostNames = main.params[ 'SCAPY' ][ 'HOSTNAMES' ].split( ',' )
64 main.scapyHosts = [] # List of scapy hosts for iterating
acsmars5d8cc862015-09-25 09:44:50 -070065 main.assertReturnString = '' # Assembled assert return string
Jeremy Songster17147f22016-05-31 18:30:52 -070066 main.cycle = 0 # How many times FUNCintent has run through its tests
kelvin-onlabd48a68c2015-07-13 16:01:36 -070067
Jon Halla3e02432015-07-24 15:55:42 -070068 main.ONOSip = main.ONOSbench.getOnosIps()
69 print main.ONOSip
kelvin-onlabd48a68c2015-07-13 16:01:36 -070070
Jon Halla3e02432015-07-24 15:55:42 -070071 # Assigning ONOS cli handles to a list
72 for i in range( 1, main.maxNodes + 1 ):
73 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070074
Jon Halla3e02432015-07-24 15:55:42 -070075 # -- INIT SECTION, ONLY RUNS ONCE -- #
76 main.startUp = imp.load_source( wrapperFile1,
77 main.dependencyPath +
78 wrapperFile1 +
79 ".py" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070080
Jon Halla3e02432015-07-24 15:55:42 -070081 main.intentFunction = imp.load_source( wrapperFile2,
82 main.dependencyPath +
83 wrapperFile2 +
84 ".py" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070085
Jon Halla3e02432015-07-24 15:55:42 -070086 main.topo = imp.load_source( wrapperFile3,
87 main.dependencyPath +
88 wrapperFile3 +
89 ".py" )
90
kelvin-onlabd9e23de2015-08-06 10:34:44 -070091 copyResult1 = main.ONOSbench.scp( main.Mininet1,
92 main.dependencyPath +
93 main.topology,
Jeremy Songster1f39bf02016-01-20 17:17:25 -080094 main.Mininet1.home + "custom/",
kelvin-onlabd9e23de2015-08-06 10:34:44 -070095 direction="to" )
Jon Halla3e02432015-07-24 15:55:42 -070096 if main.CLIs:
97 stepResult = main.TRUE
98 else:
99 main.log.error( "Did not properly created list of ONOS CLI handle" )
100 stepResult = main.FALSE
101 except Exception as e:
102 main.log.exception(e)
103 main.cleanup()
104 main.exit()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700105
106 utilities.assert_equals( expect=main.TRUE,
107 actual=stepResult,
108 onpass="Successfully construct " +
109 "test variables ",
110 onfail="Failed to construct test variables" )
111
112 if gitPull == 'True':
113 main.step( "Building ONOS in " + gitBranch + " branch" )
114 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
115 stepResult = onosBuildResult
116 utilities.assert_equals( expect=main.TRUE,
117 actual=stepResult,
118 onpass="Successfully compiled " +
119 "latest ONOS",
120 onfail="Failed to compile " +
121 "latest ONOS" )
122 else:
123 main.log.warn( "Did not pull new code so skipping mvn " +
124 "clean install" )
Jon Hall106be082015-07-22 09:53:00 -0700125 main.ONOSbench.getVersion( report=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700126
127 def CASE2( self, main ):
128 """
129 - Set up cell
130 - Create cell file
131 - Set cell file
132 - Verify cell file
133 - Kill ONOS process
134 - Uninstall ONOS cluster
135 - Verify ONOS start up
136 - Install ONOS cluster
137 - Connect to cli
138 """
alison52b25892016-09-19 10:53:48 -0700139 import time
Jeremy Songster17147f22016-05-31 18:30:52 -0700140 main.cycle += 1
141
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700142 # main.scale[ 0 ] determines the current number of ONOS controller
143 main.numCtrls = int( main.scale[ 0 ] )
Jeremycd872222016-03-29 10:08:34 -0700144 main.flowCompiler = "Flow Rules"
Jeremyd9e4eb12016-04-13 12:09:06 -0700145 main.initialized = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700146
147 main.case( "Starting up " + str( main.numCtrls ) +
148 " node(s) ONOS cluster" )
Jon Hall783bbf92015-07-23 14:33:19 -0700149 main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700150 " node(s) ONOS cluster"
151
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700152 #kill off all onos processes
153 main.log.info( "Safety check, killing all ONOS processes" +
Jon Hall70b2ff42015-11-17 15:49:44 -0800154 " before initiating environment setup" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700155
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800156 time.sleep( main.startUpSleep )
157 main.step( "Uninstalling ONOS package" )
158 onosUninstallResult = main.TRUE
159 for ip in main.ONOSip:
160 onosUninstallResult = onosUninstallResult and \
161 main.ONOSbench.onosUninstall( nodeIp=ip )
162 stepResult = onosUninstallResult
163 utilities.assert_equals( expect=main.TRUE,
164 actual=stepResult,
165 onpass="Successfully uninstalled ONOS package",
166 onfail="Failed to uninstall ONOS package" )
Jeremy42df2e72016-02-23 16:37:46 -0800167 time.sleep( main.startUpSleep )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800168
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700169 for i in range( main.maxNodes ):
170 main.ONOSbench.onosDie( main.ONOSip[ i ] )
171
172 print "NODE COUNT = ", main.numCtrls
173
174 tempOnosIp = []
175 for i in range( main.numCtrls ):
176 tempOnosIp.append( main.ONOSip[i] )
177
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700178 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
179 "temp", main.Mininet1.ip_address,
180 main.apps, tempOnosIp )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700181
182 main.step( "Apply cell to environment" )
183 cellResult = main.ONOSbench.setCell( "temp" )
184 verifyResult = main.ONOSbench.verifyCell()
185 stepResult = cellResult and verifyResult
186 utilities.assert_equals( expect=main.TRUE,
187 actual=stepResult,
188 onpass="Successfully applied cell to " + \
189 "environment",
190 onfail="Failed to apply cell to environment " )
191
192 main.step( "Creating ONOS package" )
Jon Hallbd60ea02016-08-23 10:03:59 -0700193 packageResult = main.ONOSbench.buckBuild()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700194 stepResult = packageResult
195 utilities.assert_equals( expect=main.TRUE,
196 actual=stepResult,
197 onpass="Successfully created ONOS package",
198 onfail="Failed to create ONOS package" )
199
200 time.sleep( main.startUpSleep )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700201 main.step( "Installing ONOS package" )
202 onosInstallResult = main.TRUE
203 for i in range( main.numCtrls ):
204 onosInstallResult = onosInstallResult and \
205 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
206 stepResult = onosInstallResult
207 utilities.assert_equals( expect=main.TRUE,
208 actual=stepResult,
209 onpass="Successfully installed ONOS package",
210 onfail="Failed to install ONOS package" )
211
You Wangf5de25b2017-01-06 15:13:01 -0800212 main.step( "Set up ONOS secure SSH" )
213 secureSshResult = main.TRUE
214 for i in range( int( main.numCtrls ) ):
215 secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
216 utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
217 onpass="Test step PASS",
218 onfail="Test step FAIL" )
219
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700220 time.sleep( main.startUpSleep )
221 main.step( "Starting ONOS service" )
222 stopResult = main.TRUE
223 startResult = main.TRUE
224 onosIsUp = main.TRUE
225
226 for i in range( main.numCtrls ):
Jeremy Songster7edb6632016-04-28 15:44:28 -0700227 isUp = main.ONOSbench.isup( main.ONOSip[ i ] )
228 onosIsUp = onosIsUp and isUp
229 if isUp == main.TRUE:
Jeremyd9e4eb12016-04-13 12:09:06 -0700230 main.log.report( "ONOS instance {0} is up and ready".format( i + 1 ) )
231 else:
232 main.log.report( "ONOS instance {0} may not be up, stop and ".format( i + 1 ) +
233 "start ONOS again " )
234 stopResult = stopResult and main.ONOSbench.onosStop( main.ONOSip[ i ] )
235 startResult = startResult and main.ONOSbench.onosStart( main.ONOSip[ i ] )
236 if not startResult or stopResult:
237 main.log.report( "ONOS instance {0} did not start correctly.".format( i + 1) )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700238 stepResult = onosIsUp and stopResult and startResult
239 utilities.assert_equals( expect=main.TRUE,
240 actual=stepResult,
Jeremyd9e4eb12016-04-13 12:09:06 -0700241 onpass="ONOS service is ready on all nodes",
242 onfail="ONOS service did not start properly on all nodes" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700243
244 main.step( "Start ONOS cli" )
245 cliResult = main.TRUE
246 for i in range( main.numCtrls ):
247 cliResult = cliResult and \
248 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
249 stepResult = cliResult
250 utilities.assert_equals( expect=main.TRUE,
251 actual=stepResult,
252 onpass="Successfully start ONOS cli",
253 onfail="Failed to start ONOS cli" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700254 if not stepResult:
255 main.initialized = main.FALSE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700256
257 # Remove the first element in main.scale list
258 main.scale.remove( main.scale[ 0 ] )
259
kelvin-onlab016dce22015-08-10 09:54:11 -0700260 main.intentFunction.report( main )
261
Jon Halla3e02432015-07-24 15:55:42 -0700262 def CASE8( self, main ):
263 """
acsmars59a4c552015-09-10 18:11:19 -0700264 Compare ONOS Topology to Mininet Topology
Jon Halla3e02432015-07-24 15:55:42 -0700265 """
266 import json
267
268 main.case( "Compare ONOS Topology view to Mininet topology" )
269 main.caseExplanation = "Compare topology elements between Mininet" +\
270 " and ONOS"
271
acsmars59a4c552015-09-10 18:11:19 -0700272 main.log.info( "Gathering topology information from Mininet" )
273 devicesResults = main.FALSE # Overall Boolean for device correctness
274 linksResults = main.FALSE # Overall Boolean for link correctness
275 hostsResults = main.FALSE # Overall Boolean for host correctness
276 deviceFails = [] # Nodes where devices are incorrect
277 linkFails = [] # Nodes where links are incorrect
278 hostFails = [] # Nodes where hosts are incorrect
279 attempts = main.checkTopoAttempts # Remaining Attempts
Jon Halla3e02432015-07-24 15:55:42 -0700280
281 mnSwitches = main.Mininet1.getSwitches()
282 mnLinks = main.Mininet1.getLinks()
283 mnHosts = main.Mininet1.getHosts()
284
Jon Hall70b2ff42015-11-17 15:49:44 -0800285 main.step( "Comparing Mininet topology to ONOS topology" )
Jon Halla3e02432015-07-24 15:55:42 -0700286
acsmars59a4c552015-09-10 18:11:19 -0700287 while ( attempts >= 0 ) and\
288 ( not devicesResults or not linksResults or not hostsResults ):
289 time.sleep( 2 )
290 if not devicesResults:
291 devices = main.topo.getAllDevices( main )
292 ports = main.topo.getAllPorts( main )
293 devicesResults = main.TRUE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800294 deviceFails = [] # Reset for each failed attempt
acsmars59a4c552015-09-10 18:11:19 -0700295 if not linksResults:
296 links = main.topo.getAllLinks( main )
297 linksResults = main.TRUE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800298 linkFails = [] # Reset for each failed attempt
acsmars59a4c552015-09-10 18:11:19 -0700299 if not hostsResults:
300 hosts = main.topo.getAllHosts( main )
301 hostsResults = main.TRUE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800302 hostFails = [] # Reset for each failed attempt
Jon Halla3e02432015-07-24 15:55:42 -0700303
acsmars59a4c552015-09-10 18:11:19 -0700304 # Check for matching topology on each node
305 for controller in range( main.numCtrls ):
306 controllerStr = str( controller + 1 ) # ONOS node number
307 # Compare Devices
308 if devices[ controller ] and ports[ controller ] and\
309 "Error" not in devices[ controller ] and\
310 "Error" not in ports[ controller ]:
Jon Halla3e02432015-07-24 15:55:42 -0700311
acsmars2ec91d62015-09-16 11:15:48 -0700312 try:
313 deviceData = json.loads( devices[ controller ] )
314 portData = json.loads( ports[ controller ] )
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700315 except( TypeError, ValueError ):
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800316 main.log.error( "Could not load json: {0} or {1}".format( str( devices[ controller ] ), str( ports[ controller ] ) ) )
acsmars2ec91d62015-09-16 11:15:48 -0700317 currentDevicesResult = main.FALSE
318 else:
319 currentDevicesResult = main.Mininet1.compareSwitches(
320 mnSwitches,deviceData,portData )
acsmars59a4c552015-09-10 18:11:19 -0700321 else:
322 currentDevicesResult = main.FALSE
323 if not currentDevicesResult:
324 deviceFails.append( controllerStr )
325 devicesResults = devicesResults and currentDevicesResult
326 # Compare Links
327 if links[ controller ] and "Error" not in links[ controller ]:
acsmars2ec91d62015-09-16 11:15:48 -0700328 try:
329 linkData = json.loads( links[ controller ] )
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700330 except( TypeError, ValueError ):
331 main.log.error( "Could not load json:" + str( links[ controller ] ) )
acsmars2ec91d62015-09-16 11:15:48 -0700332 currentLinksResult = main.FALSE
333 else:
334 currentLinksResult = main.Mininet1.compareLinks(
335 mnSwitches, mnLinks,linkData )
acsmars59a4c552015-09-10 18:11:19 -0700336 else:
337 currentLinksResult = main.FALSE
338 if not currentLinksResult:
339 linkFails.append( controllerStr )
340 linksResults = linksResults and currentLinksResult
341 # Compare Hosts
acsmars2ec91d62015-09-16 11:15:48 -0700342 if hosts[ controller ] and "Error" not in hosts[ controller ]:
343 try:
344 hostData = json.loads( hosts[ controller ] )
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700345 except( TypeError, ValueError ):
346 main.log.error( "Could not load json:" + str( hosts[ controller ] ) )
acsmars2ec91d62015-09-16 11:15:48 -0700347 currentHostsResult = main.FALSE
348 else:
349 currentHostsResult = main.Mininet1.compareHosts(
350 mnHosts,hostData )
acsmars59a4c552015-09-10 18:11:19 -0700351 else:
352 currentHostsResult = main.FALSE
353 if not currentHostsResult:
354 hostFails.append( controllerStr )
355 hostsResults = hostsResults and currentHostsResult
356 # Decrement Attempts Remaining
357 attempts -= 1
358
359
360 utilities.assert_equals( expect=[],
361 actual=deviceFails,
362 onpass="ONOS correctly discovered all devices",
363 onfail="ONOS incorrectly discovered devices on nodes: " +
364 str( deviceFails ) )
365 utilities.assert_equals( expect=[],
366 actual=linkFails,
367 onpass="ONOS correctly discovered all links",
368 onfail="ONOS incorrectly discovered links on nodes: " +
369 str( linkFails ) )
370 utilities.assert_equals( expect=[],
371 actual=hostFails,
372 onpass="ONOS correctly discovered all hosts",
373 onfail="ONOS incorrectly discovered hosts on nodes: " +
374 str( hostFails ) )
Jon Hall46d48252015-08-03 11:41:16 -0700375 topoResults = hostsResults and linksResults and devicesResults
376 utilities.assert_equals( expect=main.TRUE,
377 actual=topoResults,
378 onpass="ONOS correctly discovered the topology",
379 onfail="ONOS incorrectly discovered the topology" )
Jon Halla3e02432015-07-24 15:55:42 -0700380
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700381 def CASE10( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700382 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700383 Start Mininet topology with OF 1.0 switches
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700384 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700385 if main.initialized == main.FALSE:
386 main.log.error( "Test components did not start correctly, skipping further tests" )
387 main.skipCase()
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700388 main.OFProtocol = "1.0"
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700389 main.log.report( "Start Mininet topology with OF 1.0 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700390 main.case( "Start Mininet topology with OF 1.0 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700391 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700392 "switches to test intents, exits out if " +\
393 "topology did not start correctly"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700394
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700395 main.step( "Starting Mininet topology with OF 1.0 switches" )
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700396 args = "--switch ovs,protocols=OpenFlow10"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700397 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700398 main.topology,
399 args=args )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700400 stepResult = topoResult
401 utilities.assert_equals( expect=main.TRUE,
402 actual=stepResult,
403 onpass="Successfully loaded topology",
404 onfail="Failed to load topology" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700405
406 # Set flag to test cases if topology did not load properly
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700407 if not topoResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700408 main.initialized = main.FALSE
409 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700410
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700411 def CASE11( self, main ):
412 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700413 Start Mininet topology with OF 1.3 switches
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700414 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700415 if main.initialized == main.FALSE:
416 main.log.error( "Test components did not start correctly, skipping further tests" )
417 main.skipCase()
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700418 main.OFProtocol = "1.3"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700419 main.log.report( "Start Mininet topology with OF 1.3 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700420 main.case( "Start Mininet topology with OF 1.3 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700421 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700422 "switches to test intents, exits out if " +\
423 "topology did not start correctly"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700424
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700425 main.step( "Starting Mininet topology with OF 1.3 switches" )
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700426 args = "--switch ovs,protocols=OpenFlow13"
427 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
428 main.topology,
429 args=args )
430 stepResult = topoResult
431 utilities.assert_equals( expect=main.TRUE,
432 actual=stepResult,
433 onpass="Successfully loaded topology",
434 onfail="Failed to load topology" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700435 # Set flag to skip test cases if topology did not load properly
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700436 if not topoResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700437 main.initialized = main.FALSE
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700438
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700439 def CASE12( self, main ):
440 """
441 Assign mastership to controllers
442 """
443 import re
444
Jeremyd9e4eb12016-04-13 12:09:06 -0700445 if main.initialized == main.FALSE:
446 main.log.error( "Test components did not start correctly, skipping further tests" )
447 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700448 main.case( "Assign switches to controllers" )
449 main.step( "Assigning switches to controllers" )
Jon Hall783bbf92015-07-23 14:33:19 -0700450 main.caseExplanation = "Assign OF " + main.OFProtocol +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700451 " switches to ONOS nodes"
452
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700453 switchList = []
454
455 # Creates a list switch name, use getSwitch() function later...
456 for i in range( 1, ( main.numSwitch + 1 ) ):
457 switchList.append( 's' + str( i ) )
458
459 tempONOSip = []
460 for i in range( main.numCtrls ):
461 tempONOSip.append( main.ONOSip[ i ] )
462
463 assignResult = main.Mininet1.assignSwController( sw=switchList,
464 ip=tempONOSip,
alison52b25892016-09-19 10:53:48 -0700465 port="6653" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700466 if not assignResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700467 main.log.error( "Problem assigning mastership of switches" )
468 main.initialized = main.FALSE
469 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700470
471 for i in range( 1, ( main.numSwitch + 1 ) ):
472 response = main.Mininet1.getSwController( "s" + str( i ) )
473 print( "Response is " + str( response ) )
474 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
475 assignResult = assignResult and main.TRUE
476 else:
477 assignResult = main.FALSE
478 stepResult = assignResult
479 utilities.assert_equals( expect=main.TRUE,
480 actual=stepResult,
481 onpass="Successfully assigned switches" +
482 "to controller",
483 onfail="Failed to assign switches to " +
484 "controller" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700485 if not stepResult:
486 main.initialized = main.FALSE
acsmars5d8cc862015-09-25 09:44:50 -0700487
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800488 def CASE13( self,main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700489 """
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800490 Create Scapy components
491 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700492 if main.initialized == main.FALSE:
493 main.log.error( "Test components did not start correctly, skipping further tests" )
494 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800495 main.case( "Create scapy components" )
496 main.step( "Create scapy components" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800497 scapyResult = main.TRUE
498 for hostName in main.scapyHostNames:
499 main.Scapy1.createHostComponent( hostName )
500 main.scapyHosts.append( getattr( main, hostName ) )
501
502 main.step( "Start scapy components" )
503 for host in main.scapyHosts:
504 host.startHostCli()
505 host.startScapy()
506 host.updateSelf()
507 main.log.debug( host.name )
508 main.log.debug( host.hostIp )
509 main.log.debug( host.hostMac )
510
511
512 utilities.assert_equals( expect=main.TRUE,
513 actual=scapyResult,
514 onpass="Successfully created Scapy Components",
515 onfail="Failed to discover Scapy Components" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700516 if not scapyResult:
517 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800518
519 def CASE14( self, main ):
520 """
521 Discover all hosts with fwd and pingall and store its data in a dictionary
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700522 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700523 if main.initialized == main.FALSE:
524 main.log.error( "Test components did not start correctly, skipping further tests" )
525 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700526 main.case( "Discover all hosts" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800527 main.step( "Pingall hosts and confirm ONOS discovery" )
528 utilities.retry( f=main.intentFunction.fwdPingall, retValue=main.FALSE, args=[ main ] )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700529
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800530 utilities.retry( f=main.intentFunction.confirmHostDiscovery, retValue=main.FALSE,
531 args=[ main ], attempts=main.checkTopoAttempts, sleep=2 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700532 utilities.assert_equals( expect=main.TRUE,
533 actual=stepResult,
534 onpass="Successfully discovered hosts",
535 onfail="Failed to discover hosts" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700536 if not stepResult:
537 main.initialized = main.FALSE
538 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700539
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800540 main.step( "Populate hostsData" )
541 stepResult = main.intentFunction.populateHostData( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700542 utilities.assert_equals( expect=main.TRUE,
543 actual=stepResult,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800544 onpass="Successfully populated hostsData",
545 onfail="Failed to populate hostsData" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700546 if not stepResult:
547 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800548
549 def CASE15( self, main ):
550 """
551 Discover all hosts with scapy arp packets and store its data to a dictionary
552 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700553 if main.initialized == main.FALSE:
554 main.log.error( "Test components did not start correctly, skipping further tests" )
555 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800556 main.case( "Discover all hosts using scapy" )
557 main.step( "Send packets from each host to the first host and confirm onos discovery" )
558
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800559 if len( main.scapyHosts ) < 1:
560 main.log.error( "No scapy hosts have been created" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700561 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800562 main.skipCase()
563
564 # Send ARP packets from each scapy host component
565 main.intentFunction.sendDiscoveryArp( main, main.scapyHosts )
566
567 stepResult = utilities.retry( f=main.intentFunction.confirmHostDiscovery,
568 retValue=main.FALSE, args=[ main ],
569 attempts=main.checkTopoAttempts, sleep=2 )
570
571 utilities.assert_equals( expect=main.TRUE,
572 actual=stepResult,
573 onpass="ONOS correctly discovered all hosts",
574 onfail="ONOS incorrectly discovered hosts" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700575 if not stepResult:
576 main.initialized = main.FALSE
577 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800578
579 main.step( "Populate hostsData" )
580 stepResult = main.intentFunction.populateHostData( main )
581 utilities.assert_equals( expect=main.TRUE,
582 actual=stepResult,
583 onpass="Successfully populated hostsData",
584 onfail="Failed to populate hostsData" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700585 if not stepResult:
586 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800587
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800588 def CASE16( self, main ):
589 """
Jeremy42df2e72016-02-23 16:37:46 -0800590 Balance Masters
591 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700592 if main.initialized == main.FALSE:
593 main.log.error( "Test components did not start correctly, skipping further tests" )
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700594 main.stop()
Jeremyd9e4eb12016-04-13 12:09:06 -0700595 main.skipCase()
Jeremy42df2e72016-02-23 16:37:46 -0800596 main.case( "Balance mastership of switches" )
597 main.step( "Balancing mastership of switches" )
598
Jeremy42df2e72016-02-23 16:37:46 -0800599 balanceResult = utilities.retry( f=main.CLIs[ 0 ].balanceMasters, retValue=main.FALSE, args=[] )
600
601 utilities.assert_equals( expect=main.TRUE,
Jeremy6e9748f2016-03-25 15:03:39 -0700602 actual=balanceResult,
Jeremy42df2e72016-02-23 16:37:46 -0800603 onpass="Successfully balanced mastership of switches",
604 onfail="Failed to balance mastership of switches" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700605 if not balanceResult:
606 main.initialized = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800607
608 def CASE17( self, main ):
609 """
Jeremy6e9748f2016-03-25 15:03:39 -0700610 Use Flow Objectives
611 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700612 if main.initialized == main.FALSE:
613 main.log.error( "Test components did not start correctly, skipping further tests" )
614 main.skipCase()
Jeremy6e9748f2016-03-25 15:03:39 -0700615 main.case( "Enable intent compilation using Flow Objectives" )
616 main.step( "Enabling Flow Objectives" )
617
618 main.flowCompiler = "Flow Objectives"
619
620 cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator"
621
622 stepResult = main.CLIs[ 0 ].setCfg( component=cmd,
623 propName="useFlowObjectives", value="true" )
624
625 utilities.assert_equals( expect=main.TRUE,
626 actual=stepResult,
627 onpass="Successfully activated Flow Objectives",
628 onfail="Failed to activate Flow Objectives" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700629 if not balanceResult:
630 main.initialized = main.FALSE
Jeremy6e9748f2016-03-25 15:03:39 -0700631
632 def CASE18( self, main ):
633 """
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800634 Stop mininet and remove scapy host
635 """
636 main.log.report( "Stop Mininet and Scapy" )
637 main.case( "Stop Mininet and Scapy" )
638 main.caseExplanation = "Stopping the current mininet topology " +\
639 "to start up fresh"
640 main.step( "Stopping and Removing Scapy Host Components" )
641 scapyResult = main.TRUE
642 for host in main.scapyHosts:
643 scapyResult = scapyResult and host.stopScapy()
644 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
645
646 for host in main.scapyHosts:
647 scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
648 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
649
650 main.scapyHosts = []
651 main.scapyHostIPs = []
652
653 utilities.assert_equals( expect=main.TRUE,
654 actual=scapyResult,
655 onpass="Successfully stopped scapy and removed host components",
656 onfail="Failed to stop mininet and scapy" )
657
658 main.step( "Stopping Mininet Topology" )
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700659 mininetResult = main.Mininet1.stopNet()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800660
661 utilities.assert_equals( expect=main.TRUE,
662 actual=mininetResult,
663 onpass="Successfully stopped mininet and scapy",
664 onfail="Failed to stop mininet and scapy" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700665 # Exit if topology did not load properly
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800666 if not ( mininetResult and scapyResult ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700667 main.cleanup()
668 main.exit()
669
Jeremy Songster17147f22016-05-31 18:30:52 -0700670 def CASE19( self, main ):
671 """
672 Copy the karaf.log files after each testcase cycle
673 """
674 main.log.report( "Copy karaf logs" )
675 main.case( "Copy karaf logs" )
676 main.caseExplanation = "Copying the karaf logs to preserve them through" +\
677 "reinstalling ONOS"
678 main.step( "Copying karaf logs" )
Jeremy Songster31aad312016-06-13 16:32:11 -0700679 stepResult = main.TRUE
680 scpResult = main.TRUE
681 copyResult = main.TRUE
Jeremy Songstercc5414b2016-07-11 10:59:53 -0700682 for i in range( main.numCtrls ):
683 main.node = main.CLIs[ i ]
Jeremy Songster17147f22016-05-31 18:30:52 -0700684 ip = main.ONOSip[ i ]
685 main.node.ip_address = ip
Jeremy Songster31aad312016-06-13 16:32:11 -0700686 scpResult = scpResult and main.ONOSbench.scp( main.node ,
687 "/opt/onos/log/karaf.log",
688 "/tmp/karaf.log",
689 direction="from" )
690 copyResult = copyResult and main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
691 copyFileName=( "karaf.log.node{0}.cycle{1}".format( str( i + 1 ), str( main.cycle ) ) ) )
692 if scpResult and copyResult:
693 stepResult = main.TRUE and stepResult
694 else:
695 stepResult = main.FALSE and stepResult
Jeremy Songster31aad312016-06-13 16:32:11 -0700696 utilities.assert_equals( expect=main.TRUE,
697 actual=stepResult,
698 onpass="Successfully copied remote ONOS logs",
699 onfail="Failed to copy remote ONOS logs" )
Jeremy Songster17147f22016-05-31 18:30:52 -0700700
kelvin-onlabb769f562015-07-15 17:05:10 -0700701 def CASE1000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700702 """
703 Add host intents between 2 host:
704 - Discover hosts
705 - Add host intents
706 - Check intents
707 - Verify flows
708 - Ping hosts
709 - Reroute
710 - Link down
711 - Verify flows
712 - Check topology
713 - Ping hosts
714 - Link up
715 - Verify flows
716 - Check topology
717 - Ping hosts
718 - Remove intents
719 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700720 if main.initialized == main.FALSE:
721 main.log.error( "Test components did not start correctly, skipping further tests" )
722 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700723 # Assert variables - These variable's name|format must be followed
724 # if you want to use the wrapper function
725 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -0700726 try:
727 assert main.CLIs
728 except AssertionError:
729 main.log.error( "There is no main.CLIs, skipping test cases" )
730 main.initialized = main.FALSE
731 main.skipCase()
732 try:
733 assert main.Mininet1
734 except AssertionError:
735 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
736 main.initialized = main.FALSE
737 main.skipCase()
738 try:
739 assert main.numSwitch
740 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700741 main.log.error( "Place the total number of switch topology in " +\
742 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -0700743 main.initialized = main.FALSE
744 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700745
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800746 # Save leader candidates
acsmarse6b410f2015-07-17 14:39:34 -0700747 intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
748
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700749 main.testName = "Host Intents"
750 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -0700751 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -0700752 main.caseExplanation = "This test case tests Host intents using " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700753 str( main.numCtrls ) + " node(s) cluster;\n" +\
754 "Different type of hosts will be tested in " +\
755 "each step such as IPV4, Dual stack, VLAN " +\
Jeremyeb51cb12016-03-28 17:53:35 -0700756 "etc;\nThe test will use OF " + main.OFProtocol +\
757 " OVS running in Mininet and compile intents" +\
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700758 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700759
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700760 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700761 main.assertReturnString = "Assertion Result for IPV4 host intent with mac addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800762 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
763 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
764 testResult = main.FALSE
765 installResult = main.intentFunction.installHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700766 name="IPV4",
767 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800768 host1=host1,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700769 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800770 if installResult:
771 testResult = main.intentFunction.testHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700772 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800773 intentId = installResult,
alison52b25892016-09-19 10:53:48 -0700774 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800775 host1=host1,
776 host2=host2,
alison52b25892016-09-19 10:53:48 -0700777 sw1="s5",
778 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700779 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800780 else:
781 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800782
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700783 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800784 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700785 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700786 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700787
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700788 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700789 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800790 host1 = { "name":"h3","id":"00:00:00:00:00:03/-1" }
791 host2 = { "name":"h11","id":"00:00:00:00:00:0B/-1 "}
792 testResult = main.FALSE
793 installResult = main.intentFunction.installHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700794 name="DUALSTACK",
795 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800796 host1=host1,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700797 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800798
799 if installResult:
800 testResult = main.intentFunction.testHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700801 name="DUALSTACK",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800802 intentId = installResult,
alison52b25892016-09-19 10:53:48 -0700803 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800804 host1=host1,
805 host2=host2,
alison52b25892016-09-19 10:53:48 -0700806 sw1="s5",
807 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700808 expectedLink=18 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700809
810 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800811 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700812 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700813 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700814
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700815 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700816 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800817 host1 = { "name":"h1" }
818 host2 = { "name":"h11" }
819 testResult = main.FALSE
820 installResult = main.intentFunction.installHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700821 name="DUALSTACK2",
822 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800823 host1=host1,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700824 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800825
826 if installResult:
827 testResult = main.intentFunction.testHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700828 name="DUALSTACK2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800829 intentId = installResult,
alison52b25892016-09-19 10:53:48 -0700830 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800831 host1=host1,
832 host2=host2,
alison52b25892016-09-19 10:53:48 -0700833 sw1="s5",
834 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700835 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800836 else:
837 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700838
839 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800840 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700841 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700842 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700843
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700844 main.step( "1HOP: Add host intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -0700845 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800846 host1 = { "name":"h1" }
847 host2 = { "name":"h3" }
848 testResult = main.FALSE
849 installResult = main.intentFunction.installHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700850 name="1HOP",
851 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800852 host1=host1,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700853 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800854
855 if installResult:
856 testResult = main.intentFunction.testHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700857 name="1HOP",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800858 intentId = installResult,
alison52b25892016-09-19 10:53:48 -0700859 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800860 host1=host1,
861 host2=host2,
alison52b25892016-09-19 10:53:48 -0700862 sw1="s5",
863 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700864 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800865 else:
866 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700867
868 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800869 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700870 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700871 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700872
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700873 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
acsmars5d8cc862015-09-25 09:44:50 -0700874 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jeremy Songster832f9e92016-05-05 14:30:49 -0700875 host1 = { "name":"h4","id":"00:00:00:00:00:04/100", "vlan":"100" }
876 host2 = { "name":"h12","id":"00:00:00:00:00:0C/100", "vlan":"100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800877 testResult = main.FALSE
878 installResult = main.intentFunction.installHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700879 name="VLAN1",
880 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800881 host1=host1,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700882 host2=host2 )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800883
884 if installResult:
885 testResult = main.intentFunction.testHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700886 name="VLAN1",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800887 intentId = installResult,
alison52b25892016-09-19 10:53:48 -0700888 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800889 host1=host1,
890 host2=host2,
alison52b25892016-09-19 10:53:48 -0700891 sw1="s5",
892 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700893 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -0800894 else:
895 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700896
897 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800898 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700899 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700900 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700901
Jeremy Songsterff553672016-05-12 17:06:23 -0700902 main.step( "VLAN2: Add vlan host intents between h4 and h13" )
903 main.assertReturnString = "Assertion Result vlan IPV4\n"
904 host1 = { "name":"h5", "vlan":"200" }
905 host2 = { "name":"h12", "vlan":"100" }
906 testResult = main.FALSE
Jeremy Songsterff553672016-05-12 17:06:23 -0700907 installResult = main.intentFunction.installHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700908 name="VLAN2",
909 onosNode=0,
Jeremy Songsterff553672016-05-12 17:06:23 -0700910 host1=host1,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700911 host2=host2 )
Jeremy Songsterff553672016-05-12 17:06:23 -0700912
913 if installResult:
914 testResult = main.intentFunction.testHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700915 name="VLAN2",
Jeremy Songsterff553672016-05-12 17:06:23 -0700916 intentId = installResult,
alison52b25892016-09-19 10:53:48 -0700917 onosNode=0,
Jeremy Songsterff553672016-05-12 17:06:23 -0700918 host1=host1,
919 host2=host2,
alison52b25892016-09-19 10:53:48 -0700920 sw1="s5",
921 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700922 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -0700923 else:
924 main.CLIs[ 0 ].removeAllIntents( purge=True )
925
926 utilities.assert_equals( expect=main.TRUE,
927 actual=testResult,
928 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700929 onfail=main.assertReturnString )
Jeremy Songsterff553672016-05-12 17:06:23 -0700930
Jeremy Songsterc032f162016-08-04 17:14:49 -0700931 main.step( "Encapsulation: Add host intents between h1 and h9" )
932 main.assertReturnString = "Assertion Result for VLAN Encapsulated host intent\n"
933 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
934 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
935 testResult = main.FALSE
Jeremy Songsterc032f162016-08-04 17:14:49 -0700936 installResult = main.intentFunction.installHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700937 name="ENCAPSULATION",
938 onosNode=0,
Jeremy Songsterc032f162016-08-04 17:14:49 -0700939 host1=host1,
940 host2=host2,
941 encap="VLAN" )
942 if installResult:
943 testResult = main.intentFunction.testHostIntent( main,
alison52b25892016-09-19 10:53:48 -0700944 name="ENCAPSULATION",
Jeremy Songsterc032f162016-08-04 17:14:49 -0700945 intentId = installResult,
alison52b25892016-09-19 10:53:48 -0700946 onosNode=0,
Jeremy Songsterc032f162016-08-04 17:14:49 -0700947 host1=host1,
948 host2=host2,
alison52b25892016-09-19 10:53:48 -0700949 sw1="s5",
950 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700951 expectedLink=18 )
Jeremy Songsterc032f162016-08-04 17:14:49 -0700952 else:
953 main.CLIs[ 0 ].removeAllIntents( purge=True )
954
955 utilities.assert_equals( expect=main.TRUE,
956 actual=testResult,
957 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700958 onfail=main.assertReturnString )
Jeremy Songsterc032f162016-08-04 17:14:49 -0700959
Shreyaca8990f2017-03-16 11:43:11 -0700960 # Testing MPLS would require kernel version of 4.1 or higher (Current version is 3.13)
alison52b25892016-09-19 10:53:48 -0700961 # main.step( "Encapsulation: Add host intents between h1 and h9" )
962 # main.assertReturnString = "Assertion Result for MPLS Encapsulated host intent\n"
963 # host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
964 # host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
965 # testResult = main.FALSE
966 # installResult = main.intentFunction.installHostIntent( main,
967 # name="ENCAPSULATION",
968 # onosNode=0,
969 # host1=host1,
970 # host2=host2,
971 # encap="MPLS" )
972 # if installResult:
973 # testResult = main.intentFunction.testHostIntent( main,
974 # name="ENCAPSULATION",
975 # intentId=installResult,
976 # onosNode=0,
977 # host1=host1,
978 # host2=host2,
979 # sw1="s5",
980 # sw2="s2",
981 # expectedLink=18 )
982 # else:
983 # main.CLIs[ 0 ].removeAllIntents( purge=True )
984 #
985 # utilities.assert_equals( expect=main.TRUE,
986 # actual=testResult,
987 # onpass=main.assertReturnString,
988 # onfail=main.assertReturnString )
989
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700990 main.step( "Confirm that ONOS leadership is unchanged" )
acsmarse6b410f2015-07-17 14:39:34 -0700991 intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
alison52b25892016-09-19 10:53:48 -0700992 testResult = main.intentFunction.checkLeaderChange( intentLeadersOld,
acsmarse6b410f2015-07-17 14:39:34 -0700993 intentLeadersNew )
994
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800995 utilities.assert_equals( expect=main.TRUE,
996 actual=testResult,
997 onpass="ONOS Leaders Unchanged",
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700998 onfail="ONOS Leader Mismatch" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800999
kelvin-onlab016dce22015-08-10 09:54:11 -07001000 main.intentFunction.report( main )
1001
kelvin-onlabb769f562015-07-15 17:05:10 -07001002 def CASE2000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001003 """
1004 Add point intents between 2 hosts:
1005 - Get device ids | ports
1006 - Add point intents
1007 - Check intents
1008 - Verify flows
1009 - Ping hosts
1010 - Reroute
1011 - Link down
1012 - Verify flows
1013 - Check topology
1014 - Ping hosts
1015 - Link up
1016 - Verify flows
1017 - Check topology
1018 - Ping hosts
1019 - Remove intents
1020 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001021 if main.initialized == main.FALSE:
1022 main.log.error( "Test components did not start correctly, skipping further tests" )
1023 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001024 # Assert variables - These variable's name|format must be followed
1025 # if you want to use the wrapper function
1026 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001027 try:
1028 assert main.CLIs
1029 except AssertionError:
1030 main.log.error( "There is no main.CLIs, skipping test cases" )
1031 main.initialized = main.FALSE
1032 main.skipCase()
1033 try:
1034 assert main.Mininet1
1035 except AssertionError:
1036 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1037 main.initialized = main.FALSE
1038 main.skipCase()
1039 try:
1040 assert main.numSwitch
1041 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001042 main.log.error( "Place the total number of switch topology in " +\
1043 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001044 main.initialized = main.FALSE
1045 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001046
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001047 main.testName = "Point Intents"
1048 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001049 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001050 main.caseExplanation = "This test case will test point to point" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001051 " intents using " + str( main.numCtrls ) +\
1052 " node(s) cluster;\n" +\
1053 "Different type of hosts will be tested in " +\
1054 "each step such as IPV4, Dual stack, VLAN etc" +\
1055 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001056 " OVS running in Mininet and compile intents" +\
1057 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001058
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001059 # No option point intents
1060 main.step( "NOOPTION: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001061 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001062 senders = [
1063 { "name":"h1","device":"of:0000000000000005/1" }
1064 ]
1065 recipients = [
1066 { "name":"h9","device":"of:0000000000000006/1" }
1067 ]
Jeremy42df2e72016-02-23 16:37:46 -08001068 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001069 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001070 main,
1071 name="NOOPTION",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001072 senders=senders,
1073 recipients=recipients )
1074
1075 if installResult:
1076 testResult = main.intentFunction.testPointIntent(
1077 main,
1078 intentId=installResult,
1079 name="NOOPTION",
1080 senders=senders,
1081 recipients=recipients,
1082 sw1="s5",
1083 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001084 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001085 else:
1086 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001087
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001088 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001089 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001090 onpass=main.assertReturnString,
1091 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001092
kelvin-onlabb769f562015-07-15 17:05:10 -07001093 main.step( "IPV4: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001094 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001095 senders = [
1096 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1097 ]
1098 recipients = [
1099 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09" }
1100 ]
Jeremy42df2e72016-02-23 16:37:46 -08001101 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001102 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001103 main,
1104 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001105 senders=senders,
1106 recipients=recipients,
1107 ethType="IPV4" )
1108
1109 if installResult:
1110 testResult = main.intentFunction.testPointIntent(
1111 main,
1112 intentId=installResult,
1113 name="IPV4",
1114 senders=senders,
1115 recipients=recipients,
1116 sw1="s5",
1117 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001118 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001119 else:
1120 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001121
1122 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001123 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001124 onpass=main.assertReturnString,
1125 onfail=main.assertReturnString )
alisonda157272016-12-22 01:13:21 -08001126
1127 main.step("Protected: Add point intents between h1 and h9")
1128 main.assertReturnString = "Assertion Result for protected point intent\n"
1129 senders = [
1130 {"name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01"}
1131 ]
1132 recipients = [
1133 {"name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09"}
1134 ]
1135 testResult = main.FALSE
1136 installResult = main.intentFunction.installPointIntent(
1137 main,
1138 name="Protected",
1139 senders=senders,
1140 recipients=recipients,
1141 protected=True )
1142
1143 if installResult:
1144 testResult = main.intentFunction.testPointIntent(
1145 main,
1146 name="Protected",
1147 intentId=installResult,
1148 senders=senders,
1149 recipients=recipients,
1150 sw1="s5",
1151 sw2="s2",
1152 protected=True,
1153 expectedLink=18 )
1154 else:
1155 main.CLIs[ 0 ].removeAllIntents( purge=True )
1156
1157 utilities.assert_equals( expect=main.TRUE,
1158 actual=testResult,
1159 onpass=main.assertReturnString,
1160 onfail=main.assertReturnString )
1161
kelvin-onlabb769f562015-07-15 17:05:10 -07001162 main.step( "IPV4_2: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001163 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001164 senders = [
1165 { "name":"h1","device":"of:0000000000000005/1" }
1166 ]
1167 recipients = [
1168 { "name":"h9","device":"of:0000000000000006/1" }
1169 ]
Jeremy42df2e72016-02-23 16:37:46 -08001170 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001171 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001172 main,
1173 name="IPV4_2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001174 senders=senders,
1175 recipients=recipients,
1176 ethType="IPV4" )
1177
1178 if installResult:
1179 testResult = main.intentFunction.testPointIntent(
1180 main,
1181 intentId=installResult,
1182 name="IPV4_2",
1183 senders=senders,
1184 recipients=recipients,
1185 sw1="s5",
1186 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001187 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001188 else:
1189 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001190
1191 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001192 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001193 onpass=main.assertReturnString,
1194 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001195
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001196 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001197 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001198 senders = [
1199 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01",
Jeremy6f000c62016-02-25 17:02:28 -08001200 "ip":( main.h1.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001201 ]
1202 recipients = [
1203 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09",
Jeremy6f000c62016-02-25 17:02:28 -08001204 "ip":( main.h9.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001205 ]
Jeremy6f000c62016-02-25 17:02:28 -08001206 ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ]
kelvin-onlab79ce0492015-07-27 16:14:39 -07001207 # Uneccessary, not including this in the selectors
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001208 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
1209 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
Jeremy42df2e72016-02-23 16:37:46 -08001210 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001211 installResult = main.intentFunction.installPointIntent(
1212 main,
1213 name="SDNIP-ICMP",
1214 senders=senders,
1215 recipients=recipients,
1216 ethType="IPV4",
1217 ipProto=ipProto,
1218 tcpSrc=tcpSrc,
1219 tcpDst=tcpDst )
1220
1221 if installResult:
1222 testResult = main.intentFunction.testPointIntent(
1223 main,
1224 intentId=installResult,
1225 name="SDNIP_ICMP",
1226 senders=senders,
1227 recipients=recipients,
1228 sw1="s5",
1229 sw2="s2",
Jeremy Songstere405d3d2016-05-17 11:18:57 -07001230 expectedLink=18,
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001231 useTCP=True )
Jeremy42df2e72016-02-23 16:37:46 -08001232 else:
1233 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabb769f562015-07-15 17:05:10 -07001234
1235 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001236 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001237 onpass=main.assertReturnString,
1238 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001239
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001240 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001241 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
kelvin-onlabb769f562015-07-15 17:05:10 -07001242 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
1243 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab58dc39e2015-08-06 08:11:09 -07001244 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
1245 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlabb769f562015-07-15 17:05:10 -07001246 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
1247 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
1248 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
1249
kelvin-onlab58dc39e2015-08-06 08:11:09 -07001250 stepResult = main.intentFunction.pointIntentTcp(
kelvin-onlabb769f562015-07-15 17:05:10 -07001251 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001252 name="SDNIP-TCP",
kelvin-onlabb769f562015-07-15 17:05:10 -07001253 host1="h1",
1254 host2="h9",
1255 deviceId1="of:0000000000000005/1",
1256 deviceId2="of:0000000000000006/1",
1257 mac1=mac1,
1258 mac2=mac2,
1259 ethType="IPV4",
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001260 ipProto=ipProto,
1261 ip1=ip1,
1262 ip2=ip2,
1263 tcp1=tcp1,
1264 tcp2=tcp2 )
kelvin-onlabb769f562015-07-15 17:05:10 -07001265
1266 utilities.assert_equals( expect=main.TRUE,
Jeremy6f000c62016-02-25 17:02:28 -08001267 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -07001268 onpass=main.assertReturnString,
1269 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001270
acsmars5d8cc862015-09-25 09:44:50 -07001271 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
1272 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001273 senders = [
1274 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1275 ]
1276 recipients = [
1277 { "name":"h11","device":"of:0000000000000006/3","mac":"00:00:00:00:00:0B" }
1278 ]
Jeremy42df2e72016-02-23 16:37:46 -08001279 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001280 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001281 main,
1282 name="DUALSTACK1",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001283 senders=senders,
1284 recipients=recipients,
1285 ethType="IPV4" )
1286
1287 if installResult:
1288 testResult = main.intentFunction.testPointIntent(
1289 main,
1290 intentId=installResult,
1291 name="DUALSTACK1",
1292 senders=senders,
1293 recipients=recipients,
1294 sw1="s5",
1295 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001296 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001297 else:
1298 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001299
1300 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001301 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001302 onpass=main.assertReturnString,
1303 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001304
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001305 main.step( "VLAN: Add point intents between h5 and h21" )
acsmars5d8cc862015-09-25 09:44:50 -07001306 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001307 senders = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001308 { "name":"h5","device":"of:0000000000000005/5","mac":"00:00:00:00:00:05", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001309 ]
1310 recipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001311 { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001312 ]
Jeremy42df2e72016-02-23 16:37:46 -08001313 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001314 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001315 main,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001316 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001317 senders=senders,
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001318 recipients=recipients )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001319
1320 if installResult:
1321 testResult = main.intentFunction.testPointIntent(
1322 main,
1323 intentId=installResult,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001324 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001325 senders=senders,
1326 recipients=recipients,
1327 sw1="s5",
1328 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001329 expectedLink=18 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001330
1331 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001332 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001333 onpass=main.assertReturnString,
1334 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001335
Jeremy Songsterff553672016-05-12 17:06:23 -07001336 main.step( "VLAN: Add point intents between h5 and h21" )
1337 main.assertReturnString = "Assertion Result for VLAN IPV4 point intents with VLAN treatment\n"
1338 senders = [
1339 { "name":"h4", "vlan":"100" }
1340 ]
1341 recipients = [
1342 { "name":"h21", "vlan":"200" }
1343 ]
1344 testResult = main.FALSE
Jeremy Songsterff553672016-05-12 17:06:23 -07001345 installResult = main.intentFunction.installPointIntent(
1346 main,
1347 name="VLAN2",
1348 senders=senders,
1349 recipients=recipients,
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001350 setVlan=200 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001351
1352 if installResult:
1353 testResult = main.intentFunction.testPointIntent(
1354 main,
1355 intentId=installResult,
1356 name="VLAN2",
1357 senders=senders,
1358 recipients=recipients,
1359 sw1="s5",
1360 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001361 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001362
1363 utilities.assert_equals( expect=main.TRUE,
1364 actual=testResult,
1365 onpass=main.assertReturnString,
1366 onfail=main.assertReturnString )
1367
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001368 main.step( "1HOP: Add point intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -07001369 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001370 senders = [
1371 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1372 ]
1373 recipients = [
1374 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1375 ]
Jeremy42df2e72016-02-23 16:37:46 -08001376 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001377 installResult = main.intentFunction.installPointIntent(
1378 main,
1379 name="1HOP IPV4",
1380 senders=senders,
1381 recipients=recipients,
1382 ethType="IPV4" )
1383
1384 if installResult:
1385 testResult = main.intentFunction.testPointIntent(
1386 main,
1387 intentId=installResult,
1388 name="1HOP IPV4",
1389 senders=senders,
1390 recipients=recipients,
1391 sw1="s5",
1392 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001393 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001394 else:
1395 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001396
1397 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001398 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001399 onpass=main.assertReturnString,
1400 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001401
Jeremy Songsterc032f162016-08-04 17:14:49 -07001402 main.step( "Add point to point intents using VLAN Encapsulation" )
1403 main.assertReturnString = "Assertion Result for VLAN Encapsulation Point Intent"
1404 senders = [
1405 { "name":"h1","device":"of:0000000000000005/1" }
1406 ]
1407 recipients = [
1408 { "name":"h9","device":"of:0000000000000006/1" }
1409 ]
1410 testResult = main.FALSE
Jeremy Songsterc032f162016-08-04 17:14:49 -07001411 installResult = main.intentFunction.installPointIntent(
1412 main,
1413 name="ENCAPSULATION",
1414 senders=senders,
1415 recipients=recipients,
1416 encap="VLAN" )
1417
1418 if installResult:
1419 testResult = main.intentFunction.testPointIntent(
1420 main,
1421 intentId=installResult,
1422 name="ENCAPSULATION",
1423 senders=senders,
1424 recipients=recipients,
1425 sw1="s5",
1426 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001427 expectedLink=18 )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001428 else:
1429 main.CLIs[ 0 ].removeAllIntents( purge=True )
1430
1431 utilities.assert_equals( expect=main.TRUE,
1432 actual=testResult,
1433 onpass=main.assertReturnString,
1434 onfail=main.assertReturnString )
1435
Shreya Chowdhary6fbb96c2017-05-02 16:20:19 -07001436 main.step( "BANDWIDTH ALLOCATION: Checking bandwidth allocation for point intents between h1 and h9" )
1437 main.assertReturnString = "Assertion Result for BANDWIDTH ALLOCATION for point intent\n"
1438 senders = [
1439 { "name":"h1","device":"of:0000000000000005/1" }
1440 ]
1441 recipients = [
1442 { "name":"h9","device":"of:0000000000000006/1" }
1443 ]
1444 testResult = main.FALSE
1445 installResult = main.intentFunction.installPointIntent(
1446 main,
1447 name="NOOPTION",
1448 senders=senders,
1449 recipients=recipients,
1450 bandwidth=100,
1451 bandwidthFlag=True )
1452
1453 if installResult:
1454 testResult = main.intentFunction.testPointIntent(
1455 main,
1456 intentId=installResult,
1457 name="NOOPTION",
1458 senders=senders,
1459 recipients=recipients,
1460 sw1="s5",
1461 sw2="s2",
1462 expectedLink=18 )
1463 else:
1464 main.CLIs[ 0 ].removeAllIntents( purge=True )
1465
1466 utilities.assert_equals( expect=main.TRUE,
1467 actual=testResult,
1468 onpass=main.assertReturnString,
1469 onfail=main.assertReturnString )
1470
Shreyaca8990f2017-03-16 11:43:11 -07001471 # Testing MPLS would require kernel version of 4.1 or higher (Current version is 3.13)
alison52b25892016-09-19 10:53:48 -07001472 # main.step( "Add point to point intents using MPLS Encapsulation" )
1473 # main.assertReturnString = "Assertion Result for MPLS Encapsulation Point Intent"
1474 # senders = [
1475 # { "name": "h1", "device": "of:0000000000000005/1" }
1476 # ]
1477 # recipients = [
1478 # { "name": "h9", "device": "of:0000000000000006/1" }
1479 # ]
1480 # testResult = main.FALSE
1481 # installResult = main.intentFunction.installPointIntent(
1482 # main,
1483 # name="ENCAPSULATION",
1484 # senders=senders,
1485 # recipients=recipients,
1486 # encap="MPLS" )
1487 #
1488 # if installResult:
1489 # testResult = main.intentFunction.testPointIntent(
1490 # main,
1491 # intentId=installResult,
1492 # name="ENCAPSULATION",
1493 # senders=senders,
1494 # recipients=recipients,
1495 # sw1="s5",
1496 # sw2="s2",
1497 # expectedLink=18 )
1498 # else:
1499 # main.CLIs[ 0 ].removeAllIntents( purge=True )
1500 #
1501 # utilities.assert_equals( expect=main.TRUE,
1502 # actual=testResult,
1503 # onpass=main.assertReturnString,
1504 # onfail=main.assertReturnString )
1505
kelvin-onlab016dce22015-08-10 09:54:11 -07001506 main.intentFunction.report( main )
1507
kelvin-onlabb769f562015-07-15 17:05:10 -07001508 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001509 """
1510 Add single point to multi point intents
1511 - Get device ids
1512 - Add single point to multi point intents
1513 - Check intents
1514 - Verify flows
1515 - Ping hosts
1516 - Reroute
1517 - Link down
1518 - Verify flows
1519 - Check topology
1520 - Ping hosts
1521 - Link up
1522 - Verify flows
1523 - Check topology
1524 - Ping hosts
1525 - Remove intents
1526 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001527 if main.initialized == main.FALSE:
1528 main.log.error( "Test components did not start correctly, skipping further tests" )
1529 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001530 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001531 try:
1532 assert main.CLIs
1533 except AssertionError:
1534 main.log.error( "There is no main.CLIs, skipping test cases" )
1535 main.initialized = main.FALSE
1536 main.skipCase()
1537 try:
1538 assert main.Mininet1
1539 except AssertionError:
1540 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1541 main.initialized = main.FALSE
1542 main.skipCase()
1543 try:
1544 assert main.numSwitch
1545 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001546 main.log.error( "Place the total number of switch topology in "+ \
1547 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001548 main.initialized = main.FALSE
1549 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001550
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001551 main.testName = "Single to Multi Point Intents"
1552 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001553 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001554 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001555 " multi point intents using " +\
1556 str( main.numCtrls ) + " node(s) cluster;\n" +\
1557 "Different type of hosts will be tested in " +\
1558 "each step such as IPV4, Dual stack, VLAN etc" +\
1559 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001560 " OVS running in Mininet and compile intents" +\
1561 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001562
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001563 main.step( "NOOPTION: Install and test single point to multi point intents" )
1564 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
1565 senders = [
1566 { "name":"h8", "device":"of:0000000000000005/8" }
1567 ]
1568 recipients = [
1569 { "name":"h16", "device":"of:0000000000000006/8" },
1570 { "name":"h24", "device":"of:0000000000000007/8" }
1571 ]
1572 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1573 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1574 testResult = main.FALSE
1575 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001576 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001577 name="NOOPTION",
1578 senders=senders,
1579 recipients=recipients,
1580 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001581 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001582
1583 if installResult:
1584 testResult = main.intentFunction.testPointIntent(
1585 main,
1586 intentId=installResult,
1587 name="NOOPTION",
1588 senders=senders,
1589 recipients=recipients,
1590 badSenders=badSenders,
1591 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001592 sw1="s5",
1593 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001594 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001595 else:
1596 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001597
1598 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001599 actual=testResult,
1600 onpass=main.assertReturnString,
1601 onfail=main.assertReturnString )
1602
1603 main.step( "IPV4: Install and test single point to multi point intents" )
1604 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses\n"
1605 senders = [
1606 { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" }
1607 ]
1608 recipients = [
1609 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1610 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1611 ]
1612 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1613 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1614 testResult = main.FALSE
1615 installResult = main.intentFunction.installSingleToMultiIntent(
1616 main,
1617 name="IPV4",
1618 senders=senders,
1619 recipients=recipients,
1620 ethType="IPV4",
1621 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001622 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001623
1624 if installResult:
1625 testResult = main.intentFunction.testPointIntent(
1626 main,
1627 intentId=installResult,
1628 name="IPV4",
1629 senders=senders,
1630 recipients=recipients,
1631 badSenders=badSenders,
1632 badRecipients=badRecipients,
1633 sw1="s5",
1634 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001635 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001636 else:
1637 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001638
1639 utilities.assert_equals( expect=main.TRUE,
1640 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001641 onpass=main.assertReturnString,
1642 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001643
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001644 main.step( "IPV4_2: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001645 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 -08001646 senders = [
1647 { "name":"h8", "device":"of:0000000000000005/8" }
1648 ]
1649 recipients = [
1650 { "name":"h16", "device":"of:0000000000000006/8" },
1651 { "name":"h24", "device":"of:0000000000000007/8" }
1652 ]
1653 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1654 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1655 testResult = main.FALSE
1656 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001657 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001658 name="IPV4_2",
1659 senders=senders,
1660 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001661 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001662 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001663 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001664
1665 if installResult:
1666 testResult = main.intentFunction.testPointIntent(
1667 main,
1668 intentId=installResult,
1669 name="IPV4_2",
1670 senders=senders,
1671 recipients=recipients,
1672 badSenders=badSenders,
1673 badRecipients=badRecipients,
1674 sw1="s5",
1675 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001676 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001677 else:
1678 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001679
1680 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001681 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001682 onpass=main.assertReturnString,
1683 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001684
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001685 main.step( "VLAN: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001686 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 -08001687 senders = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001688 { "name":"h4", "device":"of:0000000000000005/4", "mac":"00:00:00:00:00:04", "vlan":"100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001689 ]
1690 recipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001691 { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C", "vlan":"100" },
1692 { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14", "vlan":"100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001693 ]
1694 badSenders=[ { "name":"h13" } ] # Senders that are not in the intent
1695 badRecipients=[ { "name":"h21" } ] # Recipients that are not in the intent
1696 testResult = main.FALSE
1697 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001698 main,
alison52b25892016-09-19 10:53:48 -07001699 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001700 senders=senders,
1701 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001702 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001703 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001704
1705 if installResult:
1706 testResult = main.intentFunction.testPointIntent(
1707 main,
1708 intentId=installResult,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001709 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001710 senders=senders,
1711 recipients=recipients,
1712 badSenders=badSenders,
1713 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001714 sw1="s5",
1715 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001716 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001717 else:
1718 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001719
1720 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001721 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001722 onpass=main.assertReturnString,
1723 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001724
Jeremy Songsterff553672016-05-12 17:06:23 -07001725 main.step( "VLAN: Add single point to multi point intents" )
1726 main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n"
1727 senders = [
1728 { "name":"h5", "vlan":"200" }
1729 ]
1730 recipients = [
1731 { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C", "vlan":"100" },
1732 { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14", "vlan":"100" }
1733 ]
1734 badSenders=[ { "name":"h13" } ] # Senders that are not in the intent
1735 badRecipients=[ { "name":"h21" } ] # Recipients that are not in the intent
1736 testResult = main.FALSE
Jeremy Songsterff553672016-05-12 17:06:23 -07001737 installResult = main.intentFunction.installSingleToMultiIntent(
1738 main,
1739 name="VLAN2",
1740 senders=senders,
1741 recipients=recipients,
1742 sw1="s5",
1743 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001744 setVlan=100 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001745
1746 if installResult:
1747 testResult = main.intentFunction.testPointIntent(
1748 main,
1749 intentId=installResult,
1750 name="VLAN2",
1751 senders=senders,
1752 recipients=recipients,
1753 badSenders=badSenders,
1754 badRecipients=badRecipients,
1755 sw1="s5",
1756 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001757 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001758 else:
1759 main.CLIs[ 0 ].removeAllIntents( purge=True )
1760
1761 utilities.assert_equals( expect=main.TRUE,
1762 actual=testResult,
1763 onpass=main.assertReturnString,
1764 onfail=main.assertReturnString )
1765
alison52b25892016-09-19 10:53:48 -07001766 # Does not support Single point to multi point encapsulation
1767 # main.step( "ENCAPSULATION: Install and test single point to multi point intents" )
1768 # main.assertReturnString = "Assertion results for VLAN Encapsulation single to multi point intent\n"
1769 # senders = [
1770 # { "name":"h8", "device":"of:0000000000000005/8" }
1771 # ]
1772 # recipients = [
1773 # { "name":"h16", "device":"of:0000000000000006/8" },
1774 # { "name":"h24", "device":"of:0000000000000007/8" }
1775 # ]
1776 # badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1777 # badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1778 # testResult = main.FALSE
1779 # installResult = main.intentFunction.installSingleToMultiIntent(
1780 # main,
1781 # name="ENCAPSULATION",
1782 # senders=senders,
1783 # recipients=recipients,
1784 # sw1="s5",
1785 # sw2="s2",
1786 # encap="VLAN" )
1787 #
1788 # if installResult:
1789 # testResult = main.intentFunction.testPointIntent(
1790 # main,
1791 # intentId=installResult,
1792 # name="ENCAPSULATION",
1793 # senders=senders,
1794 # recipients=recipients,
1795 # badSenders=badSenders,
1796 # badRecipients=badRecipients,
1797 # sw1="s5",
1798 # sw2="s2",
1799 # expectedLink=18 )
1800 # else:
1801 # main.CLIs[ 0 ].removeAllIntents( purge=True )
1802 #
1803 # utilities.assert_equals( expect=main.TRUE,
1804 # actual=testResult,
1805 # onpass=main.assertReturnString,
1806 # onfail=main.assertReturnString )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001807
kelvin-onlab016dce22015-08-10 09:54:11 -07001808 main.intentFunction.report( main )
1809
kelvin-onlabb769f562015-07-15 17:05:10 -07001810 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001811 """
1812 Add multi point to single point intents
1813 - Get device ids
1814 - Add multi point to single point intents
1815 - Check intents
1816 - Verify flows
1817 - Ping hosts
1818 - Reroute
1819 - Link down
1820 - Verify flows
1821 - Check topology
1822 - Ping hosts
1823 - Link up
1824 - Verify flows
1825 - Check topology
1826 - Ping hosts
1827 - Remove intents
1828 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001829 if main.initialized == main.FALSE:
1830 main.log.error( "Test components did not start correctly, skipping further tests" )
1831 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001832 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001833 try:
1834 assert main.CLIs
1835 except AssertionError:
1836 main.log.error( "There is no main.CLIs, skipping test cases" )
1837 main.initialized = main.FALSE
1838 main.skipCase()
1839 try:
1840 assert main.Mininet1
1841 except AssertionError:
1842 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1843 main.initialized = main.FALSE
1844 main.skipCase()
1845 try:
1846 assert main.numSwitch
1847 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001848 main.log.error( "Place the total number of switch topology in "+\
1849 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001850 main.initialized = main.FALSE
1851 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001852
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001853 main.testName = "Multi To Single Point Intents"
1854 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001855 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001856 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001857 " multi point intents using " +\
1858 str( main.numCtrls ) + " node(s) cluster;\n" +\
1859 "Different type of hosts will be tested in " +\
1860 "each step such as IPV4, Dual stack, VLAN etc" +\
1861 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001862 " OVS running in Mininet and compile intents" +\
1863 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001864
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001865 main.step( "NOOPTION: Add multi point to single point intents" )
1866 main.assertReturnString = "Assertion results for NOOPTION multi to single point intent\n"
1867 senders = [
1868 { "name":"h16", "device":"of:0000000000000006/8" },
1869 { "name":"h24", "device":"of:0000000000000007/8" }
1870 ]
1871 recipients = [
1872 { "name":"h8", "device":"of:0000000000000005/8" }
1873 ]
1874 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1875 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1876 testResult = main.FALSE
1877 installResult = main.intentFunction.installMultiToSingleIntent(
1878 main,
1879 name="NOOPTION",
1880 senders=senders,
1881 recipients=recipients,
1882 sw1="s5",
Jeremye0cb5eb2016-01-27 17:39:09 -08001883 sw2="s2" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001884
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001885 if installResult:
1886 testResult = main.intentFunction.testPointIntent(
1887 main,
1888 intentId=installResult,
1889 name="NOOPTION",
1890 senders=senders,
1891 recipients=recipients,
1892 badSenders=badSenders,
1893 badRecipients=badRecipients,
1894 sw1="s5",
1895 sw2="s2",
Jeremye0cb5eb2016-01-27 17:39:09 -08001896 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001897 else:
1898 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001899
1900 utilities.assert_equals( expect=main.TRUE,
1901 actual=testResult,
1902 onpass=main.assertReturnString,
1903 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001904
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001905 main.step( "IPV4: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001906 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 -08001907 senders = [
1908 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1909 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1910 ]
1911 recipients = [
1912 { "name":"h8", "device":"of:0000000000000005/8", "mac":"00:00:00:00:00:08" }
1913 ]
1914 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1915 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1916 testResult = main.FALSE
1917 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001918 main,
1919 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001920 senders=senders,
1921 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001922 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001923 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001924 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001925
1926 if installResult:
1927 testResult = main.intentFunction.testPointIntent(
1928 main,
1929 intentId=installResult,
1930 name="IPV4",
1931 senders=senders,
1932 recipients=recipients,
1933 badSenders=badSenders,
1934 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001935 sw1="s5",
1936 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001937 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001938 else:
1939 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001940
1941 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001942 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001943 onpass=main.assertReturnString,
1944 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001945
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001946 main.step( "IPV4_2: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001947 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 -08001948 senders = [
1949 { "name":"h16", "device":"of:0000000000000006/8" },
1950 { "name":"h24", "device":"of:0000000000000007/8" }
1951 ]
1952 recipients = [
1953 { "name":"h8", "device":"of:0000000000000005/8" }
1954 ]
1955 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1956 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1957 testResult = main.FALSE
1958 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001959 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001960 name="IPV4_2",
1961 senders=senders,
1962 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001963 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001964 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001965 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001966
1967 if installResult:
1968 testResult = main.intentFunction.testPointIntent(
1969 main,
1970 intentId=installResult,
1971 name="IPV4_2",
1972 senders=senders,
1973 recipients=recipients,
1974 badSenders=badSenders,
1975 badRecipients=badRecipients,
1976 sw1="s5",
1977 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001978 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001979 else:
1980 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001981
1982 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001983 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001984 onpass=main.assertReturnString,
1985 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001986
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001987 main.step( "VLAN: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001988 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 -08001989 senders = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001990 { "name":"h13", "device":"of:0000000000000006/5", "vlan":"200" },
1991 { "name":"h21", "device":"of:0000000000000007/5", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001992 ]
1993 recipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001994 { "name":"h5", "device":"of:0000000000000005/5", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001995 ]
1996 badSenders=[ { "name":"h12" } ] # Senders that are not in the intent
1997 badRecipients=[ { "name":"h20" } ] # Recipients that are not in the intent
1998 testResult = main.FALSE
1999 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07002000 main,
2001 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002002 senders=senders,
2003 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002004 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002005 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002006
2007 if installResult:
2008 testResult = main.intentFunction.testPointIntent(
2009 main,
2010 intentId=installResult,
2011 name="VLAN",
2012 senders=senders,
2013 recipients=recipients,
2014 badSenders=badSenders,
2015 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07002016 sw1="s5",
2017 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002018 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08002019 else:
2020 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07002021
2022 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002023 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07002024 onpass=main.assertReturnString,
2025 onfail=main.assertReturnString )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07002026
Jeremy Songsterff553672016-05-12 17:06:23 -07002027 # Right now this fails because of this bug: https://jira.onosproject.org/browse/ONOS-4383
2028 main.step( "VLAN: Add multi point to single point intents" )
2029 main.assertReturnString = "Assertion results for multi to single point intent with VLAN ID treatment\n"
2030 senders = [
2031 { "name":"h13", "device":"of:0000000000000006/5", "vlan":"200" },
2032 { "name":"h21", "device":"of:0000000000000007/5", "vlan":"200" }
2033 ]
2034 recipients = [
2035 { "name":"h4", "vlan":"100" }
2036 ]
2037 badSenders=[ { "name":"h12" } ] # Senders that are not in the intent
2038 badRecipients=[ { "name":"h20" } ] # Recipients that are not in the intent
2039 testResult = main.FALSE
Jeremy Songsterff553672016-05-12 17:06:23 -07002040 installResult = main.intentFunction.installMultiToSingleIntent(
2041 main,
2042 name="VLAN2",
2043 senders=senders,
2044 recipients=recipients,
2045 sw1="s5",
2046 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002047 setVlan=100 )
Jeremy Songsterff553672016-05-12 17:06:23 -07002048
2049 if installResult:
2050 testResult = main.intentFunction.testPointIntent(
2051 main,
2052 intentId=installResult,
2053 name="VLAN2",
2054 senders=senders,
2055 recipients=recipients,
2056 badSenders=badSenders,
2057 badRecipients=badRecipients,
2058 sw1="s5",
2059 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002060 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07002061 else:
2062 main.CLIs[ 0 ].removeAllIntents( purge=True )
2063
2064 utilities.assert_equals( expect=main.TRUE,
2065 actual=testResult,
2066 onpass=main.assertReturnString,
2067 onfail=main.assertReturnString )
2068
Jeremy Songsterc032f162016-08-04 17:14:49 -07002069 main.step( "ENCAPSULATION: Add multi point to single point intents" )
2070 main.assertReturnString = "Assertion results for VLAN Encapsulation multi to single point intent\n"
2071 senders = [
2072 { "name":"h16", "device":"of:0000000000000006/8" },
2073 { "name":"h24", "device":"of:0000000000000007/8" }
2074 ]
2075 recipients = [
2076 { "name":"h8", "device":"of:0000000000000005/8" }
2077 ]
2078 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
2079 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
2080 testResult = main.FALSE
Jeremy Songsterc032f162016-08-04 17:14:49 -07002081 installResult = main.intentFunction.installMultiToSingleIntent(
2082 main,
2083 name="ENCAPSULATION",
2084 senders=senders,
2085 recipients=recipients,
2086 sw1="s5",
2087 sw2="s2",
2088 encap="VLAN" )
2089
2090 if installResult:
2091 testResult = main.intentFunction.testPointIntent(
2092 main,
2093 intentId=installResult,
2094 name="ENCAPSULATION",
2095 senders=senders,
2096 recipients=recipients,
2097 badSenders=badSenders,
2098 badRecipients=badRecipients,
2099 sw1="s5",
2100 sw2="s2",
2101 expectedLink=18 )
2102 else:
2103 main.CLIs[ 0 ].removeAllIntents( purge=True )
2104
2105 utilities.assert_equals( expect=main.TRUE,
2106 actual=testResult,
2107 onpass=main.assertReturnString,
2108 onfail=main.assertReturnString )
2109
Shreyaca8990f2017-03-16 11:43:11 -07002110 #Testing MPLS would require kernel version of 4.1 or higher (Current version is 3.13)
2111 #main.step( "ENCAPSULATION: Add multi point to single point intents" )
2112 #main.assertReturnString = "Assertion results for MPLS Encapsulation multi to single point intent\n"
2113 #senders = [
2114 # { "name": "h16", "device": "of:0000000000000006/8" },
2115 # { "name": "h24", "device": "of:0000000000000007/8" }
2116 #]
2117 #recipients = [
2118 # { "name": "h8", "device": "of:0000000000000005/8" }
2119 #]
2120 #badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
2121 #badRecipients = [ {"name": "h9" } ] # Recipients that are not in the intent
2122 #testResult = main.FALSE
2123 #installResult = main.intentFunction.installMultiToSingleIntent(
2124 # main,
2125 # name="ENCAPSULATION",
2126 # senders=senders,
2127 # recipients=recipients,
2128 # sw1="s5",
2129 # sw2="s2",
2130 # encap="MPLS" )
alison52b25892016-09-19 10:53:48 -07002131 #
Shreyaca8990f2017-03-16 11:43:11 -07002132 #if installResult:
2133 # testResult = main.intentFunction.testPointIntent(
2134 # main,
2135 # intentId=installResult,
2136 # name="ENCAPSULATION",
2137 # senders=senders,
2138 # recipients=recipients,
2139 # badSenders=badSenders,
2140 # badRecipients=badRecipients,
2141 # sw1="s5",
2142 # sw2="s2",
2143 # expectedLink=18 )
2144 #else:
2145 # main.CLIs[ 0 ].removeAllIntents( purge=True )
alison52b25892016-09-19 10:53:48 -07002146 #
Shreyaca8990f2017-03-16 11:43:11 -07002147 #utilities.assert_equals( expect=main.TRUE,
2148 # actual=testResult,
2149 # onpass=main.assertReturnString,
2150 # onfail=main.assertReturnString )
alison52b25892016-09-19 10:53:48 -07002151
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002152 main.intentFunction.report( main )
2153
acsmars1ff5e052015-07-23 11:27:48 -07002154 def CASE5000( self, main ):
2155 """
acsmars5d8cc862015-09-25 09:44:50 -07002156 Tests Host Mobility
2157 Modifies the topology location of h1
acsmars1ff5e052015-07-23 11:27:48 -07002158 """
Jeremyd9e4eb12016-04-13 12:09:06 -07002159 if main.initialized == main.FALSE:
2160 main.log.error( "Test components did not start correctly, skipping further tests" )
2161 main.skipCase()
acsmars1ff5e052015-07-23 11:27:48 -07002162 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07002163 try:
2164 assert main.CLIs
2165 except AssertionError:
2166 main.log.error( "There is no main.CLIs, skipping test cases" )
2167 main.initialized = main.FALSE
2168 main.skipCase()
2169 try:
2170 assert main.Mininet1
2171 except AssertionError:
2172 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
2173 main.initialized = main.FALSE
2174 main.skipCase()
2175 try:
2176 assert main.numSwitch
2177 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002178 main.log.error( "Place the total number of switch topology in "+\
2179 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07002180 main.initialized = main.FALSE
2181 main.skipCase()
alison52b25892016-09-19 10:53:48 -07002182 main.case( "Test host mobility with host intents " + " - " + str( main.numCtrls ) +
2183 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002184 main.step( "Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07002185
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002186 main.log.info( "Moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07002187 main.Mininet1.moveHost( "h1","s5","s6" )
2188
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002189 # Send discovery ping from moved host
2190 # Moving the host brings down the default interfaces and creates a new one.
2191 # Scapy is restarted on this host to detect the new interface
2192 main.h1.stopScapy()
2193 main.h1.startScapy()
2194
2195 # Discover new host location in ONOS and populate host data.
2196 # Host 1 IP and MAC should be unchanged
2197 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
2198 main.intentFunction.populateHostData( main )
2199
acsmars1ff5e052015-07-23 11:27:48 -07002200 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
2201
2202 utilities.assert_equals( expect="of:0000000000000006",
2203 actual=h1PostMove,
2204 onpass="Mobility: Successfully moved h1 to s6",
acsmars5d8cc862015-09-25 09:44:50 -07002205 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07002206 " to single point intents" +
2207 " with IPV4 type and MAC addresses" +
2208 " in the same VLAN" )
2209
2210 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07002211 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002212 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
2213 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
Jeremy42df2e72016-02-23 16:37:46 -08002214 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002215 installResult = main.intentFunction.installHostIntent( main,
alison52b25892016-09-19 10:53:48 -07002216 name="IPV4 Mobility IPV4",
2217 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002218 host1=host1,
Jeremye0cb5eb2016-01-27 17:39:09 -08002219 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -08002220 if installResult:
2221 testResult = main.intentFunction.testHostIntent( main,
alison52b25892016-09-19 10:53:48 -07002222 name="Host Mobility IPV4",
Jeremy2f190ca2016-01-29 15:23:57 -08002223 intentId = installResult,
alison52b25892016-09-19 10:53:48 -07002224 onosNode=0,
Jeremy2f190ca2016-01-29 15:23:57 -08002225 host1=host1,
2226 host2=host2,
2227 sw1="s6",
2228 sw2="s2",
2229 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08002230 else:
2231 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07002232
2233 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002234 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07002235 onpass=main.assertReturnString,
2236 onfail=main.assertReturnString )
kelvin-onlab016dce22015-08-10 09:54:11 -07002237
2238 main.intentFunction.report( main )
Jeremye0cb5eb2016-01-27 17:39:09 -08002239
2240 def CASE6000( self, main ):
2241 """
2242 Tests Multi to Single Point Intent and Single to Multi Point Intent End Point Failure
2243 """
Jeremy Songster9385d412016-06-02 17:57:36 -07002244 # At some later point discussion on this behavior in MPSP and SPMP intents
2245 # will be reoppened and this test case may need to be updated to reflect
2246 # the outcomes of that discussion
Jeremyd9e4eb12016-04-13 12:09:06 -07002247 if main.initialized == main.FALSE:
2248 main.log.error( "Test components did not start correctly, skipping further tests" )
2249 main.skipCase()
Jeremye0cb5eb2016-01-27 17:39:09 -08002250 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07002251 try:
2252 assert main.CLIs
2253 except AssertionError:
2254 main.log.error( "There is no main.CLIs, skipping test cases" )
2255 main.initialized = main.FALSE
2256 main.skipCase()
2257 try:
2258 assert main.Mininet1
2259 except AssertionError:
2260 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
2261 main.initialized = main.FALSE
2262 main.skipCase()
2263 try:
2264 assert main.numSwitch
2265 except AssertionError:
alison52b25892016-09-19 10:53:48 -07002266 main.log.error( "Place the total number of switch topology in " + main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07002267 main.initialized = main.FALSE
2268 main.skipCase()
alison52b25892016-09-19 10:53:48 -07002269 main.case( "Test Multi to Single End Point Failure" + " - " + str( main.numCtrls ) +
2270 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jeremy Songster9385d412016-06-02 17:57:36 -07002271 main.step( "Installing Multi to Single Point intents with no options set" )
2272 main.assertReturnString = "Assertion results for IPV4 multi to single " +\
2273 "point intent end point failure with no options set\n"
Jeremye0cb5eb2016-01-27 17:39:09 -08002274 senders = [
2275 { "name":"h16", "device":"of:0000000000000006/8" },
2276 { "name":"h24", "device":"of:0000000000000007/8" }
2277 ]
2278 recipients = [
2279 { "name":"h8", "device":"of:0000000000000005/8" }
2280 ]
2281 isolatedSenders = [
alison52b25892016-09-19 10:53:48 -07002282 { "name":"h24" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002283 ]
2284 isolatedRecipients = []
2285 testResult = main.FALSE
2286 installResult = main.intentFunction.installMultiToSingleIntent(
2287 main,
2288 name="NOOPTION",
2289 senders=senders,
2290 recipients=recipients,
2291 sw1="s5",
2292 sw2="s2" )
2293
2294 if installResult:
2295 testResult = main.intentFunction.testEndPointFail(
2296 main,
2297 intentId=installResult,
2298 name="NOOPTION",
2299 senders=senders,
2300 recipients=recipients,
2301 isolatedSenders=isolatedSenders,
2302 isolatedRecipients=isolatedRecipients,
2303 sw1="s6",
2304 sw2="s2",
2305 sw3="s4",
2306 sw4="s1",
2307 sw5="s3",
2308 expectedLink1=16,
2309 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002310 else:
2311 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002312
2313 utilities.assert_equals( expect=main.TRUE,
2314 actual=testResult,
2315 onpass=main.assertReturnString,
2316 onfail=main.assertReturnString )
2317
Jeremy Songster9385d412016-06-02 17:57:36 -07002318 main.step( "Installing Multi to Single Point intents with partial failure allowed" )
2319
2320 main.assertReturnString = "Assertion results for IPV4 multi to single " +\
2321 "with partial failures allowed\n"
2322 senders = [
2323 { "name":"h16", "device":"of:0000000000000006/8" },
2324 { "name":"h24", "device":"of:0000000000000007/8" }
2325 ]
2326 recipients = [
2327 { "name":"h8", "device":"of:0000000000000005/8" }
2328 ]
2329 isolatedSenders = [
alison52b25892016-09-19 10:53:48 -07002330 { "name":"h24" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002331 ]
2332 isolatedRecipients = []
2333 testResult = main.FALSE
Jeremy Songster9385d412016-06-02 17:57:36 -07002334 installResult = main.intentFunction.installMultiToSingleIntent(
2335 main,
2336 name="NOOPTION",
2337 senders=senders,
2338 recipients=recipients,
2339 sw1="s5",
2340 sw2="s2",
2341 partial=True )
2342
2343 if installResult:
2344 testResult = main.intentFunction.testEndPointFail(
2345 main,
2346 intentId=installResult,
2347 name="NOOPTION",
2348 senders=senders,
2349 recipients=recipients,
2350 isolatedSenders=isolatedSenders,
2351 isolatedRecipients=isolatedRecipients,
2352 sw1="s6",
2353 sw2="s2",
2354 sw3="s4",
2355 sw4="s1",
2356 sw5="s3",
2357 expectedLink1=16,
2358 expectedLink2=14,
2359 partial=True )
2360 else:
2361 main.CLIs[ 0 ].removeAllIntents( purge=True )
2362
2363 utilities.assert_equals( expect=main.TRUE,
2364 actual=testResult,
2365 onpass=main.assertReturnString,
2366 onfail=main.assertReturnString )
2367
Jeremye0cb5eb2016-01-27 17:39:09 -08002368 main.step( "NOOPTION: Install and test single point to multi point intents" )
Jeremy Songster9385d412016-06-02 17:57:36 -07002369 main.assertReturnString = "Assertion results for IPV4 single to multi " +\
2370 "point intent with no options set\n"
Jeremye0cb5eb2016-01-27 17:39:09 -08002371 senders = [
2372 { "name":"h8", "device":"of:0000000000000005/8" }
2373 ]
2374 recipients = [
2375 { "name":"h16", "device":"of:0000000000000006/8" },
2376 { "name":"h24", "device":"of:0000000000000007/8" }
2377 ]
Jeremy Songster9385d412016-06-02 17:57:36 -07002378 isolatedSenders = []
2379 isolatedRecipients = [
alison52b25892016-09-19 10:53:48 -07002380 { "name":"h24" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002381 ]
2382 testResult = main.FALSE
2383 installResult = main.intentFunction.installSingleToMultiIntent(
2384 main,
2385 name="NOOPTION",
2386 senders=senders,
2387 recipients=recipients,
2388 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002389 sw2="s2" )
Jeremye0cb5eb2016-01-27 17:39:09 -08002390
2391 if installResult:
2392 testResult = main.intentFunction.testEndPointFail(
2393 main,
2394 intentId=installResult,
2395 name="NOOPTION",
2396 senders=senders,
2397 recipients=recipients,
2398 isolatedSenders=isolatedSenders,
2399 isolatedRecipients=isolatedRecipients,
2400 sw1="s6",
2401 sw2="s2",
2402 sw3="s4",
2403 sw4="s1",
2404 sw5="s3",
2405 expectedLink1=16,
2406 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002407 else:
2408 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002409
2410 utilities.assert_equals( expect=main.TRUE,
2411 actual=testResult,
2412 onpass=main.assertReturnString,
2413 onfail=main.assertReturnString )
Jeremy Songster9385d412016-06-02 17:57:36 -07002414 # Right now this functionality doesn't work properly in SPMP intents
2415 main.step( "NOOPTION: Install and test single point to multi point " +\
2416 "intents with partial failures allowed" )
2417 main.assertReturnString = "Assertion results for IPV4 single to multi " +\
2418 "point intent with partial failures allowed\n"
2419 senders = [
2420 { "name":"h8", "device":"of:0000000000000005/8" }
2421 ]
2422 recipients = [
2423 { "name":"h16", "device":"of:0000000000000006/8" },
2424 { "name":"h24", "device":"of:0000000000000007/8" }
2425 ]
2426 isolatedSenders = []
2427 isolatedRecipients = [
alison52b25892016-09-19 10:53:48 -07002428 { "name":"h24" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002429 ]
2430 testResult = main.FALSE
Jeremy Songster9385d412016-06-02 17:57:36 -07002431 installResult = main.intentFunction.installSingleToMultiIntent(
2432 main,
2433 name="NOOPTION",
2434 senders=senders,
2435 recipients=recipients,
2436 sw1="s5",
2437 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002438 partial=True )
Jeremy Songster9385d412016-06-02 17:57:36 -07002439
2440 if installResult:
2441 testResult = main.intentFunction.testEndPointFail(
2442 main,
2443 intentId=installResult,
2444 name="NOOPTION",
2445 senders=senders,
2446 recipients=recipients,
2447 isolatedSenders=isolatedSenders,
2448 isolatedRecipients=isolatedRecipients,
2449 sw1="s6",
2450 sw2="s2",
2451 sw3="s4",
2452 sw4="s1",
2453 sw5="s3",
2454 expectedLink1=16,
2455 expectedLink2=14,
2456 partial=True )
2457 else:
2458 main.CLIs[ 0 ].removeAllIntents( purge=True )
2459
2460 utilities.assert_equals( expect=main.TRUE,
2461 actual=testResult,
2462 onpass=main.assertReturnString,
2463 onfail=main.assertReturnString )
Jeremye0cb5eb2016-01-27 17:39:09 -08002464
Chiyu Chengef109502016-11-21 15:51:38 -08002465 main.intentFunction.report( main )