blob: 7d220dc5563d65f99d98f01a1536ac06f9c879de [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
129 if gitPull == 'True':
130 main.step( "Building ONOS in " + gitBranch + " branch" )
131 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
132 stepResult = onosBuildResult
133 utilities.assert_equals( expect=main.TRUE,
134 actual=stepResult,
135 onpass="Successfully compiled " +
136 "latest ONOS",
137 onfail="Failed to compile " +
138 "latest ONOS" )
139 else:
140 main.log.warn( "Did not pull new code so skipping mvn " +
141 "clean install" )
142 main.ONOSbench.getVersion( report=True )
143
144 def CASE2( self, main ):
145 """
146 - Set up cell
147 - Create cell file
148 - Set cell file
149 - Verify cell file
150 - Kill ONOS process
151 - Uninstall ONOS cluster
152 - Verify ONOS start up
153 - Install ONOS cluster
154 - Connect to cli
155 """
Jeremy Songster17147f22016-05-31 18:30:52 -0700156 main.cycle += 1
157
kelvin-onlab44147802015-07-27 17:57:31 -0700158 # main.scale[ 0 ] determines the current number of ONOS controller
159 main.numCtrls = int( main.scale[ 0 ] )
Jeremyeb51cb12016-03-28 17:53:35 -0700160 main.flowCompiler = "Flow Rules"
Jeremydd9bda62016-04-18 12:02:32 -0700161 main.initialized = main.TRUE
kelvin-onlab44147802015-07-27 17:57:31 -0700162
163 main.case( "Starting up " + str( main.numCtrls ) +
164 " node(s) ONOS cluster" )
165 main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
166 " node(s) ONOS cluster"
167
kelvin-onlab44147802015-07-27 17:57:31 -0700168 #kill off all onos processes
169 main.log.info( "Safety check, killing all ONOS processes" +
Jon Hall70b2ff42015-11-17 15:49:44 -0800170 " before initiating environment setup" )
kelvin-onlab44147802015-07-27 17:57:31 -0700171
Jeremy2f190ca2016-01-29 15:23:57 -0800172 time.sleep( main.startUpSleep )
Jeremy42df2e72016-02-23 16:37:46 -0800173
Jeremy2f190ca2016-01-29 15:23:57 -0800174 main.step( "Uninstalling ONOS package" )
175 onosUninstallResult = main.TRUE
176 for ip in main.ONOSip:
177 onosUninstallResult = onosUninstallResult and \
178 main.ONOSbench.onosUninstall( nodeIp=ip )
179 stepResult = onosUninstallResult
180 utilities.assert_equals( expect=main.TRUE,
181 actual=stepResult,
182 onpass="Successfully uninstalled ONOS package",
183 onfail="Failed to uninstall ONOS package" )
184
Jeremy42df2e72016-02-23 16:37:46 -0800185 time.sleep( main.startUpSleep )
186
kelvin-onlab44147802015-07-27 17:57:31 -0700187 for i in range( main.maxNodes ):
188 main.ONOSbench.onosDie( main.ONOSip[ i ] )
189
190 print "NODE COUNT = ", main.numCtrls
191
192 tempOnosIp = []
193 for i in range( main.numCtrls ):
Jon Hall02758ac2017-05-24 16:20:28 -0700194 tempOnosIp.append( main.ONOSip[ i ] )
kelvin-onlab44147802015-07-27 17:57:31 -0700195
196 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
197 "temp", main.Mininet1.ip_address,
198 main.apps, tempOnosIp )
199
200 main.step( "Apply cell to environment" )
201 cellResult = main.ONOSbench.setCell( "temp" )
202 verifyResult = main.ONOSbench.verifyCell()
203 stepResult = cellResult and verifyResult
204 utilities.assert_equals( expect=main.TRUE,
205 actual=stepResult,
Jon Hall02758ac2017-05-24 16:20:28 -0700206 onpass="Successfully applied cell to " +
kelvin-onlab44147802015-07-27 17:57:31 -0700207 "environment",
208 onfail="Failed to apply cell to environment " )
209
210 main.step( "Creating ONOS package" )
Jon Hallbd60ea02016-08-23 10:03:59 -0700211 packageResult = main.ONOSbench.buckBuild()
kelvin-onlab44147802015-07-27 17:57:31 -0700212 stepResult = packageResult
213 utilities.assert_equals( expect=main.TRUE,
214 actual=stepResult,
215 onpass="Successfully created ONOS package",
216 onfail="Failed to create ONOS package" )
217
218 time.sleep( main.startUpSleep )
kelvin-onlab44147802015-07-27 17:57:31 -0700219 main.step( "Installing ONOS package" )
220 onosInstallResult = main.TRUE
221 for i in range( main.numCtrls ):
222 onosInstallResult = onosInstallResult and \
223 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
224 stepResult = onosInstallResult
225 utilities.assert_equals( expect=main.TRUE,
226 actual=stepResult,
227 onpass="Successfully installed ONOS package",
228 onfail="Failed to install ONOS package" )
229
You Wangf5de25b2017-01-06 15:13:01 -0800230 main.step( "Set up ONOS secure SSH" )
231 secureSshResult = main.TRUE
232 for i in range( int( main.numCtrls ) ):
Jon Hall02758ac2017-05-24 16:20:28 -0700233 secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[ i ] )
You Wangf5de25b2017-01-06 15:13:01 -0800234 utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
235 onpass="Test step PASS",
236 onfail="Test step FAIL" )
237
kelvin-onlab44147802015-07-27 17:57:31 -0700238 time.sleep( main.startUpSleep )
239 main.step( "Starting ONOS service" )
240 stopResult = main.TRUE
241 startResult = main.TRUE
242 onosIsUp = main.TRUE
243
244 for i in range( main.numCtrls ):
245 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
Jeremydd9bda62016-04-18 12:02:32 -0700246 if onosIsUp == main.TRUE:
247 main.log.report( "ONOS instance {0} is up and ready".format( i + 1 ) )
248 else:
249 main.log.report( "ONOS instance {0} may not be up, stop and ".format( i + 1 ) +
250 "start ONOS again " )
251 stopResult = stopResult and main.ONOSbench.onosStop( main.ONOSip[ i ] )
252 startResult = startResult and main.ONOSbench.onosStart( main.ONOSip[ i ] )
253 if not startResult or stopResult:
254 main.log.report( "ONOS instance {0} did not start correctly.".format( i + 1 ) )
kelvin-onlab44147802015-07-27 17:57:31 -0700255 stepResult = onosIsUp and stopResult and startResult
256 utilities.assert_equals( expect=main.TRUE,
257 actual=stepResult,
258 onpass="ONOS service is ready",
259 onfail="ONOS service did not start properly" )
Jeremydd9bda62016-04-18 12:02:32 -0700260 if not stepResult:
261 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700262
Jeremy2f190ca2016-01-29 15:23:57 -0800263 # Start an ONOS cli to provide functionality that is not currently
Jeremye1ea0602016-02-08 16:35:05 -0800264 # supported by the Rest API remove this when Leader Checking is supported
265 # by the REST API
Jeremy2f190ca2016-01-29 15:23:57 -0800266
Jeremye1ea0602016-02-08 16:35:05 -0800267 main.step( "Start ONOS cli" )
268 cliResult = main.TRUE
269 for i in range( main.numCtrls ):
270 cliResult = cliResult and \
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700271 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
Jeremye1ea0602016-02-08 16:35:05 -0800272 stepResult = cliResult
273 utilities.assert_equals( expect=main.TRUE,
274 actual=stepResult,
275 onpass="Successfully start ONOS cli",
276 onfail="Failed to start ONOS cli" )
Jeremydd9bda62016-04-18 12:02:32 -0700277 if not stepResult:
278 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800279
kelvin-onlab44147802015-07-27 17:57:31 -0700280 # Remove the first element in main.scale list
281 main.scale.remove( main.scale[ 0 ] )
282
Jeremy2f190ca2016-01-29 15:23:57 -0800283 main.intentFunction.report( main )
284
kelvin-onlab44147802015-07-27 17:57:31 -0700285 def CASE8( self, main ):
Jeremy2f190ca2016-01-29 15:23:57 -0800286 # OLD FUNCintentRest CASE 8
287 # This remains here for archiving and reference purposes and will be
288 # removed when the new FUNCintentRest is verified to work.
289 # """
290 # Compare Topo
291 # """
292 # import json
293
294 # main.case( "Compare ONOS Topology view to Mininet topology" )
295 # main.caseExplanation = "Compare topology elements between Mininet" +\
296 # " and ONOS"
297
298 # main.step( "Gathering topology information" )
299 # # TODO: add a paramaterized sleep here
300 # devicesResults = main.TRUE # Overall Boolean for device correctness
301 # linksResults = main.TRUE # Overall Boolean for link correctness
302 # hostsResults = main.TRUE # Overall Boolean for host correctness
303 # devices = main.topo.getAllDevices( main )
304 # hosts = main.topo.getAllHosts( main )
305 # ports = main.topo.getAllPorts( main )
306 # links = main.topo.getAllLinks( main )
307 # clusters = main.topo.getAllClusters( main )
308
309 # mnSwitches = main.Mininet1.getSwitches()
310 # mnLinks = main.Mininet1.getLinks()
311 # mnHosts = main.Mininet1.getHosts()
312
313 # main.step( "Comparing MN topology to ONOS topology" )
314 # for controller in range( main.numCtrls ):
315 # controllerStr = str( controller + 1 )
316 # if devices[ controller ] and ports[ controller ] and\
317 # "Error" not in devices[ controller ] and\
318 # "Error" not in ports[ controller ]:
319
320 # currentDevicesResult = main.Mininet1.compareSwitches(
321 # mnSwitches,
322 # json.loads( devices[ controller ] ),
323 # json.loads( ports[ controller ] ) )
324 # else:
325 # currentDevicesResult = main.FALSE
326 # utilities.assert_equals( expect=main.TRUE,
327 # actual=currentDevicesResult,
328 # onpass="ONOS" + controllerStr +
329 # " Switches view is correct",
330 # onfail="ONOS" + controllerStr +
331 # " Switches view is incorrect" )
332
333 # if links[ controller ] and "Error" not in links[ controller ]:
334 # currentLinksResult = main.Mininet1.compareLinks(
335 # mnSwitches, mnLinks,
336 # json.loads( links[ controller ] ) )
337 # else:
338 # currentLinksResult = main.FALSE
339 # utilities.assert_equals( expect=main.TRUE,
340 # actual=currentLinksResult,
341 # onpass="ONOS" + controllerStr +
342 # " links view is correct",
343 # onfail="ONOS" + controllerStr +
344 # " links view is incorrect" )
345
346 # if hosts[ controller ] or "Error" not in hosts[ controller ]:
347 # currentHostsResult = main.Mininet1.compareHosts(
348 # mnHosts,
349 # json.loads( hosts[ controller ] ) )
350 # else:
351 # currentHostsResult = main.FALSE
352 # utilities.assert_equals( expect=main.TRUE,
353 # actual=currentHostsResult,
354 # onpass="ONOS" + controllerStr +
355 # " hosts exist in Mininet",
356 # onfail="ONOS" + controllerStr +
357 # " hosts don't match Mininet" )
358
359 # NEW FUNCintentRest Case 8 as based off of the CASE 8 from FUNCintent
kelvin-onlab44147802015-07-27 17:57:31 -0700360 """
Jeremy2f190ca2016-01-29 15:23:57 -0800361 Compare ONOS Topology to Mininet Topology
kelvin-onlab44147802015-07-27 17:57:31 -0700362 """
363 import json
364
365 main.case( "Compare ONOS Topology view to Mininet topology" )
366 main.caseExplanation = "Compare topology elements between Mininet" +\
367 " and ONOS"
368
Jeremy2f190ca2016-01-29 15:23:57 -0800369 main.log.info( "Gathering topology information from Mininet" )
370 devicesResults = main.FALSE # Overall Boolean for device correctness
371 linksResults = main.FALSE # Overall Boolean for link correctness
372 hostsResults = main.FALSE # Overall Boolean for host correctness
373 deviceFails = [] # Nodes where devices are incorrect
374 linkFails = [] # Nodes where links are incorrect
375 hostFails = [] # Nodes where hosts are incorrect
376 attempts = main.checkTopoAttempts # Remaining Attempts
kelvin-onlab44147802015-07-27 17:57:31 -0700377
378 mnSwitches = main.Mininet1.getSwitches()
379 mnLinks = main.Mininet1.getLinks()
380 mnHosts = main.Mininet1.getHosts()
381
Jeremy2f190ca2016-01-29 15:23:57 -0800382 main.step( "Comparing Mininet topology to ONOS topology" )
kelvin-onlab44147802015-07-27 17:57:31 -0700383
Jeremy2f190ca2016-01-29 15:23:57 -0800384 while ( attempts >= 0 ) and\
Jon Hall02758ac2017-05-24 16:20:28 -0700385 ( not devicesResults or not linksResults or not hostsResults ):
Jeremy2f190ca2016-01-29 15:23:57 -0800386 time.sleep( 2 )
387 if not devicesResults:
388 devices = main.topo.getAllDevices( main )
389 ports = main.topo.getAllPorts( main )
390 devicesResults = main.TRUE
391 deviceFails = [] # Reset for each failed attempt
392 if not linksResults:
393 links = main.topo.getAllLinks( main )
394 linksResults = main.TRUE
395 linkFails = [] # Reset for each failed attempt
396 if not hostsResults:
397 hosts = main.topo.getAllHosts( main )
398 hostsResults = main.TRUE
399 hostFails = [] # Reset for each failed attempt
kelvin-onlab44147802015-07-27 17:57:31 -0700400
Jeremy2f190ca2016-01-29 15:23:57 -0800401 # Check for matching topology on each node
402 for controller in range( main.numCtrls ):
403 controllerStr = str( controller + 1 ) # ONOS node number
404 # Compare Devices
405 if devices[ controller ] and ports[ controller ] and\
Jon Hall02758ac2017-05-24 16:20:28 -0700406 "Error" not in devices[ controller ] and\
407 "Error" not in ports[ controller ]:
kelvin-onlab44147802015-07-27 17:57:31 -0700408
Jeremy2f190ca2016-01-29 15:23:57 -0800409 try:
410 deviceData = json.loads( devices[ controller ] )
411 portData = json.loads( ports[ controller ] )
Jon Hall02758ac2017-05-24 16:20:28 -0700412 except ( TypeError, ValueError ):
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700413 main.log.error( "Could not load json: {0} or {1}".format( str( devices[ controller ] ),
414 str( ports[ controller ] ) ) )
Jeremy2f190ca2016-01-29 15:23:57 -0800415 currentDevicesResult = main.FALSE
416 else:
417 currentDevicesResult = main.Mininet1.compareSwitches(
Jon Hall02758ac2017-05-24 16:20:28 -0700418 mnSwitches, deviceData, portData )
Jeremy2f190ca2016-01-29 15:23:57 -0800419 else:
420 currentDevicesResult = main.FALSE
421 if not currentDevicesResult:
422 deviceFails.append( controllerStr )
423 devicesResults = devicesResults and currentDevicesResult
424 # Compare Links
425 if links[ controller ] and "Error" not in links[ controller ]:
426 try:
427 linkData = json.loads( links[ controller ] )
Jon Hall02758ac2017-05-24 16:20:28 -0700428 except ( TypeError, ValueError ):
429 main.log.error( "Could not load json:" + str( links[ controller ] ) )
Jeremy2f190ca2016-01-29 15:23:57 -0800430 currentLinksResult = main.FALSE
431 else:
432 currentLinksResult = main.Mininet1.compareLinks(
Jon Hall02758ac2017-05-24 16:20:28 -0700433 mnSwitches, mnLinks, linkData )
Jeremy2f190ca2016-01-29 15:23:57 -0800434 else:
435 currentLinksResult = main.FALSE
436 if not currentLinksResult:
437 linkFails.append( controllerStr )
438 linksResults = linksResults and currentLinksResult
439 # Compare Hosts
440 if hosts[ controller ] and "Error" not in hosts[ controller ]:
441 try:
442 hostData = json.loads( hosts[ controller ] )
Jon Hall02758ac2017-05-24 16:20:28 -0700443 except ( TypeError, ValueError ):
444 main.log.error( "Could not load json:" + str( hosts[ controller ] ) )
Jeremy2f190ca2016-01-29 15:23:57 -0800445 currentHostsResult = main.FALSE
446 else:
447 currentHostsResult = main.Mininet1.compareHosts(
Jon Hall02758ac2017-05-24 16:20:28 -0700448 mnHosts, hostData )
Jeremy2f190ca2016-01-29 15:23:57 -0800449 else:
450 currentHostsResult = main.FALSE
451 if not currentHostsResult:
452 hostFails.append( controllerStr )
453 hostsResults = hostsResults and currentHostsResult
454 # Decrement Attempts Remaining
455 attempts -= 1
456
Jeremy2f190ca2016-01-29 15:23:57 -0800457 utilities.assert_equals( expect=[],
458 actual=deviceFails,
459 onpass="ONOS correctly discovered all devices",
460 onfail="ONOS incorrectly discovered devices on nodes: " +
461 str( deviceFails ) )
462 utilities.assert_equals( expect=[],
463 actual=linkFails,
464 onpass="ONOS correctly discovered all links",
465 onfail="ONOS incorrectly discovered links on nodes: " +
466 str( linkFails ) )
467 utilities.assert_equals( expect=[],
468 actual=hostFails,
469 onpass="ONOS correctly discovered all hosts",
470 onfail="ONOS incorrectly discovered hosts on nodes: " +
471 str( hostFails ) )
472 topoResults = hostsResults and linksResults and devicesResults
473 utilities.assert_equals( expect=main.TRUE,
474 actual=topoResults,
475 onpass="ONOS correctly discovered the topology",
476 onfail="ONOS incorrectly discovered the topology" )
kelvin-onlab44147802015-07-27 17:57:31 -0700477
478 def CASE9( self, main ):
Jon Hall02758ac2017-05-24 16:20:28 -0700479 """
kelvin-onlab44147802015-07-27 17:57:31 -0700480 Report errors/warnings/exceptions
Jon Hall02758ac2017-05-24 16:20:28 -0700481 """
kelvin-onlab44147802015-07-27 17:57:31 -0700482 main.log.info( "Error report: \n" )
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700483 main.ONOSbench.logReport( globalONOSip[ 0 ],
Jon Hall02758ac2017-05-24 16:20:28 -0700484 [ "INFO", "FOLLOWER", "WARN", "flow", "ERROR", "Except" ],
485 "s" )
486 #main.ONOSbench.logReport( globalONOSip[ 1 ], [ "INFO" ], "d" )
kelvin-onlab44147802015-07-27 17:57:31 -0700487
488 def CASE10( self, main ):
489 """
490 Start Mininet topology with OF 1.0 switches
491 """
Jeremydd9bda62016-04-18 12:02:32 -0700492 if main.initialized == main.FALSE:
493 main.log.error( "Test components did not start correctly, skipping further tests" )
494 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700495 main.OFProtocol = "1.0"
496 main.log.report( "Start Mininet topology with OF 1.0 switches" )
497 main.case( "Start Mininet topology with OF 1.0 switches" )
498 main.caseExplanation = "Start mininet topology with OF 1.0 " +\
499 "switches to test intents, exits out if " +\
500 "topology did not start correctly"
501
502 main.step( "Starting Mininet topology with OF 1.0 switches" )
503 args = "--switch ovs,protocols=OpenFlow10"
504 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
505 main.topology,
506 args=args )
507 stepResult = topoResult
508 utilities.assert_equals( expect=main.TRUE,
509 actual=stepResult,
510 onpass="Successfully loaded topology",
511 onfail="Failed to load topology" )
512 # Exit if topology did not load properly
513 if not topoResult:
Jeremydd9bda62016-04-18 12:02:32 -0700514 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700515
516 def CASE11( self, main ):
517 """
518 Start Mininet topology with OF 1.3 switches
519 """
Jeremydd9bda62016-04-18 12:02:32 -0700520 if main.initialized == main.FALSE:
521 main.log.error( "Test components did not start correctly, skipping further tests" )
522 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700523 main.OFProtocol = "1.3"
524 main.log.report( "Start Mininet topology with OF 1.3 switches" )
525 main.case( "Start Mininet topology with OF 1.3 switches" )
526 main.caseExplanation = "Start mininet topology with OF 1.3 " +\
527 "switches to test intents, exits out if " +\
528 "topology did not start correctly"
529
530 main.step( "Starting Mininet topology with OF 1.3 switches" )
531 args = "--switch ovs,protocols=OpenFlow13"
532 topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath +
533 main.topology,
534 args=args )
535 stepResult = topoResult
536 utilities.assert_equals( expect=main.TRUE,
537 actual=stepResult,
538 onpass="Successfully loaded topology",
539 onfail="Failed to load topology" )
540 # Exit if topology did not load properly
541 if not topoResult:
Jeremydd9bda62016-04-18 12:02:32 -0700542 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700543
544 def CASE12( self, main ):
545 """
546 Assign mastership to controllers
547 """
548 import re
549
Jeremydd9bda62016-04-18 12:02:32 -0700550 if main.initialized == main.FALSE:
551 main.log.error( "Test components did not start correctly, skipping further tests" )
552 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700553 main.case( "Assign switches to controllers" )
554 main.step( "Assigning switches to controllers" )
555 main.caseExplanation = "Assign OF " + main.OFProtocol +\
556 " switches to ONOS nodes"
557
558 assignResult = main.TRUE
559 switchList = []
560
561 # Creates a list switch name, use getSwitch() function later...
562 for i in range( 1, ( main.numSwitch + 1 ) ):
563 switchList.append( 's' + str( i ) )
564
565 tempONOSip = []
566 for i in range( main.numCtrls ):
567 tempONOSip.append( main.ONOSip[ i ] )
568
569 assignResult = main.Mininet1.assignSwController( sw=switchList,
570 ip=tempONOSip,
Charles Chan029be652015-08-24 01:46:10 +0800571 port='6653' )
kelvin-onlab44147802015-07-27 17:57:31 -0700572 if not assignResult:
Jeremydd9bda62016-04-18 12:02:32 -0700573 main.log.error( "Problem assigning mastership of switches, skipping further test cases" )
574 main.initialized = main.FALSE
575 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700576
577 for i in range( 1, ( main.numSwitch + 1 ) ):
578 response = main.Mininet1.getSwController( "s" + str( i ) )
579 print( "Response is " + str( response ) )
580 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
581 assignResult = assignResult and main.TRUE
582 else:
583 assignResult = main.FALSE
584 stepResult = assignResult
585 utilities.assert_equals( expect=main.TRUE,
586 actual=stepResult,
587 onpass="Successfully assigned switches" +
588 "to controller",
589 onfail="Failed to assign switches to " +
590 "controller" )
Jeremydd9bda62016-04-18 12:02:32 -0700591 if not stepResult:
592 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800593
Jon Hall02758ac2017-05-24 16:20:28 -0700594 def CASE13( self, main ):
Jeremy2f190ca2016-01-29 15:23:57 -0800595 """
596 Create Scapy components
597 """
Jeremydd9bda62016-04-18 12:02:32 -0700598 if main.initialized == main.FALSE:
599 main.log.error( "Test components did not start correctly, skipping further tests" )
600 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800601 main.case( "Create scapy components" )
602 main.step( "Create scapy components" )
603 import json
604 scapyResult = main.TRUE
605 for hostName in main.scapyHostNames:
606 main.Scapy1.createHostComponent( hostName )
607 main.scapyHosts.append( getattr( main, hostName ) )
608
609 main.step( "Start scapy components" )
610 for host in main.scapyHosts:
611 host.startHostCli()
612 host.startScapy()
613 host.updateSelf()
614 main.log.debug( host.name )
615 main.log.debug( host.hostIp )
616 main.log.debug( host.hostMac )
617
Jeremy2f190ca2016-01-29 15:23:57 -0800618 utilities.assert_equals( expect=main.TRUE,
619 actual=scapyResult,
620 onpass="Successfully created Scapy Components",
621 onfail="Failed to discover Scapy Components" )
Jeremydd9bda62016-04-18 12:02:32 -0700622 if not scapyResult:
623 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800624
625 def CASE14( self, main ):
kelvin-onlab44147802015-07-27 17:57:31 -0700626 """
627 Discover all hosts and store its data to a dictionary
628 """
Jeremydd9bda62016-04-18 12:02:32 -0700629 if main.initialized == main.FALSE:
630 main.log.error( "Test components did not start correctly, skipping further tests" )
631 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700632 main.case( "Discover all hosts" )
633
634 stepResult = main.TRUE
kelvin-onlab0e684682015-08-11 18:51:41 -0700635 main.step( "Discover all ipv4 host hosts " )
636 hostList = []
637 # List of host with default vlan
638 defaultHosts = [ "h1", "h3", "h8", "h9", "h11", "h16", "h17", "h19", "h24" ]
639 # Lists of host with unique vlan
640 vlanHosts1 = [ "h4", "h12", "h20" ]
641 vlanHosts2 = [ "h5", "h13", "h21" ]
642 vlanHosts3 = [ "h6", "h14", "h22" ]
643 vlanHosts4 = [ "h7", "h15", "h23" ]
644 hostList.append( defaultHosts )
645 hostList.append( vlanHosts1 )
646 hostList.append( vlanHosts2 )
647 hostList.append( vlanHosts3 )
648 hostList.append( vlanHosts4 )
649
650 stepResult = main.intentFunction.getHostsData( main, hostList )
kelvin-onlab44147802015-07-27 17:57:31 -0700651 utilities.assert_equals( expect=main.TRUE,
652 actual=stepResult,
653 onpass="Successfully discovered hosts",
654 onfail="Failed to discover hosts" )
Jeremydd9bda62016-04-18 12:02:32 -0700655 if not stepResult:
656 main.initialized = main.FALSE
kelvin-onlab44147802015-07-27 17:57:31 -0700657
Jeremy2f190ca2016-01-29 15:23:57 -0800658 def CASE15( self, main ):
kelvin-onlab44147802015-07-27 17:57:31 -0700659 """
Jeremy2f190ca2016-01-29 15:23:57 -0800660 Discover all hosts with scapy arp packets and store its data to a dictionary
kelvin-onlab44147802015-07-27 17:57:31 -0700661 """
Jeremydd9bda62016-04-18 12:02:32 -0700662 if main.initialized == main.FALSE:
663 main.log.error( "Test components did not start correctly, skipping further tests" )
664 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800665 main.case( "Discover all hosts using scapy" )
666 main.step( "Send packets from each host to the first host and confirm onos discovery" )
667
668 import collections
669 if len( main.scapyHosts ) < 1:
670 main.log.error( "No scapy hosts have been created" )
Jeremydd9bda62016-04-18 12:02:32 -0700671 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800672 main.skipCase()
673
674 # Send ARP packets from each scapy host component
675 main.intentFunction.sendDiscoveryArp( main, main.scapyHosts )
676
677 stepResult = utilities.retry( f=main.intentFunction.confirmHostDiscovery,
678 retValue=main.FALSE, args=[ main ],
679 attempts=main.checkTopoAttempts, sleep=2 )
680
681 utilities.assert_equals( expect=main.TRUE,
682 actual=stepResult,
683 onpass="ONOS correctly discovered all hosts",
684 onfail="ONOS incorrectly discovered hosts" )
Jeremydd9bda62016-04-18 12:02:32 -0700685 if not stepResult:
686 main.initialized = main.FALSE
687 main.skipCase()
Jeremy2f190ca2016-01-29 15:23:57 -0800688
689 main.step( "Populate hostsData" )
690 stepResult = main.intentFunction.populateHostData( main )
691 utilities.assert_equals( expect=main.TRUE,
692 actual=stepResult,
693 onpass="Successfully populated hostsData",
694 onfail="Failed to populate hostsData" )
Jeremydd9bda62016-04-18 12:02:32 -0700695 if not stepResult:
696 main.initialized = main.FALSE
Jeremy2f190ca2016-01-29 15:23:57 -0800697
698 def CASE16( self, main ):
699 """
Jeremy42df2e72016-02-23 16:37:46 -0800700 Balance Masters
701 """
Jeremydd9bda62016-04-18 12:02:32 -0700702 if main.initialized == main.FALSE:
703 main.log.error( "Test components did not start correctly, skipping further tests" )
704 main.skipCase()
Jeremy42df2e72016-02-23 16:37:46 -0800705 main.case( "Balance mastership of switches" )
706 main.step( "Balancing mastership of switches" )
707
708 balanceResult = main.FALSE
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700709 balanceResult = utilities.retry( f=main.CLIs[ 0 ].balanceMasters, retValue=main.FALSE, args=[] )
Jeremy42df2e72016-02-23 16:37:46 -0800710
711 utilities.assert_equals( expect=main.TRUE,
712 actual=stepResult,
713 onpass="Successfully balanced mastership of switches",
714 onfail="Failed to balance mastership of switches" )
Jeremydd9bda62016-04-18 12:02:32 -0700715 if not stepResult:
716 main.initialized = main.FALSE
Jeremy42df2e72016-02-23 16:37:46 -0800717
718 def CASE17( self, main ):
719 """
Jeremyeb51cb12016-03-28 17:53:35 -0700720 Use Flow Objectives
721 """
Jeremydd9bda62016-04-18 12:02:32 -0700722 if main.initialized == main.FALSE:
723 main.log.error( "Test components did not start correctly, skipping further tests" )
724 main.skipCase()
Jeremyeb51cb12016-03-28 17:53:35 -0700725 main.case( "Enable intent compilation using Flow Objectives" )
726 main.step( "Enabling Flow Objectives" )
727
728 main.flowCompiler = "Flow Objectives"
729
730 cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator"
731
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700732 stepResult = main.CLIs[ 0 ].setCfg( component=cmd,
Jeremyeb51cb12016-03-28 17:53:35 -0700733 propName="useFlowObjectives", value="true" )
You Wang106d0fa2017-05-15 17:22:15 -0700734 stepResult &= main.CLIs[ 0 ].setCfg( component=cmd,
735 propName="defaultFlowObjectiveCompiler",
Jon Hall02758ac2017-05-24 16:20:28 -0700736 value='org.onosproject.net.intent.impl.compiler.LinkCollectionIntentObjectiveCompiler' )
Jeremyeb51cb12016-03-28 17:53:35 -0700737
738 utilities.assert_equals( expect=main.TRUE,
739 actual=stepResult,
740 onpass="Successfully activated Flow Objectives",
741 onfail="Failed to activate Flow Objectives" )
Jeremydd9bda62016-04-18 12:02:32 -0700742 if not stepResult:
743 main.initialized = main.FALSE
Jeremyeb51cb12016-03-28 17:53:35 -0700744
745 def CASE18( self, main ):
746 """
Jeremy2f190ca2016-01-29 15:23:57 -0800747 Stop mininet and remove scapy hosts
748 """
749 main.log.report( "Stop Mininet and Scapy" )
750 main.case( "Stop Mininet and Scapy" )
kelvin-onlab44147802015-07-27 17:57:31 -0700751 main.caseExplanation = "Stopping the current mininet topology " +\
752 "to start up fresh"
753
Jeremy2f190ca2016-01-29 15:23:57 -0800754 main.step( "Stopping and Removing Scapy Host Components" )
755 scapyResult = main.TRUE
756 for host in main.scapyHosts:
757 scapyResult = scapyResult and host.stopScapy()
758 main.log.info( "Stopped Scapy Host: {0}".format( host.name ) )
759
760 for host in main.scapyHosts:
761 scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name )
762 main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) )
763
764 main.scapyHosts = []
765 main.scapyHostIPs = []
766
767 utilities.assert_equals( expect=main.TRUE,
768 actual=scapyResult,
769 onpass="Successfully stopped scapy and removed host components",
770 onfail="Failed to stop mininet and scapy" )
771
kelvin-onlab44147802015-07-27 17:57:31 -0700772 main.step( "Stopping Mininet Topology" )
Jon Hall02758ac2017-05-24 16:20:28 -0700773 mininetResult = main.Mininet1.stopNet()
Jeremy2f190ca2016-01-29 15:23:57 -0800774
kelvin-onlab44147802015-07-27 17:57:31 -0700775 utilities.assert_equals( expect=main.TRUE,
776 actual=stepResult,
777 onpass="Successfully stop mininet",
778 onfail="Failed to stop mininet" )
779 # Exit if topology did not load properly
Jon Hall02758ac2017-05-24 16:20:28 -0700780 if not ( mininetResult and scapyResult ):
kelvin-onlab44147802015-07-27 17:57:31 -0700781 main.cleanup()
782 main.exit()
783
Jeremy Songster17147f22016-05-31 18:30:52 -0700784 def CASE19( self, main ):
785 """
786 Copy the karaf.log files after each testcase cycle
787 """
788 main.log.report( "Copy karaf logs" )
789 main.case( "Copy karaf logs" )
790 main.caseExplanation = "Copying the karaf logs to preserve them through" +\
791 "reinstalling ONOS"
792 main.step( "Copying karaf logs" )
Jeremy Songster31aad312016-06-13 16:32:11 -0700793 stepResult = main.TRUE
794 scpResult = main.TRUE
795 copyResult = main.TRUE
Jeremy Songstercc5414b2016-07-11 10:59:53 -0700796 for i in range( main.numCtrls ):
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700797 main.node = main.CLIs[ i ]
Jeremy Songster17147f22016-05-31 18:30:52 -0700798 ip = main.ONOSip[ i ]
799 main.node.ip_address = ip
Jon Hall02758ac2017-05-24 16:20:28 -0700800 scpResult = scpResult and main.ONOSbench.scp( main.node,
801 "/opt/onos/log/karaf.log",
802 "/tmp/karaf.log",
803 direction="from" )
Jeremy Songster31aad312016-06-13 16:32:11 -0700804 copyResult = copyResult and main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -0700805 copyFileName=( "karaf.log.node{0}.cycle{1}".format(
806 str( i + 1 ), str( main.cycle ) ) ) )
Jeremy Songster31aad312016-06-13 16:32:11 -0700807 if scpResult and copyResult:
Jon Hall02758ac2017-05-24 16:20:28 -0700808 stepResult = main.TRUE and stepResult
Jeremy Songster31aad312016-06-13 16:32:11 -0700809 else:
810 stepResult = main.FALSE and stepResult
Jeremy Songster31aad312016-06-13 16:32:11 -0700811 utilities.assert_equals( expect=main.TRUE,
812 actual=stepResult,
813 onpass="Successfully copied remote ONOS logs",
814 onfail="Failed to copy remote ONOS logs" )
Jeremy Songster17147f22016-05-31 18:30:52 -0700815
kelvin-onlab44147802015-07-27 17:57:31 -0700816 def CASE1000( self, main ):
817 """
818 Add host intents between 2 host:
819 - Discover hosts
820 - Add host intents
821 - Check intents
822 - Verify flows
823 - Ping hosts
824 - Reroute
825 - Link down
826 - Verify flows
827 - Check topology
828 - Ping hosts
829 - Link up
830 - Verify flows
831 - Check topology
832 - Ping hosts
833 - Remove intents
834 """
835 import time
836 import json
837 import re
Jeremydd9bda62016-04-18 12:02:32 -0700838 if main.initialized == main.FALSE:
839 main.log.error( "Test components did not start correctly, skipping further tests" )
840 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700841 # Assert variables - These variable's name|format must be followed
842 # if you want to use the wrapper function
843 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -0700844 try:
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700845 assert main.RESTs
Jeremydd9bda62016-04-18 12:02:32 -0700846 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700847 main.log.error( "There is no main.RESTs, skipping test cases" )
Jeremydd9bda62016-04-18 12:02:32 -0700848 main.initialized = main.FALSE
849 main.skipCase()
850 try:
851 assert main.Mininet1
852 except AssertionError:
853 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
854 main.initialized = main.FALSE
855 main.skipCase()
856 try:
857 assert main.numSwitch
858 except AssertionError:
Jon Hall02758ac2017-05-24 16:20:28 -0700859 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700860 main.numSwitch )
Jeremydd9bda62016-04-18 12:02:32 -0700861 main.initialized = main.FALSE
862 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -0700863
Jeremye1ea0602016-02-08 16:35:05 -0800864 # Save leader candidates
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700865 intentLeadersOld = main.CLIs[ 0 ].leaderCandidates()
Jeremye1ea0602016-02-08 16:35:05 -0800866
kelvin-onlab44147802015-07-27 17:57:31 -0700867 main.case( "Host Intents Test - " + str( main.numCtrls ) +
Jeremyeb51cb12016-03-28 17:53:35 -0700868 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -0700869 main.caseExplanation = "This test case tests Host intents using " +\
870 str( main.numCtrls ) + " node(s) cluster;\n" +\
871 "Different type of hosts will be tested in " +\
872 "each step such as IPV4, Dual stack, VLAN " +\
Jeremyeb51cb12016-03-28 17:53:35 -0700873 "etc;\nThe test will use OF " + main.OFProtocol +\
874 " OVS running in Mininet and compile intents" +\
875 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -0700876
Jeremy2f190ca2016-01-29 15:23:57 -0800877 main.step( "IPV4: Add and test host intents between h1 and h9" )
878 main.assertReturnString = "Assertion result for IPV4 host intent with mac addresses\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700879 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
880 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800881 testResult = main.FALSE
882 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700883 name='IPV4',
884 onosNode='0',
885 host1=host1,
886 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800887
888 if installResult:
889 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700890 name='IPV4',
891 intentId=installResult,
892 onosNode='0',
893 host1=host1,
894 host2=host2,
895 sw1='s5',
896 sw2='s2',
897 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700898
899 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800900 actual=testResult,
901 onpass=main.assertReturnString,
902 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700903
904 main.step( "DUALSTACK1: Add host intents between h3 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800905 main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700906 host1 = { "name": "h3", "id": "00:00:00:00:00:03/-1" }
907 host2 = { "name": "h11", "id": "00:00:00:00:00:0B/-1" }
Jeremy2f190ca2016-01-29 15:23:57 -0800908 testResult = main.FALSE
909 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700910 name='DUALSTACK1',
911 onosNode='0',
912 host1=host1,
913 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800914
915 if installResult:
916 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700917 name='DUALSTACK1',
918 intentId=installResult,
919 onosNode='0',
920 host1=host1,
921 host2=host2,
922 sw1='s5',
923 sw2='s2',
924 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700925
926 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800927 actual=testResult,
928 onpass=main.assertReturnString,
Jeremy Songstere7f3b342016-08-17 14:56:49 -0700929 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700930
931 main.step( "DUALSTACK2: Add host intents between h1 and h11" )
Jeremy2f190ca2016-01-29 15:23:57 -0800932 main.assertReturnString = "Assertion Result for dualstack2 host intent\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700933 host1 = { "name": "h1" }
934 host2 = { "name": "h11" }
Jeremy2f190ca2016-01-29 15:23:57 -0800935 testResult = main.FALSE
936 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700937 name='DUALSTACK2',
938 onosNode='0',
939 host1=host1,
940 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800941
942 if installResult:
943 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700944 name='DUALSTACK2',
945 intentId=installResult,
946 onosNode='0',
947 host1=host1,
948 host2=host2,
949 sw1='s5',
950 sw2='s2',
951 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700952
953 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800954 actual=testResult,
955 onpass=main.assertReturnString,
956 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -0700957
958 main.step( "1HOP: Add host intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -0800959 main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700960 host1 = { "name": "h1" }
961 host2 = { "name": "h3" }
Jeremy2f190ca2016-01-29 15:23:57 -0800962 testResult = main.FALSE
963 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700964 name='1HOP',
965 onosNode='0',
966 host1=host1,
967 host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -0700968
Jeremy2f190ca2016-01-29 15:23:57 -0800969 if installResult:
970 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700971 name='1HOP',
972 intentId=installResult,
973 onosNode='0',
974 host1=host1,
975 host2=host2,
976 sw1='s5',
977 sw2='s2',
978 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -0700979
980 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -0800981 actual=testResult,
982 onpass=main.assertReturnString,
983 onfail=main.assertReturnString )
984
985 main.step( "VLAN1: Add vlan host intents between h4 and h12" )
986 main.assertReturnString = "Assertion Result vlan IPV4\n"
Jon Hall02758ac2017-05-24 16:20:28 -0700987 host1 = { "name": "h4", "id": "00:00:00:00:00:04/100", "vlanId": "100" }
988 host2 = { "name": "h12", "id": "00:00:00:00:00:0C/100", "vlanId": "100" }
Jeremy2f190ca2016-01-29 15:23:57 -0800989 testResult = main.FALSE
990 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700991 name='VLAN1',
992 onosNode='0',
993 host1=host1,
994 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -0800995
996 if installResult:
997 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -0700998 name='VLAN1',
999 intentId=installResult,
1000 onosNode='0',
1001 host1=host1,
1002 host2=host2,
1003 sw1='s5',
1004 sw2='s2',
1005 expectedLink=18 )
Jeremy2f190ca2016-01-29 15:23:57 -08001006
1007 utilities.assert_equals( expect=main.TRUE,
1008 actual=testResult,
1009 onpass=main.assertReturnString,
1010 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001011
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001012 # This step isn't currently possible to perform in the REST API
1013 # main.step( "VLAN2: Add inter vlan host intents between h13 and h20" )
1014 # main.assertReturnString = "Assertion Result different VLAN negative test\n"
1015 # host1 = { "name":"h13" }
1016 # host2 = { "name":"h20" }
1017 # testResult = main.FALSE
1018 # installResult = main.intentFunction.installHostIntent( main,
1019 # name='VLAN2',
1020 # onosNode='0',
1021 # host1=host1,
1022 # host2=host2 )
kelvin-onlab44147802015-07-27 17:57:31 -07001023
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001024 # if installResult:
1025 # testResult = main.intentFunction.testHostIntent( main,
1026 # name='VLAN2',
Jon Hall02758ac2017-05-24 16:20:28 -07001027 # intentId=installResult,
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001028 # onosNode='0',
1029 # host1=host1,
1030 # host2=host2,
1031 # sw1='s5',
1032 # sw2='s2',
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001033 # expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001034
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001035 # utilities.assert_equals( expect=main.TRUE,
1036 # actual=testResult,
1037 # onpass=main.assertReturnString,
1038 # onfail=main.assertReturnString )
Jeremy2f190ca2016-01-29 15:23:57 -08001039
Jeremye1ea0602016-02-08 16:35:05 -08001040 # Change the following to use the REST API when leader checking is
1041 # supported by it
Jeremy2f190ca2016-01-29 15:23:57 -08001042
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001043 main.step( "Confirm that ONOS leadership is unchanged" )
1044 intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
Jeremye1ea0602016-02-08 16:35:05 -08001045 main.intentFunction.checkLeaderChange( intentLeadersOld,
1046 intentLeadersNew )
Jeremy2f190ca2016-01-29 15:23:57 -08001047
Jeremye1ea0602016-02-08 16:35:05 -08001048 utilities.assert_equals( expect=main.TRUE,
1049 actual=testResult,
1050 onpass="ONOS Leaders Unchanged",
Jon Hall02758ac2017-05-24 16:20:28 -07001051 onfail="ONOS Leader Mismatch" )
Jeremy2f190ca2016-01-29 15:23:57 -08001052
1053 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001054
1055 def CASE2000( self, main ):
1056 """
1057 Add point intents between 2 hosts:
1058 - Get device ids | ports
1059 - Add point intents
1060 - Check intents
1061 - Verify flows
1062 - Ping hosts
1063 - Reroute
1064 - Link down
1065 - Verify flows
1066 - Check topology
1067 - Ping hosts
1068 - Link up
1069 - Verify flows
1070 - Check topology
1071 - Ping hosts
1072 - Remove intents
1073 """
Jeremydd9bda62016-04-18 12:02:32 -07001074 if main.initialized == main.FALSE:
1075 main.log.error( "Test components did not start correctly, skipping further tests" )
1076 main.skipCase()
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001077 # Assert variables - These variable's name|format must be followed
1078 # if you want to use the wrapper function
kelvin-onlab44147802015-07-27 17:57:31 -07001079 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -07001080 try:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001081 assert main.RESTs
Jeremydd9bda62016-04-18 12:02:32 -07001082 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001083 main.log.error( "There is no main.RESTs, skipping test cases" )
Jeremydd9bda62016-04-18 12:02:32 -07001084 main.initialized = main.FALSE
1085 main.skipCase()
1086 try:
1087 assert main.Mininet1
1088 except AssertionError:
1089 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1090 main.initialized = main.FALSE
1091 main.skipCase()
1092 try:
1093 assert main.numSwitch
1094 except AssertionError:
Jon Hall02758ac2017-05-24 16:20:28 -07001095 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001096 main.numSwitch )
Jeremydd9bda62016-04-18 12:02:32 -07001097 main.initialized = main.FALSE
1098 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001099
1100 main.case( "Point Intents Test - " + str( main.numCtrls ) +
Jon Hall02758ac2017-05-24 16:20:28 -07001101 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001102 main.caseExplanation = "This test case will test point to point" + \
1103 " intents using " + str( main.numCtrls ) + \
1104 " node(s) cluster;\n" + \
1105 "Different type of hosts will be tested in " + \
1106 "each step such as IPV4, Dual stack, VLAN etc" + \
1107 ";\nThe test will use OF " + main.OFProtocol + \
1108 " OVS running in Mininet and compile intents" + \
Jeremyeb51cb12016-03-28 17:53:35 -07001109 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001110
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001111 # No option point intent
kelvin-onlab44147802015-07-27 17:57:31 -07001112 main.step( "NOOPTION: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001113 main.assertReturnString = "Assertion Result for NOOPTION point intent\n"
1114 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001115 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy2f190ca2016-01-29 15:23:57 -08001116 ]
1117 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001118 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy2f190ca2016-01-29 15:23:57 -08001119 ]
1120 testResult = main.FALSE
1121 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001122 main,
1123 name="NOOPTION",
1124 senders=senders,
1125 recipients=recipients )
Jeremy2f190ca2016-01-29 15:23:57 -08001126
1127 if installResult:
1128 testResult = main.intentFunction.testPointIntent(
1129 main,
1130 intentId=installResult,
1131 name="NOOPTION",
1132 senders=senders,
1133 recipients=recipients,
1134 sw1="s5",
1135 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001136 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001137
1138 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001139 actual=testResult,
1140 onpass=main.assertReturnString,
1141 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001142
kelvin-onlab44147802015-07-27 17:57:31 -07001143 main.step( "IPV4: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001144 main.assertReturnString = "Assertion Result for IPV4 point intent\n"
1145 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001146 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
Jeremy2f190ca2016-01-29 15:23:57 -08001147 ]
1148 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001149 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" }
Jeremy2f190ca2016-01-29 15:23:57 -08001150 ]
1151 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001152 main,
1153 name="IPV4",
1154 senders=senders,
1155 recipients=recipients,
1156 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -08001157
1158 if installResult:
1159 testResult = main.intentFunction.testPointIntent(
1160 main,
1161 intentId=installResult,
1162 name="IPV4",
1163 senders=senders,
1164 recipients=recipients,
1165 sw1="s5",
1166 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001167 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001168
1169 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001170 actual=testResult,
1171 onpass=main.assertReturnString,
1172 onfail=main.assertReturnString )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001173
alisonda157272016-12-22 01:13:21 -08001174 # main.step( "Protected: Add point intents between h1 and h9" )
1175 # main.assertReturnString = "Assertion Result for protected point intent\n"
1176 # senders = [
1177 # { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
1178 # ]
1179 # recipients = [
1180 # { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" }
1181 # ]
1182 # testResult = main.FALSE
1183 # installResult = main.intentFunction.installPointIntent(
1184 # main,
1185 # name="Protected",
1186 # senders=senders,
1187 # recipients=recipients,
1188 # protected=True )
Jon Hall02758ac2017-05-24 16:20:28 -07001189 #
alisonda157272016-12-22 01:13:21 -08001190 # if installResult:
1191 # testResult = main.intentFunction.testPointIntent(
1192 # main,
1193 # name="Protected",
1194 # intentId=installResult,
1195 # senders=senders,
1196 # recipients=recipients,
1197 # sw1="s5",
1198 # sw2="s2",
1199 # protected=True,
1200 # expectedLink=18 )
1201 #
1202 # utilities.assert_equals( expect=main.TRUE,
1203 # actual=testResult,
1204 # onpass=main.assertReturnString,
1205 # onfail=main.assertReturnString )
1206
kelvin-onlab44147802015-07-27 17:57:31 -07001207 main.step( "IPV4_2: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001208 main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n"
1209 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001210 { "name": "h1", "device": "of:0000000000000005/1" }
Jeremy2f190ca2016-01-29 15:23:57 -08001211 ]
1212 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001213 { "name": "h9", "device": "of:0000000000000006/1" }
Jeremy2f190ca2016-01-29 15:23:57 -08001214 ]
1215 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001216 main,
1217 name="IPV4_2",
1218 senders=senders,
1219 recipients=recipients,
1220 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -08001221
1222 if installResult:
1223 testResult = main.intentFunction.testPointIntent(
1224 main,
1225 intentId=installResult,
1226 name="IPV4_2",
1227 senders=senders,
1228 recipients=recipients,
1229 sw1="s5",
1230 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001231 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001232
1233 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001234 actual=testResult,
1235 onpass=main.assertReturnString,
1236 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001237
kelvin-onlab0e684682015-08-11 18:51:41 -07001238 main.step( "SDNIP-ICMP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001239 main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n"
1240 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001241 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01",
1242 "ip": ( main.h1.hostIp + "/24" ) }
Jeremy2f190ca2016-01-29 15:23:57 -08001243 ]
1244 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001245 { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09",
1246 "ip": ( main.h9.hostIp + "/24" ) }
Jeremy2f190ca2016-01-29 15:23:57 -08001247 ]
Jon Hall02758ac2017-05-24 16:20:28 -07001248 # ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ]
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001249 ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ]
kelvin-onlab44147802015-07-27 17:57:31 -07001250 # Uneccessary, not including this in the selectors
Jon Hall02758ac2017-05-24 16:20:28 -07001251 tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
1252 tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
kelvin-onlab44147802015-07-27 17:57:31 -07001253
Jeremy2f190ca2016-01-29 15:23:57 -08001254 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001255 main,
1256 name="SDNIP-ICMP",
1257 senders=senders,
1258 recipients=recipients,
1259 ethType="IPV4",
1260 ipProto=ipProto,
1261 tcpSrc=tcpSrc,
1262 tcpDst=tcpDst )
Jeremy2f190ca2016-01-29 15:23:57 -08001263
1264 if installResult:
1265 testResult = main.intentFunction.testPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001266 main,
1267 intentId=installResult,
1268 name="SDNIP_ICMP",
1269 senders=senders,
1270 recipients=recipients,
1271 sw1="s5",
1272 sw2="s2",
1273 expectedLink=18,
1274 useTCP=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001275
1276 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001277 actual=testResult,
1278 onpass=main.assertReturnString,
1279 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001280
kelvin-onlab0e684682015-08-11 18:51:41 -07001281 main.step( "SDNIP-TCP: Add point intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001282 main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n"
Jon Hall02758ac2017-05-24 16:20:28 -07001283 mac1 = main.hostsData[ 'h1' ][ 'mac' ]
1284 mac2 = main.hostsData[ 'h9' ][ 'mac' ]
1285 ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32"
1286 ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32"
1287 ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ]
1288 tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ]
1289 tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ]
kelvin-onlab44147802015-07-27 17:57:31 -07001290
kelvin-onlab0e684682015-08-11 18:51:41 -07001291 stepResult = main.intentFunction.pointIntentTcp(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001292 main,
1293 name="SDNIP-TCP",
1294 host1="h1",
1295 host2="h9",
1296 deviceId1="of:0000000000000005/1",
1297 deviceId2="of:0000000000000006/1",
1298 mac1=mac1,
1299 mac2=mac2,
1300 ethType="IPV4",
1301 ipProto=ipProto,
1302 ip1=ip1,
1303 ip2=ip2,
1304 tcp1=tcp1,
1305 tcp2=tcp2 )
kelvin-onlab44147802015-07-27 17:57:31 -07001306
1307 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001308 actual=stepResult,
Jeremy2f190ca2016-01-29 15:23:57 -08001309 onpass=main.assertReturnString,
1310 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001311
Jeremy2f190ca2016-01-29 15:23:57 -08001312 main.step( "DUALSTACK1: Add point intents between h3 and h11" )
1313 main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n"
1314 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001315 { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
Jeremy2f190ca2016-01-29 15:23:57 -08001316 ]
1317 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001318 { "name": "h11", "device": "of:0000000000000006/3", "mac": "00:00:00:00:00:0B" }
Jeremy2f190ca2016-01-29 15:23:57 -08001319 ]
1320 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001321 main,
1322 name="DUALSTACK1",
1323 senders=senders,
1324 recipients=recipients,
1325 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -08001326
1327 if installResult:
1328 testResult = main.intentFunction.testPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001329 main,
1330 intentId=installResult,
1331 name="DUALSTACK1",
1332 senders=senders,
1333 recipients=recipients,
1334 sw1="s5",
1335 sw2="s2",
1336 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001337
1338 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001339 actual=testResult,
1340 onpass=main.assertReturnString,
1341 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001342
1343 main.step( "VLAN: Add point intents between h5 and h21" )
Jeremy2f190ca2016-01-29 15:23:57 -08001344 main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n"
1345 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001346 { "name": "h5", "device": "of:0000000000000005/5", "mac": "00:00:00:00:00:05", "vlanId": "200" }
Jeremy2f190ca2016-01-29 15:23:57 -08001347 ]
1348 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001349 { "name": "h21", "device": "of:0000000000000007/5", "mac": "00:00:00:00:00:15", "vlanId": "200" }
Jeremy2f190ca2016-01-29 15:23:57 -08001350 ]
1351 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001352 main,
1353 name="VLAN",
1354 senders=senders,
1355 recipients=recipients )
Jeremy2f190ca2016-01-29 15:23:57 -08001356
1357 if installResult:
1358 testResult = main.intentFunction.testPointIntent(
1359 main,
1360 intentId=installResult,
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001361 name="VLAN",
Jeremy2f190ca2016-01-29 15:23:57 -08001362 senders=senders,
1363 recipients=recipients,
1364 sw1="s5",
1365 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001366 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001367
1368 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001369 actual=testResult,
1370 onpass=main.assertReturnString,
1371 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001372
Jeremy Songsterae2dd452016-05-17 16:44:35 -07001373 # TODO: implement VLAN selector REST API intent test once supported
1374
kelvin-onlab44147802015-07-27 17:57:31 -07001375 main.step( "1HOP: Add point intents between h1 and h3" )
Jeremy2f190ca2016-01-29 15:23:57 -08001376 main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
1377 senders = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001378 { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" }
Jeremy2f190ca2016-01-29 15:23:57 -08001379 ]
1380 recipients = [
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001381 { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" }
Jeremy2f190ca2016-01-29 15:23:57 -08001382 ]
1383 installResult = main.intentFunction.installPointIntent(
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001384 main,
1385 name="1HOP IPV4",
1386 senders=senders,
1387 recipients=recipients,
1388 ethType="IPV4" )
Jeremy2f190ca2016-01-29 15:23:57 -08001389
1390 if installResult:
1391 testResult = main.intentFunction.testPointIntent(
1392 main,
1393 intentId=installResult,
1394 name="1HOP IPV4",
1395 senders=senders,
1396 recipients=recipients,
1397 sw1="s5",
1398 sw2="s2",
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001399 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001400
1401 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001402 actual=testResult,
1403 onpass=main.assertReturnString,
1404 onfail=main.assertReturnString )
1405
1406 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001407
1408 def CASE3000( self, main ):
1409 """
1410 Add single point to multi point intents
1411 - Get device ids
1412 - Add single point to multi point intents
1413 - Check intents
1414 - Verify flows
1415 - Ping hosts
1416 - Reroute
1417 - Link down
1418 - Verify flows
1419 - Check topology
1420 - Ping hosts
1421 - Link up
1422 - Verify flows
1423 - Check topology
1424 - Ping hosts
1425 - Remove intents
1426 """
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001427 if main.initialized == main.FALSE:
1428 main.log.error( "Test components did not start correctly, skipping further tests" )
1429 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001430 assert main, "There is no main"
kelvin-onlab44147802015-07-27 17:57:31 -07001431
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001432 try:
1433 assert main.CLIs, "There is no main.CLIs, skipping test cases"
1434 assert main.Mininet1, "Mininet handle should be named Mininet1, skipping test cases"
1435 assert main.numSwitch, "Place the total number of switch topology in main.numSwitch"
1436 except AssertionError:
1437 main.initialized = main.FALSE
1438 main.skipCase()
1439
1440 main.testName = "Single to Multi Point Intents"
1441 main.case( main.testName + " Test - " + str( main.numCtrls ) +
Jon Hall02758ac2017-05-24 16:20:28 -07001442 " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001443 main.caseExplanation = "This test case will test single point to" + \
1444 " multi point intents using " + \
1445 str( main.numCtrls ) + " node(s) cluster;\n" + \
1446 "Different type of hosts will be tested in " + \
1447 "each step such as IPV4, Dual stack, VLAN etc" + \
1448 ";\nThe test will use OF " + main.OFProtocol + \
1449 " OVS running in Mininet and compile intents" + \
Jeremyeb51cb12016-03-28 17:53:35 -07001450 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001451
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001452 main.step( "NOOPTION: Install and test single point to multi point intents" )
1453 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n"
1454 senders = [
1455 { "name": "h8", "device": "of:0000000000000005/8" }
1456 ]
1457 recipients = [
1458 { "name": "h16", "device": "of:0000000000000006/8" },
1459 { "name": "h24", "device": "of:0000000000000007/8" }
1460 ]
1461 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1462 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
1463 testResult = main.FALSE
1464 installResult = main.intentFunction.installSingleToMultiIntent(
1465 main,
1466 name="NOOPTION",
1467 senders=senders,
1468 recipients=recipients )
1469
1470 if installResult:
1471 testResult = main.intentFunction.testPointIntent(
1472 main,
1473 intentId=installResult,
1474 name="NOOPTION",
1475 senders=senders,
1476 recipients=recipients,
1477 badSenders=badSenders,
1478 badRecipients=badRecipients,
1479 sw1="s5",
1480 sw2="s2",
1481 expectedLink=18 )
1482 else:
1483 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001484
1485 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001486 actual=testResult,
1487 onpass=main.assertReturnString,
1488 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001489
Jon Hall02758ac2017-05-24 16:20:28 -07001490 main.step( "IPV4: Install and test single point to multi point intents" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001491 main.assertReturnString = "Assertion results for IPV4 single to multi point intent " \
1492 "with IPV4 type and MAC addresses\n"
1493 senders = [
Jon Hall02758ac2017-05-24 16:20:28 -07001494 { "name": "h8", "device": "of:0000000000000005/8", "mac": "00:00:00:00:00:08" }
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001495 ]
1496 recipients = [
Jon Hall02758ac2017-05-24 16:20:28 -07001497 { "name": "h16", "device": "of:0000000000000006/8", "mac": "00:00:00:00:00:10" },
1498 { "name": "h24", "device": "of:0000000000000007/8", "mac": "00:00:00:00:00:18" }
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001499 ]
Jon Hall02758ac2017-05-24 16:20:28 -07001500 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1501 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001502 installResult = main.intentFunction.installSingleToMultiIntent(
1503 main,
1504 name="IPV4",
1505 senders=senders,
1506 recipients=recipients,
Jon Hall02758ac2017-05-24 16:20:28 -07001507 ethType="IPV4" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001508
1509 if installResult:
1510 testResult = main.intentFunction.testPointIntent(
1511 main,
1512 intentId=installResult,
1513 name="IPV4",
1514 senders=senders,
1515 recipients=recipients,
1516 badSenders=badSenders,
1517 badRecipients=badRecipients,
1518 sw1="s5",
1519 sw2="s2",
1520 expectedLink=18 )
1521 else:
1522 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001523
1524 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001525 actual=testResult,
1526 onpass=main.assertReturnString,
1527 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001528
1529 main.step( "IPV4_2: Add single point to multi point intents" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001530 main.assertReturnString = "Assertion results for IPV4 single to multi point intent " \
1531 "with IPV4 type and no MAC addresses\n"
1532 senders = [
1533 { "name": "h8", "device": "of:0000000000000005/8" }
1534 ]
1535 recipients = [
1536 { "name": "h16", "device": "of:0000000000000006/8" },
1537 { "name": "h24", "device": "of:0000000000000007/8" }
1538 ]
1539 badSenders = [ { "name": "h9" } ] # Senders that are not in the intent
1540 badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent
1541 installResult = main.intentFunction.installSingleToMultiIntent(
1542 main,
1543 name="IPV4_2",
1544 senders=senders,
1545 recipients=recipients,
1546 ethType="IPV4" )
1547
1548 if installResult:
1549 testResult = main.intentFunction.testPointIntent(
1550 main,
1551 intentId=installResult,
1552 name="IPV4_2",
1553 senders=senders,
1554 recipients=recipients,
1555 badSenders=badSenders,
1556 badRecipients=badRecipients,
1557 sw1="s5",
1558 sw2="s2",
1559 expectedLink=18 )
1560 else:
1561 main.CLIs[ 0 ].removeAllIntents( purge=True )
kelvin-onlab44147802015-07-27 17:57:31 -07001562
1563 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001564 actual=testResult,
1565 onpass=main.assertReturnString,
1566 onfail=main.assertReturnString )
kelvin-onlab44147802015-07-27 17:57:31 -07001567
1568 main.step( "VLAN: Add single point to multi point intents" )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001569 main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type " \
1570 "and MAC addresses in the same VLAN\n"
1571 senders = [
1572 { "name": "h4", "device": "of:0000000000000005/4", "mac": "00:00:00:00:00:04", "vlan": "100" }
1573 ]
1574 recipients = [
1575 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1576 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
1577 ]
1578 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1579 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
1580 installResult = main.intentFunction.installSingleToMultiIntent(
1581 main,
1582 name="VLAN",
1583 senders=senders,
1584 recipients=recipients,
1585 sw1="s5",
1586 sw2="s2" )
1587
1588 if installResult:
1589 testResult = main.intentFunction.testPointIntent(
1590 main,
1591 intentId=installResult,
1592 name="VLAN",
1593 senders=senders,
1594 recipients=recipients,
1595 badSenders=badSenders,
1596 badRecipients=badRecipients,
1597 sw1="s5",
1598 sw2="s2",
1599 expectedLink=18 )
1600 else:
1601 main.CLIs[ 0 ].removeAllIntents()
kelvin-onlab44147802015-07-27 17:57:31 -07001602
1603 utilities.assert_equals( expect=main.TRUE,
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001604 actual=testResult,
1605 onpass=main.assertReturnString,
1606 onfail=main.assertReturnString )
1607
1608 main.step( "VLAN: Add single point to multi point intents" )
1609 main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n"
1610 senders = [
1611 { "name": "h5", "vlan": "200" }
1612 ]
1613 recipients = [
1614 { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" },
1615 { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" }
1616 ]
1617 badSenders = [ { "name": "h13" } ] # Senders that are not in the intent
1618 badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent
1619 testResult = main.FALSE
1620 installResult = main.intentFunction.installSingleToMultiIntent(
1621 main,
1622 name="VLAN2",
1623 senders=senders,
1624 recipients=recipients,
1625 sw1="s5",
1626 sw2="s2" )
Jon Hall02758ac2017-05-24 16:20:28 -07001627 #setVlan=100 )
Ming Yan Shuab2f7f52016-08-03 15:21:24 -07001628
1629 if installResult:
1630 testResult = main.intentFunction.testPointIntent(
1631 main,
1632 intentId=installResult,
1633 name="VLAN2",
1634 senders=senders,
1635 recipients=recipients,
1636 badSenders=badSenders,
1637 badRecipients=badRecipients,
1638 sw1="s5",
1639 sw2="s2",
1640 expectedLink=18 )
1641 else:
1642 main.CLIs[ 0 ].removeAllIntents()
1643
1644 utilities.assert_equals( expect=main.TRUE,
1645 actual=testResult,
1646 onpass=main.assertReturnString,
1647 onfail=main.assertReturnString )
1648
1649 main.intentFunction.report( main )
kelvin-onlab44147802015-07-27 17:57:31 -07001650
1651 def CASE4000( self, main ):
1652 """
1653 Add multi point to single point intents
1654 - Get device ids
1655 - Add multi point to single point intents
1656 - Check intents
1657 - Verify flows
1658 - Ping hosts
1659 - Reroute
1660 - Link down
1661 - Verify flows
1662 - Check topology
1663 - Ping hosts
1664 - Link up
1665 - Verify flows
1666 - Check topology
1667 - Ping hosts
1668 - Remove intents
1669 """
1670 assert main, "There is no main"
1671 assert main.CLIs, "There is no main.CLIs"
1672 assert main.Mininet1, "Mininet handle should be named Mininet1"
1673 assert main.numSwitch, "Placed the total number of switch topology in \
1674 main.numSwitch"
1675
1676 main.case( "Multi To Single Point Intents Test - " +
Jeremyeb51cb12016-03-28 17:53:35 -07001677 str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler )
kelvin-onlab44147802015-07-27 17:57:31 -07001678 main.caseExplanation = "This test case will test single point to" +\
1679 " multi point intents using " +\
1680 str( main.numCtrls ) + " node(s) cluster;\n" +\
1681 "Different type of hosts will be tested in " +\
1682 "each step such as IPV4, Dual stack, VLAN etc" +\
1683 ";\nThe test will use OF " + main.OFProtocol +\
Jeremyeb51cb12016-03-28 17:53:35 -07001684 " OVS running in Mininet and compile intents" +\
1685 " using " + main.flowCompiler
kelvin-onlab44147802015-07-27 17:57:31 -07001686
1687 main.step( "NOOPTION: Add multi point to single point intents" )
1688 stepResult = main.TRUE
1689 hostNames = [ 'h8', 'h16', 'h24' ]
Jon Hall02758ac2017-05-24 16:20:28 -07001690 devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8',
kelvin-onlab44147802015-07-27 17:57:31 -07001691 'of:0000000000000007/8' ]
1692 macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ]
1693 stepResult = main.intentFunction.multiToSingleIntent(
1694 main,
1695 name="NOOPTION",
1696 hostNames=hostNames,
1697 devices=devices,
1698 sw1="s5",
1699 sw2="s2",
1700 expectedLink=18 )
1701
1702 utilities.assert_equals( expect=main.TRUE,
1703 actual=stepResult,
1704 onpass="NOOPTION: Successfully added multi "
1705 + " point to single point intents" +
1706 " with no match action",
1707 onfail="NOOPTION: Failed to add multi point" +
1708 " to single point intents" +
1709 " with no match action" )
1710
1711 main.step( "IPV4: Add multi point to single point intents" )
1712 stepResult = main.TRUE
1713 stepResult = main.intentFunction.multiToSingleIntent(
1714 main,
1715 name="IPV4",
1716 hostNames=hostNames,
1717 devices=devices,
1718 ports=None,
1719 ethType="IPV4",
1720 macs=macs,
1721 bandwidth="",
1722 lambdaAlloc=False,
1723 ipProto="",
1724 ipAddresses="",
1725 tcp="",
1726 sw1="s5",
1727 sw2="s2",
1728 expectedLink=18 )
1729
1730 utilities.assert_equals( expect=main.TRUE,
1731 actual=stepResult,
1732 onpass="IPV4: Successfully added multi point"
1733 + " to single point intents" +
1734 " with IPV4 type and MAC addresses",
1735 onfail="IPV4: Failed to add multi point" +
1736 " to single point intents" +
1737 " with IPV4 type and MAC addresses" )
1738
1739 main.step( "IPV4_2: Add multi point to single point intents" )
1740 stepResult = main.TRUE
1741 hostNames = [ 'h8', 'h16', 'h24' ]
1742 stepResult = main.intentFunction.multiToSingleIntent(
1743 main,
1744 name="IPV4",
1745 hostNames=hostNames,
1746 ethType="IPV4",
1747 lambdaAlloc=False )
1748
1749 utilities.assert_equals( expect=main.TRUE,
1750 actual=stepResult,
1751 onpass="IPV4_2: Successfully added multi point"
1752 + " to single point intents" +
1753 " with IPV4 type and no MAC addresses",
1754 onfail="IPV4_2: Failed to add multi point" +
1755 " to single point intents" +
1756 " with IPV4 type and no MAC addresses" )
1757
1758 main.step( "VLAN: Add multi point to single point intents" )
1759 stepResult = main.TRUE
1760 hostNames = [ 'h5', 'h13', 'h21' ]
Jon Hall02758ac2017-05-24 16:20:28 -07001761 devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5',
kelvin-onlab44147802015-07-27 17:57:31 -07001762 'of:0000000000000007/5' ]
1763 macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ]
1764 stepResult = main.intentFunction.multiToSingleIntent(
1765 main,
1766 name="VLAN",
1767 hostNames=hostNames,
1768 devices=devices,
1769 ports=None,
1770 ethType="IPV4",
1771 macs=macs,
1772 bandwidth="",
1773 lambdaAlloc=False,
1774 ipProto="",
1775 ipAddresses="",
1776 tcp="",
1777 sw1="s5",
1778 sw2="s2",
1779 expectedLink=18 )
1780
1781 utilities.assert_equals( expect=main.TRUE,
1782 actual=stepResult,
1783 onpass="VLAN: Successfully added multi point"
1784 + " to single point intents" +
1785 " with IPV4 type and MAC addresses" +
1786 " in the same VLAN",
1787 onfail="VLAN: Failed to add multi point" +
1788 " to single point intents" )
1789
1790 def CASE5000( self, main ):
1791 """
Jeremy2f190ca2016-01-29 15:23:57 -08001792 Tests Host Mobility
1793 Modifies the topology location of h1
kelvin-onlab44147802015-07-27 17:57:31 -07001794 """
Jeremydd9bda62016-04-18 12:02:32 -07001795 if main.initialized == main.FALSE:
1796 main.log.error( "Test components did not start correctly, skipping further tests" )
1797 main.skipCase()
1798 # Assert variables - These variable's name|format must be followed
1799 # if you want to use the wrapper function
kelvin-onlab44147802015-07-27 17:57:31 -07001800 assert main, "There is no main"
Jeremydd9bda62016-04-18 12:02:32 -07001801 try:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001802 assert main.RESTs
Jeremydd9bda62016-04-18 12:02:32 -07001803 except AssertionError:
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001804 main.log.error( "There is no main.RESTs, skipping test cases" )
Jeremydd9bda62016-04-18 12:02:32 -07001805 main.initialized = main.FALSE
1806 main.skipCase()
1807 try:
1808 assert main.Mininet1
1809 except AssertionError:
1810 main.log.error( "Mininet handle should be named Mininet1, skipping test cases" )
1811 main.initialized = main.FALSE
1812 main.skipCase()
1813 try:
1814 assert main.numSwitch
1815 except AssertionError:
Jon Hall02758ac2017-05-24 16:20:28 -07001816 main.log.error( "Place the total number of switch topology in " +
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001817 main.numSwitch )
Jeremydd9bda62016-04-18 12:02:32 -07001818 main.initialized = main.FALSE
1819 main.skipCase()
kelvin-onlab44147802015-07-27 17:57:31 -07001820 main.case( "Test host mobility with host intents " )
Jeremy2f190ca2016-01-29 15:23:57 -08001821 main.step( "Testing host mobility by moving h1 from s5 to s6" )
kelvin-onlab44147802015-07-27 17:57:31 -07001822 h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1823
Jeremy Songstere7f3b342016-08-17 14:56:49 -07001824 main.log.info( "Moving h1 from s5 to s6" )
1825 main.Mininet1.moveHost( "h1", "s5", "s6" )
kelvin-onlab44147802015-07-27 17:57:31 -07001826
Jeremy2f190ca2016-01-29 15:23:57 -08001827 # Send discovery ping from moved host
1828 # Moving the host brings down the default interfaces and creates a new one.
1829 # Scapy is restarted on this host to detect the new interface
1830 main.h1.stopScapy()
1831 main.h1.startScapy()
1832
1833 # Discover new host location in ONOS and populate host data.
1834 # Host 1 IP and MAC should be unchanged
1835 main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] )
1836 main.intentFunction.populateHostData( main )
1837
kelvin-onlab44147802015-07-27 17:57:31 -07001838 h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ]
1839
1840 utilities.assert_equals( expect="of:0000000000000006",
1841 actual=h1PostMove,
1842 onpass="Mobility: Successfully moved h1 to s6",
Jeremy2f190ca2016-01-29 15:23:57 -08001843 onfail="Mobility: Failed to move h1 to s6" +
kelvin-onlab44147802015-07-27 17:57:31 -07001844 " to single point intents" +
1845 " with IPV4 type and MAC addresses" +
1846 " in the same VLAN" )
1847
1848 main.step( "IPV4: Add host intents between h1 and h9" )
Jeremy2f190ca2016-01-29 15:23:57 -08001849 main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
Jon Hall02758ac2017-05-24 16:20:28 -07001850 host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" }
1851 host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" }
Jeremy2f190ca2016-01-29 15:23:57 -08001852
1853 installResult = main.intentFunction.installHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -07001854 name='IPV4 Mobility IPV4',
1855 onosNode='0',
1856 host1=host1,
1857 host2=host2 )
Jeremy2f190ca2016-01-29 15:23:57 -08001858 if installResult:
1859 testResult = main.intentFunction.testHostIntent( main,
Jon Hall02758ac2017-05-24 16:20:28 -07001860 name='Host Mobility IPV4',
1861 intentId=installResult,
1862 onosNode='0',
1863 host1=host1,
1864 host2=host2,
1865 sw1="s6",
1866 sw2="s2",
1867 expectedLink=18 )
kelvin-onlab44147802015-07-27 17:57:31 -07001868
1869 utilities.assert_equals( expect=main.TRUE,
Jeremy2f190ca2016-01-29 15:23:57 -08001870 actual=testResult,
1871 onpass=main.assertReturnString,
1872 onfail=main.assertReturnString )
1873
Jon Hallbd60ea02016-08-23 10:03:59 -07001874 main.intentFunction.report( main )