blob: 71449b7c4444969f6626f563360131e74111aac7 [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" )
540
541 appCheck = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800542 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800543 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700544 t = main.Thread( target=cli.appToIDCheck,
545 name="appToIDCheck-" + str( i ),
546 args=[] )
547 pool.append( t )
kelvin-onlab54400a92015-02-26 18:05:51 -0800548 t.start()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800549 for t in pool:
550 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700551 appCheck = appCheck and t.result
552 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
553 onpass="App Ids seem to be correct",
554 onfail="Something is wrong with app Ids" )
555 if appCheck != main.TRUE:
556 main.log.warn( main.CLIs[0].apps() )
557 main.log.warn( main.CLIs[0].appIDs() )
558
559 time.sleep( 10 )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800560
kelvin-onlab8a832582015-01-16 17:06:11 -0800561 main.step( "Verify Pingall" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800562 ping_result = main.FALSE
563 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -0800564 ping_result = main.Mininet1.pingall(timeout=main.pingTimeout)
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800565 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800566 timeDiff = round( ( time2 - time1 ), 2 )
567 main.log.report(
568 "Time taken for Ping All: " +
569 str( timeDiff ) +
570 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800571
572 if ping_result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800573 main.log.report( "Pingall Test in Reactive mode successful" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800574 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800575 main.log.report( "Pingall Test in Reactive mode failed" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800576
kelvin-onlab8a832582015-01-16 17:06:11 -0800577 main.step( "Disable Reactive forwarding" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700578
579 main.log.info( "Uninstall reactive forwarding app" )
580 appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800581 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800582 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700583 t = main.Thread( target=cli.appToIDCheck,
584 name="appToIDCheck-" + str( i ),
585 args=[] )
586 pool.append( t )
kelvin-onlab54400a92015-02-26 18:05:51 -0800587 t.start()
kelvin-onlab06ade552015-03-31 18:09:27 -0700588
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800589 for t in pool:
590 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700591 appCheck = appCheck and t.result
592 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
593 onpass="App Ids seem to be correct",
594 onfail="Something is wrong with app Ids" )
595 if appCheck != main.TRUE:
596 main.log.warn( main.CLIs[0].apps() )
597 main.log.warn( main.CLIs[0].appIDs() )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800598
kelvin-onlab8a832582015-01-16 17:06:11 -0800599 # Waiting for reative flows to be cleared.
kelvin-onlab06ade552015-03-31 18:09:27 -0700600 time.sleep( 10 )
601 case40Result = installResult and uninstallResult and ping_result
602 utilities.assert_equals( expect=main.TRUE, actual=case40Result,
Hari Krishnab35c6d02015-03-18 11:13:51 -0700603 onpass="Reactive Mode Pingall test PASS",
604 onfail="Reactive Mode Pingall test FAIL" )
605
606 def CASE41( self, main ):
607 """
608 Verify Reactive forwarding (Chordal Topology)
609 """
610 import re
611 import copy
612 import time
613 main.log.report( "Verify Reactive forwarding (Chordal Topology)" )
614 main.log.report( "______________________________________________" )
615 main.case( "Enable Reactive forwarding and Verify ping all" )
616 main.step( "Enable Reactive forwarding" )
617 installResult = main.TRUE
kelvin-onlab06ade552015-03-31 18:09:27 -0700618 # Activate fwd app
619 appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" )
620
621 appCheck = main.TRUE
Hari Krishnab35c6d02015-03-18 11:13:51 -0700622 pool = []
Hari Krishnab35c6d02015-03-18 11:13:51 -0700623 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700624 t = main.Thread( target=cli.appToIDCheck,
625 name="appToIDCheck-" + str( i ),
626 args=[] )
627 pool.append( t )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700628 t.start()
Hari Krishnab35c6d02015-03-18 11:13:51 -0700629 for t in pool:
630 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700631 appCheck = appCheck and t.result
632 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
633 onpass="App Ids seem to be correct",
634 onfail="Something is wrong with app Ids" )
635 if appCheck != main.TRUE:
636 main.log.warn( main.CLIs[0].apps() )
637 main.log.warn( main.CLIs[0].appIDs() )
638
639 time.sleep( 10 )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700640
641 main.step( "Verify Pingall" )
642 ping_result = main.FALSE
643 time1 = time.time()
644 ping_result = main.Mininet1.pingall(timeout=main.pingTimeout)
645 time2 = time.time()
646 timeDiff = round( ( time2 - time1 ), 2 )
647 main.log.report(
648 "Time taken for Ping All: " +
649 str( timeDiff ) +
650 " seconds" )
651
652 if ping_result == main.TRUE:
653 main.log.report( "Pingall Test in Reactive mode successful" )
654 else:
655 main.log.report( "Pingall Test in Reactive mode failed" )
656
657 main.step( "Disable Reactive forwarding" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700658
659 main.log.info( "Uninstall reactive forwarding app" )
660 appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700661 pool = []
Hari Krishnab35c6d02015-03-18 11:13:51 -0700662 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700663 t = main.Thread( target=cli.appToIDCheck,
664 name="appToIDCheck-" + str( i ),
665 args=[] )
666 pool.append( t )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700667 t.start()
kelvin-onlab06ade552015-03-31 18:09:27 -0700668
Hari Krishnab35c6d02015-03-18 11:13:51 -0700669 for t in pool:
670 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700671 appCheck = appCheck and t.result
672 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
673 onpass="App Ids seem to be correct",
674 onfail="Something is wrong with app Ids" )
675 if appCheck != main.TRUE:
676 main.log.warn( main.CLIs[0].apps() )
677 main.log.warn( main.CLIs[0].appIDs() )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700678
679 # Waiting for reative flows to be cleared.
kelvin-onlab06ade552015-03-31 18:09:27 -0700680 time.sleep( 10 )
681 case41Result = installResult and uninstallResult and ping_result
682 utilities.assert_equals( expect=main.TRUE, actual=case41Result,
Hari Krishnab35c6d02015-03-18 11:13:51 -0700683 onpass="Reactive Mode Pingall test PASS",
684 onfail="Reactive Mode Pingall test FAIL" )
685
686 def CASE42( self, main ):
687 """
688 Verify Reactive forwarding (Spine Topology)
689 """
690 import re
691 import copy
692 import time
693 main.log.report( "Verify Reactive forwarding (Spine Topology)" )
694 main.log.report( "______________________________________________" )
695 main.case( "Enable Reactive forwarding and Verify ping all" )
696 main.step( "Enable Reactive forwarding" )
697 installResult = main.TRUE
kelvin-onlab06ade552015-03-31 18:09:27 -0700698 # Activate fwd app
699 appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" )
700
701 appCheck = main.TRUE
Hari Krishnab35c6d02015-03-18 11:13:51 -0700702 pool = []
Hari Krishnab35c6d02015-03-18 11:13:51 -0700703 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700704 t = main.Thread( target=cli.appToIDCheck,
705 name="appToIDCheck-" + str( i ),
706 args=[] )
707 pool.append( t )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700708 t.start()
Hari Krishnab35c6d02015-03-18 11:13:51 -0700709 for t in pool:
710 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700711 appCheck = appCheck and t.result
712 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
713 onpass="App Ids seem to be correct",
714 onfail="Something is wrong with app Ids" )
715 if appCheck != main.TRUE:
716 main.log.warn( main.CLIs[0].apps() )
717 main.log.warn( main.CLIs[0].appIDs() )
718
719 time.sleep( 10 )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700720
721 main.step( "Verify Pingall" )
722 ping_result = main.FALSE
723 time1 = time.time()
724 ping_result = main.Mininet1.pingall(timeout=main.pingTimeout)
725 time2 = time.time()
726 timeDiff = round( ( time2 - time1 ), 2 )
727 main.log.report(
728 "Time taken for Ping All: " +
729 str( timeDiff ) +
730 " seconds" )
731
732 if ping_result == main.TRUE:
733 main.log.report( "Pingall Test in Reactive mode successful" )
734 else:
735 main.log.report( "Pingall Test in Reactive mode failed" )
736
737 main.step( "Disable Reactive forwarding" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700738
739 main.log.info( "Uninstall reactive forwarding app" )
740 appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700741 pool = []
Hari Krishnab35c6d02015-03-18 11:13:51 -0700742 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700743 t = main.Thread( target=cli.appToIDCheck,
744 name="appToIDCheck-" + str( i ),
745 args=[] )
746 pool.append( t )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700747 t.start()
kelvin-onlab06ade552015-03-31 18:09:27 -0700748
Hari Krishnab35c6d02015-03-18 11:13:51 -0700749 for t in pool:
750 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700751 appCheck = appCheck and t.result
752 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
753 onpass="App Ids seem to be correct",
754 onfail="Something is wrong with app Ids" )
755 if appCheck != main.TRUE:
756 main.log.warn( main.CLIs[0].apps() )
757 main.log.warn( main.CLIs[0].appIDs() )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700758
759 # Waiting for reative flows to be cleared.
kelvin-onlab06ade552015-03-31 18:09:27 -0700760 time.sleep( 10 )
761 case42Result = installResult and uninstallResult and ping_result
762 utilities.assert_equals( expect=main.TRUE, actual=case42Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800763 onpass="Reactive Mode Pingall test PASS",
764 onfail="Reactive Mode Pingall test FAIL" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700765
kelvin-onlab8a832582015-01-16 17:06:11 -0800766 def CASE5( self, main ):
767 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800768 Compare current ONOS topology with reference data
kelvin-onlab8a832582015-01-16 17:06:11 -0800769 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800770 import re
kelvin-onlab54400a92015-02-26 18:05:51 -0800771
Hari Krishna22c3d412015-02-17 16:48:12 -0800772 devicesDPIDTemp = []
773 hostMACsTemp = []
774 deviceLinksTemp = []
775 deviceActiveLinksCountTemp = []
776 devicePortsEnabledCountTemp = []
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800777
kelvin-onlab8a832582015-01-16 17:06:11 -0800778 main.log.report(
779 "Compare ONOS topology with reference data in Stores" )
780 main.log.report( "__________________________________________________" )
781 main.case( "Compare ONOS topology with reference data" )
782
783 main.step( "Compare current Device ports enabled with reference" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800784 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800785 for i in xrange( 1,(main.numMNswitches + 1), int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800786 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800787 for cli in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -0800788 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800789 t = main.Thread(target = cli.getDevicePortsEnabledCount,
790 threadID = main.threadID,
791 name = "getDevicePortsEnabledCount",
792 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800793 t.start()
794 pool.append(t)
795 i = i + 1
796 main.threadID = main.threadID + 1
797 for thread in pool:
798 thread.join()
799 portResult = thread.result
800 portTemp = re.split( r'\t+', portResult )
801 portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
802 devicePortsEnabledCountTemp.append( portCount )
803 print "Device Enabled Port Counts Stored: \n", str( main.devicePortsEnabledCount )
804 time2 = time.time()
805 main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800806 main.log.info (
807 "Device Enabled ports EXPECTED: %s" %
808 str( main.devicePortsEnabledCount ) )
809 main.log.info (
810 "Device Enabled ports ACTUAL: %s" %
811 str( devicePortsEnabledCountTemp ) )
kelvin-onlab54400a92015-02-26 18:05:51 -0800812
Hari Krishna22c3d412015-02-17 16:48:12 -0800813 if ( cmp( main.devicePortsEnabledCount,
814 devicePortsEnabledCountTemp ) == 0 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800815 stepResult1 = main.TRUE
816 else:
817 stepResult1 = main.FALSE
818
kelvin-onlab8a832582015-01-16 17:06:11 -0800819 main.step( "Compare Device active links with reference" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800820 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800821 for i in xrange( 1, ( main.numMNswitches + 1) , int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800822 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800823 for cli in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -0800824 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800825 t = main.Thread(target = cli.getDeviceLinksActiveCount,
826 threadID = main.threadID,
827 name = "getDevicePortsEnabledCount",
828 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800829 t.start()
830 pool.append(t)
831 i = i + 1
832 main.threadID = main.threadID + 1
833 for thread in pool:
834 thread.join()
835 linkCountResult = thread.result
836 linkCountTemp = re.split( r'\t+', linkCountResult )
837 linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
838 deviceActiveLinksCountTemp.append( linkCount )
839 print "Device Active Links Count Stored: \n", str( main.deviceActiveLinksCount )
840 time2 = time.time()
841 main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800842 main.log.info (
843 "Device Active links EXPECTED: %s" %
844 str( main.deviceActiveLinksCount ) )
845 main.log.info (
846 "Device Active links ACTUAL: %s" % str( deviceActiveLinksCountTemp ) )
847 if ( cmp( main.deviceActiveLinksCount, deviceActiveLinksCountTemp ) == 0 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800848 stepResult2 = main.TRUE
849 else:
850 stepResult2 = main.FALSE
851
kelvin-onlab8a832582015-01-16 17:06:11 -0800852 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800853 place holder for comparing devices, hosts, paths and intents if required.
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800854 Links and ports data would be incorrect with out devices anyways.
kelvin-onlab8a832582015-01-16 17:06:11 -0800855 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800856 case5Result = ( stepResult1 and stepResult2 )
857 utilities.assert_equals( expect=main.TRUE, actual=case5Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800858 onpass="Compare Topology test PASS",
859 onfail="Compare Topology test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800860
kelvin-onlab65a72d22015-03-26 13:46:32 -0700861 def CASE60( self ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800862 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700863 Install 300 host intents and verify ping all (Att Topology)
kelvin-onlab8a832582015-01-16 17:06:11 -0800864 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700865 main.log.report( "Add 300 host intents and verify pingall (Att Topology)" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800866 main.log.report( "_______________________________________" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800867 import itertools
Hari Krishnaef1bd4e2015-03-12 16:55:30 -0700868 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800869 main.case( "Install 300 host intents" )
870 main.step( "Add host Intents" )
871 intentResult = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800872 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800873
kelvin-onlab54400a92015-02-26 18:05:51 -0800874 intentIdList = []
875 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800876 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800877 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800878 for cli in main.CLIs:
879 if i >= len( hostCombos ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800880 break
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800881 t = main.Thread( target=cli.addHostIntent,
882 threadID=main.threadID,
kelvin-onlab54400a92015-02-26 18:05:51 -0800883 name="addHostIntent",
884 args=[hostCombos[i][0],hostCombos[i][1]])
885 pool.append(t)
886 t.start()
887 i = i + 1
888 main.threadID = main.threadID + 1
889 for thread in pool:
890 thread.join()
891 intentIdList.append(thread.result)
892 time2 = time.time()
kelvin-onlabadfc8db2015-03-24 15:52:48 -0700893 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
894
kelvin-onlab54400a92015-02-26 18:05:51 -0800895 intentResult = main.TRUE
896 intentsJson = main.ONOScli2.intents()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800897 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
kelvin-onlab54400a92015-02-26 18:05:51 -0800898 intentsJson = intentsJson)
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800899 print getIntentStateResult
Hari Krishnab35c6d02015-03-18 11:13:51 -0700900 # Takes awhile for all the onos to get the intents
Hari Krishnaef1bd4e2015-03-12 16:55:30 -0700901 time.sleep(30)
kelvin-onlab8a832582015-01-16 17:06:11 -0800902 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800903 pingResult = main.FALSE
904 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -0800905 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800906 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800907 timeDiff = round( ( time2 - time1 ), 2 )
908 main.log.report(
909 "Time taken for Ping All: " +
910 str( timeDiff ) +
911 " seconds" )
912 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
913 onpass="PING ALL PASS",
914 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800915
kelvin-onlab65a72d22015-03-26 13:46:32 -0700916 case60Result = ( intentResult and pingResult )
kelvin-onlab54400a92015-02-26 18:05:51 -0800917
kelvin-onlab8a832582015-01-16 17:06:11 -0800918 utilities.assert_equals(
919 expect=main.TRUE,
kelvin-onlab65a72d22015-03-26 13:46:32 -0700920 actual=case60Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800921 onpass="Install 300 Host Intents and Ping All test PASS",
922 onfail="Install 300 Host Intents and Ping All test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800923
kelvin-onlab65a72d22015-03-26 13:46:32 -0700924 def CASE61( self ):
925 """
926 Install 600 host intents and verify ping all for Chordal Topology
927 """
928 main.log.report( "Add 600 host intents and verify pingall (Chordal Topo)" )
929 main.log.report( "_______________________________________" )
930 import itertools
931
932 main.case( "Install 600 host intents" )
933 main.step( "Add host Intents" )
934 intentResult = main.TRUE
935 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
936
937 intentIdList = []
938 time1 = time.time()
939
940 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
941 pool = []
942 for cli in main.CLIs:
943 if i >= len( hostCombos ):
944 break
945 t = main.Thread( target=cli.addHostIntent,
946 threadID=main.threadID,
947 name="addHostIntent",
948 args=[hostCombos[i][0],hostCombos[i][1]])
949 pool.append(t)
950 t.start()
951 i = i + 1
952 main.threadID = main.threadID + 1
953 for thread in pool:
954 thread.join()
955 intentIdList.append(thread.result)
956 time2 = time.time()
957 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
958 intentResult = main.TRUE
959 intentsJson = main.ONOScli2.intents()
960 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
961 intentsJson = intentsJson)
962 print getIntentStateResult
963
964 main.step( "Verify Ping across all hosts" )
965 pingResult = main.FALSE
966 time1 = time.time()
967 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
968 time2 = time.time()
969 timeDiff = round( ( time2 - time1 ), 2 )
970 main.log.report(
971 "Time taken for Ping All: " +
972 str( timeDiff ) +
973 " seconds" )
974 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
975 onpass="PING ALL PASS",
976 onfail="PING ALL FAIL" )
977
978 case14Result = ( intentResult and pingResult )
979
980 utilities.assert_equals(
981 expect=main.TRUE,
982 actual=case14Result,
983 onpass="Install 300 Host Intents and Ping All test PASS",
984 onfail="Install 300 Host Intents and Ping All test FAIL" )
985
986 def CASE62( self ):
987 """
988 Install 2278 host intents and verify ping all for Spine Topology
989 """
990 main.log.report( "Add 2278 host intents and verify pingall (Spine Topo)" )
991 main.log.report( "_______________________________________" )
992 import itertools
993
994 main.case( "Install 2278 host intents" )
995 main.step( "Add host Intents" )
996 intentResult = main.TRUE
997 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
998 main.pingTimeout = 300
999 intentIdList = []
1000 time1 = time.time()
1001 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
1002 pool = []
1003 for cli in main.CLIs:
1004 if i >= len( hostCombos ):
1005 break
1006 t = main.Thread( target=cli.addHostIntent,
1007 threadID=main.threadID,
1008 name="addHostIntent",
1009 args=[hostCombos[i][0],hostCombos[i][1]])
1010 pool.append(t)
1011 t.start()
1012 i = i + 1
1013 main.threadID = main.threadID + 1
1014 for thread in pool:
1015 thread.join()
1016 intentIdList.append(thread.result)
1017 time2 = time.time()
1018 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
1019 intentResult = main.TRUE
1020 intentsJson = main.ONOScli2.intents()
1021 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1022 intentsJson = intentsJson)
1023 print getIntentStateResult
1024
1025 main.step( "Verify Ping across all hosts" )
1026 pingResult = main.FALSE
1027 time1 = time.time()
1028 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
1029 time2 = time.time()
1030 timeDiff = round( ( time2 - time1 ), 2 )
1031 main.log.report(
1032 "Time taken for Ping All: " +
1033 str( timeDiff ) +
1034 " seconds" )
1035 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1036 onpass="PING ALL PASS",
1037 onfail="PING ALL FAIL" )
1038
1039 case15Result = ( intentResult and pingResult )
1040
1041 utilities.assert_equals(
1042 expect=main.TRUE,
1043 actual=case15Result,
1044 onpass="Install 2278 Host Intents and Ping All test PASS",
1045 onfail="Install 2278 Host Intents and Ping All test FAIL" )
1046
kelvin-onlab8a832582015-01-16 17:06:11 -08001047 def CASE70( self, main ):
1048 """
Hari Krishnab35c6d02015-03-18 11:13:51 -07001049 Randomly bring some core links down and verify ping all ( Host Intents-Att Topo)
kelvin-onlab8a832582015-01-16 17:06:11 -08001050 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001051 import random
Hari Krishna22c3d412015-02-17 16:48:12 -08001052 main.randomLink1 = []
1053 main.randomLink2 = []
1054 main.randomLink3 = []
kelvin-onlab65a72d22015-03-26 13:46:32 -07001055 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1056 link1End2 = main.params[ 'ATTCORELINKS' ][ 'linkS3b' ].split( ',' )
1057 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1058 link2End2 = main.params[ 'ATTCORELINKS' ][ 'linkS14b' ].split( ',' )
1059 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
1060 link3End2 = main.params[ 'ATTCORELINKS' ][ 'linkS18b' ].split( ',' )
1061 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001062 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001063
Hari Krishnab35c6d02015-03-18 11:13:51 -07001064 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Att Topo)" )
1065 main.log.report( "___________________________________________________________________________" )
Hari Krishnad97213e2015-01-24 19:30:14 -08001066 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
1067 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001068 if ( int( switchLinksToToggle ) ==
1069 0 or int( switchLinksToToggle ) > 5 ):
Hari Krishna46997e02015-01-27 11:23:07 -08001070 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 -07001071 #main.cleanup()
1072 #main.exit()
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001073 else:
Hari Krishnad97213e2015-01-24 19:30:14 -08001074 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 -08001075
kelvin-onlab8a832582015-01-16 17:06:11 -08001076 main.step( "Cut links on Core devices using user provided range" )
Hari Krishna22c3d412015-02-17 16:48:12 -08001077 main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
1078 main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
1079 main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001080 for i in range( int( switchLinksToToggle ) ):
1081 main.Mininet1.link(
1082 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001083 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001084 OPTION="down" )
1085 main.Mininet1.link(
1086 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001087 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001088 OPTION="down" )
1089 main.Mininet1.link(
1090 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001091 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001092 OPTION="down" )
1093 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001094
1095 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001096 linkDown = main.ONOSbench.checkStatus(
Hari Krishna22c3d412015-02-17 16:48:12 -08001097 topology_output, main.numMNswitches, str(
1098 int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001099 utilities.assert_equals(
1100 expect=main.TRUE,
1101 actual=linkDown,
1102 onpass="Link Down discovered properly",
1103 onfail="Link down was not discovered in " +
1104 str( link_sleep ) +
1105 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001106
kelvin-onlab8a832582015-01-16 17:06:11 -08001107 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001108 pingResultLinkDown = main.FALSE
1109 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -08001110 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout)
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001111 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001112 timeDiff = round( ( time2 - time1 ), 2 )
1113 main.log.report(
1114 "Time taken for Ping All: " +
1115 str( timeDiff ) +
1116 " seconds" )
1117 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1118 onpass="PING ALL PASS",
1119 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001120
Hari Krishna22c3d412015-02-17 16:48:12 -08001121 caseResult70 = linkDown and pingResultLinkDown
1122 utilities.assert_equals( expect=main.TRUE, actual=caseResult70,
kelvin-onlab8a832582015-01-16 17:06:11 -08001123 onpass="Random Link cut Test PASS",
1124 onfail="Random Link cut Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001125
kelvin-onlab8a832582015-01-16 17:06:11 -08001126 def CASE80( self, main ):
1127 """
Hari Krishnab35c6d02015-03-18 11:13:51 -07001128 Bring the core links up that are down and verify ping all ( Host Intents-Att Topo )
kelvin-onlab8a832582015-01-16 17:06:11 -08001129 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001130 import random
kelvin-onlab65a72d22015-03-26 13:46:32 -07001131 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1132 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1133 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001134 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001135 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001136
kelvin-onlab8a832582015-01-16 17:06:11 -08001137 main.log.report(
Hari Krishnab35c6d02015-03-18 11:13:51 -07001138 "Bring the core links up that are down and verify ping all (Host Intents-Att Topo" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001139 main.log.report(
1140 "__________________________________________________________________" )
1141 main.case(
1142 "Host intents - Bring the core links up that are down and verify ping all" )
1143 main.step( "Bring randomly cut links on Core devices up" )
1144 for i in range( int( switchLinksToToggle ) ):
1145 main.Mininet1.link(
1146 END1=link1End1,
kelvin-onlab54400a92015-02-26 18:05:51 -08001147 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001148 OPTION="up" )
1149 main.Mininet1.link(
1150 END1=link2End1,
kelvin-onlab54400a92015-02-26 18:05:51 -08001151 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001152 OPTION="up" )
1153 main.Mininet1.link(
1154 END1=link3End1,
kelvin-onlab54400a92015-02-26 18:05:51 -08001155 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001156 OPTION="up" )
1157 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001158
1159 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001160 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -08001161 topology_output,
Hari Krishna22c3d412015-02-17 16:48:12 -08001162 main.numMNswitches,
1163 str( main.numMNlinks ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001164 utilities.assert_equals(
1165 expect=main.TRUE,
1166 actual=linkUp,
1167 onpass="Link up discovered properly",
1168 onfail="Link up was not discovered in " +
1169 str( link_sleep ) +
1170 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001171
kelvin-onlab8a832582015-01-16 17:06:11 -08001172 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001173 pingResultLinkUp = main.FALSE
1174 time1 = time.time()
1175 pingResultLinkUp = main.Mininet1.pingall()
1176 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001177 timeDiff = round( ( time2 - time1 ), 2 )
1178 main.log.report(
1179 "Time taken for Ping All: " +
1180 str( timeDiff ) +
1181 " seconds" )
1182 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1183 onpass="PING ALL PASS",
1184 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001185
Hari Krishna22c3d412015-02-17 16:48:12 -08001186 caseResult80 = linkUp and pingResultLinkUp
1187 utilities.assert_equals( expect=main.TRUE, actual=caseResult80,
kelvin-onlab8a832582015-01-16 17:06:11 -08001188 onpass="Link Up Test PASS",
1189 onfail="Link Up Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001190
kelvin-onlab8a832582015-01-16 17:06:11 -08001191 def CASE71( self, main ):
1192 """
kelvin-onlab65a72d22015-03-26 13:46:32 -07001193 Randomly bring some core links down and verify ping all ( Host Intents-Att Topo)
kelvin-onlab8a832582015-01-16 17:06:11 -08001194 """
kelvin8ec71442015-01-15 16:57:00 -08001195 import random
Hari Krishna22c3d412015-02-17 16:48:12 -08001196 main.randomLink1 = []
1197 main.randomLink2 = []
1198 main.randomLink3 = []
kelvin-onlab65a72d22015-03-26 13:46:32 -07001199 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1200 link1End2 = main.params[ 'ATTCORELINKS' ][ 'linkS3b' ].split( ',' )
1201 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1202 link2End2 = main.params[ 'ATTCORELINKS' ][ 'linkS14b' ].split( ',' )
1203 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
1204 link3End2 = main.params[ 'ATTCORELINKS' ][ 'linkS18b' ].split( ',' )
1205 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001206 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin8ec71442015-01-15 16:57:00 -08001207
kelvin-onlab65a72d22015-03-26 13:46:32 -07001208 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Att Topo)" )
1209 main.log.report( "___________________________________________________________________________" )
1210 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
Hari Krishnad97213e2015-01-24 19:30:14 -08001211 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001212 if ( int( switchLinksToToggle ) ==
1213 0 or int( switchLinksToToggle ) > 5 ):
kelvin-onlab65a72d22015-03-26 13:46:32 -07001214 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 -07001215 #main.cleanup()
1216 #main.exit()
kelvin8ec71442015-01-15 16:57:00 -08001217 else:
kelvin-onlab65a72d22015-03-26 13:46:32 -07001218 main.log.info( "User provided Core switch links range to toggle is correct, proceeding to run the test" )
kelvin8ec71442015-01-15 16:57:00 -08001219
kelvin-onlab8a832582015-01-16 17:06:11 -08001220 main.step( "Cut links on Core devices using user provided range" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001221 main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
1222 main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
1223 main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001224 for i in range( int( switchLinksToToggle ) ):
1225 main.Mininet1.link(
1226 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001227 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001228 OPTION="down" )
1229 main.Mininet1.link(
1230 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001231 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001232 OPTION="down" )
1233 main.Mininet1.link(
1234 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001235 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001236 OPTION="down" )
1237 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -08001238
1239 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001240 linkDown = main.ONOSbench.checkStatus(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001241 topology_output, main.numMNswitches, str(
1242 int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001243 utilities.assert_equals(
1244 expect=main.TRUE,
1245 actual=linkDown,
1246 onpass="Link Down discovered properly",
1247 onfail="Link down was not discovered in " +
1248 str( link_sleep ) +
1249 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -08001250
kelvin-onlab8a832582015-01-16 17:06:11 -08001251 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -08001252 pingResultLinkDown = main.FALSE
1253 time1 = time.time()
kelvin-onlab65a72d22015-03-26 13:46:32 -07001254 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout)
kelvin8ec71442015-01-15 16:57:00 -08001255 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001256 timeDiff = round( ( time2 - time1 ), 2 )
1257 main.log.report(
1258 "Time taken for Ping All: " +
1259 str( timeDiff ) +
1260 " seconds" )
1261 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1262 onpass="PING ALL PASS",
1263 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001264
kelvin-onlab65a72d22015-03-26 13:46:32 -07001265 caseResult71 = linkDown and pingResultLinkDown
1266 utilities.assert_equals( expect=main.TRUE, actual=caseResult71,
kelvin-onlab8a832582015-01-16 17:06:11 -08001267 onpass="Random Link cut Test PASS",
1268 onfail="Random Link cut Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001269
kelvin-onlab8a832582015-01-16 17:06:11 -08001270 def CASE81( self, main ):
1271 """
kelvin-onlab65a72d22015-03-26 13:46:32 -07001272 Bring the core links up that are down and verify ping all ( Host Intents-Att Topo )
kelvin-onlab8a832582015-01-16 17:06:11 -08001273 """
kelvin8ec71442015-01-15 16:57:00 -08001274 import random
kelvin-onlab65a72d22015-03-26 13:46:32 -07001275 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1276 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1277 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001278 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001279 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
kelvin8ec71442015-01-15 16:57:00 -08001280
kelvin-onlab8a832582015-01-16 17:06:11 -08001281 main.log.report(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001282 "Bring the core links up that are down and verify ping all (Host Intents-Att Topo" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001283 main.log.report(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001284 "__________________________________________________________________" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001285 main.case(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001286 "Host intents - Bring the core links up that are down and verify ping all" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001287 main.step( "Bring randomly cut links on Core devices up" )
1288 for i in range( int( switchLinksToToggle ) ):
1289 main.Mininet1.link(
1290 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001291 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001292 OPTION="up" )
1293 main.Mininet1.link(
1294 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001295 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001296 OPTION="up" )
1297 main.Mininet1.link(
1298 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001299 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001300 OPTION="up" )
1301 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -08001302
1303 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001304 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -08001305 topology_output,
Hari Krishna22c3d412015-02-17 16:48:12 -08001306 main.numMNswitches,
1307 str( main.numMNlinks ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001308 utilities.assert_equals(
1309 expect=main.TRUE,
1310 actual=linkUp,
1311 onpass="Link up discovered properly",
1312 onfail="Link up was not discovered in " +
1313 str( link_sleep ) +
1314 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -08001315
kelvin-onlab8a832582015-01-16 17:06:11 -08001316 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -08001317 pingResultLinkUp = main.FALSE
1318 time1 = time.time()
kelvin-onlab77d6c302015-03-31 11:33:32 -07001319 pingResultLinkUp = main.Mininet1.pingall(timeout = main.pingTimeout)
kelvin8ec71442015-01-15 16:57:00 -08001320 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001321 timeDiff = round( ( time2 - time1 ), 2 )
1322 main.log.report(
1323 "Time taken for Ping All: " +
1324 str( timeDiff ) +
1325 " seconds" )
1326 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1327 onpass="PING ALL PASS",
1328 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001329
Hari Krishna22c3d412015-02-17 16:48:12 -08001330 caseResult81 = linkUp and pingResultLinkUp
1331 utilities.assert_equals( expect=main.TRUE, actual=caseResult81,
kelvin-onlab8a832582015-01-16 17:06:11 -08001332 onpass="Link Up Test PASS",
1333 onfail="Link Up Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001334
Hari Krishnab35c6d02015-03-18 11:13:51 -07001335 def CASE72( self, main ):
1336 """
1337 Randomly bring some links down and verify ping all ( Host Intents-Chordal Topo)
1338 """
1339 import random
1340 import itertools
1341 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1342
1343 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Chordal Topo)" )
1344 main.log.report( "___________________________________________________________________________" )
1345 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
1346 switches = []
1347 switchesComb = []
1348 for i in range( main.numMNswitches ):
1349 switches.append('s%d'%(i+1))
1350 switchesLinksComb = list(itertools.combinations(switches,2))
1351 main.randomLinks = random.sample(switchesLinksComb, 5 )
1352 print main.randomLinks
1353 main.step( "Cut links on random devices" )
1354
1355 for switch in main.randomLinks:
1356 main.Mininet1.link(
1357 END1=switch[0],
1358 END2=switch[1],
1359 OPTION="down")
1360 time.sleep( link_sleep )
1361
1362 topology_output = main.ONOScli2.topology()
1363 linkDown = main.ONOSbench.checkStatus(
1364 topology_output, main.numMNswitches, str(
1365 int( main.numMNlinks ) - 5 * 2 ) )
1366 utilities.assert_equals(
1367 expect=main.TRUE,
1368 actual=linkDown,
1369 onpass="Link Down discovered properly",
1370 onfail="Link down was not discovered in " +
1371 str( link_sleep ) +
1372 " seconds" )
1373
1374 main.step( "Verify Ping across all hosts" )
1375 pingResultLinkDown = main.FALSE
1376 time1 = time.time()
1377 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout)
1378 time2 = time.time()
1379 timeDiff = round( ( time2 - time1 ), 2 )
1380 main.log.report(
1381 "Time taken for Ping All: " +
1382 str( timeDiff ) +
1383 " seconds" )
1384 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1385 onpass="PING ALL PASS",
1386 onfail="PING ALL FAIL" )
1387
kelvin-onlab65a72d22015-03-26 13:46:32 -07001388 caseResult71 = pingResultLinkDown
1389 utilities.assert_equals( expect=main.TRUE, actual=caseResult71,
Hari Krishnab35c6d02015-03-18 11:13:51 -07001390 onpass="Random Link cut Test PASS",
1391 onfail="Random Link cut Test FAIL" )
1392
1393 def CASE82( self, main ):
1394 """
1395 Bring the core links up that are down and verify ping all ( Host Intents Chordal Topo )
1396 """
1397 import random
1398 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1399
1400 main.log.report(
1401 "Bring the core links up that are down and verify ping all (Host Intents-Chordal Topo" )
1402 main.log.report(
1403 "__________________________________________________________________" )
1404 main.case(
1405 "Host intents - Bring the core links up that are down and verify ping all" )
1406 main.step( "Bring randomly cut links on devices up" )
1407
1408 for switch in main.randomLinks:
1409 main.Mininet1.link(
1410 END1=switch[0],
1411 END2=switch[1],
1412 OPTION="up")
1413
1414 time.sleep( link_sleep )
1415
1416 topology_output = main.ONOScli2.topology()
1417 linkUp = main.ONOSbench.checkStatus(
1418 topology_output,
1419 main.numMNswitches,
1420 str( main.numMNlinks ) )
1421 utilities.assert_equals(
1422 expect=main.TRUE,
1423 actual=linkUp,
1424 onpass="Link up discovered properly",
1425 onfail="Link up was not discovered in " +
1426 str( link_sleep ) +
1427 " seconds" )
1428
1429 main.step( "Verify Ping across all hosts" )
1430 pingResultLinkUp = main.FALSE
1431 time1 = time.time()
kelvin-onlab77d6c302015-03-31 11:33:32 -07001432 pingResultLinkUp = main.Mininet1.pingall(timeout = main.pingTimeout)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001433 time2 = time.time()
1434 timeDiff = round( ( time2 - time1 ), 2 )
1435 main.log.report(
1436 "Time taken for Ping All: " +
1437 str( timeDiff ) +
1438 " seconds" )
1439 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1440 onpass="PING ALL PASS",
1441 onfail="PING ALL FAIL" )
1442
1443 caseResult82 = linkUp and pingResultLinkUp
1444 utilities.assert_equals( expect=main.TRUE, actual=caseResult82,
1445 onpass="Link Up Test PASS",
1446 onfail="Link Up Test FAIL" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001447
Hari Krishnab35c6d02015-03-18 11:13:51 -07001448 def CASE73( self, main ):
1449 """
kelvin-onlab65a72d22015-03-26 13:46:32 -07001450 Randomly bring some links down and verify ping all ( Host Intents-Chordal Topo)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001451 """
1452 import random
kelvin-onlab65a72d22015-03-26 13:46:32 -07001453 import itertools
Hari Krishnab35c6d02015-03-18 11:13:51 -07001454 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001455
1456 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Chordal Topo)" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001457 main.log.report( "___________________________________________________________________________" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001458 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
1459 switches = []
1460 switchesComb = []
1461 for i in range( main.numMNswitches ):
1462 switches.append('s%d'%(i+1))
1463 switchesLinksComb = list(itertools.combinations(switches,2))
1464 main.randomLinks = random.sample(switchesLinksComb, 5 )
1465 print main.randomLinks
1466 main.step( "Cut links on random devices" )
1467
1468 for switch in main.randomLinks:
Hari Krishnab35c6d02015-03-18 11:13:51 -07001469 main.Mininet1.link(
1470 END1=switch[0],
1471 END2=switch[1],
kelvin-onlab65a72d22015-03-26 13:46:32 -07001472 OPTION="down")
Hari Krishnab35c6d02015-03-18 11:13:51 -07001473 time.sleep( link_sleep )
1474
1475 topology_output = main.ONOScli2.topology()
1476 linkDown = main.ONOSbench.checkStatus(
1477 topology_output, main.numMNswitches, str(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001478 int( main.numMNlinks ) - 5 * 2 ) )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001479 utilities.assert_equals(
1480 expect=main.TRUE,
1481 actual=linkDown,
1482 onpass="Link Down discovered properly",
1483 onfail="Link down was not discovered in " +
1484 str( link_sleep ) +
1485 " seconds" )
1486
1487 main.step( "Verify Ping across all hosts" )
1488 pingResultLinkDown = main.FALSE
1489 time1 = time.time()
1490 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout)
1491 time2 = time.time()
1492 timeDiff = round( ( time2 - time1 ), 2 )
1493 main.log.report(
1494 "Time taken for Ping All: " +
1495 str( timeDiff ) +
1496 " seconds" )
1497 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1498 onpass="PING ALL PASS",
1499 onfail="PING ALL FAIL" )
1500
kelvin-onlab65a72d22015-03-26 13:46:32 -07001501 caseResult73 = pingResultLinkDown
Hari Krishnab35c6d02015-03-18 11:13:51 -07001502 utilities.assert_equals( expect=main.TRUE, actual=caseResult73,
1503 onpass="Random Link cut Test PASS",
1504 onfail="Random Link cut Test FAIL" )
1505
1506 def CASE83( self, main ):
1507 """
kelvin-onlab65a72d22015-03-26 13:46:32 -07001508 Bring the core links up that are down and verify ping all ( Host Intents Chordal Topo )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001509 """
1510 import random
Hari Krishnab35c6d02015-03-18 11:13:51 -07001511 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001512
Hari Krishnab35c6d02015-03-18 11:13:51 -07001513 main.log.report(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001514 "Bring the core links up that are down and verify ping all (Host Intents-Chordal Topo" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001515 main.log.report(
1516 "__________________________________________________________________" )
1517 main.case(
1518 "Host intents - Bring the core links up that are down and verify ping all" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001519 main.step( "Bring randomly cut links on devices up" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001520
kelvin-onlab65a72d22015-03-26 13:46:32 -07001521 for switch in main.randomLinks:
Hari Krishnab35c6d02015-03-18 11:13:51 -07001522 main.Mininet1.link(
1523 END1=switch[0],
1524 END2=switch[1],
1525 OPTION="up")
kelvin-onlab65a72d22015-03-26 13:46:32 -07001526
Hari Krishnab35c6d02015-03-18 11:13:51 -07001527 time.sleep( link_sleep )
1528
1529 topology_output = main.ONOScli2.topology()
1530 linkUp = main.ONOSbench.checkStatus(
1531 topology_output,
1532 main.numMNswitches,
1533 str( main.numMNlinks ) )
1534 utilities.assert_equals(
1535 expect=main.TRUE,
1536 actual=linkUp,
1537 onpass="Link up discovered properly",
1538 onfail="Link up was not discovered in " +
1539 str( link_sleep ) +
1540 " seconds" )
1541
1542 main.step( "Verify Ping across all hosts" )
1543 pingResultLinkUp = main.FALSE
1544 time1 = time.time()
kelvin-onlab77d6c302015-03-31 11:33:32 -07001545 pingResultLinkUp = main.Mininet1.pingall(timeout = main.pingTimeout)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001546 time2 = time.time()
1547 timeDiff = round( ( time2 - time1 ), 2 )
1548 main.log.report(
1549 "Time taken for Ping All: " +
1550 str( timeDiff ) +
1551 " seconds" )
1552 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1553 onpass="PING ALL PASS",
1554 onfail="PING ALL FAIL" )
1555
1556 caseResult83 = linkUp and pingResultLinkUp
1557 utilities.assert_equals( expect=main.TRUE, actual=caseResult83,
1558 onpass="Link Up Test PASS",
1559 onfail="Link Up Test FAIL" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001560
1561 def CASE74( self, main ):
1562 """
1563 Randomly bring some core links down and verify ping all ( Host Intents-Spine Topo)
1564 """
1565 import random
1566 main.randomLink1 = []
1567 main.randomLink2 = []
1568 main.randomLink3 = []
1569 main.randomLink4 = []
1570 link1End1 = main.params[ 'SPINECORELINKS' ][ 'linkS9' ]
1571 link1End2top = main.params[ 'SPINECORELINKS' ][ 'linkS9top' ].split( ',' )
1572 link1End2bot = main.params[ 'SPINECORELINKS' ][ 'linkS9bot' ].split( ',' )
1573 link2End1 = main.params[ 'SPINECORELINKS' ][ 'linkS10' ]
1574 link2End2top = main.params[ 'SPINECORELINKS' ][ 'linkS10top' ].split( ',' )
1575 link2End2bot = main.params[ 'SPINECORELINKS' ][ 'linkS10bot' ].split( ',' )
1576 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1577 main.pingTimeout = 400
1578
1579 main.log.report( "Bring some core links down and verify ping all (Host Intents-Spine Topo)" )
1580 main.log.report( "___________________________________________________________________________" )
1581
1582 linkIndex = range(4)
1583 linkIndexS9 = random.sample(linkIndex,1)[0]
1584 linkIndex.remove(linkIndexS9)
1585 linkIndexS10 = random.sample(linkIndex,1)[0]
1586 main.randomLink1 = link1End2top[linkIndexS9]
1587 main.randomLink2 = link2End2top[linkIndexS10]
1588 main.randomLink3 = random.sample(link1End2bot,1)[0]
1589 main.randomLink4 = random.sample(link2End2bot,1)[0]
kelvin-onlab77d6c302015-03-31 11:33:32 -07001590 # main.Mininet1.link( END1=link1End1, END2=main.randomLink1, OPTION="down" )
1591 # main.Mininet1.link( END1=link2End1, END2=main.randomLink2, OPTION="down" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001592 main.Mininet1.link( END1=link1End1, END2=main.randomLink3, OPTION="down" )
1593 main.Mininet1.link( END1=link2End1, END2=main.randomLink4, OPTION="down" )
kelvin-onlabd878fc22015-03-27 13:33:41 -07001594
kelvin-onlab65a72d22015-03-26 13:46:32 -07001595 time.sleep( link_sleep )
1596
1597 topology_output = main.ONOScli2.topology()
1598 linkDown = main.ONOSbench.checkStatus(
1599 topology_output, main.numMNswitches, str(
1600 int( main.numMNlinks ) - 8 ))
1601 utilities.assert_equals(
1602 expect=main.TRUE,
1603 actual=linkDown,
1604 onpass="Link Down discovered properly",
1605 onfail="Link down was not discovered in " +
1606 str( link_sleep ) +
1607 " seconds" )
1608
1609 main.step( "Verify Ping across all hosts" )
1610 pingResultLinkDown = main.FALSE
1611 time1 = time.time()
1612 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout)
1613 time2 = time.time()
1614 timeDiff = round( ( time2 - time1 ), 2 )
1615 main.log.report(
1616 "Time taken for Ping All: " +
1617 str( timeDiff ) +
1618 " seconds" )
1619 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1620 onpass="PING ALL PASS",
1621 onfail="PING ALL FAIL" )
1622
1623 caseResult74 = linkDown and pingResultLinkDown
1624 utilities.assert_equals( expect=main.TRUE, actual=caseResult74,
1625 onpass="Random Link cut Test PASS",
1626 onfail="Random Link cut Test FAIL" )
1627
1628 def CASE84( self, main ):
1629 """
1630 Bring the core links up that are down and verify ping all ( Host Intents-Spine Topo )
1631 """
1632 import random
1633 link1End1 = main.params[ 'SPINECORELINKS' ][ 'linkS9' ]
1634 link2End1 = main.params[ 'SPINECORELINKS' ][ 'linkS10' ]
1635 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1636 main.log.report(
1637 "Bring the core links up that are down and verify ping all (Host Intents-Spine Topo" )
1638 main.log.report(
1639 "__________________________________________________________________" )
1640 main.case(
1641 "Host intents - Bring the core links up that are down and verify ping all" )
1642
kelvin-onlab77d6c302015-03-31 11:33:32 -07001643 #main.Mininet1.link( END1=link1End1, END2=main.randomLink1, OPTION="up" )
1644 #main.Mininet1.link( END1=link2End1, END2=main.randomLink2, OPTION="up" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001645 main.Mininet1.link( END1=link1End1, END2=main.randomLink3, OPTION="up" )
1646 main.Mininet1.link( END1=link2End1, END2=main.randomLink4, OPTION="up" )
1647
1648 time.sleep( link_sleep )
1649 topology_output = main.ONOScli2.topology()
1650 linkUp = main.ONOSbench.checkStatus(
1651 topology_output,
1652 main.numMNswitches,
1653 str( main.numMNlinks ) )
1654 utilities.assert_equals(
1655 expect=main.TRUE,
1656 actual=linkUp,
1657 onpass="Link up discovered properly",
1658 onfail="Link up was not discovered in " +
1659 str( link_sleep ) +
1660 " seconds" )
1661
1662 main.step( "Verify Ping across all hosts" )
1663 pingResultLinkUp = main.FALSE
1664 time1 = time.time()
kelvin-onlab77d6c302015-03-31 11:33:32 -07001665 pingResultLinkUp = main.Mininet1.pingall(timeout = main.pingTimeout)
kelvin-onlab65a72d22015-03-26 13:46:32 -07001666 time2 = time.time()
1667 timeDiff = round( ( time2 - time1 ), 2 )
1668 main.log.report(
1669 "Time taken for Ping All: " +
1670 str( timeDiff ) +
1671 " seconds" )
1672 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1673 onpass="PING ALL PASS",
1674 onfail="PING ALL FAIL" )
1675
1676 caseResult84 = linkUp and pingResultLinkUp
1677 utilities.assert_equals( expect=main.TRUE, actual=caseResult84,
1678 onpass="Link Up Test PASS",
1679 onfail="Link Up Test FAIL" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001680
1681 def CASE90( self ):
kelvin-onlab8a832582015-01-16 17:06:11 -08001682 """
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001683 Install 600 point intents and verify ping all (Att Topology)
kelvin-onlab8a832582015-01-16 17:06:11 -08001684 """
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001685 main.log.report( "Add 600 point intents and verify pingall (Att Topology)" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001686 main.log.report( "_______________________________________" )
1687 import itertools
1688 import time
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001689 main.case( "Install 600 point intents" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001690 main.step( "Add point Intents" )
1691 intentResult = main.TRUE
1692 deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) )
1693
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001694 intentIdList = []
Hari Krishnab35c6d02015-03-18 11:13:51 -07001695 time1 = time.time()
Hari Krishnab35c6d02015-03-18 11:13:51 -07001696 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1697 pool = []
1698 for cli in main.CLIs:
1699 if i >= len( deviceCombos ):
1700 break
1701 t = main.Thread( target=cli.addPointIntent,
1702 threadID=main.threadID,
1703 name="addPointIntent",
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001704 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
Hari Krishnab35c6d02015-03-18 11:13:51 -07001705 pool.append(t)
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001706 #time.sleep(1)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001707 t.start()
1708 i = i + 1
1709 main.threadID = main.threadID + 1
1710 for thread in pool:
1711 thread.join()
1712 intentIdList.append(thread.result)
1713 time2 = time.time()
1714 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1715 intentResult = main.TRUE
1716 intentsJson = main.ONOScli2.intents()
1717 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1718 intentsJson = intentsJson)
1719 print getIntentStateResult
1720 # Takes awhile for all the onos to get the intents
1721 time.sleep(30)
kelvin-onlab8a832582015-01-16 17:06:11 -08001722 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001723 pingResult = main.FALSE
1724 time1 = time.time()
Hari Krishnab35c6d02015-03-18 11:13:51 -07001725 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001726 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001727 timeDiff = round( ( time2 - time1 ), 2 )
1728 main.log.report(
1729 "Time taken for Ping All: " +
1730 str( timeDiff ) +
1731 " seconds" )
1732 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1733 onpass="PING ALL PASS",
1734 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001735
kelvin-onlab65a72d22015-03-26 13:46:32 -07001736 case90Result = ( intentResult and pingResult )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001737
kelvin-onlab8a832582015-01-16 17:06:11 -08001738 utilities.assert_equals(
1739 expect=main.TRUE,
kelvin-onlab65a72d22015-03-26 13:46:32 -07001740 actual=case90Result,
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001741 onpass="Install 600 point Intents and Ping All test PASS",
1742 onfail="Install 600 point Intents and Ping All test FAIL" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001743
1744 def CASE91( self ):
1745 """
1746 Install ###$$$ point intents and verify ping all (Chordal Topology)
1747 """
1748 main.log.report( "Add ###$$$ point intents and verify pingall (Chordal Topology)" )
1749 main.log.report( "_______________________________________" )
1750 import itertools
1751 import time
1752 main.case( "Install ###$$$ point intents" )
1753 main.step( "Add point Intents" )
1754 intentResult = main.TRUE
1755 deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) )
1756
1757 intentIdList = []
1758 time1 = time.time()
1759 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1760 pool = []
1761 for cli in main.CLIs:
1762 if i >= len( deviceCombos ):
1763 break
1764 t = main.Thread( target=cli.addPointIntent,
1765 threadID=main.threadID,
1766 name="addPointIntent",
1767 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
1768 pool.append(t)
1769 #time.sleep(1)
1770 t.start()
1771 i = i + 1
1772 main.threadID = main.threadID + 1
1773 for thread in pool:
1774 thread.join()
1775 intentIdList.append(thread.result)
1776 time2 = time.time()
1777 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1778 intentResult = main.TRUE
1779 intentsJson = main.ONOScli2.intents()
1780 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1781 intentsJson = intentsJson)
1782 print getIntentStateResult
1783 # Takes awhile for all the onos to get the intents
1784 time.sleep(30)
1785 main.step( "Verify Ping across all hosts" )
1786 pingResult = main.FALSE
1787 time1 = time.time()
1788 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
1789 time2 = time.time()
1790 timeDiff = round( ( time2 - time1 ), 2 )
1791 main.log.report(
1792 "Time taken for Ping All: " +
1793 str( timeDiff ) +
1794 " seconds" )
1795 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1796 onpass="PING ALL PASS",
1797 onfail="PING ALL FAIL" )
1798
kelvin-onlab65a72d22015-03-26 13:46:32 -07001799 case91Result = ( intentResult and pingResult )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001800
1801 utilities.assert_equals(
1802 expect=main.TRUE,
kelvin-onlabd878fc22015-03-27 13:33:41 -07001803 actual=case91Result,
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001804 onpass="Install ###$$$ point Intents and Ping All test PASS",
1805 onfail="Install ###$$$ point Intents and Ping All test FAIL" )
1806
1807 def CASE92( self ):
1808 """
kelvin-onlab77d6c302015-03-31 11:33:32 -07001809 Install 4556 point intents and verify ping all (Spine Topology)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001810 """
kelvin-onlab77d6c302015-03-31 11:33:32 -07001811 main.log.report( "Add 4556 point intents and verify pingall (Spine Topology)" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001812 main.log.report( "_______________________________________" )
1813 import itertools
1814 import time
kelvin-onlab77d6c302015-03-31 11:33:32 -07001815 main.case( "Install 4556 point intents" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001816 main.step( "Add point Intents" )
1817 intentResult = main.TRUE
kelvin-onlab77d6c302015-03-31 11:33:32 -07001818 main.pingTimeout = 600
1819 for i in range(len(main.hostMACs)):
1820 main.MACsDict[main.deviceDPIDs[i+10]] = main.hostMACs[i].split('/')[0]
1821 print main.MACsDict
1822 deviceCombos = list( itertools.permutations( main.deviceDPIDs[10:], 2 ) )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001823
1824 intentIdList = []
1825 time1 = time.time()
1826 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1827 pool = []
1828 for cli in main.CLIs:
1829 if i >= len( deviceCombos ):
1830 break
1831 t = main.Thread( target=cli.addPointIntent,
1832 threadID=main.threadID,
1833 name="addPointIntent",
1834 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
1835 pool.append(t)
1836 #time.sleep(1)
1837 t.start()
1838 i = i + 1
1839 main.threadID = main.threadID + 1
1840 for thread in pool:
1841 thread.join()
1842 intentIdList.append(thread.result)
1843 time2 = time.time()
1844 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1845 intentResult = main.TRUE
1846 intentsJson = main.ONOScli2.intents()
1847 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1848 intentsJson = intentsJson)
kelvin-onlab77d6c302015-03-31 11:33:32 -07001849 #print getIntentStateResult
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001850 # Takes awhile for all the onos to get the intents
kelvin-onlab77d6c302015-03-31 11:33:32 -07001851 time.sleep(60)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001852 main.step( "Verify Ping across all hosts" )
1853 pingResult = main.FALSE
1854 time1 = time.time()
1855 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
1856 time2 = time.time()
1857 timeDiff = round( ( time2 - time1 ), 2 )
1858 main.log.report(
1859 "Time taken for Ping All: " +
1860 str( timeDiff ) +
1861 " seconds" )
1862 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1863 onpass="PING ALL PASS",
1864 onfail="PING ALL FAIL" )
1865
kelvin-onlab65a72d22015-03-26 13:46:32 -07001866 case92Result = ( intentResult and pingResult )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001867
1868 utilities.assert_equals(
1869 expect=main.TRUE,
kelvin-onlab65a72d22015-03-26 13:46:32 -07001870 actual=case92Result,
kelvin-onlab77d6c302015-03-31 11:33:32 -07001871 onpass="Install 4556 point Intents and Ping All test PASS",
1872 onfail="Install 4556 point Intents and Ping All test FAIL" )
1873
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001874 def CASE93( self ):
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001875 """
kelvin-onlab77d6c302015-03-31 11:33:32 -07001876 Install multi-single point intents and verify Ping all works
1877 for att topology
1878 """
1879 import copy
1880 import time
1881 main.log.report( "Install multi-single point intents and verify Ping all" )
1882 main.log.report( "___________________________________________" )
1883 main.case( "Install multi-single point intents and Ping all" )
1884 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
1885 portIngressList = ['1']*(len(deviceDPIDsCopy) - 1)
1886 intentIdList = []
1887 print "MACsDict", main.MACsDict
1888 time1 = time.time()
1889 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
1890 pool = []
1891 for cli in main.CLIs:
1892 egressDevice = deviceDPIDsCopy[i]
1893 ingressDeviceList = copy.copy(deviceDPIDsCopy)
1894 ingressDeviceList.remove(egressDevice)
1895 if i >= len( deviceDPIDsCopy ):
1896 break
1897 t = main.Thread( target=cli.addMultipointToSinglepointIntent,
1898 threadID=main.threadID,
1899 name="addMultipointToSinglepointIntent",
1900 args =[ingressDeviceList,egressDevice,portIngressList,'1','IPV4','',main.MACsDict.get(egressDevice)])
1901 pool.append(t)
1902 #time.sleep(1)
1903 t.start()
1904 i = i + 1
1905 main.threadID = main.threadID + 1
1906 for thread in pool:
1907 thread.join()
1908 intentIdList.append(thread.result)
1909 time2 = time.time()
1910 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
kelvin-onlab06ade552015-03-31 18:09:27 -07001911 print intentIdList
kelvin-onlab77d6c302015-03-31 11:33:32 -07001912 time.sleep(5)
1913 main.step( "Verify Ping across all hosts" )
1914 pingResult = main.FALSE
1915 time1 = time.time()
1916 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
1917 time2 = time.time()
1918 timeDiff = round( ( time2 - time1 ), 2 )
1919 main.log.report(
1920 "Time taken for Ping All: " +
1921 str( timeDiff ) +
1922 " seconds" )
1923
1924 case93Result = pingResult
1925 utilities.assert_equals(
1926 expect=main.TRUE,
1927 actual=case93Result,
1928 onpass="Install 25 multi to single point Intents and Ping All test PASS",
1929 onfail="Install 25 multi to single point Intents and Ping All test FAIL" )
1930
kelvin-onlab20c712a2015-03-31 12:55:34 -07001931 def CASE94( self ):
1932 """
1933 Install multi-single point intents and verify Ping all works
1934 for spine topology
1935 """
1936 import copy
1937 import time
1938 main.log.report( "Install multi-single point intents and verify Ping all" )
1939 main.log.report( "___________________________________________" )
1940 main.case( "Install multi-single point intents and Ping all" )
1941 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
1942 portIngressList = ['1']*(len(deviceDPIDsCopy) - 1)
1943 intentIdList = []
1944 print "MACsDict", main.MACsDict
1945 time1 = time.time()
1946 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
1947 pool = []
1948 for cli in main.CLIs:
1949 egressDevice = deviceDPIDsCopy[i]
1950 ingressDeviceList = copy.copy(deviceDPIDsCopy)
1951 ingressDeviceList.remove(egressDevice)
1952 if i >= len( deviceDPIDsCopy ):
1953 break
1954 t = main.Thread( target=cli.addMultipointToSinglepointIntent,
1955 threadID=main.threadID,
1956 name="addMultipointToSinglepointIntent",
1957 args =[ingressDeviceList,egressDevice,portIngressList,'1','IPV4','',main.MACsDict.get(egressDevice)])
1958 pool.append(t)
1959 #time.sleep(1)
1960 t.start()
1961 i = i + 1
1962 main.threadID = main.threadID + 1
1963 for thread in pool:
1964 thread.join()
1965 intentIdList.append(thread.result)
1966 time2 = time.time()
1967 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1968 time.sleep(5)
1969 main.step( "Verify Ping across all hosts" )
1970 pingResult = main.FALSE
1971 time1 = time.time()
1972 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
1973 time2 = time.time()
1974 timeDiff = round( ( time2 - time1 ), 2 )
1975 main.log.report(
1976 "Time taken for Ping All: " +
1977 str( timeDiff ) +
1978 " seconds" )
1979
1980 case94Result = pingResult
1981 utilities.assert_equals(
1982 expect=main.TRUE,
1983 actual=case94Result,
1984 onpass="Install 25 multi to single point Intents and Ping All test PASS",
1985 onfail="Install 25 multi to single point Intents and Ping All test FAIL" )
kelvin-onlab06ade552015-03-31 18:09:27 -07001986
1987 #def CASE95 multi-single point intent for Spine
1988
kelvin-onlab77d6c302015-03-31 11:33:32 -07001989 def CASE96( self ):
1990 """
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001991 Install single-multi point intents and verify Ping all works
1992 for att topology
1993 """
1994 import copy
1995 main.log.report( "Install single-multi point intents and verify Ping all" )
1996 main.log.report( "___________________________________________" )
1997 main.case( "Install single-multi point intents and Ping all" )
kelvin-onlab06ade552015-03-31 18:09:27 -07001998 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
1999 portEgressList = ['1']*(len(deviceDPIDsCopy) - 1)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002000 intentIdList = []
kelvin-onlab06ade552015-03-31 18:09:27 -07002001 print "MACsDict", main.MACsDict
2002 time1 = time.time()
2003 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
2004 pool = []
2005 for cli in main.CLIs:
2006 ingressDevice = deviceDPIDsCopy[i]
2007 egressDeviceList = copy.copy(deviceDPIDsCopy)
2008 egressDeviceList.remove(ingressDevice)
2009 if i >= len( deviceDPIDsCopy ):
2010 break
2011 t = main.Thread( target=cli.addSinglepointToMultipointIntent,
2012 threadID=main.threadID,
2013 name="addSinglepointToMultipointIntent",
2014 args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',main.MACsDict.get(ingressDevice)])
2015 pool.append(t)
2016 #time.sleep(1)
2017 t.start()
2018 i = i + 1
2019 main.threadID = main.threadID + 1
2020 for thread in pool:
2021 thread.join()
2022 intentIdList.append(thread.result)
2023 time2 = time.time()
2024 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
2025 time.sleep(5)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002026 main.step( "Verify Ping across all hosts" )
2027 pingResult = main.FALSE
2028 time1 = time.time()
kelvin-onlab06ade552015-03-31 18:09:27 -07002029 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002030 time2 = time.time()
2031 timeDiff = round( ( time2 - time1 ), 2 )
2032 main.log.report(
2033 "Time taken for Ping All: " +
2034 str( timeDiff ) +
2035 " seconds" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002036
kelvin-onlab06ade552015-03-31 18:09:27 -07002037 case96Result = pingResult
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002038 utilities.assert_equals(
2039 expect=main.TRUE,
kelvin-onlab06ade552015-03-31 18:09:27 -07002040 actual=case96Result,
2041 onpass="Install 25 single to multi point Intents and Ping All test PASS",
2042 onfail="Install 25 single to multi point Intents and Ping All test FAIL" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002043
kelvin-onlab77d6c302015-03-31 11:33:32 -07002044 def CASE97( self ):
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002045 """
2046 Install single-multi point intents and verify Ping all works
kelvin-onlab06ade552015-03-31 18:09:27 -07002047 for Chordal topology
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002048 """
2049 import copy
2050 main.log.report( "Install single-multi point intents and verify Ping all" )
2051 main.log.report( "___________________________________________" )
2052 main.case( "Install single-multi point intents and Ping all" )
kelvin-onlab06ade552015-03-31 18:09:27 -07002053 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
2054 portEgressList = ['1']*(len(deviceDPIDsCopy) - 1)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002055 intentIdList = []
kelvin-onlab06ade552015-03-31 18:09:27 -07002056 print "MACsDict", main.MACsDict
2057 time1 = time.time()
2058 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
2059 pool = []
2060 for cli in main.CLIs:
2061 ingressDevice = deviceDPIDsCopy[i]
2062 egressDeviceList = copy.copy(deviceDPIDsCopy)
2063 egressDeviceList.remove(ingressDevice)
2064 if i >= len( deviceDPIDsCopy ):
2065 break
2066 t = main.Thread( target=cli.addSinglepointToMultipointIntent,
2067 threadID=main.threadID,
2068 name="addSinglepointToMultipointIntent",
2069 args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',main.MACsDict.get(ingressDevice),''])
2070 pool.append(t)
2071 #time.sleep(1)
2072 t.start()
2073 i = i + 1
2074 main.threadID = main.threadID + 1
2075 for thread in pool:
2076 thread.join()
2077 intentIdList.append(thread.result)
2078 time2 = time.time()
2079 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
2080 time.sleep(5)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002081 main.step( "Verify Ping across all hosts" )
2082 pingResult = main.FALSE
2083 time1 = time.time()
kelvin-onlab06ade552015-03-31 18:09:27 -07002084 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002085 time2 = time.time()
2086 timeDiff = round( ( time2 - time1 ), 2 )
2087 main.log.report(
2088 "Time taken for Ping All: " +
2089 str( timeDiff ) +
2090 " seconds" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002091
kelvin-onlab06ade552015-03-31 18:09:27 -07002092 case97Result = pingResult
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002093 utilities.assert_equals(
2094 expect=main.TRUE,
kelvin-onlab06ade552015-03-31 18:09:27 -07002095 actual=case97Result,
2096 onpass="Install 25 single to multi point Intents and Ping All test PASS",
2097 onfail="Install 25 single to multi point Intents and Ping All test FAIL" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002098
kelvin-onlab8a832582015-01-16 17:06:11 -08002099 def CASE10( self ):
kelvin-onlab7642bb12015-02-27 13:48:17 -08002100 import time
kelvin-onlab8a832582015-01-16 17:06:11 -08002101 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002102 Remove all Intents
kelvin-onlab8a832582015-01-16 17:06:11 -08002103 """
2104 main.log.report( "Remove all intents that were installed previously" )
2105 main.log.report( "______________________________________________" )
2106 main.log.info( "Remove all intents" )
2107 main.case( "Removing intents" )
2108 main.step( "Obtain the intent id's first" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002109 intentsList = main.ONOScli1.getAllIntentIds()
kelvin-onlab8a832582015-01-16 17:06:11 -08002110 ansi_escape = re.compile( r'\x1b[^m]*m' )
2111 intentsList = ansi_escape.sub( '', intentsList )
2112 intentsList = intentsList.replace(
2113 " onos:intents | grep id=",
2114 "" ).replace(
2115 "id=",
2116 "" ).replace(
2117 "\r\r",
2118 "" )
2119 intentsList = intentsList.splitlines()
2120 intentsList = intentsList[ 1: ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002121 intentIdList = []
2122 step1Result = main.TRUE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002123 moreIntents = main.TRUE
2124 removeIntentCount = 0
kelvin-onlab65a72d22015-03-26 13:46:32 -07002125 intentsCount = len(intentsList)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002126 print "Current number of intents" , len(intentsList)
kelvin-onlab8a832582015-01-16 17:06:11 -08002127 if ( len( intentsList ) > 1 ):
kelvin-onlab54400a92015-02-26 18:05:51 -08002128 results = main.TRUE
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002129 main.log.info("Removing intent...")
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002130 while moreIntents:
Hari Krishnab35c6d02015-03-18 11:13:51 -07002131 if removeIntentCount == 5:
2132 break
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002133 removeIntentCount = removeIntentCount + 1
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002134 intentsList1 = main.ONOScli1.getAllIntentIds()
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002135 if len( intentsList1 ) == 0:
2136 break
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002137 ansi_escape = re.compile( r'\x1b[^m]*m' )
2138 intentsList1 = ansi_escape.sub( '', intentsList1 )
2139 intentsList1 = intentsList1.replace(
2140 " onos:intents | grep id=",
2141 "" ).replace(
2142 " state=",
2143 "" ).replace(
2144 "\r\r",
2145 "" )
2146 intentsList1 = intentsList1.splitlines()
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002147 intentsList1 = intentsList1[ 1: ]
2148 print "Round %d intents to remove: " %(removeIntentCount)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002149 print intentsList1
2150 intentIdList1 = []
Hari Krishnab35c6d02015-03-18 11:13:51 -07002151 if ( len( intentsList1 ) > 0 ):
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002152 moreIntents = main.TRUE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002153 for i in range( len( intentsList1 ) ):
2154 intentsTemp1 = intentsList1[ i ].split( ',' )
2155 intentIdList1.append( intentsTemp1[ 0 ].split('=')[1] )
2156 print "Leftover Intent IDs: ", intentIdList1
2157 print len(intentIdList1)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07002158 time1 = time.time()
2159 for i in xrange( 0, len( intentIdList1 ), int(main.numCtrls) ):
2160 pool = []
2161 for cli in main.CLIs:
2162 if i >= len( intentIdList1 ):
2163 break
2164 t = main.Thread( target=cli.removeIntent,
2165 threadID=main.threadID,
2166 name="removeIntent",
2167 args=[intentIdList1[i],'org.onosproject.cli',True,False])
2168 pool.append(t)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07002169 t.start()
2170 i = i + 1
2171 main.threadID = main.threadID + 1
2172 for thread in pool:
2173 thread.join()
2174 intentIdList.append(thread.result)
2175 time2 = time.time()
2176 main.log.info("Time for removing host intents: %2f seconds" %(time2-time1))
Hari Krishnab35c6d02015-03-18 11:13:51 -07002177 time.sleep(10)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002178 else:
Hari Krishnaef1bd4e2015-03-12 16:55:30 -07002179 time.sleep(15)
Hari Krishnab35c6d02015-03-18 11:13:51 -07002180 if len( main.ONOScli1.intents()):
Hari Krishnaef1bd4e2015-03-12 16:55:30 -07002181 continue
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002182 break
kelvin-onlab36c02b12015-03-11 11:25:55 -07002183
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002184 else:
kelvin-onlab65a72d22015-03-26 13:46:32 -07002185 print "Removed %d intents" %(intentsCount)
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002186 step1Result = main.TRUE
2187 else:
2188 print "No Intent IDs found in Intents list: ", intentsList
2189 step1Result = main.FALSE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002190
kelvin-onlabdc8719b2015-03-02 14:01:52 -08002191 print main.ONOScli1.intents()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002192 caseResult10 = step1Result
2193 utilities.assert_equals( expect=main.TRUE, actual=caseResult10,
kelvin-onlab8a832582015-01-16 17:06:11 -08002194 onpass="Intent removal test successful",
2195 onfail="Intent removal test failed" )
Hari Krishna22c3d412015-02-17 16:48:12 -08002196
2197 def CASE11( self, main ):
2198 """
2199 Enable onos-app-ifwd, Verify Intent based Reactive forwarding through ping all and Disable it
2200 """
2201 import re
2202 import copy
2203 import time
2204
kelvin-onlab54400a92015-02-26 18:05:51 -08002205 Thread = imp.load_source('Thread','/home/admin/ONLabTest/TestON/tests/OnosCHO/Thread.py')
2206 threadID = 0
2207
Hari Krishna22c3d412015-02-17 16:48:12 -08002208 main.log.report( "Enable Intent based Reactive forwarding and Verify ping all" )
2209 main.log.report( "_____________________________________________________" )
2210 main.case( "Enable Intent based Reactive forwarding and Verify ping all" )
2211 main.step( "Enable intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08002212 installResult = main.FALSE
2213 feature = "onos-app-ifwd"
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002214
kelvin-onlab54400a92015-02-26 18:05:51 -08002215 pool = []
2216 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002217 for cli,feature in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -08002218 t = main.Thread(target=cli,threadID=threadID,
2219 name="featureInstall",args=[feature])
2220 pool.append(t)
2221 t.start()
2222 threadID = threadID + 1
2223
2224 results = []
2225 for thread in pool:
2226 thread.join()
2227 results.append(thread.result)
2228 time2 = time.time()
2229
2230 if( all(result == main.TRUE for result in results) == False):
2231 main.log.info("Did not install onos-app-ifwd feature properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -07002232 #main.cleanup()
2233 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -08002234 else:
2235 main.log.info("Successful feature:install onos-app-ifwd")
2236 installResult = main.TRUE
2237 main.log.info("Time for feature:install onos-app-ifwd: %2f seconds" %(time2-time1))
2238
Hari Krishna22c3d412015-02-17 16:48:12 -08002239 main.step( "Verify Pingall" )
2240 ping_result = main.FALSE
2241 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -08002242 ping_result = main.Mininet1.pingall(timeout=600)
Hari Krishna22c3d412015-02-17 16:48:12 -08002243 time2 = time.time()
2244 timeDiff = round( ( time2 - time1 ), 2 )
2245 main.log.report(
2246 "Time taken for Ping All: " +
2247 str( timeDiff ) +
2248 " seconds" )
kelvin-onlab54400a92015-02-26 18:05:51 -08002249
Hari Krishna22c3d412015-02-17 16:48:12 -08002250 if ping_result == main.TRUE:
2251 main.log.report( "Pingall Test in Reactive mode successful" )
2252 else:
2253 main.log.report( "Pingall Test in Reactive mode failed" )
2254
2255 main.step( "Disable Intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08002256 uninstallResult = main.FALSE
2257
kelvin-onlab54400a92015-02-26 18:05:51 -08002258 pool = []
2259 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002260 for cli,feature in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -08002261 t = main.Thread(target=cli,threadID=threadID,
2262 name="featureUninstall",args=[feature])
2263 pool.append(t)
2264 t.start()
2265 threadID = threadID + 1
2266
2267 results = []
2268 for thread in pool:
2269 thread.join()
2270 results.append(thread.result)
2271 time2 = time.time()
2272
2273 if( all(result == main.TRUE for result in results) == False):
2274 main.log.info("Did not uninstall onos-app-ifwd feature properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -07002275 uninstallResult = main.FALSE
2276 #main.cleanup()
2277 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -08002278 else:
2279 main.log.info("Successful feature:uninstall onos-app-ifwd")
2280 uninstallResult = main.TRUE
2281 main.log.info("Time for feature:uninstall onos-app-ifwd: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -08002282
2283 # Waiting for reative flows to be cleared.
2284 time.sleep( 10 )
2285
2286 case11Result = installResult and ping_result and uninstallResult
2287 utilities.assert_equals( expect=main.TRUE, actual=case11Result,
2288 onpass="Intent based Reactive forwarding Pingall test PASS",
2289 onfail="Intent based Reactive forwarding Pingall test FAIL" )
2290
Hari Krishnab35c6d02015-03-18 11:13:51 -07002291 def CASE99(self):
2292 import time
2293 # WORK AROUND FOR ONOS-581. STOP ONOS BEFORE ASSIGNING CONTROLLERS AT MININET & START ONCE DONE
2294 main.step( "Stop ONOS on all Nodes" )
2295 stopResult = main.TRUE
2296 for i in range( 1, int( main.numCtrls ) + 1 ):
2297 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
2298 main.log.info( "Stopping ONOS Node IP: " + ONOS_ip )
2299 sresult = main.ONOSbench.onosStop( ONOS_ip )
2300 utilities.assert_equals( expect=main.TRUE, actual=sresult,
2301 onpass="Test step PASS",
2302 onfail="Test step FAIL" )
2303 stopResult = ( stopResult and sresult )
2304
2305 main.step( "Start ONOS on all Nodes" )
2306 startResult = main.TRUE
2307 for i in range( 1, int( main.numCtrls ) + 1 ):
2308 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
2309 main.log.info( "Starting ONOS Node IP: " + ONOS_ip )
2310 sresult = main.ONOSbench.onosStart( ONOS_ip )
2311 utilities.assert_equals( expect=main.TRUE, actual=sresult,
2312 onpass="Test step PASS",
2313 onfail="Test step FAIL" )
2314 startResult = ( startResult and sresult )
2315
2316 main.step( "Start ONOS CLI on all nodes" )
2317 cliResult = main.TRUE
2318 time.sleep( 30 )
2319 main.log.step(" Start ONOS cli using thread ")
2320 pool = []
2321 time1 = time.time()
2322 for i in range( int( main.numCtrls ) ):
2323 t = main.Thread(target=main.CLIs[i].startOnosCli,
2324 threadID=main.threadID,
2325 name="startOnosCli",
2326 args=[main.nodes[i].ip_address])
2327 pool.append(t)
2328 t.start()
2329 main.threadID = main.threadID + 1
2330 for t in pool:
2331 t.join()
2332 cliResult = cliResult and t.result
2333 time2 = time.time()
2334
2335 if not cliResult:
2336 main.log.info("ONOS CLI did not start up properly")
2337 #main.cleanup()
2338 #main.exit()
2339 else:
2340 main.log.info("Successful CLI startup")
2341 main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
2342
2343 case99Result = ( startResult and cliResult )
2344 time.sleep(30)
2345 utilities.assert_equals(
2346 expect=main.TRUE,
2347 actual=case99Result,
2348 onpass="Starting new Chordal topology test PASS",
2349 onfail="Starting new Chordal topology test FAIL" )
2350
2351
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002352
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002353