blob: 749a9a3b5fa5065137144cde0284311807e304a2 [file] [log] [blame]
kelvin-onlab4ff9cc12015-05-05 11:14:42 -07001
2# Testing the basic functionality of ONOS Next
3# For sanity and driver functionality excercises only.
4
5import time
6import json
7
8time.sleep( 1 )
9
kelvin-onlab05cf7732015-05-08 14:25:46 -070010class FuncIntent:
kelvin-onlab4ff9cc12015-05-05 11:14:42 -070011
12 def __init__( self ):
13 self.default = ''
14
15 def CASE10( self, main ):
16 import time
17 import os
18 """
19 Startup sequence:
20 cell <name>
21 onos-verify-cell
22 onos-remove-raft-log
23 git pull
24 mvn clean install
25 onos-package
26 onos-install -f
27 onos-wait-for-start
28 """
kelvin-onlabf70fd542015-05-07 18:41:40 -070029 global init
cameron@onlab.us59d29d92015-05-11 14:31:54 -070030 global globalONOSip
kelvin-onlabf70fd542015-05-07 18:41:40 -070031 try:
32 if type(init) is not bool:
33 init = False
34 except NameError:
35 init = False
cameron@onlab.us59d29d92015-05-11 14:31:54 -070036
kelvin-onlab4ff9cc12015-05-05 11:14:42 -070037 #Local variables
38 cellName = main.params[ 'ENV' ][ 'cellName' ]
kelvin-onlabf70fd542015-05-07 18:41:40 -070039 apps = main.params[ 'ENV' ][ 'cellApps' ]
kelvin-onlabf70fd542015-05-07 18:41:40 -070040 gitBranch = main.params[ 'GIT' ][ 'branch' ]
cameron@onlab.us59d29d92015-05-11 14:31:54 -070041 benchIp = os.environ[ 'OCN' ]
kelvin-onlabf70fd542015-05-07 18:41:40 -070042 benchUser = main.params[ 'BENCH' ][ 'user' ]
kelvin-onlab05cf7732015-05-08 14:25:46 -070043 topology = main.params[ 'MININET' ][ 'topo' ]
kelvin-onlab4ff9cc12015-05-05 11:14:42 -070044 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
kelvin-onlab65782a82015-05-07 14:12:13 -070045 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
kelvin-onlabf70fd542015-05-07 18:41:40 -070046 main.numCtrls = main.params[ 'CTRL' ][ 'num' ]
kelvin-onlab4ff9cc12015-05-05 11:14:42 -070047 PULLCODE = False
48 if main.params[ 'GIT' ][ 'pull' ] == 'True':
49 PULLCODE = True
50 main.case( "Setting up test environment" )
kelvin-onlabf70fd542015-05-07 18:41:40 -070051 main.CLIs = []
52 for i in range( 1, int( main.numCtrls ) + 1 ):
53 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
54
55 # -- INIT SECTION, ONLY RUNS ONCE -- #
56 if init == False:
57 init = True
kelvin-onlabf70fd542015-05-07 18:41:40 -070058
kelvin-onlab05cf7732015-05-08 14:25:46 -070059 main.ONOSport = []
60 main.scale = ( main.params[ 'SCALE' ] ).split( "," )
61 main.numCtrls = int( main.scale[ 0 ] )
kelvin-onlabf70fd542015-05-07 18:41:40 -070062
63 if PULLCODE:
64 main.step( "Git checkout and pull " + gitBranch )
65 main.ONOSbench.gitCheckout( gitBranch )
66 gitPullResult = main.ONOSbench.gitPull()
67 if gitPullResult == main.ERROR:
68 main.log.error( "Error pulling git branch" )
69 main.step( "Using mvn clean & install" )
70 cleanInstallResult = main.ONOSbench.cleanInstall()
71 stepResult = cleanInstallResult
72 utilities.assert_equals( expect=main.TRUE,
73 actual=stepResult,
74 onpass="Successfully compiled " +
75 "latest ONOS",
76 onfail="Failed to compile " +
77 "latest ONOS" )
78 else:
79 main.log.warn( "Did not pull new code so skipping mvn " +
80 "clean install" )
cameron@onlab.us59d29d92015-05-11 14:31:54 -070081
82 globalONOSip = main.ONOSbench.getOnosIpFromEnv()
83
84 maxNodes = ( len(globalONOSip) - 3 )
kelvin-onlabf70fd542015-05-07 18:41:40 -070085
kelvin-onlab05cf7732015-05-08 14:25:46 -070086 main.numCtrls = int( main.scale[ 0 ] )
87 main.scale.remove( main.scale[ 0 ] )
cameron@onlab.us59d29d92015-05-11 14:31:54 -070088
89 main.ONOSip = [0]
90 for i in range( 1, maxNodes + 1 ):
91 main.ONOSip.append( globalONOSip[i] )
92
93
94
kelvin-onlabf70fd542015-05-07 18:41:40 -070095 #kill off all onos processes
96 main.log.info( "Safety check, killing all ONOS processes" +
97 " before initiating enviornment setup" )
cameron@onlab.us59d29d92015-05-11 14:31:54 -070098 for i in range(1, maxNodes+1):
99 main.ONOSbench.onosDie( globalONOSip[ i ] )
100
kelvin-onlabf70fd542015-05-07 18:41:40 -0700101 """
102 main.step( "Apply cell to environment" )
103 cellResult = main.ONOSbench.setCell( cellName )
104 verifyResult = main.ONOSbench.verifyCell()
105 stepResult = cellResult and verifyResult
106 utilities.assert_equals( expect=main.TRUE,
107 actual=stepResult,
108 onpass="Successfully applied cell to " + \
109 "environment",
110 onfail="Failed to apply cell to environment " )
111 """
112 """main.step( "Removing raft logs" )
113 removeRaftResult = main.ONOSbench.onosRemoveRaftLogs()
114 stepResult = removeRaftResult
115 utilities.assert_equals( expect=main.TRUE,
116 actual=stepResult,
117 onpass="Successfully removed raft logs",
118 onfail="Failed to remove raft logs" )
119 """
cameron@onlab.us59d29d92015-05-11 14:31:54 -0700120
kelvin-onlab05cf7732015-05-08 14:25:46 -0700121 print "NODE COUNT = ", main.numCtrls
kelvin-onlabf70fd542015-05-07 18:41:40 -0700122 main.log.info( "Creating cell file" )
123 cellIp = []
cameron@onlab.us684cee32015-05-11 17:14:04 -0700124 for i in range( 1, main.numCtrls + 1 ):
kelvin-onlab05cf7732015-05-08 14:25:46 -0700125 cellIp.append( str( main.ONOSip[ i ] ) )
kelvin-onlabf70fd542015-05-07 18:41:40 -0700126 print cellIp
127 main.ONOSbench.createCellFile( benchIp, cellName, "",
128 str( apps ), *cellIp )
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700129
130 main.step( "Apply cell to environment" )
131 cellResult = main.ONOSbench.setCell( cellName )
132 verifyResult = main.ONOSbench.verifyCell()
133 stepResult = cellResult and verifyResult
134 utilities.assert_equals( expect=main.TRUE,
135 actual=stepResult,
136 onpass="Successfully applied cell to " + \
137 "environment",
138 onfail="Failed to apply cell to environment " )
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700139
140 main.step( "Creating ONOS package" )
141 packageResult = main.ONOSbench.onosPackage()
142 stepResult = packageResult
143 utilities.assert_equals( expect=main.TRUE,
144 actual=stepResult,
145 onpass="Successfully created ONOS package",
146 onfail="Failed to create ONOS package" )
147
148 main.step( "Uninstalling ONOS package" )
kelvin-onlabf70fd542015-05-07 18:41:40 -0700149 onosUninstallResult = main.TRUE
cameron@onlab.us59d29d92015-05-11 14:31:54 -0700150 for i in range( 1, main.numCtrls + 1):
kelvin-onlabf70fd542015-05-07 18:41:40 -0700151 onosUninstallResult = onosUninstallResult and \
kelvin-onlab05cf7732015-05-08 14:25:46 -0700152 main.ONOSbench.onosUninstall( nodeIp=main.ONOSip[ i ] )
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700153 stepResult = onosUninstallResult
154 utilities.assert_equals( expect=main.TRUE,
155 actual=stepResult,
156 onpass="Successfully uninstalled ONOS package",
157 onfail="Failed to uninstall ONOS package" )
158 time.sleep( 5 )
159 main.step( "Installing ONOS package" )
kelvin-onlabf70fd542015-05-07 18:41:40 -0700160 onosInstallResult = main.TRUE
cameron@onlab.us59d29d92015-05-11 14:31:54 -0700161 for i in range( 1, main.numCtrls+1):
kelvin-onlabf70fd542015-05-07 18:41:40 -0700162 onosInstallResult = onosInstallResult and \
kelvin-onlab05cf7732015-05-08 14:25:46 -0700163 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700164 stepResult = onosInstallResult
165 utilities.assert_equals( expect=main.TRUE,
166 actual=stepResult,
167 onpass="Successfully installed ONOS package",
168 onfail="Failed to install ONOS package" )
169
cameron@onlab.us59d29d92015-05-11 14:31:54 -0700170 time.sleep( 20 )
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700171 main.step( "Starting ONOS service" )
172 stopResult = main.TRUE
173 startResult = main.TRUE
kelvin-onlabf70fd542015-05-07 18:41:40 -0700174 onosIsUp = main.TRUE
cameron@onlab.us59d29d92015-05-11 14:31:54 -0700175 for i in range( 1, main.numCtrls+1 ):
kelvin-onlab05cf7732015-05-08 14:25:46 -0700176 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700177 if onosIsUp == main.TRUE:
178 main.log.report( "ONOS instance is up and ready" )
179 else:
180 main.log.report( "ONOS instance may not be up, stop and " +
181 "start ONOS again " )
kelvin-onlab05cf7732015-05-08 14:25:46 -0700182 for i in range( main.numCtrls ):
kelvin-onlabf70fd542015-05-07 18:41:40 -0700183 stopResult = stopResult and \
kelvin-onlab05cf7732015-05-08 14:25:46 -0700184 main.ONOSbench.onosStop( main.ONOSip[ i ] )
185 for i in range( main.numCtrls ):
kelvin-onlabf70fd542015-05-07 18:41:40 -0700186 startResult = startResult and \
kelvin-onlab05cf7732015-05-08 14:25:46 -0700187 main.ONOSbench.onosStart( main.ONOSip[ i ] )
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700188 stepResult = onosIsUp and stopResult and startResult
189 utilities.assert_equals( expect=main.TRUE,
190 actual=stepResult,
191 onpass="ONOS service is ready",
192 onfail="ONOS service did not start properly" )
kelvin-onlabf70fd542015-05-07 18:41:40 -0700193
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700194 main.step( "Start ONOS cli" )
kelvin-onlabf70fd542015-05-07 18:41:40 -0700195 cliResult = main.TRUE
kelvin-onlab05cf7732015-05-08 14:25:46 -0700196 for i in range( main.numCtrls ):
197 cliResult = cliResult and \
198 main.CLIs[i].startOnosCli( main.ONOSip[ i ] )
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700199 stepResult = cliResult
200 utilities.assert_equals( expect=main.TRUE,
201 actual=stepResult,
202 onpass="Successfully start ONOS cli",
203 onfail="Failed to start ONOS cli" )
204
205 def CASE11( self, main ):
206 """
kelvin-onlab05cf7732015-05-08 14:25:46 -0700207 Start mininet
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700208 """
kelvin-onlab05cf7732015-05-08 14:25:46 -0700209 main.log.report( "Start Mininet topology" )
210 main.log.case( "Start Mininet topology" )
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700211
kelvin-onlabf70fd542015-05-07 18:41:40 -0700212 main.step( "Starting Mininet Topology" )
213 topoResult = main.Mininet1.startNet( topoFile=topology )
214 stepResult = topoResult
215 utilities.assert_equals( expect=main.TRUE,
216 actual=stepResult,
217 onpass="Successfully loaded topology",
218 onfail="Failed to load topology" )
219 # Exit if topology did not load properly
220 if not topoResult:
221 main.cleanup()
222 main.exit()
223
kelvin-onlab05cf7732015-05-08 14:25:46 -0700224 def CASE12( self, main ):
225 """
226 Assign mastership to controllers
227 """
228 import re
229
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700230 main.step( "Assigning switches to controllers" )
231 assignResult = main.TRUE
kelvin-onlab5cbf9992015-05-05 14:34:07 -0700232 for i in range( 1, ( main.numSwitch + 1 ) ):
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700233 main.Mininet1.assignSwController( sw=str( i ),
234 count=1,
kelvin-onlab05cf7732015-05-08 14:25:46 -0700235 ip1=main.ONOSip[ 0 ],
236 port1=main.ONOSport[ 0 ] )
kelvin-onlab5cbf9992015-05-05 14:34:07 -0700237 for i in range( 1, ( main.numSwitch + 1 ) ):
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700238 response = main.Mininet1.getSwController( "s" + str( i ) )
239 print( "Response is " + str( response ) )
kelvin-onlab05cf7732015-05-08 14:25:46 -0700240 if re.search( "tcp:" + main.ONOSip[ 0 ], response ):
kelvin-onlab4ff9cc12015-05-05 11:14:42 -0700241 assignResult = assignResult and main.TRUE
242 else:
243 assignResult = main.FALSE
244 stepResult = assignResult
245 utilities.assert_equals( expect=main.TRUE,
246 actual=stepResult,
247 onpass="Successfully assigned switches" +
248 "to controller",
249 onfail="Failed to assign switches to " +
250 "controller" )
251
kelvin-onlabf70fd542015-05-07 18:41:40 -0700252 def CASE1001( self, main ):
kelvin-onlab7c577e82015-05-07 10:45:16 -0700253 """
kelvin-onlab65782a82015-05-07 14:12:13 -0700254 Add host intents between 2 host:
255 - Discover hosts
256 - Add host intents
257 - Check intents
258 - Check flows
259 - Ping hosts
260 - Reroute
261 - Link down
262 - Ping hosts
263 - Link up
264 - Ping hosts
265 - Remove intents
kelvin-onlab7c577e82015-05-07 10:45:16 -0700266 """
267 import time
268 import json
kelvin-onlab65782a82015-05-07 14:12:13 -0700269 import re
270 """
271 Create your item(s) here
272 item = { 'name': '', 'host1':
273 { 'name': '', 'MAC': '00:00:00:00:00:0X',
274 'id':'00:00:00:00:00:0X/-X' } , 'host2':
275 { 'name': '', 'MAC': '00:00:00:00:00:0X',
276 'id':'00:00:00:00:00:0X/-X'}, 'link': { 'switch1': '',
277 'switch2': '', 'num':'' } }
278 """
279 # Local variables
280 items = []
281 ipv4 = { 'name': 'IPV4', 'host1':
282 { 'name': 'h1', 'MAC': '00:00:00:00:00:01',
283 'id':'00:00:00:00:00:01/-1' } , 'host2':
284 { 'name': 'h9', 'MAC': '00:00:00:00:00:09',
kelvin-onlab05cf7732015-05-08 14:25:46 -0700285 'id':'00:00:00:00:00:09/-1'}, 'link': { 'switch1': 's5',
kelvin-onlab65782a82015-05-07 14:12:13 -0700286 'switch2': 's2', 'num':'18' } }
287 dualStack1 = { 'name': 'DUALSTACK1', 'host1':
288 { 'name': 'h3', 'MAC': '00:00:00:00:00:03',
289 'id':'00:00:00:00:00:03/-1' } , 'host2':
kelvin-onlabf70fd542015-05-07 18:41:40 -0700290 { 'name': 'h11', 'MAC': '00:00:00:00:00:0B',
kelvin-onlab65782a82015-05-07 14:12:13 -0700291 'id':'00:00:00:00:00:0B/-1'}, 'link': { 'switch1': 's5',
292 'switch2': 's2', 'num':'18' } }
293 items.append( ipv4 )
kelvin-onlabf70fd542015-05-07 18:41:40 -0700294 items.append( dualStack1 )
kelvin-onlab65782a82015-05-07 14:12:13 -0700295 # Global variables
kelvin-onlab7c577e82015-05-07 10:45:16 -0700296
kelvin-onlabf70fd542015-05-07 18:41:40 -0700297 main.log.case( "Add host intents between 2 host" )
kelvin-onlab7c577e82015-05-07 10:45:16 -0700298
kelvin-onlab65782a82015-05-07 14:12:13 -0700299 for item in items:
300 stepResult = main.TRUE
kelvin-onlab05cf7732015-05-08 14:25:46 -0700301 itemName = item[ 'name' ]
kelvin-onlab65782a82015-05-07 14:12:13 -0700302 h1Name = item[ 'host1' ][ 'name' ]
303 h2Name = item[ 'host2' ][ 'name' ]
304 h1Mac = item[ 'host1' ][ 'MAC' ]
305 h2Mac = item[ 'host2' ][ 'MAC' ]
306 h1Id = item[ 'host1' ][ 'id']
307 h2Id = item[ 'host2' ][ 'id']
308 # Link down/up for rerouting
309 sw1 = item[ 'link' ][ 'switch1' ]
310 sw2 = item[ 'link' ][ 'switch2' ]
311 remLink = item[ 'link' ][ 'num' ]
kelvin-onlab05cf7732015-05-08 14:25:46 -0700312 pingResult = main.TRUE
313 statusResult = main.TRUE
314 linkDownResult = main.TRUE
315 linkUpResult = main.TRUE
kelvin-onlab65782a82015-05-07 14:12:13 -0700316 intentsId = []
kelvin-onlab05cf7732015-05-08 14:25:46 -0700317 main.step( itemName + ": Add host intents between " + h1Name
kelvin-onlab65782a82015-05-07 14:12:13 -0700318 + " and " + h2Name )
kelvin-onlab05cf7732015-05-08 14:25:46 -0700319 main.log.info( itemName + ": Discover host using arping" )
kelvin-onlab65782a82015-05-07 14:12:13 -0700320 main.Mininet1.arping( host=h1Name )
321 main.Mininet1.arping( host=h2Name )
kelvin-onlab05cf7732015-05-08 14:25:46 -0700322 host1 = main.CLIs[ 0 ].getHost( mac=h1Mac )
323 host2 = main.CLIs[ 0 ].getHost( mac=h2Mac )
kelvin-onlab65782a82015-05-07 14:12:13 -0700324 print host1
325 print host2
326 # Adding intents
kelvin-onlab05cf7732015-05-08 14:25:46 -0700327 main.log.info( itemName + ": Adding host intents" )
328 intent1 = main.CLIs[ 0 ].addHostIntent( hostIdOne=h1Id,
kelvin-onlab65782a82015-05-07 14:12:13 -0700329 hostIdTwo=h2Id )
330 intentsId.append( intent1 )
331 time.sleep( 5 )
kelvin-onlab05cf7732015-05-08 14:25:46 -0700332 intent2 = main.CLIs[ 0 ].addHostIntent( hostIdOne=h2Id,
kelvin-onlab65782a82015-05-07 14:12:13 -0700333 hostIdTwo=h1Id )
334 intentsId.append( intent2 )
335 # Checking intents
kelvin-onlab05cf7732015-05-08 14:25:46 -0700336 main.log.info( itemName + ": Check host intents state" )
337 time.sleep( 30 )
338 for i in range( main.numCtrls ):
339 intentResult = main.CLIs[ i ].checkIntentState(
340 intentsId=intentsId )
kelvin-onlab65782a82015-05-07 14:12:13 -0700341 if not intentResult:
kelvin-onlab05cf7732015-05-08 14:25:46 -0700342 main.log.info( itemName + ": Check host intents state" +
kelvin-onlab65782a82015-05-07 14:12:13 -0700343 " again")
kelvin-onlab05cf7732015-05-08 14:25:46 -0700344 for i in range( main.numCtrls ):
345 intentResult = main.CLIs[ i ].checkIntentState(
kelvin-onlab65782a82015-05-07 14:12:13 -0700346 intentsId=intentsId )
347 # Ping hosts
348 time.sleep( 10 )
kelvin-onlab05cf7732015-05-08 14:25:46 -0700349 main.log.info( itemName + ": Ping " + h1Name + " and " +
kelvin-onlab65782a82015-05-07 14:12:13 -0700350 h2Name )
351 pingResult1 = main.Mininet1.pingHost( src=h1Name , target=h2Name )
352 if not pingResult1:
kelvin-onlab05cf7732015-05-08 14:25:46 -0700353 main.log.info( itemName + ": " + h1Name + " cannot ping "
kelvin-onlab65782a82015-05-07 14:12:13 -0700354 + h2Name )
355 pingResult2 = main.Mininet1.pingHost( src=h2Name , target=h1Name )
356 if not pingResult2:
kelvin-onlab05cf7732015-05-08 14:25:46 -0700357 main.log.info( itemName + ": " + h2Name + " cannot ping "
kelvin-onlab65782a82015-05-07 14:12:13 -0700358 + h1Name )
359 pingResult = pingResult1 and pingResult2
360 if pingResult:
kelvin-onlab05cf7732015-05-08 14:25:46 -0700361 main.log.info( itemName + ": Successfully pinged " +
kelvin-onlab65782a82015-05-07 14:12:13 -0700362 "both hosts" )
363 else:
kelvin-onlab05cf7732015-05-08 14:25:46 -0700364 main.log.info( itemName + ": Failed to ping " +
kelvin-onlab65782a82015-05-07 14:12:13 -0700365 "both hosts" )
366 # Rerouting ( link down )
kelvin-onlab05cf7732015-05-08 14:25:46 -0700367 main.log.info( itemName + ": Bring link down between " +
kelvin-onlab65782a82015-05-07 14:12:13 -0700368 sw1 + " and " + sw2 )
369 main.Mininet1.link( end1=sw1,
370 end2=sw2,
371 option="down" )
372 time.sleep( 5 )
kelvin-onlab7c577e82015-05-07 10:45:16 -0700373
kelvin-onlab65782a82015-05-07 14:12:13 -0700374 # Check onos topology
kelvin-onlab05cf7732015-05-08 14:25:46 -0700375 main.log.info( itemName + ": Checking ONOS topology " )
376
377 for i in range( main.numCtrls ):
378 topologyResult = main.CLIs[ i ].topology()
379 linkDownResult = main.ONOSbench.checkStatus( topologyResult,
380 main.numSwitch,
381 remLink )\
382 and linkDownResult
383 if not linkDownResult:
384 main.log.info( itemName + ": Topology mismatch" )
kelvin-onlab65782a82015-05-07 14:12:13 -0700385 else:
kelvin-onlab05cf7732015-05-08 14:25:46 -0700386 main.log.info( itemName + ": Topology match" )
kelvin-onlab7c577e82015-05-07 10:45:16 -0700387
kelvin-onlab65782a82015-05-07 14:12:13 -0700388 # Ping hosts
kelvin-onlab05cf7732015-05-08 14:25:46 -0700389 main.log.info( itemName + ": Ping " + h1Name + " and " +
kelvin-onlab65782a82015-05-07 14:12:13 -0700390 h2Name )
391 pingResult1 = main.Mininet1.pingHost( src=h1Name , target=h2Name )
392 if not pingResult1:
kelvin-onlab05cf7732015-05-08 14:25:46 -0700393 main.log.info( itemName + ": " + h1Name + " cannot ping "
kelvin-onlab65782a82015-05-07 14:12:13 -0700394 + h2Name )
395 pingResult2 = main.Mininet1.pingHost( src=h2Name , target=h1Name )
396 if not pingResult2:
kelvin-onlab05cf7732015-05-08 14:25:46 -0700397 main.log.info( itemName + ": " + h2Name + " cannot ping "
kelvin-onlab65782a82015-05-07 14:12:13 -0700398 + h1Name )
399 pingResult = pingResult1 and pingResult2
400 if pingResult:
kelvin-onlab05cf7732015-05-08 14:25:46 -0700401 main.log.info( itemName + ": Successfully pinged " +
kelvin-onlab65782a82015-05-07 14:12:13 -0700402 "both hosts" )
403 else:
kelvin-onlab05cf7732015-05-08 14:25:46 -0700404 main.log.info( itemName + ": Failed to ping " +
kelvin-onlab65782a82015-05-07 14:12:13 -0700405 "both hosts" )
406 # link up
kelvin-onlab05cf7732015-05-08 14:25:46 -0700407 main.log.info( itemName + ": Bring link up between " +
kelvin-onlab65782a82015-05-07 14:12:13 -0700408 sw1 + " and " + sw2 )
409 main.Mininet1.link( end1=sw1,
410 end2=sw2,
411 option="up" )
412 time.sleep( 5 )
kelvin-onlab7c577e82015-05-07 10:45:16 -0700413
kelvin-onlab65782a82015-05-07 14:12:13 -0700414 # Check onos topology
kelvin-onlab05cf7732015-05-08 14:25:46 -0700415 main.log.info( itemName + ": Checking ONOS topology " )
416 for i in range( main.numCtrls ):
417 topologyResult = main.CLIs[ i ].topology()
418 linkUpResult = main.ONOSbench.checkStatus( topologyResult,
419 main.numSwitch,
420 main.numLinks )\
421 and linkUpResult
422 if not linkUpResult:
423 main.log.info( itemName + ": Topology mismatch" )
kelvin-onlab65782a82015-05-07 14:12:13 -0700424 else:
kelvin-onlab05cf7732015-05-08 14:25:46 -0700425 main.log.info( itemName + ": Topology match" )
kelvin-onlab7c577e82015-05-07 10:45:16 -0700426
kelvin-onlab65782a82015-05-07 14:12:13 -0700427 # Ping hosts
kelvin-onlab05cf7732015-05-08 14:25:46 -0700428 main.log.info( itemName + ": Ping " + h1Name + " and " +
kelvin-onlab65782a82015-05-07 14:12:13 -0700429 h2Name )
430 pingResult1 = main.Mininet1.pingHost( src=h1Name , target=h2Name )
431 if not pingResult1:
kelvin-onlab05cf7732015-05-08 14:25:46 -0700432 main.log.info( itemName + ": " + h1Name + " cannot ping "
kelvin-onlab65782a82015-05-07 14:12:13 -0700433 + h2Name )
434 pingResult2 = main.Mininet1.pingHost( src=h2Name , target=h1Name )
435 if not pingResult2:
kelvin-onlab05cf7732015-05-08 14:25:46 -0700436 main.log.info( itemName + ": " + h2Name + " cannot ping "
kelvin-onlab65782a82015-05-07 14:12:13 -0700437 + h1Name )
438 pingResult = pingResult1 and pingResult2
439 if pingResult:
kelvin-onlab05cf7732015-05-08 14:25:46 -0700440 main.log.info( itemName + ": Successfully pinged " +
kelvin-onlab65782a82015-05-07 14:12:13 -0700441 "both hosts" )
442 else:
kelvin-onlab05cf7732015-05-08 14:25:46 -0700443 main.log.info( itemName + ": Failed to ping " +
kelvin-onlab65782a82015-05-07 14:12:13 -0700444 "both hosts" )
445
446 # Remove intents
447 for intent in intentsId:
kelvin-onlab05cf7732015-05-08 14:25:46 -0700448 main.CLIs[ 0 ].removeIntent( intentId=intent, purge=True )
kelvin-onlab65782a82015-05-07 14:12:13 -0700449
kelvin-onlab05cf7732015-05-08 14:25:46 -0700450 print main.CLIs[ 0 ].intents()
451 stepResult = pingResult and linkDownResult and linkUpResult \
452 and intentResult
kelvin-onlab65782a82015-05-07 14:12:13 -0700453 utilities.assert_equals( expect=main.TRUE,
454 actual=stepResult,
kelvin-onlab05cf7732015-05-08 14:25:46 -0700455 onpass=itemName +
456 ": host intent successful",
457 onfail=itemName +
458 ": Add host intent failed" )
kelvin-onlabf70fd542015-05-07 18:41:40 -0700459 def CASE1002( self, main ):
kelvin-onlab65782a82015-05-07 14:12:13 -0700460 """
461 Add point intents between 2 hosts:
462 - Get device ids
463 - Add point intents
464 - Check intents
465 - Check flows
466 - Ping hosts
467 - Reroute
468 - Link down
469 - Ping hosts
470 - Link up
471 - Ping hosts
472 - Remove intents
473 """
474
kelvin-onlabf70fd542015-05-07 18:41:40 -0700475 def CASE1003( self, main ):
kelvin-onlab65782a82015-05-07 14:12:13 -0700476 """
477 Add single point to multi point intents
478 - Get device ids
479 - Add single point to multi point intents
480 - Check intents
481 - Check flows
482 - Ping hosts
483 - Reroute
484 - Link down
485 - Ping hosts
486 - Link up
487 - Ping hosts
488 - Remove intents
489 """
490
kelvin-onlabf70fd542015-05-07 18:41:40 -0700491 def CASE1004( self, main ):
kelvin-onlab65782a82015-05-07 14:12:13 -0700492 """
493 Add multi point to single point intents
494 - Get device ids
495 - Add multi point to single point intents
496 - Check intents
497 - Check flows
498 - Ping hosts
499 - Reroute
500 - Link down
501 - Ping hosts
502 - Link up
503 - Ping hosts
504 - Remove intents
505 """