blob: 080aa8fa3230510a33ee5b35ef8d9277d146ea05 [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 ):
Jeremy Songster7edb6632016-04-28 15:44:28 -0700212 isUp = main.ONOSbench.isup( main.ONOSip[ i ] )
213 onosIsUp = onosIsUp and isUp
214 if isUp == main.TRUE:
Jeremyd9e4eb12016-04-13 12:09:06 -0700215 main.log.report( "ONOS instance {0} is up and ready".format( i + 1 ) )
216 else:
217 main.log.report( "ONOS instance {0} may not be up, stop and ".format( i + 1 ) +
218 "start ONOS again " )
219 stopResult = stopResult and main.ONOSbench.onosStop( main.ONOSip[ i ] )
220 startResult = startResult and main.ONOSbench.onosStart( main.ONOSip[ i ] )
221 if not startResult or stopResult:
222 main.log.report( "ONOS instance {0} did not start correctly.".format( i + 1) )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700223 stepResult = onosIsUp and stopResult and startResult
224 utilities.assert_equals( expect=main.TRUE,
225 actual=stepResult,
Jeremyd9e4eb12016-04-13 12:09:06 -0700226 onpass="ONOS service is ready on all nodes",
227 onfail="ONOS service did not start properly on all nodes" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700228
229 main.step( "Start ONOS cli" )
230 cliResult = main.TRUE
231 for i in range( main.numCtrls ):
232 cliResult = cliResult and \
233 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
234 stepResult = cliResult
235 utilities.assert_equals( expect=main.TRUE,
236 actual=stepResult,
237 onpass="Successfully start ONOS cli",
238 onfail="Failed to start ONOS cli" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700239 if not stepResult:
240 main.initialized = main.FALSE
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700241
242 # Remove the first element in main.scale list
243 main.scale.remove( main.scale[ 0 ] )
244
kelvin-onlab016dce22015-08-10 09:54:11 -0700245 main.intentFunction.report( main )
246
Jon Halla3e02432015-07-24 15:55:42 -0700247 def CASE8( self, main ):
248 """
acsmars59a4c552015-09-10 18:11:19 -0700249 Compare ONOS Topology to Mininet Topology
Jon Halla3e02432015-07-24 15:55:42 -0700250 """
251 import json
252
253 main.case( "Compare ONOS Topology view to Mininet topology" )
254 main.caseExplanation = "Compare topology elements between Mininet" +\
255 " and ONOS"
256
acsmars59a4c552015-09-10 18:11:19 -0700257 main.log.info( "Gathering topology information from Mininet" )
258 devicesResults = main.FALSE # Overall Boolean for device correctness
259 linksResults = main.FALSE # Overall Boolean for link correctness
260 hostsResults = main.FALSE # Overall Boolean for host correctness
261 deviceFails = [] # Nodes where devices are incorrect
262 linkFails = [] # Nodes where links are incorrect
263 hostFails = [] # Nodes where hosts are incorrect
264 attempts = main.checkTopoAttempts # Remaining Attempts
Jon Halla3e02432015-07-24 15:55:42 -0700265
266 mnSwitches = main.Mininet1.getSwitches()
267 mnLinks = main.Mininet1.getLinks()
268 mnHosts = main.Mininet1.getHosts()
269
Jon Hall70b2ff42015-11-17 15:49:44 -0800270 main.step( "Comparing Mininet topology to ONOS topology" )
Jon Halla3e02432015-07-24 15:55:42 -0700271
acsmars59a4c552015-09-10 18:11:19 -0700272 while ( attempts >= 0 ) and\
273 ( not devicesResults or not linksResults or not hostsResults ):
274 time.sleep( 2 )
275 if not devicesResults:
276 devices = main.topo.getAllDevices( main )
277 ports = main.topo.getAllPorts( main )
278 devicesResults = main.TRUE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800279 deviceFails = [] # Reset for each failed attempt
acsmars59a4c552015-09-10 18:11:19 -0700280 if not linksResults:
281 links = main.topo.getAllLinks( main )
282 linksResults = main.TRUE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800283 linkFails = [] # Reset for each failed attempt
acsmars59a4c552015-09-10 18:11:19 -0700284 if not hostsResults:
285 hosts = main.topo.getAllHosts( main )
286 hostsResults = main.TRUE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800287 hostFails = [] # Reset for each failed attempt
Jon Halla3e02432015-07-24 15:55:42 -0700288
acsmars59a4c552015-09-10 18:11:19 -0700289 # Check for matching topology on each node
290 for controller in range( main.numCtrls ):
291 controllerStr = str( controller + 1 ) # ONOS node number
292 # Compare Devices
293 if devices[ controller ] and ports[ controller ] and\
294 "Error" not in devices[ controller ] and\
295 "Error" not in ports[ controller ]:
Jon Halla3e02432015-07-24 15:55:42 -0700296
acsmars2ec91d62015-09-16 11:15:48 -0700297 try:
298 deviceData = json.loads( devices[ controller ] )
299 portData = json.loads( ports[ controller ] )
300 except (TypeError,ValueError):
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800301 main.log.error( "Could not load json: {0} or {1}".format( str( devices[ controller ] ), str( ports[ controller ] ) ) )
acsmars2ec91d62015-09-16 11:15:48 -0700302 currentDevicesResult = main.FALSE
303 else:
304 currentDevicesResult = main.Mininet1.compareSwitches(
305 mnSwitches,deviceData,portData )
acsmars59a4c552015-09-10 18:11:19 -0700306 else:
307 currentDevicesResult = main.FALSE
308 if not currentDevicesResult:
309 deviceFails.append( controllerStr )
310 devicesResults = devicesResults and currentDevicesResult
311 # Compare Links
312 if links[ controller ] and "Error" not in links[ controller ]:
acsmars2ec91d62015-09-16 11:15:48 -0700313 try:
314 linkData = json.loads( links[ controller ] )
315 except (TypeError,ValueError):
316 main.log.error("Could not load json:" + str( links[ controller ] ) )
317 currentLinksResult = main.FALSE
318 else:
319 currentLinksResult = main.Mininet1.compareLinks(
320 mnSwitches, mnLinks,linkData )
acsmars59a4c552015-09-10 18:11:19 -0700321 else:
322 currentLinksResult = main.FALSE
323 if not currentLinksResult:
324 linkFails.append( controllerStr )
325 linksResults = linksResults and currentLinksResult
326 # Compare Hosts
acsmars2ec91d62015-09-16 11:15:48 -0700327 if hosts[ controller ] and "Error" not in hosts[ controller ]:
328 try:
329 hostData = json.loads( hosts[ controller ] )
330 except (TypeError,ValueError):
331 main.log.error("Could not load json:" + str( hosts[ controller ] ) )
332 currentHostsResult = main.FALSE
333 else:
334 currentHostsResult = main.Mininet1.compareHosts(
335 mnHosts,hostData )
acsmars59a4c552015-09-10 18:11:19 -0700336 else:
337 currentHostsResult = main.FALSE
338 if not currentHostsResult:
339 hostFails.append( controllerStr )
340 hostsResults = hostsResults and currentHostsResult
341 # Decrement Attempts Remaining
342 attempts -= 1
343
344
345 utilities.assert_equals( expect=[],
346 actual=deviceFails,
347 onpass="ONOS correctly discovered all devices",
348 onfail="ONOS incorrectly discovered devices on nodes: " +
349 str( deviceFails ) )
350 utilities.assert_equals( expect=[],
351 actual=linkFails,
352 onpass="ONOS correctly discovered all links",
353 onfail="ONOS incorrectly discovered links on nodes: " +
354 str( linkFails ) )
355 utilities.assert_equals( expect=[],
356 actual=hostFails,
357 onpass="ONOS correctly discovered all hosts",
358 onfail="ONOS incorrectly discovered hosts on nodes: " +
359 str( hostFails ) )
Jon Hall46d48252015-08-03 11:41:16 -0700360 topoResults = hostsResults and linksResults and devicesResults
361 utilities.assert_equals( expect=main.TRUE,
362 actual=topoResults,
363 onpass="ONOS correctly discovered the topology",
364 onfail="ONOS incorrectly discovered the topology" )
Jon Halla3e02432015-07-24 15:55:42 -0700365
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700366 def CASE10( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700367 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700368 Start Mininet topology with OF 1.0 switches
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700369 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700370 if main.initialized == main.FALSE:
371 main.log.error( "Test components did not start correctly, skipping further tests" )
372 main.skipCase()
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700373 main.OFProtocol = "1.0"
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700374 main.log.report( "Start Mininet topology with OF 1.0 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700375 main.case( "Start Mininet topology with OF 1.0 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700376 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700377 "switches to test intents, exits out if " +\
378 "topology did not start correctly"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700379
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700380 main.step( "Starting Mininet topology with OF 1.0 switches" )
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700381 args = "--switch ovs,protocols=OpenFlow10"
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700382 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700383 main.topology,
384 args=args )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700385 stepResult = topoResult
386 utilities.assert_equals( expect=main.TRUE,
387 actual=stepResult,
388 onpass="Successfully loaded topology",
389 onfail="Failed to load topology" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700390
391 # Set flag to test cases if topology did not load properly
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700392 if not topoResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700393 main.initialized = main.FALSE
394 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700395
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700396 def CASE11( self, main ):
397 """
kelvin-onlabb0b0dcb2015-07-22 16:51:33 -0700398 Start Mininet topology with OF 1.3 switches
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700399 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700400 if main.initialized == main.FALSE:
401 main.log.error( "Test components did not start correctly, skipping further tests" )
402 main.skipCase()
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700403 main.OFProtocol = "1.3"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700404 main.log.report( "Start Mininet topology with OF 1.3 switches" )
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700405 main.case( "Start Mininet topology with OF 1.3 switches" )
Jon Hall783bbf92015-07-23 14:33:19 -0700406 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700407 "switches to test intents, exits out if " +\
408 "topology did not start correctly"
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700409
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700410 main.step( "Starting Mininet topology with OF 1.3 switches" )
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700411 args = "--switch ovs,protocols=OpenFlow13"
412 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
413 main.topology,
414 args=args )
415 stepResult = topoResult
416 utilities.assert_equals( expect=main.TRUE,
417 actual=stepResult,
418 onpass="Successfully loaded topology",
419 onfail="Failed to load topology" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700420 # Set flag to skip test cases if topology did not load properly
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700421 if not topoResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700422 main.initialized = main.FALSE
kelvin-onlabb5cfab32015-07-22 16:38:22 -0700423
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700424 def CASE12( self, main ):
425 """
426 Assign mastership to controllers
427 """
428 import re
429
Jeremyd9e4eb12016-04-13 12:09:06 -0700430 if main.initialized == main.FALSE:
431 main.log.error( "Test components did not start correctly, skipping further tests" )
432 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700433 main.case( "Assign switches to controllers" )
434 main.step( "Assigning switches to controllers" )
Jon Hall783bbf92015-07-23 14:33:19 -0700435 main.caseExplanation = "Assign OF " + main.OFProtocol +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700436 " switches to ONOS nodes"
437
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700438 assignResult = main.TRUE
439 switchList = []
440
441 # Creates a list switch name, use getSwitch() function later...
442 for i in range( 1, ( main.numSwitch + 1 ) ):
443 switchList.append( 's' + str( i ) )
444
445 tempONOSip = []
446 for i in range( main.numCtrls ):
447 tempONOSip.append( main.ONOSip[ i ] )
448
449 assignResult = main.Mininet1.assignSwController( sw=switchList,
450 ip=tempONOSip,
Charles Chan029be652015-08-24 01:46:10 +0800451 port='6653' )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700452 if not assignResult:
Jeremyd9e4eb12016-04-13 12:09:06 -0700453 main.log.error( "Problem assigning mastership of switches" )
454 main.initialized = main.FALSE
455 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700456
457 for i in range( 1, ( main.numSwitch + 1 ) ):
458 response = main.Mininet1.getSwController( "s" + str( i ) )
459 print( "Response is " + str( response ) )
460 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
461 assignResult = assignResult and main.TRUE
462 else:
463 assignResult = main.FALSE
464 stepResult = assignResult
465 utilities.assert_equals( expect=main.TRUE,
466 actual=stepResult,
467 onpass="Successfully assigned switches" +
468 "to controller",
469 onfail="Failed to assign switches to " +
470 "controller" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700471 if not stepResult:
472 main.initialized = main.FALSE
acsmars5d8cc862015-09-25 09:44:50 -0700473
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800474 def CASE13( self,main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700475 """
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800476 Create Scapy components
477 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700478 if main.initialized == main.FALSE:
479 main.log.error( "Test components did not start correctly, skipping further tests" )
480 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800481 main.case( "Create scapy components" )
482 main.step( "Create scapy components" )
483 import json
484 scapyResult = main.TRUE
485 for hostName in main.scapyHostNames:
486 main.Scapy1.createHostComponent( hostName )
487 main.scapyHosts.append( getattr( main, hostName ) )
488
489 main.step( "Start scapy components" )
490 for host in main.scapyHosts:
491 host.startHostCli()
492 host.startScapy()
493 host.updateSelf()
494 main.log.debug( host.name )
495 main.log.debug( host.hostIp )
496 main.log.debug( host.hostMac )
497
498
499 utilities.assert_equals( expect=main.TRUE,
500 actual=scapyResult,
501 onpass="Successfully created Scapy Components",
502 onfail="Failed to discover Scapy Components" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700503 if not scapyResult:
504 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800505
506 def CASE14( self, main ):
507 """
508 Discover all hosts with fwd and pingall and store its data in a dictionary
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700509 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700510 if main.initialized == main.FALSE:
511 main.log.error( "Test components did not start correctly, skipping further tests" )
512 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700513 main.case( "Discover all hosts" )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800514 main.step( "Pingall hosts and confirm ONOS discovery" )
515 utilities.retry( f=main.intentFunction.fwdPingall, retValue=main.FALSE, args=[ main ] )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700516
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800517 utilities.retry( f=main.intentFunction.confirmHostDiscovery, retValue=main.FALSE,
518 args=[ main ], attempts=main.checkTopoAttempts, sleep=2 )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700519 utilities.assert_equals( expect=main.TRUE,
520 actual=stepResult,
521 onpass="Successfully discovered hosts",
522 onfail="Failed to discover hosts" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700523 if not stepResult:
524 main.initialized = main.FALSE
525 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700526
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800527 main.step( "Populate hostsData" )
528 stepResult = main.intentFunction.populateHostData( main )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700529 utilities.assert_equals( expect=main.TRUE,
530 actual=stepResult,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800531 onpass="Successfully populated hostsData",
532 onfail="Failed to populate hostsData" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700533 if not stepResult:
534 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800535
536 def CASE15( self, main ):
537 """
538 Discover all hosts with scapy arp packets and store its data to a dictionary
539 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700540 if main.initialized == main.FALSE:
541 main.log.error( "Test components did not start correctly, skipping further tests" )
542 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800543 main.case( "Discover all hosts using scapy" )
544 main.step( "Send packets from each host to the first host and confirm onos discovery" )
545
546 import collections
547 if len( main.scapyHosts ) < 1:
548 main.log.error( "No scapy hosts have been created" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700549 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800550 main.skipCase()
551
552 # Send ARP packets from each scapy host component
553 main.intentFunction.sendDiscoveryArp( main, main.scapyHosts )
554
555 stepResult = utilities.retry( f=main.intentFunction.confirmHostDiscovery,
556 retValue=main.FALSE, args=[ main ],
557 attempts=main.checkTopoAttempts, sleep=2 )
558
559 utilities.assert_equals( expect=main.TRUE,
560 actual=stepResult,
561 onpass="ONOS correctly discovered all hosts",
562 onfail="ONOS incorrectly discovered hosts" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700563 if not stepResult:
564 main.initialized = main.FALSE
565 main.skipCase()
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800566
567 main.step( "Populate hostsData" )
568 stepResult = main.intentFunction.populateHostData( main )
569 utilities.assert_equals( expect=main.TRUE,
570 actual=stepResult,
571 onpass="Successfully populated hostsData",
572 onfail="Failed to populate hostsData" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700573 if not stepResult:
574 main.initialized = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800575
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800576 def CASE16( self, main ):
577 """
Jeremy42df2e72016-02-23 16:37:46 -0800578 Balance Masters
579 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700580 if main.initialized == main.FALSE:
581 main.log.error( "Test components did not start correctly, skipping further tests" )
582 main.skipCase()
Jeremy42df2e72016-02-23 16:37:46 -0800583 main.case( "Balance mastership of switches" )
584 main.step( "Balancing mastership of switches" )
585
586 balanceResult = main.FALSE
587 balanceResult = utilities.retry( f=main.CLIs[ 0 ].balanceMasters, retValue=main.FALSE, args=[] )
588
589 utilities.assert_equals( expect=main.TRUE,
Jeremy6e9748f2016-03-25 15:03:39 -0700590 actual=balanceResult,
Jeremy42df2e72016-02-23 16:37:46 -0800591 onpass="Successfully balanced mastership of switches",
592 onfail="Failed to balance mastership of switches" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700593 if not balanceResult:
594 main.initialized = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800595
596 def CASE17( self, main ):
597 """
Jeremy6e9748f2016-03-25 15:03:39 -0700598 Use Flow Objectives
599 """
Jeremyd9e4eb12016-04-13 12:09:06 -0700600 if main.initialized == main.FALSE:
601 main.log.error( "Test components did not start correctly, skipping further tests" )
602 main.skipCase()
Jeremy6e9748f2016-03-25 15:03:39 -0700603 main.case( "Enable intent compilation using Flow Objectives" )
604 main.step( "Enabling Flow Objectives" )
605
606 main.flowCompiler = "Flow Objectives"
607
608 cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator"
609
610 stepResult = main.CLIs[ 0 ].setCfg( component=cmd,
611 propName="useFlowObjectives", value="true" )
612
613 utilities.assert_equals( expect=main.TRUE,
614 actual=stepResult,
615 onpass="Successfully activated Flow Objectives",
616 onfail="Failed to activate Flow Objectives" )
Jeremyd9e4eb12016-04-13 12:09:06 -0700617 if not balanceResult:
618 main.initialized = main.FALSE
Jeremy6e9748f2016-03-25 15:03:39 -0700619
620 def CASE18( self, main ):
621 """
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800622 Stop mininet and remove scapy host
623 """
624 main.log.report( "Stop Mininet and Scapy" )
625 main.case( "Stop Mininet and Scapy" )
626 main.caseExplanation = "Stopping the current mininet topology " +\
627 "to start up fresh"
628 main.step( "Stopping and Removing Scapy Host Components" )
629 scapyResult = main.TRUE
630 for host in main.scapyHosts:
631 scapyResult = scapyResult and host.stopScapy()
632 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
633
634 for host in main.scapyHosts:
635 scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
636 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
637
638 main.scapyHosts = []
639 main.scapyHostIPs = []
640
641 utilities.assert_equals( expect=main.TRUE,
642 actual=scapyResult,
643 onpass="Successfully stopped scapy and removed host components",
644 onfail="Failed to stop mininet and scapy" )
645
646 main.step( "Stopping Mininet Topology" )
647 mininetResult = main.Mininet1.stopNet( )
648
649 utilities.assert_equals( expect=main.TRUE,
650 actual=mininetResult,
651 onpass="Successfully stopped mininet and scapy",
652 onfail="Failed to stop mininet and scapy" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700653 # Exit if topology did not load properly
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800654 if not ( mininetResult and scapyResult ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700655 main.cleanup()
656 main.exit()
657
kelvin-onlabb769f562015-07-15 17:05:10 -0700658 def CASE1000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700659 """
660 Add host intents between 2 host:
661 - Discover hosts
662 - Add host intents
663 - Check intents
664 - Verify flows
665 - Ping hosts
666 - Reroute
667 - Link down
668 - Verify flows
669 - Check topology
670 - Ping hosts
671 - Link up
672 - Verify flows
673 - Check topology
674 - Ping hosts
675 - Remove intents
676 """
677 import time
678 import json
679 import re
Jeremyd9e4eb12016-04-13 12:09:06 -0700680 if main.initialized == main.FALSE:
681 main.log.error( "Test components did not start correctly, skipping further tests" )
682 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700683 # Assert variables - These variable's name|format must be followed
684 # if you want to use the wrapper function
685 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -0700686 try:
687 assert main.CLIs
688 except AssertionError:
689 main.log.error( "There is no main.CLIs, skipping test cases" )
690 main.initialized = main.FALSE
691 main.skipCase()
692 try:
693 assert main.Mininet1
694 except AssertionError:
695 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
696 main.initialized = main.FALSE
697 main.skipCase()
698 try:
699 assert main.numSwitch
700 except AssertionError:
701 main.log.error( "Place the total number of switch topology in \
702 main.numSwitch" )
703 main.initialized = main.FALSE
704 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700705
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800706 # Save leader candidates
acsmarse6b410f2015-07-17 14:39:34 -0700707 intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
708
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700709 main.testName = "Host Intents"
710 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -0700711 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -0700712 main.caseExplanation = "This test case tests Host intents using " +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700713 str( main.numCtrls ) + " node(s) cluster;\n" +\
714 "Different type of hosts will be tested in " +\
715 "each step such as IPV4, Dual stack, VLAN " +\
Jeremyeb51cb12016-03-28 17:53:35 -0700716 "etc;\nThe test will use OF " + main.OFProtocol +\
717 " OVS running in Mininet and compile intents" +\
Jeremy6e9748f2016-03-25 15:03:39 -0700718 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700719
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700720 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700721 main.assertReturnString = "Assertion Result for IPV4 host intent with mac addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800722 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
723 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
724 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800725 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800726 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700727 name='IPV4',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800728 onosNode='0',
729 host1=host1,
730 host2=host2)
731 if installResult:
732 testResult = main.intentFunction.testHostIntent( main,
733 name='IPV4',
734 intentId = installResult,
735 onosNode='0',
736 host1=host1,
737 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700738 sw1='s5',
739 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800740 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800741 else:
742 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800743
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700744 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800745 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700746 onpass=main.assertReturnString,
747 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700748
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700749 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700750 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800751 host1 = { "name":"h3","id":"00:00:00:00:00:03/-1" }
752 host2 = { "name":"h11","id":"00:00:00:00:00:0B/-1 "}
753 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800754 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800755 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700756 name='DUALSTACK',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800757 onosNode='0',
758 host1=host1,
759 host2=host2)
760
761 if installResult:
762 testResult = main.intentFunction.testHostIntent( main,
763 name='DUALSTACK',
764 intentId = installResult,
765 onosNode='0',
766 host1=host1,
767 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700768 sw1='s5',
769 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800770 expectedLink = 18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700771
772 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800773 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700774 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800775 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700776
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700777 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
acsmars5d8cc862015-09-25 09:44:50 -0700778 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800779 host1 = { "name":"h1" }
780 host2 = { "name":"h11" }
781 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800782 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800783 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700784 name='DUALSTACK2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800785 onosNode='0',
786 host1=host1,
787 host2=host2)
788
789 if installResult:
790 testResult = main.intentFunction.testHostIntent( main,
791 name='DUALSTACK2',
792 intentId = installResult,
793 onosNode='0',
794 host1=host1,
795 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700796 sw1='s5',
797 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800798 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800799 else:
800 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700801
802 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800803 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700804 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800805 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700806
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700807 main.step( "1HOP: Add host intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -0700808 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800809 host1 = { "name":"h1" }
810 host2 = { "name":"h3" }
811 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800812 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800813 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700814 name='1HOP',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800815 onosNode='0',
816 host1=host1,
817 host2=host2)
818
819 if installResult:
820 testResult = main.intentFunction.testHostIntent( main,
821 name='1HOP',
822 intentId = installResult,
823 onosNode='0',
824 host1=host1,
825 host2=host2,
826 sw1='s5',
827 sw2='s2',
828 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800829 else:
830 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700831
832 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800833 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700834 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800835 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700836
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700837 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
acsmars5d8cc862015-09-25 09:44:50 -0700838 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800839 host1 = { "name":"h4","id":"00:00:00:00:00:04/100" }
840 host2 = { "name":"h12","id":"00:00:00:00:00:0C/100 "}
841 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800842 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800843 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700844 name='VLAN1',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800845 onosNode='0',
846 host1=host1,
847 host2=host2)
848
849 if installResult:
850 testResult = main.intentFunction.testHostIntent( main,
851 name='VLAN1',
852 intentId = installResult,
853 onosNode='0',
854 host1=host1,
855 host2=host2,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700856 sw1='s5',
857 sw2='s2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800858 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800859 else:
860 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700861
862 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800863 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700864 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800865 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700866
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700867 main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
acsmars5d8cc862015-09-25 09:44:50 -0700868 main.assertReturnString = "Assertion Result different VLAN negative test\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800869 host1 = { "name":"h13" }
870 host2 = { "name":"h20" }
871 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800872 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800873 installResult = main.intentFunction.installHostIntent( main,
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700874 name='VLAN2',
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800875 onosNode='0',
876 host1=host1,
877 host2=host2)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700878
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800879 if installResult:
880 testResult = main.intentFunction.testHostIntent( main,
881 name='VLAN2',
882 intentId = installResult,
883 onosNode='0',
884 host1=host1,
885 host2=host2,
886 sw1='s5',
887 sw2='s2',
888 expectedLink = 18)
Jeremy42df2e72016-02-23 16:37:46 -0800889 else:
890 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800891
892 utilities.assert_equals( expect=main.TRUE,
893 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -0700894 onpass=main.assertReturnString,
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800895 onfail=main.assertReturnString)
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700896
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800897 main.step( "Confirm that ONOS leadership is unchanged")
acsmarse6b410f2015-07-17 14:39:34 -0700898 intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
899 main.intentFunction.checkLeaderChange( intentLeadersOld,
900 intentLeadersNew )
901
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800902 utilities.assert_equals( expect=main.TRUE,
903 actual=testResult,
904 onpass="ONOS Leaders Unchanged",
905 onfail="ONOS Leader Mismatch")
906
kelvin-onlab016dce22015-08-10 09:54:11 -0700907 main.intentFunction.report( main )
908
kelvin-onlabb769f562015-07-15 17:05:10 -0700909 def CASE2000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700910 """
911 Add point intents between 2 hosts:
912 - Get device ids | ports
913 - Add point intents
914 - Check intents
915 - Verify flows
916 - Ping hosts
917 - Reroute
918 - Link down
919 - Verify flows
920 - Check topology
921 - Ping hosts
922 - Link up
923 - Verify flows
924 - Check topology
925 - Ping hosts
926 - Remove intents
927 """
928 import time
929 import json
930 import re
Jeremyd9e4eb12016-04-13 12:09:06 -0700931 if main.initialized == main.FALSE:
932 main.log.error( "Test components did not start correctly, skipping further tests" )
933 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700934 # Assert variables - These variable's name|format must be followed
935 # if you want to use the wrapper function
936 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -0700937 try:
938 assert main.CLIs
939 except AssertionError:
940 main.log.error( "There is no main.CLIs, skipping test cases" )
941 main.initialized = main.FALSE
942 main.skipCase()
943 try:
944 assert main.Mininet1
945 except AssertionError:
946 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
947 main.initialized = main.FALSE
948 main.skipCase()
949 try:
950 assert main.numSwitch
951 except AssertionError:
952 main.log.error( "Place the total number of switch topology in \
953 main.numSwitch" )
954 main.initialized = main.FALSE
955 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700956
kelvin-onlab7bb2d972015-08-05 10:56:16 -0700957 main.testName = "Point Intents"
958 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -0700959 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -0700960 main.caseExplanation = "This test case will test point to point" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -0700961 " intents using " + str( main.numCtrls ) +\
962 " node(s) cluster;\n" +\
963 "Different type of hosts will be tested in " +\
964 "each step such as IPV4, Dual stack, VLAN etc" +\
965 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -0700966 " OVS running in Mininet and compile intents" +\
967 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700968
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700969 # No option point intents
970 main.step( "NOOPTION: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -0700971 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800972 senders = [
973 { "name":"h1","device":"of:0000000000000005/1" }
974 ]
975 recipients = [
976 { "name":"h9","device":"of:0000000000000006/1" }
977 ]
Jeremy42df2e72016-02-23 16:37:46 -0800978 testResult = main.FALSE
979 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800980 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700981 main,
982 name="NOOPTION",
Jeremy Songster1f39bf02016-01-20 17:17:25 -0800983 senders=senders,
984 recipients=recipients )
985
986 if installResult:
987 testResult = main.intentFunction.testPointIntent(
988 main,
989 intentId=installResult,
990 name="NOOPTION",
991 senders=senders,
992 recipients=recipients,
993 sw1="s5",
994 sw2="s2",
995 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -0800996 else:
997 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700998
kelvin-onlabd48a68c2015-07-13 16:01:36 -0700999 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001000 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001001 onpass=main.assertReturnString,
1002 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001003
1004 stepResult = main.TRUE
kelvin-onlabb769f562015-07-15 17:05:10 -07001005 main.step( "IPV4: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001006 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001007 senders = [
1008 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1009 ]
1010 recipients = [
1011 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09" }
1012 ]
Jeremy42df2e72016-02-23 16:37:46 -08001013 testResult = main.FALSE
1014 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001015 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001016 main,
1017 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001018 senders=senders,
1019 recipients=recipients,
1020 ethType="IPV4" )
1021
1022 if installResult:
1023 testResult = main.intentFunction.testPointIntent(
1024 main,
1025 intentId=installResult,
1026 name="IPV4",
1027 senders=senders,
1028 recipients=recipients,
1029 sw1="s5",
1030 sw2="s2",
1031 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001032 else:
1033 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001034
1035 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001036 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001037 onpass=main.assertReturnString,
1038 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001039 main.step( "IPV4_2: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001040 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001041 senders = [
1042 { "name":"h1","device":"of:0000000000000005/1" }
1043 ]
1044 recipients = [
1045 { "name":"h9","device":"of:0000000000000006/1" }
1046 ]
Jeremy42df2e72016-02-23 16:37:46 -08001047 testResult = main.FALSE
1048 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001049 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001050 main,
1051 name="IPV4_2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001052 senders=senders,
1053 recipients=recipients,
1054 ethType="IPV4" )
1055
1056 if installResult:
1057 testResult = main.intentFunction.testPointIntent(
1058 main,
1059 intentId=installResult,
1060 name="IPV4_2",
1061 senders=senders,
1062 recipients=recipients,
1063 sw1="s5",
1064 sw2="s2",
1065 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001066 else:
1067 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001068
1069 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001070 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001071 onpass=main.assertReturnString,
1072 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001073
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001074 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001075 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001076 senders = [
1077 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01",
Jeremy6f000c62016-02-25 17:02:28 -08001078 "ip":( main.h1.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001079 ]
1080 recipients = [
1081 { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09",
Jeremy6f000c62016-02-25 17:02:28 -08001082 "ip":( main.h9.hostIp + "/24" ) }
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001083 ]
Jeremy6f000c62016-02-25 17:02:28 -08001084 ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ]
kelvin-onlab79ce0492015-07-27 16:14:39 -07001085 # Uneccessary, not including this in the selectors
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001086 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
1087 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
Jeremy42df2e72016-02-23 16:37:46 -08001088 testResult = main.FALSE
1089 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001090 installResult = main.intentFunction.installPointIntent(
1091 main,
1092 name="SDNIP-ICMP",
1093 senders=senders,
1094 recipients=recipients,
1095 ethType="IPV4",
1096 ipProto=ipProto,
1097 tcpSrc=tcpSrc,
1098 tcpDst=tcpDst )
1099
1100 if installResult:
1101 testResult = main.intentFunction.testPointIntent(
1102 main,
1103 intentId=installResult,
1104 name="SDNIP_ICMP",
1105 senders=senders,
1106 recipients=recipients,
1107 sw1="s5",
1108 sw2="s2",
1109 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001110 else:
1111 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabb769f562015-07-15 17:05:10 -07001112
1113 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001114 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001115 onpass=main.assertReturnString,
1116 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001117
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001118 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001119 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
kelvin-onlabb769f562015-07-15 17:05:10 -07001120 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
1121 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
kelvin-onlab58dc39e2015-08-06 08:11:09 -07001122 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
1123 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
kelvin-onlabb769f562015-07-15 17:05:10 -07001124 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
1125 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
1126 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
1127
kelvin-onlab58dc39e2015-08-06 08:11:09 -07001128 stepResult = main.intentFunction.pointIntentTcp(
kelvin-onlabb769f562015-07-15 17:05:10 -07001129 main,
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001130 name="SDNIP-TCP",
kelvin-onlabb769f562015-07-15 17:05:10 -07001131 host1="h1",
1132 host2="h9",
1133 deviceId1="of:0000000000000005/1",
1134 deviceId2="of:0000000000000006/1",
1135 mac1=mac1,
1136 mac2=mac2,
1137 ethType="IPV4",
kelvin-onlabb55e58e2015-08-04 00:13:48 -07001138 ipProto=ipProto,
1139 ip1=ip1,
1140 ip2=ip2,
1141 tcp1=tcp1,
1142 tcp2=tcp2 )
kelvin-onlabb769f562015-07-15 17:05:10 -07001143
1144 utilities.assert_equals( expect=main.TRUE,
Jeremy6f000c62016-02-25 17:02:28 -08001145 actual=stepResult,
acsmars5d8cc862015-09-25 09:44:50 -07001146 onpass=main.assertReturnString,
1147 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001148
acsmars5d8cc862015-09-25 09:44:50 -07001149 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
1150 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001151 senders = [
1152 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1153 ]
1154 recipients = [
1155 { "name":"h11","device":"of:0000000000000006/3","mac":"00:00:00:00:00:0B" }
1156 ]
Jeremy42df2e72016-02-23 16:37:46 -08001157 testResult = main.FALSE
1158 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001159 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001160 main,
1161 name="DUALSTACK1",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001162 senders=senders,
1163 recipients=recipients,
1164 ethType="IPV4" )
1165
1166 if installResult:
1167 testResult = main.intentFunction.testPointIntent(
1168 main,
1169 intentId=installResult,
1170 name="DUALSTACK1",
1171 senders=senders,
1172 recipients=recipients,
1173 sw1="s5",
1174 sw2="s2",
1175 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001176 else:
1177 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001178
1179 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001180 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001181 onpass=main.assertReturnString,
1182 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001183
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001184 main.step( "VLAN: Add point intents between h5 and h21" )
acsmars5d8cc862015-09-25 09:44:50 -07001185 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001186 senders = [
1187 { "name":"h5","device":"of:0000000000000005/5","mac":"00:00:00:00:00:05" }
1188 ]
1189 recipients = [
1190 { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15" }
1191 ]
Jeremy42df2e72016-02-23 16:37:46 -08001192 testResult = main.FALSE
1193 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001194 installResult = main.intentFunction.installPointIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001195 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001196 name="DUALSTACK1",
1197 senders=senders,
1198 recipients=recipients,
1199 ethType="IPV4" )
1200
1201 if installResult:
1202 testResult = main.intentFunction.testPointIntent(
1203 main,
1204 intentId=installResult,
1205 name="DUALSTACK1",
1206 senders=senders,
1207 recipients=recipients,
1208 sw1="s5",
1209 sw2="s2",
1210 expectedLink=18)
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001211
1212 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001213 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001214 onpass=main.assertReturnString,
1215 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001216
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001217 main.step( "1HOP: Add point intents between h1 and h3" )
acsmars5d8cc862015-09-25 09:44:50 -07001218 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001219 senders = [
1220 { "name":"h1","device":"of:0000000000000005/1","mac":"00:00:00:00:00:01" }
1221 ]
1222 recipients = [
1223 { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
1224 ]
Jeremy42df2e72016-02-23 16:37:46 -08001225 testResult = main.FALSE
1226 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001227 installResult = main.intentFunction.installPointIntent(
1228 main,
1229 name="1HOP IPV4",
1230 senders=senders,
1231 recipients=recipients,
1232 ethType="IPV4" )
1233
1234 if installResult:
1235 testResult = main.intentFunction.testPointIntent(
1236 main,
1237 intentId=installResult,
1238 name="1HOP IPV4",
1239 senders=senders,
1240 recipients=recipients,
1241 sw1="s5",
1242 sw2="s2",
1243 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001244 else:
1245 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001246
1247 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001248 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001249 onpass=main.assertReturnString,
1250 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001251
kelvin-onlab016dce22015-08-10 09:54:11 -07001252 main.intentFunction.report( main )
1253
kelvin-onlabb769f562015-07-15 17:05:10 -07001254 def CASE3000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001255 """
1256 Add single point to multi point intents
1257 - Get device ids
1258 - Add single point to multi point intents
1259 - Check intents
1260 - Verify flows
1261 - Ping hosts
1262 - Reroute
1263 - Link down
1264 - Verify flows
1265 - Check topology
1266 - Ping hosts
1267 - Link up
1268 - Verify flows
1269 - Check topology
1270 - Ping hosts
1271 - Remove intents
1272 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001273 if main.initialized == main.FALSE:
1274 main.log.error( "Test components did not start correctly, skipping further tests" )
1275 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001276 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001277 try:
1278 assert main.CLIs
1279 except AssertionError:
1280 main.log.error( "There is no main.CLIs, skipping test cases" )
1281 main.initialized = main.FALSE
1282 main.skipCase()
1283 try:
1284 assert main.Mininet1
1285 except AssertionError:
1286 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1287 main.initialized = main.FALSE
1288 main.skipCase()
1289 try:
1290 assert main.numSwitch
1291 except AssertionError:
1292 main.log.error( "Place the total number of switch topology in \
1293 main.numSwitch" )
1294 main.initialized = main.FALSE
1295 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001296
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001297 main.testName = "Single to Multi Point Intents"
1298 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001299 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001300 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001301 " multi point intents using " +\
1302 str( main.numCtrls ) + " node(s) cluster;\n" +\
1303 "Different type of hosts will be tested in " +\
1304 "each step such as IPV4, Dual stack, VLAN etc" +\
1305 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001306 " OVS running in Mininet and compile intents" +\
1307 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001308
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001309 main.step( "NOOPTION: Install and test single point to multi point intents" )
1310 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
1311 senders = [
1312 { "name":"h8", "device":"of:0000000000000005/8" }
1313 ]
1314 recipients = [
1315 { "name":"h16", "device":"of:0000000000000006/8" },
1316 { "name":"h24", "device":"of:0000000000000007/8" }
1317 ]
1318 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1319 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1320 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001321 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001322 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001323 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001324 name="NOOPTION",
1325 senders=senders,
1326 recipients=recipients,
1327 sw1="s5",
1328 sw2="s2")
1329
1330 if installResult:
1331 testResult = main.intentFunction.testPointIntent(
1332 main,
1333 intentId=installResult,
1334 name="NOOPTION",
1335 senders=senders,
1336 recipients=recipients,
1337 badSenders=badSenders,
1338 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001339 sw1="s5",
1340 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001341 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001342 else:
1343 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001344
1345 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001346 actual=testResult,
1347 onpass=main.assertReturnString,
1348 onfail=main.assertReturnString )
1349
1350 main.step( "IPV4: Install and test single point to multi point intents" )
1351 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type and MAC addresses\n"
1352 senders = [
1353 { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" }
1354 ]
1355 recipients = [
1356 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1357 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1358 ]
1359 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1360 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1361 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001362 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001363 installResult = main.intentFunction.installSingleToMultiIntent(
1364 main,
1365 name="IPV4",
1366 senders=senders,
1367 recipients=recipients,
1368 ethType="IPV4",
1369 sw1="s5",
1370 sw2="s2")
1371
1372 if installResult:
1373 testResult = main.intentFunction.testPointIntent(
1374 main,
1375 intentId=installResult,
1376 name="IPV4",
1377 senders=senders,
1378 recipients=recipients,
1379 badSenders=badSenders,
1380 badRecipients=badRecipients,
1381 sw1="s5",
1382 sw2="s2",
1383 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001384 else:
1385 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001386
1387 utilities.assert_equals( expect=main.TRUE,
1388 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001389 onpass=main.assertReturnString,
1390 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001391
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001392 main.step( "IPV4_2: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001393 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 -08001394 senders = [
1395 { "name":"h8", "device":"of:0000000000000005/8" }
1396 ]
1397 recipients = [
1398 { "name":"h16", "device":"of:0000000000000006/8" },
1399 { "name":"h24", "device":"of:0000000000000007/8" }
1400 ]
1401 badSenders=[ { "name":"h9" } ] # Senders that are not in the intent
1402 badRecipients=[ { "name":"h17" } ] # Recipients that are not in the intent
1403 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001404 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001405 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001406 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001407 name="IPV4_2",
1408 senders=senders,
1409 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001410 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001411 sw1="s5",
1412 sw2="s2")
1413
1414 if installResult:
1415 testResult = main.intentFunction.testPointIntent(
1416 main,
1417 intentId=installResult,
1418 name="IPV4_2",
1419 senders=senders,
1420 recipients=recipients,
1421 badSenders=badSenders,
1422 badRecipients=badRecipients,
1423 sw1="s5",
1424 sw2="s2",
1425 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001426 else:
1427 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001428
1429 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001430 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001431 onpass=main.assertReturnString,
1432 onfail=main.assertReturnString )
kelvin-onlabb769f562015-07-15 17:05:10 -07001433
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001434 main.step( "VLAN: Add single point to multi point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001435 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 -08001436 senders = [
1437 { "name":"h4", "device":"of:0000000000000005/4", "mac":"00:00:00:00:00:04" }
1438 ]
1439 recipients = [
1440 { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C" },
1441 { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14" }
1442 ]
1443 badSenders=[ { "name":"h13" } ] # Senders that are not in the intent
1444 badRecipients=[ { "name":"h21" } ] # Recipients that are not in the intent
1445 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001446 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001447 installResult = main.intentFunction.installSingleToMultiIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001448 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001449 name="IPV4",
1450 senders=senders,
1451 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001452 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001453 sw1="s5",
1454 sw2="s2")
1455
1456 if installResult:
1457 testResult = main.intentFunction.testPointIntent(
1458 main,
1459 intentId=installResult,
1460 name="IPV4",
1461 senders=senders,
1462 recipients=recipients,
1463 badSenders=badSenders,
1464 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001465 sw1="s5",
1466 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001467 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001468 else:
1469 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001470
1471 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001472 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001473 onpass=main.assertReturnString,
1474 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001475
kelvin-onlab016dce22015-08-10 09:54:11 -07001476 main.intentFunction.report( main )
1477
kelvin-onlabb769f562015-07-15 17:05:10 -07001478 def CASE4000( self, main ):
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001479 """
1480 Add multi point to single point intents
1481 - Get device ids
1482 - Add multi point to single point intents
1483 - Check intents
1484 - Verify flows
1485 - Ping hosts
1486 - Reroute
1487 - Link down
1488 - Verify flows
1489 - Check topology
1490 - Ping hosts
1491 - Link up
1492 - Verify flows
1493 - Check topology
1494 - Ping hosts
1495 - Remove intents
1496 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001497 if main.initialized == main.FALSE:
1498 main.log.error( "Test components did not start correctly, skipping further tests" )
1499 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001500 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001501 try:
1502 assert main.CLIs
1503 except AssertionError:
1504 main.log.error( "There is no main.CLIs, skipping test cases" )
1505 main.initialized = main.FALSE
1506 main.skipCase()
1507 try:
1508 assert main.Mininet1
1509 except AssertionError:
1510 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1511 main.initialized = main.FALSE
1512 main.skipCase()
1513 try:
1514 assert main.numSwitch
1515 except AssertionError:
1516 main.log.error( "Place the total number of switch topology in \
1517 main.numSwitch" )
1518 main.initialized = main.FALSE
1519 main.skipCase()
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001520
kelvin-onlab7bb2d972015-08-05 10:56:16 -07001521 main.testName = "Multi To Single Point Intents"
1522 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jeremy6e9748f2016-03-25 15:03:39 -07001523 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Jon Hall783bbf92015-07-23 14:33:19 -07001524 main.caseExplanation = "This test case will test single point to" +\
kelvin-onlab6dea6e62015-07-23 13:07:26 -07001525 " multi point intents using " +\
1526 str( main.numCtrls ) + " node(s) cluster;\n" +\
1527 "Different type of hosts will be tested in " +\
1528 "each step such as IPV4, Dual stack, VLAN etc" +\
1529 ";\nThe test will use OF " + main.OFProtocol +\
Jeremy6e9748f2016-03-25 15:03:39 -07001530 " OVS running in Mininet and compile intents" +\
1531 " using " + main.flowCompiler
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001532
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001533 main.step( "NOOPTION: Add multi point to single point intents" )
1534 main.assertReturnString = "Assertion results for NOOPTION multi to single point intent\n"
1535 senders = [
1536 { "name":"h16", "device":"of:0000000000000006/8" },
1537 { "name":"h24", "device":"of:0000000000000007/8" }
1538 ]
1539 recipients = [
1540 { "name":"h8", "device":"of:0000000000000005/8" }
1541 ]
1542 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1543 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1544 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001545 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001546 installResult = main.intentFunction.installMultiToSingleIntent(
1547 main,
1548 name="NOOPTION",
1549 senders=senders,
1550 recipients=recipients,
1551 sw1="s5",
Jeremye0cb5eb2016-01-27 17:39:09 -08001552 sw2="s2" )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001553
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001554 if installResult:
1555 testResult = main.intentFunction.testPointIntent(
1556 main,
1557 intentId=installResult,
1558 name="NOOPTION",
1559 senders=senders,
1560 recipients=recipients,
1561 badSenders=badSenders,
1562 badRecipients=badRecipients,
1563 sw1="s5",
1564 sw2="s2",
Jeremye0cb5eb2016-01-27 17:39:09 -08001565 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001566 else:
1567 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001568
1569 utilities.assert_equals( expect=main.TRUE,
1570 actual=testResult,
1571 onpass=main.assertReturnString,
1572 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001573
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001574 main.step( "IPV4: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001575 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 -08001576 senders = [
1577 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1578 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1579 ]
1580 recipients = [
1581 { "name":"h8", "device":"of:0000000000000005/8", "mac":"00:00:00:00:00:08" }
1582 ]
1583 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1584 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1585 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001586 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001587 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001588 main,
1589 name="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001590 senders=senders,
1591 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001592 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001593 sw1="s5",
1594 sw2="s2")
1595
1596 if installResult:
1597 testResult = main.intentFunction.testPointIntent(
1598 main,
1599 intentId=installResult,
1600 name="IPV4",
1601 senders=senders,
1602 recipients=recipients,
1603 badSenders=badSenders,
1604 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001605 sw1="s5",
1606 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001607 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001608 else:
1609 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001610
1611 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001612 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001613 onpass=main.assertReturnString,
1614 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001615
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001616 main.step( "IPV4_2: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001617 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 -08001618 senders = [
1619 { "name":"h16", "device":"of:0000000000000006/8" },
1620 { "name":"h24", "device":"of:0000000000000007/8" }
1621 ]
1622 recipients = [
1623 { "name":"h8", "device":"of:0000000000000005/8" }
1624 ]
1625 badSenders=[ { "name":"h17" } ] # Senders that are not in the intent
1626 badRecipients=[ { "name":"h9" } ] # Recipients that are not in the intent
1627 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001628 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001629 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001630 main,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001631 name="IPV4_2",
1632 senders=senders,
1633 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001634 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001635 sw1="s5",
1636 sw2="s2")
1637
1638 if installResult:
1639 testResult = main.intentFunction.testPointIntent(
1640 main,
1641 intentId=installResult,
1642 name="IPV4_2",
1643 senders=senders,
1644 recipients=recipients,
1645 badSenders=badSenders,
1646 badRecipients=badRecipients,
1647 sw1="s5",
1648 sw2="s2",
1649 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001650 else:
1651 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001652
1653 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001654 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001655 onpass=main.assertReturnString,
1656 onfail=main.assertReturnString )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001657
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001658 main.step( "VLAN: Add multi point to single point intents" )
acsmars5d8cc862015-09-25 09:44:50 -07001659 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 -08001660 senders = [
1661 { "name":"h13", "device":"of:0000000000000006/5" },
1662 { "name":"h21", "device":"of:0000000000000007/5" }
1663 ]
1664 recipients = [
1665 { "name":"h5", "device":"of:0000000000000005/5" }
1666 ]
1667 badSenders=[ { "name":"h12" } ] # Senders that are not in the intent
1668 badRecipients=[ { "name":"h20" } ] # Recipients that are not in the intent
1669 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001670 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001671 installResult = main.intentFunction.installMultiToSingleIntent(
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001672 main,
1673 name="VLAN",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001674 senders=senders,
1675 recipients=recipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001676 ethType="IPV4",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001677 sw1="s5",
1678 sw2="s2")
1679
1680 if installResult:
1681 testResult = main.intentFunction.testPointIntent(
1682 main,
1683 intentId=installResult,
1684 name="VLAN",
1685 senders=senders,
1686 recipients=recipients,
1687 badSenders=badSenders,
1688 badRecipients=badRecipients,
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001689 sw1="s5",
1690 sw2="s2",
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001691 expectedLink=18)
Jeremy42df2e72016-02-23 16:37:46 -08001692 else:
1693 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabd48a68c2015-07-13 16:01:36 -07001694
1695 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001696 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001697 onpass=main.assertReturnString,
1698 onfail=main.assertReturnString )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001699
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001700 main.intentFunction.report( main )
1701
acsmars1ff5e052015-07-23 11:27:48 -07001702 def CASE5000( self, main ):
1703 """
acsmars5d8cc862015-09-25 09:44:50 -07001704 Tests Host Mobility
1705 Modifies the topology location of h1
acsmars1ff5e052015-07-23 11:27:48 -07001706 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001707 if main.initialized == main.FALSE:
1708 main.log.error( "Test components did not start correctly, skipping further tests" )
1709 main.skipCase()
acsmars1ff5e052015-07-23 11:27:48 -07001710 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001711 try:
1712 assert main.CLIs
1713 except AssertionError:
1714 main.log.error( "There is no main.CLIs, skipping test cases" )
1715 main.initialized = main.FALSE
1716 main.skipCase()
1717 try:
1718 assert main.Mininet1
1719 except AssertionError:
1720 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1721 main.initialized = main.FALSE
1722 main.skipCase()
1723 try:
1724 assert main.numSwitch
1725 except AssertionError:
1726 main.log.error( "Place the total number of switch topology in \
1727 main.numSwitch" )
1728 main.initialized = main.FALSE
1729 main.skipCase()
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001730 main.case( "Test host mobility with host intents " )
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001731 main.step( "Testing host mobility by moving h1 from s5 to s6" )
acsmars1ff5e052015-07-23 11:27:48 -07001732 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1733
Jeremy2f190ca2016-01-29 15:23:57 -08001734 main.log.info( "Moving h1 from s5 to s6")
acsmars1ff5e052015-07-23 11:27:48 -07001735 main.Mininet1.moveHost( "h1","s5","s6" )
1736
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001737 # Send discovery ping from moved host
1738 # Moving the host brings down the default interfaces and creates a new one.
1739 # Scapy is restarted on this host to detect the new interface
1740 main.h1.stopScapy()
1741 main.h1.startScapy()
1742
1743 # Discover new host location in ONOS and populate host data.
1744 # Host 1 IP and MAC should be unchanged
1745 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
1746 main.intentFunction.populateHostData( main )
1747
acsmars1ff5e052015-07-23 11:27:48 -07001748 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1749
1750 utilities.assert_equals( expect="of:0000000000000006",
1751 actual=h1PostMove,
1752 onpass="Mobility: Successfully moved h1 to s6",
acsmars5d8cc862015-09-25 09:44:50 -07001753 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001754 " to single point intents" +
1755 " with IPV4 type and MAC addresses" +
1756 " in the same VLAN" )
1757
1758 main.step( "IPV4: Add host intents between h1 and h9" )
acsmars5d8cc862015-09-25 09:44:50 -07001759 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001760 host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
1761 host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
Jeremy42df2e72016-02-23 16:37:46 -08001762 testResult = main.FALSE
1763 installResult = main.FALSE
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001764 installResult = main.intentFunction.installHostIntent( main,
1765 name='IPV4 Mobility IPV4',
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001766 onosNode='0',
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001767 host1=host1,
Jeremye0cb5eb2016-01-27 17:39:09 -08001768 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -08001769 if installResult:
1770 testResult = main.intentFunction.testHostIntent( main,
1771 name='Host Mobility IPV4',
1772 intentId = installResult,
1773 onosNode='0',
1774 host1=host1,
1775 host2=host2,
1776 sw1="s6",
1777 sw2="s2",
1778 expectedLink=18 )
Jeremy42df2e72016-02-23 16:37:46 -08001779 else:
1780 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlabf34a58a2015-07-23 16:41:52 -07001781
1782 utilities.assert_equals( expect=main.TRUE,
Jeremy Songster1f39bf02016-01-20 17:17:25 -08001783 actual=testResult,
acsmars5d8cc862015-09-25 09:44:50 -07001784 onpass=main.assertReturnString,
1785 onfail=main.assertReturnString )
kelvin-onlab016dce22015-08-10 09:54:11 -07001786
1787 main.intentFunction.report( main )
Jeremye0cb5eb2016-01-27 17:39:09 -08001788
1789 def CASE6000( self, main ):
1790 """
1791 Tests Multi to Single Point Intent and Single to Multi Point Intent End Point Failure
1792 """
Jeremyd9e4eb12016-04-13 12:09:06 -07001793 if main.initialized == main.FALSE:
1794 main.log.error( "Test components did not start correctly, skipping further tests" )
1795 main.skipCase()
Jeremye0cb5eb2016-01-27 17:39:09 -08001796 assert main, "There is no main"
Jeremyd9e4eb12016-04-13 12:09:06 -07001797 try:
1798 assert main.CLIs
1799 except AssertionError:
1800 main.log.error( "There is no main.CLIs, skipping test cases" )
1801 main.initialized = main.FALSE
1802 main.skipCase()
1803 try:
1804 assert main.Mininet1
1805 except AssertionError:
1806 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1807 main.initialized = main.FALSE
1808 main.skipCase()
1809 try:
1810 assert main.numSwitch
1811 except AssertionError:
1812 main.log.error( "Place the total number of switch topology in \
1813 main.numSwitch" )
1814 main.initialized = main.FALSE
1815 main.skipCase()
Jeremye0cb5eb2016-01-27 17:39:09 -08001816 main.case( "Test Multi to Single End Point Failure" )
1817 main.step( "Installing Multi to Single Point intents" )
1818
1819 main.assertReturnString = "Assertion results for IPV4 multi to single \
1820 point intent end point failure with no options set\n"
1821 senders = [
1822 { "name":"h16", "device":"of:0000000000000006/8" },
1823 { "name":"h24", "device":"of:0000000000000007/8" }
1824 ]
1825 recipients = [
1826 { "name":"h8", "device":"of:0000000000000005/8" }
1827 ]
1828 isolatedSenders = [
1829 { "name":"h24"}
1830 ]
1831 isolatedRecipients = []
1832 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001833 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08001834 installResult = main.intentFunction.installMultiToSingleIntent(
1835 main,
1836 name="NOOPTION",
1837 senders=senders,
1838 recipients=recipients,
1839 sw1="s5",
1840 sw2="s2" )
1841
1842 if installResult:
1843 testResult = main.intentFunction.testEndPointFail(
1844 main,
1845 intentId=installResult,
1846 name="NOOPTION",
1847 senders=senders,
1848 recipients=recipients,
1849 isolatedSenders=isolatedSenders,
1850 isolatedRecipients=isolatedRecipients,
1851 sw1="s6",
1852 sw2="s2",
1853 sw3="s4",
1854 sw4="s1",
1855 sw5="s3",
1856 expectedLink1=16,
1857 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08001858 else:
1859 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08001860
1861 utilities.assert_equals( expect=main.TRUE,
1862 actual=testResult,
1863 onpass=main.assertReturnString,
1864 onfail=main.assertReturnString )
1865
1866 main.step( "IPV4: Add multi point to single point intents" )
1867 main.assertReturnString = "Assertion results for IPV4 multi to single \
1868 point intent end point failure with IPV4 type and MAC addresses\n"
1869 senders = [
1870 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
1871 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
1872 ]
1873 recipients = [
1874 { "name":"h8", "device":"of:0000000000000005/8", "mac":"00:00:00:00:00:08" }
1875 ]
1876 isolatedSenders = [
1877 { "name":"h24"}
1878 ]
1879 isolatedRecipients = []
1880 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001881 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08001882 installResult = main.intentFunction.installMultiToSingleIntent(
1883 main,
1884 name="IPV4",
1885 senders=senders,
1886 recipients=recipients,
1887 ethType="IPV4",
1888 sw1="s5",
1889 sw2="s2")
1890
1891 if installResult:
1892 testResult = main.intentFunction.testEndPointFail(
1893 main,
1894 intentId=installResult,
1895 name="IPV4",
1896 senders=senders,
1897 recipients=recipients,
1898 isolatedSenders=isolatedSenders,
1899 isolatedRecipients=isolatedRecipients,
1900 sw1="s6",
1901 sw2="s2",
1902 sw3="s4",
1903 sw4="s1",
1904 sw5="s3",
1905 expectedLink1=16,
1906 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08001907 else:
1908 main.CLIs[ 0 ].removeAllIntents( purge=True )
1909
Jeremye0cb5eb2016-01-27 17:39:09 -08001910 utilities.assert_equals( expect=main.TRUE,
1911 actual=testResult,
1912 onpass=main.assertReturnString,
1913 onfail=main.assertReturnString )
1914
1915 main.step( "IPV4_2: Add multi point to single point intents" )
1916 main.assertReturnString = "Assertion results for IPV4 multi to single \
1917 point intent end point failure with IPV4 type and no MAC addresses\n"
1918 senders = [
1919 { "name":"h16", "device":"of:0000000000000006/8" },
1920 { "name":"h24", "device":"of:0000000000000007/8" }
1921 ]
1922 recipients = [
1923 { "name":"h8", "device":"of:0000000000000005/8" }
1924 ]
1925 isolatedSenders = [
1926 { "name":"h24"}
1927 ]
1928 isolatedRecipients = []
1929 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001930 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08001931 installResult = main.intentFunction.installMultiToSingleIntent(
1932 main,
1933 name="IPV4_2",
1934 senders=senders,
1935 recipients=recipients,
1936 ethType="IPV4",
1937 sw1="s5",
1938 sw2="s2")
1939
1940 if installResult:
1941 testResult = main.intentFunction.testEndPointFail(
1942 main,
1943 intentId=installResult,
1944 name="IPV4_2",
1945 senders=senders,
1946 recipients=recipients,
1947 isolatedSenders=isolatedSenders,
1948 isolatedRecipients=isolatedRecipients,
1949 sw1="s6",
1950 sw2="s2",
1951 sw3="s4",
1952 sw4="s1",
1953 sw5="s3",
1954 expectedLink1=16,
1955 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08001956 else:
1957 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08001958
1959 utilities.assert_equals( expect=main.TRUE,
1960 actual=testResult,
1961 onpass=main.assertReturnString,
1962 onfail=main.assertReturnString )
1963
1964 main.step( "VLAN: Add multi point to single point intents" )
1965 main.assertReturnString = "Assertion results for IPV4 multi to single \
1966 point intent end point failure with IPV4 type and no MAC addresses in the same VLAN\n"
1967 senders = [
1968 { "name":"h13", "device":"of:0000000000000006/5" },
1969 { "name":"h21", "device":"of:0000000000000007/5" }
1970 ]
1971 recipients = [
1972 { "name":"h5", "device":"of:0000000000000005/5" }
1973 ]
1974 isolatedSenders = [
1975 { "name":"h21"}
1976 ]
1977 isolatedRecipients = []
1978 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08001979 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08001980 installResult = main.intentFunction.installMultiToSingleIntent(
1981 main,
1982 name="VLAN",
1983 senders=senders,
1984 recipients=recipients,
1985 ethType="IPV4",
1986 sw1="s5",
1987 sw2="s2")
1988
1989 if installResult:
1990 testResult = main.intentFunction.testEndPointFail(
1991 main,
1992 intentId=installResult,
1993 name="VLAN",
1994 senders=senders,
1995 recipients=recipients,
1996 isolatedSenders=isolatedSenders,
1997 isolatedRecipients=isolatedRecipients,
1998 sw1="s6",
1999 sw2="s2",
2000 sw3="s4",
2001 sw4="s1",
2002 sw5="s3",
2003 expectedLink1=16,
2004 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002005 else:
2006 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002007
2008 utilities.assert_equals( expect=main.TRUE,
2009 actual=testResult,
2010 onpass=main.assertReturnString,
2011 onfail=main.assertReturnString )
2012
2013 main.step( "NOOPTION: Install and test single point to multi point intents" )
2014 main.assertReturnString = "Assertion results for IPV4 single to multi \
2015 point intent end point failure with no options set\n"
2016 senders = [
2017 { "name":"h8", "device":"of:0000000000000005/8" }
2018 ]
2019 recipients = [
2020 { "name":"h16", "device":"of:0000000000000006/8" },
2021 { "name":"h24", "device":"of:0000000000000007/8" }
2022 ]
2023 isolatedSenders = []
2024 isolatedRecipients = [
2025 { "name":"h24" }
2026 ]
2027 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08002028 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08002029 installResult = main.intentFunction.installSingleToMultiIntent(
2030 main,
2031 name="NOOPTION",
2032 senders=senders,
2033 recipients=recipients,
2034 sw1="s5",
2035 sw2="s2")
2036
2037 if installResult:
2038 testResult = main.intentFunction.testEndPointFail(
2039 main,
2040 intentId=installResult,
2041 name="NOOPTION",
2042 senders=senders,
2043 recipients=recipients,
2044 isolatedSenders=isolatedSenders,
2045 isolatedRecipients=isolatedRecipients,
2046 sw1="s6",
2047 sw2="s2",
2048 sw3="s4",
2049 sw4="s1",
2050 sw5="s3",
2051 expectedLink1=16,
2052 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002053 else:
2054 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002055
2056 utilities.assert_equals( expect=main.TRUE,
2057 actual=testResult,
2058 onpass=main.assertReturnString,
2059 onfail=main.assertReturnString )
2060
2061 main.step( "IPV4: Install and test single point to multi point intents" )
2062 main.assertReturnString = "Assertion results for IPV4 single to multi \
2063 point intent end point failure with IPV4 type and no MAC addresses\n"
2064 senders = [
2065 { "name":"h8", "device":"of:0000000000000005/8","mac":"00:00:00:00:00:08" }
2066 ]
2067 recipients = [
2068 { "name":"h16", "device":"of:0000000000000006/8", "mac":"00:00:00:00:00:10" },
2069 { "name":"h24", "device":"of:0000000000000007/8", "mac":"00:00:00:00:00:18" }
2070 ]
2071 isolatedSenders = []
2072 isolatedRecipients = [
2073 { "name":"h24" }
2074 ]
2075 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08002076 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08002077 installResult = main.intentFunction.installSingleToMultiIntent(
2078 main,
2079 name="IPV4",
2080 senders=senders,
2081 recipients=recipients,
2082 ethType="IPV4",
2083 sw1="s5",
2084 sw2="s2")
2085
2086 if installResult:
2087 testResult = main.intentFunction.testEndPointFail(
2088 main,
2089 intentId=installResult,
2090 name="IPV4",
2091 senders=senders,
2092 recipients=recipients,
2093 isolatedSenders=isolatedSenders,
2094 isolatedRecipients=isolatedRecipients,
2095 sw1="s6",
2096 sw2="s2",
2097 sw3="s4",
2098 sw4="s1",
2099 sw5="s3",
2100 expectedLink1=16,
2101 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002102 else:
2103 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002104
2105 utilities.assert_equals( expect=main.TRUE,
2106 actual=testResult,
2107 onpass=main.assertReturnString,
2108 onfail=main.assertReturnString )
2109
2110 main.step( "IPV4_2: Add single point to multi point intents" )
2111 main.assertReturnString = "Assertion results for IPV4 single to multi\
2112 point intent endpoint failure with IPV4 type and no MAC addresses\n"
2113 senders = [
2114 { "name":"h8", "device":"of:0000000000000005/8" }
2115 ]
2116 recipients = [
2117 { "name":"h16", "device":"of:0000000000000006/8" },
2118 { "name":"h24", "device":"of:0000000000000007/8" }
2119 ]
2120 isolatedSenders = []
2121 isolatedRecipients = [
2122 { "name":"h24" }
2123 ]
2124 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08002125 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08002126 installResult = main.intentFunction.installSingleToMultiIntent(
2127 main,
2128 name="IPV4_2",
2129 senders=senders,
2130 recipients=recipients,
2131 ethType="IPV4",
2132 sw1="s5",
2133 sw2="s2")
2134
2135 if installResult:
2136 testResult = main.intentFunction.testEndPointFail(
2137 main,
2138 intentId=installResult,
2139 name="IPV4_2",
2140 senders=senders,
2141 recipients=recipients,
2142 isolatedSenders=isolatedSenders,
2143 isolatedRecipients=isolatedRecipients,
2144 sw1="s6",
2145 sw2="s2",
2146 sw3="s4",
2147 sw4="s1",
2148 sw5="s3",
2149 expectedLink1=16,
2150 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002151 else:
2152 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002153
2154 utilities.assert_equals( expect=main.TRUE,
2155 actual=testResult,
2156 onpass=main.assertReturnString,
2157 onfail=main.assertReturnString )
2158
2159 main.step( "VLAN: Add single point to multi point intents" )
2160 main.assertReturnString = "Assertion results for IPV4 single to multi point\
2161 intent endpoint failure with IPV4 type and MAC addresses in the same VLAN\n"
2162 senders = [
2163 { "name":"h4", "device":"of:0000000000000005/4", "mac":"00:00:00:00:00:04" }
2164 ]
2165 recipients = [
2166 { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C" },
2167 { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14" }
2168 ]
2169 isolatedSenders = []
2170 isolatedRecipients = [
2171 { "name":"h20" }
2172 ]
2173 testResult = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -08002174 installResult = main.FALSE
Jeremye0cb5eb2016-01-27 17:39:09 -08002175 installResult = main.intentFunction.installSingleToMultiIntent(
2176 main,
2177 name="IPV4",
2178 senders=senders,
2179 recipients=recipients,
2180 ethType="IPV4",
2181 sw1="s5",
2182 sw2="s2")
2183
2184 if installResult:
2185 testResult = main.intentFunction.testEndPointFail(
2186 main,
2187 intentId=installResult,
2188 name="IPV4",
2189 senders=senders,
2190 recipients=recipients,
2191 isolatedSenders=isolatedSenders,
2192 isolatedRecipients=isolatedRecipients,
2193 sw1="s6",
2194 sw2="s2",
2195 sw3="s4",
2196 sw4="s1",
2197 sw5="s3",
2198 expectedLink1=16,
2199 expectedLink2=14 )
Jeremy42df2e72016-02-23 16:37:46 -08002200 else:
2201 main.CLIs[ 0 ].removeAllIntents( purge=True )
Jeremye0cb5eb2016-01-27 17:39:09 -08002202
2203 utilities.assert_equals( expect=main.TRUE,
2204 actual=testResult,
2205 onpass=main.assertReturnString,
2206 onfail=main.assertReturnString )
2207
Jeremy2f190ca2016-01-29 15:23:57 -08002208 main.intentFunction.report( main )