blob: ceb4b2db6345c72deda12de40ae969b8e6da7a34 [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 ):
9 import time
kelvin-onlabd48a68c2015-07-13 16:01:36 -070010 import imp
Jon Hallf632d202015-07-30 15:45:11 -070011 import re
kelvin-onlabd48a68c2015-07-13 16:01:36 -070012
13 """
14 - Construct tests variables
15 - GIT ( optional )
16 - Checkout ONOS master branch
17 - Pull latest ONOS code
18 - Building ONOS ( optional )
19 - Install ONOS package
20 - Build ONOS package
21 """
22
23 main.case( "Constructing test variables and building ONOS package" )
24 main.step( "Constructing test variables" )
Jon Hall783bbf92015-07-23 14:33:19 -070025 main.caseExplanation = "This test case is mainly for loading " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -070026 "from params file, and pull and build the " +\
27 " latest ONOS package"
kelvin-onlabd48a68c2015-07-13 16:01:36 -070028 stepResult = main.FALSE
29
30 # Test variables
Jon Halla3e02432015-07-24 15:55:42 -070031 try:
Jon Hallf632d202015-07-30 15:45:11 -070032 main.testOnDirectory = re.sub( "(/tests)$", "", main.testDir )
Jon Halla3e02432015-07-24 15:55:42 -070033 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
34 gitBranch = main.params[ 'GIT' ][ 'branch' ]
35 main.dependencyPath = main.testOnDirectory + \
36 main.params[ 'DEPENDENCY' ][ 'path' ]
37 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
38 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
39 if main.ONOSbench.maxNodes:
40 main.maxNodes = int( main.ONOSbench.maxNodes )
41 else:
42 main.maxNodes = 0
43 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
44 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
45 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
46 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
47 main.checkIntentSleep = int( main.params[ 'SLEEP' ][ 'checkintent' ] )
acsmarscfa52272015-08-06 15:21:45 -070048 main.removeIntentSleep = int( main.params[ 'SLEEP' ][ 'removeintent' ] )
Jon Halla3e02432015-07-24 15:55:42 -070049 main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] )
50 main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
acsmars59a4c552015-09-10 18:11:19 -070051 main.checkTopoAttempts = int( main.params[ 'SLEEP' ][ 'topoAttempts' ] )
Jon Halla3e02432015-07-24 15:55:42 -070052 gitPull = main.params[ 'GIT' ][ 'pull' ]
53 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
54 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
55 main.cellData = {} # for creating cell file
56 main.hostsData = {}
57 main.CLIs = []
58 main.ONOSip = []
Jeremy Songster1f39bf02016-01-20 17:17:25 -080059 main.scapyHostNames = main.params[ 'SCAPY' ][ 'HOSTNAMES' ].split( ',' )
60 main.scapyHosts = [] # List of scapy hosts for iterating
acsmars5d8cc862015-09-25 09:44:50 -070061 main.assertReturnString = '' # Assembled assert return string
kelvin-onlabd48a68c2015-07-13 16:01:36 -070062
Jon Halla3e02432015-07-24 15:55:42 -070063 main.ONOSip = main.ONOSbench.getOnosIps()
64 print main.ONOSip
kelvin-onlabd48a68c2015-07-13 16:01:36 -070065
Jon Halla3e02432015-07-24 15:55:42 -070066 # Assigning ONOS cli handles to a list
67 for i in range( 1, main.maxNodes + 1 ):
68 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070069
Jon Halla3e02432015-07-24 15:55:42 -070070 # -- INIT SECTION, ONLY RUNS ONCE -- #
71 main.startUp = imp.load_source( wrapperFile1,
72 main.dependencyPath +
73 wrapperFile1 +
74 ".py" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070075
Jon Halla3e02432015-07-24 15:55:42 -070076 main.intentFunction = imp.load_source( wrapperFile2,
77 main.dependencyPath +
78 wrapperFile2 +
79 ".py" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -070080
Jon Halla3e02432015-07-24 15:55:42 -070081 main.topo = imp.load_source( wrapperFile3,
82 main.dependencyPath +
83 wrapperFile3 +
84 ".py" )
85
kelvin-onlabd9e23de2015-08-06 10:34:44 -070086 copyResult1 = main.ONOSbench.scp( main.Mininet1,
87 main.dependencyPath +
88 main.topology,
Jeremy Songster1f39bf02016-01-20 17:17:25 -080089 main.Mininet1.home + "custom/",
kelvin-onlabd9e23de2015-08-06 10:34:44 -070090 direction="to" )
Jon Halla3e02432015-07-24 15:55:42 -070091 if main.CLIs:
92 stepResult = main.TRUE
93 else:
94 main.log.error( "Did not properly created list of ONOS CLI handle" )
95 stepResult = main.FALSE
96 except Exception as e:
97 main.log.exception(e)
98 main.cleanup()
99 main.exit()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700100
101 utilities.assert_equals( expect=main.TRUE,
102 actual=stepResult,
103 onpass="Successfully construct " +
104 "test variables ",
105 onfail="Failed to construct test variables" )
106
107 if gitPull == 'True':
108 main.step( "Building ONOS in " + gitBranch + " branch" )
109 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
110 stepResult = onosBuildResult
111 utilities.assert_equals( expect=main.TRUE,
112 actual=stepResult,
113 onpass="Successfully compiled " +
114 "latest ONOS",
115 onfail="Failed to compile " +
116 "latest ONOS" )
117 else:
118 main.log.warn( "Did not pull new code so skipping mvn " +
119 "clean install" )
Jon Hall106be082015-07-22 09:53:00 -0700120 main.ONOSbench.getVersion( report=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700121
122 def CASE2( self, main ):
123 """
124 - Set up cell
125 - Create cell file
126 - Set cell file
127 - Verify cell file
128 - Kill ONOS process
129 - Uninstall ONOS cluster
130 - Verify ONOS start up
131 - Install ONOS cluster
132 - Connect to cli
133 """
134
135 # main.scale[ 0 ] determines the current number of ONOS controller
136 main.numCtrls = int( main.scale[ 0 ] )
Jeremycd872222016-03-29 10:08:34 -0700137 main.flowCompiler = "Flow Rules"
Jeremyd9e4eb12016-04-13 12:09:06 -0700138 main.initialized = main.TRUE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700139
140 main.case( "Starting up " + str( main.numCtrls ) +
141 " node(s) ONOS cluster" )
Jon Hall783bbf92015-07-23 14:33:19 -0700142 main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700143 " node(s) ONOS cluster"
144
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700145 #kill off all onos processes
146 main.log.info( "Safety check, killing all ONOS processes" +
Jon Hall70b2ff42015-11-17 15:49:44 -0800147 " before initiating environment setup" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700148
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800149 time.sleep( main.startUpSleep )
150 main.step( "Uninstalling ONOS package" )
151 onosUninstallResult = main.TRUE
152 for ip in main.ONOSip:
153 onosUninstallResult = onosUninstallResult and \
154 main.ONOSbench.onosUninstall( nodeIp=ip )
155 stepResult = onosUninstallResult
156 utilities.assert_equals( expect=main.TRUE,
157 actual=stepResult,
158 onpass="Successfully uninstalled ONOS package",
159 onfail="Failed to uninstall ONOS package" )
Jeremy42df2e72016-02-23 16:37:46 -0800160 time.sleep( main.startUpSleep )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800161
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700162 for i in range( main.maxNodes ):
163 main.ONOSbench.onosDie( main.ONOSip[ i ] )
164
165 print "NODE COUNT = ", main.numCtrls
166
167 tempOnosIp = []
168 for i in range( main.numCtrls ):
169 tempOnosIp.append( main.ONOSip[i] )
170
kelvin-onlabf34a58a2015-07-23 16:41:52 -0700171 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
172 "temp", main.Mininet1.ip_address,
173 main.apps, tempOnosIp )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700174
175 main.step( "Apply cell to environment" )
176 cellResult = main.ONOSbench.setCell( "temp" )
177 verifyResult = main.ONOSbench.verifyCell()
178 stepResult = cellResult and verifyResult
179 utilities.assert_equals( expect=main.TRUE,
180 actual=stepResult,
181 onpass="Successfully applied cell to " + \
182 "environment",
183 onfail="Failed to apply cell to environment " )
184
185 main.step( "Creating ONOS package" )
186 packageResult = main.ONOSbench.onosPackage()
187 stepResult = packageResult
188 utilities.assert_equals( expect=main.TRUE,
189 actual=stepResult,
190 onpass="Successfully created ONOS package",
191 onfail="Failed to create ONOS package" )
192
193 time.sleep( main.startUpSleep )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700194 main.step( "Installing ONOS package" )
195 onosInstallResult = main.TRUE
196 for i in range( main.numCtrls ):
197 onosInstallResult = onosInstallResult and \
198 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
199 stepResult = onosInstallResult
200 utilities.assert_equals( expect=main.TRUE,
201 actual=stepResult,
202 onpass="Successfully installed ONOS package",
203 onfail="Failed to install ONOS package" )
204
205 time.sleep( main.startUpSleep )
206 main.step( "Starting ONOS service" )
207 stopResult = main.TRUE
208 startResult = main.TRUE
209 onosIsUp = main.TRUE
210
211 for i in range( main.numCtrls ):
Jeremyd9e4eb12016-04-13 12:09:06 -0700212 onosIsUp = main.ONOSbench.isup( main.ONOSip[ i ] )
213 if onosIsUp == main.TRUE:
214 main.log.report( "ONOS instance {0} is up and ready".format( i + 1 ) )
215 else:
216 main.log.report( "ONOS instance {0} may not be up, stop and ".format( i + 1 ) +
217 "start ONOS again " )
218 stopResult = stopResult and main.ONOSbench.onosStop( main.ONOSip[ i ] )
219 startResult = startResult and main.ONOSbench.onosStart( main.ONOSip[ i ] )
220 if not startResult or stopResult:
221 main.log.report( "ONOS instance {0} did not start correctly.".format( i + 1) )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700222 stepResult = onosIsUp and stopResult and startResult
223 utilities.assert_equals( expect=main.TRUE,
224 actual=stepResult,
Jeremyd9e4eb12016-04-13 12:09:06 -0700225 onpass="ONOS service is ready on all nodes",
226 onfail="ONOS service did not start properly on all nodes" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700227
228 main.step( "Start ONOS cli" )
229 cliResult = main.TRUE
230 for i in range( main.numCtrls ):
231 cliResult = cliResult and \
232 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
233 stepResult = cliResult
234 utilities.assert_equals( expect=main.TRUE,
235 actual=stepResult,
236 onpass="Successfully start ONOS cli",
237 onfail="Failed to start ONOS cli" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700238 if not stepResult:
239 main.initialized = main.FALSE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700240
241 # Remove the first element in main.scale list
242 main.scale.remove( main.scale[ 0 ] )
243
kelvin-onlab016dce22015-08-10 09:54:11 -0700244 main.intentFunction.report( main )
245
Jon Halla3e02432015-07-24 15:55:42 -0700246 def CASE8( self, main ):
247 """
acsmars59a4c552015-09-10 18:11:19 -0700248 Compare ONOS Topology to Mininet Topology
Jon Halla3e02432015-07-24 15:55:42 -0700249 """
250 import json
251
252 main.case( "Compare ONOS Topology view to Mininet topology" )
253 main.caseExplanation = "Compare topology elements between Mininet" +\
254 " and ONOS"
255
acsmars59a4c552015-09-10 18:11:19 -0700256 main.log.info( "Gathering topology information from Mininet" )
257 devicesResults = main.FALSE # Overall Boolean for device correctness
258 linksResults = main.FALSE # Overall Boolean for link correctness
259 hostsResults = main.FALSE # Overall Boolean for host correctness
260 deviceFails = [] # Nodes where devices are incorrect
261 linkFails = [] # Nodes where links are incorrect
262 hostFails = [] # Nodes where hosts are incorrect
263 attempts = main.checkTopoAttempts # Remaining Attempts
Jon Halla3e02432015-07-24 15:55:42 -0700264
265 mnSwitches = main.Mininet1.getSwitches()
266 mnLinks = main.Mininet1.getLinks()
267 mnHosts = main.Mininet1.getHosts()
268
Jon Hall70b2ff42015-11-17 15:49:44 -0800269 main.step( "Comparing Mininet topology to ONOS topology" )
Jon Halla3e02432015-07-24 15:55:42 -0700270
acsmars59a4c552015-09-10 18:11:19 -0700271 while ( attempts >= 0 ) and\
272 ( not devicesResults or not linksResults or not hostsResults ):
273 time.sleep( 2 )
274 if not devicesResults:
275 devices = main.topo.getAllDevices( main )
276 ports = main.topo.getAllPorts( main )
277 devicesResults = main.TRUE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800278 deviceFails = [] # Reset for each failed attempt
acsmars59a4c552015-09-10 18:11:19 -0700279 if not linksResults:
280 links = main.topo.getAllLinks( main )
281 linksResults = main.TRUE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800282 linkFails = [] # Reset for each failed attempt
acsmars59a4c552015-09-10 18:11:19 -0700283 if not hostsResults:
284 hosts = main.topo.getAllHosts( main )
285 hostsResults = main.TRUE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800286 hostFails = [] # Reset for each failed attempt
Jon Halla3e02432015-07-24 15:55:42 -0700287
acsmars59a4c552015-09-10 18:11:19 -0700288 # Check for matching topology on each node
289 for controller in range( main.numCtrls ):
290 controllerStr = str( controller + 1 ) # ONOS node number
291 # Compare Devices
292 if devices[ controller ] and ports[ controller ] and\
293 "Error" not in devices[ controller ] and\
294 "Error" not in ports[ controller ]:
Jon Halla3e02432015-07-24 15:55:42 -0700295
acsmars2ec91d62015-09-16 11:15:48 -0700296 try:
297 deviceData = json.loads( devices[ controller ] )
298 portData = json.loads( ports[ controller ] )
299 except (TypeError,ValueError):
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800300 main.log.error( "Could not load json: {0} or {1}".format( str( devices[ controller ] ), str( ports[ controller ] ) ) )
acsmars2ec91d62015-09-16 11:15:48 -0700301 currentDevicesResult = main.FALSE
302 else:
303 currentDevicesResult = main.Mininet1.compareSwitches(
304 mnSwitches,deviceData,portData )
acsmars59a4c552015-09-10 18:11:19 -0700305 else:
306 currentDevicesResult = main.FALSE
307 if not currentDevicesResult:
308 deviceFails.append( controllerStr )
309 devicesResults = devicesResults and currentDevicesResult
310 # Compare Links
311 if links[ controller ] and "Error" not in links[ controller ]:
acsmars2ec91d62015-09-16 11:15:48 -0700312 try:
313 linkData = json.loads( links[ controller ] )
314 except (TypeError,ValueError):
315 main.log.error("Could not load json:" + str( links[ controller ] ) )
316 currentLinksResult = main.FALSE
317 else:
318 currentLinksResult = main.Mininet1.compareLinks(
319 mnSwitches, mnLinks,linkData )
acsmars59a4c552015-09-10 18:11:19 -0700320 else:
321 currentLinksResult = main.FALSE
322 if not currentLinksResult:
323 linkFails.append( controllerStr )
324 linksResults = linksResults and currentLinksResult
325 # Compare Hosts
acsmars2ec91d62015-09-16 11:15:48 -0700326 if hosts[ controller ] and "Error" not in hosts[ controller ]:
327 try:
328 hostData = json.loads( hosts[ controller ] )
329 except (TypeError,ValueError):
330 main.log.error("Could not load json:" + str( hosts[ controller ] ) )
331 currentHostsResult = main.FALSE
332 else:
333 currentHostsResult = main.Mininet1.compareHosts(
334 mnHosts,hostData )
acsmars59a4c552015-09-10 18:11:19 -0700335 else:
336 currentHostsResult = main.FALSE
337 if not currentHostsResult:
338 hostFails.append( controllerStr )
339 hostsResults = hostsResults and currentHostsResult
340 # Decrement Attempts Remaining
341 attempts -= 1
342
343
344 utilities.assert_equals( expect=[],
345 actual=deviceFails,
346 onpass="ONOS correctly discovered all devices",
347 onfail="ONOS incorrectly discovered devices on nodes: " +
348 str( deviceFails ) )
349 utilities.assert_equals( expect=[],
350 actual=linkFails,
351 onpass="ONOS correctly discovered all links",
352 onfail="ONOS incorrectly discovered links on nodes: " +
353 str( linkFails ) )
354 utilities.assert_equals( expect=[],
355 actual=hostFails,
356 onpass="ONOS correctly discovered all hosts",
357 onfail="ONOS incorrectly discovered hosts on nodes: " +
358 str( hostFails ) )
Jon Hall46d48252015-08-03 11:41:16 -0700359 topoResults = hostsResults and linksResults and devicesResults
360 utilities.assert_equals( expect=main.TRUE,
361 actual=topoResults,
362 onpass="ONOS correctly discovered the topology",
363 onfail="ONOS incorrectly discovered the topology" )
Jon Halla3e02432015-07-24 15:55:42 -0700364
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700365 def CASE10( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700366 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700367 Start Mininet topology with OF 1.0 switches
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700368 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700369 if main.initialized == main.FALSE:
370 main.log.error( "Test components did not start correctly, skipping further tests" )
371 main.skipCase()
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700372 main.OFProtocol = "1.0"
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700373 main.log.report( "Start Mininet topology with OF 1.0 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700374 main.case( "Start Mininet topology with OF 1.0 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700375 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700376 "switches to test intents, exits out if " +\
377 "topology did not start correctly"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700378
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700379 main.step( "Starting Mininet topology with OF 1.0 switches" )
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700380 args = "--switch ovs,protocols=OpenFlow10"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700381 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700382 main.topology,
383 args=args )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700384 stepResult = topoResult
385 utilities.assert_equals( expect=main.TRUE,
386 actual=stepResult,
387 onpass="Successfully loaded topology",
388 onfail="Failed to load topology" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700389
390 # Set flag to test cases if topology did not load properly
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700391 if not topoResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700392 main.initialized = main.FALSE
393 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700394
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700395 def CASE11( self, main ):
396 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700397 Start Mininet topology with OF 1.3 switches
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700398 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700399 if main.initialized == main.FALSE:
400 main.log.error( "Test components did not start correctly, skipping further tests" )
401 main.skipCase()
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700402 main.OFProtocol = "1.3"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700403 main.log.report( "Start Mininet topology with OF 1.3 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700404 main.case( "Start Mininet topology with OF 1.3 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700405 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700406 "switches to test intents, exits out if " +\
407 "topology did not start correctly"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700408
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700409 main.step( "Starting Mininet topology with OF 1.3 switches" )
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700410 args = "--switch ovs,protocols=OpenFlow13"
411 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
412 main.topology,
413 args=args )
414 stepResult = topoResult
415 utilities.assert_equals( expect=main.TRUE,
416 actual=stepResult,
417 onpass="Successfully loaded topology",
418 onfail="Failed to load topology" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700419 # Set flag to skip test cases if topology did not load properly
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700420 if not topoResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700421 main.initialized = main.FALSE
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700422
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700423 def CASE12( self, main ):
424 """
425 Assign mastership to controllers
426 """
427 import re
428
Jeremyd9e4eb12016-04-13 12:09:06 -0700429 if main.initialized == main.FALSE:
430 main.log.error( "Test components did not start correctly, skipping further tests" )
431 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700432 main.case( "Assign switches to controllers" )
433 main.step( "Assigning switches to controllers" )
Jon Hall783bbf92015-07-23 14:33:19 -0700434 main.caseExplanation = "Assign OF " + main.OFProtocol +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700435 " switches to ONOS nodes"
436
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700437 assignResult = main.TRUE
438 switchList = []
439
440 # Creates a list switch name, use getSwitch() function later...
441 for i in range( 1, ( main.numSwitch + 1 ) ):
442 switchList.append( 's' + str( i ) )
443
444 tempONOSip = []
445 for i in range( main.numCtrls ):
446 tempONOSip.append( main.ONOSip[ i ] )
447
448 assignResult = main.Mininet1.assignSwController( sw=switchList,
449 ip=tempONOSip,
Charles Chan029be652015-08-24 01:46:10 +0800450 port='6653' )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700451 if not assignResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700452 main.log.error( "Problem assigning mastership of switches" )
453 main.initialized = main.FALSE
454 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700455
456 for i in range( 1, ( main.numSwitch + 1 ) ):
457 response = main.Mininet1.getSwController( "s" + str( i ) )
458 print( "Response is " + str( response ) )
459 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
460 assignResult = assignResult and main.TRUE
461 else:
462 assignResult = main.FALSE
463 stepResult = assignResult
464 utilities.assert_equals( expect=main.TRUE,
465 actual=stepResult,
466 onpass="Successfully assigned switches" +
467 "to controller",
468 onfail="Failed to assign switches to " +
469 "controller" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700470 if not stepResult:
471 main.initialized = main.FALSE
acsmars5d8cc862015-09-25 09:44:50 -0700472
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800473 def CASE13( self,main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700474 """
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800475 Create Scapy components
476 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700477 if main.initialized == main.FALSE:
478 main.log.error( "Test components did not start correctly, skipping further tests" )
479 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800480 main.case( "Create scapy components" )
481 main.step( "Create scapy components" )
482 import json
483 scapyResult = main.TRUE
484 for hostName in main.scapyHostNames:
485 main.Scapy1.createHostComponent( hostName )
486 main.scapyHosts.append( getattr( main, hostName ) )
487
488 main.step( "Start scapy components" )
489 for host in main.scapyHosts:
490 host.startHostCli()
491 host.startScapy()
492 host.updateSelf()
493 main.log.debug( host.name )
494 main.log.debug( host.hostIp )
495 main.log.debug( host.hostMac )
496
497
498 utilities.assert_equals( expect=main.TRUE,
499 actual=scapyResult,
500 onpass="Successfully created Scapy Components",
501 onfail="Failed to discover Scapy Components" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700502 if not scapyResult:
503 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800504
505 def CASE14( self, main ):
506 """
507 Discover all hosts with fwd and pingall and store its data in a dictionary
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700508 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700509 if main.initialized == main.FALSE:
510 main.log.error( "Test components did not start correctly, skipping further tests" )
511 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700512 main.case( "Discover all hosts" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800513 main.step( "Pingall hosts and confirm ONOS discovery" )
514 utilities.retry( f=main.intentFunction.fwdPingall, retValue=main.FALSE, args=[ main ] )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700515
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800516 utilities.retry( f=main.intentFunction.confirmHostDiscovery, retValue=main.FALSE,
517 args=[ main ], attempts=main.checkTopoAttempts, sleep=2 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700518 utilities.assert_equals( expect=main.TRUE,
519 actual=stepResult,
520 onpass="Successfully discovered hosts",
521 onfail="Failed to discover hosts" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700522 if not stepResult:
523 main.initialized = main.FALSE
524 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700525
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800526 main.step( "Populate hostsData" )
527 stepResult = main.intentFunction.populateHostData( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700528 utilities.assert_equals( expect=main.TRUE,
529 actual=stepResult,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800530 onpass="Successfully populated hostsData",
531 onfail="Failed to populate hostsData" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700532 if not stepResult:
533 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800534
535 def CASE15( self, main ):
536 """
537 Discover all hosts with scapy arp packets and store its data to a dictionary
538 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700539 if main.initialized == main.FALSE:
540 main.log.error( "Test components did not start correctly, skipping further tests" )
541 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800542 main.case( "Discover all hosts using scapy" )
543 main.step( "Send packets from each host to the first host and confirm onos discovery" )
544
545 import collections
546 if len( main.scapyHosts ) < 1:
547 main.log.error( "No scapy hosts have been created" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700548 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800549 main.skipCase()
550
551 # Send ARP packets from each scapy host component
552 main.intentFunction.sendDiscoveryArp( main, main.scapyHosts )
553
554 stepResult = utilities.retry( f=main.intentFunction.confirmHostDiscovery,
555 retValue=main.FALSE, args=[ main ],
556 attempts=main.checkTopoAttempts, sleep=2 )
557
558 utilities.assert_equals( expect=main.TRUE,
559 actual=stepResult,
560 onpass="ONOS correctly discovered all hosts",
561 onfail="ONOS incorrectly discovered hosts" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700562 if not stepResult:
563 main.initialized = main.FALSE
564 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800565
566 main.step( "Populate hostsData" )
567 stepResult = main.intentFunction.populateHostData( main )
568 utilities.assert_equals( expect=main.TRUE,
569 actual=stepResult,
570 onpass="Successfully populated hostsData",
571 onfail="Failed to populate hostsData" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700572 if not stepResult:
573 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800574
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800575 def CASE16( self, main ):
576 """
Jeremy42df2e72016-02-23 16:37:46 -0800577 Balance Masters
578 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700579 if main.initialized == main.FALSE:
580 main.log.error( "Test components did not start correctly, skipping further tests" )
581 main.skipCase()
Jeremy42df2e72016-02-23 16:37:46 -0800582 main.case( "Balance mastership of switches" )
583 main.step( "Balancing mastership of switches" )
584
585 balanceResult = main.FALSE
586 balanceResult = utilities.retry( f=main.CLIs[ 0 ].balanceMasters, retValue=main.FALSE, args=[] )
587
588 utilities.assert_equals( expect=main.TRUE,
Jeremy6e9748f2016-03-25 15:03:39 -0700589 actual=balanceResult,
Jeremy42df2e72016-02-23 16:37:46 -0800590 onpass="Successfully balanced mastership of switches",
591 onfail="Failed to balance mastership of switches" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700592 if not balanceResult:
593 main.initialized = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800594
595 def CASE17( self, main ):
596 """
Jeremy6e9748f2016-03-25 15:03:39 -0700597 Use Flow Objectives
598 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700599 if main.initialized == main.FALSE:
600 main.log.error( "Test components did not start correctly, skipping further tests" )
601 main.skipCase()
Jeremy6e9748f2016-03-25 15:03:39 -0700602 main.case( "Enable intent compilation using Flow Objectives" )
603 main.step( "Enabling Flow Objectives" )
604
605 main.flowCompiler = "Flow Objectives"
606
607 cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator"
608
609 stepResult = main.CLIs[ 0 ].setCfg( component=cmd,
610 propName="useFlowObjectives", value="true" )
611
612 utilities.assert_equals( expect=main.TRUE,
613 actual=stepResult,
614 onpass="Successfully activated Flow Objectives",
615 onfail="Failed to activate Flow Objectives" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700616 if not balanceResult:
617 main.initialized = main.FALSE
Jeremy6e9748f2016-03-25 15:03:39 -0700618
619 def CASE18( self, main ):
620 """
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800621 Stop mininet and remove scapy host
622 """
623 main.log.report( "Stop Mininet and Scapy" )
624 main.case( "Stop Mininet and Scapy" )
625 main.caseExplanation = "Stopping the current mininet topology " +\
626 "to start up fresh"
627 main.step( "Stopping and Removing Scapy Host Components" )
628 scapyResult = main.TRUE
629 for host in main.scapyHosts:
630 scapyResult = scapyResult and host.stopScapy()
631 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
632
633 for host in main.scapyHosts:
634 scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
635 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
636
637 main.scapyHosts = []
638 main.scapyHostIPs = []
639
640 utilities.assert_equals( expect=main.TRUE,
641 actual=scapyResult,
642 onpass="Successfully stopped scapy and removed host components",
643 onfail="Failed to stop mininet and scapy" )
644
645 main.step( "Stopping Mininet Topology" )
646 mininetResult = main.Mininet1.stopNet( )
647
648 utilities.assert_equals( expect=main.TRUE,
649 actual=mininetResult,
650 onpass="Successfully stopped mininet and scapy",
651 onfail="Failed to stop mininet and scapy" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700652 # Exit if topology did not load properly
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800653 if not ( mininetResult and scapyResult ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700654 main.cleanup()
655 main.exit()
656
kelvin-onlabb769f562015-07-15 17:05:10 -0700657 def CASE1000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700658 """
659 Add host intents between 2 host:
660 - Discover hosts
661 - Add host intents
662 - Check intents
663 - Verify flows
664 - Ping hosts
665 - Reroute
666 - Link down
667 - Verify flows
668 - Check topology
669 - Ping hosts
670 - Link up
671 - Verify flows
672 - Check topology
673 - Ping hosts
674 - Remove intents
675 """
676 import time
677 import json
678 import re
Jeremyd9e4eb12016-04-13 12:09:06 -0700679 if main.initialized == main.FALSE:
680 main.log.error( "Test components did not start correctly, skipping further tests" )
681 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700682 # Assert variables - These variable's name|format must be followed
683 # if you want to use the wrapper function
684 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -0700685 try:
686 assert main.CLIs
687 except AssertionError:
688 main.log.error( "There is no main.CLIs, skipping test cases" )
689 main.initialized = main.FALSE
690 main.skipCase()
691 try:
692 assert main.Mininet1
693 except AssertionError:
694 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
695 main.initialized = main.FALSE
696 main.skipCase()
697 try:
698 assert main.numSwitch
699 except AssertionError:
700 main.log.error( "Place the total number of switch topology in \
701 main.numSwitch" )
702 main.initialized = main.FALSE
703 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700704
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800705 # Save leader candidates
acsmarse6b410f2015-07-17 14:39:34 -0700706 intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
707
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700708 main.testName = "Host Intents"
709 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -0700710 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -0700711 main.caseExplanation = "This test case tests Host intents using " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700712 str( main.numCtrls ) + " node(s) cluster;\n" +\
713 "Different type of hosts will be tested in " +\
714 "each step such as IPV4, Dual stack, VLAN " +\
Jeremyeb51cb12016-03-28 17:53:35 -0700715 "etc;\nThe test will use OF " + main.OFProtocol +\
716 " OVS running in Mininet and compile intents" +\
Jeremy6e9748f2016-03-25 15:03:39 -0700717 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700718
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700719 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700720 main.assertReturnString = "Assertion Result for IPV4 host intent with mac addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800721 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
722 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
723 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800724 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800725 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700726 name='IPV4',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800727 onosNode='0',
728 host1=host1,
729 host2=host2)
730 if installResult:
731 testResult = main.intentFunction.testHostIntent( main,
732 name='IPV4',
733 intentId = installResult,
734 onosNode='0',
735 host1=host1,
736 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700737 sw1='s5',
738 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800739 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800740 else:
741 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800742
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700743 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800744 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700745 onpass=main.assertReturnString,
746 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700747
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700748 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700749 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800750 host1 = { "name":"h3","id":"00:00:00:00:00:03/-1" }
751 host2 = { "name":"h11","id":"00:00:00:00:00:0B/-1 "}
752 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800753 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800754 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700755 name='DUALSTACK',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800756 onosNode='0',
757 host1=host1,
758 host2=host2)
759
760 if installResult:
761 testResult = main.intentFunction.testHostIntent( main,
762 name='DUALSTACK',
763 intentId = installResult,
764 onosNode='0',
765 host1=host1,
766 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700767 sw1='s5',
768 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800769 expectedLink = 18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700770
771 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800772 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700773 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800774 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700775
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700776 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700777 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800778 host1 = { "name":"h1" }
779 host2 = { "name":"h11" }
780 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800781 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800782 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700783 name='DUALSTACK2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800784 onosNode='0',
785 host1=host1,
786 host2=host2)
787
788 if installResult:
789 testResult = main.intentFunction.testHostIntent( main,
790 name='DUALSTACK2',
791 intentId = installResult,
792 onosNode='0',
793 host1=host1,
794 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700795 sw1='s5',
796 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800797 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800798 else:
799 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700800
801 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800802 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700803 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800804 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700805
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700806 main.step( "1HOP: Add host intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -0700807 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800808 host1 = { "name":"h1" }
809 host2 = { "name":"h3" }
810 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800811 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800812 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700813 name='1HOP',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800814 onosNode='0',
815 host1=host1,
816 host2=host2)
817
818 if installResult:
819 testResult = main.intentFunction.testHostIntent( main,
820 name='1HOP',
821 intentId = installResult,
822 onosNode='0',
823 host1=host1,
824 host2=host2,
825 sw1='s5',
826 sw2='s2',
827 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800828 else:
829 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700830
831 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800832 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700833 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800834 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700835
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700836 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
acsmars5d8cc862015-09-25 09:44:50 -0700837 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800838 host1 = { "name":"h4","id":"00:00:00:00:00:04/100" }
839 host2 = { "name":"h12","id":"00:00:00:00:00:0C/100 "}
840 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800841 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800842 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700843 name='VLAN1',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800844 onosNode='0',
845 host1=host1,
846 host2=host2)
847
848 if installResult:
849 testResult = main.intentFunction.testHostIntent( main,
850 name='VLAN1',
851 intentId = installResult,
852 onosNode='0',
853 host1=host1,
854 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700855 sw1='s5',
856 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800857 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800858 else:
859 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700860
861 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800862 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700863 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800864 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700865
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700866 main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
acsmars5d8cc862015-09-25 09:44:50 -0700867 main.assertReturnString = "Assertion Result different VLAN negative test\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800868 host1 = { "name":"h13" }
869 host2 = { "name":"h20" }
870 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800871 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800872 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700873 name='VLAN2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800874 onosNode='0',
875 host1=host1,
876 host2=host2)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700877
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800878 if installResult:
879 testResult = main.intentFunction.testHostIntent( main,
880 name='VLAN2',
881 intentId = installResult,
882 onosNode='0',
883 host1=host1,
884 host2=host2,
885 sw1='s5',
886 sw2='s2',
887 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800888 else:
889 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800890
891 utilities.assert_equals( expect=main.TRUE,
892 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700893 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800894 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700895
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800896 main.step( "Confirm that ONOS leadership is unchanged")
acsmarse6b410f2015-07-17 14:39:34 -0700897 intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
898 main.intentFunction.checkLeaderChange( intentLeadersOld,
899 intentLeadersNew )
900
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800901 utilities.assert_equals( expect=main.TRUE,
902 actual=testResult,
903 onpass="ONOS Leaders Unchanged",
904 onfail="ONOS Leader Mismatch")
905
kelvin-onlab016dce22015-08-10 09:54:11 -0700906 main.intentFunction.report( main )
907
kelvin-onlabb769f562015-07-15 17:05:10 -0700908 def CASE2000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700909 """
910 Add point intents between 2 hosts:
911 - Get device ids | ports
912 - Add point intents
913 - Check intents
914 - Verify flows
915 - Ping hosts
916 - Reroute
917 - Link down
918 - Verify flows
919 - Check topology
920 - Ping hosts
921 - Link up
922 - Verify flows
923 - Check topology
924 - Ping hosts
925 - Remove intents
926 """
927 import time
928 import json
929 import re
Jeremyd9e4eb12016-04-13 12:09:06 -0700930 if main.initialized == main.FALSE:
931 main.log.error( "Test components did not start correctly, skipping further tests" )
932 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700933 # Assert variables - These variable's name|format must be followed
934 # if you want to use the wrapper function
935 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -0700936 try:
937 assert main.CLIs
938 except AssertionError:
939 main.log.error( "There is no main.CLIs, skipping test cases" )
940 main.initialized = main.FALSE
941 main.skipCase()
942 try:
943 assert main.Mininet1
944 except AssertionError:
945 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
946 main.initialized = main.FALSE
947 main.skipCase()
948 try:
949 assert main.numSwitch
950 except AssertionError:
951 main.log.error( "Place the total number of switch topology in \
952 main.numSwitch" )
953 main.initialized = main.FALSE
954 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700955
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700956 main.testName = "Point Intents"
957 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -0700958 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -0700959 main.caseExplanation = "This test case will test point to point" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700960 " intents using " + str( main.numCtrls ) +\
961 " node(s) cluster;\n" +\
962 "Different type of hosts will be tested in " +\
963 "each step such as IPV4, Dual stack, VLAN etc" +\
964 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -0700965 " OVS running in Mininet and compile intents" +\
966 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700967
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700968 # No option point intents
969 main.step( "NOOPTION: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700970 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800971 senders = [
972 { "name":"h1","device":"of:0000000000000005/1" }
973 ]
974 recipients = [
975 { "name":"h9","device":"of:0000000000000006/1" }
976 ]
Jeremy42df2e72016-02-23 16:37:46 -0800977 testResult = main.FALSE
978 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800979 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700980 main,
981 name="NOOPTION",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800982 senders=senders,
983 recipients=recipients )
984
985 if installResult:
986 testResult = main.intentFunction.testPointIntent(
987 main,
988 intentId=installResult,
989 name="NOOPTION",
990 senders=senders,
991 recipients=recipients,
992 sw1="s5",
993 sw2="s2",
994 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -0800995 else:
996 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700997
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700998 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800999 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001000 onpass=main.assertReturnString,
1001 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001002
1003 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -07001004 main.step( "IPV4: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001005 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001006 senders = [
1007 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1008 ]
1009 recipients = [
1010 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09" }
1011 ]
Jeremy42df2e72016-02-23 16:37:46 -08001012 testResult = main.FALSE
1013 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001014 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001015 main,
1016 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001017 senders=senders,
1018 recipients=recipients,
1019 ethType="IPV4" )
1020
1021 if installResult:
1022 testResult = main.intentFunction.testPointIntent(
1023 main,
1024 intentId=installResult,
1025 name="IPV4",
1026 senders=senders,
1027 recipients=recipients,
1028 sw1="s5",
1029 sw2="s2",
1030 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001031 else:
1032 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001033
1034 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001035 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001036 onpass=main.assertReturnString,
1037 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001038 main.step( "IPV4_2: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001039 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001040 senders = [
1041 { "name":"h1","device":"of:0000000000000005/1" }
1042 ]
1043 recipients = [
1044 { "name":"h9","device":"of:0000000000000006/1" }
1045 ]
Jeremy42df2e72016-02-23 16:37:46 -08001046 testResult = main.FALSE
1047 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001048 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001049 main,
1050 name="IPV4_2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001051 senders=senders,
1052 recipients=recipients,
1053 ethType="IPV4" )
1054
1055 if installResult:
1056 testResult = main.intentFunction.testPointIntent(
1057 main,
1058 intentId=installResult,
1059 name="IPV4_2",
1060 senders=senders,
1061 recipients=recipients,
1062 sw1="s5",
1063 sw2="s2",
1064 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001065 else:
1066 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001067
1068 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001069 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001070 onpass=main.assertReturnString,
1071 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001072
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001073 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001074 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001075 senders = [
1076 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01",
Jeremy6f000c62016-02-25 17:02:28 -08001077 "ip":( main.h1.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001078 ]
1079 recipients = [
1080 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09",
Jeremy6f000c62016-02-25 17:02:28 -08001081 "ip":( main.h9.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001082 ]
Jeremy6f000c62016-02-25 17:02:28 -08001083 ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ]
kelvin-onlab79ce0492015-07-27 16:14:39 -07001084 # Uneccessary, not including this in the selectors
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001085 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
1086 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
Jeremy42df2e72016-02-23 16:37:46 -08001087 testResult = main.FALSE
1088 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001089 installResult = main.intentFunction.installPointIntent(
1090 main,
1091 name="SDNIP-ICMP",
1092 senders=senders,
1093 recipients=recipients,
1094 ethType="IPV4",
1095 ipProto=ipProto,
1096 tcpSrc=tcpSrc,
1097 tcpDst=tcpDst )
1098
1099 if installResult:
1100 testResult = main.intentFunction.testPointIntent(
1101 main,
1102 intentId=installResult,
1103 name="SDNIP_ICMP",
1104 senders=senders,
1105 recipients=recipients,
1106 sw1="s5",
1107 sw2="s2",
1108 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001109 else:
1110 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabb769f562015-07-15 17:05:10 -07001111
1112 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001113 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001114 onpass=main.assertReturnString,
1115 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001116
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001117 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001118 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
kelvin-onlabb769f562015-07-15 17:05:10 -07001119 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
1120 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab58dc39e2015-08-06 08:11:09 -07001121 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
1122 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlabb769f562015-07-15 17:05:10 -07001123 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
1124 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
1125 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
1126
kelvin-onlab58dc39e2015-08-06 08:11:09 -07001127 stepResult = main.intentFunction.pointIntentTcp(
kelvin-onlabb769f562015-07-15 17:05:10 -07001128 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001129 name="SDNIP-TCP",
kelvin-onlabb769f562015-07-15 17:05:10 -07001130 host1="h1",
1131 host2="h9",
1132 deviceId1="of:0000000000000005/1",
1133 deviceId2="of:0000000000000006/1",
1134 mac1=mac1,
1135 mac2=mac2,
1136 ethType="IPV4",
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001137 ipProto=ipProto,
1138 ip1=ip1,
1139 ip2=ip2,
1140 tcp1=tcp1,
1141 tcp2=tcp2 )
kelvin-onlabb769f562015-07-15 17:05:10 -07001142
1143 utilities.assert_equals( expect=main.TRUE,
Jeremy6f000c62016-02-25 17:02:28 -08001144 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -07001145 onpass=main.assertReturnString,
1146 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001147
acsmars5d8cc862015-09-25 09:44:50 -07001148 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
1149 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001150 senders = [
1151 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1152 ]
1153 recipients = [
1154 { "name":"h11","device":"of:0000000000000006/3","mac":"00:00:00:00:00:0B" }
1155 ]
Jeremy42df2e72016-02-23 16:37:46 -08001156 testResult = main.FALSE
1157 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001158 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001159 main,
1160 name="DUALSTACK1",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001161 senders=senders,
1162 recipients=recipients,
1163 ethType="IPV4" )
1164
1165 if installResult:
1166 testResult = main.intentFunction.testPointIntent(
1167 main,
1168 intentId=installResult,
1169 name="DUALSTACK1",
1170 senders=senders,
1171 recipients=recipients,
1172 sw1="s5",
1173 sw2="s2",
1174 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001175 else:
1176 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001177
1178 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001179 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001180 onpass=main.assertReturnString,
1181 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001182
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001183 main.step( "VLAN: Add point intents between h5 and h21" )
acsmars5d8cc862015-09-25 09:44:50 -07001184 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001185 senders = [
1186 { "name":"h5","device":"of:0000000000000005/5","mac":"00:00:00:00:00:05" }
1187 ]
1188 recipients = [
1189 { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15" }
1190 ]
Jeremy42df2e72016-02-23 16:37:46 -08001191 testResult = main.FALSE
1192 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001193 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001194 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001195 name="DUALSTACK1",
1196 senders=senders,
1197 recipients=recipients,
1198 ethType="IPV4" )
1199
1200 if installResult:
1201 testResult = main.intentFunction.testPointIntent(
1202 main,
1203 intentId=installResult,
1204 name="DUALSTACK1",
1205 senders=senders,
1206 recipients=recipients,
1207 sw1="s5",
1208 sw2="s2",
1209 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001210
1211 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001212 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001213 onpass=main.assertReturnString,
1214 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001215
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001216 main.step( "1HOP: Add point intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -07001217 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001218 senders = [
1219 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1220 ]
1221 recipients = [
1222 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1223 ]
Jeremy42df2e72016-02-23 16:37:46 -08001224 testResult = main.FALSE
1225 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001226 installResult = main.intentFunction.installPointIntent(
1227 main,
1228 name="1HOP IPV4",
1229 senders=senders,
1230 recipients=recipients,
1231 ethType="IPV4" )
1232
1233 if installResult:
1234 testResult = main.intentFunction.testPointIntent(
1235 main,
1236 intentId=installResult,
1237 name="1HOP IPV4",
1238 senders=senders,
1239 recipients=recipients,
1240 sw1="s5",
1241 sw2="s2",
1242 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001243 else:
1244 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001245
1246 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001247 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001248 onpass=main.assertReturnString,
1249 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001250
kelvin-onlab016dce22015-08-10 09:54:11 -07001251 main.intentFunction.report( main )
1252
kelvin-onlabb769f562015-07-15 17:05:10 -07001253 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001254 """
1255 Add single point to multi point intents
1256 - Get device ids
1257 - Add single point to multi point intents
1258 - Check intents
1259 - Verify flows
1260 - Ping hosts
1261 - Reroute
1262 - Link down
1263 - Verify flows
1264 - Check topology
1265 - Ping hosts
1266 - Link up
1267 - Verify flows
1268 - Check topology
1269 - Ping hosts
1270 - Remove intents
1271 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001272 if main.initialized == main.FALSE:
1273 main.log.error( "Test components did not start correctly, skipping further tests" )
1274 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001275 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001276 try:
1277 assert main.CLIs
1278 except AssertionError:
1279 main.log.error( "There is no main.CLIs, skipping test cases" )
1280 main.initialized = main.FALSE
1281 main.skipCase()
1282 try:
1283 assert main.Mininet1
1284 except AssertionError:
1285 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1286 main.initialized = main.FALSE
1287 main.skipCase()
1288 try:
1289 assert main.numSwitch
1290 except AssertionError:
1291 main.log.error( "Place the total number of switch topology in \
1292 main.numSwitch" )
1293 main.initialized = main.FALSE
1294 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001295
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001296 main.testName = "Single to Multi Point Intents"
1297 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001298 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001299 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001300 " multi point intents using " +\
1301 str( main.numCtrls ) + " node(s) cluster;\n" +\
1302 "Different type of hosts will be tested in " +\
1303 "each step such as IPV4, Dual stack, VLAN etc" +\
1304 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001305 " OVS running in Mininet and compile intents" +\
1306 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001307
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001308 main.step( "NOOPTION: Install and test single point to multi point intents" )
1309 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
1310 senders = [
1311 { "name":"h8", "device":"of:0000000000000005/8" }
1312 ]
1313 recipients = [
1314 { "name":"h16", "device":"of:0000000000000006/8" },
1315 { "name":"h24", "device":"of:0000000000000007/8" }
1316 ]
1317 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1318 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1319 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001320 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001321 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001322 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001323 name="NOOPTION",
1324 senders=senders,
1325 recipients=recipients,
1326 sw1="s5",
1327 sw2="s2")
1328
1329 if installResult:
1330 testResult = main.intentFunction.testPointIntent(
1331 main,
1332 intentId=installResult,
1333 name="NOOPTION",
1334 senders=senders,
1335 recipients=recipients,
1336 badSenders=badSenders,
1337 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001338 sw1="s5",
1339 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001340 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001341 else:
1342 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001343
1344 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001345 actual=testResult,
1346 onpass=main.assertReturnString,
1347 onfail=main.assertReturnString )
1348
1349 main.step( "IPV4: Install and test single point to multi point intents" )
1350 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses\n"
1351 senders = [
1352 { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" }
1353 ]
1354 recipients = [
1355 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1356 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1357 ]
1358 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1359 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1360 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001361 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001362 installResult = main.intentFunction.installSingleToMultiIntent(
1363 main,
1364 name="IPV4",
1365 senders=senders,
1366 recipients=recipients,
1367 ethType="IPV4",
1368 sw1="s5",
1369 sw2="s2")
1370
1371 if installResult:
1372 testResult = main.intentFunction.testPointIntent(
1373 main,
1374 intentId=installResult,
1375 name="IPV4",
1376 senders=senders,
1377 recipients=recipients,
1378 badSenders=badSenders,
1379 badRecipients=badRecipients,
1380 sw1="s5",
1381 sw2="s2",
1382 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001383 else:
1384 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001385
1386 utilities.assert_equals( expect=main.TRUE,
1387 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001388 onpass=main.assertReturnString,
1389 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001390
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001391 main.step( "IPV4_2: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001392 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 -08001393 senders = [
1394 { "name":"h8", "device":"of:0000000000000005/8" }
1395 ]
1396 recipients = [
1397 { "name":"h16", "device":"of:0000000000000006/8" },
1398 { "name":"h24", "device":"of:0000000000000007/8" }
1399 ]
1400 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1401 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1402 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001403 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001404 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001405 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001406 name="IPV4_2",
1407 senders=senders,
1408 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001409 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001410 sw1="s5",
1411 sw2="s2")
1412
1413 if installResult:
1414 testResult = main.intentFunction.testPointIntent(
1415 main,
1416 intentId=installResult,
1417 name="IPV4_2",
1418 senders=senders,
1419 recipients=recipients,
1420 badSenders=badSenders,
1421 badRecipients=badRecipients,
1422 sw1="s5",
1423 sw2="s2",
1424 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001425 else:
1426 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001427
1428 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001429 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001430 onpass=main.assertReturnString,
1431 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001432
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001433 main.step( "VLAN: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001434 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 -08001435 senders = [
1436 { "name":"h4", "device":"of:0000000000000005/4", "mac":"00:00:00:00:00:04" }
1437 ]
1438 recipients = [
1439 { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C" },
1440 { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14" }
1441 ]
1442 badSenders=[ { "name":"h13" } ] # Senders that are not in the intent
1443 badRecipients=[ { "name":"h21" } ] # Recipients that are not in the intent
1444 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001445 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001446 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001447 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001448 name="IPV4",
1449 senders=senders,
1450 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001451 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001452 sw1="s5",
1453 sw2="s2")
1454
1455 if installResult:
1456 testResult = main.intentFunction.testPointIntent(
1457 main,
1458 intentId=installResult,
1459 name="IPV4",
1460 senders=senders,
1461 recipients=recipients,
1462 badSenders=badSenders,
1463 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001464 sw1="s5",
1465 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001466 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001467 else:
1468 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001469
1470 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001471 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001472 onpass=main.assertReturnString,
1473 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001474
kelvin-onlab016dce22015-08-10 09:54:11 -07001475 main.intentFunction.report( main )
1476
kelvin-onlabb769f562015-07-15 17:05:10 -07001477 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001478 """
1479 Add multi point to single point intents
1480 - Get device ids
1481 - Add multi point to single point intents
1482 - Check intents
1483 - Verify flows
1484 - Ping hosts
1485 - Reroute
1486 - Link down
1487 - Verify flows
1488 - Check topology
1489 - Ping hosts
1490 - Link up
1491 - Verify flows
1492 - Check topology
1493 - Ping hosts
1494 - Remove intents
1495 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001496 if main.initialized == main.FALSE:
1497 main.log.error( "Test components did not start correctly, skipping further tests" )
1498 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001499 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001500 try:
1501 assert main.CLIs
1502 except AssertionError:
1503 main.log.error( "There is no main.CLIs, skipping test cases" )
1504 main.initialized = main.FALSE
1505 main.skipCase()
1506 try:
1507 assert main.Mininet1
1508 except AssertionError:
1509 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1510 main.initialized = main.FALSE
1511 main.skipCase()
1512 try:
1513 assert main.numSwitch
1514 except AssertionError:
1515 main.log.error( "Place the total number of switch topology in \
1516 main.numSwitch" )
1517 main.initialized = main.FALSE
1518 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001519
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001520 main.testName = "Multi To Single Point Intents"
1521 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001522 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001523 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001524 " multi point intents using " +\
1525 str( main.numCtrls ) + " node(s) cluster;\n" +\
1526 "Different type of hosts will be tested in " +\
1527 "each step such as IPV4, Dual stack, VLAN etc" +\
1528 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001529 " OVS running in Mininet and compile intents" +\
1530 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001531
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001532 main.step( "NOOPTION: Add multi point to single point intents" )
1533 main.assertReturnString = "Assertion results for NOOPTION multi to single point intent\n"
1534 senders = [
1535 { "name":"h16", "device":"of:0000000000000006/8" },
1536 { "name":"h24", "device":"of:0000000000000007/8" }
1537 ]
1538 recipients = [
1539 { "name":"h8", "device":"of:0000000000000005/8" }
1540 ]
1541 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1542 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1543 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001544 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001545 installResult = main.intentFunction.installMultiToSingleIntent(
1546 main,
1547 name="NOOPTION",
1548 senders=senders,
1549 recipients=recipients,
1550 sw1="s5",
Jeremye0cb5eb2016-01-27 17:39:09 -08001551 sw2="s2" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001552
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001553 if installResult:
1554 testResult = main.intentFunction.testPointIntent(
1555 main,
1556 intentId=installResult,
1557 name="NOOPTION",
1558 senders=senders,
1559 recipients=recipients,
1560 badSenders=badSenders,
1561 badRecipients=badRecipients,
1562 sw1="s5",
1563 sw2="s2",
Jeremye0cb5eb2016-01-27 17:39:09 -08001564 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001565 else:
1566 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001567
1568 utilities.assert_equals( expect=main.TRUE,
1569 actual=testResult,
1570 onpass=main.assertReturnString,
1571 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001572
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001573 main.step( "IPV4: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001574 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 -08001575 senders = [
1576 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1577 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1578 ]
1579 recipients = [
1580 { "name":"h8", "device":"of:0000000000000005/8", "mac":"00:00:00:00:00:08" }
1581 ]
1582 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1583 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1584 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001585 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001586 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001587 main,
1588 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001589 senders=senders,
1590 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001591 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001592 sw1="s5",
1593 sw2="s2")
1594
1595 if installResult:
1596 testResult = main.intentFunction.testPointIntent(
1597 main,
1598 intentId=installResult,
1599 name="IPV4",
1600 senders=senders,
1601 recipients=recipients,
1602 badSenders=badSenders,
1603 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001604 sw1="s5",
1605 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001606 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001607 else:
1608 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001609
1610 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001611 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001612 onpass=main.assertReturnString,
1613 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001614
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001615 main.step( "IPV4_2: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001616 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 -08001617 senders = [
1618 { "name":"h16", "device":"of:0000000000000006/8" },
1619 { "name":"h24", "device":"of:0000000000000007/8" }
1620 ]
1621 recipients = [
1622 { "name":"h8", "device":"of:0000000000000005/8" }
1623 ]
1624 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1625 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1626 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001627 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001628 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001629 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001630 name="IPV4_2",
1631 senders=senders,
1632 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001633 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001634 sw1="s5",
1635 sw2="s2")
1636
1637 if installResult:
1638 testResult = main.intentFunction.testPointIntent(
1639 main,
1640 intentId=installResult,
1641 name="IPV4_2",
1642 senders=senders,
1643 recipients=recipients,
1644 badSenders=badSenders,
1645 badRecipients=badRecipients,
1646 sw1="s5",
1647 sw2="s2",
1648 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001649 else:
1650 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001651
1652 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001653 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001654 onpass=main.assertReturnString,
1655 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001656
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001657 main.step( "VLAN: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001658 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 -08001659 senders = [
1660 { "name":"h13", "device":"of:0000000000000006/5" },
1661 { "name":"h21", "device":"of:0000000000000007/5" }
1662 ]
1663 recipients = [
1664 { "name":"h5", "device":"of:0000000000000005/5" }
1665 ]
1666 badSenders=[ { "name":"h12" } ] # Senders that are not in the intent
1667 badRecipients=[ { "name":"h20" } ] # Recipients that are not in the intent
1668 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001669 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001670 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001671 main,
1672 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001673 senders=senders,
1674 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001675 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001676 sw1="s5",
1677 sw2="s2")
1678
1679 if installResult:
1680 testResult = main.intentFunction.testPointIntent(
1681 main,
1682 intentId=installResult,
1683 name="VLAN",
1684 senders=senders,
1685 recipients=recipients,
1686 badSenders=badSenders,
1687 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001688 sw1="s5",
1689 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001690 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001691 else:
1692 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001693
1694 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001695 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001696 onpass=main.assertReturnString,
1697 onfail=main.assertReturnString )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001698
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001699 main.intentFunction.report( main )
1700
acsmars1ff5e052015-07-23 11:27:48 -07001701 def CASE5000( self, main ):
1702 """
acsmars5d8cc862015-09-25 09:44:50 -07001703 Tests Host Mobility
1704 Modifies the topology location of h1
acsmars1ff5e052015-07-23 11:27:48 -07001705 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001706 if main.initialized == main.FALSE:
1707 main.log.error( "Test components did not start correctly, skipping further tests" )
1708 main.skipCase()
acsmars1ff5e052015-07-23 11:27:48 -07001709 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001710 try:
1711 assert main.CLIs
1712 except AssertionError:
1713 main.log.error( "There is no main.CLIs, skipping test cases" )
1714 main.initialized = main.FALSE
1715 main.skipCase()
1716 try:
1717 assert main.Mininet1
1718 except AssertionError:
1719 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1720 main.initialized = main.FALSE
1721 main.skipCase()
1722 try:
1723 assert main.numSwitch
1724 except AssertionError:
1725 main.log.error( "Place the total number of switch topology in \
1726 main.numSwitch" )
1727 main.initialized = main.FALSE
1728 main.skipCase()
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001729 main.case( "Test host mobility with host intents " )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001730 main.step( "Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07001731 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1732
Jeremy2f190ca2016-01-29 15:23:57 -08001733 main.log.info( "Moving h1 from s5 to s6")
acsmars1ff5e052015-07-23 11:27:48 -07001734 main.Mininet1.moveHost( "h1","s5","s6" )
1735
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001736 # Send discovery ping from moved host
1737 # Moving the host brings down the default interfaces and creates a new one.
1738 # Scapy is restarted on this host to detect the new interface
1739 main.h1.stopScapy()
1740 main.h1.startScapy()
1741
1742 # Discover new host location in ONOS and populate host data.
1743 # Host 1 IP and MAC should be unchanged
1744 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
1745 main.intentFunction.populateHostData( main )
1746
acsmars1ff5e052015-07-23 11:27:48 -07001747 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1748
1749 utilities.assert_equals( expect="of:0000000000000006",
1750 actual=h1PostMove,
1751 onpass="Mobility: Successfully moved h1 to s6",
acsmars5d8cc862015-09-25 09:44:50 -07001752 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001753 " to single point intents" +
1754 " with IPV4 type and MAC addresses" +
1755 " in the same VLAN" )
1756
1757 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001758 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001759 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
1760 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
Jeremy42df2e72016-02-23 16:37:46 -08001761 testResult = main.FALSE
1762 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001763 installResult = main.intentFunction.installHostIntent( main,
1764 name='IPV4 Mobility IPV4',
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001765 onosNode='0',
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001766 host1=host1,
Jeremye0cb5eb2016-01-27 17:39:09 -08001767 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -08001768 if installResult:
1769 testResult = main.intentFunction.testHostIntent( main,
1770 name='Host Mobility IPV4',
1771 intentId = installResult,
1772 onosNode='0',
1773 host1=host1,
1774 host2=host2,
1775 sw1="s6",
1776 sw2="s2",
1777 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001778 else:
1779 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001780
1781 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001782 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001783 onpass=main.assertReturnString,
1784 onfail=main.assertReturnString )
kelvin-onlab016dce22015-08-10 09:54:11 -07001785
1786 main.intentFunction.report( main )
Jeremye0cb5eb2016-01-27 17:39:09 -08001787
1788 def CASE6000( self, main ):
1789 """
1790 Tests Multi to Single Point Intent and Single to Multi Point Intent End Point Failure
1791 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001792 if main.initialized == main.FALSE:
1793 main.log.error( "Test components did not start correctly, skipping further tests" )
1794 main.skipCase()
Jeremye0cb5eb2016-01-27 17:39:09 -08001795 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001796 try:
1797 assert main.CLIs
1798 except AssertionError:
1799 main.log.error( "There is no main.CLIs, skipping test cases" )
1800 main.initialized = main.FALSE
1801 main.skipCase()
1802 try:
1803 assert main.Mininet1
1804 except AssertionError:
1805 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1806 main.initialized = main.FALSE
1807 main.skipCase()
1808 try:
1809 assert main.numSwitch
1810 except AssertionError:
1811 main.log.error( "Place the total number of switch topology in \
1812 main.numSwitch" )
1813 main.initialized = main.FALSE
1814 main.skipCase()
Jeremye0cb5eb2016-01-27 17:39:09 -08001815 main.case( "Test Multi to Single End Point Failure" )
1816 main.step( "Installing Multi to Single Point intents" )
1817
1818 main.assertReturnString = "Assertion results for IPV4 multi to single \
1819 point intent end point failure with no options set\n"
1820 senders = [
1821 { "name":"h16", "device":"of:0000000000000006/8" },
1822 { "name":"h24", "device":"of:0000000000000007/8" }
1823 ]
1824 recipients = [
1825 { "name":"h8", "device":"of:0000000000000005/8" }
1826 ]
1827 isolatedSenders = [
1828 { "name":"h24"}
1829 ]
1830 isolatedRecipients = []
1831 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001832 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08001833 installResult = main.intentFunction.installMultiToSingleIntent(
1834 main,
1835 name="NOOPTION",
1836 senders=senders,
1837 recipients=recipients,
1838 sw1="s5",
1839 sw2="s2" )
1840
1841 if installResult:
1842 testResult = main.intentFunction.testEndPointFail(
1843 main,
1844 intentId=installResult,
1845 name="NOOPTION",
1846 senders=senders,
1847 recipients=recipients,
1848 isolatedSenders=isolatedSenders,
1849 isolatedRecipients=isolatedRecipients,
1850 sw1="s6",
1851 sw2="s2",
1852 sw3="s4",
1853 sw4="s1",
1854 sw5="s3",
1855 expectedLink1=16,
1856 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08001857 else:
1858 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08001859
1860 utilities.assert_equals( expect=main.TRUE,
1861 actual=testResult,
1862 onpass=main.assertReturnString,
1863 onfail=main.assertReturnString )
1864
1865 main.step( "IPV4: Add multi point to single point intents" )
1866 main.assertReturnString = "Assertion results for IPV4 multi to single \
1867 point intent end point failure with IPV4 type and MAC addresses\n"
1868 senders = [
1869 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1870 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1871 ]
1872 recipients = [
1873 { "name":"h8", "device":"of:0000000000000005/8", "mac":"00:00:00:00:00:08" }
1874 ]
1875 isolatedSenders = [
1876 { "name":"h24"}
1877 ]
1878 isolatedRecipients = []
1879 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001880 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08001881 installResult = main.intentFunction.installMultiToSingleIntent(
1882 main,
1883 name="IPV4",
1884 senders=senders,
1885 recipients=recipients,
1886 ethType="IPV4",
1887 sw1="s5",
1888 sw2="s2")
1889
1890 if installResult:
1891 testResult = main.intentFunction.testEndPointFail(
1892 main,
1893 intentId=installResult,
1894 name="IPV4",
1895 senders=senders,
1896 recipients=recipients,
1897 isolatedSenders=isolatedSenders,
1898 isolatedRecipients=isolatedRecipients,
1899 sw1="s6",
1900 sw2="s2",
1901 sw3="s4",
1902 sw4="s1",
1903 sw5="s3",
1904 expectedLink1=16,
1905 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08001906 else:
1907 main.CLIs[ 0 ].removeAllIntents( purge=True )
1908
Jeremye0cb5eb2016-01-27 17:39:09 -08001909 utilities.assert_equals( expect=main.TRUE,
1910 actual=testResult,
1911 onpass=main.assertReturnString,
1912 onfail=main.assertReturnString )
1913
1914 main.step( "IPV4_2: Add multi point to single point intents" )
1915 main.assertReturnString = "Assertion results for IPV4 multi to single \
1916 point intent end point failure with IPV4 type and no MAC addresses\n"
1917 senders = [
1918 { "name":"h16", "device":"of:0000000000000006/8" },
1919 { "name":"h24", "device":"of:0000000000000007/8" }
1920 ]
1921 recipients = [
1922 { "name":"h8", "device":"of:0000000000000005/8" }
1923 ]
1924 isolatedSenders = [
1925 { "name":"h24"}
1926 ]
1927 isolatedRecipients = []
1928 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001929 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08001930 installResult = main.intentFunction.installMultiToSingleIntent(
1931 main,
1932 name="IPV4_2",
1933 senders=senders,
1934 recipients=recipients,
1935 ethType="IPV4",
1936 sw1="s5",
1937 sw2="s2")
1938
1939 if installResult:
1940 testResult = main.intentFunction.testEndPointFail(
1941 main,
1942 intentId=installResult,
1943 name="IPV4_2",
1944 senders=senders,
1945 recipients=recipients,
1946 isolatedSenders=isolatedSenders,
1947 isolatedRecipients=isolatedRecipients,
1948 sw1="s6",
1949 sw2="s2",
1950 sw3="s4",
1951 sw4="s1",
1952 sw5="s3",
1953 expectedLink1=16,
1954 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08001955 else:
1956 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08001957
1958 utilities.assert_equals( expect=main.TRUE,
1959 actual=testResult,
1960 onpass=main.assertReturnString,
1961 onfail=main.assertReturnString )
1962
1963 main.step( "VLAN: Add multi point to single point intents" )
1964 main.assertReturnString = "Assertion results for IPV4 multi to single \
1965 point intent end point failure with IPV4 type and no MAC addresses in the same VLAN\n"
1966 senders = [
1967 { "name":"h13", "device":"of:0000000000000006/5" },
1968 { "name":"h21", "device":"of:0000000000000007/5" }
1969 ]
1970 recipients = [
1971 { "name":"h5", "device":"of:0000000000000005/5" }
1972 ]
1973 isolatedSenders = [
1974 { "name":"h21"}
1975 ]
1976 isolatedRecipients = []
1977 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001978 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08001979 installResult = main.intentFunction.installMultiToSingleIntent(
1980 main,
1981 name="VLAN",
1982 senders=senders,
1983 recipients=recipients,
1984 ethType="IPV4",
1985 sw1="s5",
1986 sw2="s2")
1987
1988 if installResult:
1989 testResult = main.intentFunction.testEndPointFail(
1990 main,
1991 intentId=installResult,
1992 name="VLAN",
1993 senders=senders,
1994 recipients=recipients,
1995 isolatedSenders=isolatedSenders,
1996 isolatedRecipients=isolatedRecipients,
1997 sw1="s6",
1998 sw2="s2",
1999 sw3="s4",
2000 sw4="s1",
2001 sw5="s3",
2002 expectedLink1=16,
2003 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002004 else:
2005 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002006
2007 utilities.assert_equals( expect=main.TRUE,
2008 actual=testResult,
2009 onpass=main.assertReturnString,
2010 onfail=main.assertReturnString )
2011
2012 main.step( "NOOPTION: Install and test single point to multi point intents" )
2013 main.assertReturnString = "Assertion results for IPV4 single to multi \
2014 point intent end point failure with no options set\n"
2015 senders = [
2016 { "name":"h8", "device":"of:0000000000000005/8" }
2017 ]
2018 recipients = [
2019 { "name":"h16", "device":"of:0000000000000006/8" },
2020 { "name":"h24", "device":"of:0000000000000007/8" }
2021 ]
2022 isolatedSenders = []
2023 isolatedRecipients = [
2024 { "name":"h24" }
2025 ]
2026 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08002027 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08002028 installResult = main.intentFunction.installSingleToMultiIntent(
2029 main,
2030 name="NOOPTION",
2031 senders=senders,
2032 recipients=recipients,
2033 sw1="s5",
2034 sw2="s2")
2035
2036 if installResult:
2037 testResult = main.intentFunction.testEndPointFail(
2038 main,
2039 intentId=installResult,
2040 name="NOOPTION",
2041 senders=senders,
2042 recipients=recipients,
2043 isolatedSenders=isolatedSenders,
2044 isolatedRecipients=isolatedRecipients,
2045 sw1="s6",
2046 sw2="s2",
2047 sw3="s4",
2048 sw4="s1",
2049 sw5="s3",
2050 expectedLink1=16,
2051 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002052 else:
2053 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002054
2055 utilities.assert_equals( expect=main.TRUE,
2056 actual=testResult,
2057 onpass=main.assertReturnString,
2058 onfail=main.assertReturnString )
2059
2060 main.step( "IPV4: Install and test single point to multi point intents" )
2061 main.assertReturnString = "Assertion results for IPV4 single to multi \
2062 point intent end point failure with IPV4 type and no MAC addresses\n"
2063 senders = [
2064 { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" }
2065 ]
2066 recipients = [
2067 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
2068 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
2069 ]
2070 isolatedSenders = []
2071 isolatedRecipients = [
2072 { "name":"h24" }
2073 ]
2074 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08002075 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08002076 installResult = main.intentFunction.installSingleToMultiIntent(
2077 main,
2078 name="IPV4",
2079 senders=senders,
2080 recipients=recipients,
2081 ethType="IPV4",
2082 sw1="s5",
2083 sw2="s2")
2084
2085 if installResult:
2086 testResult = main.intentFunction.testEndPointFail(
2087 main,
2088 intentId=installResult,
2089 name="IPV4",
2090 senders=senders,
2091 recipients=recipients,
2092 isolatedSenders=isolatedSenders,
2093 isolatedRecipients=isolatedRecipients,
2094 sw1="s6",
2095 sw2="s2",
2096 sw3="s4",
2097 sw4="s1",
2098 sw5="s3",
2099 expectedLink1=16,
2100 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002101 else:
2102 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002103
2104 utilities.assert_equals( expect=main.TRUE,
2105 actual=testResult,
2106 onpass=main.assertReturnString,
2107 onfail=main.assertReturnString )
2108
2109 main.step( "IPV4_2: Add single point to multi point intents" )
2110 main.assertReturnString = "Assertion results for IPV4 single to multi\
2111 point intent endpoint failure with IPV4 type and no MAC addresses\n"
2112 senders = [
2113 { "name":"h8", "device":"of:0000000000000005/8" }
2114 ]
2115 recipients = [
2116 { "name":"h16", "device":"of:0000000000000006/8" },
2117 { "name":"h24", "device":"of:0000000000000007/8" }
2118 ]
2119 isolatedSenders = []
2120 isolatedRecipients = [
2121 { "name":"h24" }
2122 ]
2123 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08002124 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08002125 installResult = main.intentFunction.installSingleToMultiIntent(
2126 main,
2127 name="IPV4_2",
2128 senders=senders,
2129 recipients=recipients,
2130 ethType="IPV4",
2131 sw1="s5",
2132 sw2="s2")
2133
2134 if installResult:
2135 testResult = main.intentFunction.testEndPointFail(
2136 main,
2137 intentId=installResult,
2138 name="IPV4_2",
2139 senders=senders,
2140 recipients=recipients,
2141 isolatedSenders=isolatedSenders,
2142 isolatedRecipients=isolatedRecipients,
2143 sw1="s6",
2144 sw2="s2",
2145 sw3="s4",
2146 sw4="s1",
2147 sw5="s3",
2148 expectedLink1=16,
2149 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002150 else:
2151 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002152
2153 utilities.assert_equals( expect=main.TRUE,
2154 actual=testResult,
2155 onpass=main.assertReturnString,
2156 onfail=main.assertReturnString )
2157
2158 main.step( "VLAN: Add single point to multi point intents" )
2159 main.assertReturnString = "Assertion results for IPV4 single to multi point\
2160 intent endpoint failure with IPV4 type and MAC addresses in the same VLAN\n"
2161 senders = [
2162 { "name":"h4", "device":"of:0000000000000005/4", "mac":"00:00:00:00:00:04" }
2163 ]
2164 recipients = [
2165 { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C" },
2166 { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14" }
2167 ]
2168 isolatedSenders = []
2169 isolatedRecipients = [
2170 { "name":"h20" }
2171 ]
2172 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08002173 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08002174 installResult = main.intentFunction.installSingleToMultiIntent(
2175 main,
2176 name="IPV4",
2177 senders=senders,
2178 recipients=recipients,
2179 ethType="IPV4",
2180 sw1="s5",
2181 sw2="s2")
2182
2183 if installResult:
2184 testResult = main.intentFunction.testEndPointFail(
2185 main,
2186 intentId=installResult,
2187 name="IPV4",
2188 senders=senders,
2189 recipients=recipients,
2190 isolatedSenders=isolatedSenders,
2191 isolatedRecipients=isolatedRecipients,
2192 sw1="s6",
2193 sw2="s2",
2194 sw3="s4",
2195 sw4="s1",
2196 sw5="s3",
2197 expectedLink1=16,
2198 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002199 else:
2200 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002201
2202 utilities.assert_equals( expect=main.TRUE,
2203 actual=testResult,
2204 onpass=main.assertReturnString,
2205 onfail=main.assertReturnString )
2206
Jeremy2f190ca2016-01-29 15:23:57 -08002207 main.intentFunction.report( main )