blob: eaf15a69900484a09e521a5ccf2cbd04b59e5ebd [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 ) )
kelvin-onlab54400a92015-02-26 18:05:51 -0800570 CLI1 = (main.ONOScli1.addHostIntent)
571 CLI2 = (main.ONOScli2.addHostIntent)
572 CLI3 = (main.ONOScli3.addHostIntent)
573 CLI4 = (main.ONOScli4.addHostIntent)
574 CLI5 = (main.ONOScli5.addHostIntent)
575 ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5]
576 results = main.TRUE
577 intentIdList = []
578 time1 = time.time()
579 for i in xrange(0,len(hostCombos),5):
580 pool = []
581 for cli in ONOSCLI:
582 if i >= len(hostCombos):
583 break
584 t = main.Thread(target=cli,threadID=main.threadID,
585 name="addHostIntent",
586 args=[hostCombos[i][0],hostCombos[i][1]])
587 pool.append(t)
588 t.start()
589 i = i + 1
590 main.threadID = main.threadID + 1
591 for thread in pool:
592 thread.join()
593 intentIdList.append(thread.result)
594 time2 = time.time()
595 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
596 intentResult = main.TRUE
597 intentsJson = main.ONOScli2.intents()
598 getIntentResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
599 intentsJson = intentsJson)
600 print getIntentResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800601 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800602 pingResult = main.FALSE
603 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -0800604 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800605 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800606 timeDiff = round( ( time2 - time1 ), 2 )
607 main.log.report(
608 "Time taken for Ping All: " +
609 str( timeDiff ) +
610 " seconds" )
611 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
612 onpass="PING ALL PASS",
613 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800614
kelvin-onlab8a832582015-01-16 17:06:11 -0800615 case4Result = ( intentResult and pingResult )
kelvin-onlab54400a92015-02-26 18:05:51 -0800616
Hari Krishna46997e02015-01-27 11:23:07 -0800617 #case4Result = pingResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800618 utilities.assert_equals(
619 expect=main.TRUE,
620 actual=case4Result,
621 onpass="Install 300 Host Intents and Ping All test PASS",
622 onfail="Install 300 Host Intents and Ping All test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800623
kelvin-onlab8a832582015-01-16 17:06:11 -0800624 def CASE70( self, main ):
625 """
626 Randomly bring some core links down and verify ping all ( Host Intents Scenario )
627 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800628 import random
Hari Krishna22c3d412015-02-17 16:48:12 -0800629 main.randomLink1 = []
630 main.randomLink2 = []
631 main.randomLink3 = []
kelvin-onlab8a832582015-01-16 17:06:11 -0800632 link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
633 link1End2 = main.params[ 'CORELINKS' ][ 'linkS3b' ].split( ',' )
634 link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
635 link2End2 = main.params[ 'CORELINKS' ][ 'linkS14b' ].split( ',' )
636 link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
637 link3End2 = main.params[ 'CORELINKS' ][ 'linkS18b' ].split( ',' )
638 switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
639 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800640
Hari Krishnad97213e2015-01-24 19:30:14 -0800641 main.log.report( "Host intents - Randomly bring some core links down and verify ping all" )
642 main.log.report( "_________________________________________________________________" )
643 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
644 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800645 if ( int( switchLinksToToggle ) ==
646 0 or int( switchLinksToToggle ) > 5 ):
Hari Krishna46997e02015-01-27 11:23:07 -0800647 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 -0800648 main.cleanup()
649 main.exit()
650 else:
Hari Krishnad97213e2015-01-24 19:30:14 -0800651 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 -0800652
kelvin-onlab8a832582015-01-16 17:06:11 -0800653 main.step( "Cut links on Core devices using user provided range" )
Hari Krishna22c3d412015-02-17 16:48:12 -0800654 main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
655 main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
656 main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800657 for i in range( int( switchLinksToToggle ) ):
658 main.Mininet1.link(
659 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800660 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800661 OPTION="down" )
662 main.Mininet1.link(
663 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800664 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800665 OPTION="down" )
666 main.Mininet1.link(
667 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800668 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800669 OPTION="down" )
670 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800671
672 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800673 linkDown = main.ONOSbench.checkStatus(
Hari Krishna22c3d412015-02-17 16:48:12 -0800674 topology_output, main.numMNswitches, str(
675 int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800676 utilities.assert_equals(
677 expect=main.TRUE,
678 actual=linkDown,
679 onpass="Link Down discovered properly",
680 onfail="Link down was not discovered in " +
681 str( link_sleep ) +
682 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800683
kelvin-onlab8a832582015-01-16 17:06:11 -0800684 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800685 pingResultLinkDown = main.FALSE
686 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -0800687 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout)
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800688 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800689 timeDiff = round( ( time2 - time1 ), 2 )
690 main.log.report(
691 "Time taken for Ping All: " +
692 str( timeDiff ) +
693 " seconds" )
694 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
695 onpass="PING ALL PASS",
696 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800697
Hari Krishna22c3d412015-02-17 16:48:12 -0800698 caseResult70 = linkDown and pingResultLinkDown
699 utilities.assert_equals( expect=main.TRUE, actual=caseResult70,
kelvin-onlab8a832582015-01-16 17:06:11 -0800700 onpass="Random Link cut Test PASS",
701 onfail="Random Link cut Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800702
kelvin-onlab8a832582015-01-16 17:06:11 -0800703 def CASE80( self, main ):
704 """
705 Bring the core links up that are down and verify ping all ( Host Intents Scenario )
706 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800707 import random
kelvin-onlab8a832582015-01-16 17:06:11 -0800708 link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
709 link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
710 link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
711 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
712 switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800713
kelvin-onlab8a832582015-01-16 17:06:11 -0800714 main.log.report(
715 "Host intents - Bring the core links up that are down and verify ping all" )
716 main.log.report(
717 "__________________________________________________________________" )
718 main.case(
719 "Host intents - Bring the core links up that are down and verify ping all" )
720 main.step( "Bring randomly cut links on Core devices up" )
721 for i in range( int( switchLinksToToggle ) ):
722 main.Mininet1.link(
723 END1=link1End1,
kelvin-onlab54400a92015-02-26 18:05:51 -0800724 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800725 OPTION="up" )
726 main.Mininet1.link(
727 END1=link2End1,
kelvin-onlab54400a92015-02-26 18:05:51 -0800728 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800729 OPTION="up" )
730 main.Mininet1.link(
731 END1=link3End1,
kelvin-onlab54400a92015-02-26 18:05:51 -0800732 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800733 OPTION="up" )
734 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800735
736 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800737 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -0800738 topology_output,
Hari Krishna22c3d412015-02-17 16:48:12 -0800739 main.numMNswitches,
740 str( main.numMNlinks ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800741 utilities.assert_equals(
742 expect=main.TRUE,
743 actual=linkUp,
744 onpass="Link up discovered properly",
745 onfail="Link up was not discovered in " +
746 str( link_sleep ) +
747 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800748
kelvin-onlab8a832582015-01-16 17:06:11 -0800749 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800750 pingResultLinkUp = main.FALSE
751 time1 = time.time()
752 pingResultLinkUp = main.Mininet1.pingall()
753 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800754 timeDiff = round( ( time2 - time1 ), 2 )
755 main.log.report(
756 "Time taken for Ping All: " +
757 str( timeDiff ) +
758 " seconds" )
759 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
760 onpass="PING ALL PASS",
761 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800762
Hari Krishna22c3d412015-02-17 16:48:12 -0800763 caseResult80 = linkUp and pingResultLinkUp
764 utilities.assert_equals( expect=main.TRUE, actual=caseResult80,
kelvin-onlab8a832582015-01-16 17:06:11 -0800765 onpass="Link Up Test PASS",
766 onfail="Link Up Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800767
kelvin-onlab8a832582015-01-16 17:06:11 -0800768 def CASE71( self, main ):
769 """
770 Randomly bring some core links down and verify ping all ( Point Intents Scenario )
771 """
kelvin8ec71442015-01-15 16:57:00 -0800772 import random
Hari Krishna22c3d412015-02-17 16:48:12 -0800773 main.randomLink1 = []
774 main.randomLink2 = []
775 main.randomLink3 = []
kelvin-onlab8a832582015-01-16 17:06:11 -0800776 link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
777 link1End2 = main.params[ 'CORELINKS' ][ 'linkS3b' ].split( ',' )
778 link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
779 link2End2 = main.params[ 'CORELINKS' ][ 'linkS14b' ].split( ',' )
780 link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
781 link3End2 = main.params[ 'CORELINKS' ][ 'linkS18b' ].split( ',' )
782 switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
783 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin8ec71442015-01-15 16:57:00 -0800784
Hari Krishnad97213e2015-01-24 19:30:14 -0800785 main.log.report( "Point Intents - Randomly bring some core links down and verify ping all" )
786 main.log.report( "__________________________________________________________________" )
787 main.case( "Point Intents - Randomly bring some core links down and verify ping all" )
788 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800789 if ( int( switchLinksToToggle ) ==
790 0 or int( switchLinksToToggle ) > 5 ):
791 main.log.info(
792 "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 -0800793 main.cleanup()
794 main.exit()
795 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800796 main.log.info(
797 "User provided Core switch links range to toggle is correct, proceeding to run the test" )
kelvin8ec71442015-01-15 16:57:00 -0800798
kelvin-onlab8a832582015-01-16 17:06:11 -0800799 main.step( "Cut links on Core devices using user provided range" )
800 randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
801 randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
802 randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
803 for i in range( int( switchLinksToToggle ) ):
804 main.Mininet1.link(
805 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800806 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800807 OPTION="down" )
808 main.Mininet1.link(
809 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800810 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800811 OPTION="down" )
812 main.Mininet1.link(
813 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800814 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800815 OPTION="down" )
816 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -0800817
818 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800819 linkDown = main.ONOSbench.checkStatus(
Hari Krishna22c3d412015-02-17 16:48:12 -0800820 topology_output, main.numSwitches, str(
821 int( main.numLinks ) - int( switchLinksToToggle ) * 6 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800822 utilities.assert_equals(
823 expect=main.TRUE,
824 actual=linkDown,
825 onpass="Link Down discovered properly",
826 onfail="Link down was not discovered in " +
827 str( link_sleep ) +
828 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -0800829
kelvin-onlab8a832582015-01-16 17:06:11 -0800830 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -0800831 pingResultLinkDown = main.FALSE
832 time1 = time.time()
833 pingResultLinkDown = main.Mininet1.pingall()
834 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800835 timeDiff = round( ( time2 - time1 ), 2 )
836 main.log.report(
837 "Time taken for Ping All: " +
838 str( timeDiff ) +
839 " seconds" )
840 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
841 onpass="PING ALL PASS",
842 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -0800843
844 caseResult7 = linkDown and pingResultLinkDown
kelvin-onlab8a832582015-01-16 17:06:11 -0800845 utilities.assert_equals( expect=main.TRUE, actual=caseResult7,
846 onpass="Random Link cut Test PASS",
847 onfail="Random Link cut Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -0800848
kelvin-onlab8a832582015-01-16 17:06:11 -0800849 def CASE81( self, main ):
850 """
851 Bring the core links up that are down and verify ping all ( Point Intents Scenario )
852 """
kelvin8ec71442015-01-15 16:57:00 -0800853 import random
kelvin-onlab8a832582015-01-16 17:06:11 -0800854 link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
855 link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
856 link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
857 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
858 switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
kelvin8ec71442015-01-15 16:57:00 -0800859
kelvin-onlab8a832582015-01-16 17:06:11 -0800860 main.log.report(
861 "Point intents - Bring the core links up that are down and verify ping all" )
862 main.log.report(
863 "___________________________________________________________________" )
864 main.case(
865 "Point intents - Bring the core links up that are down and verify ping all" )
866 main.step( "Bring randomly cut links on Core devices up" )
867 for i in range( int( switchLinksToToggle ) ):
868 main.Mininet1.link(
869 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800870 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800871 OPTION="up" )
872 main.Mininet1.link(
873 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800874 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800875 OPTION="up" )
876 main.Mininet1.link(
877 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800878 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800879 OPTION="up" )
880 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -0800881
882 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800883 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -0800884 topology_output,
Hari Krishna22c3d412015-02-17 16:48:12 -0800885 main.numMNswitches,
886 str( main.numMNlinks ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800887 utilities.assert_equals(
888 expect=main.TRUE,
889 actual=linkUp,
890 onpass="Link up discovered properly",
891 onfail="Link up was not discovered in " +
892 str( link_sleep ) +
893 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -0800894
kelvin-onlab8a832582015-01-16 17:06:11 -0800895 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -0800896 pingResultLinkUp = main.FALSE
897 time1 = time.time()
898 pingResultLinkUp = main.Mininet1.pingall()
899 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800900 timeDiff = round( ( time2 - time1 ), 2 )
901 main.log.report(
902 "Time taken for Ping All: " +
903 str( timeDiff ) +
904 " seconds" )
905 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
906 onpass="PING ALL PASS",
907 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -0800908
Hari Krishna22c3d412015-02-17 16:48:12 -0800909 caseResult81 = linkUp and pingResultLinkUp
910 utilities.assert_equals( expect=main.TRUE, actual=caseResult81,
kelvin-onlab8a832582015-01-16 17:06:11 -0800911 onpass="Link Up Test PASS",
912 onfail="Link Up Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -0800913
kelvin-onlab8a832582015-01-16 17:06:11 -0800914 def CASE9( self ):
915 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800916 Install 114 point intents and verify Ping all works
kelvin-onlab8a832582015-01-16 17:06:11 -0800917 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800918 import copy
kelvin-onlab8a832582015-01-16 17:06:11 -0800919 main.log.report( "Install 114 point intents and verify Ping all" )
920 main.log.report( "___________________________________________" )
921 main.case( "Install 114 point intents and Ping all" )
Hari Krishna22c3d412015-02-17 16:48:12 -0800922 deviceLinksCopy = copy.copy( main.deviceLinks )
kelvin-onlab8a832582015-01-16 17:06:11 -0800923 main.step( "Install 114 point intents" )
Hari Krishna22c3d412015-02-17 16:48:12 -0800924 for i in range( len( deviceLinksCopy ) ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800925 pointLink = str(
Hari Krishna22c3d412015-02-17 16:48:12 -0800926 deviceLinksCopy[ i ] ).replace(
kelvin-onlab8a832582015-01-16 17:06:11 -0800927 "src=",
928 "" ).replace(
929 "dst=",
930 "" ).split( ',' )
931 point1 = pointLink[ 0 ].split( '/' )
932 point2 = pointLink[ 1 ].split( '/' )
Hari Krishnad97213e2015-01-24 19:30:14 -0800933 installResult = main.ONOScli1.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -0800934 point1[ 0 ], point2[ 0 ], int(
935 point1[ 1 ] ), int(
936 point2[ 1 ] ) )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800937 if installResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800938 print "Installed Point intent between :", point1[ 0 ], int( point1[ 1 ] ), point2[ 0 ], int( point2[ 1 ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800939
kelvin-onlab8a832582015-01-16 17:06:11 -0800940 main.step( "Obtain the intent id's" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800941 intentsList = main.ONOScli1.getAllIntentIds()
kelvin-onlab8a832582015-01-16 17:06:11 -0800942 ansi_escape = re.compile( r'\x1b[^m]*m' )
943 intentsList = ansi_escape.sub( '', intentsList )
944 intentsList = intentsList.replace(
945 " onos:intents | grep id=",
946 "" ).replace(
947 "id=",
948 "" ).replace(
949 "\r\r",
950 "" )
951 intentsList = intentsList.splitlines()
952 intentsList = intentsList[ 1: ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800953 intentIdList = []
kelvin-onlab8a832582015-01-16 17:06:11 -0800954 for i in range( len( intentsList ) ):
955 intentsTemp = intentsList[ i ].split( ',' )
956 intentIdList.append( intentsTemp[ 0 ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800957 print "Intent IDs: ", intentIdList
kelvin-onlab8a832582015-01-16 17:06:11 -0800958 print "Total Intents installed: ", len( intentIdList )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800959
kelvin-onlab8a832582015-01-16 17:06:11 -0800960 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800961 pingResult = main.FALSE
962 time1 = time.time()
963 pingResult = main.Mininet1.pingall()
964 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800965 timeDiff = round( ( time2 - time1 ), 2 )
966 main.log.report(
967 "Time taken for Ping All: " +
968 str( timeDiff ) +
969 " seconds" )
970 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
971 onpass="PING ALL PASS",
972 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800973
974 case8_result = installResult and pingResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800975 utilities.assert_equals(
976 expect=main.TRUE,
977 actual=case8_result,
978 onpass="Ping all test after Point intents addition successful",
979 onfail="Ping all test after Point intents addition failed" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800980
kelvin-onlab8a832582015-01-16 17:06:11 -0800981 def CASE10( self ):
kelvin-onlab7642bb12015-02-27 13:48:17 -0800982 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800983 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800984 Remove all Intents
kelvin-onlab8a832582015-01-16 17:06:11 -0800985 """
986 main.log.report( "Remove all intents that were installed previously" )
987 main.log.report( "______________________________________________" )
988 main.log.info( "Remove all intents" )
989 main.case( "Removing intents" )
990 main.step( "Obtain the intent id's first" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800991 intentsList = main.ONOScli1.getAllIntentIds()
kelvin-onlab8a832582015-01-16 17:06:11 -0800992 ansi_escape = re.compile( r'\x1b[^m]*m' )
993 intentsList = ansi_escape.sub( '', intentsList )
994 intentsList = intentsList.replace(
995 " onos:intents | grep id=",
996 "" ).replace(
997 "id=",
998 "" ).replace(
999 "\r\r",
1000 "" )
1001 intentsList = intentsList.splitlines()
1002 intentsList = intentsList[ 1: ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001003 intentIdList = []
1004 step1Result = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001005 if ( len( intentsList ) > 1 ):
1006 for i in range( len( intentsList ) ):
1007 intentsTemp = intentsList[ i ].split( ',' )
1008 intentIdList.append( intentsTemp[ 0 ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001009 print "Intent IDs: ", intentIdList
kelvin-onlab54400a92015-02-26 18:05:51 -08001010
kelvin-onlab54400a92015-02-26 18:05:51 -08001011 CLI1 = (main.ONOScli1.removeIntent)
1012 CLI2 = (main.ONOScli2.removeIntent)
1013 CLI3 = (main.ONOScli3.removeIntent)
1014 CLI4 = (main.ONOScli4.removeIntent)
1015 CLI5 = (main.ONOScli5.removeIntent)
1016 ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5]
1017 results = main.TRUE
1018 time1 = time.time()
1019
1020 for i in xrange(0,len(intentIdList),5):
1021 pool = []
1022 for cli in ONOSCLI:
1023 if i >= len(intentIdList):
1024 break
1025 print "Removing intent id (round 1) :", intentIdList[ i ]
1026 t = main.Thread(target=cli,threadID=main.threadID,
1027 name="removeIntent",
kelvin-onlab7642bb12015-02-27 13:48:17 -08001028 args=[intentIdList[i],'org.onosproject.cli',False,False])
kelvin-onlab54400a92015-02-26 18:05:51 -08001029 pool.append(t)
1030 t.start()
1031 i = i + 1
1032 main.threadID = main.threadID + 1
kelvin-onlab54400a92015-02-26 18:05:51 -08001033 for thread in pool:
1034 thread.join()
1035 results = results and thread.result
kelvin-onlabdc8719b2015-03-02 14:01:52 -08001036
kelvin-onlab54400a92015-02-26 18:05:51 -08001037 time2 = time.time()
1038 main.log.info("Time for feature:install onos-app-fwd: %2f seconds" %(time2-time1))
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001039
kelvin-onlab8a832582015-01-16 17:06:11 -08001040 main.log.info(
1041 "Verify all intents are removed and if any leftovers try remove one more time" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001042 intentsList1 = main.ONOScli1.getAllIntentIds()
kelvin-onlab8a832582015-01-16 17:06:11 -08001043 ansi_escape = re.compile( r'\x1b[^m]*m' )
1044 intentsList1 = ansi_escape.sub( '', intentsList1 )
1045 intentsList1 = intentsList1.replace(
1046 " onos:intents | grep id=",
1047 "" ).replace(
1048 " state=",
1049 "" ).replace(
1050 "\r\r",
1051 "" )
1052 intentsList1 = intentsList1.splitlines()
1053 intentsList1 = intentsList1[ 1: ]
kelvin-onlab7642bb12015-02-27 13:48:17 -08001054
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001055 print "Round 2 (leftover) intents to remove: ", intentsList1
1056 intentIdList1 = []
kelvin-onlab8a832582015-01-16 17:06:11 -08001057 if ( len( intentsList1 ) > 1 ):
1058 for i in range( len( intentsList1 ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001059 intentsTemp1 = intentsList1[ i ].split( ',' )
kelvin-onlabf9c71282015-02-27 10:41:41 -08001060 intentIdList1.append( intentsTemp1[ 0 ].split('=')[1] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001061 print "Leftover Intent IDs: ", intentIdList1
kelvin-onlab54400a92015-02-26 18:05:51 -08001062 for i in xrange(0,len(intentIdList1),5):
1063 pool = []
1064 for cli in ONOSCLI:
kelvin-onlabfd3d76e2015-02-27 11:23:21 -08001065 if i >= len(intentIdList1):
kelvin-onlab54400a92015-02-26 18:05:51 -08001066 break
1067 print "Removing intent id (round 2) :", intentIdList1[ i ]
1068 t = main.Thread(target=cli,threadID=main.threadID,
1069 name="removeIntent",
kelvin-onlab7642bb12015-02-27 13:48:17 -08001070 args=[intentIdList1[i],'org.onosproject.cli',True,False])
kelvin-onlab54400a92015-02-26 18:05:51 -08001071 pool.append(t)
1072 t.start()
1073 i = i + 1
1074 main.threadID = main.threadID + 1
1075
1076 for thread in pool:
1077 thread.join()
1078 results = results and thread.result
1079 step1Result = results
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001080 else:
1081 print "There are no more intents that need to be removed"
1082 step1Result = main.TRUE
1083 else:
1084 print "No Intent IDs found in Intents list: ", intentsList
1085 step1Result = main.FALSE
1086
kelvin-onlabdc8719b2015-03-02 14:01:52 -08001087 print main.ONOScli1.intents()
1088 time.sleep(600)
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001089 caseResult7 = step1Result
kelvin-onlab8a832582015-01-16 17:06:11 -08001090 utilities.assert_equals( expect=main.TRUE, actual=caseResult7,
1091 onpass="Intent removal test successful",
1092 onfail="Intent removal test failed" )
Hari Krishna22c3d412015-02-17 16:48:12 -08001093
1094 def CASE11( self, main ):
1095 """
1096 Enable onos-app-ifwd, Verify Intent based Reactive forwarding through ping all and Disable it
1097 """
1098 import re
1099 import copy
1100 import time
1101
kelvin-onlab54400a92015-02-26 18:05:51 -08001102 Thread = imp.load_source('Thread','/home/admin/ONLabTest/TestON/tests/OnosCHO/Thread.py')
1103 threadID = 0
1104
Hari Krishna22c3d412015-02-17 16:48:12 -08001105 main.log.report( "Enable Intent based Reactive forwarding and Verify ping all" )
1106 main.log.report( "_____________________________________________________" )
1107 main.case( "Enable Intent based Reactive forwarding and Verify ping all" )
1108 main.step( "Enable intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001109 installResult = main.FALSE
1110 feature = "onos-app-ifwd"
1111 CLI1 = (main.ONOScli1.featureInstall,feature)
1112 CLI2 = (main.ONOScli2.featureInstall,feature)
1113 CLI3 = (main.ONOScli3.featureInstall,feature)
1114 CLI4 = (main.ONOScli4.featureInstall,feature)
1115 CLI5 = (main.ONOScli5.featureInstall,feature)
1116 ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5]
1117 pool = []
1118 time1 = time.time()
1119 for cli,feature in ONOSCLI:
1120 t = main.Thread(target=cli,threadID=threadID,
1121 name="featureInstall",args=[feature])
1122 pool.append(t)
1123 t.start()
1124 threadID = threadID + 1
1125
1126 results = []
1127 for thread in pool:
1128 thread.join()
1129 results.append(thread.result)
1130 time2 = time.time()
1131
1132 if( all(result == main.TRUE for result in results) == False):
1133 main.log.info("Did not install onos-app-ifwd feature properly")
1134 main.cleanup()
1135 main.exit()
1136 else:
1137 main.log.info("Successful feature:install onos-app-ifwd")
1138 installResult = main.TRUE
1139 main.log.info("Time for feature:install onos-app-ifwd: %2f seconds" %(time2-time1))
1140
Hari Krishna22c3d412015-02-17 16:48:12 -08001141 main.step( "Verify Pingall" )
1142 ping_result = main.FALSE
1143 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -08001144 ping_result = main.Mininet1.pingall(timeout=600)
Hari Krishna22c3d412015-02-17 16:48:12 -08001145 time2 = time.time()
1146 timeDiff = round( ( time2 - time1 ), 2 )
1147 main.log.report(
1148 "Time taken for Ping All: " +
1149 str( timeDiff ) +
1150 " seconds" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001151
Hari Krishna22c3d412015-02-17 16:48:12 -08001152 if ping_result == main.TRUE:
1153 main.log.report( "Pingall Test in Reactive mode successful" )
1154 else:
1155 main.log.report( "Pingall Test in Reactive mode failed" )
1156
1157 main.step( "Disable Intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001158 uninstallResult = main.FALSE
1159
1160 CLI1 = (main.ONOScli1.featureUninstall,feature)
1161 CLI2 = (main.ONOScli2.featureUninstall,feature)
1162 CLI3 = (main.ONOScli3.featureUninstall,feature)
1163 CLI4 = (main.ONOScli4.featureUninstall,feature)
1164 CLI5 = (main.ONOScli5.featureUninstall,feature)
1165 ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5]
1166 pool = []
1167 time1 = time.time()
1168 for cli,feature in ONOSCLI:
1169 t = main.Thread(target=cli,threadID=threadID,
1170 name="featureUninstall",args=[feature])
1171 pool.append(t)
1172 t.start()
1173 threadID = threadID + 1
1174
1175 results = []
1176 for thread in pool:
1177 thread.join()
1178 results.append(thread.result)
1179 time2 = time.time()
1180
1181 if( all(result == main.TRUE for result in results) == False):
1182 main.log.info("Did not uninstall onos-app-ifwd feature properly")
1183 main.cleanup()
1184 main.exit()
1185 else:
1186 main.log.info("Successful feature:uninstall onos-app-ifwd")
1187 uninstallResult = main.TRUE
1188 main.log.info("Time for feature:uninstall onos-app-ifwd: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -08001189
1190 # Waiting for reative flows to be cleared.
1191 time.sleep( 10 )
1192
1193 case11Result = installResult and ping_result and uninstallResult
1194 utilities.assert_equals( expect=main.TRUE, actual=case11Result,
1195 onpass="Intent based Reactive forwarding Pingall test PASS",
1196 onfail="Intent based Reactive forwarding Pingall test FAIL" )
1197
1198 def CASE12( self, main ):
1199 """
1200 This test script Loads a new Topology (Chordal) on CHO setup and balances all switches
1201 """
1202 import re
1203 import time
1204 import copy
kelvin-onlab54400a92015-02-26 18:05:51 -08001205
Hari Krishna22c3d412015-02-17 16:48:12 -08001206
kelvin-onlab54400a92015-02-26 18:05:51 -08001207 Thread = imp.load_source('Thread','/home/admin/ONLabTest/TestON/tests/OnosCHO/Thread.py')
Hari Krishna22c3d412015-02-17 16:48:12 -08001208 newTopo = main.params['TOPO2']['topo']
1209 main.numMNswitches = int ( main.params[ 'TOPO2' ][ 'numSwitches' ] )
1210 main.numMNlinks = int ( main.params[ 'TOPO2' ][ 'numLinks' ] )
1211 main.numMNhosts = int ( main.params[ 'TOPO2' ][ 'numHosts' ] )
kelvin-onlab54400a92015-02-26 18:05:51 -08001212 main.pingTimeout = 60
Hari Krishna22c3d412015-02-17 16:48:12 -08001213 main.log.report(
1214 "Load Chordal topology and Balance all Mininet switches across controllers" )
1215 main.log.report(
1216 "________________________________________________________________________" )
1217 # need to wait here for sometime until ONOS bootup
1218 time.sleep( 15 )
1219 main.case(
1220 "Assign and Balance all Mininet switches across controllers" )
1221 main.step( "Stop any previous Mininet network topology" )
1222 stopStatus = main.Mininet1.stopNet()
1223
1224 # WORK AROUND FOR ONOS-581. STOP ONOS BEFORE ASSIGNING CONTROLLERS AT MININET & START ONCE DONE
1225 main.step( "Stop ONOS on all Nodes" )
1226 stopResult = main.TRUE
1227 for i in range( 1, int( main.numCtrls ) + 1 ):
1228 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
1229 main.log.info( "Stopping ONOS Node IP: " + ONOS_ip )
1230 sresult = main.ONOSbench.onosStop( ONOS_ip )
1231 utilities.assert_equals( expect=main.TRUE, actual=sresult,
1232 onpass="Test step PASS",
1233 onfail="Test step FAIL" )
1234 stopResult = ( stopResult and sresult )
1235
1236 main.step( "Start Mininet with Chordal topology" )
1237 startStatus = main.Mininet1.startNet(topoFile = newTopo)
1238
1239 main.step( "Assign switches to controllers" )
1240 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
1241 main.Mininet1.assignSwController(
1242 sw=str( i ),
1243 count=int( main.numCtrls ),
1244 ip1=main.ONOS1_ip,
1245 port1=main.ONOS1_port,
1246 ip2=main.ONOS2_ip,
1247 port2=main.ONOS2_port,
1248 ip3=main.ONOS3_ip,
1249 port3=main.ONOS3_port,
1250 ip4=main.ONOS4_ip,
1251 port4=main.ONOS4_port,
1252 ip5=main.ONOS5_ip,
1253 port5=main.ONOS5_port )
1254
1255 switch_mastership = main.TRUE
1256 for i in range( 1, ( main.numMNswitches + 1 ) ):
1257 response = main.Mininet1.getSwController( "s" + str( i ) )
1258 print( "Response is " + str( response ) )
1259 if re.search( "tcp:" + main.ONOS1_ip, response ):
1260 switch_mastership = switch_mastership and main.TRUE
1261 else:
1262 switch_mastership = main.FALSE
1263
1264 if switch_mastership == main.TRUE:
1265 main.log.report( "Controller assignment successfull" )
1266 else:
1267 main.log.report( "Controller assignment failed" )
1268 time.sleep( 5 )
1269
1270 main.step( "Start ONOS on all Nodes" )
1271 startResult = main.TRUE
1272 for i in range( 1, int( main.numCtrls ) + 1 ):
1273 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
1274 main.log.info( "Starting ONOS Node IP: " + ONOS_ip )
1275 sresult = main.ONOSbench.onosStart( ONOS_ip )
1276 utilities.assert_equals( expect=main.TRUE, actual=sresult,
1277 onpass="Test step PASS",
1278 onfail="Test step FAIL" )
1279 startResult = ( startResult and sresult )
1280
1281 main.step( "Start ONOS CLI on all nodes" )
1282 cliResult = main.TRUE
1283 #karafTimeout = "3600000" # This is not needed here as it is already set before.
1284 # need to wait here sometime for ONOS to bootup.
1285 time.sleep( 30 )
kelvin-onlab54400a92015-02-26 18:05:51 -08001286
1287 main.log.step(" Start ONOS cli using thread ")
1288
1289 CLI1 = (main.ONOScli1.startOnosCli,main.ONOS1_ip)
1290 CLI2 = (main.ONOScli2.startOnosCli,main.ONOS2_ip)
1291 CLI3 = (main.ONOScli3.startOnosCli,main.ONOS3_ip)
1292 CLI4 = (main.ONOScli4.startOnosCli,main.ONOS4_ip)
1293 CLI5 = (main.ONOScli5.startOnosCli,main.ONOS5_ip)
1294 ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5]
1295 pool = []
1296 time1 = time.time()
1297 for cli,ip in ONOSCLI:
1298 t = main.Thread(target=cli,threadID=main.threadID,
1299 name="startOnosCli",args=[ip])
1300 pool.append(t)
1301 t.start()
1302 main.threadID = main.threadID + 1
1303
1304 cliResult = main.FALSE
1305 results = []
1306 for thread in pool:
1307 thread.join()
1308 results.append(thread.result)
1309 time2 = time.time()
1310
1311 if( all(result == main.TRUE for result in results) == False):
1312 main.log.info("ONOS CLI did not start up properly")
1313 main.cleanup()
1314 main.exit()
1315 else:
1316 main.log.info("Successful CLI startup")
1317 cliResult = main.TRUE
1318 main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -08001319
1320 main.step( "Balance devices across controllers" )
1321 for i in range( int( main.numCtrls ) ):
1322 balanceResult = main.ONOScli1.balanceMasters()
1323 # giving some breathing time for ONOS to complete re-balance
1324 time.sleep( 3 )
1325
1326 case12Result = ( startResult and cliResult )
1327 utilities.assert_equals(
1328 expect=main.TRUE,
1329 actual=case12Result,
1330 onpass="Starting new Chordal topology test PASS",
1331 onfail="Starting new Chordal topology test FAIL" )
1332
1333 def CASE13( self, main ):
1334 """
1335 This test script Loads a new Topology (Spine) on CHO setup and balances all switches
1336 """
1337 import re
1338 import time
1339 import copy
1340
1341 newTopo = main.params['TOPO3']['topo']
1342 main.numMNswitches = int ( main.params[ 'TOPO3' ][ 'numSwitches' ] )
1343 main.numMNlinks = int ( main.params[ 'TOPO3' ][ 'numLinks' ] )
1344 main.numMNhosts = int ( main.params[ 'TOPO3' ][ 'numHosts' ] )
kelvin-onlab54400a92015-02-26 18:05:51 -08001345 main.pingTimeout = 600
Hari Krishna22c3d412015-02-17 16:48:12 -08001346 main.log.report(
1347 "Load Spine and Leaf topology and Balance all Mininet switches across controllers" )
1348 main.log.report(
1349 "________________________________________________________________________" )
1350 # need to wait here for sometime until ONOS bootup
1351 time.sleep( 15 )
1352 main.case(
1353 "Assign and Balance all Mininet switches across controllers" )
1354 main.step( "Stop any previous Mininet network topology" )
1355 stopStatus = main.Mininet1.stopNet()
1356
1357 # WORK AROUND FOR ONOS-581. STOP ONOS BEFORE ASSIGNING CONTROLLERS AT MININET & START ONCE DONE
1358 main.step( "Stop ONOS on all Nodes" )
1359 stopResult = main.TRUE
1360 for i in range( 1, int( main.numCtrls ) + 1 ):
1361 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
1362 main.log.info( "Stopping ONOS Node IP: " + ONOS_ip )
1363 sresult = main.ONOSbench.onosStop( ONOS_ip )
1364 utilities.assert_equals( expect=main.TRUE, actual=sresult,
1365 onpass="Test step PASS",
1366 onfail="Test step FAIL" )
1367 stopResult = ( stopResult and sresult )
1368
1369 main.step( "Start Mininet with Spine topology" )
1370 startStatus = main.Mininet1.startNet(topoFile = newTopo)
1371
1372 main.step( "Assign switches to controllers" )
1373 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
1374 main.Mininet1.assignSwController(
1375 sw=str( i ),
1376 count=int( main.numCtrls ),
1377 ip1=main.ONOS1_ip,
1378 port1=main.ONOS1_port,
1379 ip2=main.ONOS2_ip,
1380 port2=main.ONOS2_port,
1381 ip3=main.ONOS3_ip,
1382 port3=main.ONOS3_port,
1383 ip4=main.ONOS4_ip,
1384 port4=main.ONOS4_port,
1385 ip5=main.ONOS5_ip,
1386 port5=main.ONOS5_port )
1387
1388 switch_mastership = main.TRUE
1389 for i in range( 1, ( main.numMNswitches + 1 ) ):
1390 response = main.Mininet1.getSwController( "s" + str( i ) )
1391 print( "Response is " + str( response ) )
1392 if re.search( "tcp:" + main.ONOS1_ip, response ):
1393 switch_mastership = switch_mastership and main.TRUE
1394 else:
1395 switch_mastership = main.FALSE
1396
1397 if switch_mastership == main.TRUE:
1398 main.log.report( "Controller assignment successfull" )
1399 else:
1400 main.log.report( "Controller assignment failed" )
1401 time.sleep( 5 )
1402
1403 main.step( "Start ONOS on all Nodes" )
1404 startResult = main.TRUE
1405 for i in range( 1, int( main.numCtrls ) + 1 ):
1406 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
1407 main.log.info( "Starting ONOS Node IP: " + ONOS_ip )
1408 sresult = main.ONOSbench.onosStart( ONOS_ip )
1409 utilities.assert_equals( expect=main.TRUE, actual=sresult,
1410 onpass="Test step PASS",
1411 onfail="Test step FAIL" )
1412 startResult = ( startResult and sresult )
1413
1414 main.step( "Start ONOS CLI on all nodes" )
1415 cliResult = main.TRUE
1416 #karafTimeout = "3600000" # This is not needed here as it is already set before.
1417 # need to wait here sometime for ONOS to bootup.
1418 time.sleep( 30 )
kelvin-onlab54400a92015-02-26 18:05:51 -08001419
1420 main.log.step(" Start ONOS cli using thread ")
1421
1422 CLI1 = (main.ONOScli1.startOnosCli,main.ONOS1_ip)
1423 CLI2 = (main.ONOScli2.startOnosCli,main.ONOS2_ip)
1424 CLI3 = (main.ONOScli3.startOnosCli,main.ONOS3_ip)
1425 CLI4 = (main.ONOScli4.startOnosCli,main.ONOS4_ip)
1426 CLI5 = (main.ONOScli5.startOnosCli,main.ONOS5_ip)
1427 ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5]
1428 pool = []
1429 time1 = time.time()
1430 for cli,ip in ONOSCLI:
1431 t = main.Thread(target=cli,threadID=main.threadID,
1432 name="startOnosCli",args=[ip])
1433 pool.append(t)
1434 t.start()
1435 main.threadID = main.threadID + 1
1436
1437 cliResult = main.FALSE
1438 results = []
1439 for thread in pool:
1440 thread.join()
1441 results.append(thread.result)
1442 time2 = time.time()
1443
1444 if( all(result == main.TRUE for result in results) == False):
1445 main.log.info("ONOS CLI did not start up properly")
1446 main.cleanup()
1447 main.exit()
1448 else:
1449 main.log.info("Successful CLI startup")
1450 cliResult = main.TRUE
1451 main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
1452
1453 main.step( "Balance devices across controllers" )
1454 for i in range( int( main.numCtrls ) ):
1455 balanceResult = main.ONOScli1.balanceMasters()
1456 # giving some breathing time for ONOS to complete re-balance
1457 time.sleep( 3 )
Hari Krishna22c3d412015-02-17 16:48:12 -08001458
1459 main.step( "Balance devices across controllers" )
1460 for i in range( int( main.numCtrls ) ):
1461 balanceResult = main.ONOScli1.balanceMasters()
1462 # giving some breathing time for ONOS to complete re-balance
1463 time.sleep( 3 )
1464
1465 case13Result = ( startResult and cliResult )
1466 utilities.assert_equals(
1467 expect=main.TRUE,
1468 actual=case13Result,
1469 onpass="Starting new Spine topology test PASS",
1470 onfail="Starting new Spine topology test FAIL" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001471
1472 def CASE14(self,main):
1473 """
1474 Install 300 host intents and verify ping all
1475 """
1476 main.log.report( "Add 300 host intents and verify pingall" )
1477 main.log.report( "_______________________________________" )
1478 import itertools
1479
1480 main.case( "Install 300 host intents" )
1481 main.step( "Add host Intents" )
1482 intentResult = main.TRUE
1483 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
1484
1485 CLI1 = (main.ONOScli1.addHostIntent)
1486 CLI2 = (main.ONOScli2.addHostIntent)
1487 CLI3 = (main.ONOScli3.addHostIntent)
1488 CLI4 = (main.ONOScli4.addHostIntent)
1489 CLI5 = (main.ONOScli5.addHostIntent)
1490 ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5]
1491 results = main.TRUE
1492 time1 = time.time()
1493 for i in xrange(0,len(hostCombos),5):
1494 pool = []
1495 for cli in ONOSCLI:
1496 if i >= len(hostCombos):
1497 break
1498 t = main.Thread(target=cli,threadID=main.threadID,
1499 name="addHostIntent",
1500 args=[hostCombos[i][0],hostCombos[i][1]])
1501 pool.append(t)
1502 t.start()
1503 i = i + 1
1504 main.threadID = main.threadID + 1
1505
1506 for thread in pool:
1507 thread.join()
1508 results = results and thread.result
1509
1510 time2 = time.time()
1511
1512 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
1513 intentResult = results
1514 """
1515 for i in range( len( hostCombos ) ):
1516 iResult = main.ONOScli1.addHostIntent(
1517 hostCombos[ i ][ 0 ],
1518 hostCombos[ i ][ 1 ] )
1519 intentResult = ( intentResult and iResult )
1520 """
1521
1522 main.step( "Verify Ping across all hosts" )
1523 pingResult = main.FALSE
1524 time1 = time.time()
1525 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
1526 time2 = time.time()
1527 timeDiff = round( ( time2 - time1 ), 2 )
1528 main.log.report(
1529 "Time taken for Ping All: " +
1530 str( timeDiff ) +
1531 " seconds" )
1532 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1533 onpass="PING ALL PASS",
1534 onfail="PING ALL FAIL" )
1535
1536 case4Result = ( intentResult and pingResult )
1537
1538 #case4Result = pingResult
1539 utilities.assert_equals(
1540 expect=main.TRUE,
1541 actual=case4Result,
1542 onpass="Install 300 Host Intents and Ping All test PASS",
1543 onfail="Install 300 Host Intents and Ping All test FAIL" )
1544
1545 def CASE15( self,main):
1546 """
1547 Install 300 host intents and verify ping all
1548 """
1549 main.log.report( "Add 300 host intents and verify pingall" )
1550 main.log.report( "_______________________________________" )
1551 import itertools
1552
1553 main.case( "Install 300 host intents" )
1554 main.step( "Add host Intents" )
1555 intentResult = main.TRUE
1556 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
1557
1558 CLI1 = (main.ONOScli1.addHostIntent)
1559 CLI2 = (main.ONOScli2.addHostIntent)
1560 CLI3 = (main.ONOScli3.addHostIntent)
1561 CLI4 = (main.ONOScli4.addHostIntent)
1562 CLI5 = (main.ONOScli5.addHostIntent)
1563 ONOSCLI = [CLI1,CLI2,CLI3,CLI4,CLI5]
1564 results = main.TRUE
1565 time1 = time.time()
1566 for i in xrange(0,len(hostCombos),5):
1567 pool = []
1568 for cli in ONOSCLI:
1569 if i >= len(hostCombos):
1570 break
1571 t = main.Thread(target=cli,threadID=main.threadID,
1572 name="addHostIntent",
1573 args=[hostCombos[i][0],hostCombos[i][1]])
1574 pool.append(t)
1575 t.start()
1576 i = i + 1
1577 main.threadID = main.threadID + 1
1578
1579 for thread in pool:
1580 thread.join()
1581 results = results and thread.result
1582
1583 time2 = time.time()
1584
1585 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
1586 intentResult = results
1587 """
1588 for i in range( len( hostCombos ) ):
1589 iResult = main.ONOScli1.addHostIntent(
1590 hostCombos[ i ][ 0 ],
1591 hostCombos[ i ][ 1 ] )
1592 intentResult = ( intentResult and iResult )
1593 """
1594
1595 main.step( "Verify Ping across all hosts" )
1596 pingResult = main.FALSE
1597 time1 = time.time()
1598 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
1599 time2 = time.time()
1600 timeDiff = round( ( time2 - time1 ), 2 )
1601 main.log.report(
1602 "Time taken for Ping All: " +
1603 str( timeDiff ) +
1604 " seconds" )
1605 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1606 onpass="PING ALL PASS",
1607 onfail="PING ALL FAIL" )
1608
1609 case4Result = ( intentResult and pingResult )
1610
1611 #case4Result = pingResult
1612 utilities.assert_equals(
1613 expect=main.TRUE,
1614 actual=case4Result,
1615 onpass="Install 300 Host Intents and Ping All test PASS",
1616 onfail="Install 300 Host Intents and Ping All test FAIL" )