blob: 8ea8d0dbe0fee5823f7506e25af183c54dd07a50 [file] [log] [blame]
kelvin-onlab44147802015-07-27 17:57:31 -07001
2# Testing the basic intent functionality of ONOS
Jeremy2f190ca2016-01-29 15:23:57 -08003# TODO: Replace the CLI calls with REST API equivalents as they become available.
4# - May need to write functions in the onosrestdriver.py file to do this
5# TODO: Complete implementation of case 3000, 4000, and 6000 as REST API allows
6# -Currently there is no support in the REST API for Multi to Single and Single to Multi point intents
7# As such, these cases are incomplete and should not be enabled in the .params file
kelvin-onlab44147802015-07-27 17:57:31 -07008
9import time
10import json
11
Jon Hall02758ac2017-05-24 16:20:28 -070012
kelvin-onlab44147802015-07-27 17:57:31 -070013class FUNCintentRest:
14
15 def __init__( self ):
16 self.default = ''
17
18 def CASE1( self, main ):
19 import time
kelvin-onlab44147802015-07-27 17:57:31 -070020 import imp
Jon Hallf7234882015-08-28 13:16:31 -070021 import re
kelvin-onlab44147802015-07-27 17:57:31 -070022
23 """
24 - Construct tests variables
25 - GIT ( optional )
26 - Checkout ONOS master branch
27 - Pull latest ONOS code
28 - Building ONOS ( optional )
29 - Install ONOS package
30 - Build ONOS package
31 """
kelvin-onlab44147802015-07-27 17:57:31 -070032 main.case( "Constructing test variables and building ONOS package" )
33 main.step( "Constructing test variables" )
34 main.caseExplanation = "This test case is mainly for loading " +\
35 "from params file, and pull and build the " +\
36 " latest ONOS package"
37 stepResult = main.FALSE
38
39 # Test variables
40 try:
Jon Hallf7234882015-08-28 13:16:31 -070041 main.testOnDirectory = re.sub( "(/tests)$", "", main.testDir )
kelvin-onlab44147802015-07-27 17:57:31 -070042 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
43 gitBranch = main.params[ 'GIT' ][ 'branch' ]
44 main.dependencyPath = main.testOnDirectory + \
45 main.params[ 'DEPENDENCY' ][ 'path' ]
46 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
47 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
48 if main.ONOSbench.maxNodes:
49 main.maxNodes = int( main.ONOSbench.maxNodes )
50 else:
51 main.maxNodes = 0
52 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
53 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
54 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
55 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
Jeremy2f190ca2016-01-29 15:23:57 -080056 main.checkIntentSleep = int( main.params[ 'SLEEP' ][ 'checkintent' ] )
57 main.removeIntentsleeo = int( main.params[ 'SLEEP' ][ 'removeintent' ] )
kelvin-onlab44147802015-07-27 17:57:31 -070058 main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] )
59 main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
kelvin-onlab0e684682015-08-11 18:51:41 -070060 main.addIntentSleep = int( main.params[ 'SLEEP' ][ 'addIntent' ] )
Jeremy2f190ca2016-01-29 15:23:57 -080061 main.checkTopoAttempts = int( main.params[ 'SLEEP' ][ 'topoAttempts' ] )
Jeremy Songster306ed7a2016-07-19 10:59:07 -070062 main.flowDurationSleep = int( main.params[ 'SLEEP' ][ 'flowDuration' ] )
kelvin-onlab44147802015-07-27 17:57:31 -070063 gitPull = main.params[ 'GIT' ][ 'pull' ]
64 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
65 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
Jon Hall02758ac2017-05-24 16:20:28 -070066 main.cellData = {} # for creating cell file
kelvin-onlab44147802015-07-27 17:57:31 -070067 main.hostsData = {}
Jeremy Songstere7f3b342016-08-17 14:56:49 -070068 main.RESTs = []
kelvin-onlab44147802015-07-27 17:57:31 -070069 main.CLIs = []
70 main.ONOSip = []
Jeremy2f190ca2016-01-29 15:23:57 -080071 main.scapyHostNames = main.params[ 'SCAPY' ][ 'HOSTNAMES' ].split( ',' )
72 main.scapyHosts = [] # List of scapy hosts for iterating
73 main.assertReturnString = '' # Assembled assert return string
Jon Hall02758ac2017-05-24 16:20:28 -070074 main.cycle = 0 # How many times FUNCintent has run through its tests
kelvin-onlab44147802015-07-27 17:57:31 -070075
76 main.ONOSip = main.ONOSbench.getOnosIps()
Jeremy2f190ca2016-01-29 15:23:57 -080077 print main.ONOSip
kelvin-onlab44147802015-07-27 17:57:31 -070078
79 # Assigning ONOS cli handles to a list
Jon Hallf7234882015-08-28 13:16:31 -070080 try:
Jon Hall02758ac2017-05-24 16:20:28 -070081 for i in range( 1, main.maxNodes + 1 ):
Jeremy Songstere7f3b342016-08-17 14:56:49 -070082 main.RESTs.append( getattr( main, 'ONOSrest' + str( i ) ) )
83 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
Jon Hallf7234882015-08-28 13:16:31 -070084 except AttributeError:
85 main.log.warn( "A " + str( main.maxNodes ) + " node cluster " +
86 "was defined in env variables, but only " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -070087 str( len( main.RESTs ) ) +
Jon Hallf7234882015-08-28 13:16:31 -070088 " nodes were defined in the .topo file. " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -070089 "Using " + str( len( main.RESTs ) ) +
Jon Hallf7234882015-08-28 13:16:31 -070090 " nodes for the test." )
kelvin-onlab44147802015-07-27 17:57:31 -070091
92 # -- INIT SECTION, ONLY RUNS ONCE -- #
93 main.startUp = imp.load_source( wrapperFile1,
94 main.dependencyPath +
95 wrapperFile1 +
96 ".py" )
97
98 main.intentFunction = imp.load_source( wrapperFile2,
Jon Hall02758ac2017-05-24 16:20:28 -070099 main.dependencyPath +
100 wrapperFile2 +
101 ".py" )
kelvin-onlab44147802015-07-27 17:57:31 -0700102
103 main.topo = imp.load_source( wrapperFile3,
104 main.dependencyPath +
105 wrapperFile3 +
106 ".py" )
107
Jon Hallf7234882015-08-28 13:16:31 -0700108 copyResult1 = main.ONOSbench.scp( main.Mininet1,
109 main.dependencyPath +
110 main.topology,
Jeremy2f190ca2016-01-29 15:23:57 -0800111 main.Mininet1.home + "custom/",
Jon Hallf7234882015-08-28 13:16:31 -0700112 direction="to" )
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700113 if main.RESTs and main.CLIs:
kelvin-onlab44147802015-07-27 17:57:31 -0700114 stepResult = main.TRUE
115 else:
116 main.log.error( "Did not properly created list of ONOS CLI handle" )
117 stepResult = main.FALSE
118 except Exception as e:
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700119 main.log.exception( e )
kelvin-onlab44147802015-07-27 17:57:31 -0700120 main.cleanup()
121 main.exit()
122
123 utilities.assert_equals( expect=main.TRUE,
124 actual=stepResult,
125 onpass="Successfully construct " +
126 "test variables ",
127 onfail="Failed to construct test variables" )
128
kelvin-onlab44147802015-07-27 17:57:31 -0700129 main.ONOSbench.getVersion( report=True )
130
131 def CASE2( self, main ):
132 """
133 - Set up cell
134 - Create cell file
135 - Set cell file
136 - Verify cell file
137 - Kill ONOS process
138 - Uninstall ONOS cluster
139 - Verify ONOS start up
140 - Install ONOS cluster
141 - Connect to cli
142 """
Jeremy Songster17147f22016-05-31 18:30:52 -0700143 main.cycle += 1
144
kelvin-onlab44147802015-07-27 17:57:31 -0700145 # main.scale[ 0 ] determines the current number of ONOS controller
146 main.numCtrls = int( main.scale[ 0 ] )
Jeremyeb51cb12016-03-28 17:53:35 -0700147 main.flowCompiler = "Flow Rules"
Jeremydd9bda62016-04-18 12:02:32 -0700148 main.initialized = main.TRUE
kelvin-onlab44147802015-07-27 17:57:31 -0700149
150 main.case( "Starting up " + str( main.numCtrls ) +
151 " node(s) ONOS cluster" )
152 main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
153 " node(s) ONOS cluster"
154
kelvin-onlab44147802015-07-27 17:57:31 -0700155 #kill off all onos processes
156 main.log.info( "Safety check, killing all ONOS processes" +
Jon Hall70b2ff42015-11-17 15:49:44 -0800157 " before initiating environment setup" )
kelvin-onlab44147802015-07-27 17:57:31 -0700158
Jeremy2f190ca2016-01-29 15:23:57 -0800159 time.sleep( main.startUpSleep )
Jeremy42df2e72016-02-23 16:37:46 -0800160
Jeremy2f190ca2016-01-29 15:23:57 -0800161 main.step( "Uninstalling ONOS package" )
162 onosUninstallResult = main.TRUE
163 for ip in main.ONOSip:
164 onosUninstallResult = onosUninstallResult and \
165 main.ONOSbench.onosUninstall( nodeIp=ip )
166 stepResult = onosUninstallResult
167 utilities.assert_equals( expect=main.TRUE,
168 actual=stepResult,
169 onpass="Successfully uninstalled ONOS package",
170 onfail="Failed to uninstall ONOS package" )
171
Jeremy42df2e72016-02-23 16:37:46 -0800172 time.sleep( main.startUpSleep )
173
kelvin-onlab44147802015-07-27 17:57:31 -0700174 for i in range( main.maxNodes ):
175 main.ONOSbench.onosDie( main.ONOSip[ i ] )
176
177 print "NODE COUNT = ", main.numCtrls
178
179 tempOnosIp = []
180 for i in range( main.numCtrls ):
Jon Hall02758ac2017-05-24 16:20:28 -0700181 tempOnosIp.append( main.ONOSip[ i ] )
kelvin-onlab44147802015-07-27 17:57:31 -0700182
183 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
184 "temp", main.Mininet1.ip_address,
Devin Lim461f0872017-06-05 16:49:33 -0700185 main.apps, tempOnosIp, main.ONOScli1.user_name )
kelvin-onlab44147802015-07-27 17:57:31 -0700186
187 main.step( "Apply cell to environment" )
188 cellResult = main.ONOSbench.setCell( "temp" )
189 verifyResult = main.ONOSbench.verifyCell()
190 stepResult = cellResult and verifyResult
191 utilities.assert_equals( expect=main.TRUE,
192 actual=stepResult,
Jon Hall02758ac2017-05-24 16:20:28 -0700193 onpass="Successfully applied cell to " +
kelvin-onlab44147802015-07-27 17:57:31 -0700194 "environment",
195 onfail="Failed to apply cell to environment " )
196
197 main.step( "Creating ONOS package" )
Jon Hallbd60ea02016-08-23 10:03:59 -0700198 packageResult = main.ONOSbench.buckBuild()
kelvin-onlab44147802015-07-27 17:57:31 -0700199 stepResult = packageResult
200 utilities.assert_equals( expect=main.TRUE,
201 actual=stepResult,
202 onpass="Successfully created ONOS package",
203 onfail="Failed to create ONOS package" )
204
205 time.sleep( main.startUpSleep )
kelvin-onlab44147802015-07-27 17:57:31 -0700206 main.step( "Installing ONOS package" )
207 onosInstallResult = main.TRUE
208 for i in range( main.numCtrls ):
209 onosInstallResult = onosInstallResult and \
210 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
211 stepResult = onosInstallResult
212 utilities.assert_equals( expect=main.TRUE,
213 actual=stepResult,
214 onpass="Successfully installed ONOS package",
215 onfail="Failed to install ONOS package" )
216
You Wangf5de25b2017-01-06 15:13:01 -0800217 main.step( "Set up ONOS secure SSH" )
218 secureSshResult = main.TRUE
219 for i in range( int( main.numCtrls ) ):
Jon Hall02758ac2017-05-24 16:20:28 -0700220 secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[ i ] )
You Wangf5de25b2017-01-06 15:13:01 -0800221 utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
222 onpass="Test step PASS",
223 onfail="Test step FAIL" )
224
kelvin-onlab44147802015-07-27 17:57:31 -0700225 time.sleep( main.startUpSleep )
226 main.step( "Starting ONOS service" )
227 stopResult = main.TRUE
228 startResult = main.TRUE
229 onosIsUp = main.TRUE
230
231 for i in range( main.numCtrls ):
232 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
Jeremydd9bda62016-04-18 12:02:32 -0700233 if onosIsUp == main.TRUE:
234 main.log.report( "ONOS instance {0} is up and ready".format( i + 1 ) )
235 else:
236 main.log.report( "ONOS instance {0} may not be up, stop and ".format( i + 1 ) +
237 "start ONOS again " )
238 stopResult = stopResult and main.ONOSbench.onosStop( main.ONOSip[ i ] )
239 startResult = startResult and main.ONOSbench.onosStart( main.ONOSip[ i ] )
240 if not startResult or stopResult:
241 main.log.report( "ONOS instance {0} did not start correctly.".format( i + 1 ) )
kelvin-onlab44147802015-07-27 17:57:31 -0700242 stepResult = onosIsUp and stopResult and startResult
243 utilities.assert_equals( expect=main.TRUE,
244 actual=stepResult,
245 onpass="ONOS service is ready",
246 onfail="ONOS service did not start properly" )
Jeremydd9bda62016-04-18 12:02:32 -0700247 if not stepResult:
248 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700249
Jeremy2f190ca2016-01-29 15:23:57 -0800250 # Start an ONOS cli to provide functionality that is not currently
Jeremye1ea0602016-02-08 16:35:05 -0800251 # supported by the Rest API remove this when Leader Checking is supported
252 # by the REST API
Jeremy2f190ca2016-01-29 15:23:57 -0800253
Jeremye1ea0602016-02-08 16:35:05 -0800254 main.step( "Start ONOS cli" )
255 cliResult = main.TRUE
256 for i in range( main.numCtrls ):
257 cliResult = cliResult and \
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700258 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
Jeremye1ea0602016-02-08 16:35:05 -0800259 stepResult = cliResult
260 utilities.assert_equals( expect=main.TRUE,
261 actual=stepResult,
262 onpass="Successfully start ONOS cli",
263 onfail="Failed to start ONOS cli" )
Jeremydd9bda62016-04-18 12:02:32 -0700264 if not stepResult:
265 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800266
kelvin-onlab44147802015-07-27 17:57:31 -0700267 # Remove the first element in main.scale list
268 main.scale.remove( main.scale[ 0 ] )
269
Jeremy2f190ca2016-01-29 15:23:57 -0800270 main.intentFunction.report( main )
271
kelvin-onlab44147802015-07-27 17:57:31 -0700272 def CASE8( self, main ):
Jeremy2f190ca2016-01-29 15:23:57 -0800273 # OLD FUNCintentRest CASE 8
274 # This remains here for archiving and reference purposes and will be
275 # removed when the new FUNCintentRest is verified to work.
276 # """
277 # Compare Topo
278 # """
279 # import json
280
281 # main.case( "Compare ONOS Topology view to Mininet topology" )
282 # main.caseExplanation = "Compare topology elements between Mininet" +\
283 # " and ONOS"
284
285 # main.step( "Gathering topology information" )
286 # # TODO: add a paramaterized sleep here
287 # devicesResults = main.TRUE # Overall Boolean for device correctness
288 # linksResults = main.TRUE # Overall Boolean for link correctness
289 # hostsResults = main.TRUE # Overall Boolean for host correctness
290 # devices = main.topo.getAllDevices( main )
291 # hosts = main.topo.getAllHosts( main )
292 # ports = main.topo.getAllPorts( main )
293 # links = main.topo.getAllLinks( main )
294 # clusters = main.topo.getAllClusters( main )
295
296 # mnSwitches = main.Mininet1.getSwitches()
297 # mnLinks = main.Mininet1.getLinks()
298 # mnHosts = main.Mininet1.getHosts()
299
300 # main.step( "Comparing MN topology to ONOS topology" )
301 # for controller in range( main.numCtrls ):
302 # controllerStr = str( controller + 1 )
303 # if devices[ controller ] and ports[ controller ] and\
304 # "Error" not in devices[ controller ] and\
305 # "Error" not in ports[ controller ]:
306
307 # currentDevicesResult = main.Mininet1.compareSwitches(
308 # mnSwitches,
309 # json.loads( devices[ controller ] ),
310 # json.loads( ports[ controller ] ) )
311 # else:
312 # currentDevicesResult = main.FALSE
313 # utilities.assert_equals( expect=main.TRUE,
314 # actual=currentDevicesResult,
315 # onpass="ONOS" + controllerStr +
316 # " Switches view is correct",
317 # onfail="ONOS" + controllerStr +
318 # " Switches view is incorrect" )
319
320 # if links[ controller ] and "Error" not in links[ controller ]:
321 # currentLinksResult = main.Mininet1.compareLinks(
322 # mnSwitches, mnLinks,
323 # json.loads( links[ controller ] ) )
324 # else:
325 # currentLinksResult = main.FALSE
326 # utilities.assert_equals( expect=main.TRUE,
327 # actual=currentLinksResult,
328 # onpass="ONOS" + controllerStr +
329 # " links view is correct",
330 # onfail="ONOS" + controllerStr +
331 # " links view is incorrect" )
332
333 # if hosts[ controller ] or "Error" not in hosts[ controller ]:
334 # currentHostsResult = main.Mininet1.compareHosts(
335 # mnHosts,
336 # json.loads( hosts[ controller ] ) )
337 # else:
338 # currentHostsResult = main.FALSE
339 # utilities.assert_equals( expect=main.TRUE,
340 # actual=currentHostsResult,
341 # onpass="ONOS" + controllerStr +
342 # " hosts exist in Mininet",
343 # onfail="ONOS" + controllerStr +
344 # " hosts don't match Mininet" )
345
346 # NEW FUNCintentRest Case 8 as based off of the CASE 8 from FUNCintent
kelvin-onlab44147802015-07-27 17:57:31 -0700347 """
Jeremy2f190ca2016-01-29 15:23:57 -0800348 Compare ONOS Topology to Mininet Topology
kelvin-onlab44147802015-07-27 17:57:31 -0700349 """
350 import json
351
352 main.case( "Compare ONOS Topology view to Mininet topology" )
353 main.caseExplanation = "Compare topology elements between Mininet" +\
354 " and ONOS"
355
Jeremy2f190ca2016-01-29 15:23:57 -0800356 main.log.info( "Gathering topology information from Mininet" )
357 devicesResults = main.FALSE # Overall Boolean for device correctness
358 linksResults = main.FALSE # Overall Boolean for link correctness
359 hostsResults = main.FALSE # Overall Boolean for host correctness
360 deviceFails = [] # Nodes where devices are incorrect
361 linkFails = [] # Nodes where links are incorrect
362 hostFails = [] # Nodes where hosts are incorrect
363 attempts = main.checkTopoAttempts # Remaining Attempts
kelvin-onlab44147802015-07-27 17:57:31 -0700364
365 mnSwitches = main.Mininet1.getSwitches()
366 mnLinks = main.Mininet1.getLinks()
367 mnHosts = main.Mininet1.getHosts()
368
Jeremy2f190ca2016-01-29 15:23:57 -0800369 main.step( "Comparing Mininet topology to ONOS topology" )
kelvin-onlab44147802015-07-27 17:57:31 -0700370
Jeremy2f190ca2016-01-29 15:23:57 -0800371 while ( attempts >= 0 ) and\
Jon Hall02758ac2017-05-24 16:20:28 -0700372 ( not devicesResults or not linksResults or not hostsResults ):
Jeremy2f190ca2016-01-29 15:23:57 -0800373 time.sleep( 2 )
374 if not devicesResults:
375 devices = main.topo.getAllDevices( main )
376 ports = main.topo.getAllPorts( main )
377 devicesResults = main.TRUE
378 deviceFails = [] # Reset for each failed attempt
379 if not linksResults:
380 links = main.topo.getAllLinks( main )
381 linksResults = main.TRUE
382 linkFails = [] # Reset for each failed attempt
383 if not hostsResults:
384 hosts = main.topo.getAllHosts( main )
385 hostsResults = main.TRUE
386 hostFails = [] # Reset for each failed attempt
kelvin-onlab44147802015-07-27 17:57:31 -0700387
Jeremy2f190ca2016-01-29 15:23:57 -0800388 # Check for matching topology on each node
389 for controller in range( main.numCtrls ):
390 controllerStr = str( controller + 1 ) # ONOS node number
391 # Compare Devices
392 if devices[ controller ] and ports[ controller ] and\
Jon Hall02758ac2017-05-24 16:20:28 -0700393 "Error" not in devices[ controller ] and\
394 "Error" not in ports[ controller ]:
kelvin-onlab44147802015-07-27 17:57:31 -0700395
Jeremy2f190ca2016-01-29 15:23:57 -0800396 try:
397 deviceData = json.loads( devices[ controller ] )
398 portData = json.loads( ports[ controller ] )
Jon Hall02758ac2017-05-24 16:20:28 -0700399 except ( TypeError, ValueError ):
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700400 main.log.error( "Could not load json: {0} or {1}".format( str( devices[ controller ] ),
401 str( ports[ controller ] ) ) )
Jeremy2f190ca2016-01-29 15:23:57 -0800402 currentDevicesResult = main.FALSE
403 else:
404 currentDevicesResult = main.Mininet1.compareSwitches(
Jon Hall02758ac2017-05-24 16:20:28 -0700405 mnSwitches, deviceData, portData )
Jeremy2f190ca2016-01-29 15:23:57 -0800406 else:
407 currentDevicesResult = main.FALSE
408 if not currentDevicesResult:
409 deviceFails.append( controllerStr )
410 devicesResults = devicesResults and currentDevicesResult
411 # Compare Links
412 if links[ controller ] and "Error" not in links[ controller ]:
413 try:
414 linkData = json.loads( links[ controller ] )
Jon Hall02758ac2017-05-24 16:20:28 -0700415 except ( TypeError, ValueError ):
416 main.log.error( "Could not load json:" + str( links[ controller ] ) )
Jeremy2f190ca2016-01-29 15:23:57 -0800417 currentLinksResult = main.FALSE
418 else:
419 currentLinksResult = main.Mininet1.compareLinks(
Jon Hall02758ac2017-05-24 16:20:28 -0700420 mnSwitches, mnLinks, linkData )
Jeremy2f190ca2016-01-29 15:23:57 -0800421 else:
422 currentLinksResult = main.FALSE
423 if not currentLinksResult:
424 linkFails.append( controllerStr )
425 linksResults = linksResults and currentLinksResult
426 # Compare Hosts
427 if hosts[ controller ] and "Error" not in hosts[ controller ]:
428 try:
429 hostData = json.loads( hosts[ controller ] )
Jon Hall02758ac2017-05-24 16:20:28 -0700430 except ( TypeError, ValueError ):
431 main.log.error( "Could not load json:" + str( hosts[ controller ] ) )
Jeremy2f190ca2016-01-29 15:23:57 -0800432 currentHostsResult = main.FALSE
433 else:
434 currentHostsResult = main.Mininet1.compareHosts(
Jon Hall02758ac2017-05-24 16:20:28 -0700435 mnHosts, hostData )
Jeremy2f190ca2016-01-29 15:23:57 -0800436 else:
437 currentHostsResult = main.FALSE
438 if not currentHostsResult:
439 hostFails.append( controllerStr )
440 hostsResults = hostsResults and currentHostsResult
441 # Decrement Attempts Remaining
442 attempts -= 1
443
Jeremy2f190ca2016-01-29 15:23:57 -0800444 utilities.assert_equals( expect=[],
445 actual=deviceFails,
446 onpass="ONOS correctly discovered all devices",
447 onfail="ONOS incorrectly discovered devices on nodes: " +
448 str( deviceFails ) )
449 utilities.assert_equals( expect=[],
450 actual=linkFails,
451 onpass="ONOS correctly discovered all links",
452 onfail="ONOS incorrectly discovered links on nodes: " +
453 str( linkFails ) )
454 utilities.assert_equals( expect=[],
455 actual=hostFails,
456 onpass="ONOS correctly discovered all hosts",
457 onfail="ONOS incorrectly discovered hosts on nodes: " +
458 str( hostFails ) )
459 topoResults = hostsResults and linksResults and devicesResults
460 utilities.assert_equals( expect=main.TRUE,
461 actual=topoResults,
462 onpass="ONOS correctly discovered the topology",
463 onfail="ONOS incorrectly discovered the topology" )
kelvin-onlab44147802015-07-27 17:57:31 -0700464
465 def CASE9( self, main ):
Jon Hall02758ac2017-05-24 16:20:28 -0700466 """
kelvin-onlab44147802015-07-27 17:57:31 -0700467 Report errors/warnings/exceptions
Jon Hall02758ac2017-05-24 16:20:28 -0700468 """
kelvin-onlab44147802015-07-27 17:57:31 -0700469 main.log.info( "Error report: \n" )
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700470 main.ONOSbench.logReport( globalONOSip[ 0 ],
Jon Hall02758ac2017-05-24 16:20:28 -0700471 [ "INFO", "FOLLOWER", "WARN", "flow", "ERROR", "Except" ],
472 "s" )
473 #main.ONOSbench.logReport( globalONOSip[ 1 ], [ "INFO" ], "d" )
kelvin-onlab44147802015-07-27 17:57:31 -0700474
475 def CASE10( self, main ):
476 """
477 Start Mininet topology with OF 1.0 switches
478 """
Jeremydd9bda62016-04-18 12:02:32 -0700479 if main.initialized == main.FALSE:
480 main.log.error( "Test components did not start correctly, skipping further tests" )
481 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700482 main.OFProtocol = "1.0"
483 main.log.report( "Start Mininet topology with OF 1.0 switches" )
484 main.case( "Start Mininet topology with OF 1.0 switches" )
485 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
486 "switches to test intents, exits out if " +\
487 "topology did not start correctly"
488
489 main.step( "Starting Mininet topology with OF 1.0 switches" )
490 args = "--switch ovs,protocols=OpenFlow10"
491 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
492 main.topology,
493 args=args )
494 stepResult = topoResult
495 utilities.assert_equals( expect=main.TRUE,
496 actual=stepResult,
497 onpass="Successfully loaded topology",
498 onfail="Failed to load topology" )
499 # Exit if topology did not load properly
500 if not topoResult:
Jeremydd9bda62016-04-18 12:02:32 -0700501 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700502
503 def CASE11( self, main ):
504 """
505 Start Mininet topology with OF 1.3 switches
506 """
Jeremydd9bda62016-04-18 12:02:32 -0700507 if main.initialized == main.FALSE:
508 main.log.error( "Test components did not start correctly, skipping further tests" )
509 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700510 main.OFProtocol = "1.3"
511 main.log.report( "Start Mininet topology with OF 1.3 switches" )
512 main.case( "Start Mininet topology with OF 1.3 switches" )
513 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
514 "switches to test intents, exits out if " +\
515 "topology did not start correctly"
516
517 main.step( "Starting Mininet topology with OF 1.3 switches" )
518 args = "--switch ovs,protocols=OpenFlow13"
519 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
520 main.topology,
521 args=args )
522 stepResult = topoResult
523 utilities.assert_equals( expect=main.TRUE,
524 actual=stepResult,
525 onpass="Successfully loaded topology",
526 onfail="Failed to load topology" )
527 # Exit if topology did not load properly
528 if not topoResult:
Jeremydd9bda62016-04-18 12:02:32 -0700529 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700530
531 def CASE12( self, main ):
532 """
533 Assign mastership to controllers
534 """
535 import re
536
Jeremydd9bda62016-04-18 12:02:32 -0700537 if main.initialized == main.FALSE:
538 main.log.error( "Test components did not start correctly, skipping further tests" )
539 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700540 main.case( "Assign switches to controllers" )
541 main.step( "Assigning switches to controllers" )
542 main.caseExplanation = "Assign OF " + main.OFProtocol +\
543 " switches to ONOS nodes"
544
545 assignResult = main.TRUE
546 switchList = []
547
548 # Creates a list switch name, use getSwitch() function later...
549 for i in range( 1, ( main.numSwitch + 1 ) ):
550 switchList.append( 's' + str( i ) )
551
552 tempONOSip = []
553 for i in range( main.numCtrls ):
554 tempONOSip.append( main.ONOSip[ i ] )
555
556 assignResult = main.Mininet1.assignSwController( sw=switchList,
557 ip=tempONOSip,
Charles Chan029be652015-08-24 01:46:10 +0800558 port='6653' )
kelvin-onlab44147802015-07-27 17:57:31 -0700559 if not assignResult:
Jeremydd9bda62016-04-18 12:02:32 -0700560 main.log.error( "Problem assigning mastership of switches, skipping further test cases" )
561 main.initialized = main.FALSE
562 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700563
564 for i in range( 1, ( main.numSwitch + 1 ) ):
565 response = main.Mininet1.getSwController( "s" + str( i ) )
566 print( "Response is " + str( response ) )
567 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
568 assignResult = assignResult and main.TRUE
569 else:
570 assignResult = main.FALSE
571 stepResult = assignResult
572 utilities.assert_equals( expect=main.TRUE,
573 actual=stepResult,
574 onpass="Successfully assigned switches" +
575 "to controller",
576 onfail="Failed to assign switches to " +
577 "controller" )
Jeremydd9bda62016-04-18 12:02:32 -0700578 if not stepResult:
579 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800580
Jon Hall02758ac2017-05-24 16:20:28 -0700581 def CASE13( self, main ):
Jeremy2f190ca2016-01-29 15:23:57 -0800582 """
583 Create Scapy components
584 """
Jeremydd9bda62016-04-18 12:02:32 -0700585 if main.initialized == main.FALSE:
586 main.log.error( "Test components did not start correctly, skipping further tests" )
587 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800588 main.case( "Create scapy components" )
589 main.step( "Create scapy components" )
590 import json
591 scapyResult = main.TRUE
592 for hostName in main.scapyHostNames:
593 main.Scapy1.createHostComponent( hostName )
594 main.scapyHosts.append( getattr( main, hostName ) )
595
596 main.step( "Start scapy components" )
597 for host in main.scapyHosts:
598 host.startHostCli()
599 host.startScapy()
600 host.updateSelf()
601 main.log.debug( host.name )
602 main.log.debug( host.hostIp )
603 main.log.debug( host.hostMac )
604
Jeremy2f190ca2016-01-29 15:23:57 -0800605 utilities.assert_equals( expect=main.TRUE,
606 actual=scapyResult,
607 onpass="Successfully created Scapy Components",
608 onfail="Failed to discover Scapy Components" )
Jeremydd9bda62016-04-18 12:02:32 -0700609 if not scapyResult:
610 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800611
612 def CASE14( self, main ):
kelvin-onlab44147802015-07-27 17:57:31 -0700613 """
614 Discover all hosts and store its data to a dictionary
615 """
Jeremydd9bda62016-04-18 12:02:32 -0700616 if main.initialized == main.FALSE:
617 main.log.error( "Test components did not start correctly, skipping further tests" )
618 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700619 main.case( "Discover all hosts" )
620
621 stepResult = main.TRUE
kelvin-onlab0e684682015-08-11 18:51:41 -0700622 main.step( "Discover all ipv4 host hosts " )
623 hostList = []
624 # List of host with default vlan
625 defaultHosts = [ "h1", "h3", "h8", "h9", "h11", "h16", "h17", "h19", "h24" ]
626 # Lists of host with unique vlan
627 vlanHosts1 = [ "h4", "h12", "h20" ]
628 vlanHosts2 = [ "h5", "h13", "h21" ]
629 vlanHosts3 = [ "h6", "h14", "h22" ]
630 vlanHosts4 = [ "h7", "h15", "h23" ]
631 hostList.append( defaultHosts )
632 hostList.append( vlanHosts1 )
633 hostList.append( vlanHosts2 )
634 hostList.append( vlanHosts3 )
635 hostList.append( vlanHosts4 )
636
637 stepResult = main.intentFunction.getHostsData( main, hostList )
kelvin-onlab44147802015-07-27 17:57:31 -0700638 utilities.assert_equals( expect=main.TRUE,
639 actual=stepResult,
640 onpass="Successfully discovered hosts",
641 onfail="Failed to discover hosts" )
Jeremydd9bda62016-04-18 12:02:32 -0700642 if not stepResult:
643 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700644
Jeremy2f190ca2016-01-29 15:23:57 -0800645 def CASE15( self, main ):
kelvin-onlab44147802015-07-27 17:57:31 -0700646 """
Jeremy2f190ca2016-01-29 15:23:57 -0800647 Discover all hosts with scapy arp packets and store its data to a dictionary
kelvin-onlab44147802015-07-27 17:57:31 -0700648 """
Jeremydd9bda62016-04-18 12:02:32 -0700649 if main.initialized == main.FALSE:
650 main.log.error( "Test components did not start correctly, skipping further tests" )
651 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800652 main.case( "Discover all hosts using scapy" )
653 main.step( "Send packets from each host to the first host and confirm onos discovery" )
654
655 import collections
656 if len( main.scapyHosts ) < 1:
657 main.log.error( "No scapy hosts have been created" )
Jeremydd9bda62016-04-18 12:02:32 -0700658 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800659 main.skipCase()
660
661 # Send ARP packets from each scapy host component
662 main.intentFunction.sendDiscoveryArp( main, main.scapyHosts )
663
664 stepResult = utilities.retry( f=main.intentFunction.confirmHostDiscovery,
665 retValue=main.FALSE, args=[ main ],
666 attempts=main.checkTopoAttempts, sleep=2 )
667
668 utilities.assert_equals( expect=main.TRUE,
669 actual=stepResult,
670 onpass="ONOS correctly discovered all hosts",
671 onfail="ONOS incorrectly discovered hosts" )
Jeremydd9bda62016-04-18 12:02:32 -0700672 if not stepResult:
673 main.initialized = main.FALSE
674 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800675
676 main.step( "Populate hostsData" )
677 stepResult = main.intentFunction.populateHostData( main )
678 utilities.assert_equals( expect=main.TRUE,
679 actual=stepResult,
680 onpass="Successfully populated hostsData",
681 onfail="Failed to populate hostsData" )
Jeremydd9bda62016-04-18 12:02:32 -0700682 if not stepResult:
683 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800684
685 def CASE16( self, main ):
686 """
Jeremy42df2e72016-02-23 16:37:46 -0800687 Balance Masters
688 """
Jeremydd9bda62016-04-18 12:02:32 -0700689 if main.initialized == main.FALSE:
690 main.log.error( "Test components did not start correctly, skipping further tests" )
691 main.skipCase()
Jeremy42df2e72016-02-23 16:37:46 -0800692 main.case( "Balance mastership of switches" )
693 main.step( "Balancing mastership of switches" )
694
695 balanceResult = main.FALSE
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700696 balanceResult = utilities.retry( f=main.CLIs[ 0 ].balanceMasters, retValue=main.FALSE, args=[] )
Jeremy42df2e72016-02-23 16:37:46 -0800697
698 utilities.assert_equals( expect=main.TRUE,
699 actual=stepResult,
700 onpass="Successfully balanced mastership of switches",
701 onfail="Failed to balance mastership of switches" )
Jeremydd9bda62016-04-18 12:02:32 -0700702 if not stepResult:
703 main.initialized = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800704
705 def CASE17( self, main ):
706 """
Jeremyeb51cb12016-03-28 17:53:35 -0700707 Use Flow Objectives
708 """
Jeremydd9bda62016-04-18 12:02:32 -0700709 if main.initialized == main.FALSE:
710 main.log.error( "Test components did not start correctly, skipping further tests" )
711 main.skipCase()
Jeremyeb51cb12016-03-28 17:53:35 -0700712 main.case( "Enable intent compilation using Flow Objectives" )
713 main.step( "Enabling Flow Objectives" )
714
715 main.flowCompiler = "Flow Objectives"
716
717 cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator"
718
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700719 stepResult = main.CLIs[ 0 ].setCfg( component=cmd,
Jeremyeb51cb12016-03-28 17:53:35 -0700720 propName="useFlowObjectives", value="true" )
You Wang106d0fa2017-05-15 17:22:15 -0700721 stepResult &= main.CLIs[ 0 ].setCfg( component=cmd,
722 propName="defaultFlowObjectiveCompiler",
Jon Hall02758ac2017-05-24 16:20:28 -0700723 value='org.onosproject.net.intent.impl.compiler.LinkCollectionIntentObjectiveCompiler' )
Jeremyeb51cb12016-03-28 17:53:35 -0700724
725 utilities.assert_equals( expect=main.TRUE,
726 actual=stepResult,
727 onpass="Successfully activated Flow Objectives",
728 onfail="Failed to activate Flow Objectives" )
Jeremydd9bda62016-04-18 12:02:32 -0700729 if not stepResult:
730 main.initialized = main.FALSE
Jeremyeb51cb12016-03-28 17:53:35 -0700731
732 def CASE18( self, main ):
733 """
Jeremy2f190ca2016-01-29 15:23:57 -0800734 Stop mininet and remove scapy hosts
735 """
736 main.log.report( "Stop Mininet and Scapy" )
737 main.case( "Stop Mininet and Scapy" )
kelvin-onlab44147802015-07-27 17:57:31 -0700738 main.caseExplanation = "Stopping the current mininet topology " +\
739 "to start up fresh"
740
Jeremy2f190ca2016-01-29 15:23:57 -0800741 main.step( "Stopping and Removing Scapy Host Components" )
742 scapyResult = main.TRUE
743 for host in main.scapyHosts:
744 scapyResult = scapyResult and host.stopScapy()
745 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
746
747 for host in main.scapyHosts:
748 scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
749 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
750
751 main.scapyHosts = []
752 main.scapyHostIPs = []
753
754 utilities.assert_equals( expect=main.TRUE,
755 actual=scapyResult,
756 onpass="Successfully stopped scapy and removed host components",
757 onfail="Failed to stop mininet and scapy" )
758
kelvin-onlab44147802015-07-27 17:57:31 -0700759 main.step( "Stopping Mininet Topology" )
Jon Hall02758ac2017-05-24 16:20:28 -0700760 mininetResult = main.Mininet1.stopNet()
Jeremy2f190ca2016-01-29 15:23:57 -0800761
kelvin-onlab44147802015-07-27 17:57:31 -0700762 utilities.assert_equals( expect=main.TRUE,
763 actual=stepResult,
764 onpass="Successfully stop mininet",
765 onfail="Failed to stop mininet" )
766 # Exit if topology did not load properly
Jon Hall02758ac2017-05-24 16:20:28 -0700767 if not ( mininetResult and scapyResult ):
kelvin-onlab44147802015-07-27 17:57:31 -0700768 main.cleanup()
769 main.exit()
770
Jeremy Songster17147f22016-05-31 18:30:52 -0700771 def CASE19( self, main ):
772 """
773 Copy the karaf.log files after each testcase cycle
774 """
775 main.log.report( "Copy karaf logs" )
776 main.case( "Copy karaf logs" )
777 main.caseExplanation = "Copying the karaf logs to preserve them through" +\
778 "reinstalling ONOS"
779 main.step( "Copying karaf logs" )
Jeremy Songster31aad312016-06-13 16:32:11 -0700780 stepResult = main.TRUE
781 scpResult = main.TRUE
782 copyResult = main.TRUE
Jeremy Songstercc5414b2016-07-11 10:59:53 -0700783 for i in range( main.numCtrls ):
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700784 main.node = main.CLIs[ i ]
Jeremy Songster17147f22016-05-31 18:30:52 -0700785 ip = main.ONOSip[ i ]
786 main.node.ip_address = ip
Jon Hall02758ac2017-05-24 16:20:28 -0700787 scpResult = scpResult and main.ONOSbench.scp( main.node,
788 "/opt/onos/log/karaf.log",
789 "/tmp/karaf.log",
790 direction="from" )
Jeremy Songster31aad312016-06-13 16:32:11 -0700791 copyResult = copyResult and main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700792 copyFileName=( "karaf.log.node{0}.cycle{1}".format(
793 str( i + 1 ), str( main.cycle ) ) ) )
Jeremy Songster31aad312016-06-13 16:32:11 -0700794 if scpResult and copyResult:
Jon Hall02758ac2017-05-24 16:20:28 -0700795 stepResult = main.TRUE and stepResult
Jeremy Songster31aad312016-06-13 16:32:11 -0700796 else:
797 stepResult = main.FALSE and stepResult
Jeremy Songster31aad312016-06-13 16:32:11 -0700798 utilities.assert_equals( expect=main.TRUE,
799 actual=stepResult,
800 onpass="Successfully copied remote ONOS logs",
801 onfail="Failed to copy remote ONOS logs" )
Jeremy Songster17147f22016-05-31 18:30:52 -0700802
kelvin-onlab44147802015-07-27 17:57:31 -0700803 def CASE1000( self, main ):
804 """
805 Add host intents between 2 host:
806 - Discover hosts
807 - Add host intents
808 - Check intents
809 - Verify flows
810 - Ping hosts
811 - Reroute
812 - Link down
813 - Verify flows
814 - Check topology
815 - Ping hosts
816 - Link up
817 - Verify flows
818 - Check topology
819 - Ping hosts
820 - Remove intents
821 """
822 import time
823 import json
824 import re
Jeremydd9bda62016-04-18 12:02:32 -0700825 if main.initialized == main.FALSE:
826 main.log.error( "Test components did not start correctly, skipping further tests" )
827 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700828 # Assert variables - These variable's name|format must be followed
829 # if you want to use the wrapper function
830 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -0700831 try:
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700832 assert main.RESTs
Jeremydd9bda62016-04-18 12:02:32 -0700833 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700834 main.log.error( "There is no main.RESTs, skipping test cases" )
Jeremydd9bda62016-04-18 12:02:32 -0700835 main.initialized = main.FALSE
836 main.skipCase()
837 try:
838 assert main.Mininet1
839 except AssertionError:
840 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
841 main.initialized = main.FALSE
842 main.skipCase()
843 try:
844 assert main.numSwitch
845 except AssertionError:
Jon Hall02758ac2017-05-24 16:20:28 -0700846 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700847 main.numSwitch )
Jeremydd9bda62016-04-18 12:02:32 -0700848 main.initialized = main.FALSE
849 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700850
Jeremye1ea0602016-02-08 16:35:05 -0800851 # Save leader candidates
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700852 intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
Jeremye1ea0602016-02-08 16:35:05 -0800853
kelvin-onlab44147802015-07-27 17:57:31 -0700854 main.case( "Host Intents Test - " + str( main.numCtrls ) +
Jeremyeb51cb12016-03-28 17:53:35 -0700855 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -0700856 main.caseExplanation = "This test case tests Host intents using " +\
857 str( main.numCtrls ) + " node(s) cluster;\n" +\
858 "Different type of hosts will be tested in " +\
859 "each step such as IPV4, Dual stack, VLAN " +\
Jeremyeb51cb12016-03-28 17:53:35 -0700860 "etc;\nThe test will use OF " + main.OFProtocol +\
861 " OVS running in Mininet and compile intents" +\
862 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -0700863
Jeremy2f190ca2016-01-29 15:23:57 -0800864 main.step( "IPV4: Add and test host intents between h1 and h9" )
865 main.assertReturnString = "Assertion result for IPV4 host intent with mac addresses\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700866 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
867 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800868 testResult = main.FALSE
869 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700870 name='IPV4',
871 onosNode='0',
872 host1=host1,
873 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800874
875 if installResult:
876 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700877 name='IPV4',
878 intentId=installResult,
879 onosNode='0',
880 host1=host1,
881 host2=host2,
882 sw1='s5',
883 sw2='s2',
884 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700885
886 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800887 actual=testResult,
888 onpass=main.assertReturnString,
889 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700890
891 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800892 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700893 host1 = { "name": "h3", "id": "00:00:00:00:00:03/-1" }
894 host2 = { "name": "h11", "id": "00:00:00:00:00:0B/-1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800895 testResult = main.FALSE
896 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700897 name='DUALSTACK1',
898 onosNode='0',
899 host1=host1,
900 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800901
902 if installResult:
903 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700904 name='DUALSTACK1',
905 intentId=installResult,
906 onosNode='0',
907 host1=host1,
908 host2=host2,
909 sw1='s5',
910 sw2='s2',
911 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700912
913 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800914 actual=testResult,
915 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700916 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700917
918 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800919 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700920 host1 = { "name": "h1" }
921 host2 = { "name": "h11" }
Jeremy2f190ca2016-01-29 15:23:57 -0800922 testResult = main.FALSE
923 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700924 name='DUALSTACK2',
925 onosNode='0',
926 host1=host1,
927 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800928
929 if installResult:
930 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700931 name='DUALSTACK2',
932 intentId=installResult,
933 onosNode='0',
934 host1=host1,
935 host2=host2,
936 sw1='s5',
937 sw2='s2',
938 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700939
940 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800941 actual=testResult,
942 onpass=main.assertReturnString,
943 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700944
945 main.step( "1HOP: Add host intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -0800946 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700947 host1 = { "name": "h1" }
948 host2 = { "name": "h3" }
Jeremy2f190ca2016-01-29 15:23:57 -0800949 testResult = main.FALSE
950 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700951 name='1HOP',
952 onosNode='0',
953 host1=host1,
954 host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700955
Jeremy2f190ca2016-01-29 15:23:57 -0800956 if installResult:
957 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700958 name='1HOP',
959 intentId=installResult,
960 onosNode='0',
961 host1=host1,
962 host2=host2,
963 sw1='s5',
964 sw2='s2',
965 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700966
967 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800968 actual=testResult,
969 onpass=main.assertReturnString,
970 onfail=main.assertReturnString )
971
972 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
973 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700974 host1 = { "name": "h4", "id": "00:00:00:00:00:04/100", "vlanId": "100" }
975 host2 = { "name": "h12", "id": "00:00:00:00:00:0C/100", "vlanId": "100" }
Jeremy2f190ca2016-01-29 15:23:57 -0800976 testResult = main.FALSE
977 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700978 name='VLAN1',
979 onosNode='0',
980 host1=host1,
981 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800982
983 if installResult:
984 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700985 name='VLAN1',
986 intentId=installResult,
987 onosNode='0',
988 host1=host1,
989 host2=host2,
990 sw1='s5',
991 sw2='s2',
992 expectedLink=18 )
Jeremy2f190ca2016-01-29 15:23:57 -0800993
994 utilities.assert_equals( expect=main.TRUE,
995 actual=testResult,
996 onpass=main.assertReturnString,
997 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700998
Jeremy Songsterae2dd452016-05-17 16:44:35 -0700999 # This step isn't currently possible to perform in the REST API
1000 # main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
1001 # main.assertReturnString = "Assertion Result different VLAN negative test\n"
1002 # host1 = { "name":"h13" }
1003 # host2 = { "name":"h20" }
1004 # testResult = main.FALSE
1005 # installResult = main.intentFunction.installHostIntent( main,
1006 # name='VLAN2',
1007 # onosNode='0',
1008 # host1=host1,
1009 # host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -07001010
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001011 # if installResult:
1012 # testResult = main.intentFunction.testHostIntent( main,
1013 # name='VLAN2',
Jon Hall02758ac2017-05-24 16:20:28 -07001014 # intentId=installResult,
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001015 # onosNode='0',
1016 # host1=host1,
1017 # host2=host2,
1018 # sw1='s5',
1019 # sw2='s2',
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001020 # expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001021
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001022 # utilities.assert_equals( expect=main.TRUE,
1023 # actual=testResult,
1024 # onpass=main.assertReturnString,
1025 # onfail=main.assertReturnString )
Jeremy2f190ca2016-01-29 15:23:57 -08001026
Jeremye1ea0602016-02-08 16:35:05 -08001027 # Change the following to use the REST API when leader checking is
1028 # supported by it
Jeremy2f190ca2016-01-29 15:23:57 -08001029
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001030 main.step( "Confirm that ONOS leadership is unchanged" )
1031 intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
Jeremye1ea0602016-02-08 16:35:05 -08001032 main.intentFunction.checkLeaderChange( intentLeadersOld,
1033 intentLeadersNew )
Jeremy2f190ca2016-01-29 15:23:57 -08001034
Jeremye1ea0602016-02-08 16:35:05 -08001035 utilities.assert_equals( expect=main.TRUE,
1036 actual=testResult,
1037 onpass="ONOS Leaders Unchanged",
Jon Hall02758ac2017-05-24 16:20:28 -07001038 onfail="ONOS Leader Mismatch" )
Jeremy2f190ca2016-01-29 15:23:57 -08001039
1040 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001041
1042 def CASE2000( self, main ):
1043 """
1044 Add point intents between 2 hosts:
1045 - Get device ids | ports
1046 - Add point intents
1047 - Check intents
1048 - Verify flows
1049 - Ping hosts
1050 - Reroute
1051 - Link down
1052 - Verify flows
1053 - Check topology
1054 - Ping hosts
1055 - Link up
1056 - Verify flows
1057 - Check topology
1058 - Ping hosts
1059 - Remove intents
1060 """
Jeremydd9bda62016-04-18 12:02:32 -07001061 if main.initialized == main.FALSE:
1062 main.log.error( "Test components did not start correctly, skipping further tests" )
1063 main.skipCase()
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001064 # Assert variables - These variable's name|format must be followed
1065 # if you want to use the wrapper function
kelvin-onlab44147802015-07-27 17:57:31 -07001066 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -07001067 try:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001068 assert main.RESTs
Jeremydd9bda62016-04-18 12:02:32 -07001069 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001070 main.log.error( "There is no main.RESTs, skipping test cases" )
Jeremydd9bda62016-04-18 12:02:32 -07001071 main.initialized = main.FALSE
1072 main.skipCase()
1073 try:
1074 assert main.Mininet1
1075 except AssertionError:
1076 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1077 main.initialized = main.FALSE
1078 main.skipCase()
1079 try:
1080 assert main.numSwitch
1081 except AssertionError:
Jon Hall02758ac2017-05-24 16:20:28 -07001082 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001083 main.numSwitch )
Jeremydd9bda62016-04-18 12:02:32 -07001084 main.initialized = main.FALSE
1085 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001086
1087 main.case( "Point Intents Test - " + str( main.numCtrls ) +
Jon Hall02758ac2017-05-24 16:20:28 -07001088 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001089 main.caseExplanation = "This test case will test point to point" + \
1090 " intents using " + str( main.numCtrls ) + \
1091 " node(s) cluster;\n" + \
1092 "Different type of hosts will be tested in " + \
1093 "each step such as IPV4, Dual stack, VLAN etc" + \
1094 ";\nThe test will use OF " + main.OFProtocol + \
1095 " OVS running in Mininet and compile intents" + \
Jeremyeb51cb12016-03-28 17:53:35 -07001096 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001097
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001098 # No option point intent
kelvin-onlab44147802015-07-27 17:57:31 -07001099 main.step( "NOOPTION: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001100 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
1101 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001102 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy2f190ca2016-01-29 15:23:57 -08001103 ]
1104 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001105 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy2f190ca2016-01-29 15:23:57 -08001106 ]
1107 testResult = main.FALSE
1108 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001109 main,
1110 name="NOOPTION",
1111 senders=senders,
1112 recipients=recipients )
Jeremy2f190ca2016-01-29 15:23:57 -08001113
1114 if installResult:
1115 testResult = main.intentFunction.testPointIntent(
1116 main,
1117 intentId=installResult,
1118 name="NOOPTION",
1119 senders=senders,
1120 recipients=recipients,
1121 sw1="s5",
1122 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001123 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001124
1125 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001126 actual=testResult,
1127 onpass=main.assertReturnString,
1128 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001129
kelvin-onlab44147802015-07-27 17:57:31 -07001130 main.step( "IPV4: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001131 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
1132 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001133 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
Jeremy2f190ca2016-01-29 15:23:57 -08001134 ]
1135 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001136 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" }
Jeremy2f190ca2016-01-29 15:23:57 -08001137 ]
1138 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001139 main,
1140 name="IPV4",
1141 senders=senders,
1142 recipients=recipients,
1143 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -08001144
1145 if installResult:
1146 testResult = main.intentFunction.testPointIntent(
1147 main,
1148 intentId=installResult,
1149 name="IPV4",
1150 senders=senders,
1151 recipients=recipients,
1152 sw1="s5",
1153 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001154 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001155
1156 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001157 actual=testResult,
1158 onpass=main.assertReturnString,
1159 onfail=main.assertReturnString )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001160
alisonda157272016-12-22 01:13:21 -08001161 # main.step( "Protected: Add point intents between h1 and h9" )
1162 # main.assertReturnString = "Assertion Result for protected point intent\n"
1163 # senders = [
1164 # { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
1165 # ]
1166 # recipients = [
1167 # { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" }
1168 # ]
1169 # testResult = main.FALSE
1170 # installResult = main.intentFunction.installPointIntent(
1171 # main,
1172 # name="Protected",
1173 # senders=senders,
1174 # recipients=recipients,
1175 # protected=True )
Jon Hall02758ac2017-05-24 16:20:28 -07001176 #
alisonda157272016-12-22 01:13:21 -08001177 # if installResult:
1178 # testResult = main.intentFunction.testPointIntent(
1179 # main,
1180 # name="Protected",
1181 # intentId=installResult,
1182 # senders=senders,
1183 # recipients=recipients,
1184 # sw1="s5",
1185 # sw2="s2",
1186 # protected=True,
1187 # expectedLink=18 )
1188 #
1189 # utilities.assert_equals( expect=main.TRUE,
1190 # actual=testResult,
1191 # onpass=main.assertReturnString,
1192 # onfail=main.assertReturnString )
1193
kelvin-onlab44147802015-07-27 17:57:31 -07001194 main.step( "IPV4_2: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001195 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
1196 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001197 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy2f190ca2016-01-29 15:23:57 -08001198 ]
1199 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001200 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy2f190ca2016-01-29 15:23:57 -08001201 ]
1202 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001203 main,
1204 name="IPV4_2",
1205 senders=senders,
1206 recipients=recipients,
1207 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -08001208
1209 if installResult:
1210 testResult = main.intentFunction.testPointIntent(
1211 main,
1212 intentId=installResult,
1213 name="IPV4_2",
1214 senders=senders,
1215 recipients=recipients,
1216 sw1="s5",
1217 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001218 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001219
1220 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001221 actual=testResult,
1222 onpass=main.assertReturnString,
1223 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001224
kelvin-onlab0e684682015-08-11 18:51:41 -07001225 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001226 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
1227 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001228 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01",
1229 "ip": ( main.h1.hostIp + "/24" ) }
Jeremy2f190ca2016-01-29 15:23:57 -08001230 ]
1231 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001232 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09",
1233 "ip": ( main.h9.hostIp + "/24" ) }
Jeremy2f190ca2016-01-29 15:23:57 -08001234 ]
Jon Hall02758ac2017-05-24 16:20:28 -07001235 # ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001236 ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ]
kelvin-onlab44147802015-07-27 17:57:31 -07001237 # Uneccessary, not including this in the selectors
Jon Hall02758ac2017-05-24 16:20:28 -07001238 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
1239 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
kelvin-onlab44147802015-07-27 17:57:31 -07001240
Jeremy2f190ca2016-01-29 15:23:57 -08001241 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001242 main,
1243 name="SDNIP-ICMP",
1244 senders=senders,
1245 recipients=recipients,
1246 ethType="IPV4",
1247 ipProto=ipProto,
1248 tcpSrc=tcpSrc,
1249 tcpDst=tcpDst )
Jeremy2f190ca2016-01-29 15:23:57 -08001250
1251 if installResult:
1252 testResult = main.intentFunction.testPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001253 main,
1254 intentId=installResult,
1255 name="SDNIP_ICMP",
1256 senders=senders,
1257 recipients=recipients,
1258 sw1="s5",
1259 sw2="s2",
1260 expectedLink=18,
1261 useTCP=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001262
1263 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001264 actual=testResult,
1265 onpass=main.assertReturnString,
1266 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001267
kelvin-onlab0e684682015-08-11 18:51:41 -07001268 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001269 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
Jon Hall02758ac2017-05-24 16:20:28 -07001270 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
1271 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
1272 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
1273 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
1274 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
1275 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
1276 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
kelvin-onlab44147802015-07-27 17:57:31 -07001277
kelvin-onlab0e684682015-08-11 18:51:41 -07001278 stepResult = main.intentFunction.pointIntentTcp(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001279 main,
1280 name="SDNIP-TCP",
1281 host1="h1",
1282 host2="h9",
1283 deviceId1="of:0000000000000005/1",
1284 deviceId2="of:0000000000000006/1",
1285 mac1=mac1,
1286 mac2=mac2,
1287 ethType="IPV4",
1288 ipProto=ipProto,
1289 ip1=ip1,
1290 ip2=ip2,
1291 tcp1=tcp1,
1292 tcp2=tcp2 )
kelvin-onlab44147802015-07-27 17:57:31 -07001293
1294 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001295 actual=stepResult,
Jeremy2f190ca2016-01-29 15:23:57 -08001296 onpass=main.assertReturnString,
1297 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001298
Jeremy2f190ca2016-01-29 15:23:57 -08001299 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
1300 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
1301 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001302 { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
Jeremy2f190ca2016-01-29 15:23:57 -08001303 ]
1304 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001305 { "name": "h11", "device": "of:0000000000000006/3", "mac": "00:00:00:00:00:0B" }
Jeremy2f190ca2016-01-29 15:23:57 -08001306 ]
1307 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001308 main,
1309 name="DUALSTACK1",
1310 senders=senders,
1311 recipients=recipients,
1312 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -08001313
1314 if installResult:
1315 testResult = main.intentFunction.testPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001316 main,
1317 intentId=installResult,
1318 name="DUALSTACK1",
1319 senders=senders,
1320 recipients=recipients,
1321 sw1="s5",
1322 sw2="s2",
1323 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001324
1325 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001326 actual=testResult,
1327 onpass=main.assertReturnString,
1328 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001329
1330 main.step( "VLAN: Add point intents between h5 and h21" )
Jeremy2f190ca2016-01-29 15:23:57 -08001331 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
1332 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001333 { "name": "h5", "device": "of:0000000000000005/5", "mac": "00:00:00:00:00:05", "vlanId": "200" }
Jeremy2f190ca2016-01-29 15:23:57 -08001334 ]
1335 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001336 { "name": "h21", "device": "of:0000000000000007/5", "mac": "00:00:00:00:00:15", "vlanId": "200" }
Jeremy2f190ca2016-01-29 15:23:57 -08001337 ]
1338 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001339 main,
1340 name="VLAN",
1341 senders=senders,
1342 recipients=recipients )
Jeremy2f190ca2016-01-29 15:23:57 -08001343
1344 if installResult:
1345 testResult = main.intentFunction.testPointIntent(
1346 main,
1347 intentId=installResult,
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001348 name="VLAN",
Jeremy2f190ca2016-01-29 15:23:57 -08001349 senders=senders,
1350 recipients=recipients,
1351 sw1="s5",
1352 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001353 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001354
1355 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001356 actual=testResult,
1357 onpass=main.assertReturnString,
1358 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001359
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001360 # TODO: implement VLAN selector REST API intent test once supported
1361
kelvin-onlab44147802015-07-27 17:57:31 -07001362 main.step( "1HOP: Add point intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -08001363 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
1364 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001365 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
Jeremy2f190ca2016-01-29 15:23:57 -08001366 ]
1367 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001368 { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
Jeremy2f190ca2016-01-29 15:23:57 -08001369 ]
1370 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001371 main,
1372 name="1HOP IPV4",
1373 senders=senders,
1374 recipients=recipients,
1375 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -08001376
1377 if installResult:
1378 testResult = main.intentFunction.testPointIntent(
1379 main,
1380 intentId=installResult,
1381 name="1HOP IPV4",
1382 senders=senders,
1383 recipients=recipients,
1384 sw1="s5",
1385 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001386 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001387
1388 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001389 actual=testResult,
1390 onpass=main.assertReturnString,
1391 onfail=main.assertReturnString )
1392
1393 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001394
1395 def CASE3000( self, main ):
1396 """
1397 Add single point to multi point intents
1398 - Get device ids
1399 - Add single point to multi point intents
1400 - Check intents
1401 - Verify flows
1402 - Ping hosts
1403 - Reroute
1404 - Link down
1405 - Verify flows
1406 - Check topology
1407 - Ping hosts
1408 - Link up
1409 - Verify flows
1410 - Check topology
1411 - Ping hosts
1412 - Remove intents
1413 """
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001414 if main.initialized == main.FALSE:
1415 main.log.error( "Test components did not start correctly, skipping further tests" )
1416 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001417 assert main, "There is no main"
kelvin-onlab44147802015-07-27 17:57:31 -07001418
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001419 try:
1420 assert main.CLIs, "There is no main.CLIs, skipping test cases"
1421 assert main.Mininet1, "Mininet handle should be named Mininet1, skipping test cases"
1422 assert main.numSwitch, "Place the total number of switch topology in main.numSwitch"
1423 except AssertionError:
1424 main.initialized = main.FALSE
1425 main.skipCase()
1426
1427 main.testName = "Single to Multi Point Intents"
1428 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jon Hall02758ac2017-05-24 16:20:28 -07001429 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001430 main.caseExplanation = "This test case will test single point to" + \
1431 " multi point intents using " + \
1432 str( main.numCtrls ) + " node(s) cluster;\n" + \
1433 "Different type of hosts will be tested in " + \
1434 "each step such as IPV4, Dual stack, VLAN etc" + \
1435 ";\nThe test will use OF " + main.OFProtocol + \
1436 " OVS running in Mininet and compile intents" + \
Jeremyeb51cb12016-03-28 17:53:35 -07001437 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001438
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001439 main.step( "NOOPTION: Install and test single point to multi point intents" )
1440 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
1441 senders = [
1442 { "name": "h8", "device": "of:0000000000000005/8" }
1443 ]
1444 recipients = [
1445 { "name": "h16", "device": "of:0000000000000006/8" },
1446 { "name": "h24", "device": "of:0000000000000007/8" }
1447 ]
1448 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1449 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
1450 testResult = main.FALSE
1451 installResult = main.intentFunction.installSingleToMultiIntent(
1452 main,
1453 name="NOOPTION",
1454 senders=senders,
1455 recipients=recipients )
1456
1457 if installResult:
1458 testResult = main.intentFunction.testPointIntent(
1459 main,
1460 intentId=installResult,
1461 name="NOOPTION",
1462 senders=senders,
1463 recipients=recipients,
1464 badSenders=badSenders,
1465 badRecipients=badRecipients,
1466 sw1="s5",
1467 sw2="s2",
1468 expectedLink=18 )
1469 else:
1470 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001471
1472 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001473 actual=testResult,
1474 onpass=main.assertReturnString,
1475 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001476
Jon Hall02758ac2017-05-24 16:20:28 -07001477 main.step( "IPV4: Install and test single point to multi point intents" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001478 main.assertReturnString = "Assertion results for IPV4 single to multi point intent " \
1479 "with IPV4 type and MAC addresses\n"
1480 senders = [
Jon Hall02758ac2017-05-24 16:20:28 -07001481 { "name": "h8", "device": "of:0000000000000005/8", "mac": "00:00:00:00:00:08" }
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001482 ]
1483 recipients = [
Jon Hall02758ac2017-05-24 16:20:28 -07001484 { "name": "h16", "device": "of:0000000000000006/8", "mac": "00:00:00:00:00:10" },
1485 { "name": "h24", "device": "of:0000000000000007/8", "mac": "00:00:00:00:00:18" }
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001486 ]
Jon Hall02758ac2017-05-24 16:20:28 -07001487 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1488 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001489 installResult = main.intentFunction.installSingleToMultiIntent(
1490 main,
1491 name="IPV4",
1492 senders=senders,
1493 recipients=recipients,
Jon Hall02758ac2017-05-24 16:20:28 -07001494 ethType="IPV4" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001495
1496 if installResult:
1497 testResult = main.intentFunction.testPointIntent(
1498 main,
1499 intentId=installResult,
1500 name="IPV4",
1501 senders=senders,
1502 recipients=recipients,
1503 badSenders=badSenders,
1504 badRecipients=badRecipients,
1505 sw1="s5",
1506 sw2="s2",
1507 expectedLink=18 )
1508 else:
1509 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001510
1511 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001512 actual=testResult,
1513 onpass=main.assertReturnString,
1514 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001515
1516 main.step( "IPV4_2: Add single point to multi point intents" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001517 main.assertReturnString = "Assertion results for IPV4 single to multi point intent " \
1518 "with IPV4 type and no MAC addresses\n"
1519 senders = [
1520 { "name": "h8", "device": "of:0000000000000005/8" }
1521 ]
1522 recipients = [
1523 { "name": "h16", "device": "of:0000000000000006/8" },
1524 { "name": "h24", "device": "of:0000000000000007/8" }
1525 ]
1526 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1527 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
1528 installResult = main.intentFunction.installSingleToMultiIntent(
1529 main,
1530 name="IPV4_2",
1531 senders=senders,
1532 recipients=recipients,
1533 ethType="IPV4" )
1534
1535 if installResult:
1536 testResult = main.intentFunction.testPointIntent(
1537 main,
1538 intentId=installResult,
1539 name="IPV4_2",
1540 senders=senders,
1541 recipients=recipients,
1542 badSenders=badSenders,
1543 badRecipients=badRecipients,
1544 sw1="s5",
1545 sw2="s2",
1546 expectedLink=18 )
1547 else:
1548 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001549
1550 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001551 actual=testResult,
1552 onpass=main.assertReturnString,
1553 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001554
1555 main.step( "VLAN: Add single point to multi point intents" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001556 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type " \
1557 "and MAC addresses in the same VLAN\n"
1558 senders = [
1559 { "name": "h4", "device": "of:0000000000000005/4", "mac": "00:00:00:00:00:04", "vlan": "100" }
1560 ]
1561 recipients = [
1562 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1563 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
1564 ]
1565 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1566 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
1567 installResult = main.intentFunction.installSingleToMultiIntent(
1568 main,
1569 name="VLAN",
1570 senders=senders,
1571 recipients=recipients,
1572 sw1="s5",
1573 sw2="s2" )
1574
1575 if installResult:
1576 testResult = main.intentFunction.testPointIntent(
1577 main,
1578 intentId=installResult,
1579 name="VLAN",
1580 senders=senders,
1581 recipients=recipients,
1582 badSenders=badSenders,
1583 badRecipients=badRecipients,
1584 sw1="s5",
1585 sw2="s2",
1586 expectedLink=18 )
1587 else:
1588 main.CLIs[ 0 ].removeAllIntents()
kelvin-onlab44147802015-07-27 17:57:31 -07001589
1590 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001591 actual=testResult,
1592 onpass=main.assertReturnString,
1593 onfail=main.assertReturnString )
1594
1595 main.step( "VLAN: Add single point to multi point intents" )
1596 main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n"
1597 senders = [
1598 { "name": "h5", "vlan": "200" }
1599 ]
1600 recipients = [
1601 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1602 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
1603 ]
1604 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1605 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
1606 testResult = main.FALSE
1607 installResult = main.intentFunction.installSingleToMultiIntent(
1608 main,
1609 name="VLAN2",
1610 senders=senders,
1611 recipients=recipients,
1612 sw1="s5",
1613 sw2="s2" )
Jon Hall02758ac2017-05-24 16:20:28 -07001614 #setVlan=100 )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001615
1616 if installResult:
1617 testResult = main.intentFunction.testPointIntent(
1618 main,
1619 intentId=installResult,
1620 name="VLAN2",
1621 senders=senders,
1622 recipients=recipients,
1623 badSenders=badSenders,
1624 badRecipients=badRecipients,
1625 sw1="s5",
1626 sw2="s2",
1627 expectedLink=18 )
1628 else:
1629 main.CLIs[ 0 ].removeAllIntents()
1630
1631 utilities.assert_equals( expect=main.TRUE,
1632 actual=testResult,
1633 onpass=main.assertReturnString,
1634 onfail=main.assertReturnString )
1635
1636 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001637
1638 def CASE4000( self, main ):
1639 """
1640 Add multi point to single point intents
1641 - Get device ids
1642 - Add multi point to single point intents
1643 - Check intents
1644 - Verify flows
1645 - Ping hosts
1646 - Reroute
1647 - Link down
1648 - Verify flows
1649 - Check topology
1650 - Ping hosts
1651 - Link up
1652 - Verify flows
1653 - Check topology
1654 - Ping hosts
1655 - Remove intents
1656 """
1657 assert main, "There is no main"
1658 assert main.CLIs, "There is no main.CLIs"
1659 assert main.Mininet1, "Mininet handle should be named Mininet1"
1660 assert main.numSwitch, "Placed the total number of switch topology in \
1661 main.numSwitch"
1662
1663 main.case( "Multi To Single Point Intents Test - " +
Jeremyeb51cb12016-03-28 17:53:35 -07001664 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -07001665 main.caseExplanation = "This test case will test single point to" +\
1666 " multi point intents using " +\
1667 str( main.numCtrls ) + " node(s) cluster;\n" +\
1668 "Different type of hosts will be tested in " +\
1669 "each step such as IPV4, Dual stack, VLAN etc" +\
1670 ";\nThe test will use OF " + main.OFProtocol +\
Jeremyeb51cb12016-03-28 17:53:35 -07001671 " OVS running in Mininet and compile intents" +\
1672 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001673
1674 main.step( "NOOPTION: Add multi point to single point intents" )
1675 stepResult = main.TRUE
1676 hostNames = [ 'h8', 'h16', 'h24' ]
Jon Hall02758ac2017-05-24 16:20:28 -07001677 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8',
kelvin-onlab44147802015-07-27 17:57:31 -07001678 'of:0000000000000007/8' ]
1679 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
1680 stepResult = main.intentFunction.multiToSingleIntent(
1681 main,
1682 name="NOOPTION",
1683 hostNames=hostNames,
1684 devices=devices,
1685 sw1="s5",
1686 sw2="s2",
1687 expectedLink=18 )
1688
1689 utilities.assert_equals( expect=main.TRUE,
1690 actual=stepResult,
1691 onpass="NOOPTION: Successfully added multi "
1692 + " point to single point intents" +
1693 " with no match action",
1694 onfail="NOOPTION: Failed to add multi point" +
1695 " to single point intents" +
1696 " with no match action" )
1697
1698 main.step( "IPV4: Add multi point to single point intents" )
1699 stepResult = main.TRUE
1700 stepResult = main.intentFunction.multiToSingleIntent(
1701 main,
1702 name="IPV4",
1703 hostNames=hostNames,
1704 devices=devices,
1705 ports=None,
1706 ethType="IPV4",
1707 macs=macs,
1708 bandwidth="",
1709 lambdaAlloc=False,
1710 ipProto="",
1711 ipAddresses="",
1712 tcp="",
1713 sw1="s5",
1714 sw2="s2",
1715 expectedLink=18 )
1716
1717 utilities.assert_equals( expect=main.TRUE,
1718 actual=stepResult,
1719 onpass="IPV4: Successfully added multi point"
1720 + " to single point intents" +
1721 " with IPV4 type and MAC addresses",
1722 onfail="IPV4: Failed to add multi point" +
1723 " to single point intents" +
1724 " with IPV4 type and MAC addresses" )
1725
1726 main.step( "IPV4_2: Add multi point to single point intents" )
1727 stepResult = main.TRUE
1728 hostNames = [ 'h8', 'h16', 'h24' ]
1729 stepResult = main.intentFunction.multiToSingleIntent(
1730 main,
1731 name="IPV4",
1732 hostNames=hostNames,
1733 ethType="IPV4",
1734 lambdaAlloc=False )
1735
1736 utilities.assert_equals( expect=main.TRUE,
1737 actual=stepResult,
1738 onpass="IPV4_2: Successfully added multi point"
1739 + " to single point intents" +
1740 " with IPV4 type and no MAC addresses",
1741 onfail="IPV4_2: Failed to add multi point" +
1742 " to single point intents" +
1743 " with IPV4 type and no MAC addresses" )
1744
1745 main.step( "VLAN: Add multi point to single point intents" )
1746 stepResult = main.TRUE
1747 hostNames = [ 'h5', 'h13', 'h21' ]
Jon Hall02758ac2017-05-24 16:20:28 -07001748 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5',
kelvin-onlab44147802015-07-27 17:57:31 -07001749 'of:0000000000000007/5' ]
1750 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
1751 stepResult = main.intentFunction.multiToSingleIntent(
1752 main,
1753 name="VLAN",
1754 hostNames=hostNames,
1755 devices=devices,
1756 ports=None,
1757 ethType="IPV4",
1758 macs=macs,
1759 bandwidth="",
1760 lambdaAlloc=False,
1761 ipProto="",
1762 ipAddresses="",
1763 tcp="",
1764 sw1="s5",
1765 sw2="s2",
1766 expectedLink=18 )
1767
1768 utilities.assert_equals( expect=main.TRUE,
1769 actual=stepResult,
1770 onpass="VLAN: Successfully added multi point"
1771 + " to single point intents" +
1772 " with IPV4 type and MAC addresses" +
1773 " in the same VLAN",
1774 onfail="VLAN: Failed to add multi point" +
1775 " to single point intents" )
1776
1777 def CASE5000( self, main ):
1778 """
Jeremy2f190ca2016-01-29 15:23:57 -08001779 Tests Host Mobility
1780 Modifies the topology location of h1
kelvin-onlab44147802015-07-27 17:57:31 -07001781 """
Jeremydd9bda62016-04-18 12:02:32 -07001782 if main.initialized == main.FALSE:
1783 main.log.error( "Test components did not start correctly, skipping further tests" )
1784 main.skipCase()
1785 # Assert variables - These variable's name|format must be followed
1786 # if you want to use the wrapper function
kelvin-onlab44147802015-07-27 17:57:31 -07001787 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -07001788 try:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001789 assert main.RESTs
Jeremydd9bda62016-04-18 12:02:32 -07001790 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001791 main.log.error( "There is no main.RESTs, skipping test cases" )
Jeremydd9bda62016-04-18 12:02:32 -07001792 main.initialized = main.FALSE
1793 main.skipCase()
1794 try:
1795 assert main.Mininet1
1796 except AssertionError:
1797 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1798 main.initialized = main.FALSE
1799 main.skipCase()
1800 try:
1801 assert main.numSwitch
1802 except AssertionError:
Jon Hall02758ac2017-05-24 16:20:28 -07001803 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001804 main.numSwitch )
Jeremydd9bda62016-04-18 12:02:32 -07001805 main.initialized = main.FALSE
1806 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001807 main.case( "Test host mobility with host intents " )
Jeremy2f190ca2016-01-29 15:23:57 -08001808 main.step( "Testing host mobility by moving h1 from s5 to s6" )
kelvin-onlab44147802015-07-27 17:57:31 -07001809 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1810
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001811 main.log.info( "Moving h1 from s5 to s6" )
1812 main.Mininet1.moveHost( "h1", "s5", "s6" )
kelvin-onlab44147802015-07-27 17:57:31 -07001813
Jeremy2f190ca2016-01-29 15:23:57 -08001814 # Send discovery ping from moved host
1815 # Moving the host brings down the default interfaces and creates a new one.
1816 # Scapy is restarted on this host to detect the new interface
1817 main.h1.stopScapy()
1818 main.h1.startScapy()
1819
1820 # Discover new host location in ONOS and populate host data.
1821 # Host 1 IP and MAC should be unchanged
1822 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
1823 main.intentFunction.populateHostData( main )
1824
kelvin-onlab44147802015-07-27 17:57:31 -07001825 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1826
1827 utilities.assert_equals( expect="of:0000000000000006",
1828 actual=h1PostMove,
1829 onpass="Mobility: Successfully moved h1 to s6",
Jeremy2f190ca2016-01-29 15:23:57 -08001830 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlab44147802015-07-27 17:57:31 -07001831 " to single point intents" +
1832 " with IPV4 type and MAC addresses" +
1833 " in the same VLAN" )
1834
1835 main.step( "IPV4: Add host intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001836 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
Jon Hall02758ac2017-05-24 16:20:28 -07001837 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
1838 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy2f190ca2016-01-29 15:23:57 -08001839
1840 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -07001841 name='IPV4 Mobility IPV4',
1842 onosNode='0',
1843 host1=host1,
1844 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -08001845 if installResult:
1846 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -07001847 name='Host Mobility IPV4',
1848 intentId=installResult,
1849 onosNode='0',
1850 host1=host1,
1851 host2=host2,
1852 sw1="s6",
1853 sw2="s2",
1854 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001855
1856 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001857 actual=testResult,
1858 onpass=main.assertReturnString,
1859 onfail=main.assertReturnString )
1860
Jon Hallbd60ea02016-08-23 10:03:59 -07001861 main.intentFunction.report( main )