blob: 11f422b8ed4dc29222784ab45826cc4a845ce547 [file] [log] [blame]
GlennRC5147a422015-10-06 17:26:17 -07001class FUNCflow:
2
3 def __init__( self ):
4 self.default = ''
5
6 def CASE1( self, main ):
7 import time
8 import os
9 import imp
10
11 """
12 - Construct tests variables
13 - GIT ( optional )
14 - Checkout ONOS master branch
15 - Pull latest ONOS code
16 - Building ONOS ( optional )
17 - Install ONOS package
18 - Build ONOS package
19 """
20
21 main.case( "Constructing test variables and building ONOS package" )
22 main.step( "Constructing test variables" )
23 stepResult = main.FALSE
24
25 # Test variables
26 main.testOnDirectory = os.path.dirname( os.getcwd ( ) )
27 main.cellName = main.params[ 'ENV' ][ 'cellName' ]
28 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
29 gitBranch = main.params[ 'GIT' ][ 'branch' ]
GlennRC073e8bc2015-10-27 17:11:28 -070030 gitPull = main.params[ 'GIT' ][ 'pull' ]
31 main.ONOSport = main.params[ 'CTRL' ][ 'port' ]
GlennRC5147a422015-10-06 17:26:17 -070032 main.dependencyPath = main.testOnDirectory + \
33 main.params[ 'DEPENDENCY' ][ 'path' ]
GlennRC5147a422015-10-06 17:26:17 -070034 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
GlennRC1704d072015-10-07 18:40:45 -070035 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
GlennRC073e8bc2015-10-27 17:11:28 -070036 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
37 main.maxNodes = int( main.params[ 'SCALE' ][ 'max' ] )
GlennRC5147a422015-10-06 17:26:17 -070038 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
GlennRC073e8bc2015-10-27 17:11:28 -070039 main.startMNSleep = int( main.params[ 'SLEEP' ][ 'startMN' ] )
40 main.addFlowSleep = int( main.params[ 'SLEEP' ][ 'addFlow' ] )
41 main.delFlowSleep = int( main.params[ 'SLEEP' ][ 'delFlow' ] )
GlennRC956ea742015-11-05 16:14:15 -080042 main.debug = main.params['DEBUG']
GlennRC073e8bc2015-10-27 17:11:28 -070043 main.swDPID = main.params[ 'TEST' ][ 'swDPID' ]
GlennRC5147a422015-10-06 17:26:17 -070044 main.cellData = {} # for creating cell file
45 main.CLIs = []
46 main.ONOSip = []
47
GlennRC956ea742015-11-05 16:14:15 -080048 main.debug = True if "on" in main.debug else False
49
GlennRC5147a422015-10-06 17:26:17 -070050 main.ONOSip = main.ONOSbench.getOnosIps()
GlennRC5147a422015-10-06 17:26:17 -070051
52 # Assigning ONOS cli handles to a list
53 for i in range( 1, main.maxNodes + 1 ):
54 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
55
56 # -- INIT SECTION, ONLY RUNS ONCE -- #
57 main.startUp = imp.load_source( wrapperFile1,
58 main.dependencyPath +
59 wrapperFile1 +
60 ".py" )
61
GlennRC1704d072015-10-07 18:40:45 -070062 main.topo = imp.load_source( wrapperFile2,
63 main.dependencyPath +
64 wrapperFile2 +
65 ".py" )
66
GlennRC956ea742015-11-05 16:14:15 -080067
GlennRC94ed2232015-10-07 15:08:57 -070068 copyResult = main.ONOSbench.scp( main.Mininet1,
69 main.dependencyPath+main.topology,
70 main.Mininet1.home+'/custom/',
71 direction="to" )
72
GlennRC5147a422015-10-06 17:26:17 -070073 if main.CLIs:
74 stepResult = main.TRUE
75 else:
76 main.log.error( "Did not properly created list of ONOS CLI handle" )
77 stepResult = main.FALSE
78
79 utilities.assert_equals( expect=main.TRUE,
80 actual=stepResult,
81 onpass="Successfully construct " +
82 "test variables ",
83 onfail="Failed to construct test variables" )
84
85 if gitPull == 'True':
86 main.step( "Building ONOS in " + gitBranch + " branch" )
87 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
88 stepResult = onosBuildResult
89 utilities.assert_equals( expect=main.TRUE,
90 actual=stepResult,
91 onpass="Successfully compiled " +
92 "latest ONOS",
93 onfail="Failed to compile " +
94 "latest ONOS" )
95 else:
96 main.log.warn( "Did not pull new code so skipping mvn " +
97 "clean install" )
98
99 def CASE2( self, main ):
100 """
101 - Set up cell
102 - Create cell file
103 - Set cell file
104 - Verify cell file
105 - Kill ONOS process
106 - Uninstall ONOS cluster
107 - Verify ONOS start up
108 - Install ONOS cluster
109 - Connect to cli
110 """
111
112 main.numCtrls = int( main.maxNodes )
113
114 main.case( "Starting up " + str( main.numCtrls ) +
115 " node(s) ONOS cluster" )
116
117 #kill off all onos processes
118 main.log.info( "Safety check, killing all ONOS processes" +
Jon Hall70b2ff42015-11-17 15:49:44 -0800119 " before initiating environment setup" )
GlennRC5147a422015-10-06 17:26:17 -0700120
121 for i in range( main.maxNodes ):
122 main.ONOSbench.onosDie( main.ONOSip[ i ] )
123
124 print "NODE COUNT = ", main.numCtrls
125
126 tempOnosIp = []
127 for i in range( main.numCtrls ):
128 tempOnosIp.append( main.ONOSip[i] )
129
130 main.ONOSbench.createCellFile( main.ONOSbench.ip_address, "temp", main.Mininet1.ip_address, main.apps, tempOnosIp )
131
132 main.step( "Apply cell to environment" )
133 cellResult = main.ONOSbench.setCell( "temp" )
134 verifyResult = main.ONOSbench.verifyCell()
135 stepResult = cellResult and verifyResult
136 utilities.assert_equals( expect=main.TRUE,
137 actual=stepResult,
138 onpass="Successfully applied cell to " + \
139 "environment",
140 onfail="Failed to apply cell to environment " )
141
142 main.step( "Creating ONOS package" )
143 packageResult = main.ONOSbench.onosPackage()
144 stepResult = packageResult
145 utilities.assert_equals( expect=main.TRUE,
146 actual=stepResult,
147 onpass="Successfully created ONOS package",
148 onfail="Failed to create ONOS package" )
149
150 time.sleep( main.startUpSleep )
151 main.step( "Uninstalling ONOS package" )
152 onosUninstallResult = main.TRUE
Jeremy86160992016-04-11 10:05:53 -0700153 for ip in main.ONOSip:
GlennRC5147a422015-10-06 17:26:17 -0700154 onosUninstallResult = onosUninstallResult and \
Jeremy86160992016-04-11 10:05:53 -0700155 main.ONOSbench.onosUninstall( nodeIp=ip )
GlennRC5147a422015-10-06 17:26:17 -0700156 stepResult = onosUninstallResult
157 utilities.assert_equals( expect=main.TRUE,
158 actual=stepResult,
159 onpass="Successfully uninstalled ONOS package",
160 onfail="Failed to uninstall ONOS package" )
GlennRC5147a422015-10-06 17:26:17 -0700161 time.sleep( main.startUpSleep )
162 main.step( "Installing ONOS package" )
163 onosInstallResult = main.TRUE
164 for i in range( main.numCtrls ):
165 onosInstallResult = onosInstallResult and \
166 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
167 stepResult = onosInstallResult
168 utilities.assert_equals( expect=main.TRUE,
169 actual=stepResult,
170 onpass="Successfully installed ONOS package",
171 onfail="Failed to install ONOS package" )
172
173 time.sleep( main.startUpSleep )
174 main.step( "Starting ONOS service" )
175 stopResult = main.TRUE
176 startResult = main.TRUE
177 onosIsUp = main.TRUE
178
179 for i in range( main.numCtrls ):
180 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
181 if onosIsUp == main.TRUE:
182 main.log.report( "ONOS instance is up and ready" )
183 else:
184 main.log.report( "ONOS instance may not be up, stop and " +
185 "start ONOS again " )
186 for i in range( main.numCtrls ):
187 stopResult = stopResult and \
188 main.ONOSbench.onosStop( main.ONOSip[ i ] )
189 for i in range( main.numCtrls ):
190 startResult = startResult and \
191 main.ONOSbench.onosStart( main.ONOSip[ i ] )
192 stepResult = onosIsUp and stopResult and startResult
193 utilities.assert_equals( expect=main.TRUE,
194 actual=stepResult,
195 onpass="ONOS service is ready",
196 onfail="ONOS service did not start properly" )
197
198 main.step( "Start ONOS cli" )
199 cliResult = main.TRUE
200 for i in range( main.numCtrls ):
201 cliResult = cliResult and \
202 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
203 stepResult = cliResult
204 utilities.assert_equals( expect=main.TRUE,
205 actual=stepResult,
206 onpass="Successfully start ONOS cli",
207 onfail="Failed to start ONOS cli" )
208
GlennRC68449942015-10-16 16:03:12 -0700209 def CASE10( self, main ):
210 '''
211 Start Mininet
212 '''
GlennRC073e8bc2015-10-27 17:11:28 -0700213 import json
214
215 main.case( "Setup mininet and compare ONOS topology view to Mininet topology" )
216 main.caseExplanation = "Start mininet with custom topology and compare topology " +\
217 "elements between Mininet and ONOS"
218
GlennRC68449942015-10-16 16:03:12 -0700219 main.step( "Setup Mininet Topology" )
220 topology = main.Mininet1.home + '/custom/' + main.topology
GlennRC073e8bc2015-10-27 17:11:28 -0700221 stepResult = main.Mininet1.startNet( topoFile=topology )
GlennRC68449942015-10-16 16:03:12 -0700222
223 utilities.assert_equals( expect=main.TRUE,
GlennRC073e8bc2015-10-27 17:11:28 -0700224 actual=stepResult,
GlennRC68449942015-10-16 16:03:12 -0700225 onpass="Successfully loaded topology",
226 onfail="Failed to load topology" )
227
GlennRC073e8bc2015-10-27 17:11:28 -0700228 main.step( "Assign switch to controller" )
229 stepResult = main.Mininet1.assignSwController( "s1", main.ONOSip[0] )
GlennRC68449942015-10-16 16:03:12 -0700230
231 utilities.assert_equals( expect=main.TRUE,
GlennRC073e8bc2015-10-27 17:11:28 -0700232 actual=stepResult,
233 onpass="Successfully assigned switch to controller",
234 onfail="Failed to assign switch to controller" )
GlennRC68449942015-10-16 16:03:12 -0700235
GlennRC073e8bc2015-10-27 17:11:28 -0700236 time.sleep( main.startMNSleep )
GlennRC68449942015-10-16 16:03:12 -0700237
Jon Hall70b2ff42015-11-17 15:49:44 -0800238 main.step( "Comparing MN topology to ONOS topology" )
GlennRC073e8bc2015-10-27 17:11:28 -0700239 main.log.info( "Gathering topology information" )
GlennRC1704d072015-10-07 18:40:45 -0700240 devicesResults = main.TRUE
241 linksResults = main.TRUE
242 hostsResults = main.TRUE
243 devices = main.topo.getAllDevices( main )
244 hosts = main.topo.getAllHosts( main )
245 ports = main.topo.getAllPorts( main )
246 links = main.topo.getAllLinks( main )
247 clusters = main.topo.getAllClusters( main )
248
249 mnSwitches = main.Mininet1.getSwitches()
250 mnLinks = main.Mininet1.getLinks()
251 mnHosts = main.Mininet1.getHosts()
252
GlennRC1704d072015-10-07 18:40:45 -0700253 for controller in range( main.numCtrls ):
254 controllerStr = str( controller + 1 )
255 if devices[ controller ] and ports[ controller ] and\
256 "Error" not in devices[ controller ] and\
257 "Error" not in ports[ controller ]:
258
259 currentDevicesResult = main.Mininet1.compareSwitches(
260 mnSwitches,
261 json.loads( devices[ controller ] ),
262 json.loads( ports[ controller ] ) )
263 else:
264 currentDevicesResult = main.FALSE
265 utilities.assert_equals( expect=main.TRUE,
266 actual=currentDevicesResult,
267 onpass="ONOS" + controllerStr +
GlennRC68449942015-10-16 16:03:12 -0700268 " Switches view is correct",
GlennRC1704d072015-10-07 18:40:45 -0700269 onfail="ONOS" + controllerStr +
GlennRC68449942015-10-16 16:03:12 -0700270 " Switches view is incorrect" )
GlennRC1704d072015-10-07 18:40:45 -0700271 if links[ controller ] and "Error" not in links[ controller ]:
272 currentLinksResult = main.Mininet1.compareLinks(
273 mnSwitches, mnLinks,
274 json.loads( links[ controller ] ) )
275 else:
276 currentLinksResult = main.FALSE
277 utilities.assert_equals( expect=main.TRUE,
278 actual=currentLinksResult,
279 onpass="ONOS" + controllerStr +
GlennRC68449942015-10-16 16:03:12 -0700280 " links view is correct",
GlennRC1704d072015-10-07 18:40:45 -0700281 onfail="ONOS" + controllerStr +
GlennRC68449942015-10-16 16:03:12 -0700282 " links view is incorrect" )
GlennRC1704d072015-10-07 18:40:45 -0700283
284 if hosts[ controller ] or "Error" not in hosts[ controller ]:
285 currentHostsResult = main.Mininet1.compareHosts(
286 mnHosts,
287 json.loads( hosts[ controller ] ) )
288 else:
289 currentHostsResult = main.FALSE
290 utilities.assert_equals( expect=main.TRUE,
291 actual=currentHostsResult,
292 onpass="ONOS" + controllerStr +
GlennRC68449942015-10-16 16:03:12 -0700293 " hosts exist in Mininet",
GlennRC1704d072015-10-07 18:40:45 -0700294 onfail="ONOS" + controllerStr +
GlennRC68449942015-10-16 16:03:12 -0700295 " hosts don't match Mininet")
GlennRCa5391372015-10-14 17:28:15 -0700296
GlennRC68449942015-10-16 16:03:12 -0700297
Jon Hall892818c2015-10-20 17:58:34 -0700298 def CASE66( self, main ):
299 '''
300 Testing scapy
301 '''
302 main.case( "Testing scapy" )
303 main.step( "Creating Host1 component" )
304 main.Mininet1.createHostComponent( "h1" )
305 main.Mininet1.createHostComponent( "h2" )
306 hosts = [main.h1, main.h2]
307 for host in hosts:
308 host.startHostCli()
309 host.startScapy()
310 host.updateSelf()
311 main.log.debug( host.name )
312 main.log.debug( host.hostIp )
313 main.log.debug( host.hostMac )
314
315 main.step( "Sending/Receiving Test packet - Filter doesn't match" )
316 main.h2.startFilter()
317 main.h1.buildEther( dst=main.h2.hostMac )
318 main.h1.sendPacket( )
319 finished = main.h2.checkFilter()
320 i = ""
321 if finished:
322 a = main.h2.readPackets()
323 for i in a.splitlines():
324 main.log.info( i )
325 else:
326 kill = main.h2.killFilter()
327 main.log.debug( kill )
328 main.h2.handle.sendline( "" )
329 main.h2.handle.expect( main.h2.scapyPrompt )
330 main.log.debug( main.h2.handle.before )
331 utilities.assert_equals( expect=True,
332 actual="dst=00:00:00:00:00:02 src=00:00:00:00:00:01" in i,
333 onpass="Pass",
334 onfail="Fail" )
335
336 main.step( "Sending/Receiving Test packet - Filter matches" )
337 main.h2.startFilter()
338 main.h1.buildEther( dst=main.h2.hostMac )
339 main.h1.buildIP( dst=main.h2.hostIp )
340 main.h1.sendPacket( )
341 finished = main.h2.checkFilter()
342 i = ""
343 if finished:
344 a = main.h2.readPackets()
345 for i in a.splitlines():
346 main.log.info( i )
347 else:
348 kill = main.h2.killFilter()
349 main.log.debug( kill )
350 main.h2.handle.sendline( "" )
351 main.h2.handle.expect( main.h2.scapyPrompt )
352 main.log.debug( main.h2.handle.before )
353 utilities.assert_equals( expect=True,
354 actual="dst=00:00:00:00:00:02 src=00:00:00:00:00:01" in i,
355 onpass="Pass",
356 onfail="Fail" )
357
358
359
360 main.step( "Clean up host components" )
361 for host in hosts:
362 host.stopScapy()
363 main.Mininet1.removeHostComponent("h1")
364 main.Mininet1.removeHostComponent("h2")
365
GlennRC68449942015-10-16 16:03:12 -0700366 def CASE1000( self, main ):
367 '''
GlennRC073e8bc2015-10-27 17:11:28 -0700368 Add flows with MAC selectors and verify the flows
GlennRC68449942015-10-16 16:03:12 -0700369 '''
GlennRC073e8bc2015-10-27 17:11:28 -0700370 import json
371 import time
GlennRC68449942015-10-16 16:03:12 -0700372
GlennRC073e8bc2015-10-27 17:11:28 -0700373 main.case( "Verify flow MAC selectors are correctly compiled" )
374 main.caseExplanation = "Install two flows with only MAC selectors " +\
375 "specified, then verify flows are added in ONOS, finally "+\
376 "send a packet that only specifies the MAC src and dst."
GlennRC68449942015-10-16 16:03:12 -0700377
GlennRC073e8bc2015-10-27 17:11:28 -0700378 main.step( "Add flows with MAC addresses as the only selectors" )
GlennRC68449942015-10-16 16:03:12 -0700379
GlennRC073e8bc2015-10-27 17:11:28 -0700380 main.log.info( "Creating host components" )
381 main.Mininet1.createHostComponent( "h1" )
382 main.Mininet1.createHostComponent( "h2" )
383 hosts = [main.h1, main.h2]
384 stepResult = main.TRUE
385 for host in hosts:
386 host.startHostCli()
387 host.startScapy()
388 host.updateSelf()
GlennRC68449942015-10-16 16:03:12 -0700389
GlennRC073e8bc2015-10-27 17:11:28 -0700390 # Add a flow that connects host1 on port1 to host2 on port2
391 # send output on port2
392 # recieve input on port1
393 egress = 2
394 ingress = 1
395
396 # Add flows that sends packets from port1 to port2 with correct
397 # MAC src and dst addresses
398 main.log.info( "Adding flow with MAC selectors" )
399 stepResult = main.ONOSrest.addFlow( deviceId=main.swDPID,
400 egressPort=egress,
401 ingressPort=ingress,
402 ethSrc=main.h1.hostMac,
403 ethDst=main.h2.hostMac,
GlennRC956ea742015-11-05 16:14:15 -0800404 debug=main.debug )
GlennRC68449942015-10-16 16:03:12 -0700405
GlennRCa5391372015-10-14 17:28:15 -0700406 utilities.assert_equals( expect=main.TRUE,
407 actual=stepResult,
GlennRC68449942015-10-16 16:03:12 -0700408 onpass="Successfully added flows",
409 onfail="Failed add flows" )
GlennRCa5391372015-10-14 17:28:15 -0700410
GlennRC073e8bc2015-10-27 17:11:28 -0700411 # Giving ONOS time to add the flows
412 time.sleep( main.addFlowSleep )
GlennRC5147a422015-10-06 17:26:17 -0700413
GlennRC073e8bc2015-10-27 17:11:28 -0700414 main.step( "Check flows are in the ADDED state" )
415
GlennRC073e8bc2015-10-27 17:11:28 -0700416 main.log.info( "Get the flows from ONOS" )
Jeremy86160992016-04-11 10:05:53 -0700417 try:
418 flows = json.loads( main.ONOSrest.flows() )
GlennRC68449942015-10-16 16:03:12 -0700419
Jeremy86160992016-04-11 10:05:53 -0700420 stepResult = main.TRUE
421 for f in flows:
422 if "rest" in f.get("appId"):
423 if "ADDED" not in f.get("state"):
424 stepResult = main.FALSE
425 main.log.error( "Flow: %s in state: %s" % (f.get("id"), f.get("state")) )
426 except TypeError:
427 main.log.error( "No Flows found by the REST API" )
428 stepResult = main.FALSE
429 except ValueError:
430 main.log.error( "Problem getting Flows state from REST API. Exiting test" )
431 main.cleanup()
432 main.exit()
GlennRC68449942015-10-16 16:03:12 -0700433
434 utilities.assert_equals( expect=main.TRUE,
435 actual=stepResult,
436 onpass="All flows are in the ADDED state",
GlennRC073e8bc2015-10-27 17:11:28 -0700437 onfail="All flows are NOT in the ADDED state" )
GlennRC68449942015-10-16 16:03:12 -0700438
GlennRC956ea742015-11-05 16:14:15 -0800439 main.step( "Check flows are in Mininet's flow table" )
440
441 # get the flow IDs that were added through rest
442 main.log.info( "Getting the flow IDs from ONOS" )
443 flowIds = [ f.get("id") for f in flows if "rest" in f.get("appId") ]
444 # convert the flowIDs to ints then hex and finally back to strings
445 flowIds = [str(hex(int(x))) for x in flowIds]
446 main.log.info( "ONOS flow IDs: {}".format(flowIds) )
447
448 stepResult = main.Mininet1.checkFlowId( "s1", flowIds, debug=False )
449
450 utilities.assert_equals( expect=main.TRUE,
451 actual=stepResult,
452 onpass="All flows are in mininet",
453 onfail="All flows are NOT in mininet" )
454
GlennRC073e8bc2015-10-27 17:11:28 -0700455 main.step( "Send a packet to verify the flows are correct" )
456
457 # Specify the src and dst MAC addr
458 main.log.info( "Constructing packet" )
459 main.h1.buildEther( src=main.h1.hostMac, dst=main.h2.hostMac )
460
461 # Filter for packets with the correct host name. Otherwise,
462 # the filter we catch any packet that is sent to host2
463 # NOTE: I believe it doesn't matter which host name it is,
GlennRC956ea742015-11-05 16:14:15 -0800464 # as long as the src and dst are both specified
GlennRC073e8bc2015-10-27 17:11:28 -0700465 main.log.info( "Starting filter on host2" )
466 main.h2.startFilter( pktFilter="ether host %s" % main.h1.hostMac)
467
468 main.log.info( "Sending packet to host2" )
469 main.h1.sendPacket()
470
471 main.log.info( "Checking filter for our packet" )
472 stepResult = main.h2.checkFilter()
473 if stepResult:
474 main.log.info( "Packet: %s" % main.h2.readPackets() )
475 else: main.h2.killFilter()
476
477 main.log.info( "Clean up host components" )
478 for host in hosts:
479 host.stopScapy()
480 main.Mininet1.removeHostComponent("h1")
481 main.Mininet1.removeHostComponent("h2")
482
483 utilities.assert_equals( expect=main.TRUE,
484 actual=stepResult,
485 onpass="Successfully sent a packet",
486 onfail="Failed to send a packet" )
487
488 def CASE1100( self, main ):
GlennRC68449942015-10-16 16:03:12 -0700489 '''
GlennRC073e8bc2015-10-27 17:11:28 -0700490 Add flows with IPv4 selectors and verify the flows
GlennRC68449942015-10-16 16:03:12 -0700491 '''
492 import json
GlennRC073e8bc2015-10-27 17:11:28 -0700493 import time
GlennRC68449942015-10-16 16:03:12 -0700494
GlennRC073e8bc2015-10-27 17:11:28 -0700495 main.case( "Verify flow IP selectors are correctly compiled" )
496 main.caseExplanation = "Install two flows with only IP selectors " +\
497 "specified, then verify flows are added in ONOS, finally "+\
498 "send a packet that only specifies the IP src and dst."
499
500 main.step( "Add flows with IPv4 addresses as the only selectors" )
501
502 main.log.info( "Creating host components" )
503 main.Mininet1.createHostComponent( "h1" )
504 main.Mininet1.createHostComponent( "h2" )
505 hosts = [main.h1, main.h2]
506 stepResult = main.TRUE
507 for host in hosts:
508 host.startHostCli()
509 host.startScapy()
510 host.updateSelf()
511
512 # Add a flow that connects host1 on port1 to host2 on port2
513 # send output on port2
514 # recieve input on port1
515 egress = 2
516 ingress = 1
517 # IPv4 etherType = 0x800
518 IPv4=2048
519
520 # Add flows that connects host1 to host2
521 main.log.info( "Add flow with port ingress 1 to port egress 2" )
522 stepResult = main.ONOSrest.addFlow( deviceId=main.swDPID,
523 egressPort=egress,
524 ingressPort=ingress,
525 ethType=IPv4,
526 ipSrc=("IPV4_SRC", main.h1.hostIp+"/32"),
527 ipDst=("IPV4_DST", main.h2.hostIp+"/32"),
GlennRC956ea742015-11-05 16:14:15 -0800528 debug=main.debug )
GlennRC073e8bc2015-10-27 17:11:28 -0700529
530 utilities.assert_equals( expect=main.TRUE,
531 actual=stepResult,
532 onpass="Successfully added flows",
533 onfail="Failed add flows" )
534
535 # Giving ONOS time to add the flow
536 time.sleep( main.addFlowSleep )
537
538 main.step( "Check flow is in the ADDED state" )
539
540 main.log.info( "Get the flows from ONOS" )
Jeremy86160992016-04-11 10:05:53 -0700541 try:
542 flows = json.loads( main.ONOSrest.flows() )
GlennRC68449942015-10-16 16:03:12 -0700543
Jeremy86160992016-04-11 10:05:53 -0700544 stepResult = main.TRUE
545 for f in flows:
546 if "rest" in f.get("appId"):
547 if "ADDED" not in f.get("state"):
548 stepResult = main.FALSE
549 main.log.error( "Flow: %s in state: %s" % (f.get("id"), f.get("state")) )
550 except TypeError:
551 main.log.error( "No Flows found by the REST API" )
552 stepResult = main.FALSE
553 except ValueError:
554 main.log.error( "Problem getting Flows state from REST API. Exiting test" )
555 main.cleanup()
556 main.exit()
GlennRC68449942015-10-16 16:03:12 -0700557
558 utilities.assert_equals( expect=main.TRUE,
559 actual=stepResult,
GlennRC073e8bc2015-10-27 17:11:28 -0700560 onpass="All flows are in the ADDED state",
561 onfail="All flows are NOT in the ADDED state" )
562
GlennRC956ea742015-11-05 16:14:15 -0800563 main.step( "Check flows are in Mininet's flow table" )
564
565 # get the flow IDs that were added through rest
566 main.log.info( "Getting the flow IDs from ONOS" )
567 flowIds = [ f.get("id") for f in flows if "rest" in f.get("appId") ]
568 # convert the flowIDs to ints then hex and finally back to strings
569 flowIds = [str(hex(int(x))) for x in flowIds]
570 main.log.info( "ONOS flow IDs: {}".format(flowIds) )
571
572 stepResult = main.Mininet1.checkFlowId( "s1", flowIds, debug=False )
573
574 utilities.assert_equals( expect=main.TRUE,
575 actual=stepResult,
576 onpass="All flows are in mininet",
577 onfail="All flows are NOT in mininet" )
578
GlennRC073e8bc2015-10-27 17:11:28 -0700579 main.step( "Send a packet to verify the flow is correct" )
580
581 main.log.info( "Constructing packet" )
582 # No need for the MAC src dst
583 main.h1.buildEther( dst=main.h2.hostMac )
584 main.h1.buildIP( src=main.h1.hostIp, dst=main.h2.hostIp )
585
586 main.log.info( "Starting filter on host2" )
587 # Defaults to ip
588 main.h2.startFilter()
589
590 main.log.info( "Sending packet to host2" )
591 main.h1.sendPacket()
592
593 main.log.info( "Checking filter for our packet" )
594 stepResult = main.h2.checkFilter()
595 if stepResult:
596 main.log.info( "Packet: %s" % main.h2.readPackets() )
597 else: main.h2.killFilter()
598
599 main.log.info( "Clean up host components" )
600 for host in hosts:
601 host.stopScapy()
602 main.Mininet1.removeHostComponent("h1")
603 main.Mininet1.removeHostComponent("h2")
604
605 utilities.assert_equals( expect=main.TRUE,
606 actual=stepResult,
607 onpass="Successfully sent a packet",
608 onfail="Failed to send a packet" )
609
610 def CASE1200( self, main ):
611 '''
612 Add flow with VLAN selector and verify the flow
613 '''
614 import json
615 import time
616
617 main.case( "Verify VLAN selector is correctly compiled" )
618 main.caseExplanation = "Install one flow with only the VLAN selector " +\
619 "specified, then verify the flow is added in ONOS, and finally "+\
620 "broadcast a packet with the correct VLAN tag."
621
622 # We do this here to utilize the hosts information
623 main.log.info( "Creating host components" )
624 main.Mininet1.createHostComponent( "h3" )
625 main.Mininet1.createHostComponent( "h4" )
626 hosts = [main.h3, main.h4]
627 stepResult = main.TRUE
628 for host in hosts:
629 host.startHostCli()
630 host.startScapy()
631 host.updateSelf()
632
633
634 main.step( "Add a flow with the VLAN tag as the only selector" )
635
636 # Add flows that connects the two vlan hosts h3 and h4
637 # Host 3 is on port 3 and host 4 is on port 4
638 vlan = main.params[ 'TEST' ][ 'vlan' ]
639 egress = 4
640 ingress = 3
641 # VLAN ethType = 0x8100
642 ethType = 33024
643
644 # Add only one flow because we don't need a response
645 main.log.info( "Add flow with port ingress 1 to port egress 2" )
646 stepResult = main.ONOSrest.addFlow( deviceId=main.swDPID,
647 egressPort=egress,
648 ingressPort=ingress,
649 ethType=ethType,
650 vlan=vlan,
GlennRC956ea742015-11-05 16:14:15 -0800651 debug=main.debug )
GlennRC073e8bc2015-10-27 17:11:28 -0700652
653
654 utilities.assert_equals( expect=main.TRUE,
655 actual=stepResult,
656 onpass="Successfully added flow",
657 onfail="Failed add flows" )
658
659 # Giving ONOS time to add the flows
660 time.sleep( main.addFlowSleep )
661
662 main.step( "Check flows are in the ADDED state" )
663
664 main.log.info( "Get the flows from ONOS" )
Jeremy86160992016-04-11 10:05:53 -0700665 try:
666 flows = json.loads( main.ONOSrest.flows() )
GlennRC073e8bc2015-10-27 17:11:28 -0700667
Jeremy86160992016-04-11 10:05:53 -0700668 stepResult = main.TRUE
669 for f in flows:
670 if "rest" in f.get("appId"):
671 if "ADDED" not in f.get("state"):
672 stepResult = main.FALSE
673 main.log.error( "Flow: %s in state: %s" % (f.get("id"), f.get("state")) )
674 except TypeError:
675 main.log.error( "No Flows found by the REST API" )
676 stepResult = main.FALSE
677 except ValueError:
678 main.log.error( "Problem getting Flows state from REST API. Exiting test" )
679 main.cleanup()
680 main.exit()
GlennRC073e8bc2015-10-27 17:11:28 -0700681
682 utilities.assert_equals( expect=main.TRUE,
683 actual=stepResult,
684 onpass="All flows are in the ADDED state",
685 onfail="All flows are NOT in the ADDED state" )
686
GlennRC956ea742015-11-05 16:14:15 -0800687 main.step( "Check flows are in Mininet's flow table" )
688
689 # get the flow IDs that were added through rest
690 main.log.info( "Getting the flow IDs from ONOS" )
691 flowIds = [ f.get("id") for f in flows if "rest" in f.get("appId") ]
692 # convert the flowIDs to ints then hex and finally back to strings
693 flowIds = [str(hex(int(x))) for x in flowIds]
694 main.log.info( "ONOS flow IDs: {}".format(flowIds) )
695
696 stepResult = main.Mininet1.checkFlowId( "s1", flowIds, debug=False )
697
698 utilities.assert_equals( expect=main.TRUE,
699 actual=stepResult,
700 onpass="All flows are in mininet",
701 onfail="All flows are NOT in mininet" )
702
GlennRC073e8bc2015-10-27 17:11:28 -0700703 main.step( "Send a packet to verify the flow are correct" )
704
705 # The receiving interface
706 recIface = "{}-eth0.{}".format(main.h4.name, vlan)
707 main.log.info( "Starting filter on host2" )
708 # Filter is setup to catch any packet on the vlan interface with the correct vlan tag
709 main.h4.startFilter( ifaceName=recIface, pktFilter="" )
710
711 # Broadcast the packet on the vlan interface. We only care if the flow forwards
712 # the packet with the correct vlan tag, not if the mac addr is correct
GlennRC073e8bc2015-10-27 17:11:28 -0700713 sendIface = "{}-eth0.{}".format(main.h3.name, vlan)
714 main.log.info( "Broadcasting the packet with a vlan tag" )
GlennRC956ea742015-11-05 16:14:15 -0800715 main.h3.sendPacket( iface=sendIface,
716 packet="Ether()/Dot1Q(vlan={})".format(vlan) )
GlennRC073e8bc2015-10-27 17:11:28 -0700717
718 main.log.info( "Checking filter for our packet" )
719 stepResult = main.h4.checkFilter()
720 if stepResult:
721 main.log.info( "Packet: %s" % main.h4.readPackets() )
722 else: main.h4.killFilter()
723
724 main.log.info( "Clean up host components" )
725 for host in hosts:
726 host.stopScapy()
727 main.Mininet1.removeHostComponent("h3")
728 main.Mininet1.removeHostComponent("h4")
729
730 utilities.assert_equals( expect=main.TRUE,
731 actual=stepResult,
732 onpass="Successfully sent a packet",
733 onfail="Failed to send a packet" )
GlennRC68449942015-10-16 16:03:12 -0700734
GlennRC956ea742015-11-05 16:14:15 -0800735 def CASE1300( self, main ):
736 '''
737 Add flows with MPLS selector and verify the flows
738 '''
739 import json
740 import time
741
742 main.case( "Verify the MPLS selector is correctly compiled on the flow." )
743 main.caseExplanation = "Install one flow with an MPLS selector, " +\
744 "verify the flow is added in ONOS, and finally "+\
745 "send a packet via scapy that has a MPLS label."
746
747 main.step( "Add a flow with a MPLS selector" )
748
749 main.log.info( "Creating host components" )
750 main.Mininet1.createHostComponent( "h1" )
751 main.Mininet1.createHostComponent( "h2" )
752 hosts = [main.h1, main.h2]
753 stepResult = main.TRUE
754 for host in hosts:
755 host.startHostCli()
756 host.startScapy( main.dependencyPath )
757 host.updateSelf()
758
759 # ports
760 egress = 2
761 ingress = 1
762 # MPLS etherType
763 ethType = main.params[ 'TEST' ][ 'mplsType' ]
764 # MPLS label
765 mplsLabel = main.params[ 'TEST' ][ 'mpls' ]
766
767 # Add a flow that connects host1 on port1 to host2 on port2
768 main.log.info( "Adding flow with MPLS selector" )
769 stepResult = main.ONOSrest.addFlow( deviceId=main.swDPID,
770 egressPort=egress,
771 ingressPort=ingress,
772 ethType=ethType,
773 mpls=mplsLabel,
774 debug=main.debug )
775
776 utilities.assert_equals( expect=main.TRUE,
777 actual=stepResult,
778 onpass="Successfully added flow",
779 onfail="Failed add flow" )
780
781 # Giving ONOS time to add the flow
782 time.sleep( main.addFlowSleep )
783
784 main.step( "Check flow is in the ADDED state" )
785
786 main.log.info( "Get the flows from ONOS" )
Jeremy86160992016-04-11 10:05:53 -0700787 try:
788 flows = json.loads( main.ONOSrest.flows() )
GlennRC956ea742015-11-05 16:14:15 -0800789
Jeremy86160992016-04-11 10:05:53 -0700790 stepResult = main.TRUE
791 for f in flows:
792 if "rest" in f.get("appId"):
793 if "ADDED" not in f.get("state"):
794 stepResult = main.FALSE
795 main.log.error( "Flow: %s in state: %s" % (f.get("id"), f.get("state")) )
796 except TypeError:
797 main.log.error( "No Flows found by the REST API" )
798 stepResult = main.FALSE
799 except ValueError:
800 main.log.error( "Problem getting Flows state from REST API. Exiting test" )
801 main.cleanup()
802 main.exit()
GlennRC956ea742015-11-05 16:14:15 -0800803
804 utilities.assert_equals( expect=main.TRUE,
805 actual=stepResult,
806 onpass="All flows are in the ADDED state",
807 onfail="All flows are NOT in the ADDED state" )
808
809 main.step( "Check flows are in Mininet's flow table" )
810
811 # get the flow IDs that were added through rest
812 main.log.info( "Getting the flow IDs from ONOS" )
813 flowIds = [ f.get("id") for f in flows if "rest" in f.get("appId") ]
814 # convert the flowIDs to ints then hex and finally back to strings
815 flowIds = [str(hex(int(x))) for x in flowIds]
816 main.log.info( "ONOS flow IDs: {}".format(flowIds) )
817
818 stepResult = main.Mininet1.checkFlowId( "s1", flowIds, debug=True )
819
820 utilities.assert_equals( expect=main.TRUE,
821 actual=stepResult,
822 onpass="All flows are in mininet",
823 onfail="All flows are NOT in mininet" )
824
825 main.step( "Send a packet to verify the flow is correct" )
826
827 main.log.info( "Starting filter on host2" )
828 main.h2.startFilter( pktFilter="mpls" )
829
830 main.log.info( "Constructing packet" )
831 main.log.info( "Sending packet to host2" )
832 main.h1.sendPacket( packet='Ether()/MPLS(label={})'.format(mplsLabel) )
833
834 main.log.info( "Checking filter for our packet" )
835 stepResult = main.h2.checkFilter()
836 if stepResult:
837 main.log.info( "Packet: %s" % main.h2.readPackets() )
838 else: main.h2.killFilter()
839
840 main.log.info( "Clean up host components" )
841 for host in hosts:
842 host.stopScapy()
843 main.Mininet1.removeHostComponent("h1")
844 main.Mininet1.removeHostComponent("h2")
845
846 utilities.assert_equals( expect=main.TRUE,
847 actual=stepResult,
848 onpass="Successfully sent a packet",
849 onfail="Failed to send a packet" )
850
851 def CASE1400( self, main ):
852 '''
853 Add flows with a TCP selector and verify the flow
854 '''
855 import json
856 import time
857
858 main.case( "Verify the TCP selector is correctly compiled on the flow" )
859 main.caseExplanation = "Install a flow with only the TCP selector " +\
860 "specified, verify the flow is added in ONOS, and finally "+\
861 "send a TCP packet to verify the TCP selector is compiled correctly."
862
863 main.step( "Add a flow with a TCP selector" )
864
865 main.log.info( "Creating host components" )
866 main.Mininet1.createHostComponent( "h1" )
867 main.Mininet1.createHostComponent( "h2" )
868 hosts = [main.h1, main.h2]
869 stepResult = main.TRUE
870 for host in hosts:
871 host.startHostCli()
872 host.startScapy()
873 host.updateSelf()
874
875 # Add a flow that connects host1 on port1 to host2 on port2
876 egress = 2
877 ingress = 1
878 # IPv4 etherType
879 ethType = main.params[ 'TEST' ][ 'ip4Type' ]
880 # IP protocol
881 ipProto = main.params[ 'TEST' ][ 'tcpProto' ]
882 # TCP port destination
883 tcpDst = main.params[ 'TEST' ][ 'tcpDst' ]
884
885 main.log.info( "Add a flow that connects host1 on port1 to host2 on port2" )
886 stepResult = main.ONOSrest.addFlow( deviceId=main.swDPID,
887 egressPort=egress,
888 ingressPort=ingress,
889 ethType=ethType,
890 ipProto=ipProto,
891 tcpDst=tcpDst,
892 debug=main.debug )
893
894 utilities.assert_equals( expect=main.TRUE,
895 actual=stepResult,
896 onpass="Successfully added flows",
897 onfail="Failed add flows" )
898
899 # Giving ONOS time to add the flow
900 time.sleep( main.addFlowSleep )
901
902 main.step( "Check flow is in the ADDED state" )
903
904 main.log.info( "Get the flows from ONOS" )
Jeremy86160992016-04-11 10:05:53 -0700905 try:
906 flows = json.loads( main.ONOSrest.flows() )
GlennRC956ea742015-11-05 16:14:15 -0800907
Jeremy86160992016-04-11 10:05:53 -0700908 stepResult = main.TRUE
909 for f in flows:
910 if "rest" in f.get("appId"):
911 if "ADDED" not in f.get("state"):
912 stepResult = main.FALSE
913 main.log.error( "Flow: %s in state: %s" % (f.get("id"), f.get("state")) )
914 except TypeError:
915 main.log.error( "No Flows found by the REST API" )
916 stepResult = main.FALSE
917 except ValueError:
918 main.log.error( "Problem getting Flows state from REST API. Exiting test" )
919 main.cleanup()
920 main.exit()
GlennRC956ea742015-11-05 16:14:15 -0800921
922 utilities.assert_equals( expect=main.TRUE,
923 actual=stepResult,
924 onpass="All flows are in the ADDED state",
925 onfail="All flows are NOT in the ADDED state" )
926
927 main.step( "Check flows are in Mininet's flow table" )
928
929 # get the flow IDs that were added through rest
930 main.log.info( "Getting the flow IDs from ONOS" )
931 flowIds = [ f.get("id") for f in flows if "rest" in f.get("appId") ]
932 # convert the flowIDs to ints then hex and finally back to strings
933 flowIds = [str(hex(int(x))) for x in flowIds]
934 main.log.info( "ONOS flow IDs: {}".format(flowIds) )
935
936 stepResult = main.Mininet1.checkFlowId( "s1", flowIds, debug=False )
937
938 utilities.assert_equals( expect=main.TRUE,
939 actual=stepResult,
940 onpass="All flows are in mininet",
941 onfail="All flows are NOT in mininet" )
942
943 main.step( "Send a packet to verify the flow is correct" )
944
945 main.log.info( "Constructing packet" )
946 # No need for the MAC src dst
947 main.h1.buildEther( dst=main.h2.hostMac )
948 main.h1.buildIP( dst=main.h2.hostIp )
949 main.h1.buildTCP( dport=tcpDst )
950
951 main.log.info( "Starting filter on host2" )
952 # Defaults to ip
953 main.h2.startFilter( pktFilter="tcp" )
954
955 main.log.info( "Sending packet to host2" )
956 main.h1.sendPacket()
957
958 main.log.info( "Checking filter for our packet" )
959 stepResult = main.h2.checkFilter()
960 if stepResult:
961 main.log.info( "Packet: %s" % main.h2.readPackets() )
962 else: main.h2.killFilter()
963
964 main.log.info( "Clean up host components" )
965 for host in hosts:
966 host.stopScapy()
967 main.Mininet1.removeHostComponent("h1")
968 main.Mininet1.removeHostComponent("h2")
969
970 utilities.assert_equals( expect=main.TRUE,
971 actual=stepResult,
972 onpass="Successfully sent a packet",
973 onfail="Failed to send a packet" )
974
975 def CASE1500( self, main ):
976 '''
977 Add flows with a UDP selector and verify the flow
978 '''
979 import json
980 import time
981
982 main.case( "Verify the UDP selector is correctly compiled on the flow" )
983 main.caseExplanation = "Install a flow with only the UDP selector " +\
984 "specified, verify the flow is added in ONOS, and finally "+\
985 "send a UDP packet to verify the UDP selector is compiled correctly."
986
987 main.step( "Add a flow with a UDP selector" )
988
989 main.log.info( "Creating host components" )
990 main.Mininet1.createHostComponent( "h1" )
991 main.Mininet1.createHostComponent( "h2" )
992 hosts = [main.h1, main.h2]
993 stepResult = main.TRUE
994 for host in hosts:
995 host.startHostCli()
996 host.startScapy()
997 host.updateSelf()
998
999 # Add a flow that connects host1 on port1 to host2 on port2
1000 egress = 2
1001 ingress = 1
1002 # IPv4 etherType
1003 ethType = main.params[ 'TEST' ][ 'ip4Type' ]
1004 # IP protocol
1005 ipProto = main.params[ 'TEST' ][ 'udpProto' ]
1006 # UDP port destination
1007 udpDst = main.params[ 'TEST' ][ 'udpDst' ]
1008
1009 main.log.info( "Add a flow that connects host1 on port1 to host2 on port2" )
1010 stepResult = main.ONOSrest.addFlow( deviceId=main.swDPID,
1011 egressPort=egress,
1012 ingressPort=ingress,
1013 ethType=ethType,
1014 ipProto=ipProto,
1015 udpDst=udpDst,
1016 debug=main.debug )
1017
1018 utilities.assert_equals( expect=main.TRUE,
1019 actual=stepResult,
1020 onpass="Successfully added flows",
1021 onfail="Failed add flows" )
1022
1023 # Giving ONOS time to add the flow
1024 time.sleep( main.addFlowSleep )
1025
1026 main.step( "Check flow is in the ADDED state" )
1027
1028 main.log.info( "Get the flows from ONOS" )
Jeremy86160992016-04-11 10:05:53 -07001029 try:
1030 flows = json.loads( main.ONOSrest.flows() )
GlennRC956ea742015-11-05 16:14:15 -08001031
Jeremy86160992016-04-11 10:05:53 -07001032 stepResult = main.TRUE
1033 for f in flows:
1034 if "rest" in f.get("appId"):
1035 if "ADDED" not in f.get("state"):
1036 stepResult = main.FALSE
1037 main.log.error( "Flow: %s in state: %s" % (f.get("id"), f.get("state")) )
1038 except TypeError:
1039 main.log.error( "No Flows found by the REST API" )
1040 stepResult = main.FALSE
1041 except ValueError:
1042 main.log.error( "Problem getting Flows state from REST API. Exiting test" )
1043 main.cleanup()
1044 main.exit()
GlennRC956ea742015-11-05 16:14:15 -08001045
1046 utilities.assert_equals( expect=main.TRUE,
1047 actual=stepResult,
1048 onpass="All flows are in the ADDED state",
1049 onfail="All flows are NOT in the ADDED state" )
1050
1051 main.step( "Check flows are in Mininet's flow table" )
1052
1053 # get the flow IDs that were added through rest
1054 main.log.info( "Getting the flow IDs from ONOS" )
1055 flowIds = [ f.get("id") for f in flows if "rest" in f.get("appId") ]
1056 # convert the flowIDs to ints then hex and finally back to strings
1057 flowIds = [str(hex(int(x))) for x in flowIds]
1058 main.log.info( "ONOS flow IDs: {}".format(flowIds) )
1059
1060 stepResult = main.Mininet1.checkFlowId( "s1", flowIds, debug=False )
1061
1062 utilities.assert_equals( expect=main.TRUE,
1063 actual=stepResult,
1064 onpass="All flows are in mininet",
1065 onfail="All flows are NOT in mininet" )
1066
1067 main.step( "Send a packet to verify the flow is correct" )
1068
1069 main.log.info( "Constructing packet" )
1070 # No need for the MAC src dst
1071 main.h1.buildEther( dst=main.h2.hostMac )
1072 main.h1.buildIP( dst=main.h2.hostIp )
1073 main.h1.buildUDP( dport=udpDst )
1074
1075 main.log.info( "Starting filter on host2" )
1076 # Defaults to ip
1077 main.h2.startFilter( pktFilter="udp" )
1078
1079 main.log.info( "Sending packet to host2" )
1080 main.h1.sendPacket()
1081
1082 main.log.info( "Checking filter for our packet" )
1083 stepResult = main.h2.checkFilter()
1084 if stepResult:
1085 main.log.info( "Packet: %s" % main.h2.readPackets() )
1086 else: main.h2.killFilter()
1087
1088 main.log.info( "Clean up host components" )
1089 for host in hosts:
1090 host.stopScapy()
1091 main.Mininet1.removeHostComponent("h1")
1092 main.Mininet1.removeHostComponent("h2")
1093
1094 utilities.assert_equals( expect=main.TRUE,
1095 actual=stepResult,
1096 onpass="Successfully sent a packet",
1097 onfail="Failed to send a packet" )
1098
1099
1100 def CASE2000( self, main ):
1101 import json
1102
1103 main.case( "Delete flows that were added through rest" )
1104 main.step("Deleting flows")
1105
1106 main.log.info( "Getting flows" )
Jeremy86160992016-04-11 10:05:53 -07001107 try:
1108 flows = json.loads( main.ONOSrest.flows() )
GlennRC956ea742015-11-05 16:14:15 -08001109
Jeremy86160992016-04-11 10:05:53 -07001110 stepResult = main.TRUE
1111 for f in flows:
1112 if "rest" in f.get("appId"):
1113 if main.debug: main.log.debug( "Flow to be deleted:\n{}".format( main.ONOSrest.pprint(f) ) )
1114 stepResult = stepResult and main.ONOSrest.removeFlow( f.get("deviceId"), f.get("id") )
1115 except TypeError:
1116 main.log.error( "No Flows found by the REST API" )
1117 stepResult = main.FALSE
1118 except ValueError:
1119 main.log.error( "Problem getting Flows state from REST API. Exiting test" )
1120 main.cleanup()
1121 main.exit()
GlennRC956ea742015-11-05 16:14:15 -08001122
1123 utilities.assert_equals( expect=main.TRUE,
1124 actual=stepResult,
1125 onpass="Successfully deleting flows",
1126 onfail="Failed to delete flows" )
1127
1128 time.sleep( main.delFlowSleep )
1129
GlennRC68449942015-10-16 16:03:12 -07001130 def CASE100( self, main ):
GlennRC5147a422015-10-06 17:26:17 -07001131 '''
1132 Report errors/warnings/exceptions
1133 '''
1134 main.log.info("Error report: \n" )
1135 main.ONOSbench.logReport( main.ONOSip[ 0 ],
1136 [ "INFO",
1137 "FOLLOWER",
1138 "WARN",
1139 "flow",
1140 "ERROR",
1141 "Except" ],
GlennRC68449942015-10-16 16:03:12 -07001142 "s" )