blob: f96ef73cc66814e4d88a35d6a9839611dfaff77c [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
Shreyaca8990f2017-03-16 11:43:11 -07001436 # Testing MPLS would require kernel version of 4.1 or higher (Current version is 3.13)
alison52b25892016-09-19 10:53:48 -07001437 # main.step( "Add point to point intents using MPLS Encapsulation" )
1438 # main.assertReturnString = "Assertion Result for MPLS Encapsulation Point Intent"
1439 # senders = [
1440 # { "name": "h1", "device": "of:0000000000000005/1" }
1441 # ]
1442 # recipients = [
1443 # { "name": "h9", "device": "of:0000000000000006/1" }
1444 # ]
1445 # testResult = main.FALSE
1446 # installResult = main.intentFunction.installPointIntent(
1447 # main,
1448 # name="ENCAPSULATION",
1449 # senders=senders,
1450 # recipients=recipients,
1451 # encap="MPLS" )
1452 #
1453 # if installResult:
1454 # testResult = main.intentFunction.testPointIntent(
1455 # main,
1456 # intentId=installResult,
1457 # name="ENCAPSULATION",
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
kelvin-onlab016dce22015-08-10 09:54:11 -07001471 main.intentFunction.report( main )
1472
kelvin-onlabb769f562015-07-15 17:05:10 -07001473 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001474 """
1475 Add single point to multi point intents
1476 - Get device ids
1477 - Add single point to multi point intents
1478 - Check intents
1479 - Verify flows
1480 - Ping hosts
1481 - Reroute
1482 - Link down
1483 - Verify flows
1484 - Check topology
1485 - Ping hosts
1486 - Link up
1487 - Verify flows
1488 - Check topology
1489 - Ping hosts
1490 - Remove intents
1491 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001492 if main.initialized == main.FALSE:
1493 main.log.error( "Test components did not start correctly, skipping further tests" )
1494 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001495 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001496 try:
1497 assert main.CLIs
1498 except AssertionError:
1499 main.log.error( "There is no main.CLIs, skipping test cases" )
1500 main.initialized = main.FALSE
1501 main.skipCase()
1502 try:
1503 assert main.Mininet1
1504 except AssertionError:
1505 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1506 main.initialized = main.FALSE
1507 main.skipCase()
1508 try:
1509 assert main.numSwitch
1510 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001511 main.log.error( "Place the total number of switch topology in "+ \
1512 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001513 main.initialized = main.FALSE
1514 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001515
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001516 main.testName = "Single to Multi Point Intents"
1517 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001518 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001519 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001520 " multi point intents using " +\
1521 str( main.numCtrls ) + " node(s) cluster;\n" +\
1522 "Different type of hosts will be tested in " +\
1523 "each step such as IPV4, Dual stack, VLAN etc" +\
1524 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001525 " OVS running in Mininet and compile intents" +\
1526 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001527
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001528 main.step( "NOOPTION: Install and test single point to multi point intents" )
1529 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
1530 senders = [
1531 { "name":"h8", "device":"of:0000000000000005/8" }
1532 ]
1533 recipients = [
1534 { "name":"h16", "device":"of:0000000000000006/8" },
1535 { "name":"h24", "device":"of:0000000000000007/8" }
1536 ]
1537 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1538 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1539 testResult = main.FALSE
1540 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001541 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001542 name="NOOPTION",
1543 senders=senders,
1544 recipients=recipients,
1545 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001546 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001547
1548 if installResult:
1549 testResult = main.intentFunction.testPointIntent(
1550 main,
1551 intentId=installResult,
1552 name="NOOPTION",
1553 senders=senders,
1554 recipients=recipients,
1555 badSenders=badSenders,
1556 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001557 sw1="s5",
1558 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001559 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001560 else:
1561 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001562
1563 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001564 actual=testResult,
1565 onpass=main.assertReturnString,
1566 onfail=main.assertReturnString )
1567
1568 main.step( "IPV4: Install and test single point to multi point intents" )
1569 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses\n"
1570 senders = [
1571 { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" }
1572 ]
1573 recipients = [
1574 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1575 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1576 ]
1577 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1578 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1579 testResult = main.FALSE
1580 installResult = main.intentFunction.installSingleToMultiIntent(
1581 main,
1582 name="IPV4",
1583 senders=senders,
1584 recipients=recipients,
1585 ethType="IPV4",
1586 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001587 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001588
1589 if installResult:
1590 testResult = main.intentFunction.testPointIntent(
1591 main,
1592 intentId=installResult,
1593 name="IPV4",
1594 senders=senders,
1595 recipients=recipients,
1596 badSenders=badSenders,
1597 badRecipients=badRecipients,
1598 sw1="s5",
1599 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001600 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001601 else:
1602 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001603
1604 utilities.assert_equals( expect=main.TRUE,
1605 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001606 onpass=main.assertReturnString,
1607 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001608
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001609 main.step( "IPV4_2: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001610 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 -08001611 senders = [
1612 { "name":"h8", "device":"of:0000000000000005/8" }
1613 ]
1614 recipients = [
1615 { "name":"h16", "device":"of:0000000000000006/8" },
1616 { "name":"h24", "device":"of:0000000000000007/8" }
1617 ]
1618 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1619 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1620 testResult = main.FALSE
1621 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001622 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001623 name="IPV4_2",
1624 senders=senders,
1625 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001626 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001627 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001628 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001629
1630 if installResult:
1631 testResult = main.intentFunction.testPointIntent(
1632 main,
1633 intentId=installResult,
1634 name="IPV4_2",
1635 senders=senders,
1636 recipients=recipients,
1637 badSenders=badSenders,
1638 badRecipients=badRecipients,
1639 sw1="s5",
1640 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001641 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001642 else:
1643 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001644
1645 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001646 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001647 onpass=main.assertReturnString,
1648 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001649
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001650 main.step( "VLAN: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001651 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 -08001652 senders = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001653 { "name":"h4", "device":"of:0000000000000005/4", "mac":"00:00:00:00:00:04", "vlan":"100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001654 ]
1655 recipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001656 { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C", "vlan":"100" },
1657 { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14", "vlan":"100" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001658 ]
1659 badSenders=[ { "name":"h13" } ] # Senders that are not in the intent
1660 badRecipients=[ { "name":"h21" } ] # Recipients that are not in the intent
1661 testResult = main.FALSE
1662 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001663 main,
alison52b25892016-09-19 10:53:48 -07001664 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001665 senders=senders,
1666 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001667 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001668 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001669
1670 if installResult:
1671 testResult = main.intentFunction.testPointIntent(
1672 main,
1673 intentId=installResult,
Jeremy Songster832f9e92016-05-05 14:30:49 -07001674 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001675 senders=senders,
1676 recipients=recipients,
1677 badSenders=badSenders,
1678 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001679 sw1="s5",
1680 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001681 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001682 else:
1683 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001684
1685 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001686 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001687 onpass=main.assertReturnString,
1688 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001689
Jeremy Songsterff553672016-05-12 17:06:23 -07001690 main.step( "VLAN: Add single point to multi point intents" )
1691 main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n"
1692 senders = [
1693 { "name":"h5", "vlan":"200" }
1694 ]
1695 recipients = [
1696 { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C", "vlan":"100" },
1697 { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14", "vlan":"100" }
1698 ]
1699 badSenders=[ { "name":"h13" } ] # Senders that are not in the intent
1700 badRecipients=[ { "name":"h21" } ] # Recipients that are not in the intent
1701 testResult = main.FALSE
Jeremy Songsterff553672016-05-12 17:06:23 -07001702 installResult = main.intentFunction.installSingleToMultiIntent(
1703 main,
1704 name="VLAN2",
1705 senders=senders,
1706 recipients=recipients,
1707 sw1="s5",
1708 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001709 setVlan=100 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001710
1711 if installResult:
1712 testResult = main.intentFunction.testPointIntent(
1713 main,
1714 intentId=installResult,
1715 name="VLAN2",
1716 senders=senders,
1717 recipients=recipients,
1718 badSenders=badSenders,
1719 badRecipients=badRecipients,
1720 sw1="s5",
1721 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001722 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07001723 else:
1724 main.CLIs[ 0 ].removeAllIntents( purge=True )
1725
1726 utilities.assert_equals( expect=main.TRUE,
1727 actual=testResult,
1728 onpass=main.assertReturnString,
1729 onfail=main.assertReturnString )
1730
alison52b25892016-09-19 10:53:48 -07001731 # Does not support Single point to multi point encapsulation
1732 # main.step( "ENCAPSULATION: Install and test single point to multi point intents" )
1733 # main.assertReturnString = "Assertion results for VLAN Encapsulation single to multi point intent\n"
1734 # senders = [
1735 # { "name":"h8", "device":"of:0000000000000005/8" }
1736 # ]
1737 # recipients = [
1738 # { "name":"h16", "device":"of:0000000000000006/8" },
1739 # { "name":"h24", "device":"of:0000000000000007/8" }
1740 # ]
1741 # badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1742 # badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1743 # testResult = main.FALSE
1744 # installResult = main.intentFunction.installSingleToMultiIntent(
1745 # main,
1746 # name="ENCAPSULATION",
1747 # senders=senders,
1748 # recipients=recipients,
1749 # sw1="s5",
1750 # sw2="s2",
1751 # encap="VLAN" )
1752 #
1753 # if installResult:
1754 # testResult = main.intentFunction.testPointIntent(
1755 # main,
1756 # intentId=installResult,
1757 # name="ENCAPSULATION",
1758 # senders=senders,
1759 # recipients=recipients,
1760 # badSenders=badSenders,
1761 # badRecipients=badRecipients,
1762 # sw1="s5",
1763 # sw2="s2",
1764 # expectedLink=18 )
1765 # else:
1766 # main.CLIs[ 0 ].removeAllIntents( purge=True )
1767 #
1768 # utilities.assert_equals( expect=main.TRUE,
1769 # actual=testResult,
1770 # onpass=main.assertReturnString,
1771 # onfail=main.assertReturnString )
Jeremy Songsterc032f162016-08-04 17:14:49 -07001772
kelvin-onlab016dce22015-08-10 09:54:11 -07001773 main.intentFunction.report( main )
1774
kelvin-onlabb769f562015-07-15 17:05:10 -07001775 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001776 """
1777 Add multi point to single point intents
1778 - Get device ids
1779 - Add multi point to single point intents
1780 - Check intents
1781 - Verify flows
1782 - Ping hosts
1783 - Reroute
1784 - Link down
1785 - Verify flows
1786 - Check topology
1787 - Ping hosts
1788 - Link up
1789 - Verify flows
1790 - Check topology
1791 - Ping hosts
1792 - Remove intents
1793 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001794 if main.initialized == main.FALSE:
1795 main.log.error( "Test components did not start correctly, skipping further tests" )
1796 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001797 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001798 try:
1799 assert main.CLIs
1800 except AssertionError:
1801 main.log.error( "There is no main.CLIs, skipping test cases" )
1802 main.initialized = main.FALSE
1803 main.skipCase()
1804 try:
1805 assert main.Mininet1
1806 except AssertionError:
1807 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1808 main.initialized = main.FALSE
1809 main.skipCase()
1810 try:
1811 assert main.numSwitch
1812 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001813 main.log.error( "Place the total number of switch topology in "+\
1814 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07001815 main.initialized = main.FALSE
1816 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001817
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001818 main.testName = "Multi To Single Point Intents"
1819 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001820 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001821 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001822 " multi point intents using " +\
1823 str( main.numCtrls ) + " node(s) cluster;\n" +\
1824 "Different type of hosts will be tested in " +\
1825 "each step such as IPV4, Dual stack, VLAN etc" +\
1826 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001827 " OVS running in Mininet and compile intents" +\
1828 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001829
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001830 main.step( "NOOPTION: Add multi point to single point intents" )
1831 main.assertReturnString = "Assertion results for NOOPTION multi to single point intent\n"
1832 senders = [
1833 { "name":"h16", "device":"of:0000000000000006/8" },
1834 { "name":"h24", "device":"of:0000000000000007/8" }
1835 ]
1836 recipients = [
1837 { "name":"h8", "device":"of:0000000000000005/8" }
1838 ]
1839 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1840 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1841 testResult = main.FALSE
1842 installResult = main.intentFunction.installMultiToSingleIntent(
1843 main,
1844 name="NOOPTION",
1845 senders=senders,
1846 recipients=recipients,
1847 sw1="s5",
Jeremye0cb5eb2016-01-27 17:39:09 -08001848 sw2="s2" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001849
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001850 if installResult:
1851 testResult = main.intentFunction.testPointIntent(
1852 main,
1853 intentId=installResult,
1854 name="NOOPTION",
1855 senders=senders,
1856 recipients=recipients,
1857 badSenders=badSenders,
1858 badRecipients=badRecipients,
1859 sw1="s5",
1860 sw2="s2",
Jeremye0cb5eb2016-01-27 17:39:09 -08001861 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001862 else:
1863 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001864
1865 utilities.assert_equals( expect=main.TRUE,
1866 actual=testResult,
1867 onpass=main.assertReturnString,
1868 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001869
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001870 main.step( "IPV4: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001871 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 -08001872 senders = [
1873 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1874 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1875 ]
1876 recipients = [
1877 { "name":"h8", "device":"of:0000000000000005/8", "mac":"00:00:00:00:00:08" }
1878 ]
1879 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1880 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1881 testResult = main.FALSE
1882 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001883 main,
1884 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001885 senders=senders,
1886 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001887 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001888 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001889 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001890
1891 if installResult:
1892 testResult = main.intentFunction.testPointIntent(
1893 main,
1894 intentId=installResult,
1895 name="IPV4",
1896 senders=senders,
1897 recipients=recipients,
1898 badSenders=badSenders,
1899 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001900 sw1="s5",
1901 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001902 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001903 else:
1904 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001905
1906 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001907 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001908 onpass=main.assertReturnString,
1909 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001910
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001911 main.step( "IPV4_2: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001912 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 -08001913 senders = [
1914 { "name":"h16", "device":"of:0000000000000006/8" },
1915 { "name":"h24", "device":"of:0000000000000007/8" }
1916 ]
1917 recipients = [
1918 { "name":"h8", "device":"of:0000000000000005/8" }
1919 ]
1920 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1921 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1922 testResult = main.FALSE
1923 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001924 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001925 name="IPV4_2",
1926 senders=senders,
1927 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001928 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001929 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001930 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001931
1932 if installResult:
1933 testResult = main.intentFunction.testPointIntent(
1934 main,
1935 intentId=installResult,
1936 name="IPV4_2",
1937 senders=senders,
1938 recipients=recipients,
1939 badSenders=badSenders,
1940 badRecipients=badRecipients,
1941 sw1="s5",
1942 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001943 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001944 else:
1945 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001946
1947 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001948 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001949 onpass=main.assertReturnString,
1950 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001951
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001952 main.step( "VLAN: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001953 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 -08001954 senders = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001955 { "name":"h13", "device":"of:0000000000000006/5", "vlan":"200" },
1956 { "name":"h21", "device":"of:0000000000000007/5", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001957 ]
1958 recipients = [
Jeremy Songster832f9e92016-05-05 14:30:49 -07001959 { "name":"h5", "device":"of:0000000000000005/5", "vlan":"200" }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001960 ]
1961 badSenders=[ { "name":"h12" } ] # Senders that are not in the intent
1962 badRecipients=[ { "name":"h20" } ] # Recipients that are not in the intent
1963 testResult = main.FALSE
1964 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001965 main,
1966 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001967 senders=senders,
1968 recipients=recipients,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001969 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001970 sw2="s2" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001971
1972 if installResult:
1973 testResult = main.intentFunction.testPointIntent(
1974 main,
1975 intentId=installResult,
1976 name="VLAN",
1977 senders=senders,
1978 recipients=recipients,
1979 badSenders=badSenders,
1980 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001981 sw1="s5",
1982 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001983 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001984 else:
1985 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001986
1987 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001988 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001989 onpass=main.assertReturnString,
1990 onfail=main.assertReturnString )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001991
Jeremy Songsterff553672016-05-12 17:06:23 -07001992 # Right now this fails because of this bug: https://jira.onosproject.org/browse/ONOS-4383
1993 main.step( "VLAN: Add multi point to single point intents" )
1994 main.assertReturnString = "Assertion results for multi to single point intent with VLAN ID treatment\n"
1995 senders = [
1996 { "name":"h13", "device":"of:0000000000000006/5", "vlan":"200" },
1997 { "name":"h21", "device":"of:0000000000000007/5", "vlan":"200" }
1998 ]
1999 recipients = [
2000 { "name":"h4", "vlan":"100" }
2001 ]
2002 badSenders=[ { "name":"h12" } ] # Senders that are not in the intent
2003 badRecipients=[ { "name":"h20" } ] # Recipients that are not in the intent
2004 testResult = main.FALSE
Jeremy Songsterff553672016-05-12 17:06:23 -07002005 installResult = main.intentFunction.installMultiToSingleIntent(
2006 main,
2007 name="VLAN2",
2008 senders=senders,
2009 recipients=recipients,
2010 sw1="s5",
2011 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002012 setVlan=100 )
Jeremy Songsterff553672016-05-12 17:06:23 -07002013
2014 if installResult:
2015 testResult = main.intentFunction.testPointIntent(
2016 main,
2017 intentId=installResult,
2018 name="VLAN2",
2019 senders=senders,
2020 recipients=recipients,
2021 badSenders=badSenders,
2022 badRecipients=badRecipients,
2023 sw1="s5",
2024 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002025 expectedLink=18 )
Jeremy Songsterff553672016-05-12 17:06:23 -07002026 else:
2027 main.CLIs[ 0 ].removeAllIntents( purge=True )
2028
2029 utilities.assert_equals( expect=main.TRUE,
2030 actual=testResult,
2031 onpass=main.assertReturnString,
2032 onfail=main.assertReturnString )
2033
Jeremy Songsterc032f162016-08-04 17:14:49 -07002034 main.step( "ENCAPSULATION: Add multi point to single point intents" )
2035 main.assertReturnString = "Assertion results for VLAN Encapsulation multi to single point intent\n"
2036 senders = [
2037 { "name":"h16", "device":"of:0000000000000006/8" },
2038 { "name":"h24", "device":"of:0000000000000007/8" }
2039 ]
2040 recipients = [
2041 { "name":"h8", "device":"of:0000000000000005/8" }
2042 ]
2043 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
2044 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
2045 testResult = main.FALSE
Jeremy Songsterc032f162016-08-04 17:14:49 -07002046 installResult = main.intentFunction.installMultiToSingleIntent(
2047 main,
2048 name="ENCAPSULATION",
2049 senders=senders,
2050 recipients=recipients,
2051 sw1="s5",
2052 sw2="s2",
2053 encap="VLAN" )
2054
2055 if installResult:
2056 testResult = main.intentFunction.testPointIntent(
2057 main,
2058 intentId=installResult,
2059 name="ENCAPSULATION",
2060 senders=senders,
2061 recipients=recipients,
2062 badSenders=badSenders,
2063 badRecipients=badRecipients,
2064 sw1="s5",
2065 sw2="s2",
2066 expectedLink=18 )
2067 else:
2068 main.CLIs[ 0 ].removeAllIntents( purge=True )
2069
2070 utilities.assert_equals( expect=main.TRUE,
2071 actual=testResult,
2072 onpass=main.assertReturnString,
2073 onfail=main.assertReturnString )
2074
Shreyaca8990f2017-03-16 11:43:11 -07002075 #Testing MPLS would require kernel version of 4.1 or higher (Current version is 3.13)
2076 #main.step( "ENCAPSULATION: Add multi point to single point intents" )
2077 #main.assertReturnString = "Assertion results for MPLS Encapsulation multi to single point intent\n"
2078 #senders = [
2079 # { "name": "h16", "device": "of:0000000000000006/8" },
2080 # { "name": "h24", "device": "of:0000000000000007/8" }
2081 #]
2082 #recipients = [
2083 # { "name": "h8", "device": "of:0000000000000005/8" }
2084 #]
2085 #badSenders = [ { "name": "h17" } ] # Senders that are not in the intent
2086 #badRecipients = [ {"name": "h9" } ] # Recipients that are not in the intent
2087 #testResult = main.FALSE
2088 #installResult = main.intentFunction.installMultiToSingleIntent(
2089 # main,
2090 # name="ENCAPSULATION",
2091 # senders=senders,
2092 # recipients=recipients,
2093 # sw1="s5",
2094 # sw2="s2",
2095 # encap="MPLS" )
alison52b25892016-09-19 10:53:48 -07002096 #
Shreyaca8990f2017-03-16 11:43:11 -07002097 #if installResult:
2098 # testResult = main.intentFunction.testPointIntent(
2099 # main,
2100 # intentId=installResult,
2101 # name="ENCAPSULATION",
2102 # senders=senders,
2103 # recipients=recipients,
2104 # badSenders=badSenders,
2105 # badRecipients=badRecipients,
2106 # sw1="s5",
2107 # sw2="s2",
2108 # expectedLink=18 )
2109 #else:
2110 # main.CLIs[ 0 ].removeAllIntents( purge=True )
alison52b25892016-09-19 10:53:48 -07002111 #
Shreyaca8990f2017-03-16 11:43:11 -07002112 #utilities.assert_equals( expect=main.TRUE,
2113 # actual=testResult,
2114 # onpass=main.assertReturnString,
2115 # onfail=main.assertReturnString )
alison52b25892016-09-19 10:53:48 -07002116
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002117 main.intentFunction.report( main )
2118
acsmars1ff5e052015-07-23 11:27:48 -07002119 def CASE5000( self, main ):
2120 """
acsmars5d8cc862015-09-25 09:44:50 -07002121 Tests Host Mobility
2122 Modifies the topology location of h1
acsmars1ff5e052015-07-23 11:27:48 -07002123 """
Jeremyd9e4eb12016-04-13 12:09:06 -07002124 if main.initialized == main.FALSE:
2125 main.log.error( "Test components did not start correctly, skipping further tests" )
2126 main.skipCase()
acsmars1ff5e052015-07-23 11:27:48 -07002127 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07002128 try:
2129 assert main.CLIs
2130 except AssertionError:
2131 main.log.error( "There is no main.CLIs, skipping test cases" )
2132 main.initialized = main.FALSE
2133 main.skipCase()
2134 try:
2135 assert main.Mininet1
2136 except AssertionError:
2137 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
2138 main.initialized = main.FALSE
2139 main.skipCase()
2140 try:
2141 assert main.numSwitch
2142 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002143 main.log.error( "Place the total number of switch topology in "+\
2144 main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07002145 main.initialized = main.FALSE
2146 main.skipCase()
alison52b25892016-09-19 10:53:48 -07002147 main.case( "Test host mobility with host intents " + " - " + str( main.numCtrls ) +
2148 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002149 main.step( "Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07002150
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002151 main.log.info( "Moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07002152 main.Mininet1.moveHost( "h1","s5","s6" )
2153
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002154 # Send discovery ping from moved host
2155 # Moving the host brings down the default interfaces and creates a new one.
2156 # Scapy is restarted on this host to detect the new interface
2157 main.h1.stopScapy()
2158 main.h1.startScapy()
2159
2160 # Discover new host location in ONOS and populate host data.
2161 # Host 1 IP and MAC should be unchanged
2162 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
2163 main.intentFunction.populateHostData( main )
2164
acsmars1ff5e052015-07-23 11:27:48 -07002165 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
2166
2167 utilities.assert_equals( expect="of:0000000000000006",
2168 actual=h1PostMove,
2169 onpass="Mobility: Successfully moved h1 to s6",
acsmars5d8cc862015-09-25 09:44:50 -07002170 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07002171 " to single point intents" +
2172 " with IPV4 type and MAC addresses" +
2173 " in the same VLAN" )
2174
2175 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07002176 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002177 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
2178 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
Jeremy42df2e72016-02-23 16:37:46 -08002179 testResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002180 installResult = main.intentFunction.installHostIntent( main,
alison52b25892016-09-19 10:53:48 -07002181 name="IPV4 Mobility IPV4",
2182 onosNode=0,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002183 host1=host1,
Jeremye0cb5eb2016-01-27 17:39:09 -08002184 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -08002185 if installResult:
2186 testResult = main.intentFunction.testHostIntent( main,
alison52b25892016-09-19 10:53:48 -07002187 name="Host Mobility IPV4",
Jeremy2f190ca2016-01-29 15:23:57 -08002188 intentId = installResult,
alison52b25892016-09-19 10:53:48 -07002189 onosNode=0,
Jeremy2f190ca2016-01-29 15:23:57 -08002190 host1=host1,
2191 host2=host2,
2192 sw1="s6",
2193 sw2="s2",
2194 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08002195 else:
2196 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07002197
2198 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08002199 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07002200 onpass=main.assertReturnString,
2201 onfail=main.assertReturnString )
kelvin-onlab016dce22015-08-10 09:54:11 -07002202
2203 main.intentFunction.report( main )
Jeremye0cb5eb2016-01-27 17:39:09 -08002204
2205 def CASE6000( self, main ):
2206 """
2207 Tests Multi to Single Point Intent and Single to Multi Point Intent End Point Failure
2208 """
Jeremy Songster9385d412016-06-02 17:57:36 -07002209 # At some later point discussion on this behavior in MPSP and SPMP intents
2210 # will be reoppened and this test case may need to be updated to reflect
2211 # the outcomes of that discussion
Jeremyd9e4eb12016-04-13 12:09:06 -07002212 if main.initialized == main.FALSE:
2213 main.log.error( "Test components did not start correctly, skipping further tests" )
2214 main.skipCase()
Jeremye0cb5eb2016-01-27 17:39:09 -08002215 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07002216 try:
2217 assert main.CLIs
2218 except AssertionError:
2219 main.log.error( "There is no main.CLIs, skipping test cases" )
2220 main.initialized = main.FALSE
2221 main.skipCase()
2222 try:
2223 assert main.Mininet1
2224 except AssertionError:
2225 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
2226 main.initialized = main.FALSE
2227 main.skipCase()
2228 try:
2229 assert main.numSwitch
2230 except AssertionError:
alison52b25892016-09-19 10:53:48 -07002231 main.log.error( "Place the total number of switch topology in " + main.numSwitch )
Jeremyd9e4eb12016-04-13 12:09:06 -07002232 main.initialized = main.FALSE
2233 main.skipCase()
alison52b25892016-09-19 10:53:48 -07002234 main.case( "Test Multi to Single End Point Failure" + " - " + str( main.numCtrls ) +
2235 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jeremy Songster9385d412016-06-02 17:57:36 -07002236 main.step( "Installing Multi to Single Point intents with no options set" )
2237 main.assertReturnString = "Assertion results for IPV4 multi to single " +\
2238 "point intent end point failure with no options set\n"
Jeremye0cb5eb2016-01-27 17:39:09 -08002239 senders = [
2240 { "name":"h16", "device":"of:0000000000000006/8" },
2241 { "name":"h24", "device":"of:0000000000000007/8" }
2242 ]
2243 recipients = [
2244 { "name":"h8", "device":"of:0000000000000005/8" }
2245 ]
2246 isolatedSenders = [
alison52b25892016-09-19 10:53:48 -07002247 { "name":"h24" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002248 ]
2249 isolatedRecipients = []
2250 testResult = main.FALSE
2251 installResult = main.intentFunction.installMultiToSingleIntent(
2252 main,
2253 name="NOOPTION",
2254 senders=senders,
2255 recipients=recipients,
2256 sw1="s5",
2257 sw2="s2" )
2258
2259 if installResult:
2260 testResult = main.intentFunction.testEndPointFail(
2261 main,
2262 intentId=installResult,
2263 name="NOOPTION",
2264 senders=senders,
2265 recipients=recipients,
2266 isolatedSenders=isolatedSenders,
2267 isolatedRecipients=isolatedRecipients,
2268 sw1="s6",
2269 sw2="s2",
2270 sw3="s4",
2271 sw4="s1",
2272 sw5="s3",
2273 expectedLink1=16,
2274 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002275 else:
2276 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002277
2278 utilities.assert_equals( expect=main.TRUE,
2279 actual=testResult,
2280 onpass=main.assertReturnString,
2281 onfail=main.assertReturnString )
2282
Jeremy Songster9385d412016-06-02 17:57:36 -07002283 main.step( "Installing Multi to Single Point intents with partial failure allowed" )
2284
2285 main.assertReturnString = "Assertion results for IPV4 multi to single " +\
2286 "with partial failures allowed\n"
2287 senders = [
2288 { "name":"h16", "device":"of:0000000000000006/8" },
2289 { "name":"h24", "device":"of:0000000000000007/8" }
2290 ]
2291 recipients = [
2292 { "name":"h8", "device":"of:0000000000000005/8" }
2293 ]
2294 isolatedSenders = [
alison52b25892016-09-19 10:53:48 -07002295 { "name":"h24" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002296 ]
2297 isolatedRecipients = []
2298 testResult = main.FALSE
Jeremy Songster9385d412016-06-02 17:57:36 -07002299 installResult = main.intentFunction.installMultiToSingleIntent(
2300 main,
2301 name="NOOPTION",
2302 senders=senders,
2303 recipients=recipients,
2304 sw1="s5",
2305 sw2="s2",
2306 partial=True )
2307
2308 if installResult:
2309 testResult = main.intentFunction.testEndPointFail(
2310 main,
2311 intentId=installResult,
2312 name="NOOPTION",
2313 senders=senders,
2314 recipients=recipients,
2315 isolatedSenders=isolatedSenders,
2316 isolatedRecipients=isolatedRecipients,
2317 sw1="s6",
2318 sw2="s2",
2319 sw3="s4",
2320 sw4="s1",
2321 sw5="s3",
2322 expectedLink1=16,
2323 expectedLink2=14,
2324 partial=True )
2325 else:
2326 main.CLIs[ 0 ].removeAllIntents( purge=True )
2327
2328 utilities.assert_equals( expect=main.TRUE,
2329 actual=testResult,
2330 onpass=main.assertReturnString,
2331 onfail=main.assertReturnString )
2332
Jeremye0cb5eb2016-01-27 17:39:09 -08002333 main.step( "NOOPTION: Install and test single point to multi point intents" )
Jeremy Songster9385d412016-06-02 17:57:36 -07002334 main.assertReturnString = "Assertion results for IPV4 single to multi " +\
2335 "point intent with no options set\n"
Jeremye0cb5eb2016-01-27 17:39:09 -08002336 senders = [
2337 { "name":"h8", "device":"of:0000000000000005/8" }
2338 ]
2339 recipients = [
2340 { "name":"h16", "device":"of:0000000000000006/8" },
2341 { "name":"h24", "device":"of:0000000000000007/8" }
2342 ]
Jeremy Songster9385d412016-06-02 17:57:36 -07002343 isolatedSenders = []
2344 isolatedRecipients = [
alison52b25892016-09-19 10:53:48 -07002345 { "name":"h24" }
Jeremye0cb5eb2016-01-27 17:39:09 -08002346 ]
2347 testResult = main.FALSE
2348 installResult = main.intentFunction.installSingleToMultiIntent(
2349 main,
2350 name="NOOPTION",
2351 senders=senders,
2352 recipients=recipients,
2353 sw1="s5",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002354 sw2="s2" )
Jeremye0cb5eb2016-01-27 17:39:09 -08002355
2356 if installResult:
2357 testResult = main.intentFunction.testEndPointFail(
2358 main,
2359 intentId=installResult,
2360 name="NOOPTION",
2361 senders=senders,
2362 recipients=recipients,
2363 isolatedSenders=isolatedSenders,
2364 isolatedRecipients=isolatedRecipients,
2365 sw1="s6",
2366 sw2="s2",
2367 sw3="s4",
2368 sw4="s1",
2369 sw5="s3",
2370 expectedLink1=16,
2371 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002372 else:
2373 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002374
2375 utilities.assert_equals( expect=main.TRUE,
2376 actual=testResult,
2377 onpass=main.assertReturnString,
2378 onfail=main.assertReturnString )
Jeremy Songster9385d412016-06-02 17:57:36 -07002379 # Right now this functionality doesn't work properly in SPMP intents
2380 main.step( "NOOPTION: Install and test single point to multi point " +\
2381 "intents with partial failures allowed" )
2382 main.assertReturnString = "Assertion results for IPV4 single to multi " +\
2383 "point intent with partial failures allowed\n"
2384 senders = [
2385 { "name":"h8", "device":"of:0000000000000005/8" }
2386 ]
2387 recipients = [
2388 { "name":"h16", "device":"of:0000000000000006/8" },
2389 { "name":"h24", "device":"of:0000000000000007/8" }
2390 ]
2391 isolatedSenders = []
2392 isolatedRecipients = [
alison52b25892016-09-19 10:53:48 -07002393 { "name":"h24" }
Jeremy Songster9385d412016-06-02 17:57:36 -07002394 ]
2395 testResult = main.FALSE
Jeremy Songster9385d412016-06-02 17:57:36 -07002396 installResult = main.intentFunction.installSingleToMultiIntent(
2397 main,
2398 name="NOOPTION",
2399 senders=senders,
2400 recipients=recipients,
2401 sw1="s5",
2402 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07002403 partial=True )
Jeremy Songster9385d412016-06-02 17:57:36 -07002404
2405 if installResult:
2406 testResult = main.intentFunction.testEndPointFail(
2407 main,
2408 intentId=installResult,
2409 name="NOOPTION",
2410 senders=senders,
2411 recipients=recipients,
2412 isolatedSenders=isolatedSenders,
2413 isolatedRecipients=isolatedRecipients,
2414 sw1="s6",
2415 sw2="s2",
2416 sw3="s4",
2417 sw4="s1",
2418 sw5="s3",
2419 expectedLink1=16,
2420 expectedLink2=14,
2421 partial=True )
2422 else:
2423 main.CLIs[ 0 ].removeAllIntents( purge=True )
2424
2425 utilities.assert_equals( expect=main.TRUE,
2426 actual=testResult,
2427 onpass=main.assertReturnString,
2428 onfail=main.assertReturnString )
Jeremye0cb5eb2016-01-27 17:39:09 -08002429
Chiyu Chengef109502016-11-21 15:51:38 -08002430 main.intentFunction.report( main )