blob: 7851d51cf64e9dd64ff935b216a68d49085c8564 [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
Jon Hall53c5e662016-04-13 16:06:56 -0700124 main.log.info( "NODE COUNT = " + str( main.numCtrls ) )
GlennRC5147a422015-10-06 17:26:17 -0700125
126 tempOnosIp = []
127 for i in range( main.numCtrls ):
128 tempOnosIp.append( main.ONOSip[i] )
129
Jon Hall53c5e662016-04-13 16:06:56 -0700130 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
131 "temp",
132 main.Mininet1.ip_address,
133 main.apps,
134 tempOnosIp )
GlennRC5147a422015-10-06 17:26:17 -0700135
136 main.step( "Apply cell to environment" )
137 cellResult = main.ONOSbench.setCell( "temp" )
138 verifyResult = main.ONOSbench.verifyCell()
139 stepResult = cellResult and verifyResult
140 utilities.assert_equals( expect=main.TRUE,
141 actual=stepResult,
142 onpass="Successfully applied cell to " + \
143 "environment",
144 onfail="Failed to apply cell to environment " )
145
146 main.step( "Creating ONOS package" )
147 packageResult = main.ONOSbench.onosPackage()
148 stepResult = packageResult
149 utilities.assert_equals( expect=main.TRUE,
150 actual=stepResult,
151 onpass="Successfully created ONOS package",
152 onfail="Failed to create ONOS package" )
153
154 time.sleep( main.startUpSleep )
155 main.step( "Uninstalling ONOS package" )
156 onosUninstallResult = main.TRUE
Jeremy86160992016-04-11 10:05:53 -0700157 for ip in main.ONOSip:
GlennRC5147a422015-10-06 17:26:17 -0700158 onosUninstallResult = onosUninstallResult and \
Jeremy86160992016-04-11 10:05:53 -0700159 main.ONOSbench.onosUninstall( nodeIp=ip )
GlennRC5147a422015-10-06 17:26:17 -0700160 stepResult = onosUninstallResult
161 utilities.assert_equals( expect=main.TRUE,
162 actual=stepResult,
163 onpass="Successfully uninstalled ONOS package",
164 onfail="Failed to uninstall ONOS package" )
GlennRC5147a422015-10-06 17:26:17 -0700165 time.sleep( main.startUpSleep )
166 main.step( "Installing ONOS package" )
167 onosInstallResult = main.TRUE
168 for i in range( main.numCtrls ):
169 onosInstallResult = onosInstallResult and \
170 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
171 stepResult = onosInstallResult
172 utilities.assert_equals( expect=main.TRUE,
173 actual=stepResult,
174 onpass="Successfully installed ONOS package",
175 onfail="Failed to install ONOS package" )
176
177 time.sleep( main.startUpSleep )
178 main.step( "Starting ONOS service" )
179 stopResult = main.TRUE
180 startResult = main.TRUE
181 onosIsUp = main.TRUE
182
183 for i in range( main.numCtrls ):
184 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
185 if onosIsUp == main.TRUE:
186 main.log.report( "ONOS instance is up and ready" )
187 else:
188 main.log.report( "ONOS instance may not be up, stop and " +
189 "start ONOS again " )
190 for i in range( main.numCtrls ):
191 stopResult = stopResult and \
192 main.ONOSbench.onosStop( main.ONOSip[ i ] )
193 for i in range( main.numCtrls ):
194 startResult = startResult and \
195 main.ONOSbench.onosStart( main.ONOSip[ i ] )
196 stepResult = onosIsUp and stopResult and startResult
197 utilities.assert_equals( expect=main.TRUE,
198 actual=stepResult,
199 onpass="ONOS service is ready",
200 onfail="ONOS service did not start properly" )
201
202 main.step( "Start ONOS cli" )
203 cliResult = main.TRUE
204 for i in range( main.numCtrls ):
205 cliResult = cliResult and \
206 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
207 stepResult = cliResult
208 utilities.assert_equals( expect=main.TRUE,
209 actual=stepResult,
210 onpass="Successfully start ONOS cli",
211 onfail="Failed to start ONOS cli" )
212
GlennRC68449942015-10-16 16:03:12 -0700213 def CASE10( self, main ):
214 '''
215 Start Mininet
216 '''
GlennRC073e8bc2015-10-27 17:11:28 -0700217 import json
218
219 main.case( "Setup mininet and compare ONOS topology view to Mininet topology" )
220 main.caseExplanation = "Start mininet with custom topology and compare topology " +\
221 "elements between Mininet and ONOS"
222
GlennRC68449942015-10-16 16:03:12 -0700223 main.step( "Setup Mininet Topology" )
224 topology = main.Mininet1.home + '/custom/' + main.topology
GlennRC073e8bc2015-10-27 17:11:28 -0700225 stepResult = main.Mininet1.startNet( topoFile=topology )
GlennRC68449942015-10-16 16:03:12 -0700226
227 utilities.assert_equals( expect=main.TRUE,
GlennRC073e8bc2015-10-27 17:11:28 -0700228 actual=stepResult,
GlennRC68449942015-10-16 16:03:12 -0700229 onpass="Successfully loaded topology",
230 onfail="Failed to load topology" )
231
GlennRC073e8bc2015-10-27 17:11:28 -0700232 main.step( "Assign switch to controller" )
233 stepResult = main.Mininet1.assignSwController( "s1", main.ONOSip[0] )
GlennRC68449942015-10-16 16:03:12 -0700234
235 utilities.assert_equals( expect=main.TRUE,
GlennRC073e8bc2015-10-27 17:11:28 -0700236 actual=stepResult,
237 onpass="Successfully assigned switch to controller",
238 onfail="Failed to assign switch to controller" )
GlennRC68449942015-10-16 16:03:12 -0700239
GlennRC073e8bc2015-10-27 17:11:28 -0700240 time.sleep( main.startMNSleep )
GlennRC68449942015-10-16 16:03:12 -0700241
Jon Hall70b2ff42015-11-17 15:49:44 -0800242 main.step( "Comparing MN topology to ONOS topology" )
GlennRC073e8bc2015-10-27 17:11:28 -0700243 main.log.info( "Gathering topology information" )
GlennRC1704d072015-10-07 18:40:45 -0700244 devicesResults = main.TRUE
245 linksResults = main.TRUE
246 hostsResults = main.TRUE
247 devices = main.topo.getAllDevices( main )
248 hosts = main.topo.getAllHosts( main )
249 ports = main.topo.getAllPorts( main )
250 links = main.topo.getAllLinks( main )
251 clusters = main.topo.getAllClusters( main )
252
253 mnSwitches = main.Mininet1.getSwitches()
254 mnLinks = main.Mininet1.getLinks()
255 mnHosts = main.Mininet1.getHosts()
256
GlennRC1704d072015-10-07 18:40:45 -0700257 for controller in range( main.numCtrls ):
258 controllerStr = str( controller + 1 )
259 if devices[ controller ] and ports[ controller ] and\
260 "Error" not in devices[ controller ] and\
261 "Error" not in ports[ controller ]:
262
263 currentDevicesResult = main.Mininet1.compareSwitches(
264 mnSwitches,
265 json.loads( devices[ controller ] ),
266 json.loads( ports[ controller ] ) )
267 else:
268 currentDevicesResult = main.FALSE
269 utilities.assert_equals( expect=main.TRUE,
270 actual=currentDevicesResult,
271 onpass="ONOS" + controllerStr +
GlennRC68449942015-10-16 16:03:12 -0700272 " Switches view is correct",
GlennRC1704d072015-10-07 18:40:45 -0700273 onfail="ONOS" + controllerStr +
GlennRC68449942015-10-16 16:03:12 -0700274 " Switches view is incorrect" )
GlennRC1704d072015-10-07 18:40:45 -0700275 if links[ controller ] and "Error" not in links[ controller ]:
276 currentLinksResult = main.Mininet1.compareLinks(
277 mnSwitches, mnLinks,
278 json.loads( links[ controller ] ) )
279 else:
280 currentLinksResult = main.FALSE
281 utilities.assert_equals( expect=main.TRUE,
282 actual=currentLinksResult,
283 onpass="ONOS" + controllerStr +
GlennRC68449942015-10-16 16:03:12 -0700284 " links view is correct",
GlennRC1704d072015-10-07 18:40:45 -0700285 onfail="ONOS" + controllerStr +
GlennRC68449942015-10-16 16:03:12 -0700286 " links view is incorrect" )
GlennRC1704d072015-10-07 18:40:45 -0700287
288 if hosts[ controller ] or "Error" not in hosts[ controller ]:
289 currentHostsResult = main.Mininet1.compareHosts(
290 mnHosts,
291 json.loads( hosts[ controller ] ) )
292 else:
293 currentHostsResult = main.FALSE
294 utilities.assert_equals( expect=main.TRUE,
295 actual=currentHostsResult,
296 onpass="ONOS" + controllerStr +
GlennRC68449942015-10-16 16:03:12 -0700297 " hosts exist in Mininet",
GlennRC1704d072015-10-07 18:40:45 -0700298 onfail="ONOS" + controllerStr +
GlennRC68449942015-10-16 16:03:12 -0700299 " hosts don't match Mininet")
GlennRCa5391372015-10-14 17:28:15 -0700300
GlennRC68449942015-10-16 16:03:12 -0700301
Jon Hall892818c2015-10-20 17:58:34 -0700302 def CASE66( self, main ):
303 '''
304 Testing scapy
305 '''
306 main.case( "Testing scapy" )
307 main.step( "Creating Host1 component" )
308 main.Mininet1.createHostComponent( "h1" )
309 main.Mininet1.createHostComponent( "h2" )
310 hosts = [main.h1, main.h2]
311 for host in hosts:
312 host.startHostCli()
313 host.startScapy()
314 host.updateSelf()
315 main.log.debug( host.name )
316 main.log.debug( host.hostIp )
317 main.log.debug( host.hostMac )
318
319 main.step( "Sending/Receiving Test packet - Filter doesn't match" )
320 main.h2.startFilter()
321 main.h1.buildEther( dst=main.h2.hostMac )
322 main.h1.sendPacket( )
323 finished = main.h2.checkFilter()
324 i = ""
325 if finished:
326 a = main.h2.readPackets()
327 for i in a.splitlines():
328 main.log.info( i )
329 else:
330 kill = main.h2.killFilter()
331 main.log.debug( kill )
332 main.h2.handle.sendline( "" )
333 main.h2.handle.expect( main.h2.scapyPrompt )
334 main.log.debug( main.h2.handle.before )
335 utilities.assert_equals( expect=True,
336 actual="dst=00:00:00:00:00:02 src=00:00:00:00:00:01" in i,
337 onpass="Pass",
338 onfail="Fail" )
339
340 main.step( "Sending/Receiving Test packet - Filter matches" )
341 main.h2.startFilter()
342 main.h1.buildEther( dst=main.h2.hostMac )
343 main.h1.buildIP( dst=main.h2.hostIp )
344 main.h1.sendPacket( )
345 finished = main.h2.checkFilter()
346 i = ""
347 if finished:
348 a = main.h2.readPackets()
349 for i in a.splitlines():
350 main.log.info( i )
351 else:
352 kill = main.h2.killFilter()
353 main.log.debug( kill )
354 main.h2.handle.sendline( "" )
355 main.h2.handle.expect( main.h2.scapyPrompt )
356 main.log.debug( main.h2.handle.before )
357 utilities.assert_equals( expect=True,
358 actual="dst=00:00:00:00:00:02 src=00:00:00:00:00:01" in i,
359 onpass="Pass",
360 onfail="Fail" )
361
362
363
364 main.step( "Clean up host components" )
365 for host in hosts:
366 host.stopScapy()
367 main.Mininet1.removeHostComponent("h1")
368 main.Mininet1.removeHostComponent("h2")
369
GlennRC68449942015-10-16 16:03:12 -0700370 def CASE1000( self, main ):
371 '''
GlennRC073e8bc2015-10-27 17:11:28 -0700372 Add flows with MAC selectors and verify the flows
GlennRC68449942015-10-16 16:03:12 -0700373 '''
GlennRC073e8bc2015-10-27 17:11:28 -0700374 import json
375 import time
GlennRC68449942015-10-16 16:03:12 -0700376
GlennRC073e8bc2015-10-27 17:11:28 -0700377 main.case( "Verify flow MAC selectors are correctly compiled" )
378 main.caseExplanation = "Install two flows with only MAC selectors " +\
379 "specified, then verify flows are added in ONOS, finally "+\
380 "send a packet that only specifies the MAC src and dst."
GlennRC68449942015-10-16 16:03:12 -0700381
GlennRC073e8bc2015-10-27 17:11:28 -0700382 main.step( "Add flows with MAC addresses as the only selectors" )
GlennRC68449942015-10-16 16:03:12 -0700383
GlennRC073e8bc2015-10-27 17:11:28 -0700384 main.log.info( "Creating host components" )
385 main.Mininet1.createHostComponent( "h1" )
386 main.Mininet1.createHostComponent( "h2" )
387 hosts = [main.h1, main.h2]
388 stepResult = main.TRUE
389 for host in hosts:
390 host.startHostCli()
391 host.startScapy()
392 host.updateSelf()
GlennRC68449942015-10-16 16:03:12 -0700393
GlennRC073e8bc2015-10-27 17:11:28 -0700394 # Add a flow that connects host1 on port1 to host2 on port2
395 # send output on port2
396 # recieve input on port1
397 egress = 2
398 ingress = 1
399
400 # Add flows that sends packets from port1 to port2 with correct
401 # MAC src and dst addresses
402 main.log.info( "Adding flow with MAC selectors" )
403 stepResult = main.ONOSrest.addFlow( deviceId=main.swDPID,
404 egressPort=egress,
405 ingressPort=ingress,
406 ethSrc=main.h1.hostMac,
407 ethDst=main.h2.hostMac,
GlennRC956ea742015-11-05 16:14:15 -0800408 debug=main.debug )
GlennRC68449942015-10-16 16:03:12 -0700409
GlennRCa5391372015-10-14 17:28:15 -0700410 utilities.assert_equals( expect=main.TRUE,
411 actual=stepResult,
GlennRC68449942015-10-16 16:03:12 -0700412 onpass="Successfully added flows",
413 onfail="Failed add flows" )
GlennRCa5391372015-10-14 17:28:15 -0700414
GlennRC073e8bc2015-10-27 17:11:28 -0700415 # Giving ONOS time to add the flows
416 time.sleep( main.addFlowSleep )
GlennRC5147a422015-10-06 17:26:17 -0700417
GlennRC073e8bc2015-10-27 17:11:28 -0700418 main.step( "Check flows are in the ADDED state" )
419
GlennRC073e8bc2015-10-27 17:11:28 -0700420 main.log.info( "Get the flows from ONOS" )
Jeremy86160992016-04-11 10:05:53 -0700421 try:
422 flows = json.loads( main.ONOSrest.flows() )
GlennRC68449942015-10-16 16:03:12 -0700423
Jeremy86160992016-04-11 10:05:53 -0700424 stepResult = main.TRUE
425 for f in flows:
426 if "rest" in f.get("appId"):
427 if "ADDED" not in f.get("state"):
428 stepResult = main.FALSE
429 main.log.error( "Flow: %s in state: %s" % (f.get("id"), f.get("state")) )
430 except TypeError:
431 main.log.error( "No Flows found by the REST API" )
432 stepResult = main.FALSE
433 except ValueError:
434 main.log.error( "Problem getting Flows state from REST API. Exiting test" )
435 main.cleanup()
436 main.exit()
GlennRC68449942015-10-16 16:03:12 -0700437
438 utilities.assert_equals( expect=main.TRUE,
439 actual=stepResult,
440 onpass="All flows are in the ADDED state",
GlennRC073e8bc2015-10-27 17:11:28 -0700441 onfail="All flows are NOT in the ADDED state" )
GlennRC68449942015-10-16 16:03:12 -0700442
GlennRC956ea742015-11-05 16:14:15 -0800443 main.step( "Check flows are in Mininet's flow table" )
444
445 # get the flow IDs that were added through rest
446 main.log.info( "Getting the flow IDs from ONOS" )
447 flowIds = [ f.get("id") for f in flows if "rest" in f.get("appId") ]
448 # convert the flowIDs to ints then hex and finally back to strings
449 flowIds = [str(hex(int(x))) for x in flowIds]
450 main.log.info( "ONOS flow IDs: {}".format(flowIds) )
451
452 stepResult = main.Mininet1.checkFlowId( "s1", flowIds, debug=False )
453
454 utilities.assert_equals( expect=main.TRUE,
455 actual=stepResult,
456 onpass="All flows are in mininet",
457 onfail="All flows are NOT in mininet" )
458
GlennRC073e8bc2015-10-27 17:11:28 -0700459 main.step( "Send a packet to verify the flows are correct" )
460
461 # Specify the src and dst MAC addr
462 main.log.info( "Constructing packet" )
463 main.h1.buildEther( src=main.h1.hostMac, dst=main.h2.hostMac )
464
465 # Filter for packets with the correct host name. Otherwise,
466 # the filter we catch any packet that is sent to host2
467 # NOTE: I believe it doesn't matter which host name it is,
GlennRC956ea742015-11-05 16:14:15 -0800468 # as long as the src and dst are both specified
GlennRC073e8bc2015-10-27 17:11:28 -0700469 main.log.info( "Starting filter on host2" )
470 main.h2.startFilter( pktFilter="ether host %s" % main.h1.hostMac)
471
472 main.log.info( "Sending packet to host2" )
473 main.h1.sendPacket()
474
475 main.log.info( "Checking filter for our packet" )
476 stepResult = main.h2.checkFilter()
477 if stepResult:
478 main.log.info( "Packet: %s" % main.h2.readPackets() )
479 else: main.h2.killFilter()
480
481 main.log.info( "Clean up host components" )
482 for host in hosts:
483 host.stopScapy()
484 main.Mininet1.removeHostComponent("h1")
485 main.Mininet1.removeHostComponent("h2")
486
487 utilities.assert_equals( expect=main.TRUE,
488 actual=stepResult,
489 onpass="Successfully sent a packet",
490 onfail="Failed to send a packet" )
491
492 def CASE1100( self, main ):
GlennRC68449942015-10-16 16:03:12 -0700493 '''
GlennRC073e8bc2015-10-27 17:11:28 -0700494 Add flows with IPv4 selectors and verify the flows
GlennRC68449942015-10-16 16:03:12 -0700495 '''
496 import json
GlennRC073e8bc2015-10-27 17:11:28 -0700497 import time
GlennRC68449942015-10-16 16:03:12 -0700498
GlennRC073e8bc2015-10-27 17:11:28 -0700499 main.case( "Verify flow IP selectors are correctly compiled" )
500 main.caseExplanation = "Install two flows with only IP selectors " +\
501 "specified, then verify flows are added in ONOS, finally "+\
502 "send a packet that only specifies the IP src and dst."
503
504 main.step( "Add flows with IPv4 addresses as the only selectors" )
505
506 main.log.info( "Creating host components" )
507 main.Mininet1.createHostComponent( "h1" )
508 main.Mininet1.createHostComponent( "h2" )
509 hosts = [main.h1, main.h2]
510 stepResult = main.TRUE
511 for host in hosts:
512 host.startHostCli()
513 host.startScapy()
514 host.updateSelf()
515
516 # Add a flow that connects host1 on port1 to host2 on port2
517 # send output on port2
518 # recieve input on port1
519 egress = 2
520 ingress = 1
521 # IPv4 etherType = 0x800
522 IPv4=2048
523
524 # Add flows that connects host1 to host2
525 main.log.info( "Add flow with port ingress 1 to port egress 2" )
526 stepResult = main.ONOSrest.addFlow( deviceId=main.swDPID,
527 egressPort=egress,
528 ingressPort=ingress,
529 ethType=IPv4,
530 ipSrc=("IPV4_SRC", main.h1.hostIp+"/32"),
531 ipDst=("IPV4_DST", main.h2.hostIp+"/32"),
GlennRC956ea742015-11-05 16:14:15 -0800532 debug=main.debug )
GlennRC073e8bc2015-10-27 17:11:28 -0700533
534 utilities.assert_equals( expect=main.TRUE,
535 actual=stepResult,
536 onpass="Successfully added flows",
537 onfail="Failed add flows" )
538
539 # Giving ONOS time to add the flow
540 time.sleep( main.addFlowSleep )
541
542 main.step( "Check flow is in the ADDED state" )
543
544 main.log.info( "Get the flows from ONOS" )
Jeremy86160992016-04-11 10:05:53 -0700545 try:
546 flows = json.loads( main.ONOSrest.flows() )
GlennRC68449942015-10-16 16:03:12 -0700547
Jeremy86160992016-04-11 10:05:53 -0700548 stepResult = main.TRUE
549 for f in flows:
550 if "rest" in f.get("appId"):
551 if "ADDED" not in f.get("state"):
552 stepResult = main.FALSE
553 main.log.error( "Flow: %s in state: %s" % (f.get("id"), f.get("state")) )
554 except TypeError:
555 main.log.error( "No Flows found by the REST API" )
556 stepResult = main.FALSE
557 except ValueError:
558 main.log.error( "Problem getting Flows state from REST API. Exiting test" )
559 main.cleanup()
560 main.exit()
GlennRC68449942015-10-16 16:03:12 -0700561
562 utilities.assert_equals( expect=main.TRUE,
563 actual=stepResult,
GlennRC073e8bc2015-10-27 17:11:28 -0700564 onpass="All flows are in the ADDED state",
565 onfail="All flows are NOT in the ADDED state" )
566
GlennRC956ea742015-11-05 16:14:15 -0800567 main.step( "Check flows are in Mininet's flow table" )
568
569 # get the flow IDs that were added through rest
570 main.log.info( "Getting the flow IDs from ONOS" )
571 flowIds = [ f.get("id") for f in flows if "rest" in f.get("appId") ]
572 # convert the flowIDs to ints then hex and finally back to strings
573 flowIds = [str(hex(int(x))) for x in flowIds]
574 main.log.info( "ONOS flow IDs: {}".format(flowIds) )
575
576 stepResult = main.Mininet1.checkFlowId( "s1", flowIds, debug=False )
577
578 utilities.assert_equals( expect=main.TRUE,
579 actual=stepResult,
580 onpass="All flows are in mininet",
581 onfail="All flows are NOT in mininet" )
582
GlennRC073e8bc2015-10-27 17:11:28 -0700583 main.step( "Send a packet to verify the flow is correct" )
584
585 main.log.info( "Constructing packet" )
586 # No need for the MAC src dst
587 main.h1.buildEther( dst=main.h2.hostMac )
588 main.h1.buildIP( src=main.h1.hostIp, dst=main.h2.hostIp )
589
590 main.log.info( "Starting filter on host2" )
591 # Defaults to ip
592 main.h2.startFilter()
593
594 main.log.info( "Sending packet to host2" )
595 main.h1.sendPacket()
596
597 main.log.info( "Checking filter for our packet" )
598 stepResult = main.h2.checkFilter()
599 if stepResult:
600 main.log.info( "Packet: %s" % main.h2.readPackets() )
601 else: main.h2.killFilter()
602
603 main.log.info( "Clean up host components" )
604 for host in hosts:
605 host.stopScapy()
606 main.Mininet1.removeHostComponent("h1")
607 main.Mininet1.removeHostComponent("h2")
608
609 utilities.assert_equals( expect=main.TRUE,
610 actual=stepResult,
611 onpass="Successfully sent a packet",
612 onfail="Failed to send a packet" )
613
614 def CASE1200( self, main ):
615 '''
616 Add flow with VLAN selector and verify the flow
617 '''
618 import json
619 import time
620
621 main.case( "Verify VLAN selector is correctly compiled" )
622 main.caseExplanation = "Install one flow with only the VLAN selector " +\
623 "specified, then verify the flow is added in ONOS, and finally "+\
624 "broadcast a packet with the correct VLAN tag."
625
626 # We do this here to utilize the hosts information
627 main.log.info( "Creating host components" )
628 main.Mininet1.createHostComponent( "h3" )
629 main.Mininet1.createHostComponent( "h4" )
630 hosts = [main.h3, main.h4]
631 stepResult = main.TRUE
632 for host in hosts:
633 host.startHostCli()
634 host.startScapy()
635 host.updateSelf()
636
637
638 main.step( "Add a flow with the VLAN tag as the only selector" )
639
640 # Add flows that connects the two vlan hosts h3 and h4
641 # Host 3 is on port 3 and host 4 is on port 4
642 vlan = main.params[ 'TEST' ][ 'vlan' ]
643 egress = 4
644 ingress = 3
645 # VLAN ethType = 0x8100
646 ethType = 33024
647
648 # Add only one flow because we don't need a response
649 main.log.info( "Add flow with port ingress 1 to port egress 2" )
650 stepResult = main.ONOSrest.addFlow( deviceId=main.swDPID,
651 egressPort=egress,
652 ingressPort=ingress,
653 ethType=ethType,
654 vlan=vlan,
GlennRC956ea742015-11-05 16:14:15 -0800655 debug=main.debug )
GlennRC073e8bc2015-10-27 17:11:28 -0700656
657
658 utilities.assert_equals( expect=main.TRUE,
659 actual=stepResult,
660 onpass="Successfully added flow",
661 onfail="Failed add flows" )
662
663 # Giving ONOS time to add the flows
664 time.sleep( main.addFlowSleep )
665
666 main.step( "Check flows are in the ADDED state" )
667
668 main.log.info( "Get the flows from ONOS" )
Jeremy86160992016-04-11 10:05:53 -0700669 try:
670 flows = json.loads( main.ONOSrest.flows() )
GlennRC073e8bc2015-10-27 17:11:28 -0700671
Jeremy86160992016-04-11 10:05:53 -0700672 stepResult = main.TRUE
673 for f in flows:
674 if "rest" in f.get("appId"):
675 if "ADDED" not in f.get("state"):
676 stepResult = main.FALSE
677 main.log.error( "Flow: %s in state: %s" % (f.get("id"), f.get("state")) )
678 except TypeError:
679 main.log.error( "No Flows found by the REST API" )
680 stepResult = main.FALSE
681 except ValueError:
682 main.log.error( "Problem getting Flows state from REST API. Exiting test" )
683 main.cleanup()
684 main.exit()
GlennRC073e8bc2015-10-27 17:11:28 -0700685
686 utilities.assert_equals( expect=main.TRUE,
687 actual=stepResult,
688 onpass="All flows are in the ADDED state",
689 onfail="All flows are NOT in the ADDED state" )
690
GlennRC956ea742015-11-05 16:14:15 -0800691 main.step( "Check flows are in Mininet's flow table" )
692
693 # get the flow IDs that were added through rest
694 main.log.info( "Getting the flow IDs from ONOS" )
695 flowIds = [ f.get("id") for f in flows if "rest" in f.get("appId") ]
696 # convert the flowIDs to ints then hex and finally back to strings
697 flowIds = [str(hex(int(x))) for x in flowIds]
698 main.log.info( "ONOS flow IDs: {}".format(flowIds) )
699
700 stepResult = main.Mininet1.checkFlowId( "s1", flowIds, debug=False )
701
702 utilities.assert_equals( expect=main.TRUE,
703 actual=stepResult,
704 onpass="All flows are in mininet",
705 onfail="All flows are NOT in mininet" )
706
GlennRC073e8bc2015-10-27 17:11:28 -0700707 main.step( "Send a packet to verify the flow are correct" )
708
709 # The receiving interface
710 recIface = "{}-eth0.{}".format(main.h4.name, vlan)
711 main.log.info( "Starting filter on host2" )
712 # Filter is setup to catch any packet on the vlan interface with the correct vlan tag
713 main.h4.startFilter( ifaceName=recIface, pktFilter="" )
714
715 # Broadcast the packet on the vlan interface. We only care if the flow forwards
716 # the packet with the correct vlan tag, not if the mac addr is correct
GlennRC073e8bc2015-10-27 17:11:28 -0700717 sendIface = "{}-eth0.{}".format(main.h3.name, vlan)
718 main.log.info( "Broadcasting the packet with a vlan tag" )
GlennRC956ea742015-11-05 16:14:15 -0800719 main.h3.sendPacket( iface=sendIface,
720 packet="Ether()/Dot1Q(vlan={})".format(vlan) )
GlennRC073e8bc2015-10-27 17:11:28 -0700721
722 main.log.info( "Checking filter for our packet" )
723 stepResult = main.h4.checkFilter()
724 if stepResult:
725 main.log.info( "Packet: %s" % main.h4.readPackets() )
726 else: main.h4.killFilter()
727
728 main.log.info( "Clean up host components" )
729 for host in hosts:
730 host.stopScapy()
731 main.Mininet1.removeHostComponent("h3")
732 main.Mininet1.removeHostComponent("h4")
733
734 utilities.assert_equals( expect=main.TRUE,
735 actual=stepResult,
736 onpass="Successfully sent a packet",
737 onfail="Failed to send a packet" )
GlennRC68449942015-10-16 16:03:12 -0700738
GlennRC956ea742015-11-05 16:14:15 -0800739 def CASE1300( self, main ):
740 '''
741 Add flows with MPLS selector and verify the flows
742 '''
743 import json
744 import time
745
746 main.case( "Verify the MPLS selector is correctly compiled on the flow." )
747 main.caseExplanation = "Install one flow with an MPLS selector, " +\
748 "verify the flow is added in ONOS, and finally "+\
749 "send a packet via scapy that has a MPLS label."
750
751 main.step( "Add a flow with a MPLS selector" )
752
753 main.log.info( "Creating host components" )
754 main.Mininet1.createHostComponent( "h1" )
755 main.Mininet1.createHostComponent( "h2" )
756 hosts = [main.h1, main.h2]
757 stepResult = main.TRUE
758 for host in hosts:
759 host.startHostCli()
760 host.startScapy( main.dependencyPath )
761 host.updateSelf()
762
763 # ports
764 egress = 2
765 ingress = 1
766 # MPLS etherType
767 ethType = main.params[ 'TEST' ][ 'mplsType' ]
768 # MPLS label
769 mplsLabel = main.params[ 'TEST' ][ 'mpls' ]
770
771 # Add a flow that connects host1 on port1 to host2 on port2
772 main.log.info( "Adding flow with MPLS selector" )
773 stepResult = main.ONOSrest.addFlow( deviceId=main.swDPID,
774 egressPort=egress,
775 ingressPort=ingress,
776 ethType=ethType,
777 mpls=mplsLabel,
778 debug=main.debug )
779
780 utilities.assert_equals( expect=main.TRUE,
781 actual=stepResult,
782 onpass="Successfully added flow",
783 onfail="Failed add flow" )
784
785 # Giving ONOS time to add the flow
786 time.sleep( main.addFlowSleep )
787
788 main.step( "Check flow is in the ADDED state" )
789
790 main.log.info( "Get the flows from ONOS" )
Jeremy86160992016-04-11 10:05:53 -0700791 try:
792 flows = json.loads( main.ONOSrest.flows() )
GlennRC956ea742015-11-05 16:14:15 -0800793
Jeremy86160992016-04-11 10:05:53 -0700794 stepResult = main.TRUE
795 for f in flows:
796 if "rest" in f.get("appId"):
797 if "ADDED" not in f.get("state"):
798 stepResult = main.FALSE
799 main.log.error( "Flow: %s in state: %s" % (f.get("id"), f.get("state")) )
800 except TypeError:
801 main.log.error( "No Flows found by the REST API" )
802 stepResult = main.FALSE
803 except ValueError:
804 main.log.error( "Problem getting Flows state from REST API. Exiting test" )
805 main.cleanup()
806 main.exit()
GlennRC956ea742015-11-05 16:14:15 -0800807
808 utilities.assert_equals( expect=main.TRUE,
809 actual=stepResult,
810 onpass="All flows are in the ADDED state",
811 onfail="All flows are NOT in the ADDED state" )
812
813 main.step( "Check flows are in Mininet's flow table" )
814
815 # get the flow IDs that were added through rest
816 main.log.info( "Getting the flow IDs from ONOS" )
817 flowIds = [ f.get("id") for f in flows if "rest" in f.get("appId") ]
818 # convert the flowIDs to ints then hex and finally back to strings
819 flowIds = [str(hex(int(x))) for x in flowIds]
820 main.log.info( "ONOS flow IDs: {}".format(flowIds) )
821
822 stepResult = main.Mininet1.checkFlowId( "s1", flowIds, debug=True )
823
824 utilities.assert_equals( expect=main.TRUE,
825 actual=stepResult,
826 onpass="All flows are in mininet",
827 onfail="All flows are NOT in mininet" )
828
829 main.step( "Send a packet to verify the flow is correct" )
830
831 main.log.info( "Starting filter on host2" )
832 main.h2.startFilter( pktFilter="mpls" )
833
834 main.log.info( "Constructing packet" )
835 main.log.info( "Sending packet to host2" )
836 main.h1.sendPacket( packet='Ether()/MPLS(label={})'.format(mplsLabel) )
837
838 main.log.info( "Checking filter for our packet" )
839 stepResult = main.h2.checkFilter()
840 if stepResult:
841 main.log.info( "Packet: %s" % main.h2.readPackets() )
842 else: main.h2.killFilter()
843
844 main.log.info( "Clean up host components" )
845 for host in hosts:
846 host.stopScapy()
847 main.Mininet1.removeHostComponent("h1")
848 main.Mininet1.removeHostComponent("h2")
849
850 utilities.assert_equals( expect=main.TRUE,
851 actual=stepResult,
852 onpass="Successfully sent a packet",
853 onfail="Failed to send a packet" )
854
855 def CASE1400( self, main ):
856 '''
857 Add flows with a TCP selector and verify the flow
858 '''
859 import json
860 import time
861
862 main.case( "Verify the TCP selector is correctly compiled on the flow" )
863 main.caseExplanation = "Install a flow with only the TCP selector " +\
864 "specified, verify the flow is added in ONOS, and finally "+\
865 "send a TCP packet to verify the TCP selector is compiled correctly."
866
867 main.step( "Add a flow with a TCP selector" )
868
869 main.log.info( "Creating host components" )
870 main.Mininet1.createHostComponent( "h1" )
871 main.Mininet1.createHostComponent( "h2" )
872 hosts = [main.h1, main.h2]
873 stepResult = main.TRUE
874 for host in hosts:
875 host.startHostCli()
876 host.startScapy()
877 host.updateSelf()
878
879 # Add a flow that connects host1 on port1 to host2 on port2
880 egress = 2
881 ingress = 1
882 # IPv4 etherType
883 ethType = main.params[ 'TEST' ][ 'ip4Type' ]
884 # IP protocol
885 ipProto = main.params[ 'TEST' ][ 'tcpProto' ]
886 # TCP port destination
887 tcpDst = main.params[ 'TEST' ][ 'tcpDst' ]
888
889 main.log.info( "Add a flow that connects host1 on port1 to host2 on port2" )
890 stepResult = main.ONOSrest.addFlow( deviceId=main.swDPID,
891 egressPort=egress,
892 ingressPort=ingress,
893 ethType=ethType,
894 ipProto=ipProto,
895 tcpDst=tcpDst,
896 debug=main.debug )
897
898 utilities.assert_equals( expect=main.TRUE,
899 actual=stepResult,
900 onpass="Successfully added flows",
901 onfail="Failed add flows" )
902
903 # Giving ONOS time to add the flow
904 time.sleep( main.addFlowSleep )
905
906 main.step( "Check flow is in the ADDED state" )
907
908 main.log.info( "Get the flows from ONOS" )
Jeremy86160992016-04-11 10:05:53 -0700909 try:
910 flows = json.loads( main.ONOSrest.flows() )
GlennRC956ea742015-11-05 16:14:15 -0800911
Jeremy86160992016-04-11 10:05:53 -0700912 stepResult = main.TRUE
913 for f in flows:
914 if "rest" in f.get("appId"):
915 if "ADDED" not in f.get("state"):
916 stepResult = main.FALSE
917 main.log.error( "Flow: %s in state: %s" % (f.get("id"), f.get("state")) )
918 except TypeError:
919 main.log.error( "No Flows found by the REST API" )
920 stepResult = main.FALSE
921 except ValueError:
922 main.log.error( "Problem getting Flows state from REST API. Exiting test" )
923 main.cleanup()
924 main.exit()
GlennRC956ea742015-11-05 16:14:15 -0800925
926 utilities.assert_equals( expect=main.TRUE,
927 actual=stepResult,
928 onpass="All flows are in the ADDED state",
929 onfail="All flows are NOT in the ADDED state" )
930
931 main.step( "Check flows are in Mininet's flow table" )
932
933 # get the flow IDs that were added through rest
934 main.log.info( "Getting the flow IDs from ONOS" )
935 flowIds = [ f.get("id") for f in flows if "rest" in f.get("appId") ]
936 # convert the flowIDs to ints then hex and finally back to strings
937 flowIds = [str(hex(int(x))) for x in flowIds]
938 main.log.info( "ONOS flow IDs: {}".format(flowIds) )
939
940 stepResult = main.Mininet1.checkFlowId( "s1", flowIds, debug=False )
941
942 utilities.assert_equals( expect=main.TRUE,
943 actual=stepResult,
944 onpass="All flows are in mininet",
945 onfail="All flows are NOT in mininet" )
946
947 main.step( "Send a packet to verify the flow is correct" )
948
949 main.log.info( "Constructing packet" )
950 # No need for the MAC src dst
951 main.h1.buildEther( dst=main.h2.hostMac )
952 main.h1.buildIP( dst=main.h2.hostIp )
953 main.h1.buildTCP( dport=tcpDst )
954
955 main.log.info( "Starting filter on host2" )
956 # Defaults to ip
957 main.h2.startFilter( pktFilter="tcp" )
958
959 main.log.info( "Sending packet to host2" )
960 main.h1.sendPacket()
961
962 main.log.info( "Checking filter for our packet" )
963 stepResult = main.h2.checkFilter()
964 if stepResult:
965 main.log.info( "Packet: %s" % main.h2.readPackets() )
966 else: main.h2.killFilter()
967
968 main.log.info( "Clean up host components" )
969 for host in hosts:
970 host.stopScapy()
971 main.Mininet1.removeHostComponent("h1")
972 main.Mininet1.removeHostComponent("h2")
973
974 utilities.assert_equals( expect=main.TRUE,
975 actual=stepResult,
976 onpass="Successfully sent a packet",
977 onfail="Failed to send a packet" )
978
979 def CASE1500( self, main ):
980 '''
981 Add flows with a UDP selector and verify the flow
982 '''
983 import json
984 import time
985
986 main.case( "Verify the UDP selector is correctly compiled on the flow" )
987 main.caseExplanation = "Install a flow with only the UDP selector " +\
988 "specified, verify the flow is added in ONOS, and finally "+\
989 "send a UDP packet to verify the UDP selector is compiled correctly."
990
991 main.step( "Add a flow with a UDP selector" )
992
993 main.log.info( "Creating host components" )
994 main.Mininet1.createHostComponent( "h1" )
995 main.Mininet1.createHostComponent( "h2" )
996 hosts = [main.h1, main.h2]
997 stepResult = main.TRUE
998 for host in hosts:
999 host.startHostCli()
1000 host.startScapy()
1001 host.updateSelf()
1002
1003 # Add a flow that connects host1 on port1 to host2 on port2
1004 egress = 2
1005 ingress = 1
1006 # IPv4 etherType
1007 ethType = main.params[ 'TEST' ][ 'ip4Type' ]
1008 # IP protocol
1009 ipProto = main.params[ 'TEST' ][ 'udpProto' ]
1010 # UDP port destination
1011 udpDst = main.params[ 'TEST' ][ 'udpDst' ]
1012
1013 main.log.info( "Add a flow that connects host1 on port1 to host2 on port2" )
1014 stepResult = main.ONOSrest.addFlow( deviceId=main.swDPID,
1015 egressPort=egress,
1016 ingressPort=ingress,
1017 ethType=ethType,
1018 ipProto=ipProto,
1019 udpDst=udpDst,
1020 debug=main.debug )
1021
1022 utilities.assert_equals( expect=main.TRUE,
1023 actual=stepResult,
1024 onpass="Successfully added flows",
1025 onfail="Failed add flows" )
1026
1027 # Giving ONOS time to add the flow
1028 time.sleep( main.addFlowSleep )
1029
1030 main.step( "Check flow is in the ADDED state" )
1031
1032 main.log.info( "Get the flows from ONOS" )
Jeremy86160992016-04-11 10:05:53 -07001033 try:
1034 flows = json.loads( main.ONOSrest.flows() )
GlennRC956ea742015-11-05 16:14:15 -08001035
Jeremy86160992016-04-11 10:05:53 -07001036 stepResult = main.TRUE
1037 for f in flows:
1038 if "rest" in f.get("appId"):
1039 if "ADDED" not in f.get("state"):
1040 stepResult = main.FALSE
1041 main.log.error( "Flow: %s in state: %s" % (f.get("id"), f.get("state")) )
1042 except TypeError:
1043 main.log.error( "No Flows found by the REST API" )
1044 stepResult = main.FALSE
1045 except ValueError:
1046 main.log.error( "Problem getting Flows state from REST API. Exiting test" )
1047 main.cleanup()
1048 main.exit()
GlennRC956ea742015-11-05 16:14:15 -08001049
1050 utilities.assert_equals( expect=main.TRUE,
1051 actual=stepResult,
1052 onpass="All flows are in the ADDED state",
1053 onfail="All flows are NOT in the ADDED state" )
1054
1055 main.step( "Check flows are in Mininet's flow table" )
1056
1057 # get the flow IDs that were added through rest
1058 main.log.info( "Getting the flow IDs from ONOS" )
1059 flowIds = [ f.get("id") for f in flows if "rest" in f.get("appId") ]
1060 # convert the flowIDs to ints then hex and finally back to strings
1061 flowIds = [str(hex(int(x))) for x in flowIds]
1062 main.log.info( "ONOS flow IDs: {}".format(flowIds) )
1063
1064 stepResult = main.Mininet1.checkFlowId( "s1", flowIds, debug=False )
1065
1066 utilities.assert_equals( expect=main.TRUE,
1067 actual=stepResult,
1068 onpass="All flows are in mininet",
1069 onfail="All flows are NOT in mininet" )
1070
1071 main.step( "Send a packet to verify the flow is correct" )
1072
1073 main.log.info( "Constructing packet" )
1074 # No need for the MAC src dst
1075 main.h1.buildEther( dst=main.h2.hostMac )
1076 main.h1.buildIP( dst=main.h2.hostIp )
1077 main.h1.buildUDP( dport=udpDst )
1078
1079 main.log.info( "Starting filter on host2" )
1080 # Defaults to ip
1081 main.h2.startFilter( pktFilter="udp" )
1082
1083 main.log.info( "Sending packet to host2" )
1084 main.h1.sendPacket()
1085
1086 main.log.info( "Checking filter for our packet" )
1087 stepResult = main.h2.checkFilter()
1088 if stepResult:
1089 main.log.info( "Packet: %s" % main.h2.readPackets() )
1090 else: main.h2.killFilter()
1091
1092 main.log.info( "Clean up host components" )
1093 for host in hosts:
1094 host.stopScapy()
1095 main.Mininet1.removeHostComponent("h1")
1096 main.Mininet1.removeHostComponent("h2")
1097
1098 utilities.assert_equals( expect=main.TRUE,
1099 actual=stepResult,
1100 onpass="Successfully sent a packet",
1101 onfail="Failed to send a packet" )
1102
1103
1104 def CASE2000( self, main ):
1105 import json
1106
1107 main.case( "Delete flows that were added through rest" )
1108 main.step("Deleting flows")
1109
1110 main.log.info( "Getting flows" )
Jeremy86160992016-04-11 10:05:53 -07001111 try:
1112 flows = json.loads( main.ONOSrest.flows() )
GlennRC956ea742015-11-05 16:14:15 -08001113
Jeremy86160992016-04-11 10:05:53 -07001114 stepResult = main.TRUE
1115 for f in flows:
1116 if "rest" in f.get("appId"):
1117 if main.debug: main.log.debug( "Flow to be deleted:\n{}".format( main.ONOSrest.pprint(f) ) )
1118 stepResult = stepResult and main.ONOSrest.removeFlow( f.get("deviceId"), f.get("id") )
1119 except TypeError:
1120 main.log.error( "No Flows found by the REST API" )
1121 stepResult = main.FALSE
1122 except ValueError:
1123 main.log.error( "Problem getting Flows state from REST API. Exiting test" )
1124 main.cleanup()
1125 main.exit()
GlennRC956ea742015-11-05 16:14:15 -08001126
1127 utilities.assert_equals( expect=main.TRUE,
1128 actual=stepResult,
1129 onpass="Successfully deleting flows",
1130 onfail="Failed to delete flows" )
1131
1132 time.sleep( main.delFlowSleep )
1133
GlennRC68449942015-10-16 16:03:12 -07001134 def CASE100( self, main ):
GlennRC5147a422015-10-06 17:26:17 -07001135 '''
1136 Report errors/warnings/exceptions
1137 '''
1138 main.log.info("Error report: \n" )
1139 main.ONOSbench.logReport( main.ONOSip[ 0 ],
1140 [ "INFO",
1141 "FOLLOWER",
1142 "WARN",
1143 "flow",
1144 "ERROR",
1145 "Except" ],
GlennRC68449942015-10-16 16:03:12 -07001146 "s" )