blob: 23da6ecbf7f2b631aaa39323e2a8db7d58e44248 [file] [log] [blame]
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001import time
2import sys
3import os
4import re
5import time
6import json
7import itertools
8
kelvin8ec71442015-01-15 16:57:00 -08009
Hari Krishnaa43d4e92014-12-19 13:22:40 -080010class OnosCHO:
kelvin8ec71442015-01-15 16:57:00 -080011
kelvin-onlab8a832582015-01-16 17:06:11 -080012 def __init__( self ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -080013 self.default = ''
kelvin8ec71442015-01-15 16:57:00 -080014
kelvin-onlab8a832582015-01-16 17:06:11 -080015 def CASE1( self, main ):
16 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -080017 Startup sequence:
18 git pull
19 mvn clean install
20 onos-package
21 cell <name>
22 onos-verify-cell
23 onos-install -f
24 onos-wait-for-start
kelvin-onlab8a832582015-01-16 17:06:11 -080025 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -080026 import time
kelvin-onlab54400a92015-02-26 18:05:51 -080027
28 main.threadID = 0
29 main.pingTimeout = 300
Hari Krishna22c3d412015-02-17 16:48:12 -080030 main.numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ]
31 main.ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
32 main.ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
33 main.ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
34 main.ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ]
35 main.ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ]
36 main.ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
37 main.ONOS2_port = main.params[ 'CTRL' ][ 'port2' ]
38 main.ONOS3_port = main.params[ 'CTRL' ][ 'port3' ]
39 main.ONOS4_port = main.params[ 'CTRL' ][ 'port4' ]
40 main.ONOS5_port = main.params[ 'CTRL' ][ 'port5' ]
kelvin-onlab8a832582015-01-16 17:06:11 -080041 cell_name = main.params[ 'ENV' ][ 'cellName' ]
42 git_pull = main.params[ 'GIT' ][ 'autoPull' ]
kelvin-onlab8a832582015-01-16 17:06:11 -080043 git_branch = main.params[ 'GIT' ][ 'branch' ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -080044
kelvin-onlab8a832582015-01-16 17:06:11 -080045 main.case( "Set up test environment" )
46 main.log.report( "Set up test environment" )
47 main.log.report( "_______________________" )
48
49 main.step( "Git checkout and pull " + git_branch )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080050 if git_pull == 'on':
Hari Krishnad97213e2015-01-24 19:30:14 -080051 checkout_result = main.ONOSbench.gitCheckout( git_branch )
52 pull_result = main.ONOSbench.gitPull()
kelvin-onlab8a832582015-01-16 17:06:11 -080053 cp_result = ( checkout_result and pull_result )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080054 else:
55 checkout_result = main.TRUE
56 pull_result = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -080057 main.log.info( "Skipped git checkout and pull" )
58 cp_result = ( checkout_result and pull_result )
59 utilities.assert_equals( expect=main.TRUE, actual=cp_result,
60 onpass="Test step PASS",
61 onfail="Test step FAIL" )
62
63 main.step( "mvn clean & install" )
Hari Krishna22c3d412015-02-17 16:48:12 -080064 if git_pull == 'on':
65 mvn_result = main.ONOSbench.cleanInstall()
66 utilities.assert_equals( expect=main.TRUE, actual=mvn_result,
kelvin-onlab8a832582015-01-16 17:06:11 -080067 onpass="Test step PASS",
68 onfail="Test step FAIL" )
Hari Krishna22c3d412015-02-17 16:48:12 -080069 else:
70 mvn_result = main.TRUE
71 main.log.info("Skipped mvn clean install as git pull is disabled in params file")
Hari Krishnaa43d4e92014-12-19 13:22:40 -080072
Hari Krishnad97213e2015-01-24 19:30:14 -080073 main.ONOSbench.getVersion( report=True )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080074
kelvin-onlab8a832582015-01-16 17:06:11 -080075 main.step( "Apply Cell environment for ONOS" )
Hari Krishnad97213e2015-01-24 19:30:14 -080076 cell_result = main.ONOSbench.setCell( cell_name )
kelvin-onlab8a832582015-01-16 17:06:11 -080077 utilities.assert_equals( expect=main.TRUE, actual=cell_result,
78 onpass="Test step PASS",
79 onfail="Test step FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080080
kelvin-onlab8a832582015-01-16 17:06:11 -080081 main.step( "Create ONOS package" )
Hari Krishnad97213e2015-01-24 19:30:14 -080082 packageResult = main.ONOSbench.onosPackage()
kelvin-onlab8a832582015-01-16 17:06:11 -080083 utilities.assert_equals( expect=main.TRUE, actual=packageResult,
84 onpass="Test step PASS",
85 onfail="Test step FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080086
kelvin-onlab8a832582015-01-16 17:06:11 -080087 main.step( "Uninstall ONOS package on all Nodes" )
88 uninstallResult = main.TRUE
Hari Krishna22c3d412015-02-17 16:48:12 -080089 for i in range( 1, int( main.numCtrls ) + 1 ):
kelvin-onlab8a832582015-01-16 17:06:11 -080090 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
kelvin-onlab54400a92015-02-26 18:05:51 -080091 main.log.info( "Uninstalling package on ONOS Node IP: " + ONOS_ip )
Hari Krishnad97213e2015-01-24 19:30:14 -080092 u_result = main.ONOSbench.onosUninstall( ONOS_ip )
kelvin-onlab8a832582015-01-16 17:06:11 -080093 utilities.assert_equals( expect=main.TRUE, actual=u_result,
94 onpass="Test step PASS",
95 onfail="Test step FAIL" )
96 uninstallResult = ( uninstallResult and u_result )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080097
kelvin-onlab8a832582015-01-16 17:06:11 -080098 main.step( "Removing copy-cat logs from ONOS nodes" )
Hari Krishnad97213e2015-01-24 19:30:14 -080099 main.ONOSbench.onosRemoveRaftLogs()
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800100
kelvin-onlab8a832582015-01-16 17:06:11 -0800101 main.step( "Install ONOS package on all Nodes" )
102 installResult = main.TRUE
Hari Krishna22c3d412015-02-17 16:48:12 -0800103 for i in range( 1, int( main.numCtrls ) + 1 ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800104 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
105 main.log.info( "Intsalling package on ONOS Node IP: " + ONOS_ip )
Hari Krishnad97213e2015-01-24 19:30:14 -0800106 i_result = main.ONOSbench.onosInstall( node=ONOS_ip )
kelvin-onlab8a832582015-01-16 17:06:11 -0800107 utilities.assert_equals( expect=main.TRUE, actual=i_result,
108 onpass="Test step PASS",
109 onfail="Test step FAIL" )
110 installResult = ( installResult and i_result )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800111
kelvin-onlab8a832582015-01-16 17:06:11 -0800112 main.step( "Verify ONOS nodes UP status" )
113 statusResult = main.TRUE
Hari Krishna22c3d412015-02-17 16:48:12 -0800114 for i in range( 1, int( main.numCtrls ) + 1 ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800115 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
116 main.log.info( "ONOS Node " + ONOS_ip + " status:" )
Hari Krishnad97213e2015-01-24 19:30:14 -0800117 onos_status = main.ONOSbench.onosStatus( node=ONOS_ip )
kelvin-onlab8a832582015-01-16 17:06:11 -0800118 utilities.assert_equals( expect=main.TRUE, actual=onos_status,
119 onpass="Test step PASS",
120 onfail="Test step FAIL" )
121 statusResult = ( statusResult and onos_status )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800122
kelvin-onlab8a832582015-01-16 17:06:11 -0800123 main.step( "Start ONOS CLI on all nodes" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800124 cliResult = main.TRUE
kelvin8ec71442015-01-15 16:57:00 -0800125 karafTimeout = "3600000"
kelvin-onlab8a832582015-01-16 17:06:11 -0800126 # need to wait here for sometime. This will be removed once ONOS is
127 # stable enough
kelvin-onlab54400a92015-02-26 18:05:51 -0800128 time.sleep( 25 )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800129
kelvin-onlab54400a92015-02-26 18:05:51 -0800130 main.log.step(" Start ONOS cli using thread ")
131 startCliResult = main.FALSE
132
133 CLI1 = (main.ONOScli1.startOnosCli,main.ONOS1_ip)
134 CLI2 = (main.ONOScli2.startOnosCli,main.ONOS2_ip)
135 CLI3 = (main.ONOScli3.startOnosCli,main.ONOS3_ip)
136 CLI4 = (main.ONOScli4.startOnosCli,main.ONOS4_ip)
137 CLI5 = (main.ONOScli5.startOnosCli,main.ONOS5_ip)
138 ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5]
139 pool = []
140 time1 = time.time()
141 for cli,ip in ONOSCLI:
142 t = main.Thread(target=cli,threadID=main.threadID,
143 name="startOnosCli",args=[ip])
144 pool.append(t)
145 t.start()
146 main.threadID = main.threadID + 1
147
148 results = []
149 for thread in pool:
150 thread.join()
151 results.append(thread.result)
152 time2 = time.time()
153
154 if( all(result == main.TRUE for result in results) == False):
155 main.log.info("ONOS CLI did not start up properly")
156 main.cleanup()
157 main.exit()
158 else:
159 main.log.info("Successful CLI startup")
160 startCliResult = main.TRUE
161 case1Result = installResult and uninstallResult and statusResult and startCliResult
162
163 main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
kelvin-onlab8a832582015-01-16 17:06:11 -0800164 utilities.assert_equals( expect=main.TRUE, actual=case1Result,
165 onpass="Set up test environment PASS",
166 onfail="Set up test environment FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800167
kelvin-onlab8a832582015-01-16 17:06:11 -0800168 def CASE2( self, main ):
169 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800170 This test loads a Topology (ATT) on Mininet and balances all switches.
kelvin-onlab8a832582015-01-16 17:06:11 -0800171 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800172 import re
173 import time
174 import copy
Hari Krishna22c3d412015-02-17 16:48:12 -0800175 main.numMNswitches = int ( main.params[ 'TOPO1' ][ 'numSwitches' ] )
176 main.numMNlinks = int ( main.params[ 'TOPO1' ][ 'numLinks' ] )
177 main.numMNhosts = int ( main.params[ 'TOPO1' ][ 'numHosts' ] )
kelvin-onlab54400a92015-02-26 18:05:51 -0800178 main.pingTimeout = 60
kelvin-onlab8a832582015-01-16 17:06:11 -0800179 main.log.report(
180 "Assign and Balance all Mininet switches across controllers" )
181 main.log.report(
182 "_________________________________________________________" )
183 # need to wait here for sometime. This will be removed once ONOS is
184 # stable enough
185 time.sleep( 15 )
186 main.case(
187 "Assign and Balance all Mininet switches across controllers" )
188 main.step( "Assign switches to controllers" )
Hari Krishna22c3d412015-02-17 16:48:12 -0800189 netStatus = main.Mininet1.startNet()
190 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
Hari Krishnad97213e2015-01-24 19:30:14 -0800191 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800192 sw=str( i ),
Hari Krishna22c3d412015-02-17 16:48:12 -0800193 count=int( main.numCtrls ),
194 ip1=main.ONOS1_ip,
195 port1=main.ONOS1_port,
196 ip2=main.ONOS2_ip,
197 port2=main.ONOS2_port,
198 ip3=main.ONOS3_ip,
199 port3=main.ONOS3_port,
200 ip4=main.ONOS4_ip,
201 port4=main.ONOS4_port,
202 ip5=main.ONOS5_ip,
203 port5=main.ONOS5_port )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800204
205 switch_mastership = main.TRUE
Hari Krishna22c3d412015-02-17 16:48:12 -0800206 for i in range( 1, ( main.numMNswitches + 1 ) ):
Hari Krishnad97213e2015-01-24 19:30:14 -0800207 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800208 print( "Response is " + str( response ) )
Hari Krishna22c3d412015-02-17 16:48:12 -0800209 if re.search( "tcp:" + main.ONOS1_ip, response ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800210 switch_mastership = switch_mastership and main.TRUE
211 else:
212 switch_mastership = main.FALSE
213
214 if switch_mastership == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800215 main.log.report( "Controller assignment successfull" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800216 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800217 main.log.report( "Controller assignment failed" )
Hari Krishna22c3d412015-02-17 16:48:12 -0800218 time.sleep( 15 )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800219
Hari Krishna22c3d412015-02-17 16:48:12 -0800220 #main.step( "Balance devices across controllers" )
221 #for i in range( int( main.numCtrls ) ):
222 # balanceResult = main.ONOScli1.balanceMasters()
kelvin-onlab8a832582015-01-16 17:06:11 -0800223 # giving some breathing time for ONOS to complete re-balance
Hari Krishna22c3d412015-02-17 16:48:12 -0800224 # time.sleep( 3 )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800225
Hari Krishna22c3d412015-02-17 16:48:12 -0800226 #utilities.assert_equals(
227 # expect=main.TRUE,
228 # actual=balanceResult,
229 # onpass="Assign and Balance devices test PASS",
230 #onfail="Assign and Balance devices test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800231
kelvin-onlab8a832582015-01-16 17:06:11 -0800232 def CASE3( self, main ):
233 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800234 This Test case will be extended to collect and store more data related
235 ONOS state.
kelvin-onlab8a832582015-01-16 17:06:11 -0800236 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800237 import re
238 import copy
Hari Krishna22c3d412015-02-17 16:48:12 -0800239 main.deviceDPIDs = []
240 main.hostMACs = []
241 main.deviceLinks = []
242 main.deviceActiveLinksCount = []
243 main.devicePortsEnabledCount = []
kelvin-onlab54400a92015-02-26 18:05:51 -0800244
kelvin-onlab8a832582015-01-16 17:06:11 -0800245 main.log.report(
246 "Collect and Store topology details from ONOS before running any Tests" )
247 main.log.report(
248 "____________________________________________________________________" )
249 main.case( "Collect and Store Topology Deatils from ONOS" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800250 main.step( "Collect and store current number of switches and links" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800251 topology_output = main.ONOScli1.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800252 topology_result = main.ONOSbench.getTopology( topology_output )
Hari Krishna22c3d412015-02-17 16:48:12 -0800253 numOnosDevices = topology_result[ 'devices' ]
254 numOnosLinks = topology_result[ 'links' ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800255
kelvin-onlab54400a92015-02-26 18:05:51 -0800256 if ( ( main.numMNswitches == int(numOnosDevices) ) and ( main.numMNlinks >= int(numOnosLinks) ) ):
Hari Krishna22c3d412015-02-17 16:48:12 -0800257 main.step( "Store Device DPIDs" )
258 for i in range( 1, (main.numMNswitches+1) ):
259 main.deviceDPIDs.append( "of:00000000000000" + format( i, '02x' ) )
260 print "Device DPIDs in Store: \n", str( main.deviceDPIDs )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800261
Hari Krishna22c3d412015-02-17 16:48:12 -0800262 main.step( "Store Host MACs" )
263 for i in range( 1, ( main.numMNhosts + 1 ) ):
264 main.hostMACs.append( "00:00:00:00:00:" + format( i, '02x' ) + "/-1" )
265 print "Host MACs in Store: \n", str( main.hostMACs )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800266
Hari Krishna22c3d412015-02-17 16:48:12 -0800267 main.step( "Collect and store all Devices Links" )
268 linksResult = main.ONOScli1.links( jsonFormat=False )
269 ansi_escape = re.compile( r'\x1b[^m]*m' )
270 linksResult = ansi_escape.sub( '', linksResult )
271 linksResult = linksResult.replace( " links", "" ).replace( "\r\r", "" )
272 linksResult = linksResult.splitlines()
273 linksResult = linksResult[ 1: ]
274 main.deviceLinks = copy.copy( linksResult )
275 print "Device Links Stored: \n", str( main.deviceLinks )
276 # this will be asserted to check with the params provided count of
277 # links
278 print "Length of Links Store", len( main.deviceLinks )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800279
Hari Krishna22c3d412015-02-17 16:48:12 -0800280 main.step( "Collect and store each Device ports enabled Count" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800281
282 CLI1 = (main.ONOScli1)
283 CLI2 = (main.ONOScli2)
284 CLI3 = (main.ONOScli3)
285 CLI4 = (main.ONOScli4)
286 CLI5 = (main.ONOScli5)
287 ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5]
288 time1 = time.time()
289
290 for i in xrange(1,(main.numMNswitches + 1),5):
291 pool = []
292 for cli in ONOSCLI:
293 dpid = "of:00000000000000" + format( i,'02x' )
294 t = main.Thread(target = cli.getDevicePortsEnabledCount,threadID = main.threadID, name = "getDevicePortsEnabledCount",args = [dpid])
295 t.start()
296 pool.append(t)
297 i = i + 1
298 main.threadID = main.threadID + 1
299 for thread in pool:
300 thread.join()
301 portResult = thread.result
302 portTemp = re.split( r'\t+', portResult )
303 portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
304 main.devicePortsEnabledCount.append( portCount )
Hari Krishna22c3d412015-02-17 16:48:12 -0800305 print "Device Enabled Port Counts Stored: \n", str( main.devicePortsEnabledCount )
kelvin-onlab54400a92015-02-26 18:05:51 -0800306 time2 = time.time()
307 main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1))
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800308
Hari Krishna22c3d412015-02-17 16:48:12 -0800309 main.step( "Collect and store each Device active links Count" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800310 time1 = time.time()
311
312 for i in xrange(1,(main.numMNswitches + 1),5):
313 pool = []
314 for cli in ONOSCLI:
315 dpid = "of:00000000000000" + format( i,'02x' )
316 t = main.Thread(target = cli.getDeviceLinksActiveCount,threadID = main.threadID, name = "getDevicePortsEnabledCount",args = [dpid])
317 t.start()
318 pool.append(t)
319 i = i + 1
320 main.threadID = main.threadID + 1
321 for thread in pool:
322 thread.join()
323 linkCountResult = thread.result
324 linkCountTemp = re.split( r'\t+', linkCountResult )
325 linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
326 main.deviceActiveLinksCount.append( linkCount )
327 print "Device Active Links Count Stored: \n", str( main.deviceActiveLinksCount )
328 time2 = time.time()
329 main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800330
331 else:
332 main.log.info("Devices (expected): %s, Links (expected): %s" %
333 ( str( main.numMNswitches ), str( main.numMNlinks ) ) )
334 main.log.info("Devices (actual): %s, Links (actual): %s" %
335 ( numOnosDevices , numOnosLinks ) )
336 main.log.info("Topology does not match, exiting CHO test...")
kelvin-onlab54400a92015-02-26 18:05:51 -0800337 #time.sleep(300)
338 main.cleanup()
339 main.exit()
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800340
kelvin-onlab8a832582015-01-16 17:06:11 -0800341 # just returning TRUE for now as this one just collects data
Hari Krishna22c3d412015-02-17 16:48:12 -0800342 case3Result = main.TRUE
343 utilities.assert_equals( expect=main.TRUE, actual=case3Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800344 onpass="Saving ONOS topology data test PASS",
345 onfail="Saving ONOS topology data test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800346
kelvin-onlab8a832582015-01-16 17:06:11 -0800347 def CASE4( self, main ):
348 """
349 Enable onos-app-fwd, Verify Reactive forwarding through ping all and Disable it
350 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800351 import re
352 import copy
353 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800354 main.log.report( "Enable Reactive forwarding and Verify ping all" )
355 main.log.report( "______________________________________________" )
356 main.case( "Enable Reactive forwarding and Verify ping all" )
357 main.step( "Enable Reactive forwarding" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800358 installResult = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800359 feature = "onos-app-fwd"
360 CLI1 = (main.ONOScli1.featureInstall,feature)
361 CLI2 = (main.ONOScli2.featureInstall,feature)
362 CLI3 = (main.ONOScli3.featureInstall,feature)
363 CLI4 = (main.ONOScli4.featureInstall,feature)
364 CLI5 = (main.ONOScli5.featureInstall,feature)
365 ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5]
366 pool = []
367 time1 = time.time()
368 for cli,feature in ONOSCLI:
369 t = main.Thread(target=cli,threadID=main.threadID,
370 name="featureInstall",args=[feature])
371 pool.append(t)
372 t.start()
373 main.threadID = main.threadID + 1
374
375 results = []
376 for thread in pool:
377 thread.join()
378 results.append(thread.result)
379 time2 = time.time()
380
381 if( all(result == main.TRUE for result in results) == False):
382 main.log.info("Did not install onos-app-fwd feature properly")
383 main.cleanup()
384 main.exit()
385 else:
386 main.log.info("Successful feature:install onos-app-fwd")
387 installResult = main.TRUE
388 main.log.info("Time for feature:install onos-app-fwd: %2f seconds" %(time2-time1))
389
kelvin-onlab8a832582015-01-16 17:06:11 -0800390 time.sleep( 5 )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800391
kelvin-onlab8a832582015-01-16 17:06:11 -0800392 main.step( "Verify Pingall" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800393 ping_result = main.FALSE
394 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -0800395 ping_result = main.Mininet1.pingall(timeout=main.pingTimeout)
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800396 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800397 timeDiff = round( ( time2 - time1 ), 2 )
398 main.log.report(
399 "Time taken for Ping All: " +
400 str( timeDiff ) +
401 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800402
403 if ping_result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800404 main.log.report( "Pingall Test in Reactive mode successful" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800405 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800406 main.log.report( "Pingall Test in Reactive mode failed" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800407
kelvin-onlab8a832582015-01-16 17:06:11 -0800408 main.step( "Disable Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800409 uninstallResult = main.FALSE
410 CLI1 = (main.ONOScli1.featureUninstall,"onos-app-fwd")
411 CLI2 = (main.ONOScli2.featureUninstall,"onos-app-fwd")
412 CLI3 = (main.ONOScli3.featureUninstall,"onos-app-fwd")
413 CLI4 = (main.ONOScli4.featureUninstall,"onos-app-fwd")
414 CLI5 = (main.ONOScli5.featureUninstall,"onos-app-fwd")
415 ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5]
416 pool = []
417 time1 = time.time()
418 for cli,feature in ONOSCLI:
419 t = main.Thread(target=cli,threadID=main.threadID,
420 name="featureUninstall",args=[feature])
421 pool.append(t)
422 t.start()
423 main.threadID = main.threadID + 1
424
425 results = []
426 for thread in pool:
427 thread.join()
428 results.append(thread.result)
429 time2 = time.time()
430
431 if( all(result == main.TRUE for result in results) == False):
432 main.log.info("Did not uninstall onos-app-fwd feature properly")
433 main.cleanup()
434 main.exit()
435 else:
436 main.log.info("Successful feature:uninstall onos-app-fwd")
437 uninstallResult = main.TRUE
438 main.log.info("Time for feature:uninstall onos-app-fwd: %2f seconds" %(time2-time1))
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800439
kelvin-onlab8a832582015-01-16 17:06:11 -0800440 # Waiting for reative flows to be cleared.
kelvin-onlab54400a92015-02-26 18:05:51 -0800441 time.sleep( 5 )
442 case4Result = installResult and uninstallResult and ping_result
443 utilities.assert_equals( expect=main.TRUE, actual=case4Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800444 onpass="Reactive Mode Pingall test PASS",
445 onfail="Reactive Mode Pingall test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800446
kelvin-onlab8a832582015-01-16 17:06:11 -0800447 def CASE5( self, main ):
448 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800449 Compare current ONOS topology with reference data
kelvin-onlab8a832582015-01-16 17:06:11 -0800450 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800451 import re
kelvin-onlab54400a92015-02-26 18:05:51 -0800452
Hari Krishna22c3d412015-02-17 16:48:12 -0800453 devicesDPIDTemp = []
454 hostMACsTemp = []
455 deviceLinksTemp = []
456 deviceActiveLinksCountTemp = []
457 devicePortsEnabledCountTemp = []
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800458
kelvin-onlab8a832582015-01-16 17:06:11 -0800459 main.log.report(
460 "Compare ONOS topology with reference data in Stores" )
461 main.log.report( "__________________________________________________" )
462 main.case( "Compare ONOS topology with reference data" )
463
464 main.step( "Compare current Device ports enabled with reference" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800465
466 CLI1 = (main.ONOScli1)
467 CLI2 = (main.ONOScli2)
468 CLI3 = (main.ONOScli3)
469 CLI4 = (main.ONOScli4)
470 CLI5 = (main.ONOScli5)
471 ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5]
472 time1 = time.time()
473
474 for i in xrange(1,(main.numMNswitches + 1),5):
475 pool = []
476 for cli in ONOSCLI:
477 dpid = "of:00000000000000" + format( i,'02x' )
478 t = main.Thread(target = cli.getDevicePortsEnabledCount,threadID = main.threadID, name = "getDevicePortsEnabledCount",args = [dpid])
479 t.start()
480 pool.append(t)
481 i = i + 1
482 main.threadID = main.threadID + 1
483 for thread in pool:
484 thread.join()
485 portResult = thread.result
486 portTemp = re.split( r'\t+', portResult )
487 portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
488 devicePortsEnabledCountTemp.append( portCount )
489 print "Device Enabled Port Counts Stored: \n", str( main.devicePortsEnabledCount )
490 time2 = time.time()
491 main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1))
492
493
494 """
kelvin-onlab8a832582015-01-16 17:06:11 -0800495 for i in range( 1, 26 ):
496 portResult = main.ONOScli1.getDevicePortsEnabledCount(
497 "of:00000000000000" +
498 format(
499 i,
500 '02x' ) )
501 portTemp = re.split( r'\t+', portResult )
502 portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
Hari Krishna22c3d412015-02-17 16:48:12 -0800503 devicePortsEnabledCountTemp.append( portCount )
kelvin-onlab8a832582015-01-16 17:06:11 -0800504 time.sleep( 2 )
kelvin-onlab54400a92015-02-26 18:05:51 -0800505 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800506 main.log.info (
507 "Device Enabled ports EXPECTED: %s" %
508 str( main.devicePortsEnabledCount ) )
509 main.log.info (
510 "Device Enabled ports ACTUAL: %s" %
511 str( devicePortsEnabledCountTemp ) )
kelvin-onlab54400a92015-02-26 18:05:51 -0800512
Hari Krishna22c3d412015-02-17 16:48:12 -0800513 if ( cmp( main.devicePortsEnabledCount,
514 devicePortsEnabledCountTemp ) == 0 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800515 stepResult1 = main.TRUE
516 else:
517 stepResult1 = main.FALSE
518
kelvin-onlab8a832582015-01-16 17:06:11 -0800519 main.step( "Compare Device active links with reference" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800520 time1 = time.time()
521 for i in xrange(1,(main.numMNswitches + 1),5):
522 pool = []
523 for cli in ONOSCLI:
524 dpid = "of:00000000000000" + format( i,'02x' )
525 t = main.Thread(target = cli.getDeviceLinksActiveCount,threadID = main.threadID, name = "getDevicePortsEnabledCount",args = [dpid])
526 t.start()
527 pool.append(t)
528 i = i + 1
529 main.threadID = main.threadID + 1
530 for thread in pool:
531 thread.join()
532 linkCountResult = thread.result
533 linkCountTemp = re.split( r'\t+', linkCountResult )
534 linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
535 deviceActiveLinksCountTemp.append( linkCount )
536 print "Device Active Links Count Stored: \n", str( main.deviceActiveLinksCount )
537 time2 = time.time()
538 main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800539 main.log.info (
540 "Device Active links EXPECTED: %s" %
541 str( main.deviceActiveLinksCount ) )
542 main.log.info (
543 "Device Active links ACTUAL: %s" % str( deviceActiveLinksCountTemp ) )
544 if ( cmp( main.deviceActiveLinksCount, deviceActiveLinksCountTemp ) == 0 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800545 stepResult2 = main.TRUE
546 else:
547 stepResult2 = main.FALSE
548
kelvin-onlab8a832582015-01-16 17:06:11 -0800549 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800550 place holder for comparing devices, hosts, paths and intents if required.
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800551 Links and ports data would be incorrect with out devices anyways.
kelvin-onlab8a832582015-01-16 17:06:11 -0800552 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800553 case5Result = ( stepResult1 and stepResult2 )
554 utilities.assert_equals( expect=main.TRUE, actual=case5Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800555 onpass="Compare Topology test PASS",
556 onfail="Compare Topology test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800557
kelvin-onlab8a832582015-01-16 17:06:11 -0800558 def CASE6( self ):
559 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800560 Install 300 host intents and verify ping all
kelvin-onlab8a832582015-01-16 17:06:11 -0800561 """
562 main.log.report( "Add 300 host intents and verify pingall" )
563 main.log.report( "_______________________________________" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800564 import itertools
kelvin-onlab54400a92015-02-26 18:05:51 -0800565
kelvin-onlab8a832582015-01-16 17:06:11 -0800566 main.case( "Install 300 host intents" )
567 main.step( "Add host Intents" )
568 intentResult = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800569 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
570
571 CLI1 = (main.ONOScli1.addHostIntent)
572 CLI2 = (main.ONOScli2.addHostIntent)
573 CLI3 = (main.ONOScli3.addHostIntent)
574 CLI4 = (main.ONOScli4.addHostIntent)
575 CLI5 = (main.ONOScli5.addHostIntent)
576 ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5]
577 results = main.TRUE
578 intentIdList = []
579 time1 = time.time()
580 for i in xrange(0,len(hostCombos),5):
581 pool = []
582 for cli in ONOSCLI:
583 if i >= len(hostCombos):
584 break
585 t = main.Thread(target=cli,threadID=main.threadID,
586 name="addHostIntent",
587 args=[hostCombos[i][0],hostCombos[i][1]])
588 pool.append(t)
589 t.start()
590 i = i + 1
591 main.threadID = main.threadID + 1
592 for thread in pool:
593 thread.join()
594 intentIdList.append(thread.result)
595 time2 = time.time()
596 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
597 intentResult = main.TRUE
598 intentsJson = main.ONOScli2.intents()
599 getIntentResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
600 intentsJson = intentsJson)
601 print getIntentResult
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800602
kelvin-onlab8a832582015-01-16 17:06:11 -0800603 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800604 pingResult = main.FALSE
605 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -0800606 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800607 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800608 timeDiff = round( ( time2 - time1 ), 2 )
609 main.log.report(
610 "Time taken for Ping All: " +
611 str( timeDiff ) +
612 " seconds" )
613 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
614 onpass="PING ALL PASS",
615 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800616
kelvin-onlab8a832582015-01-16 17:06:11 -0800617 case4Result = ( intentResult and pingResult )
kelvin-onlab54400a92015-02-26 18:05:51 -0800618
Hari Krishna46997e02015-01-27 11:23:07 -0800619 #case4Result = pingResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800620 utilities.assert_equals(
621 expect=main.TRUE,
622 actual=case4Result,
623 onpass="Install 300 Host Intents and Ping All test PASS",
624 onfail="Install 300 Host Intents and Ping All test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800625
kelvin-onlab8a832582015-01-16 17:06:11 -0800626 def CASE70( self, main ):
627 """
628 Randomly bring some core links down and verify ping all ( Host Intents Scenario )
629 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800630 import random
Hari Krishna22c3d412015-02-17 16:48:12 -0800631 main.randomLink1 = []
632 main.randomLink2 = []
633 main.randomLink3 = []
kelvin-onlab8a832582015-01-16 17:06:11 -0800634 link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
635 link1End2 = main.params[ 'CORELINKS' ][ 'linkS3b' ].split( ',' )
636 link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
637 link2End2 = main.params[ 'CORELINKS' ][ 'linkS14b' ].split( ',' )
638 link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
639 link3End2 = main.params[ 'CORELINKS' ][ 'linkS18b' ].split( ',' )
640 switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
641 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800642
Hari Krishnad97213e2015-01-24 19:30:14 -0800643 main.log.report( "Host intents - Randomly bring some core links down and verify ping all" )
644 main.log.report( "_________________________________________________________________" )
645 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
646 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800647 if ( int( switchLinksToToggle ) ==
648 0 or int( switchLinksToToggle ) > 5 ):
Hari Krishna46997e02015-01-27 11:23:07 -0800649 main.log.info( "Please check your PARAMS file. Valid range for number of switch links to toggle is between 1 to 5" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800650 main.cleanup()
651 main.exit()
652 else:
Hari Krishnad97213e2015-01-24 19:30:14 -0800653 main.log.info( "User provided Core switch links range to toggle is correct, proceeding to run the test" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800654
kelvin-onlab8a832582015-01-16 17:06:11 -0800655 main.step( "Cut links on Core devices using user provided range" )
Hari Krishna22c3d412015-02-17 16:48:12 -0800656 main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
657 main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
658 main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800659 for i in range( int( switchLinksToToggle ) ):
660 main.Mininet1.link(
661 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800662 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800663 OPTION="down" )
664 main.Mininet1.link(
665 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800666 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800667 OPTION="down" )
668 main.Mininet1.link(
669 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800670 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800671 OPTION="down" )
672 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800673
674 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800675 linkDown = main.ONOSbench.checkStatus(
Hari Krishna22c3d412015-02-17 16:48:12 -0800676 topology_output, main.numMNswitches, str(
677 int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800678 utilities.assert_equals(
679 expect=main.TRUE,
680 actual=linkDown,
681 onpass="Link Down discovered properly",
682 onfail="Link down was not discovered in " +
683 str( link_sleep ) +
684 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800685
kelvin-onlab8a832582015-01-16 17:06:11 -0800686 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800687 pingResultLinkDown = main.FALSE
688 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -0800689 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout)
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800690 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800691 timeDiff = round( ( time2 - time1 ), 2 )
692 main.log.report(
693 "Time taken for Ping All: " +
694 str( timeDiff ) +
695 " seconds" )
696 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
697 onpass="PING ALL PASS",
698 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800699
Hari Krishna22c3d412015-02-17 16:48:12 -0800700 caseResult70 = linkDown and pingResultLinkDown
701 utilities.assert_equals( expect=main.TRUE, actual=caseResult70,
kelvin-onlab8a832582015-01-16 17:06:11 -0800702 onpass="Random Link cut Test PASS",
703 onfail="Random Link cut Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800704
kelvin-onlab8a832582015-01-16 17:06:11 -0800705 def CASE80( self, main ):
706 """
707 Bring the core links up that are down and verify ping all ( Host Intents Scenario )
708 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800709 import random
kelvin-onlab8a832582015-01-16 17:06:11 -0800710 link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
711 link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
712 link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
713 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
714 switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800715
kelvin-onlab8a832582015-01-16 17:06:11 -0800716 main.log.report(
717 "Host intents - Bring the core links up that are down and verify ping all" )
718 main.log.report(
719 "__________________________________________________________________" )
720 main.case(
721 "Host intents - Bring the core links up that are down and verify ping all" )
722 main.step( "Bring randomly cut links on Core devices up" )
723 for i in range( int( switchLinksToToggle ) ):
724 main.Mininet1.link(
725 END1=link1End1,
kelvin-onlab54400a92015-02-26 18:05:51 -0800726 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800727 OPTION="up" )
728 main.Mininet1.link(
729 END1=link2End1,
kelvin-onlab54400a92015-02-26 18:05:51 -0800730 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800731 OPTION="up" )
732 main.Mininet1.link(
733 END1=link3End1,
kelvin-onlab54400a92015-02-26 18:05:51 -0800734 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800735 OPTION="up" )
736 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800737
738 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800739 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -0800740 topology_output,
Hari Krishna22c3d412015-02-17 16:48:12 -0800741 main.numMNswitches,
742 str( main.numMNlinks ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800743 utilities.assert_equals(
744 expect=main.TRUE,
745 actual=linkUp,
746 onpass="Link up discovered properly",
747 onfail="Link up was not discovered in " +
748 str( link_sleep ) +
749 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800750
kelvin-onlab8a832582015-01-16 17:06:11 -0800751 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800752 pingResultLinkUp = main.FALSE
753 time1 = time.time()
754 pingResultLinkUp = main.Mininet1.pingall()
755 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800756 timeDiff = round( ( time2 - time1 ), 2 )
757 main.log.report(
758 "Time taken for Ping All: " +
759 str( timeDiff ) +
760 " seconds" )
761 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
762 onpass="PING ALL PASS",
763 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800764
Hari Krishna22c3d412015-02-17 16:48:12 -0800765 caseResult80 = linkUp and pingResultLinkUp
766 utilities.assert_equals( expect=main.TRUE, actual=caseResult80,
kelvin-onlab8a832582015-01-16 17:06:11 -0800767 onpass="Link Up Test PASS",
768 onfail="Link Up Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800769
kelvin-onlab8a832582015-01-16 17:06:11 -0800770 def CASE71( self, main ):
771 """
772 Randomly bring some core links down and verify ping all ( Point Intents Scenario )
773 """
kelvin8ec71442015-01-15 16:57:00 -0800774 import random
Hari Krishna22c3d412015-02-17 16:48:12 -0800775 main.randomLink1 = []
776 main.randomLink2 = []
777 main.randomLink3 = []
kelvin-onlab8a832582015-01-16 17:06:11 -0800778 link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
779 link1End2 = main.params[ 'CORELINKS' ][ 'linkS3b' ].split( ',' )
780 link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
781 link2End2 = main.params[ 'CORELINKS' ][ 'linkS14b' ].split( ',' )
782 link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
783 link3End2 = main.params[ 'CORELINKS' ][ 'linkS18b' ].split( ',' )
784 switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
785 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin8ec71442015-01-15 16:57:00 -0800786
Hari Krishnad97213e2015-01-24 19:30:14 -0800787 main.log.report( "Point Intents - Randomly bring some core links down and verify ping all" )
788 main.log.report( "__________________________________________________________________" )
789 main.case( "Point Intents - Randomly bring some core links down and verify ping all" )
790 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800791 if ( int( switchLinksToToggle ) ==
792 0 or int( switchLinksToToggle ) > 5 ):
793 main.log.info(
794 "Please check you PARAMS file. Valid range for number of switch links to toggle is between 1 to 5" )
kelvin8ec71442015-01-15 16:57:00 -0800795 main.cleanup()
796 main.exit()
797 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800798 main.log.info(
799 "User provided Core switch links range to toggle is correct, proceeding to run the test" )
kelvin8ec71442015-01-15 16:57:00 -0800800
kelvin-onlab8a832582015-01-16 17:06:11 -0800801 main.step( "Cut links on Core devices using user provided range" )
802 randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
803 randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
804 randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
805 for i in range( int( switchLinksToToggle ) ):
806 main.Mininet1.link(
807 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800808 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800809 OPTION="down" )
810 main.Mininet1.link(
811 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800812 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800813 OPTION="down" )
814 main.Mininet1.link(
815 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800816 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800817 OPTION="down" )
818 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -0800819
820 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800821 linkDown = main.ONOSbench.checkStatus(
Hari Krishna22c3d412015-02-17 16:48:12 -0800822 topology_output, main.numSwitches, str(
823 int( main.numLinks ) - int( switchLinksToToggle ) * 6 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800824 utilities.assert_equals(
825 expect=main.TRUE,
826 actual=linkDown,
827 onpass="Link Down discovered properly",
828 onfail="Link down was not discovered in " +
829 str( link_sleep ) +
830 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -0800831
kelvin-onlab8a832582015-01-16 17:06:11 -0800832 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -0800833 pingResultLinkDown = main.FALSE
834 time1 = time.time()
835 pingResultLinkDown = main.Mininet1.pingall()
836 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800837 timeDiff = round( ( time2 - time1 ), 2 )
838 main.log.report(
839 "Time taken for Ping All: " +
840 str( timeDiff ) +
841 " seconds" )
842 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
843 onpass="PING ALL PASS",
844 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -0800845
846 caseResult7 = linkDown and pingResultLinkDown
kelvin-onlab8a832582015-01-16 17:06:11 -0800847 utilities.assert_equals( expect=main.TRUE, actual=caseResult7,
848 onpass="Random Link cut Test PASS",
849 onfail="Random Link cut Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -0800850
kelvin-onlab8a832582015-01-16 17:06:11 -0800851 def CASE81( self, main ):
852 """
853 Bring the core links up that are down and verify ping all ( Point Intents Scenario )
854 """
kelvin8ec71442015-01-15 16:57:00 -0800855 import random
kelvin-onlab8a832582015-01-16 17:06:11 -0800856 link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
857 link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
858 link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
859 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
860 switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
kelvin8ec71442015-01-15 16:57:00 -0800861
kelvin-onlab8a832582015-01-16 17:06:11 -0800862 main.log.report(
863 "Point intents - Bring the core links up that are down and verify ping all" )
864 main.log.report(
865 "___________________________________________________________________" )
866 main.case(
867 "Point intents - Bring the core links up that are down and verify ping all" )
868 main.step( "Bring randomly cut links on Core devices up" )
869 for i in range( int( switchLinksToToggle ) ):
870 main.Mininet1.link(
871 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800872 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800873 OPTION="up" )
874 main.Mininet1.link(
875 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800876 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800877 OPTION="up" )
878 main.Mininet1.link(
879 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800880 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800881 OPTION="up" )
882 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -0800883
884 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800885 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -0800886 topology_output,
Hari Krishna22c3d412015-02-17 16:48:12 -0800887 main.numMNswitches,
888 str( main.numMNlinks ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800889 utilities.assert_equals(
890 expect=main.TRUE,
891 actual=linkUp,
892 onpass="Link up discovered properly",
893 onfail="Link up was not discovered in " +
894 str( link_sleep ) +
895 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -0800896
kelvin-onlab8a832582015-01-16 17:06:11 -0800897 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -0800898 pingResultLinkUp = main.FALSE
899 time1 = time.time()
900 pingResultLinkUp = main.Mininet1.pingall()
901 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800902 timeDiff = round( ( time2 - time1 ), 2 )
903 main.log.report(
904 "Time taken for Ping All: " +
905 str( timeDiff ) +
906 " seconds" )
907 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
908 onpass="PING ALL PASS",
909 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -0800910
Hari Krishna22c3d412015-02-17 16:48:12 -0800911 caseResult81 = linkUp and pingResultLinkUp
912 utilities.assert_equals( expect=main.TRUE, actual=caseResult81,
kelvin-onlab8a832582015-01-16 17:06:11 -0800913 onpass="Link Up Test PASS",
914 onfail="Link Up Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -0800915
kelvin-onlab8a832582015-01-16 17:06:11 -0800916 def CASE9( self ):
917 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800918 Install 114 point intents and verify Ping all works
kelvin-onlab8a832582015-01-16 17:06:11 -0800919 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800920 import copy
kelvin-onlab8a832582015-01-16 17:06:11 -0800921 main.log.report( "Install 114 point intents and verify Ping all" )
922 main.log.report( "___________________________________________" )
923 main.case( "Install 114 point intents and Ping all" )
Hari Krishna22c3d412015-02-17 16:48:12 -0800924 deviceLinksCopy = copy.copy( main.deviceLinks )
kelvin-onlab8a832582015-01-16 17:06:11 -0800925 main.step( "Install 114 point intents" )
Hari Krishna22c3d412015-02-17 16:48:12 -0800926 for i in range( len( deviceLinksCopy ) ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800927 pointLink = str(
Hari Krishna22c3d412015-02-17 16:48:12 -0800928 deviceLinksCopy[ i ] ).replace(
kelvin-onlab8a832582015-01-16 17:06:11 -0800929 "src=",
930 "" ).replace(
931 "dst=",
932 "" ).split( ',' )
933 point1 = pointLink[ 0 ].split( '/' )
934 point2 = pointLink[ 1 ].split( '/' )
Hari Krishnad97213e2015-01-24 19:30:14 -0800935 installResult = main.ONOScli1.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -0800936 point1[ 0 ], point2[ 0 ], int(
937 point1[ 1 ] ), int(
938 point2[ 1 ] ) )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800939 if installResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800940 print "Installed Point intent between :", point1[ 0 ], int( point1[ 1 ] ), point2[ 0 ], int( point2[ 1 ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800941
kelvin-onlab8a832582015-01-16 17:06:11 -0800942 main.step( "Obtain the intent id's" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800943 intentsList = main.ONOScli1.getAllIntentIds()
kelvin-onlab8a832582015-01-16 17:06:11 -0800944 ansi_escape = re.compile( r'\x1b[^m]*m' )
945 intentsList = ansi_escape.sub( '', intentsList )
946 intentsList = intentsList.replace(
947 " onos:intents | grep id=",
948 "" ).replace(
949 "id=",
950 "" ).replace(
951 "\r\r",
952 "" )
953 intentsList = intentsList.splitlines()
954 intentsList = intentsList[ 1: ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800955 intentIdList = []
kelvin-onlab8a832582015-01-16 17:06:11 -0800956 for i in range( len( intentsList ) ):
957 intentsTemp = intentsList[ i ].split( ',' )
958 intentIdList.append( intentsTemp[ 0 ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800959 print "Intent IDs: ", intentIdList
kelvin-onlab8a832582015-01-16 17:06:11 -0800960 print "Total Intents installed: ", len( intentIdList )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800961
kelvin-onlab8a832582015-01-16 17:06:11 -0800962 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800963 pingResult = main.FALSE
964 time1 = time.time()
965 pingResult = main.Mininet1.pingall()
966 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800967 timeDiff = round( ( time2 - time1 ), 2 )
968 main.log.report(
969 "Time taken for Ping All: " +
970 str( timeDiff ) +
971 " seconds" )
972 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
973 onpass="PING ALL PASS",
974 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800975
976 case8_result = installResult and pingResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800977 utilities.assert_equals(
978 expect=main.TRUE,
979 actual=case8_result,
980 onpass="Ping all test after Point intents addition successful",
981 onfail="Ping all test after Point intents addition failed" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800982
kelvin-onlab8a832582015-01-16 17:06:11 -0800983 def CASE10( self ):
984 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800985 Remove all Intents
kelvin-onlab8a832582015-01-16 17:06:11 -0800986 """
987 main.log.report( "Remove all intents that were installed previously" )
988 main.log.report( "______________________________________________" )
989 main.log.info( "Remove all intents" )
990 main.case( "Removing intents" )
991 main.step( "Obtain the intent id's first" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800992 intentsList = main.ONOScli1.getAllIntentIds()
kelvin-onlab8a832582015-01-16 17:06:11 -0800993 ansi_escape = re.compile( r'\x1b[^m]*m' )
994 intentsList = ansi_escape.sub( '', intentsList )
995 intentsList = intentsList.replace(
996 " onos:intents | grep id=",
997 "" ).replace(
998 "id=",
999 "" ).replace(
1000 "\r\r",
1001 "" )
1002 intentsList = intentsList.splitlines()
1003 intentsList = intentsList[ 1: ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001004 intentIdList = []
1005 step1Result = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001006 if ( len( intentsList ) > 1 ):
1007 for i in range( len( intentsList ) ):
1008 intentsTemp = intentsList[ i ].split( ',' )
1009 intentIdList.append( intentsTemp[ 0 ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001010 print "Intent IDs: ", intentIdList
kelvin-onlab54400a92015-02-26 18:05:51 -08001011
1012
1013 CLI1 = (main.ONOScli1.removeIntent)
1014 CLI2 = (main.ONOScli2.removeIntent)
1015 CLI3 = (main.ONOScli3.removeIntent)
1016 CLI4 = (main.ONOScli4.removeIntent)
1017 CLI5 = (main.ONOScli5.removeIntent)
1018 ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5]
1019 results = main.TRUE
1020 time1 = time.time()
1021
1022 for i in xrange(0,len(intentIdList),5):
1023 pool = []
1024 for cli in ONOSCLI:
1025 if i >= len(intentIdList):
1026 break
1027 print "Removing intent id (round 1) :", intentIdList[ i ]
1028 t = main.Thread(target=cli,threadID=main.threadID,
1029 name="removeIntent",
kelvin-onlabfd3d76e2015-02-27 11:23:21 -08001030 args=[intentIdList[i],'org.onosproject.cli',False,True])
kelvin-onlab54400a92015-02-26 18:05:51 -08001031 pool.append(t)
1032 t.start()
1033 i = i + 1
1034 main.threadID = main.threadID + 1
1035
1036 for thread in pool:
1037 thread.join()
1038 results = results and thread.result
1039
1040 time2 = time.time()
1041 main.log.info("Time for feature:install onos-app-fwd: %2f seconds" %(time2-time1))
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001042
kelvin-onlab8a832582015-01-16 17:06:11 -08001043 main.log.info(
1044 "Verify all intents are removed and if any leftovers try remove one more time" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001045 intentsList1 = main.ONOScli1.getAllIntentIds()
kelvin-onlab8a832582015-01-16 17:06:11 -08001046 ansi_escape = re.compile( r'\x1b[^m]*m' )
1047 intentsList1 = ansi_escape.sub( '', intentsList1 )
1048 intentsList1 = intentsList1.replace(
1049 " onos:intents | grep id=",
1050 "" ).replace(
1051 " state=",
1052 "" ).replace(
1053 "\r\r",
1054 "" )
1055 intentsList1 = intentsList1.splitlines()
1056 intentsList1 = intentsList1[ 1: ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001057 print "Round 2 (leftover) intents to remove: ", intentsList1
1058 intentIdList1 = []
kelvin-onlab8a832582015-01-16 17:06:11 -08001059 if ( len( intentsList1 ) > 1 ):
1060 for i in range( len( intentsList1 ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001061 intentsTemp1 = intentsList1[ i ].split( ',' )
kelvin-onlabf9c71282015-02-27 10:41:41 -08001062 intentIdList1.append( intentsTemp1[ 0 ].split('=')[1] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001063 print "Leftover Intent IDs: ", intentIdList1
kelvin-onlabf9c71282015-02-27 10:41:41 -08001064
kelvin-onlab54400a92015-02-26 18:05:51 -08001065 for i in xrange(0,len(intentIdList1),5):
1066 pool = []
1067 for cli in ONOSCLI:
kelvin-onlabfd3d76e2015-02-27 11:23:21 -08001068 if i >= len(intentIdList1):
kelvin-onlab54400a92015-02-26 18:05:51 -08001069 break
1070 print "Removing intent id (round 2) :", intentIdList1[ i ]
1071 t = main.Thread(target=cli,threadID=main.threadID,
1072 name="removeIntent",
kelvin-onlabfd3d76e2015-02-27 11:23:21 -08001073 args=[intentIdList1[i],'org.onosproject.cli',False,True])
kelvin-onlab54400a92015-02-26 18:05:51 -08001074 pool.append(t)
1075 t.start()
1076 i = i + 1
1077 main.threadID = main.threadID + 1
1078
1079 for thread in pool:
1080 thread.join()
1081 results = results and thread.result
1082 step1Result = results
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001083 else:
1084 print "There are no more intents that need to be removed"
1085 step1Result = main.TRUE
1086 else:
1087 print "No Intent IDs found in Intents list: ", intentsList
1088 step1Result = main.FALSE
1089
1090 caseResult7 = step1Result
kelvin-onlab8a832582015-01-16 17:06:11 -08001091 utilities.assert_equals( expect=main.TRUE, actual=caseResult7,
1092 onpass="Intent removal test successful",
1093 onfail="Intent removal test failed" )
Hari Krishna22c3d412015-02-17 16:48:12 -08001094
1095 def CASE11( self, main ):
1096 """
1097 Enable onos-app-ifwd, Verify Intent based Reactive forwarding through ping all and Disable it
1098 """
1099 import re
1100 import copy
1101 import time
1102
kelvin-onlab54400a92015-02-26 18:05:51 -08001103 Thread = imp.load_source('Thread','/home/admin/ONLabTest/TestON/tests/OnosCHO/Thread.py')
1104 threadID = 0
1105
Hari Krishna22c3d412015-02-17 16:48:12 -08001106 main.log.report( "Enable Intent based Reactive forwarding and Verify ping all" )
1107 main.log.report( "_____________________________________________________" )
1108 main.case( "Enable Intent based Reactive forwarding and Verify ping all" )
1109 main.step( "Enable intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001110 installResult = main.FALSE
1111 feature = "onos-app-ifwd"
1112 CLI1 = (main.ONOScli1.featureInstall,feature)
1113 CLI2 = (main.ONOScli2.featureInstall,feature)
1114 CLI3 = (main.ONOScli3.featureInstall,feature)
1115 CLI4 = (main.ONOScli4.featureInstall,feature)
1116 CLI5 = (main.ONOScli5.featureInstall,feature)
1117 ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5]
1118 pool = []
1119 time1 = time.time()
1120 for cli,feature in ONOSCLI:
1121 t = main.Thread(target=cli,threadID=threadID,
1122 name="featureInstall",args=[feature])
1123 pool.append(t)
1124 t.start()
1125 threadID = threadID + 1
1126
1127 results = []
1128 for thread in pool:
1129 thread.join()
1130 results.append(thread.result)
1131 time2 = time.time()
1132
1133 if( all(result == main.TRUE for result in results) == False):
1134 main.log.info("Did not install onos-app-ifwd feature properly")
1135 main.cleanup()
1136 main.exit()
1137 else:
1138 main.log.info("Successful feature:install onos-app-ifwd")
1139 installResult = main.TRUE
1140 main.log.info("Time for feature:install onos-app-ifwd: %2f seconds" %(time2-time1))
1141
Hari Krishna22c3d412015-02-17 16:48:12 -08001142 main.step( "Verify Pingall" )
1143 ping_result = main.FALSE
1144 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -08001145 ping_result = main.Mininet1.pingall(timeout=600)
Hari Krishna22c3d412015-02-17 16:48:12 -08001146 time2 = time.time()
1147 timeDiff = round( ( time2 - time1 ), 2 )
1148 main.log.report(
1149 "Time taken for Ping All: " +
1150 str( timeDiff ) +
1151 " seconds" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001152
Hari Krishna22c3d412015-02-17 16:48:12 -08001153 if ping_result == main.TRUE:
1154 main.log.report( "Pingall Test in Reactive mode successful" )
1155 else:
1156 main.log.report( "Pingall Test in Reactive mode failed" )
1157
1158 main.step( "Disable Intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001159 uninstallResult = main.FALSE
1160
1161 CLI1 = (main.ONOScli1.featureUninstall,feature)
1162 CLI2 = (main.ONOScli2.featureUninstall,feature)
1163 CLI3 = (main.ONOScli3.featureUninstall,feature)
1164 CLI4 = (main.ONOScli4.featureUninstall,feature)
1165 CLI5 = (main.ONOScli5.featureUninstall,feature)
1166 ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5]
1167 pool = []
1168 time1 = time.time()
1169 for cli,feature in ONOSCLI:
1170 t = main.Thread(target=cli,threadID=threadID,
1171 name="featureUninstall",args=[feature])
1172 pool.append(t)
1173 t.start()
1174 threadID = threadID + 1
1175
1176 results = []
1177 for thread in pool:
1178 thread.join()
1179 results.append(thread.result)
1180 time2 = time.time()
1181
1182 if( all(result == main.TRUE for result in results) == False):
1183 main.log.info("Did not uninstall onos-app-ifwd feature properly")
1184 main.cleanup()
1185 main.exit()
1186 else:
1187 main.log.info("Successful feature:uninstall onos-app-ifwd")
1188 uninstallResult = main.TRUE
1189 main.log.info("Time for feature:uninstall onos-app-ifwd: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -08001190
1191 # Waiting for reative flows to be cleared.
1192 time.sleep( 10 )
1193
1194 case11Result = installResult and ping_result and uninstallResult
1195 utilities.assert_equals( expect=main.TRUE, actual=case11Result,
1196 onpass="Intent based Reactive forwarding Pingall test PASS",
1197 onfail="Intent based Reactive forwarding Pingall test FAIL" )
1198
1199 def CASE12( self, main ):
1200 """
1201 This test script Loads a new Topology (Chordal) on CHO setup and balances all switches
1202 """
1203 import re
1204 import time
1205 import copy
kelvin-onlab54400a92015-02-26 18:05:51 -08001206
Hari Krishna22c3d412015-02-17 16:48:12 -08001207
kelvin-onlab54400a92015-02-26 18:05:51 -08001208 Thread = imp.load_source('Thread','/home/admin/ONLabTest/TestON/tests/OnosCHO/Thread.py')
Hari Krishna22c3d412015-02-17 16:48:12 -08001209 newTopo = main.params['TOPO2']['topo']
1210 main.numMNswitches = int ( main.params[ 'TOPO2' ][ 'numSwitches' ] )
1211 main.numMNlinks = int ( main.params[ 'TOPO2' ][ 'numLinks' ] )
1212 main.numMNhosts = int ( main.params[ 'TOPO2' ][ 'numHosts' ] )
kelvin-onlab54400a92015-02-26 18:05:51 -08001213 main.pingTimeout = 60
Hari Krishna22c3d412015-02-17 16:48:12 -08001214 main.log.report(
1215 "Load Chordal topology and Balance all Mininet switches across controllers" )
1216 main.log.report(
1217 "________________________________________________________________________" )
1218 # need to wait here for sometime until ONOS bootup
1219 time.sleep( 15 )
1220 main.case(
1221 "Assign and Balance all Mininet switches across controllers" )
1222 main.step( "Stop any previous Mininet network topology" )
1223 stopStatus = main.Mininet1.stopNet()
1224
1225 # WORK AROUND FOR ONOS-581. STOP ONOS BEFORE ASSIGNING CONTROLLERS AT MININET & START ONCE DONE
1226 main.step( "Stop ONOS on all Nodes" )
1227 stopResult = main.TRUE
1228 for i in range( 1, int( main.numCtrls ) + 1 ):
1229 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
1230 main.log.info( "Stopping ONOS Node IP: " + ONOS_ip )
1231 sresult = main.ONOSbench.onosStop( ONOS_ip )
1232 utilities.assert_equals( expect=main.TRUE, actual=sresult,
1233 onpass="Test step PASS",
1234 onfail="Test step FAIL" )
1235 stopResult = ( stopResult and sresult )
1236
1237 main.step( "Start Mininet with Chordal topology" )
1238 startStatus = main.Mininet1.startNet(topoFile = newTopo)
1239
1240 main.step( "Assign switches to controllers" )
1241 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
1242 main.Mininet1.assignSwController(
1243 sw=str( i ),
1244 count=int( main.numCtrls ),
1245 ip1=main.ONOS1_ip,
1246 port1=main.ONOS1_port,
1247 ip2=main.ONOS2_ip,
1248 port2=main.ONOS2_port,
1249 ip3=main.ONOS3_ip,
1250 port3=main.ONOS3_port,
1251 ip4=main.ONOS4_ip,
1252 port4=main.ONOS4_port,
1253 ip5=main.ONOS5_ip,
1254 port5=main.ONOS5_port )
1255
1256 switch_mastership = main.TRUE
1257 for i in range( 1, ( main.numMNswitches + 1 ) ):
1258 response = main.Mininet1.getSwController( "s" + str( i ) )
1259 print( "Response is " + str( response ) )
1260 if re.search( "tcp:" + main.ONOS1_ip, response ):
1261 switch_mastership = switch_mastership and main.TRUE
1262 else:
1263 switch_mastership = main.FALSE
1264
1265 if switch_mastership == main.TRUE:
1266 main.log.report( "Controller assignment successfull" )
1267 else:
1268 main.log.report( "Controller assignment failed" )
1269 time.sleep( 5 )
1270
1271 main.step( "Start ONOS on all Nodes" )
1272 startResult = main.TRUE
1273 for i in range( 1, int( main.numCtrls ) + 1 ):
1274 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
1275 main.log.info( "Starting ONOS Node IP: " + ONOS_ip )
1276 sresult = main.ONOSbench.onosStart( ONOS_ip )
1277 utilities.assert_equals( expect=main.TRUE, actual=sresult,
1278 onpass="Test step PASS",
1279 onfail="Test step FAIL" )
1280 startResult = ( startResult and sresult )
1281
1282 main.step( "Start ONOS CLI on all nodes" )
1283 cliResult = main.TRUE
1284 #karafTimeout = "3600000" # This is not needed here as it is already set before.
1285 # need to wait here sometime for ONOS to bootup.
1286 time.sleep( 30 )
kelvin-onlab54400a92015-02-26 18:05:51 -08001287
1288 main.log.step(" Start ONOS cli using thread ")
1289
1290 CLI1 = (main.ONOScli1.startOnosCli,main.ONOS1_ip)
1291 CLI2 = (main.ONOScli2.startOnosCli,main.ONOS2_ip)
1292 CLI3 = (main.ONOScli3.startOnosCli,main.ONOS3_ip)
1293 CLI4 = (main.ONOScli4.startOnosCli,main.ONOS4_ip)
1294 CLI5 = (main.ONOScli5.startOnosCli,main.ONOS5_ip)
1295 ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5]
1296 pool = []
1297 time1 = time.time()
1298 for cli,ip in ONOSCLI:
1299 t = main.Thread(target=cli,threadID=main.threadID,
1300 name="startOnosCli",args=[ip])
1301 pool.append(t)
1302 t.start()
1303 main.threadID = main.threadID + 1
1304
1305 cliResult = main.FALSE
1306 results = []
1307 for thread in pool:
1308 thread.join()
1309 results.append(thread.result)
1310 time2 = time.time()
1311
1312 if( all(result == main.TRUE for result in results) == False):
1313 main.log.info("ONOS CLI did not start up properly")
1314 main.cleanup()
1315 main.exit()
1316 else:
1317 main.log.info("Successful CLI startup")
1318 cliResult = main.TRUE
1319 main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -08001320
1321 main.step( "Balance devices across controllers" )
1322 for i in range( int( main.numCtrls ) ):
1323 balanceResult = main.ONOScli1.balanceMasters()
1324 # giving some breathing time for ONOS to complete re-balance
1325 time.sleep( 3 )
1326
1327 case12Result = ( startResult and cliResult )
1328 utilities.assert_equals(
1329 expect=main.TRUE,
1330 actual=case12Result,
1331 onpass="Starting new Chordal topology test PASS",
1332 onfail="Starting new Chordal topology test FAIL" )
1333
1334 def CASE13( self, main ):
1335 """
1336 This test script Loads a new Topology (Spine) on CHO setup and balances all switches
1337 """
1338 import re
1339 import time
1340 import copy
1341
1342 newTopo = main.params['TOPO3']['topo']
1343 main.numMNswitches = int ( main.params[ 'TOPO3' ][ 'numSwitches' ] )
1344 main.numMNlinks = int ( main.params[ 'TOPO3' ][ 'numLinks' ] )
1345 main.numMNhosts = int ( main.params[ 'TOPO3' ][ 'numHosts' ] )
kelvin-onlab54400a92015-02-26 18:05:51 -08001346 main.pingTimeout = 600
Hari Krishna22c3d412015-02-17 16:48:12 -08001347 main.log.report(
1348 "Load Spine and Leaf topology and Balance all Mininet switches across controllers" )
1349 main.log.report(
1350 "________________________________________________________________________" )
1351 # need to wait here for sometime until ONOS bootup
1352 time.sleep( 15 )
1353 main.case(
1354 "Assign and Balance all Mininet switches across controllers" )
1355 main.step( "Stop any previous Mininet network topology" )
1356 stopStatus = main.Mininet1.stopNet()
1357
1358 # WORK AROUND FOR ONOS-581. STOP ONOS BEFORE ASSIGNING CONTROLLERS AT MININET & START ONCE DONE
1359 main.step( "Stop ONOS on all Nodes" )
1360 stopResult = main.TRUE
1361 for i in range( 1, int( main.numCtrls ) + 1 ):
1362 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
1363 main.log.info( "Stopping ONOS Node IP: " + ONOS_ip )
1364 sresult = main.ONOSbench.onosStop( ONOS_ip )
1365 utilities.assert_equals( expect=main.TRUE, actual=sresult,
1366 onpass="Test step PASS",
1367 onfail="Test step FAIL" )
1368 stopResult = ( stopResult and sresult )
1369
1370 main.step( "Start Mininet with Spine topology" )
1371 startStatus = main.Mininet1.startNet(topoFile = newTopo)
1372
1373 main.step( "Assign switches to controllers" )
1374 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
1375 main.Mininet1.assignSwController(
1376 sw=str( i ),
1377 count=int( main.numCtrls ),
1378 ip1=main.ONOS1_ip,
1379 port1=main.ONOS1_port,
1380 ip2=main.ONOS2_ip,
1381 port2=main.ONOS2_port,
1382 ip3=main.ONOS3_ip,
1383 port3=main.ONOS3_port,
1384 ip4=main.ONOS4_ip,
1385 port4=main.ONOS4_port,
1386 ip5=main.ONOS5_ip,
1387 port5=main.ONOS5_port )
1388
1389 switch_mastership = main.TRUE
1390 for i in range( 1, ( main.numMNswitches + 1 ) ):
1391 response = main.Mininet1.getSwController( "s" + str( i ) )
1392 print( "Response is " + str( response ) )
1393 if re.search( "tcp:" + main.ONOS1_ip, response ):
1394 switch_mastership = switch_mastership and main.TRUE
1395 else:
1396 switch_mastership = main.FALSE
1397
1398 if switch_mastership == main.TRUE:
1399 main.log.report( "Controller assignment successfull" )
1400 else:
1401 main.log.report( "Controller assignment failed" )
1402 time.sleep( 5 )
1403
1404 main.step( "Start ONOS on all Nodes" )
1405 startResult = main.TRUE
1406 for i in range( 1, int( main.numCtrls ) + 1 ):
1407 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
1408 main.log.info( "Starting ONOS Node IP: " + ONOS_ip )
1409 sresult = main.ONOSbench.onosStart( ONOS_ip )
1410 utilities.assert_equals( expect=main.TRUE, actual=sresult,
1411 onpass="Test step PASS",
1412 onfail="Test step FAIL" )
1413 startResult = ( startResult and sresult )
1414
1415 main.step( "Start ONOS CLI on all nodes" )
1416 cliResult = main.TRUE
1417 #karafTimeout = "3600000" # This is not needed here as it is already set before.
1418 # need to wait here sometime for ONOS to bootup.
1419 time.sleep( 30 )
kelvin-onlab54400a92015-02-26 18:05:51 -08001420
1421 main.log.step(" Start ONOS cli using thread ")
1422
1423 CLI1 = (main.ONOScli1.startOnosCli,main.ONOS1_ip)
1424 CLI2 = (main.ONOScli2.startOnosCli,main.ONOS2_ip)
1425 CLI3 = (main.ONOScli3.startOnosCli,main.ONOS3_ip)
1426 CLI4 = (main.ONOScli4.startOnosCli,main.ONOS4_ip)
1427 CLI5 = (main.ONOScli5.startOnosCli,main.ONOS5_ip)
1428 ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5]
1429 pool = []
1430 time1 = time.time()
1431 for cli,ip in ONOSCLI:
1432 t = main.Thread(target=cli,threadID=main.threadID,
1433 name="startOnosCli",args=[ip])
1434 pool.append(t)
1435 t.start()
1436 main.threadID = main.threadID + 1
1437
1438 cliResult = main.FALSE
1439 results = []
1440 for thread in pool:
1441 thread.join()
1442 results.append(thread.result)
1443 time2 = time.time()
1444
1445 if( all(result == main.TRUE for result in results) == False):
1446 main.log.info("ONOS CLI did not start up properly")
1447 main.cleanup()
1448 main.exit()
1449 else:
1450 main.log.info("Successful CLI startup")
1451 cliResult = main.TRUE
1452 main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
1453
1454 main.step( "Balance devices across controllers" )
1455 for i in range( int( main.numCtrls ) ):
1456 balanceResult = main.ONOScli1.balanceMasters()
1457 # giving some breathing time for ONOS to complete re-balance
1458 time.sleep( 3 )
Hari Krishna22c3d412015-02-17 16:48:12 -08001459
1460 main.step( "Balance devices across controllers" )
1461 for i in range( int( main.numCtrls ) ):
1462 balanceResult = main.ONOScli1.balanceMasters()
1463 # giving some breathing time for ONOS to complete re-balance
1464 time.sleep( 3 )
1465
1466 case13Result = ( startResult and cliResult )
1467 utilities.assert_equals(
1468 expect=main.TRUE,
1469 actual=case13Result,
1470 onpass="Starting new Spine topology test PASS",
1471 onfail="Starting new Spine topology test FAIL" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001472
1473 def CASE14(self,main):
1474 """
1475 Install 300 host intents and verify ping all
1476 """
1477 main.log.report( "Add 300 host intents and verify pingall" )
1478 main.log.report( "_______________________________________" )
1479 import itertools
1480
1481 main.case( "Install 300 host intents" )
1482 main.step( "Add host Intents" )
1483 intentResult = main.TRUE
1484 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
1485
1486 CLI1 = (main.ONOScli1.addHostIntent)
1487 CLI2 = (main.ONOScli2.addHostIntent)
1488 CLI3 = (main.ONOScli3.addHostIntent)
1489 CLI4 = (main.ONOScli4.addHostIntent)
1490 CLI5 = (main.ONOScli5.addHostIntent)
1491 ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5]
1492 results = main.TRUE
1493 time1 = time.time()
1494 for i in xrange(0,len(hostCombos),5):
1495 pool = []
1496 for cli in ONOSCLI:
1497 if i >= len(hostCombos):
1498 break
1499 t = main.Thread(target=cli,threadID=main.threadID,
1500 name="addHostIntent",
1501 args=[hostCombos[i][0],hostCombos[i][1]])
1502 pool.append(t)
1503 t.start()
1504 i = i + 1
1505 main.threadID = main.threadID + 1
1506
1507 for thread in pool:
1508 thread.join()
1509 results = results and thread.result
1510
1511 time2 = time.time()
1512
1513 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
1514 intentResult = results
1515 """
1516 for i in range( len( hostCombos ) ):
1517 iResult = main.ONOScli1.addHostIntent(
1518 hostCombos[ i ][ 0 ],
1519 hostCombos[ i ][ 1 ] )
1520 intentResult = ( intentResult and iResult )
1521 """
1522
1523 main.step( "Verify Ping across all hosts" )
1524 pingResult = main.FALSE
1525 time1 = time.time()
1526 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
1527 time2 = time.time()
1528 timeDiff = round( ( time2 - time1 ), 2 )
1529 main.log.report(
1530 "Time taken for Ping All: " +
1531 str( timeDiff ) +
1532 " seconds" )
1533 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1534 onpass="PING ALL PASS",
1535 onfail="PING ALL FAIL" )
1536
1537 case4Result = ( intentResult and pingResult )
1538
1539 #case4Result = pingResult
1540 utilities.assert_equals(
1541 expect=main.TRUE,
1542 actual=case4Result,
1543 onpass="Install 300 Host Intents and Ping All test PASS",
1544 onfail="Install 300 Host Intents and Ping All test FAIL" )
1545
1546 def CASE15( self,main):
1547 """
1548 Install 300 host intents and verify ping all
1549 """
1550 main.log.report( "Add 300 host intents and verify pingall" )
1551 main.log.report( "_______________________________________" )
1552 import itertools
1553
1554 main.case( "Install 300 host intents" )
1555 main.step( "Add host Intents" )
1556 intentResult = main.TRUE
1557 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
1558
1559 CLI1 = (main.ONOScli1.addHostIntent)
1560 CLI2 = (main.ONOScli2.addHostIntent)
1561 CLI3 = (main.ONOScli3.addHostIntent)
1562 CLI4 = (main.ONOScli4.addHostIntent)
1563 CLI5 = (main.ONOScli5.addHostIntent)
1564 ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5]
1565 results = main.TRUE
1566 time1 = time.time()
1567 for i in xrange(0,len(hostCombos),5):
1568 pool = []
1569 for cli in ONOSCLI:
1570 if i >= len(hostCombos):
1571 break
1572 t = main.Thread(target=cli,threadID=main.threadID,
1573 name="addHostIntent",
1574 args=[hostCombos[i][0],hostCombos[i][1]])
1575 pool.append(t)
1576 t.start()
1577 i = i + 1
1578 main.threadID = main.threadID + 1
1579
1580 for thread in pool:
1581 thread.join()
1582 results = results and thread.result
1583
1584 time2 = time.time()
1585
1586 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
1587 intentResult = results
1588 """
1589 for i in range( len( hostCombos ) ):
1590 iResult = main.ONOScli1.addHostIntent(
1591 hostCombos[ i ][ 0 ],
1592 hostCombos[ i ][ 1 ] )
1593 intentResult = ( intentResult and iResult )
1594 """
1595
1596 main.step( "Verify Ping across all hosts" )
1597 pingResult = main.FALSE
1598 time1 = time.time()
1599 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
1600 time2 = time.time()
1601 timeDiff = round( ( time2 - time1 ), 2 )
1602 main.log.report(
1603 "Time taken for Ping All: " +
1604 str( timeDiff ) +
1605 " seconds" )
1606 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1607 onpass="PING ALL PASS",
1608 onfail="PING ALL FAIL" )
1609
1610 case4Result = ( intentResult and pingResult )
1611
1612 #case4Result = pingResult
1613 utilities.assert_equals(
1614 expect=main.TRUE,
1615 actual=case4Result,
1616 onpass="Install 300 Host Intents and Ping All test PASS",
1617 onfail="Install 300 Host Intents and Ping All test FAIL" )