blob: 3706a03f94659ecdebc5e301d21d7c206e52cff9 [file] [log] [blame]
kelvin-onlab65a72d22015-03-26 13:46:32 -07001
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002import 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-onlab78f7d2d2015-03-02 17:37:35 -080027
28 global intentState
kelvin-onlab54400a92015-02-26 18:05:51 -080029 main.threadID = 0
30 main.pingTimeout = 300
Hari Krishna22c3d412015-02-17 16:48:12 -080031 main.numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ]
32 main.ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
33 main.ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
34 main.ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
35 main.ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ]
36 main.ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ]
37 main.ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
38 main.ONOS2_port = main.params[ 'CTRL' ][ 'port2' ]
39 main.ONOS3_port = main.params[ 'CTRL' ][ 'port3' ]
40 main.ONOS4_port = main.params[ 'CTRL' ][ 'port4' ]
41 main.ONOS5_port = main.params[ 'CTRL' ][ 'port5' ]
kelvin-onlab8a832582015-01-16 17:06:11 -080042 cell_name = main.params[ 'ENV' ][ 'cellName' ]
43 git_pull = main.params[ 'GIT' ][ 'autoPull' ]
kelvin-onlab8a832582015-01-16 17:06:11 -080044 git_branch = main.params[ 'GIT' ][ 'branch' ]
Hari Krishnab35c6d02015-03-18 11:13:51 -070045 main.newTopo = ""
kelvin-onlab78f7d2d2015-03-02 17:37:35 -080046 main.CLIs = []
47 main.nodes = []
48 for i in range( 1, int(main.numCtrls) + 1 ):
49 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
50 main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
51
kelvin-onlab8a832582015-01-16 17:06:11 -080052 main.case( "Set up test environment" )
53 main.log.report( "Set up test environment" )
54 main.log.report( "_______________________" )
55
56 main.step( "Git checkout and pull " + git_branch )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080057 if git_pull == 'on':
Hari Krishnad97213e2015-01-24 19:30:14 -080058 checkout_result = main.ONOSbench.gitCheckout( git_branch )
59 pull_result = main.ONOSbench.gitPull()
kelvin-onlab8a832582015-01-16 17:06:11 -080060 cp_result = ( checkout_result and pull_result )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080061 else:
62 checkout_result = main.TRUE
63 pull_result = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -080064 main.log.info( "Skipped git checkout and pull" )
65 cp_result = ( checkout_result and pull_result )
66 utilities.assert_equals( expect=main.TRUE, actual=cp_result,
67 onpass="Test step PASS",
68 onfail="Test step FAIL" )
69
70 main.step( "mvn clean & install" )
Hari Krishna22c3d412015-02-17 16:48:12 -080071 if git_pull == 'on':
72 mvn_result = main.ONOSbench.cleanInstall()
73 utilities.assert_equals( expect=main.TRUE, actual=mvn_result,
kelvin-onlab8a832582015-01-16 17:06:11 -080074 onpass="Test step PASS",
75 onfail="Test step FAIL" )
Hari Krishna22c3d412015-02-17 16:48:12 -080076 else:
77 mvn_result = main.TRUE
78 main.log.info("Skipped mvn clean install as git pull is disabled in params file")
Hari Krishnaa43d4e92014-12-19 13:22:40 -080079
Hari Krishnad97213e2015-01-24 19:30:14 -080080 main.ONOSbench.getVersion( report=True )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080081
kelvin-onlab8a832582015-01-16 17:06:11 -080082 main.step( "Apply Cell environment for ONOS" )
Hari Krishnad97213e2015-01-24 19:30:14 -080083 cell_result = main.ONOSbench.setCell( cell_name )
kelvin-onlab8a832582015-01-16 17:06:11 -080084 utilities.assert_equals( expect=main.TRUE, actual=cell_result,
85 onpass="Test step PASS",
86 onfail="Test step FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080087
kelvin-onlab8a832582015-01-16 17:06:11 -080088 main.step( "Create ONOS package" )
Hari Krishnad97213e2015-01-24 19:30:14 -080089 packageResult = main.ONOSbench.onosPackage()
kelvin-onlab8a832582015-01-16 17:06:11 -080090 utilities.assert_equals( expect=main.TRUE, actual=packageResult,
91 onpass="Test step PASS",
92 onfail="Test step FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080093
kelvin-onlab8a832582015-01-16 17:06:11 -080094 main.step( "Uninstall ONOS package on all Nodes" )
95 uninstallResult = main.TRUE
Hari Krishna22c3d412015-02-17 16:48:12 -080096 for i in range( 1, int( main.numCtrls ) + 1 ):
kelvin-onlab8a832582015-01-16 17:06:11 -080097 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
kelvin-onlab54400a92015-02-26 18:05:51 -080098 main.log.info( "Uninstalling package on ONOS Node IP: " + ONOS_ip )
Hari Krishnad97213e2015-01-24 19:30:14 -080099 u_result = main.ONOSbench.onosUninstall( ONOS_ip )
kelvin-onlab8a832582015-01-16 17:06:11 -0800100 utilities.assert_equals( expect=main.TRUE, actual=u_result,
101 onpass="Test step PASS",
102 onfail="Test step FAIL" )
103 uninstallResult = ( uninstallResult and u_result )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800104
Hari Krishnab35c6d02015-03-18 11:13:51 -0700105 #main.step( "Removing copy-cat logs from ONOS nodes" )
106 #main.ONOSbench.onosRemoveRaftLogs()
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800107
kelvin-onlab8a832582015-01-16 17:06:11 -0800108 main.step( "Install ONOS package on all Nodes" )
109 installResult = main.TRUE
Hari Krishna22c3d412015-02-17 16:48:12 -0800110 for i in range( 1, int( main.numCtrls ) + 1 ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800111 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
112 main.log.info( "Intsalling package on ONOS Node IP: " + ONOS_ip )
Hari Krishnad97213e2015-01-24 19:30:14 -0800113 i_result = main.ONOSbench.onosInstall( node=ONOS_ip )
kelvin-onlab8a832582015-01-16 17:06:11 -0800114 utilities.assert_equals( expect=main.TRUE, actual=i_result,
115 onpass="Test step PASS",
116 onfail="Test step FAIL" )
117 installResult = ( installResult and i_result )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800118
kelvin-onlab8a832582015-01-16 17:06:11 -0800119 main.step( "Verify ONOS nodes UP status" )
120 statusResult = main.TRUE
Hari Krishna22c3d412015-02-17 16:48:12 -0800121 for i in range( 1, int( main.numCtrls ) + 1 ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800122 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
123 main.log.info( "ONOS Node " + ONOS_ip + " status:" )
Hari Krishnad97213e2015-01-24 19:30:14 -0800124 onos_status = main.ONOSbench.onosStatus( node=ONOS_ip )
kelvin-onlab8a832582015-01-16 17:06:11 -0800125 utilities.assert_equals( expect=main.TRUE, actual=onos_status,
126 onpass="Test step PASS",
127 onfail="Test step FAIL" )
128 statusResult = ( statusResult and onos_status )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700129
kelvin-onlab8a832582015-01-16 17:06:11 -0800130 main.step( "Start ONOS CLI on all nodes" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800131 cliResult = main.TRUE
kelvin8ec71442015-01-15 16:57:00 -0800132 karafTimeout = "3600000"
kelvin-onlab8a832582015-01-16 17:06:11 -0800133 # need to wait here for sometime. This will be removed once ONOS is
134 # stable enough
kelvin-onlab54400a92015-02-26 18:05:51 -0800135 time.sleep( 25 )
kelvin-onlab54400a92015-02-26 18:05:51 -0800136 main.log.step(" Start ONOS cli using thread ")
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800137 startCliResult = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800138 pool = []
139 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800140 for i in range( int( main.numCtrls) ):
141 t = main.Thread( target=main.CLIs[i].startOnosCli,
142 threadID=main.threadID,
143 name="startOnosCli",
144 args=[ main.nodes[i].ip_address ] )
kelvin-onlab54400a92015-02-26 18:05:51 -0800145 pool.append(t)
146 t.start()
147 main.threadID = main.threadID + 1
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800148 for t in pool:
149 t.join()
150 startCliResult = startCliResult and t.result
kelvin-onlab54400a92015-02-26 18:05:51 -0800151 time2 = time.time()
152
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800153 if not startCliResult:
kelvin-onlab54400a92015-02-26 18:05:51 -0800154 main.log.info("ONOS CLI did not start up properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -0700155 #main.cleanup()
156 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -0800157 else:
158 main.log.info("Successful CLI startup")
159 startCliResult = main.TRUE
160 case1Result = installResult and uninstallResult and statusResult and startCliResult
161
162 main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
kelvin-onlab8a832582015-01-16 17:06:11 -0800163 utilities.assert_equals( expect=main.TRUE, actual=case1Result,
164 onpass="Set up test environment PASS",
165 onfail="Set up test environment FAIL" )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700166
kelvin-onlab65a72d22015-03-26 13:46:32 -0700167 def CASE20( self, main ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800168 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700169 This test script Loads a new Topology (Att) on CHO setup and balances all switches
kelvin-onlab8a832582015-01-16 17:06:11 -0800170 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800171 import re
172 import time
173 import copy
Hari Krishnab35c6d02015-03-18 11:13:51 -0700174
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' ] )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700178 main.pingTimeout = 60
kelvin-onlab8a832582015-01-16 17:06:11 -0800179 main.log.report(
Hari Krishnab35c6d02015-03-18 11:13:51 -0700180 "Load Att topology and Balance all Mininet switches across controllers" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800181 main.log.report(
Hari Krishnab35c6d02015-03-18 11:13:51 -0700182 "________________________________________________________________________" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800183 main.case(
184 "Assign and Balance all Mininet switches across controllers" )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700185 main.step( "Stop any previous Mininet network topology" )
186 cliResult = main.TRUE
187 if main.newTopo == main.params['TOPO3']['topo']:
188 stopStatus = main.Mininet1.stopNet( fileName = "topoSpine" )
189
190 main.step( "Start Mininet with Att topology" )
191 main.newTopo = main.params['TOPO1']['topo']
192 startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
193
kelvin-onlab8a832582015-01-16 17:06:11 -0800194 main.step( "Assign switches to controllers" )
Hari Krishna22c3d412015-02-17 16:48:12 -0800195 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
Hari Krishnad97213e2015-01-24 19:30:14 -0800196 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800197 sw=str( i ),
Hari Krishna22c3d412015-02-17 16:48:12 -0800198 count=int( main.numCtrls ),
199 ip1=main.ONOS1_ip,
200 port1=main.ONOS1_port,
201 ip2=main.ONOS2_ip,
202 port2=main.ONOS2_port,
203 ip3=main.ONOS3_ip,
204 port3=main.ONOS3_port,
205 ip4=main.ONOS4_ip,
206 port4=main.ONOS4_port,
207 ip5=main.ONOS5_ip,
208 port5=main.ONOS5_port )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800209
210 switch_mastership = main.TRUE
Hari Krishna22c3d412015-02-17 16:48:12 -0800211 for i in range( 1, ( main.numMNswitches + 1 ) ):
Hari Krishnad97213e2015-01-24 19:30:14 -0800212 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800213 print( "Response is " + str( response ) )
Hari Krishna22c3d412015-02-17 16:48:12 -0800214 if re.search( "tcp:" + main.ONOS1_ip, response ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800215 switch_mastership = switch_mastership and main.TRUE
216 else:
217 switch_mastership = main.FALSE
218
219 if switch_mastership == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800220 main.log.report( "Controller assignment successfull" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800221 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800222 main.log.report( "Controller assignment failed" )
kelvin-onlab77d6c302015-03-31 11:33:32 -0700223
224 """topoFailed = main.FALSE
225 checkCount = 0
226 while(topoFailed == main.FALSE):
227 topology_output = main.ONOScli1.topology()
228 topology_result = main.ONOSbench.getTopology( topology_output )
229 numOnosDevices = topology_result[ 'deviceCount' ]
230 numOnosLinks = topology_result[ 'linkCount' ]
231 if ( ( main.numMNswitches == int(numOnosDevices) ) and ( main.numMNlinks >= int(numOnosLinks) ) ):
232 main.log.info("Att topology is now ready!")
233 break
234 else:
235 main.log.info("Att topology is not ready yet!")
236 checkCount = checkCount + 1
237 time.sleep(2)
238 if checkCount == 10:
239 topoFailed = main.TRUE
240 if topoFailed:
241 main.log.info("Att topology failed to start correctly")
Hari Krishnab35c6d02015-03-18 11:13:51 -0700242 """
kelvin-onlab77d6c302015-03-31 11:33:32 -0700243 time.sleep(15)
244 #Don't balance master for now..
Hari Krishnab35c6d02015-03-18 11:13:51 -0700245 main.step( "Balance devices across controllers" )
246 for i in range( int( main.numCtrls ) ):
247 balanceResult = main.ONOScli1.balanceMasters()
kelvin-onlab8a832582015-01-16 17:06:11 -0800248 # giving some breathing time for ONOS to complete re-balance
Hari Krishnab35c6d02015-03-18 11:13:51 -0700249 time.sleep( 3 )
kelvin-onlab77d6c302015-03-31 11:33:32 -0700250 topology_output = main.ONOScli1.topology()
251 topology_result = main.ONOSbench.getTopology( topology_output )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700252 case2Result = ( switch_mastership and startStatus )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700253 utilities.assert_equals(
254 expect=main.TRUE,
255 actual=case2Result,
256 onpass="Starting new Att topology test PASS",
257 onfail="Starting new Att topology test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800258
kelvin-onlab65a72d22015-03-26 13:46:32 -0700259 def CASE21( self, main ):
260 """
261 This test script Loads a new Topology (Chordal) on CHO setup and balances all switches
262 """
263 import re
264 import time
265 import copy
266
267 main.newTopo = main.params['TOPO2']['topo']
268 main.numMNswitches = int ( main.params[ 'TOPO2' ][ 'numSwitches' ] )
269 main.numMNlinks = int ( main.params[ 'TOPO2' ][ 'numLinks' ] )
270 main.numMNhosts = int ( main.params[ 'TOPO2' ][ 'numHosts' ] )
271 main.pingTimeout = 120
272 main.log.report(
273 "Load Chordal topology and Balance all Mininet switches across controllers" )
274 main.log.report(
275 "________________________________________________________________________" )
276 main.case(
277 "Assign and Balance all Mininet switches across controllers" )
278 main.step( "Stop any previous Mininet network topology" )
kelvin-onlabb9408212015-04-01 13:34:04 -0700279 stopStatus = main.Mininet1.stopNet(fileName = "topoChordal" )
kelvin-onlab65a72d22015-03-26 13:46:32 -0700280 #time.sleep(10)
281 main.step( "Start Mininet with Chordal topology" )
282 startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
283 time.sleep(15)
284 main.step( "Assign switches to controllers" )
285 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
286 main.Mininet1.assignSwController(
287 sw=str( i ),
288 count=int( main.numCtrls ),
289 ip1=main.ONOS1_ip,
290 port1=main.ONOS1_port,
291 ip2=main.ONOS2_ip,
292 port2=main.ONOS2_port,
293 ip3=main.ONOS3_ip,
294 port3=main.ONOS3_port,
295 ip4=main.ONOS4_ip,
296 port4=main.ONOS4_port,
297 ip5=main.ONOS5_ip,
298 port5=main.ONOS5_port )
299
300 switch_mastership = main.TRUE
301 for i in range( 1, ( main.numMNswitches + 1 ) ):
302 response = main.Mininet1.getSwController( "s" + str( i ) )
303 print( "Response is " + str( response ) )
304 if re.search( "tcp:" + main.ONOS1_ip, response ):
305 switch_mastership = switch_mastership and main.TRUE
306 else:
307 switch_mastership = main.FALSE
308
309 if switch_mastership == main.TRUE:
310 main.log.report( "Controller assignment successfull" )
311 else:
312 main.log.report( "Controller assignment failed" )
313 time.sleep( 5 )
314
315 #Don't balance master for now..
316 """
317 main.step( "Balance devices across controllers" )
318 for i in range( int( main.numCtrls ) ):
319 balanceResult = main.ONOScli1.balanceMasters()
320 # giving some breathing time for ONOS to complete re-balance
321 time.sleep( 3 )
322 """
323 case21Result = switch_mastership
324 time.sleep(30)
325 utilities.assert_equals(
326 expect=main.TRUE,
327 actual=case21Result,
328 onpass="Starting new Chordal topology test PASS",
329 onfail="Starting new Chordal topology test FAIL" )
330
331 def CASE22( self, main ):
332 """
333 This test script Loads a new Topology (Spine) on CHO setup and balances all switches
334 """
335 import re
336 import time
337 import copy
338
339 main.newTopo = main.params['TOPO3']['topo']
340 main.numMNswitches = int ( main.params[ 'TOPO3' ][ 'numSwitches' ] )
341 main.numMNlinks = int ( main.params[ 'TOPO3' ][ 'numLinks' ] )
342 main.numMNhosts = int ( main.params[ 'TOPO3' ][ 'numHosts' ] )
343 main.pingTimeout = 400
344
345 main.log.report(
346 "Load Spine and Leaf topology and Balance all Mininet switches across controllers" )
347 main.log.report(
348 "________________________________________________________________________" )
349 # need to wait here for sometime until ONOS bootup
350 main.case(
351 "Assign and Balance all Mininet switches across controllers" )
352 main.step( "Stop any previous Mininet network topology" )
kelvin-onlabb9408212015-04-01 13:34:04 -0700353 stopStatus = main.Mininet1.stopNet(fileName = "topoSpine" )
kelvin-onlab65a72d22015-03-26 13:46:32 -0700354 main.step( "Start Mininet with Spine topology" )
355 startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
356 time.sleep(20)
357 main.step( "Assign switches to controllers" )
358 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
359 main.Mininet1.assignSwController(
360 sw=str( i ),
361 count= 1,
362 ip1=main.ONOS1_ip,
363 port1=main.ONOS1_port,
364 ip2=main.ONOS2_ip,
365 port2=main.ONOS2_port,
366 ip3=main.ONOS3_ip,
367 port3=main.ONOS3_port,
368 ip4=main.ONOS4_ip,
369 port4=main.ONOS4_port,
370 ip5=main.ONOS5_ip,
371 port5=main.ONOS5_port )
372
373 switch_mastership = main.TRUE
374 for i in range( 1, ( main.numMNswitches + 1 ) ):
375 response = main.Mininet1.getSwController( "s" + str( i ) )
376 print( "Response is " + str( response ) )
377 if re.search( "tcp:" + main.ONOS1_ip, response ):
378 switch_mastership = switch_mastership and main.TRUE
379 else:
380 switch_mastership = main.FALSE
381
382 if switch_mastership == main.TRUE:
383 main.log.report( "Controller assignment successfull" )
384 else:
385 main.log.report( "Controller assignment failed" )
386 time.sleep( 5 )
387 """
388 main.step( "Balance devices across controllers" )
389
390 for i in range( int( main.numCtrls ) ):
391 balanceResult = main.ONOScli1.balanceMasters()
392 # giving some breathing time for ONOS to complete re-balance
393 time.sleep( 3 )
394
395 main.step( "Balance devices across controllers" )
396 for i in range( int( main.numCtrls ) ):
397 balanceResult = main.ONOScli1.balanceMasters()
398 # giving some breathing time for ONOS to complete re-balance
399 time.sleep( 3 )
400 """
401 case22Result = switch_mastership
402 time.sleep(30)
403 utilities.assert_equals(
404 expect=main.TRUE,
405 actual=case22Result,
406 onpass="Starting new Spine topology test PASS",
407 onfail="Starting new Spine topology test FAIL" )
408
kelvin-onlab8a832582015-01-16 17:06:11 -0800409 def CASE3( self, main ):
410 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800411 This Test case will be extended to collect and store more data related
412 ONOS state.
kelvin-onlab8a832582015-01-16 17:06:11 -0800413 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800414 import re
415 import copy
Hari Krishna22c3d412015-02-17 16:48:12 -0800416 main.deviceDPIDs = []
417 main.hostMACs = []
418 main.deviceLinks = []
419 main.deviceActiveLinksCount = []
420 main.devicePortsEnabledCount = []
kelvin-onlab54400a92015-02-26 18:05:51 -0800421
kelvin-onlab8a832582015-01-16 17:06:11 -0800422 main.log.report(
423 "Collect and Store topology details from ONOS before running any Tests" )
424 main.log.report(
425 "____________________________________________________________________" )
Hari Krishna5afb4cc2015-03-23 15:35:15 -0700426 main.case( "Collect and Store Topology Details from ONOS" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800427 main.step( "Collect and store current number of switches and links" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800428 topology_output = main.ONOScli1.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800429 topology_result = main.ONOSbench.getTopology( topology_output )
Hari Krishnaef1bd4e2015-03-12 16:55:30 -0700430 numOnosDevices = topology_result[ 'deviceCount' ]
431 numOnosLinks = topology_result[ 'linkCount' ]
Hari Krishnab35c6d02015-03-18 11:13:51 -0700432 topoResult = main.TRUE
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800433
kelvin-onlab54400a92015-02-26 18:05:51 -0800434 if ( ( main.numMNswitches == int(numOnosDevices) ) and ( main.numMNlinks >= int(numOnosLinks) ) ):
Hari Krishna22c3d412015-02-17 16:48:12 -0800435 main.step( "Store Device DPIDs" )
436 for i in range( 1, (main.numMNswitches+1) ):
437 main.deviceDPIDs.append( "of:00000000000000" + format( i, '02x' ) )
438 print "Device DPIDs in Store: \n", str( main.deviceDPIDs )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800439
Hari Krishna22c3d412015-02-17 16:48:12 -0800440 main.step( "Store Host MACs" )
441 for i in range( 1, ( main.numMNhosts + 1 ) ):
442 main.hostMACs.append( "00:00:00:00:00:" + format( i, '02x' ) + "/-1" )
443 print "Host MACs in Store: \n", str( main.hostMACs )
Hari Krishna5afb4cc2015-03-23 15:35:15 -0700444 main.MACsDict = {}
kelvin-onlab65a72d22015-03-26 13:46:32 -0700445 print "Creating dictionary of DPID and HostMacs"
446 for i in range(len(main.hostMACs)):
Hari Krishna5afb4cc2015-03-23 15:35:15 -0700447 main.MACsDict[main.deviceDPIDs[i]] = main.hostMACs[i].split('/')[0]
448 print main.MACsDict
Hari Krishna22c3d412015-02-17 16:48:12 -0800449 main.step( "Collect and store all Devices Links" )
450 linksResult = main.ONOScli1.links( jsonFormat=False )
451 ansi_escape = re.compile( r'\x1b[^m]*m' )
452 linksResult = ansi_escape.sub( '', linksResult )
453 linksResult = linksResult.replace( " links", "" ).replace( "\r\r", "" )
454 linksResult = linksResult.splitlines()
455 linksResult = linksResult[ 1: ]
456 main.deviceLinks = copy.copy( linksResult )
457 print "Device Links Stored: \n", str( main.deviceLinks )
458 # this will be asserted to check with the params provided count of
459 # links
460 print "Length of Links Store", len( main.deviceLinks )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800461
Hari Krishna22c3d412015-02-17 16:48:12 -0800462 main.step( "Collect and store each Device ports enabled Count" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800463 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800464 for i in xrange(1,(main.numMNswitches + 1), int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800465 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800466 for cli in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -0800467 dpid = "of:00000000000000" + format( i,'02x' )
468 t = main.Thread(target = cli.getDevicePortsEnabledCount,threadID = main.threadID, name = "getDevicePortsEnabledCount",args = [dpid])
469 t.start()
470 pool.append(t)
471 i = i + 1
472 main.threadID = main.threadID + 1
473 for thread in pool:
474 thread.join()
475 portResult = thread.result
476 portTemp = re.split( r'\t+', portResult )
477 portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
478 main.devicePortsEnabledCount.append( portCount )
Hari Krishna22c3d412015-02-17 16:48:12 -0800479 print "Device Enabled Port Counts Stored: \n", str( main.devicePortsEnabledCount )
kelvin-onlab54400a92015-02-26 18:05:51 -0800480 time2 = time.time()
481 main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1))
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800482
Hari Krishna22c3d412015-02-17 16:48:12 -0800483 main.step( "Collect and store each Device active links Count" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800484 time1 = time.time()
485
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800486 for i in xrange( 1,( main.numMNswitches + 1 ), int( main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800487 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800488 for cli in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -0800489 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800490 t = main.Thread( target = cli.getDeviceLinksActiveCount,
491 threadID = main.threadID,
492 name = "getDevicePortsEnabledCount",
493 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800494 t.start()
495 pool.append(t)
496 i = i + 1
497 main.threadID = main.threadID + 1
498 for thread in pool:
499 thread.join()
500 linkCountResult = thread.result
501 linkCountTemp = re.split( r'\t+', linkCountResult )
502 linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
503 main.deviceActiveLinksCount.append( linkCount )
504 print "Device Active Links Count Stored: \n", str( main.deviceActiveLinksCount )
505 time2 = time.time()
506 main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800507
508 else:
509 main.log.info("Devices (expected): %s, Links (expected): %s" %
510 ( str( main.numMNswitches ), str( main.numMNlinks ) ) )
511 main.log.info("Devices (actual): %s, Links (actual): %s" %
512 ( numOnosDevices , numOnosLinks ) )
513 main.log.info("Topology does not match, exiting CHO test...")
Hari Krishnab35c6d02015-03-18 11:13:51 -0700514 topoResult = main.FALSE
515
kelvin-onlab54400a92015-02-26 18:05:51 -0800516 #time.sleep(300)
Hari Krishnab35c6d02015-03-18 11:13:51 -0700517 #main.cleanup()
518 #main.exit()
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800519
kelvin-onlab8a832582015-01-16 17:06:11 -0800520 # just returning TRUE for now as this one just collects data
Hari Krishnab35c6d02015-03-18 11:13:51 -0700521 case3Result = topoResult
Hari Krishna22c3d412015-02-17 16:48:12 -0800522 utilities.assert_equals( expect=main.TRUE, actual=case3Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800523 onpass="Saving ONOS topology data test PASS",
524 onfail="Saving ONOS topology data test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800525
kelvin-onlab65a72d22015-03-26 13:46:32 -0700526 def CASE40( self, main ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800527 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700528 Verify Reactive forwarding (Att Topology)
kelvin-onlab8a832582015-01-16 17:06:11 -0800529 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800530 import re
531 import copy
532 import time
Hari Krishnab35c6d02015-03-18 11:13:51 -0700533 main.log.report( "Verify Reactive forwarding (Att Topology)" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800534 main.log.report( "______________________________________________" )
535 main.case( "Enable Reactive forwarding and Verify ping all" )
536 main.step( "Enable Reactive forwarding" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800537 installResult = main.TRUE
kelvin-onlab06ade552015-03-31 18:09:27 -0700538 # Activate fwd app
539 appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700540 appCheck = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800541 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800542 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700543 t = main.Thread( target=cli.appToIDCheck,
544 name="appToIDCheck-" + str( i ),
545 args=[] )
546 pool.append( t )
kelvin-onlab54400a92015-02-26 18:05:51 -0800547 t.start()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800548 for t in pool:
549 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700550 appCheck = appCheck and t.result
551 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
552 onpass="App Ids seem to be correct",
553 onfail="Something is wrong with app Ids" )
554 if appCheck != main.TRUE:
555 main.log.warn( main.CLIs[0].apps() )
556 main.log.warn( main.CLIs[0].appIDs() )
557
558 time.sleep( 10 )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800559
kelvin-onlab8a832582015-01-16 17:06:11 -0800560 main.step( "Verify Pingall" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800561 ping_result = main.FALSE
562 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -0700563 ping_result = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800564 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800565 timeDiff = round( ( time2 - time1 ), 2 )
566 main.log.report(
567 "Time taken for Ping All: " +
568 str( timeDiff ) +
569 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800570
571 if ping_result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800572 main.log.report( "Pingall Test in Reactive mode successful" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800573 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800574 main.log.report( "Pingall Test in Reactive mode failed" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800575
kelvin-onlab8a832582015-01-16 17:06:11 -0800576 main.step( "Disable Reactive forwarding" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700577
578 main.log.info( "Uninstall reactive forwarding app" )
579 appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800580 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800581 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700582 t = main.Thread( target=cli.appToIDCheck,
583 name="appToIDCheck-" + str( i ),
584 args=[] )
585 pool.append( t )
kelvin-onlab54400a92015-02-26 18:05:51 -0800586 t.start()
kelvin-onlab06ade552015-03-31 18:09:27 -0700587
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800588 for t in pool:
589 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700590 appCheck = appCheck and t.result
591 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
592 onpass="App Ids seem to be correct",
593 onfail="Something is wrong with app Ids" )
594 if appCheck != main.TRUE:
595 main.log.warn( main.CLIs[0].apps() )
596 main.log.warn( main.CLIs[0].appIDs() )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800597
kelvin-onlab8a832582015-01-16 17:06:11 -0800598 # Waiting for reative flows to be cleared.
kelvin-onlab06ade552015-03-31 18:09:27 -0700599 time.sleep( 10 )
600 case40Result = installResult and uninstallResult and ping_result
601 utilities.assert_equals( expect=main.TRUE, actual=case40Result,
Hari Krishnab35c6d02015-03-18 11:13:51 -0700602 onpass="Reactive Mode Pingall test PASS",
603 onfail="Reactive Mode Pingall test FAIL" )
604
605 def CASE41( self, main ):
606 """
607 Verify Reactive forwarding (Chordal Topology)
608 """
609 import re
610 import copy
611 import time
612 main.log.report( "Verify Reactive forwarding (Chordal Topology)" )
613 main.log.report( "______________________________________________" )
614 main.case( "Enable Reactive forwarding and Verify ping all" )
615 main.step( "Enable Reactive forwarding" )
616 installResult = main.TRUE
kelvin-onlab06ade552015-03-31 18:09:27 -0700617 # Activate fwd app
618 appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" )
619
620 appCheck = main.TRUE
Hari Krishnab35c6d02015-03-18 11:13:51 -0700621 pool = []
Hari Krishnab35c6d02015-03-18 11:13:51 -0700622 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700623 t = main.Thread( target=cli.appToIDCheck,
624 name="appToIDCheck-" + str( i ),
625 args=[] )
626 pool.append( t )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700627 t.start()
Hari Krishnab35c6d02015-03-18 11:13:51 -0700628 for t in pool:
629 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700630 appCheck = appCheck and t.result
631 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
632 onpass="App Ids seem to be correct",
633 onfail="Something is wrong with app Ids" )
634 if appCheck != main.TRUE:
635 main.log.warn( main.CLIs[0].apps() )
636 main.log.warn( main.CLIs[0].appIDs() )
637
638 time.sleep( 10 )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700639
640 main.step( "Verify Pingall" )
641 ping_result = main.FALSE
642 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -0700643 ping_result = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
Hari Krishnab35c6d02015-03-18 11:13:51 -0700644 time2 = time.time()
645 timeDiff = round( ( time2 - time1 ), 2 )
646 main.log.report(
647 "Time taken for Ping All: " +
648 str( timeDiff ) +
649 " seconds" )
650
651 if ping_result == main.TRUE:
652 main.log.report( "Pingall Test in Reactive mode successful" )
653 else:
654 main.log.report( "Pingall Test in Reactive mode failed" )
655
656 main.step( "Disable Reactive forwarding" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700657
658 main.log.info( "Uninstall reactive forwarding app" )
659 appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700660 pool = []
Hari Krishnab35c6d02015-03-18 11:13:51 -0700661 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700662 t = main.Thread( target=cli.appToIDCheck,
663 name="appToIDCheck-" + str( i ),
664 args=[] )
665 pool.append( t )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700666 t.start()
kelvin-onlab06ade552015-03-31 18:09:27 -0700667
Hari Krishnab35c6d02015-03-18 11:13:51 -0700668 for t in pool:
669 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700670 appCheck = appCheck and t.result
671 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
672 onpass="App Ids seem to be correct",
673 onfail="Something is wrong with app Ids" )
674 if appCheck != main.TRUE:
675 main.log.warn( main.CLIs[0].apps() )
676 main.log.warn( main.CLIs[0].appIDs() )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700677
678 # Waiting for reative flows to be cleared.
kelvin-onlab06ade552015-03-31 18:09:27 -0700679 time.sleep( 10 )
680 case41Result = installResult and uninstallResult and ping_result
681 utilities.assert_equals( expect=main.TRUE, actual=case41Result,
Hari Krishnab35c6d02015-03-18 11:13:51 -0700682 onpass="Reactive Mode Pingall test PASS",
683 onfail="Reactive Mode Pingall test FAIL" )
684
685 def CASE42( self, main ):
686 """
687 Verify Reactive forwarding (Spine Topology)
688 """
689 import re
690 import copy
691 import time
692 main.log.report( "Verify Reactive forwarding (Spine Topology)" )
693 main.log.report( "______________________________________________" )
694 main.case( "Enable Reactive forwarding and Verify ping all" )
695 main.step( "Enable Reactive forwarding" )
696 installResult = main.TRUE
kelvin-onlab06ade552015-03-31 18:09:27 -0700697 # Activate fwd app
698 appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" )
699
700 appCheck = main.TRUE
Hari Krishnab35c6d02015-03-18 11:13:51 -0700701 pool = []
Hari Krishnab35c6d02015-03-18 11:13:51 -0700702 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700703 t = main.Thread( target=cli.appToIDCheck,
704 name="appToIDCheck-" + str( i ),
705 args=[] )
706 pool.append( t )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700707 t.start()
Hari Krishnab35c6d02015-03-18 11:13:51 -0700708 for t in pool:
709 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700710 appCheck = appCheck and t.result
711 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
712 onpass="App Ids seem to be correct",
713 onfail="Something is wrong with app Ids" )
714 if appCheck != main.TRUE:
715 main.log.warn( main.CLIs[0].apps() )
716 main.log.warn( main.CLIs[0].appIDs() )
717
718 time.sleep( 10 )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700719
720 main.step( "Verify Pingall" )
721 ping_result = main.FALSE
722 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -0700723 ping_result = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
Hari Krishnab35c6d02015-03-18 11:13:51 -0700724 time2 = time.time()
725 timeDiff = round( ( time2 - time1 ), 2 )
726 main.log.report(
727 "Time taken for Ping All: " +
728 str( timeDiff ) +
729 " seconds" )
730
731 if ping_result == main.TRUE:
732 main.log.report( "Pingall Test in Reactive mode successful" )
733 else:
734 main.log.report( "Pingall Test in Reactive mode failed" )
735
736 main.step( "Disable Reactive forwarding" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700737
738 main.log.info( "Uninstall reactive forwarding app" )
739 appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700740 pool = []
Hari Krishnab35c6d02015-03-18 11:13:51 -0700741 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700742 t = main.Thread( target=cli.appToIDCheck,
743 name="appToIDCheck-" + str( i ),
744 args=[] )
745 pool.append( t )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700746 t.start()
kelvin-onlab06ade552015-03-31 18:09:27 -0700747
Hari Krishnab35c6d02015-03-18 11:13:51 -0700748 for t in pool:
749 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700750 appCheck = appCheck and t.result
751 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
752 onpass="App Ids seem to be correct",
753 onfail="Something is wrong with app Ids" )
754 if appCheck != main.TRUE:
755 main.log.warn( main.CLIs[0].apps() )
756 main.log.warn( main.CLIs[0].appIDs() )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700757
758 # Waiting for reative flows to be cleared.
kelvin-onlab06ade552015-03-31 18:09:27 -0700759 time.sleep( 10 )
760 case42Result = installResult and uninstallResult and ping_result
761 utilities.assert_equals( expect=main.TRUE, actual=case42Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800762 onpass="Reactive Mode Pingall test PASS",
763 onfail="Reactive Mode Pingall test FAIL" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700764
kelvin-onlab8a832582015-01-16 17:06:11 -0800765 def CASE5( self, main ):
766 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800767 Compare current ONOS topology with reference data
kelvin-onlab8a832582015-01-16 17:06:11 -0800768 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800769 import re
kelvin-onlab54400a92015-02-26 18:05:51 -0800770
Hari Krishna22c3d412015-02-17 16:48:12 -0800771 devicesDPIDTemp = []
772 hostMACsTemp = []
773 deviceLinksTemp = []
774 deviceActiveLinksCountTemp = []
775 devicePortsEnabledCountTemp = []
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800776
kelvin-onlab8a832582015-01-16 17:06:11 -0800777 main.log.report(
778 "Compare ONOS topology with reference data in Stores" )
779 main.log.report( "__________________________________________________" )
780 main.case( "Compare ONOS topology with reference data" )
781
782 main.step( "Compare current Device ports enabled with reference" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800783 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800784 for i in xrange( 1,(main.numMNswitches + 1), int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800785 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800786 for cli in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -0800787 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800788 t = main.Thread(target = cli.getDevicePortsEnabledCount,
789 threadID = main.threadID,
790 name = "getDevicePortsEnabledCount",
791 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800792 t.start()
793 pool.append(t)
794 i = i + 1
795 main.threadID = main.threadID + 1
796 for thread in pool:
797 thread.join()
798 portResult = thread.result
799 portTemp = re.split( r'\t+', portResult )
800 portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
801 devicePortsEnabledCountTemp.append( portCount )
802 print "Device Enabled Port Counts Stored: \n", str( main.devicePortsEnabledCount )
803 time2 = time.time()
804 main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800805 main.log.info (
806 "Device Enabled ports EXPECTED: %s" %
807 str( main.devicePortsEnabledCount ) )
808 main.log.info (
809 "Device Enabled ports ACTUAL: %s" %
810 str( devicePortsEnabledCountTemp ) )
kelvin-onlab54400a92015-02-26 18:05:51 -0800811
Hari Krishna22c3d412015-02-17 16:48:12 -0800812 if ( cmp( main.devicePortsEnabledCount,
813 devicePortsEnabledCountTemp ) == 0 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800814 stepResult1 = main.TRUE
815 else:
816 stepResult1 = main.FALSE
817
kelvin-onlab8a832582015-01-16 17:06:11 -0800818 main.step( "Compare Device active links with reference" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800819 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800820 for i in xrange( 1, ( main.numMNswitches + 1) , int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800821 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800822 for cli in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -0800823 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800824 t = main.Thread(target = cli.getDeviceLinksActiveCount,
825 threadID = main.threadID,
826 name = "getDevicePortsEnabledCount",
827 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800828 t.start()
829 pool.append(t)
830 i = i + 1
831 main.threadID = main.threadID + 1
832 for thread in pool:
833 thread.join()
834 linkCountResult = thread.result
835 linkCountTemp = re.split( r'\t+', linkCountResult )
836 linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
837 deviceActiveLinksCountTemp.append( linkCount )
838 print "Device Active Links Count Stored: \n", str( main.deviceActiveLinksCount )
839 time2 = time.time()
840 main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800841 main.log.info (
842 "Device Active links EXPECTED: %s" %
843 str( main.deviceActiveLinksCount ) )
844 main.log.info (
845 "Device Active links ACTUAL: %s" % str( deviceActiveLinksCountTemp ) )
846 if ( cmp( main.deviceActiveLinksCount, deviceActiveLinksCountTemp ) == 0 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800847 stepResult2 = main.TRUE
848 else:
849 stepResult2 = main.FALSE
850
kelvin-onlab8a832582015-01-16 17:06:11 -0800851 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800852 place holder for comparing devices, hosts, paths and intents if required.
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800853 Links and ports data would be incorrect with out devices anyways.
kelvin-onlab8a832582015-01-16 17:06:11 -0800854 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800855 case5Result = ( stepResult1 and stepResult2 )
856 utilities.assert_equals( expect=main.TRUE, actual=case5Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800857 onpass="Compare Topology test PASS",
858 onfail="Compare Topology test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800859
kelvin-onlab65a72d22015-03-26 13:46:32 -0700860 def CASE60( self ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800861 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700862 Install 300 host intents and verify ping all (Att Topology)
kelvin-onlab8a832582015-01-16 17:06:11 -0800863 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700864 main.log.report( "Add 300 host intents and verify pingall (Att Topology)" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800865 main.log.report( "_______________________________________" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800866 import itertools
Hari Krishnaef1bd4e2015-03-12 16:55:30 -0700867 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800868 main.case( "Install 300 host intents" )
869 main.step( "Add host Intents" )
870 intentResult = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800871 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800872
kelvin-onlab54400a92015-02-26 18:05:51 -0800873 intentIdList = []
874 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800875 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800876 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800877 for cli in main.CLIs:
878 if i >= len( hostCombos ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800879 break
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800880 t = main.Thread( target=cli.addHostIntent,
881 threadID=main.threadID,
kelvin-onlab54400a92015-02-26 18:05:51 -0800882 name="addHostIntent",
883 args=[hostCombos[i][0],hostCombos[i][1]])
884 pool.append(t)
885 t.start()
886 i = i + 1
887 main.threadID = main.threadID + 1
888 for thread in pool:
889 thread.join()
890 intentIdList.append(thread.result)
891 time2 = time.time()
kelvin-onlabadfc8db2015-03-24 15:52:48 -0700892 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
893
kelvin-onlab54400a92015-02-26 18:05:51 -0800894 intentResult = main.TRUE
895 intentsJson = main.ONOScli2.intents()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800896 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
kelvin-onlab54400a92015-02-26 18:05:51 -0800897 intentsJson = intentsJson)
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800898 print getIntentStateResult
Hari Krishnab35c6d02015-03-18 11:13:51 -0700899 # Takes awhile for all the onos to get the intents
Hari Krishnaef1bd4e2015-03-12 16:55:30 -0700900 time.sleep(30)
kelvin-onlab8a832582015-01-16 17:06:11 -0800901 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800902 pingResult = main.FALSE
903 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -0700904 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800905 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800906 timeDiff = round( ( time2 - time1 ), 2 )
907 main.log.report(
908 "Time taken for Ping All: " +
909 str( timeDiff ) +
910 " seconds" )
911 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
912 onpass="PING ALL PASS",
913 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800914
kelvin-onlab65a72d22015-03-26 13:46:32 -0700915 case60Result = ( intentResult and pingResult )
kelvin-onlab54400a92015-02-26 18:05:51 -0800916
kelvin-onlab8a832582015-01-16 17:06:11 -0800917 utilities.assert_equals(
918 expect=main.TRUE,
kelvin-onlab65a72d22015-03-26 13:46:32 -0700919 actual=case60Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800920 onpass="Install 300 Host Intents and Ping All test PASS",
921 onfail="Install 300 Host Intents and Ping All test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800922
kelvin-onlab65a72d22015-03-26 13:46:32 -0700923 def CASE61( self ):
924 """
925 Install 600 host intents and verify ping all for Chordal Topology
926 """
927 main.log.report( "Add 600 host intents and verify pingall (Chordal Topo)" )
928 main.log.report( "_______________________________________" )
929 import itertools
930
931 main.case( "Install 600 host intents" )
932 main.step( "Add host Intents" )
933 intentResult = main.TRUE
934 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
935
936 intentIdList = []
937 time1 = time.time()
938
939 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
940 pool = []
941 for cli in main.CLIs:
942 if i >= len( hostCombos ):
943 break
944 t = main.Thread( target=cli.addHostIntent,
945 threadID=main.threadID,
946 name="addHostIntent",
947 args=[hostCombos[i][0],hostCombos[i][1]])
948 pool.append(t)
949 t.start()
950 i = i + 1
951 main.threadID = main.threadID + 1
952 for thread in pool:
953 thread.join()
954 intentIdList.append(thread.result)
955 time2 = time.time()
956 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
957 intentResult = main.TRUE
958 intentsJson = main.ONOScli2.intents()
959 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
960 intentsJson = intentsJson)
961 print getIntentStateResult
962
963 main.step( "Verify Ping across all hosts" )
964 pingResult = main.FALSE
965 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -0700966 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin-onlab65a72d22015-03-26 13:46:32 -0700967 time2 = time.time()
968 timeDiff = round( ( time2 - time1 ), 2 )
969 main.log.report(
970 "Time taken for Ping All: " +
971 str( timeDiff ) +
972 " seconds" )
973 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
974 onpass="PING ALL PASS",
975 onfail="PING ALL FAIL" )
976
977 case14Result = ( intentResult and pingResult )
978
979 utilities.assert_equals(
980 expect=main.TRUE,
981 actual=case14Result,
982 onpass="Install 300 Host Intents and Ping All test PASS",
983 onfail="Install 300 Host Intents and Ping All test FAIL" )
984
985 def CASE62( self ):
986 """
987 Install 2278 host intents and verify ping all for Spine Topology
988 """
989 main.log.report( "Add 2278 host intents and verify pingall (Spine Topo)" )
990 main.log.report( "_______________________________________" )
991 import itertools
992
993 main.case( "Install 2278 host intents" )
994 main.step( "Add host Intents" )
995 intentResult = main.TRUE
996 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
997 main.pingTimeout = 300
998 intentIdList = []
999 time1 = time.time()
1000 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
1001 pool = []
1002 for cli in main.CLIs:
1003 if i >= len( hostCombos ):
1004 break
1005 t = main.Thread( target=cli.addHostIntent,
1006 threadID=main.threadID,
1007 name="addHostIntent",
1008 args=[hostCombos[i][0],hostCombos[i][1]])
1009 pool.append(t)
1010 t.start()
1011 i = i + 1
1012 main.threadID = main.threadID + 1
1013 for thread in pool:
1014 thread.join()
1015 intentIdList.append(thread.result)
1016 time2 = time.time()
1017 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
1018 intentResult = main.TRUE
1019 intentsJson = main.ONOScli2.intents()
1020 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1021 intentsJson = intentsJson)
1022 print getIntentStateResult
1023
1024 main.step( "Verify Ping across all hosts" )
1025 pingResult = main.FALSE
1026 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001027 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin-onlab65a72d22015-03-26 13:46:32 -07001028 time2 = time.time()
1029 timeDiff = round( ( time2 - time1 ), 2 )
1030 main.log.report(
1031 "Time taken for Ping All: " +
1032 str( timeDiff ) +
1033 " seconds" )
1034 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1035 onpass="PING ALL PASS",
1036 onfail="PING ALL FAIL" )
1037
1038 case15Result = ( intentResult and pingResult )
1039
1040 utilities.assert_equals(
1041 expect=main.TRUE,
1042 actual=case15Result,
1043 onpass="Install 2278 Host Intents and Ping All test PASS",
1044 onfail="Install 2278 Host Intents and Ping All test FAIL" )
1045
kelvin-onlab8a832582015-01-16 17:06:11 -08001046 def CASE70( self, main ):
1047 """
Hari Krishnab35c6d02015-03-18 11:13:51 -07001048 Randomly bring some core links down and verify ping all ( Host Intents-Att Topo)
kelvin-onlab8a832582015-01-16 17:06:11 -08001049 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001050 import random
Hari Krishna22c3d412015-02-17 16:48:12 -08001051 main.randomLink1 = []
1052 main.randomLink2 = []
1053 main.randomLink3 = []
kelvin-onlab65a72d22015-03-26 13:46:32 -07001054 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1055 link1End2 = main.params[ 'ATTCORELINKS' ][ 'linkS3b' ].split( ',' )
1056 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1057 link2End2 = main.params[ 'ATTCORELINKS' ][ 'linkS14b' ].split( ',' )
1058 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
1059 link3End2 = main.params[ 'ATTCORELINKS' ][ 'linkS18b' ].split( ',' )
1060 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001061 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001062
Hari Krishnab35c6d02015-03-18 11:13:51 -07001063 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Att Topo)" )
1064 main.log.report( "___________________________________________________________________________" )
Hari Krishnad97213e2015-01-24 19:30:14 -08001065 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
1066 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001067 if ( int( switchLinksToToggle ) ==
1068 0 or int( switchLinksToToggle ) > 5 ):
Hari Krishna46997e02015-01-27 11:23:07 -08001069 main.log.info( "Please check your PARAMS file. Valid range for number of switch links to toggle is between 1 to 5" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001070 #main.cleanup()
1071 #main.exit()
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001072 else:
Hari Krishnad97213e2015-01-24 19:30:14 -08001073 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 -08001074
kelvin-onlab8a832582015-01-16 17:06:11 -08001075 main.step( "Cut links on Core devices using user provided range" )
Hari Krishna22c3d412015-02-17 16:48:12 -08001076 main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
1077 main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
1078 main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001079 for i in range( int( switchLinksToToggle ) ):
1080 main.Mininet1.link(
1081 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001082 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001083 OPTION="down" )
1084 main.Mininet1.link(
1085 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001086 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001087 OPTION="down" )
1088 main.Mininet1.link(
1089 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001090 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001091 OPTION="down" )
1092 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001093
1094 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001095 linkDown = main.ONOSbench.checkStatus(
Hari Krishna22c3d412015-02-17 16:48:12 -08001096 topology_output, main.numMNswitches, str(
1097 int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001098 utilities.assert_equals(
1099 expect=main.TRUE,
1100 actual=linkDown,
1101 onpass="Link Down discovered properly",
1102 onfail="Link down was not discovered in " +
1103 str( link_sleep ) +
1104 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001105
kelvin-onlab8a832582015-01-16 17:06:11 -08001106 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001107 pingResultLinkDown = main.FALSE
1108 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001109 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001110 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001111 timeDiff = round( ( time2 - time1 ), 2 )
1112 main.log.report(
1113 "Time taken for Ping All: " +
1114 str( timeDiff ) +
1115 " seconds" )
1116 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1117 onpass="PING ALL PASS",
1118 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001119
Hari Krishna22c3d412015-02-17 16:48:12 -08001120 caseResult70 = linkDown and pingResultLinkDown
1121 utilities.assert_equals( expect=main.TRUE, actual=caseResult70,
kelvin-onlab8a832582015-01-16 17:06:11 -08001122 onpass="Random Link cut Test PASS",
1123 onfail="Random Link cut Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001124
kelvin-onlab8a832582015-01-16 17:06:11 -08001125 def CASE80( self, main ):
1126 """
Hari Krishnab35c6d02015-03-18 11:13:51 -07001127 Bring the core links up that are down and verify ping all ( Host Intents-Att Topo )
kelvin-onlab8a832582015-01-16 17:06:11 -08001128 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001129 import random
kelvin-onlab65a72d22015-03-26 13:46:32 -07001130 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1131 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1132 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001133 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001134 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001135
kelvin-onlab8a832582015-01-16 17:06:11 -08001136 main.log.report(
Hari Krishnab35c6d02015-03-18 11:13:51 -07001137 "Bring the core links up that are down and verify ping all (Host Intents-Att Topo" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001138 main.log.report(
1139 "__________________________________________________________________" )
1140 main.case(
1141 "Host intents - Bring the core links up that are down and verify ping all" )
1142 main.step( "Bring randomly cut links on Core devices up" )
1143 for i in range( int( switchLinksToToggle ) ):
1144 main.Mininet1.link(
1145 END1=link1End1,
kelvin-onlab54400a92015-02-26 18:05:51 -08001146 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001147 OPTION="up" )
1148 main.Mininet1.link(
1149 END1=link2End1,
kelvin-onlab54400a92015-02-26 18:05:51 -08001150 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001151 OPTION="up" )
1152 main.Mininet1.link(
1153 END1=link3End1,
kelvin-onlab54400a92015-02-26 18:05:51 -08001154 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001155 OPTION="up" )
1156 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001157
1158 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001159 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -08001160 topology_output,
Hari Krishna22c3d412015-02-17 16:48:12 -08001161 main.numMNswitches,
1162 str( main.numMNlinks ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001163 utilities.assert_equals(
1164 expect=main.TRUE,
1165 actual=linkUp,
1166 onpass="Link up discovered properly",
1167 onfail="Link up was not discovered in " +
1168 str( link_sleep ) +
1169 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001170
kelvin-onlab8a832582015-01-16 17:06:11 -08001171 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001172 pingResultLinkUp = main.FALSE
1173 time1 = time.time()
1174 pingResultLinkUp = main.Mininet1.pingall()
1175 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001176 timeDiff = round( ( time2 - time1 ), 2 )
1177 main.log.report(
1178 "Time taken for Ping All: " +
1179 str( timeDiff ) +
1180 " seconds" )
1181 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1182 onpass="PING ALL PASS",
1183 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001184
Hari Krishna22c3d412015-02-17 16:48:12 -08001185 caseResult80 = linkUp and pingResultLinkUp
1186 utilities.assert_equals( expect=main.TRUE, actual=caseResult80,
kelvin-onlab8a832582015-01-16 17:06:11 -08001187 onpass="Link Up Test PASS",
1188 onfail="Link Up Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001189
kelvin-onlab8a832582015-01-16 17:06:11 -08001190 def CASE71( self, main ):
1191 """
kelvin-onlab65a72d22015-03-26 13:46:32 -07001192 Randomly bring some core links down and verify ping all ( Host Intents-Att Topo)
kelvin-onlab8a832582015-01-16 17:06:11 -08001193 """
kelvin8ec71442015-01-15 16:57:00 -08001194 import random
Hari Krishna22c3d412015-02-17 16:48:12 -08001195 main.randomLink1 = []
1196 main.randomLink2 = []
1197 main.randomLink3 = []
kelvin-onlab65a72d22015-03-26 13:46:32 -07001198 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1199 link1End2 = main.params[ 'ATTCORELINKS' ][ 'linkS3b' ].split( ',' )
1200 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1201 link2End2 = main.params[ 'ATTCORELINKS' ][ 'linkS14b' ].split( ',' )
1202 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
1203 link3End2 = main.params[ 'ATTCORELINKS' ][ 'linkS18b' ].split( ',' )
1204 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001205 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin8ec71442015-01-15 16:57:00 -08001206
kelvin-onlab65a72d22015-03-26 13:46:32 -07001207 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Att Topo)" )
1208 main.log.report( "___________________________________________________________________________" )
1209 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
Hari Krishnad97213e2015-01-24 19:30:14 -08001210 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001211 if ( int( switchLinksToToggle ) ==
1212 0 or int( switchLinksToToggle ) > 5 ):
kelvin-onlab65a72d22015-03-26 13:46:32 -07001213 main.log.info( "Please check your PARAMS file. Valid range for number of switch links to toggle is between 1 to 5" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001214 #main.cleanup()
1215 #main.exit()
kelvin8ec71442015-01-15 16:57:00 -08001216 else:
kelvin-onlab65a72d22015-03-26 13:46:32 -07001217 main.log.info( "User provided Core switch links range to toggle is correct, proceeding to run the test" )
kelvin8ec71442015-01-15 16:57:00 -08001218
kelvin-onlab8a832582015-01-16 17:06:11 -08001219 main.step( "Cut links on Core devices using user provided range" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001220 main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
1221 main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
1222 main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001223 for i in range( int( switchLinksToToggle ) ):
1224 main.Mininet1.link(
1225 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001226 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001227 OPTION="down" )
1228 main.Mininet1.link(
1229 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001230 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001231 OPTION="down" )
1232 main.Mininet1.link(
1233 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001234 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001235 OPTION="down" )
1236 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -08001237
1238 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001239 linkDown = main.ONOSbench.checkStatus(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001240 topology_output, main.numMNswitches, str(
1241 int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001242 utilities.assert_equals(
1243 expect=main.TRUE,
1244 actual=linkDown,
1245 onpass="Link Down discovered properly",
1246 onfail="Link down was not discovered in " +
1247 str( link_sleep ) +
1248 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -08001249
kelvin-onlab8a832582015-01-16 17:06:11 -08001250 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -08001251 pingResultLinkDown = main.FALSE
1252 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001253 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin8ec71442015-01-15 16:57:00 -08001254 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001255 timeDiff = round( ( time2 - time1 ), 2 )
1256 main.log.report(
1257 "Time taken for Ping All: " +
1258 str( timeDiff ) +
1259 " seconds" )
1260 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1261 onpass="PING ALL PASS",
1262 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001263
kelvin-onlab65a72d22015-03-26 13:46:32 -07001264 caseResult71 = linkDown and pingResultLinkDown
1265 utilities.assert_equals( expect=main.TRUE, actual=caseResult71,
kelvin-onlab8a832582015-01-16 17:06:11 -08001266 onpass="Random Link cut Test PASS",
1267 onfail="Random Link cut Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001268
kelvin-onlab8a832582015-01-16 17:06:11 -08001269 def CASE81( self, main ):
1270 """
kelvin-onlab65a72d22015-03-26 13:46:32 -07001271 Bring the core links up that are down and verify ping all ( Host Intents-Att Topo )
kelvin-onlab8a832582015-01-16 17:06:11 -08001272 """
kelvin8ec71442015-01-15 16:57:00 -08001273 import random
kelvin-onlab65a72d22015-03-26 13:46:32 -07001274 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1275 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1276 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001277 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001278 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
kelvin8ec71442015-01-15 16:57:00 -08001279
kelvin-onlab8a832582015-01-16 17:06:11 -08001280 main.log.report(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001281 "Bring the core links up that are down and verify ping all (Host Intents-Att Topo" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001282 main.log.report(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001283 "__________________________________________________________________" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001284 main.case(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001285 "Host intents - Bring the core links up that are down and verify ping all" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001286 main.step( "Bring randomly cut links on Core devices up" )
1287 for i in range( int( switchLinksToToggle ) ):
1288 main.Mininet1.link(
1289 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001290 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001291 OPTION="up" )
1292 main.Mininet1.link(
1293 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001294 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001295 OPTION="up" )
1296 main.Mininet1.link(
1297 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001298 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001299 OPTION="up" )
1300 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -08001301
1302 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001303 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -08001304 topology_output,
Hari Krishna22c3d412015-02-17 16:48:12 -08001305 main.numMNswitches,
1306 str( main.numMNlinks ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001307 utilities.assert_equals(
1308 expect=main.TRUE,
1309 actual=linkUp,
1310 onpass="Link up discovered properly",
1311 onfail="Link up was not discovered in " +
1312 str( link_sleep ) +
1313 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -08001314
kelvin-onlab8a832582015-01-16 17:06:11 -08001315 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -08001316 pingResultLinkUp = main.FALSE
1317 time1 = time.time()
kelvin-onlab77d6c302015-03-31 11:33:32 -07001318 pingResultLinkUp = main.Mininet1.pingall(timeout = main.pingTimeout)
kelvin8ec71442015-01-15 16:57:00 -08001319 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001320 timeDiff = round( ( time2 - time1 ), 2 )
1321 main.log.report(
1322 "Time taken for Ping All: " +
1323 str( timeDiff ) +
1324 " seconds" )
1325 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1326 onpass="PING ALL PASS",
1327 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001328
Hari Krishna22c3d412015-02-17 16:48:12 -08001329 caseResult81 = linkUp and pingResultLinkUp
1330 utilities.assert_equals( expect=main.TRUE, actual=caseResult81,
kelvin-onlab8a832582015-01-16 17:06:11 -08001331 onpass="Link Up Test PASS",
1332 onfail="Link Up Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001333
Hari Krishnab35c6d02015-03-18 11:13:51 -07001334 def CASE72( self, main ):
1335 """
1336 Randomly bring some links down and verify ping all ( Host Intents-Chordal Topo)
1337 """
1338 import random
1339 import itertools
1340 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1341
1342 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Chordal Topo)" )
1343 main.log.report( "___________________________________________________________________________" )
1344 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
1345 switches = []
1346 switchesComb = []
1347 for i in range( main.numMNswitches ):
1348 switches.append('s%d'%(i+1))
1349 switchesLinksComb = list(itertools.combinations(switches,2))
1350 main.randomLinks = random.sample(switchesLinksComb, 5 )
1351 print main.randomLinks
1352 main.step( "Cut links on random devices" )
1353
1354 for switch in main.randomLinks:
1355 main.Mininet1.link(
1356 END1=switch[0],
1357 END2=switch[1],
1358 OPTION="down")
1359 time.sleep( link_sleep )
1360
1361 topology_output = main.ONOScli2.topology()
1362 linkDown = main.ONOSbench.checkStatus(
1363 topology_output, main.numMNswitches, str(
1364 int( main.numMNlinks ) - 5 * 2 ) )
1365 utilities.assert_equals(
1366 expect=main.TRUE,
1367 actual=linkDown,
1368 onpass="Link Down discovered properly",
1369 onfail="Link down was not discovered in " +
1370 str( link_sleep ) +
1371 " seconds" )
1372
1373 main.step( "Verify Ping across all hosts" )
1374 pingResultLinkDown = main.FALSE
1375 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001376 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001377 time2 = time.time()
1378 timeDiff = round( ( time2 - time1 ), 2 )
1379 main.log.report(
1380 "Time taken for Ping All: " +
1381 str( timeDiff ) +
1382 " seconds" )
1383 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1384 onpass="PING ALL PASS",
1385 onfail="PING ALL FAIL" )
1386
kelvin-onlab65a72d22015-03-26 13:46:32 -07001387 caseResult71 = pingResultLinkDown
1388 utilities.assert_equals( expect=main.TRUE, actual=caseResult71,
Hari Krishnab35c6d02015-03-18 11:13:51 -07001389 onpass="Random Link cut Test PASS",
1390 onfail="Random Link cut Test FAIL" )
1391
1392 def CASE82( self, main ):
1393 """
1394 Bring the core links up that are down and verify ping all ( Host Intents Chordal Topo )
1395 """
1396 import random
1397 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1398
1399 main.log.report(
1400 "Bring the core links up that are down and verify ping all (Host Intents-Chordal Topo" )
1401 main.log.report(
1402 "__________________________________________________________________" )
1403 main.case(
1404 "Host intents - Bring the core links up that are down and verify ping all" )
1405 main.step( "Bring randomly cut links on devices up" )
1406
1407 for switch in main.randomLinks:
1408 main.Mininet1.link(
1409 END1=switch[0],
1410 END2=switch[1],
1411 OPTION="up")
1412
1413 time.sleep( link_sleep )
1414
1415 topology_output = main.ONOScli2.topology()
1416 linkUp = main.ONOSbench.checkStatus(
1417 topology_output,
1418 main.numMNswitches,
1419 str( main.numMNlinks ) )
1420 utilities.assert_equals(
1421 expect=main.TRUE,
1422 actual=linkUp,
1423 onpass="Link up discovered properly",
1424 onfail="Link up was not discovered in " +
1425 str( link_sleep ) +
1426 " seconds" )
1427
1428 main.step( "Verify Ping across all hosts" )
1429 pingResultLinkUp = main.FALSE
1430 time1 = time.time()
kelvin-onlab77d6c302015-03-31 11:33:32 -07001431 pingResultLinkUp = main.Mininet1.pingall(timeout = main.pingTimeout)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001432 time2 = time.time()
1433 timeDiff = round( ( time2 - time1 ), 2 )
1434 main.log.report(
1435 "Time taken for Ping All: " +
1436 str( timeDiff ) +
1437 " seconds" )
1438 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1439 onpass="PING ALL PASS",
1440 onfail="PING ALL FAIL" )
1441
1442 caseResult82 = linkUp and pingResultLinkUp
1443 utilities.assert_equals( expect=main.TRUE, actual=caseResult82,
1444 onpass="Link Up Test PASS",
1445 onfail="Link Up Test FAIL" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001446
Hari Krishnab35c6d02015-03-18 11:13:51 -07001447 def CASE73( self, main ):
1448 """
kelvin-onlab65a72d22015-03-26 13:46:32 -07001449 Randomly bring some links down and verify ping all ( Host Intents-Chordal Topo)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001450 """
1451 import random
kelvin-onlab65a72d22015-03-26 13:46:32 -07001452 import itertools
Hari Krishnab35c6d02015-03-18 11:13:51 -07001453 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001454
1455 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Chordal Topo)" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001456 main.log.report( "___________________________________________________________________________" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001457 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
1458 switches = []
1459 switchesComb = []
1460 for i in range( main.numMNswitches ):
1461 switches.append('s%d'%(i+1))
1462 switchesLinksComb = list(itertools.combinations(switches,2))
1463 main.randomLinks = random.sample(switchesLinksComb, 5 )
1464 print main.randomLinks
1465 main.step( "Cut links on random devices" )
1466
1467 for switch in main.randomLinks:
Hari Krishnab35c6d02015-03-18 11:13:51 -07001468 main.Mininet1.link(
1469 END1=switch[0],
1470 END2=switch[1],
kelvin-onlab65a72d22015-03-26 13:46:32 -07001471 OPTION="down")
Hari Krishnab35c6d02015-03-18 11:13:51 -07001472 time.sleep( link_sleep )
1473
1474 topology_output = main.ONOScli2.topology()
1475 linkDown = main.ONOSbench.checkStatus(
1476 topology_output, main.numMNswitches, str(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001477 int( main.numMNlinks ) - 5 * 2 ) )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001478 utilities.assert_equals(
1479 expect=main.TRUE,
1480 actual=linkDown,
1481 onpass="Link Down discovered properly",
1482 onfail="Link down was not discovered in " +
1483 str( link_sleep ) +
1484 " seconds" )
1485
1486 main.step( "Verify Ping across all hosts" )
1487 pingResultLinkDown = main.FALSE
1488 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001489 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001490 time2 = time.time()
1491 timeDiff = round( ( time2 - time1 ), 2 )
1492 main.log.report(
1493 "Time taken for Ping All: " +
1494 str( timeDiff ) +
1495 " seconds" )
1496 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1497 onpass="PING ALL PASS",
1498 onfail="PING ALL FAIL" )
1499
kelvin-onlab65a72d22015-03-26 13:46:32 -07001500 caseResult73 = pingResultLinkDown
Hari Krishnab35c6d02015-03-18 11:13:51 -07001501 utilities.assert_equals( expect=main.TRUE, actual=caseResult73,
1502 onpass="Random Link cut Test PASS",
1503 onfail="Random Link cut Test FAIL" )
1504
1505 def CASE83( self, main ):
1506 """
kelvin-onlab65a72d22015-03-26 13:46:32 -07001507 Bring the core links up that are down and verify ping all ( Host Intents Chordal Topo )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001508 """
1509 import random
Hari Krishnab35c6d02015-03-18 11:13:51 -07001510 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001511
Hari Krishnab35c6d02015-03-18 11:13:51 -07001512 main.log.report(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001513 "Bring the core links up that are down and verify ping all (Host Intents-Chordal Topo" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001514 main.log.report(
1515 "__________________________________________________________________" )
1516 main.case(
1517 "Host intents - Bring the core links up that are down and verify ping all" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001518 main.step( "Bring randomly cut links on devices up" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001519
kelvin-onlab65a72d22015-03-26 13:46:32 -07001520 for switch in main.randomLinks:
Hari Krishnab35c6d02015-03-18 11:13:51 -07001521 main.Mininet1.link(
1522 END1=switch[0],
1523 END2=switch[1],
1524 OPTION="up")
kelvin-onlab65a72d22015-03-26 13:46:32 -07001525
Hari Krishnab35c6d02015-03-18 11:13:51 -07001526 time.sleep( link_sleep )
1527
1528 topology_output = main.ONOScli2.topology()
1529 linkUp = main.ONOSbench.checkStatus(
1530 topology_output,
1531 main.numMNswitches,
1532 str( main.numMNlinks ) )
1533 utilities.assert_equals(
1534 expect=main.TRUE,
1535 actual=linkUp,
1536 onpass="Link up discovered properly",
1537 onfail="Link up was not discovered in " +
1538 str( link_sleep ) +
1539 " seconds" )
1540
1541 main.step( "Verify Ping across all hosts" )
1542 pingResultLinkUp = main.FALSE
1543 time1 = time.time()
kelvin-onlab77d6c302015-03-31 11:33:32 -07001544 pingResultLinkUp = main.Mininet1.pingall(timeout = main.pingTimeout)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001545 time2 = time.time()
1546 timeDiff = round( ( time2 - time1 ), 2 )
1547 main.log.report(
1548 "Time taken for Ping All: " +
1549 str( timeDiff ) +
1550 " seconds" )
1551 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1552 onpass="PING ALL PASS",
1553 onfail="PING ALL FAIL" )
1554
1555 caseResult83 = linkUp and pingResultLinkUp
1556 utilities.assert_equals( expect=main.TRUE, actual=caseResult83,
1557 onpass="Link Up Test PASS",
1558 onfail="Link Up Test FAIL" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001559
1560 def CASE74( self, main ):
1561 """
1562 Randomly bring some core links down and verify ping all ( Host Intents-Spine Topo)
1563 """
1564 import random
1565 main.randomLink1 = []
1566 main.randomLink2 = []
1567 main.randomLink3 = []
1568 main.randomLink4 = []
1569 link1End1 = main.params[ 'SPINECORELINKS' ][ 'linkS9' ]
1570 link1End2top = main.params[ 'SPINECORELINKS' ][ 'linkS9top' ].split( ',' )
1571 link1End2bot = main.params[ 'SPINECORELINKS' ][ 'linkS9bot' ].split( ',' )
1572 link2End1 = main.params[ 'SPINECORELINKS' ][ 'linkS10' ]
1573 link2End2top = main.params[ 'SPINECORELINKS' ][ 'linkS10top' ].split( ',' )
1574 link2End2bot = main.params[ 'SPINECORELINKS' ][ 'linkS10bot' ].split( ',' )
1575 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1576 main.pingTimeout = 400
1577
1578 main.log.report( "Bring some core links down and verify ping all (Host Intents-Spine Topo)" )
1579 main.log.report( "___________________________________________________________________________" )
1580
1581 linkIndex = range(4)
1582 linkIndexS9 = random.sample(linkIndex,1)[0]
1583 linkIndex.remove(linkIndexS9)
1584 linkIndexS10 = random.sample(linkIndex,1)[0]
1585 main.randomLink1 = link1End2top[linkIndexS9]
1586 main.randomLink2 = link2End2top[linkIndexS10]
1587 main.randomLink3 = random.sample(link1End2bot,1)[0]
1588 main.randomLink4 = random.sample(link2End2bot,1)[0]
kelvin-onlab77d6c302015-03-31 11:33:32 -07001589 # main.Mininet1.link( END1=link1End1, END2=main.randomLink1, OPTION="down" )
1590 # main.Mininet1.link( END1=link2End1, END2=main.randomLink2, OPTION="down" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001591 main.Mininet1.link( END1=link1End1, END2=main.randomLink3, OPTION="down" )
1592 main.Mininet1.link( END1=link2End1, END2=main.randomLink4, OPTION="down" )
kelvin-onlabd878fc22015-03-27 13:33:41 -07001593
kelvin-onlab65a72d22015-03-26 13:46:32 -07001594 time.sleep( link_sleep )
1595
1596 topology_output = main.ONOScli2.topology()
1597 linkDown = main.ONOSbench.checkStatus(
1598 topology_output, main.numMNswitches, str(
1599 int( main.numMNlinks ) - 8 ))
1600 utilities.assert_equals(
1601 expect=main.TRUE,
1602 actual=linkDown,
1603 onpass="Link Down discovered properly",
1604 onfail="Link down was not discovered in " +
1605 str( link_sleep ) +
1606 " seconds" )
1607
1608 main.step( "Verify Ping across all hosts" )
1609 pingResultLinkDown = main.FALSE
1610 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001611 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin-onlab65a72d22015-03-26 13:46:32 -07001612 time2 = time.time()
1613 timeDiff = round( ( time2 - time1 ), 2 )
1614 main.log.report(
1615 "Time taken for Ping All: " +
1616 str( timeDiff ) +
1617 " seconds" )
1618 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1619 onpass="PING ALL PASS",
1620 onfail="PING ALL FAIL" )
1621
1622 caseResult74 = linkDown and pingResultLinkDown
1623 utilities.assert_equals( expect=main.TRUE, actual=caseResult74,
1624 onpass="Random Link cut Test PASS",
1625 onfail="Random Link cut Test FAIL" )
1626
1627 def CASE84( self, main ):
1628 """
1629 Bring the core links up that are down and verify ping all ( Host Intents-Spine Topo )
1630 """
1631 import random
1632 link1End1 = main.params[ 'SPINECORELINKS' ][ 'linkS9' ]
1633 link2End1 = main.params[ 'SPINECORELINKS' ][ 'linkS10' ]
1634 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1635 main.log.report(
1636 "Bring the core links up that are down and verify ping all (Host Intents-Spine Topo" )
1637 main.log.report(
1638 "__________________________________________________________________" )
1639 main.case(
1640 "Host intents - Bring the core links up that are down and verify ping all" )
1641
kelvin-onlab77d6c302015-03-31 11:33:32 -07001642 #main.Mininet1.link( END1=link1End1, END2=main.randomLink1, OPTION="up" )
1643 #main.Mininet1.link( END1=link2End1, END2=main.randomLink2, OPTION="up" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001644 main.Mininet1.link( END1=link1End1, END2=main.randomLink3, OPTION="up" )
1645 main.Mininet1.link( END1=link2End1, END2=main.randomLink4, OPTION="up" )
1646
1647 time.sleep( link_sleep )
1648 topology_output = main.ONOScli2.topology()
1649 linkUp = main.ONOSbench.checkStatus(
1650 topology_output,
1651 main.numMNswitches,
1652 str( main.numMNlinks ) )
1653 utilities.assert_equals(
1654 expect=main.TRUE,
1655 actual=linkUp,
1656 onpass="Link up discovered properly",
1657 onfail="Link up was not discovered in " +
1658 str( link_sleep ) +
1659 " seconds" )
1660
1661 main.step( "Verify Ping across all hosts" )
1662 pingResultLinkUp = main.FALSE
1663 time1 = time.time()
kelvin-onlab77d6c302015-03-31 11:33:32 -07001664 pingResultLinkUp = main.Mininet1.pingall(timeout = main.pingTimeout)
kelvin-onlab65a72d22015-03-26 13:46:32 -07001665 time2 = time.time()
1666 timeDiff = round( ( time2 - time1 ), 2 )
1667 main.log.report(
1668 "Time taken for Ping All: " +
1669 str( timeDiff ) +
1670 " seconds" )
1671 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1672 onpass="PING ALL PASS",
1673 onfail="PING ALL FAIL" )
1674
1675 caseResult84 = linkUp and pingResultLinkUp
1676 utilities.assert_equals( expect=main.TRUE, actual=caseResult84,
1677 onpass="Link Up Test PASS",
1678 onfail="Link Up Test FAIL" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001679
1680 def CASE90( self ):
kelvin-onlab8a832582015-01-16 17:06:11 -08001681 """
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001682 Install 600 point intents and verify ping all (Att Topology)
kelvin-onlab8a832582015-01-16 17:06:11 -08001683 """
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001684 main.log.report( "Add 600 point intents and verify pingall (Att Topology)" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001685 main.log.report( "_______________________________________" )
1686 import itertools
1687 import time
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001688 main.case( "Install 600 point intents" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001689 main.step( "Add point Intents" )
1690 intentResult = main.TRUE
1691 deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) )
1692
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001693 intentIdList = []
Hari Krishnab35c6d02015-03-18 11:13:51 -07001694 time1 = time.time()
Hari Krishnab35c6d02015-03-18 11:13:51 -07001695 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1696 pool = []
1697 for cli in main.CLIs:
1698 if i >= len( deviceCombos ):
1699 break
1700 t = main.Thread( target=cli.addPointIntent,
1701 threadID=main.threadID,
1702 name="addPointIntent",
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001703 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
Hari Krishnab35c6d02015-03-18 11:13:51 -07001704 pool.append(t)
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001705 #time.sleep(1)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001706 t.start()
1707 i = i + 1
1708 main.threadID = main.threadID + 1
1709 for thread in pool:
1710 thread.join()
1711 intentIdList.append(thread.result)
1712 time2 = time.time()
1713 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1714 intentResult = main.TRUE
1715 intentsJson = main.ONOScli2.intents()
1716 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1717 intentsJson = intentsJson)
1718 print getIntentStateResult
1719 # Takes awhile for all the onos to get the intents
1720 time.sleep(30)
kelvin-onlab8a832582015-01-16 17:06:11 -08001721 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001722 pingResult = main.FALSE
1723 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001724 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001725 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001726 timeDiff = round( ( time2 - time1 ), 2 )
1727 main.log.report(
1728 "Time taken for Ping All: " +
1729 str( timeDiff ) +
1730 " seconds" )
1731 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1732 onpass="PING ALL PASS",
1733 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001734
kelvin-onlab65a72d22015-03-26 13:46:32 -07001735 case90Result = ( intentResult and pingResult )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001736
kelvin-onlab8a832582015-01-16 17:06:11 -08001737 utilities.assert_equals(
1738 expect=main.TRUE,
kelvin-onlab65a72d22015-03-26 13:46:32 -07001739 actual=case90Result,
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001740 onpass="Install 600 point Intents and Ping All test PASS",
1741 onfail="Install 600 point Intents and Ping All test FAIL" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001742
1743 def CASE91( self ):
1744 """
1745 Install ###$$$ point intents and verify ping all (Chordal Topology)
1746 """
1747 main.log.report( "Add ###$$$ point intents and verify pingall (Chordal Topology)" )
1748 main.log.report( "_______________________________________" )
1749 import itertools
1750 import time
1751 main.case( "Install ###$$$ point intents" )
1752 main.step( "Add point Intents" )
1753 intentResult = main.TRUE
1754 deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) )
1755
1756 intentIdList = []
1757 time1 = time.time()
1758 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1759 pool = []
1760 for cli in main.CLIs:
1761 if i >= len( deviceCombos ):
1762 break
1763 t = main.Thread( target=cli.addPointIntent,
1764 threadID=main.threadID,
1765 name="addPointIntent",
1766 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
1767 pool.append(t)
1768 #time.sleep(1)
1769 t.start()
1770 i = i + 1
1771 main.threadID = main.threadID + 1
1772 for thread in pool:
1773 thread.join()
1774 intentIdList.append(thread.result)
1775 time2 = time.time()
1776 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1777 intentResult = main.TRUE
1778 intentsJson = main.ONOScli2.intents()
1779 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1780 intentsJson = intentsJson)
1781 print getIntentStateResult
1782 # Takes awhile for all the onos to get the intents
1783 time.sleep(30)
1784 main.step( "Verify Ping across all hosts" )
1785 pingResult = main.FALSE
1786 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001787 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001788 time2 = time.time()
1789 timeDiff = round( ( time2 - time1 ), 2 )
1790 main.log.report(
1791 "Time taken for Ping All: " +
1792 str( timeDiff ) +
1793 " seconds" )
1794 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1795 onpass="PING ALL PASS",
1796 onfail="PING ALL FAIL" )
1797
kelvin-onlab65a72d22015-03-26 13:46:32 -07001798 case91Result = ( intentResult and pingResult )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001799
1800 utilities.assert_equals(
1801 expect=main.TRUE,
kelvin-onlabd878fc22015-03-27 13:33:41 -07001802 actual=case91Result,
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001803 onpass="Install ###$$$ point Intents and Ping All test PASS",
1804 onfail="Install ###$$$ point Intents and Ping All test FAIL" )
1805
1806 def CASE92( self ):
1807 """
kelvin-onlab77d6c302015-03-31 11:33:32 -07001808 Install 4556 point intents and verify ping all (Spine Topology)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001809 """
kelvin-onlab77d6c302015-03-31 11:33:32 -07001810 main.log.report( "Add 4556 point intents and verify pingall (Spine Topology)" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001811 main.log.report( "_______________________________________" )
1812 import itertools
1813 import time
kelvin-onlab77d6c302015-03-31 11:33:32 -07001814 main.case( "Install 4556 point intents" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001815 main.step( "Add point Intents" )
1816 intentResult = main.TRUE
kelvin-onlab77d6c302015-03-31 11:33:32 -07001817 main.pingTimeout = 600
1818 for i in range(len(main.hostMACs)):
1819 main.MACsDict[main.deviceDPIDs[i+10]] = main.hostMACs[i].split('/')[0]
1820 print main.MACsDict
1821 deviceCombos = list( itertools.permutations( main.deviceDPIDs[10:], 2 ) )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001822
1823 intentIdList = []
1824 time1 = time.time()
1825 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1826 pool = []
1827 for cli in main.CLIs:
1828 if i >= len( deviceCombos ):
1829 break
1830 t = main.Thread( target=cli.addPointIntent,
1831 threadID=main.threadID,
1832 name="addPointIntent",
1833 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
1834 pool.append(t)
1835 #time.sleep(1)
1836 t.start()
1837 i = i + 1
1838 main.threadID = main.threadID + 1
1839 for thread in pool:
1840 thread.join()
1841 intentIdList.append(thread.result)
1842 time2 = time.time()
1843 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1844 intentResult = main.TRUE
1845 intentsJson = main.ONOScli2.intents()
1846 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1847 intentsJson = intentsJson)
kelvin-onlab77d6c302015-03-31 11:33:32 -07001848 #print getIntentStateResult
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001849 # Takes awhile for all the onos to get the intents
kelvin-onlab77d6c302015-03-31 11:33:32 -07001850 time.sleep(60)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001851 main.step( "Verify Ping across all hosts" )
1852 pingResult = main.FALSE
1853 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001854 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001855 time2 = time.time()
1856 timeDiff = round( ( time2 - time1 ), 2 )
1857 main.log.report(
1858 "Time taken for Ping All: " +
1859 str( timeDiff ) +
1860 " seconds" )
1861 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1862 onpass="PING ALL PASS",
1863 onfail="PING ALL FAIL" )
1864
kelvin-onlab65a72d22015-03-26 13:46:32 -07001865 case92Result = ( intentResult and pingResult )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001866
1867 utilities.assert_equals(
1868 expect=main.TRUE,
kelvin-onlab65a72d22015-03-26 13:46:32 -07001869 actual=case92Result,
kelvin-onlab77d6c302015-03-31 11:33:32 -07001870 onpass="Install 4556 point Intents and Ping All test PASS",
1871 onfail="Install 4556 point Intents and Ping All test FAIL" )
1872
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001873 def CASE93( self ):
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001874 """
kelvin-onlab77d6c302015-03-31 11:33:32 -07001875 Install multi-single point intents and verify Ping all works
1876 for att topology
1877 """
1878 import copy
1879 import time
1880 main.log.report( "Install multi-single point intents and verify Ping all" )
1881 main.log.report( "___________________________________________" )
1882 main.case( "Install multi-single point intents and Ping all" )
1883 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
1884 portIngressList = ['1']*(len(deviceDPIDsCopy) - 1)
1885 intentIdList = []
1886 print "MACsDict", main.MACsDict
1887 time1 = time.time()
1888 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
1889 pool = []
1890 for cli in main.CLIs:
1891 egressDevice = deviceDPIDsCopy[i]
1892 ingressDeviceList = copy.copy(deviceDPIDsCopy)
1893 ingressDeviceList.remove(egressDevice)
1894 if i >= len( deviceDPIDsCopy ):
1895 break
1896 t = main.Thread( target=cli.addMultipointToSinglepointIntent,
1897 threadID=main.threadID,
1898 name="addMultipointToSinglepointIntent",
1899 args =[ingressDeviceList,egressDevice,portIngressList,'1','IPV4','',main.MACsDict.get(egressDevice)])
1900 pool.append(t)
1901 #time.sleep(1)
1902 t.start()
1903 i = i + 1
1904 main.threadID = main.threadID + 1
1905 for thread in pool:
1906 thread.join()
1907 intentIdList.append(thread.result)
1908 time2 = time.time()
1909 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
kelvin-onlab06ade552015-03-31 18:09:27 -07001910 print intentIdList
kelvin-onlab77d6c302015-03-31 11:33:32 -07001911 time.sleep(5)
1912 main.step( "Verify Ping across all hosts" )
1913 pingResult = main.FALSE
1914 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001915 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin-onlab77d6c302015-03-31 11:33:32 -07001916 time2 = time.time()
1917 timeDiff = round( ( time2 - time1 ), 2 )
1918 main.log.report(
1919 "Time taken for Ping All: " +
1920 str( timeDiff ) +
1921 " seconds" )
1922
1923 case93Result = pingResult
1924 utilities.assert_equals(
1925 expect=main.TRUE,
1926 actual=case93Result,
1927 onpass="Install 25 multi to single point Intents and Ping All test PASS",
1928 onfail="Install 25 multi to single point Intents and Ping All test FAIL" )
1929
kelvin-onlab20c712a2015-03-31 12:55:34 -07001930 def CASE94( self ):
1931 """
1932 Install multi-single point intents and verify Ping all works
1933 for spine topology
1934 """
1935 import copy
1936 import time
1937 main.log.report( "Install multi-single point intents and verify Ping all" )
1938 main.log.report( "___________________________________________" )
1939 main.case( "Install multi-single point intents and Ping all" )
1940 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
1941 portIngressList = ['1']*(len(deviceDPIDsCopy) - 1)
1942 intentIdList = []
1943 print "MACsDict", main.MACsDict
1944 time1 = time.time()
1945 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
1946 pool = []
1947 for cli in main.CLIs:
1948 egressDevice = deviceDPIDsCopy[i]
1949 ingressDeviceList = copy.copy(deviceDPIDsCopy)
1950 ingressDeviceList.remove(egressDevice)
1951 if i >= len( deviceDPIDsCopy ):
1952 break
1953 t = main.Thread( target=cli.addMultipointToSinglepointIntent,
1954 threadID=main.threadID,
1955 name="addMultipointToSinglepointIntent",
1956 args =[ingressDeviceList,egressDevice,portIngressList,'1','IPV4','',main.MACsDict.get(egressDevice)])
1957 pool.append(t)
1958 #time.sleep(1)
1959 t.start()
1960 i = i + 1
1961 main.threadID = main.threadID + 1
1962 for thread in pool:
1963 thread.join()
1964 intentIdList.append(thread.result)
1965 time2 = time.time()
1966 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1967 time.sleep(5)
1968 main.step( "Verify Ping across all hosts" )
1969 pingResult = main.FALSE
1970 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001971 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin-onlab20c712a2015-03-31 12:55:34 -07001972 time2 = time.time()
1973 timeDiff = round( ( time2 - time1 ), 2 )
1974 main.log.report(
1975 "Time taken for Ping All: " +
1976 str( timeDiff ) +
1977 " seconds" )
1978
1979 case94Result = pingResult
1980 utilities.assert_equals(
1981 expect=main.TRUE,
1982 actual=case94Result,
1983 onpass="Install 25 multi to single point Intents and Ping All test PASS",
1984 onfail="Install 25 multi to single point Intents and Ping All test FAIL" )
kelvin-onlab06ade552015-03-31 18:09:27 -07001985
1986 #def CASE95 multi-single point intent for Spine
1987
kelvin-onlab77d6c302015-03-31 11:33:32 -07001988 def CASE96( self ):
1989 """
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001990 Install single-multi point intents and verify Ping all works
1991 for att topology
1992 """
1993 import copy
1994 main.log.report( "Install single-multi point intents and verify Ping all" )
1995 main.log.report( "___________________________________________" )
1996 main.case( "Install single-multi point intents and Ping all" )
kelvin-onlab06ade552015-03-31 18:09:27 -07001997 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
1998 portEgressList = ['1']*(len(deviceDPIDsCopy) - 1)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001999 intentIdList = []
kelvin-onlab06ade552015-03-31 18:09:27 -07002000 print "MACsDict", main.MACsDict
2001 time1 = time.time()
2002 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
2003 pool = []
2004 for cli in main.CLIs:
2005 ingressDevice = deviceDPIDsCopy[i]
2006 egressDeviceList = copy.copy(deviceDPIDsCopy)
2007 egressDeviceList.remove(ingressDevice)
2008 if i >= len( deviceDPIDsCopy ):
2009 break
2010 t = main.Thread( target=cli.addSinglepointToMultipointIntent,
2011 threadID=main.threadID,
2012 name="addSinglepointToMultipointIntent",
2013 args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',main.MACsDict.get(ingressDevice)])
2014 pool.append(t)
2015 #time.sleep(1)
2016 t.start()
2017 i = i + 1
2018 main.threadID = main.threadID + 1
2019 for thread in pool:
2020 thread.join()
2021 intentIdList.append(thread.result)
2022 time2 = time.time()
2023 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
2024 time.sleep(5)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002025 main.step( "Verify Ping across all hosts" )
2026 pingResult = main.FALSE
2027 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07002028 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002029 time2 = time.time()
2030 timeDiff = round( ( time2 - time1 ), 2 )
2031 main.log.report(
2032 "Time taken for Ping All: " +
2033 str( timeDiff ) +
2034 " seconds" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002035
kelvin-onlab06ade552015-03-31 18:09:27 -07002036 case96Result = pingResult
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002037 utilities.assert_equals(
2038 expect=main.TRUE,
kelvin-onlab06ade552015-03-31 18:09:27 -07002039 actual=case96Result,
2040 onpass="Install 25 single to multi point Intents and Ping All test PASS",
2041 onfail="Install 25 single to multi point Intents and Ping All test FAIL" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002042
kelvin-onlab77d6c302015-03-31 11:33:32 -07002043 def CASE97( self ):
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002044 """
2045 Install single-multi point intents and verify Ping all works
kelvin-onlab06ade552015-03-31 18:09:27 -07002046 for Chordal topology
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002047 """
2048 import copy
2049 main.log.report( "Install single-multi point intents and verify Ping all" )
2050 main.log.report( "___________________________________________" )
2051 main.case( "Install single-multi point intents and Ping all" )
kelvin-onlab06ade552015-03-31 18:09:27 -07002052 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
2053 portEgressList = ['1']*(len(deviceDPIDsCopy) - 1)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002054 intentIdList = []
kelvin-onlab06ade552015-03-31 18:09:27 -07002055 print "MACsDict", main.MACsDict
2056 time1 = time.time()
2057 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
2058 pool = []
2059 for cli in main.CLIs:
2060 ingressDevice = deviceDPIDsCopy[i]
2061 egressDeviceList = copy.copy(deviceDPIDsCopy)
2062 egressDeviceList.remove(ingressDevice)
2063 if i >= len( deviceDPIDsCopy ):
2064 break
2065 t = main.Thread( target=cli.addSinglepointToMultipointIntent,
2066 threadID=main.threadID,
2067 name="addSinglepointToMultipointIntent",
2068 args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',main.MACsDict.get(ingressDevice),''])
2069 pool.append(t)
2070 #time.sleep(1)
2071 t.start()
2072 i = i + 1
2073 main.threadID = main.threadID + 1
2074 for thread in pool:
2075 thread.join()
2076 intentIdList.append(thread.result)
2077 time2 = time.time()
2078 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
2079 time.sleep(5)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002080 main.step( "Verify Ping across all hosts" )
2081 pingResult = main.FALSE
2082 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07002083 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002084 time2 = time.time()
2085 timeDiff = round( ( time2 - time1 ), 2 )
2086 main.log.report(
2087 "Time taken for Ping All: " +
2088 str( timeDiff ) +
2089 " seconds" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002090
kelvin-onlab06ade552015-03-31 18:09:27 -07002091 case97Result = pingResult
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002092 utilities.assert_equals(
2093 expect=main.TRUE,
kelvin-onlab06ade552015-03-31 18:09:27 -07002094 actual=case97Result,
2095 onpass="Install 25 single to multi point Intents and Ping All test PASS",
2096 onfail="Install 25 single to multi point Intents and Ping All test FAIL" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002097
kelvin-onlab8a832582015-01-16 17:06:11 -08002098 def CASE10( self ):
kelvin-onlab7642bb12015-02-27 13:48:17 -08002099 import time
kelvin-onlab8a832582015-01-16 17:06:11 -08002100 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002101 Remove all Intents
kelvin-onlab8a832582015-01-16 17:06:11 -08002102 """
2103 main.log.report( "Remove all intents that were installed previously" )
2104 main.log.report( "______________________________________________" )
2105 main.log.info( "Remove all intents" )
2106 main.case( "Removing intents" )
2107 main.step( "Obtain the intent id's first" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002108 intentsList = main.ONOScli1.getAllIntentIds()
kelvin-onlab8a832582015-01-16 17:06:11 -08002109 ansi_escape = re.compile( r'\x1b[^m]*m' )
2110 intentsList = ansi_escape.sub( '', intentsList )
2111 intentsList = intentsList.replace(
2112 " onos:intents | grep id=",
2113 "" ).replace(
2114 "id=",
2115 "" ).replace(
2116 "\r\r",
2117 "" )
2118 intentsList = intentsList.splitlines()
2119 intentsList = intentsList[ 1: ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002120 intentIdList = []
2121 step1Result = main.TRUE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002122 moreIntents = main.TRUE
2123 removeIntentCount = 0
kelvin-onlab65a72d22015-03-26 13:46:32 -07002124 intentsCount = len(intentsList)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002125 print "Current number of intents" , len(intentsList)
kelvin-onlab8a832582015-01-16 17:06:11 -08002126 if ( len( intentsList ) > 1 ):
kelvin-onlab54400a92015-02-26 18:05:51 -08002127 results = main.TRUE
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002128 main.log.info("Removing intent...")
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002129 while moreIntents:
Hari Krishnab35c6d02015-03-18 11:13:51 -07002130 if removeIntentCount == 5:
2131 break
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002132 removeIntentCount = removeIntentCount + 1
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002133 intentsList1 = main.ONOScli1.getAllIntentIds()
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002134 if len( intentsList1 ) == 0:
2135 break
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002136 ansi_escape = re.compile( r'\x1b[^m]*m' )
2137 intentsList1 = ansi_escape.sub( '', intentsList1 )
2138 intentsList1 = intentsList1.replace(
2139 " onos:intents | grep id=",
2140 "" ).replace(
2141 " state=",
2142 "" ).replace(
2143 "\r\r",
2144 "" )
2145 intentsList1 = intentsList1.splitlines()
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002146 intentsList1 = intentsList1[ 1: ]
2147 print "Round %d intents to remove: " %(removeIntentCount)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002148 print intentsList1
2149 intentIdList1 = []
Hari Krishnab35c6d02015-03-18 11:13:51 -07002150 if ( len( intentsList1 ) > 0 ):
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002151 moreIntents = main.TRUE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002152 for i in range( len( intentsList1 ) ):
2153 intentsTemp1 = intentsList1[ i ].split( ',' )
2154 intentIdList1.append( intentsTemp1[ 0 ].split('=')[1] )
2155 print "Leftover Intent IDs: ", intentIdList1
2156 print len(intentIdList1)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07002157 time1 = time.time()
2158 for i in xrange( 0, len( intentIdList1 ), int(main.numCtrls) ):
2159 pool = []
2160 for cli in main.CLIs:
2161 if i >= len( intentIdList1 ):
2162 break
2163 t = main.Thread( target=cli.removeIntent,
2164 threadID=main.threadID,
2165 name="removeIntent",
2166 args=[intentIdList1[i],'org.onosproject.cli',True,False])
2167 pool.append(t)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07002168 t.start()
2169 i = i + 1
2170 main.threadID = main.threadID + 1
2171 for thread in pool:
2172 thread.join()
2173 intentIdList.append(thread.result)
2174 time2 = time.time()
2175 main.log.info("Time for removing host intents: %2f seconds" %(time2-time1))
Hari Krishnab35c6d02015-03-18 11:13:51 -07002176 time.sleep(10)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002177 else:
Hari Krishnaef1bd4e2015-03-12 16:55:30 -07002178 time.sleep(15)
Hari Krishnab35c6d02015-03-18 11:13:51 -07002179 if len( main.ONOScli1.intents()):
Hari Krishnaef1bd4e2015-03-12 16:55:30 -07002180 continue
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002181 break
kelvin-onlab36c02b12015-03-11 11:25:55 -07002182
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002183 else:
kelvin-onlab65a72d22015-03-26 13:46:32 -07002184 print "Removed %d intents" %(intentsCount)
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002185 step1Result = main.TRUE
2186 else:
2187 print "No Intent IDs found in Intents list: ", intentsList
2188 step1Result = main.FALSE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002189
kelvin-onlabdc8719b2015-03-02 14:01:52 -08002190 print main.ONOScli1.intents()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002191 caseResult10 = step1Result
2192 utilities.assert_equals( expect=main.TRUE, actual=caseResult10,
kelvin-onlab8a832582015-01-16 17:06:11 -08002193 onpass="Intent removal test successful",
2194 onfail="Intent removal test failed" )
Hari Krishna22c3d412015-02-17 16:48:12 -08002195
2196 def CASE11( self, main ):
2197 """
2198 Enable onos-app-ifwd, Verify Intent based Reactive forwarding through ping all and Disable it
2199 """
2200 import re
2201 import copy
2202 import time
2203
kelvin-onlab54400a92015-02-26 18:05:51 -08002204 Thread = imp.load_source('Thread','/home/admin/ONLabTest/TestON/tests/OnosCHO/Thread.py')
2205 threadID = 0
2206
Hari Krishna22c3d412015-02-17 16:48:12 -08002207 main.log.report( "Enable Intent based Reactive forwarding and Verify ping all" )
2208 main.log.report( "_____________________________________________________" )
2209 main.case( "Enable Intent based Reactive forwarding and Verify ping all" )
2210 main.step( "Enable intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08002211 installResult = main.FALSE
2212 feature = "onos-app-ifwd"
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002213
kelvin-onlab54400a92015-02-26 18:05:51 -08002214 pool = []
2215 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002216 for cli,feature in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -08002217 t = main.Thread(target=cli,threadID=threadID,
2218 name="featureInstall",args=[feature])
2219 pool.append(t)
2220 t.start()
2221 threadID = threadID + 1
2222
2223 results = []
2224 for thread in pool:
2225 thread.join()
2226 results.append(thread.result)
2227 time2 = time.time()
2228
2229 if( all(result == main.TRUE for result in results) == False):
2230 main.log.info("Did not install onos-app-ifwd feature properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -07002231 #main.cleanup()
2232 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -08002233 else:
2234 main.log.info("Successful feature:install onos-app-ifwd")
2235 installResult = main.TRUE
2236 main.log.info("Time for feature:install onos-app-ifwd: %2f seconds" %(time2-time1))
2237
Hari Krishna22c3d412015-02-17 16:48:12 -08002238 main.step( "Verify Pingall" )
2239 ping_result = main.FALSE
2240 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -08002241 ping_result = main.Mininet1.pingall(timeout=600)
Hari Krishna22c3d412015-02-17 16:48:12 -08002242 time2 = time.time()
2243 timeDiff = round( ( time2 - time1 ), 2 )
2244 main.log.report(
2245 "Time taken for Ping All: " +
2246 str( timeDiff ) +
2247 " seconds" )
kelvin-onlab54400a92015-02-26 18:05:51 -08002248
Hari Krishna22c3d412015-02-17 16:48:12 -08002249 if ping_result == main.TRUE:
2250 main.log.report( "Pingall Test in Reactive mode successful" )
2251 else:
2252 main.log.report( "Pingall Test in Reactive mode failed" )
2253
2254 main.step( "Disable Intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08002255 uninstallResult = main.FALSE
2256
kelvin-onlab54400a92015-02-26 18:05:51 -08002257 pool = []
2258 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002259 for cli,feature in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -08002260 t = main.Thread(target=cli,threadID=threadID,
2261 name="featureUninstall",args=[feature])
2262 pool.append(t)
2263 t.start()
2264 threadID = threadID + 1
2265
2266 results = []
2267 for thread in pool:
2268 thread.join()
2269 results.append(thread.result)
2270 time2 = time.time()
2271
2272 if( all(result == main.TRUE for result in results) == False):
2273 main.log.info("Did not uninstall onos-app-ifwd feature properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -07002274 uninstallResult = main.FALSE
2275 #main.cleanup()
2276 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -08002277 else:
2278 main.log.info("Successful feature:uninstall onos-app-ifwd")
2279 uninstallResult = main.TRUE
2280 main.log.info("Time for feature:uninstall onos-app-ifwd: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -08002281
2282 # Waiting for reative flows to be cleared.
2283 time.sleep( 10 )
2284
2285 case11Result = installResult and ping_result and uninstallResult
2286 utilities.assert_equals( expect=main.TRUE, actual=case11Result,
2287 onpass="Intent based Reactive forwarding Pingall test PASS",
2288 onfail="Intent based Reactive forwarding Pingall test FAIL" )
2289
Hari Krishnab35c6d02015-03-18 11:13:51 -07002290 def CASE99(self):
2291 import time
2292 # WORK AROUND FOR ONOS-581. STOP ONOS BEFORE ASSIGNING CONTROLLERS AT MININET & START ONCE DONE
2293 main.step( "Stop ONOS on all Nodes" )
2294 stopResult = main.TRUE
2295 for i in range( 1, int( main.numCtrls ) + 1 ):
2296 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
2297 main.log.info( "Stopping ONOS Node IP: " + ONOS_ip )
2298 sresult = main.ONOSbench.onosStop( ONOS_ip )
2299 utilities.assert_equals( expect=main.TRUE, actual=sresult,
2300 onpass="Test step PASS",
2301 onfail="Test step FAIL" )
2302 stopResult = ( stopResult and sresult )
2303
2304 main.step( "Start ONOS on all Nodes" )
2305 startResult = main.TRUE
2306 for i in range( 1, int( main.numCtrls ) + 1 ):
2307 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
2308 main.log.info( "Starting ONOS Node IP: " + ONOS_ip )
2309 sresult = main.ONOSbench.onosStart( ONOS_ip )
2310 utilities.assert_equals( expect=main.TRUE, actual=sresult,
2311 onpass="Test step PASS",
2312 onfail="Test step FAIL" )
2313 startResult = ( startResult and sresult )
2314
2315 main.step( "Start ONOS CLI on all nodes" )
2316 cliResult = main.TRUE
2317 time.sleep( 30 )
2318 main.log.step(" Start ONOS cli using thread ")
2319 pool = []
2320 time1 = time.time()
2321 for i in range( int( main.numCtrls ) ):
2322 t = main.Thread(target=main.CLIs[i].startOnosCli,
2323 threadID=main.threadID,
2324 name="startOnosCli",
2325 args=[main.nodes[i].ip_address])
2326 pool.append(t)
2327 t.start()
2328 main.threadID = main.threadID + 1
2329 for t in pool:
2330 t.join()
2331 cliResult = cliResult and t.result
2332 time2 = time.time()
2333
2334 if not cliResult:
2335 main.log.info("ONOS CLI did not start up properly")
2336 #main.cleanup()
2337 #main.exit()
2338 else:
2339 main.log.info("Successful CLI startup")
2340 main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
2341
2342 case99Result = ( startResult and cliResult )
2343 time.sleep(30)
2344 utilities.assert_equals(
2345 expect=main.TRUE,
2346 actual=case99Result,
2347 onpass="Starting new Chordal topology test PASS",
2348 onfail="Starting new Chordal topology test FAIL" )
2349
2350
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002351
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002352