blob: 1155fa4c1ca9e12e1162bf570963e2ca440e8a5c [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" )
279 #stopStatus = main.Mininet1.stopNet(fileName = "topoChordal" )
280 #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" )
353 #stopStatus = main.Mininet1.stopNet(fileName = "topoSpine" )
354 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-onlab54400a92015-02-26 18:05:51 -0800538 feature = "onos-app-fwd"
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800539
kelvin-onlab54400a92015-02-26 18:05:51 -0800540 pool = []
541 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800542 for cli in main.CLIs:
543 t = main.Thread( target=cli.featureInstall,
544 threadID=main.threadID,
545 name="featureInstall",
546 args=['onos-app-fwd'])
kelvin-onlab54400a92015-02-26 18:05:51 -0800547 pool.append(t)
548 t.start()
549 main.threadID = main.threadID + 1
550
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800551 installResult = main.TRUE
552 for t in pool:
553 t.join()
554 installResult = installResult and t.result
kelvin-onlab54400a92015-02-26 18:05:51 -0800555 time2 = time.time()
556
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800557 if not installResult:
kelvin-onlab54400a92015-02-26 18:05:51 -0800558 main.log.info("Did not install onos-app-fwd feature properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -0700559 #main.cleanup()
560 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -0800561 else:
562 main.log.info("Successful feature:install onos-app-fwd")
kelvin-onlab54400a92015-02-26 18:05:51 -0800563 main.log.info("Time for feature:install onos-app-fwd: %2f seconds" %(time2-time1))
564
kelvin-onlab8a832582015-01-16 17:06:11 -0800565 time.sleep( 5 )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800566
kelvin-onlab8a832582015-01-16 17:06:11 -0800567 main.step( "Verify Pingall" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800568 ping_result = main.FALSE
569 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -0800570 ping_result = main.Mininet1.pingall(timeout=main.pingTimeout)
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800571 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800572 timeDiff = round( ( time2 - time1 ), 2 )
573 main.log.report(
574 "Time taken for Ping All: " +
575 str( timeDiff ) +
576 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800577
578 if ping_result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800579 main.log.report( "Pingall Test in Reactive mode successful" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800580 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800581 main.log.report( "Pingall Test in Reactive mode failed" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800582
kelvin-onlab8a832582015-01-16 17:06:11 -0800583 main.step( "Disable Reactive forwarding" )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800584 uninstallResult = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800585 pool = []
586 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800587 for cli in main.CLIs:
588 t = main.Thread( target=cli.featureUninstall,
589 threadID=main.threadID,
590 name="featureUninstall",
591 args=['onos-app-fwd'])
kelvin-onlab54400a92015-02-26 18:05:51 -0800592 pool.append(t)
593 t.start()
594 main.threadID = main.threadID + 1
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800595 for t in pool:
596 t.join()
597 uninstallResult = uninstallResult and t.result
kelvin-onlab54400a92015-02-26 18:05:51 -0800598 time2 = time.time()
599
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800600 if not uninstallResult:
kelvin-onlab54400a92015-02-26 18:05:51 -0800601 main.log.info("Did not uninstall onos-app-fwd feature properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -0700602 #main.cleanup()
603 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -0800604 else:
605 main.log.info("Successful feature:uninstall onos-app-fwd")
kelvin-onlab54400a92015-02-26 18:05:51 -0800606 main.log.info("Time for feature:uninstall onos-app-fwd: %2f seconds" %(time2-time1))
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800607
kelvin-onlab8a832582015-01-16 17:06:11 -0800608 # Waiting for reative flows to be cleared.
Hari Krishnab35c6d02015-03-18 11:13:51 -0700609 time.sleep( 20 )
610 case4Result = installResult and uninstallResult and ping_result
611 utilities.assert_equals( expect=main.TRUE, actual=case4Result,
612 onpass="Reactive Mode Pingall test PASS",
613 onfail="Reactive Mode Pingall test FAIL" )
614
615 def CASE41( self, main ):
616 """
617 Verify Reactive forwarding (Chordal Topology)
618 """
619 import re
620 import copy
621 import time
622 main.log.report( "Verify Reactive forwarding (Chordal Topology)" )
623 main.log.report( "______________________________________________" )
624 main.case( "Enable Reactive forwarding and Verify ping all" )
625 main.step( "Enable Reactive forwarding" )
626 installResult = main.TRUE
627 feature = "onos-app-fwd"
628
629 pool = []
630 time1 = time.time()
631 for cli in main.CLIs:
632 t = main.Thread( target=cli.featureInstall,
633 threadID=main.threadID,
634 name="featureInstall",
635 args=['onos-app-fwd'])
636 pool.append(t)
637 t.start()
638 main.threadID = main.threadID + 1
639
640 installResult = main.TRUE
641 for t in pool:
642 t.join()
643 installResult = installResult and t.result
644 time2 = time.time()
645
646 if not installResult:
647 main.log.info("Did not install onos-app-fwd feature properly")
648 #main.cleanup()
649 #main.exit()
650 else:
651 main.log.info("Successful feature:install onos-app-fwd")
652 main.log.info("Time for feature:install onos-app-fwd: %2f seconds" %(time2-time1))
653
kelvin-onlab54400a92015-02-26 18:05:51 -0800654 time.sleep( 5 )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700655
656 main.step( "Verify Pingall" )
657 ping_result = main.FALSE
658 time1 = time.time()
659 ping_result = main.Mininet1.pingall(timeout=main.pingTimeout)
660 time2 = time.time()
661 timeDiff = round( ( time2 - time1 ), 2 )
662 main.log.report(
663 "Time taken for Ping All: " +
664 str( timeDiff ) +
665 " seconds" )
666
667 if ping_result == main.TRUE:
668 main.log.report( "Pingall Test in Reactive mode successful" )
669 else:
670 main.log.report( "Pingall Test in Reactive mode failed" )
671
672 main.step( "Disable Reactive forwarding" )
673 uninstallResult = main.TRUE
674 pool = []
675 time1 = time.time()
676 for cli in main.CLIs:
677 t = main.Thread( target=cli.featureUninstall,
678 threadID=main.threadID,
679 name="featureUninstall",
680 args=['onos-app-fwd'])
681 pool.append(t)
682 t.start()
683 main.threadID = main.threadID + 1
684 for t in pool:
685 t.join()
686 uninstallResult = uninstallResult and t.result
687 time2 = time.time()
688
689 if not uninstallResult:
690 main.log.info("Did not uninstall onos-app-fwd feature properly")
691 #main.cleanup()
692 #main.exit()
693 else:
694 main.log.info("Successful feature:uninstall onos-app-fwd")
695 main.log.info("Time for feature:uninstall onos-app-fwd: %2f seconds" %(time2-time1))
696
697 # Waiting for reative flows to be cleared.
698 time.sleep( 20 )
699 case4Result = installResult and uninstallResult and ping_result
700 utilities.assert_equals( expect=main.TRUE, actual=case4Result,
701 onpass="Reactive Mode Pingall test PASS",
702 onfail="Reactive Mode Pingall test FAIL" )
703
704 def CASE42( self, main ):
705 """
706 Verify Reactive forwarding (Spine Topology)
707 """
708 import re
709 import copy
710 import time
711 main.log.report( "Verify Reactive forwarding (Spine Topology)" )
712 main.log.report( "______________________________________________" )
713 main.case( "Enable Reactive forwarding and Verify ping all" )
714 main.step( "Enable Reactive forwarding" )
715 installResult = main.TRUE
716 feature = "onos-app-fwd"
717
718 pool = []
719 time1 = time.time()
720 for cli in main.CLIs:
721 t = main.Thread( target=cli.featureInstall,
722 threadID=main.threadID,
723 name="featureInstall",
724 args=['onos-app-fwd'])
725 pool.append(t)
726 t.start()
727 main.threadID = main.threadID + 1
728
729 installResult = main.TRUE
730 for t in pool:
731 t.join()
732 installResult = installResult and t.result
733 time2 = time.time()
734
735 if not installResult:
736 main.log.info("Did not install onos-app-fwd feature properly")
737 #main.cleanup()
738 #main.exit()
739 else:
740 main.log.info("Successful feature:install onos-app-fwd")
741 main.log.info("Time for feature:install onos-app-fwd: %2f seconds" %(time2-time1))
742
743 time.sleep( 5 )
744
745 main.step( "Verify Pingall" )
746 ping_result = main.FALSE
747 time1 = time.time()
748 ping_result = main.Mininet1.pingall(timeout=main.pingTimeout)
749 time2 = time.time()
750 timeDiff = round( ( time2 - time1 ), 2 )
751 main.log.report(
752 "Time taken for Ping All: " +
753 str( timeDiff ) +
754 " seconds" )
755
756 if ping_result == main.TRUE:
757 main.log.report( "Pingall Test in Reactive mode successful" )
758 else:
759 main.log.report( "Pingall Test in Reactive mode failed" )
760
761 main.step( "Disable Reactive forwarding" )
762 uninstallResult = main.TRUE
763 pool = []
764 time1 = time.time()
765 for cli in main.CLIs:
766 t = main.Thread( target=cli.featureUninstall,
767 threadID=main.threadID,
768 name="featureUninstall",
769 args=['onos-app-fwd'])
770 pool.append(t)
771 t.start()
772 main.threadID = main.threadID + 1
773 for t in pool:
774 t.join()
775 uninstallResult = uninstallResult and t.result
776 time2 = time.time()
777
778 if not uninstallResult:
779 main.log.info("Did not uninstall onos-app-fwd feature properly")
780 #main.cleanup()
781 #main.exit()
782 else:
783 main.log.info("Successful feature:uninstall onos-app-fwd")
784 main.log.info("Time for feature:uninstall onos-app-fwd: %2f seconds" %(time2-time1))
785
786 # Waiting for reative flows to be cleared.
787 time.sleep( 20 )
kelvin-onlab54400a92015-02-26 18:05:51 -0800788 case4Result = installResult and uninstallResult and ping_result
789 utilities.assert_equals( expect=main.TRUE, actual=case4Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800790 onpass="Reactive Mode Pingall test PASS",
791 onfail="Reactive Mode Pingall test FAIL" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800792 def CASE5( self, main ):
793 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800794 Compare current ONOS topology with reference data
kelvin-onlab8a832582015-01-16 17:06:11 -0800795 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800796 import re
kelvin-onlab54400a92015-02-26 18:05:51 -0800797
Hari Krishna22c3d412015-02-17 16:48:12 -0800798 devicesDPIDTemp = []
799 hostMACsTemp = []
800 deviceLinksTemp = []
801 deviceActiveLinksCountTemp = []
802 devicePortsEnabledCountTemp = []
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800803
kelvin-onlab8a832582015-01-16 17:06:11 -0800804 main.log.report(
805 "Compare ONOS topology with reference data in Stores" )
806 main.log.report( "__________________________________________________" )
807 main.case( "Compare ONOS topology with reference data" )
808
809 main.step( "Compare current Device ports enabled with reference" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800810 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800811 for i in xrange( 1,(main.numMNswitches + 1), int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800812 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800813 for cli in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -0800814 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800815 t = main.Thread(target = cli.getDevicePortsEnabledCount,
816 threadID = main.threadID,
817 name = "getDevicePortsEnabledCount",
818 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800819 t.start()
820 pool.append(t)
821 i = i + 1
822 main.threadID = main.threadID + 1
823 for thread in pool:
824 thread.join()
825 portResult = thread.result
826 portTemp = re.split( r'\t+', portResult )
827 portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
828 devicePortsEnabledCountTemp.append( portCount )
829 print "Device Enabled Port Counts Stored: \n", str( main.devicePortsEnabledCount )
830 time2 = time.time()
831 main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800832 main.log.info (
833 "Device Enabled ports EXPECTED: %s" %
834 str( main.devicePortsEnabledCount ) )
835 main.log.info (
836 "Device Enabled ports ACTUAL: %s" %
837 str( devicePortsEnabledCountTemp ) )
kelvin-onlab54400a92015-02-26 18:05:51 -0800838
Hari Krishna22c3d412015-02-17 16:48:12 -0800839 if ( cmp( main.devicePortsEnabledCount,
840 devicePortsEnabledCountTemp ) == 0 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800841 stepResult1 = main.TRUE
842 else:
843 stepResult1 = main.FALSE
844
kelvin-onlab8a832582015-01-16 17:06:11 -0800845 main.step( "Compare Device active links with reference" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800846 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800847 for i in xrange( 1, ( main.numMNswitches + 1) , int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800848 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800849 for cli in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -0800850 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800851 t = main.Thread(target = cli.getDeviceLinksActiveCount,
852 threadID = main.threadID,
853 name = "getDevicePortsEnabledCount",
854 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800855 t.start()
856 pool.append(t)
857 i = i + 1
858 main.threadID = main.threadID + 1
859 for thread in pool:
860 thread.join()
861 linkCountResult = thread.result
862 linkCountTemp = re.split( r'\t+', linkCountResult )
863 linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
864 deviceActiveLinksCountTemp.append( linkCount )
865 print "Device Active Links Count Stored: \n", str( main.deviceActiveLinksCount )
866 time2 = time.time()
867 main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800868 main.log.info (
869 "Device Active links EXPECTED: %s" %
870 str( main.deviceActiveLinksCount ) )
871 main.log.info (
872 "Device Active links ACTUAL: %s" % str( deviceActiveLinksCountTemp ) )
873 if ( cmp( main.deviceActiveLinksCount, deviceActiveLinksCountTemp ) == 0 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800874 stepResult2 = main.TRUE
875 else:
876 stepResult2 = main.FALSE
877
kelvin-onlab8a832582015-01-16 17:06:11 -0800878 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800879 place holder for comparing devices, hosts, paths and intents if required.
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800880 Links and ports data would be incorrect with out devices anyways.
kelvin-onlab8a832582015-01-16 17:06:11 -0800881 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800882 case5Result = ( stepResult1 and stepResult2 )
883 utilities.assert_equals( expect=main.TRUE, actual=case5Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800884 onpass="Compare Topology test PASS",
885 onfail="Compare Topology test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800886
kelvin-onlab65a72d22015-03-26 13:46:32 -0700887 def CASE60( self ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800888 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700889 Install 300 host intents and verify ping all (Att Topology)
kelvin-onlab8a832582015-01-16 17:06:11 -0800890 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700891 main.log.report( "Add 300 host intents and verify pingall (Att Topology)" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800892 main.log.report( "_______________________________________" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800893 import itertools
Hari Krishnaef1bd4e2015-03-12 16:55:30 -0700894 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800895 main.case( "Install 300 host intents" )
896 main.step( "Add host Intents" )
897 intentResult = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800898 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800899
kelvin-onlab54400a92015-02-26 18:05:51 -0800900 intentIdList = []
901 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800902 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800903 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800904 for cli in main.CLIs:
905 if i >= len( hostCombos ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800906 break
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800907 t = main.Thread( target=cli.addHostIntent,
908 threadID=main.threadID,
kelvin-onlab54400a92015-02-26 18:05:51 -0800909 name="addHostIntent",
910 args=[hostCombos[i][0],hostCombos[i][1]])
911 pool.append(t)
912 t.start()
913 i = i + 1
914 main.threadID = main.threadID + 1
915 for thread in pool:
916 thread.join()
917 intentIdList.append(thread.result)
918 time2 = time.time()
kelvin-onlabadfc8db2015-03-24 15:52:48 -0700919 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
920
kelvin-onlab54400a92015-02-26 18:05:51 -0800921 intentResult = main.TRUE
922 intentsJson = main.ONOScli2.intents()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800923 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
kelvin-onlab54400a92015-02-26 18:05:51 -0800924 intentsJson = intentsJson)
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800925 print getIntentStateResult
Hari Krishnab35c6d02015-03-18 11:13:51 -0700926 # Takes awhile for all the onos to get the intents
Hari Krishnaef1bd4e2015-03-12 16:55:30 -0700927 time.sleep(30)
kelvin-onlab8a832582015-01-16 17:06:11 -0800928 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800929 pingResult = main.FALSE
930 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -0800931 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800932 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800933 timeDiff = round( ( time2 - time1 ), 2 )
934 main.log.report(
935 "Time taken for Ping All: " +
936 str( timeDiff ) +
937 " seconds" )
938 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
939 onpass="PING ALL PASS",
940 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800941
kelvin-onlab65a72d22015-03-26 13:46:32 -0700942 case60Result = ( intentResult and pingResult )
kelvin-onlab54400a92015-02-26 18:05:51 -0800943
kelvin-onlab8a832582015-01-16 17:06:11 -0800944 utilities.assert_equals(
945 expect=main.TRUE,
kelvin-onlab65a72d22015-03-26 13:46:32 -0700946 actual=case60Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800947 onpass="Install 300 Host Intents and Ping All test PASS",
948 onfail="Install 300 Host Intents and Ping All test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800949
kelvin-onlab65a72d22015-03-26 13:46:32 -0700950 def CASE61( self ):
951 """
952 Install 600 host intents and verify ping all for Chordal Topology
953 """
954 main.log.report( "Add 600 host intents and verify pingall (Chordal Topo)" )
955 main.log.report( "_______________________________________" )
956 import itertools
957
958 main.case( "Install 600 host intents" )
959 main.step( "Add host Intents" )
960 intentResult = main.TRUE
961 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
962
963 intentIdList = []
964 time1 = time.time()
965
966 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
967 pool = []
968 for cli in main.CLIs:
969 if i >= len( hostCombos ):
970 break
971 t = main.Thread( target=cli.addHostIntent,
972 threadID=main.threadID,
973 name="addHostIntent",
974 args=[hostCombos[i][0],hostCombos[i][1]])
975 pool.append(t)
976 t.start()
977 i = i + 1
978 main.threadID = main.threadID + 1
979 for thread in pool:
980 thread.join()
981 intentIdList.append(thread.result)
982 time2 = time.time()
983 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
984 intentResult = main.TRUE
985 intentsJson = main.ONOScli2.intents()
986 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
987 intentsJson = intentsJson)
988 print getIntentStateResult
989
990 main.step( "Verify Ping across all hosts" )
991 pingResult = main.FALSE
992 time1 = time.time()
993 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
994 time2 = time.time()
995 timeDiff = round( ( time2 - time1 ), 2 )
996 main.log.report(
997 "Time taken for Ping All: " +
998 str( timeDiff ) +
999 " seconds" )
1000 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1001 onpass="PING ALL PASS",
1002 onfail="PING ALL FAIL" )
1003
1004 case14Result = ( intentResult and pingResult )
1005
1006 utilities.assert_equals(
1007 expect=main.TRUE,
1008 actual=case14Result,
1009 onpass="Install 300 Host Intents and Ping All test PASS",
1010 onfail="Install 300 Host Intents and Ping All test FAIL" )
1011
1012 def CASE62( self ):
1013 """
1014 Install 2278 host intents and verify ping all for Spine Topology
1015 """
1016 main.log.report( "Add 2278 host intents and verify pingall (Spine Topo)" )
1017 main.log.report( "_______________________________________" )
1018 import itertools
1019
1020 main.case( "Install 2278 host intents" )
1021 main.step( "Add host Intents" )
1022 intentResult = main.TRUE
1023 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
1024 main.pingTimeout = 300
1025 intentIdList = []
1026 time1 = time.time()
1027 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
1028 pool = []
1029 for cli in main.CLIs:
1030 if i >= len( hostCombos ):
1031 break
1032 t = main.Thread( target=cli.addHostIntent,
1033 threadID=main.threadID,
1034 name="addHostIntent",
1035 args=[hostCombos[i][0],hostCombos[i][1]])
1036 pool.append(t)
1037 t.start()
1038 i = i + 1
1039 main.threadID = main.threadID + 1
1040 for thread in pool:
1041 thread.join()
1042 intentIdList.append(thread.result)
1043 time2 = time.time()
1044 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
1045 intentResult = main.TRUE
1046 intentsJson = main.ONOScli2.intents()
1047 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1048 intentsJson = intentsJson)
1049 print getIntentStateResult
1050
1051 main.step( "Verify Ping across all hosts" )
1052 pingResult = main.FALSE
1053 time1 = time.time()
1054 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
1055 time2 = time.time()
1056 timeDiff = round( ( time2 - time1 ), 2 )
1057 main.log.report(
1058 "Time taken for Ping All: " +
1059 str( timeDiff ) +
1060 " seconds" )
1061 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1062 onpass="PING ALL PASS",
1063 onfail="PING ALL FAIL" )
1064
1065 case15Result = ( intentResult and pingResult )
1066
1067 utilities.assert_equals(
1068 expect=main.TRUE,
1069 actual=case15Result,
1070 onpass="Install 2278 Host Intents and Ping All test PASS",
1071 onfail="Install 2278 Host Intents and Ping All test FAIL" )
1072
kelvin-onlab8a832582015-01-16 17:06:11 -08001073 def CASE70( self, main ):
1074 """
Hari Krishnab35c6d02015-03-18 11:13:51 -07001075 Randomly bring some core links down and verify ping all ( Host Intents-Att Topo)
kelvin-onlab8a832582015-01-16 17:06:11 -08001076 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001077 import random
Hari Krishna22c3d412015-02-17 16:48:12 -08001078 main.randomLink1 = []
1079 main.randomLink2 = []
1080 main.randomLink3 = []
kelvin-onlab65a72d22015-03-26 13:46:32 -07001081 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1082 link1End2 = main.params[ 'ATTCORELINKS' ][ 'linkS3b' ].split( ',' )
1083 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1084 link2End2 = main.params[ 'ATTCORELINKS' ][ 'linkS14b' ].split( ',' )
1085 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
1086 link3End2 = main.params[ 'ATTCORELINKS' ][ 'linkS18b' ].split( ',' )
1087 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001088 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001089
Hari Krishnab35c6d02015-03-18 11:13:51 -07001090 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Att Topo)" )
1091 main.log.report( "___________________________________________________________________________" )
Hari Krishnad97213e2015-01-24 19:30:14 -08001092 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
1093 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001094 if ( int( switchLinksToToggle ) ==
1095 0 or int( switchLinksToToggle ) > 5 ):
Hari Krishna46997e02015-01-27 11:23:07 -08001096 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 -07001097 #main.cleanup()
1098 #main.exit()
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001099 else:
Hari Krishnad97213e2015-01-24 19:30:14 -08001100 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 -08001101
kelvin-onlab8a832582015-01-16 17:06:11 -08001102 main.step( "Cut links on Core devices using user provided range" )
Hari Krishna22c3d412015-02-17 16:48:12 -08001103 main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
1104 main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
1105 main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001106 for i in range( int( switchLinksToToggle ) ):
1107 main.Mininet1.link(
1108 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001109 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001110 OPTION="down" )
1111 main.Mininet1.link(
1112 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001113 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001114 OPTION="down" )
1115 main.Mininet1.link(
1116 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001117 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001118 OPTION="down" )
1119 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001120
1121 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001122 linkDown = main.ONOSbench.checkStatus(
Hari Krishna22c3d412015-02-17 16:48:12 -08001123 topology_output, main.numMNswitches, str(
1124 int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001125 utilities.assert_equals(
1126 expect=main.TRUE,
1127 actual=linkDown,
1128 onpass="Link Down discovered properly",
1129 onfail="Link down was not discovered in " +
1130 str( link_sleep ) +
1131 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001132
kelvin-onlab8a832582015-01-16 17:06:11 -08001133 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001134 pingResultLinkDown = main.FALSE
1135 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -08001136 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout)
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001137 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001138 timeDiff = round( ( time2 - time1 ), 2 )
1139 main.log.report(
1140 "Time taken for Ping All: " +
1141 str( timeDiff ) +
1142 " seconds" )
1143 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1144 onpass="PING ALL PASS",
1145 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001146
Hari Krishna22c3d412015-02-17 16:48:12 -08001147 caseResult70 = linkDown and pingResultLinkDown
1148 utilities.assert_equals( expect=main.TRUE, actual=caseResult70,
kelvin-onlab8a832582015-01-16 17:06:11 -08001149 onpass="Random Link cut Test PASS",
1150 onfail="Random Link cut Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001151
kelvin-onlab8a832582015-01-16 17:06:11 -08001152 def CASE80( self, main ):
1153 """
Hari Krishnab35c6d02015-03-18 11:13:51 -07001154 Bring the core links up that are down and verify ping all ( Host Intents-Att Topo )
kelvin-onlab8a832582015-01-16 17:06:11 -08001155 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001156 import random
kelvin-onlab65a72d22015-03-26 13:46:32 -07001157 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1158 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1159 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001160 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001161 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001162
kelvin-onlab8a832582015-01-16 17:06:11 -08001163 main.log.report(
Hari Krishnab35c6d02015-03-18 11:13:51 -07001164 "Bring the core links up that are down and verify ping all (Host Intents-Att Topo" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001165 main.log.report(
1166 "__________________________________________________________________" )
1167 main.case(
1168 "Host intents - Bring the core links up that are down and verify ping all" )
1169 main.step( "Bring randomly cut links on Core devices up" )
1170 for i in range( int( switchLinksToToggle ) ):
1171 main.Mininet1.link(
1172 END1=link1End1,
kelvin-onlab54400a92015-02-26 18:05:51 -08001173 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001174 OPTION="up" )
1175 main.Mininet1.link(
1176 END1=link2End1,
kelvin-onlab54400a92015-02-26 18:05:51 -08001177 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001178 OPTION="up" )
1179 main.Mininet1.link(
1180 END1=link3End1,
kelvin-onlab54400a92015-02-26 18:05:51 -08001181 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001182 OPTION="up" )
1183 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001184
1185 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001186 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -08001187 topology_output,
Hari Krishna22c3d412015-02-17 16:48:12 -08001188 main.numMNswitches,
1189 str( main.numMNlinks ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001190 utilities.assert_equals(
1191 expect=main.TRUE,
1192 actual=linkUp,
1193 onpass="Link up discovered properly",
1194 onfail="Link up was not discovered in " +
1195 str( link_sleep ) +
1196 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001197
kelvin-onlab8a832582015-01-16 17:06:11 -08001198 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001199 pingResultLinkUp = main.FALSE
1200 time1 = time.time()
1201 pingResultLinkUp = main.Mininet1.pingall()
1202 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001203 timeDiff = round( ( time2 - time1 ), 2 )
1204 main.log.report(
1205 "Time taken for Ping All: " +
1206 str( timeDiff ) +
1207 " seconds" )
1208 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1209 onpass="PING ALL PASS",
1210 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001211
Hari Krishna22c3d412015-02-17 16:48:12 -08001212 caseResult80 = linkUp and pingResultLinkUp
1213 utilities.assert_equals( expect=main.TRUE, actual=caseResult80,
kelvin-onlab8a832582015-01-16 17:06:11 -08001214 onpass="Link Up Test PASS",
1215 onfail="Link Up Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001216
kelvin-onlab8a832582015-01-16 17:06:11 -08001217 def CASE71( self, main ):
1218 """
kelvin-onlab65a72d22015-03-26 13:46:32 -07001219 Randomly bring some core links down and verify ping all ( Host Intents-Att Topo)
kelvin-onlab8a832582015-01-16 17:06:11 -08001220 """
kelvin8ec71442015-01-15 16:57:00 -08001221 import random
Hari Krishna22c3d412015-02-17 16:48:12 -08001222 main.randomLink1 = []
1223 main.randomLink2 = []
1224 main.randomLink3 = []
kelvin-onlab65a72d22015-03-26 13:46:32 -07001225 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1226 link1End2 = main.params[ 'ATTCORELINKS' ][ 'linkS3b' ].split( ',' )
1227 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1228 link2End2 = main.params[ 'ATTCORELINKS' ][ 'linkS14b' ].split( ',' )
1229 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
1230 link3End2 = main.params[ 'ATTCORELINKS' ][ 'linkS18b' ].split( ',' )
1231 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001232 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin8ec71442015-01-15 16:57:00 -08001233
kelvin-onlab65a72d22015-03-26 13:46:32 -07001234 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Att Topo)" )
1235 main.log.report( "___________________________________________________________________________" )
1236 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
Hari Krishnad97213e2015-01-24 19:30:14 -08001237 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001238 if ( int( switchLinksToToggle ) ==
1239 0 or int( switchLinksToToggle ) > 5 ):
kelvin-onlab65a72d22015-03-26 13:46:32 -07001240 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 -07001241 #main.cleanup()
1242 #main.exit()
kelvin8ec71442015-01-15 16:57:00 -08001243 else:
kelvin-onlab65a72d22015-03-26 13:46:32 -07001244 main.log.info( "User provided Core switch links range to toggle is correct, proceeding to run the test" )
kelvin8ec71442015-01-15 16:57:00 -08001245
kelvin-onlab8a832582015-01-16 17:06:11 -08001246 main.step( "Cut links on Core devices using user provided range" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001247 main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
1248 main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
1249 main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001250 for i in range( int( switchLinksToToggle ) ):
1251 main.Mininet1.link(
1252 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001253 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001254 OPTION="down" )
1255 main.Mininet1.link(
1256 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001257 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001258 OPTION="down" )
1259 main.Mininet1.link(
1260 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001261 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001262 OPTION="down" )
1263 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -08001264
1265 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001266 linkDown = main.ONOSbench.checkStatus(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001267 topology_output, main.numMNswitches, str(
1268 int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001269 utilities.assert_equals(
1270 expect=main.TRUE,
1271 actual=linkDown,
1272 onpass="Link Down discovered properly",
1273 onfail="Link down was not discovered in " +
1274 str( link_sleep ) +
1275 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -08001276
kelvin-onlab8a832582015-01-16 17:06:11 -08001277 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -08001278 pingResultLinkDown = main.FALSE
1279 time1 = time.time()
kelvin-onlab65a72d22015-03-26 13:46:32 -07001280 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout)
kelvin8ec71442015-01-15 16:57:00 -08001281 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001282 timeDiff = round( ( time2 - time1 ), 2 )
1283 main.log.report(
1284 "Time taken for Ping All: " +
1285 str( timeDiff ) +
1286 " seconds" )
1287 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1288 onpass="PING ALL PASS",
1289 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001290
kelvin-onlab65a72d22015-03-26 13:46:32 -07001291 caseResult71 = linkDown and pingResultLinkDown
1292 utilities.assert_equals( expect=main.TRUE, actual=caseResult71,
kelvin-onlab8a832582015-01-16 17:06:11 -08001293 onpass="Random Link cut Test PASS",
1294 onfail="Random Link cut Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001295
kelvin-onlab8a832582015-01-16 17:06:11 -08001296 def CASE81( self, main ):
1297 """
kelvin-onlab65a72d22015-03-26 13:46:32 -07001298 Bring the core links up that are down and verify ping all ( Host Intents-Att Topo )
kelvin-onlab8a832582015-01-16 17:06:11 -08001299 """
kelvin8ec71442015-01-15 16:57:00 -08001300 import random
kelvin-onlab65a72d22015-03-26 13:46:32 -07001301 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1302 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1303 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001304 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001305 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
kelvin8ec71442015-01-15 16:57:00 -08001306
kelvin-onlab8a832582015-01-16 17:06:11 -08001307 main.log.report(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001308 "Bring the core links up that are down and verify ping all (Host Intents-Att Topo" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001309 main.log.report(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001310 "__________________________________________________________________" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001311 main.case(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001312 "Host intents - Bring the core links up that are down and verify ping all" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001313 main.step( "Bring randomly cut links on Core devices up" )
1314 for i in range( int( switchLinksToToggle ) ):
1315 main.Mininet1.link(
1316 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001317 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001318 OPTION="up" )
1319 main.Mininet1.link(
1320 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001321 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001322 OPTION="up" )
1323 main.Mininet1.link(
1324 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001325 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001326 OPTION="up" )
1327 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -08001328
1329 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001330 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -08001331 topology_output,
Hari Krishna22c3d412015-02-17 16:48:12 -08001332 main.numMNswitches,
1333 str( main.numMNlinks ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001334 utilities.assert_equals(
1335 expect=main.TRUE,
1336 actual=linkUp,
1337 onpass="Link up discovered properly",
1338 onfail="Link up was not discovered in " +
1339 str( link_sleep ) +
1340 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -08001341
kelvin-onlab8a832582015-01-16 17:06:11 -08001342 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -08001343 pingResultLinkUp = main.FALSE
1344 time1 = time.time()
kelvin-onlab77d6c302015-03-31 11:33:32 -07001345 pingResultLinkUp = main.Mininet1.pingall(timeout = main.pingTimeout)
kelvin8ec71442015-01-15 16:57:00 -08001346 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001347 timeDiff = round( ( time2 - time1 ), 2 )
1348 main.log.report(
1349 "Time taken for Ping All: " +
1350 str( timeDiff ) +
1351 " seconds" )
1352 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1353 onpass="PING ALL PASS",
1354 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001355
Hari Krishna22c3d412015-02-17 16:48:12 -08001356 caseResult81 = linkUp and pingResultLinkUp
1357 utilities.assert_equals( expect=main.TRUE, actual=caseResult81,
kelvin-onlab8a832582015-01-16 17:06:11 -08001358 onpass="Link Up Test PASS",
1359 onfail="Link Up Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001360
Hari Krishnab35c6d02015-03-18 11:13:51 -07001361 def CASE72( self, main ):
1362 """
1363 Randomly bring some links down and verify ping all ( Host Intents-Chordal Topo)
1364 """
1365 import random
1366 import itertools
1367 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1368
1369 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Chordal Topo)" )
1370 main.log.report( "___________________________________________________________________________" )
1371 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
1372 switches = []
1373 switchesComb = []
1374 for i in range( main.numMNswitches ):
1375 switches.append('s%d'%(i+1))
1376 switchesLinksComb = list(itertools.combinations(switches,2))
1377 main.randomLinks = random.sample(switchesLinksComb, 5 )
1378 print main.randomLinks
1379 main.step( "Cut links on random devices" )
1380
1381 for switch in main.randomLinks:
1382 main.Mininet1.link(
1383 END1=switch[0],
1384 END2=switch[1],
1385 OPTION="down")
1386 time.sleep( link_sleep )
1387
1388 topology_output = main.ONOScli2.topology()
1389 linkDown = main.ONOSbench.checkStatus(
1390 topology_output, main.numMNswitches, str(
1391 int( main.numMNlinks ) - 5 * 2 ) )
1392 utilities.assert_equals(
1393 expect=main.TRUE,
1394 actual=linkDown,
1395 onpass="Link Down discovered properly",
1396 onfail="Link down was not discovered in " +
1397 str( link_sleep ) +
1398 " seconds" )
1399
1400 main.step( "Verify Ping across all hosts" )
1401 pingResultLinkDown = main.FALSE
1402 time1 = time.time()
1403 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout)
1404 time2 = time.time()
1405 timeDiff = round( ( time2 - time1 ), 2 )
1406 main.log.report(
1407 "Time taken for Ping All: " +
1408 str( timeDiff ) +
1409 " seconds" )
1410 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1411 onpass="PING ALL PASS",
1412 onfail="PING ALL FAIL" )
1413
kelvin-onlab65a72d22015-03-26 13:46:32 -07001414 caseResult71 = pingResultLinkDown
1415 utilities.assert_equals( expect=main.TRUE, actual=caseResult71,
Hari Krishnab35c6d02015-03-18 11:13:51 -07001416 onpass="Random Link cut Test PASS",
1417 onfail="Random Link cut Test FAIL" )
1418
1419 def CASE82( self, main ):
1420 """
1421 Bring the core links up that are down and verify ping all ( Host Intents Chordal Topo )
1422 """
1423 import random
1424 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1425
1426 main.log.report(
1427 "Bring the core links up that are down and verify ping all (Host Intents-Chordal Topo" )
1428 main.log.report(
1429 "__________________________________________________________________" )
1430 main.case(
1431 "Host intents - Bring the core links up that are down and verify ping all" )
1432 main.step( "Bring randomly cut links on devices up" )
1433
1434 for switch in main.randomLinks:
1435 main.Mininet1.link(
1436 END1=switch[0],
1437 END2=switch[1],
1438 OPTION="up")
1439
1440 time.sleep( link_sleep )
1441
1442 topology_output = main.ONOScli2.topology()
1443 linkUp = main.ONOSbench.checkStatus(
1444 topology_output,
1445 main.numMNswitches,
1446 str( main.numMNlinks ) )
1447 utilities.assert_equals(
1448 expect=main.TRUE,
1449 actual=linkUp,
1450 onpass="Link up discovered properly",
1451 onfail="Link up was not discovered in " +
1452 str( link_sleep ) +
1453 " seconds" )
1454
1455 main.step( "Verify Ping across all hosts" )
1456 pingResultLinkUp = main.FALSE
1457 time1 = time.time()
kelvin-onlab77d6c302015-03-31 11:33:32 -07001458 pingResultLinkUp = main.Mininet1.pingall(timeout = main.pingTimeout)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001459 time2 = time.time()
1460 timeDiff = round( ( time2 - time1 ), 2 )
1461 main.log.report(
1462 "Time taken for Ping All: " +
1463 str( timeDiff ) +
1464 " seconds" )
1465 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1466 onpass="PING ALL PASS",
1467 onfail="PING ALL FAIL" )
1468
1469 caseResult82 = linkUp and pingResultLinkUp
1470 utilities.assert_equals( expect=main.TRUE, actual=caseResult82,
1471 onpass="Link Up Test PASS",
1472 onfail="Link Up Test FAIL" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001473
Hari Krishnab35c6d02015-03-18 11:13:51 -07001474 def CASE73( self, main ):
1475 """
kelvin-onlab65a72d22015-03-26 13:46:32 -07001476 Randomly bring some links down and verify ping all ( Host Intents-Chordal Topo)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001477 """
1478 import random
kelvin-onlab65a72d22015-03-26 13:46:32 -07001479 import itertools
Hari Krishnab35c6d02015-03-18 11:13:51 -07001480 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001481
1482 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Chordal Topo)" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001483 main.log.report( "___________________________________________________________________________" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001484 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
1485 switches = []
1486 switchesComb = []
1487 for i in range( main.numMNswitches ):
1488 switches.append('s%d'%(i+1))
1489 switchesLinksComb = list(itertools.combinations(switches,2))
1490 main.randomLinks = random.sample(switchesLinksComb, 5 )
1491 print main.randomLinks
1492 main.step( "Cut links on random devices" )
1493
1494 for switch in main.randomLinks:
Hari Krishnab35c6d02015-03-18 11:13:51 -07001495 main.Mininet1.link(
1496 END1=switch[0],
1497 END2=switch[1],
kelvin-onlab65a72d22015-03-26 13:46:32 -07001498 OPTION="down")
Hari Krishnab35c6d02015-03-18 11:13:51 -07001499 time.sleep( link_sleep )
1500
1501 topology_output = main.ONOScli2.topology()
1502 linkDown = main.ONOSbench.checkStatus(
1503 topology_output, main.numMNswitches, str(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001504 int( main.numMNlinks ) - 5 * 2 ) )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001505 utilities.assert_equals(
1506 expect=main.TRUE,
1507 actual=linkDown,
1508 onpass="Link Down discovered properly",
1509 onfail="Link down was not discovered in " +
1510 str( link_sleep ) +
1511 " seconds" )
1512
1513 main.step( "Verify Ping across all hosts" )
1514 pingResultLinkDown = main.FALSE
1515 time1 = time.time()
1516 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout)
1517 time2 = time.time()
1518 timeDiff = round( ( time2 - time1 ), 2 )
1519 main.log.report(
1520 "Time taken for Ping All: " +
1521 str( timeDiff ) +
1522 " seconds" )
1523 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1524 onpass="PING ALL PASS",
1525 onfail="PING ALL FAIL" )
1526
kelvin-onlab65a72d22015-03-26 13:46:32 -07001527 caseResult73 = pingResultLinkDown
Hari Krishnab35c6d02015-03-18 11:13:51 -07001528 utilities.assert_equals( expect=main.TRUE, actual=caseResult73,
1529 onpass="Random Link cut Test PASS",
1530 onfail="Random Link cut Test FAIL" )
1531
1532 def CASE83( self, main ):
1533 """
kelvin-onlab65a72d22015-03-26 13:46:32 -07001534 Bring the core links up that are down and verify ping all ( Host Intents Chordal Topo )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001535 """
1536 import random
Hari Krishnab35c6d02015-03-18 11:13:51 -07001537 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001538
Hari Krishnab35c6d02015-03-18 11:13:51 -07001539 main.log.report(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001540 "Bring the core links up that are down and verify ping all (Host Intents-Chordal Topo" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001541 main.log.report(
1542 "__________________________________________________________________" )
1543 main.case(
1544 "Host intents - Bring the core links up that are down and verify ping all" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001545 main.step( "Bring randomly cut links on devices up" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001546
kelvin-onlab65a72d22015-03-26 13:46:32 -07001547 for switch in main.randomLinks:
Hari Krishnab35c6d02015-03-18 11:13:51 -07001548 main.Mininet1.link(
1549 END1=switch[0],
1550 END2=switch[1],
1551 OPTION="up")
kelvin-onlab65a72d22015-03-26 13:46:32 -07001552
Hari Krishnab35c6d02015-03-18 11:13:51 -07001553 time.sleep( link_sleep )
1554
1555 topology_output = main.ONOScli2.topology()
1556 linkUp = main.ONOSbench.checkStatus(
1557 topology_output,
1558 main.numMNswitches,
1559 str( main.numMNlinks ) )
1560 utilities.assert_equals(
1561 expect=main.TRUE,
1562 actual=linkUp,
1563 onpass="Link up discovered properly",
1564 onfail="Link up was not discovered in " +
1565 str( link_sleep ) +
1566 " seconds" )
1567
1568 main.step( "Verify Ping across all hosts" )
1569 pingResultLinkUp = main.FALSE
1570 time1 = time.time()
kelvin-onlab77d6c302015-03-31 11:33:32 -07001571 pingResultLinkUp = main.Mininet1.pingall(timeout = main.pingTimeout)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001572 time2 = time.time()
1573 timeDiff = round( ( time2 - time1 ), 2 )
1574 main.log.report(
1575 "Time taken for Ping All: " +
1576 str( timeDiff ) +
1577 " seconds" )
1578 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1579 onpass="PING ALL PASS",
1580 onfail="PING ALL FAIL" )
1581
1582 caseResult83 = linkUp and pingResultLinkUp
1583 utilities.assert_equals( expect=main.TRUE, actual=caseResult83,
1584 onpass="Link Up Test PASS",
1585 onfail="Link Up Test FAIL" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001586
1587 def CASE74( self, main ):
1588 """
1589 Randomly bring some core links down and verify ping all ( Host Intents-Spine Topo)
1590 """
1591 import random
1592 main.randomLink1 = []
1593 main.randomLink2 = []
1594 main.randomLink3 = []
1595 main.randomLink4 = []
1596 link1End1 = main.params[ 'SPINECORELINKS' ][ 'linkS9' ]
1597 link1End2top = main.params[ 'SPINECORELINKS' ][ 'linkS9top' ].split( ',' )
1598 link1End2bot = main.params[ 'SPINECORELINKS' ][ 'linkS9bot' ].split( ',' )
1599 link2End1 = main.params[ 'SPINECORELINKS' ][ 'linkS10' ]
1600 link2End2top = main.params[ 'SPINECORELINKS' ][ 'linkS10top' ].split( ',' )
1601 link2End2bot = main.params[ 'SPINECORELINKS' ][ 'linkS10bot' ].split( ',' )
1602 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1603 main.pingTimeout = 400
1604
1605 main.log.report( "Bring some core links down and verify ping all (Host Intents-Spine Topo)" )
1606 main.log.report( "___________________________________________________________________________" )
1607
1608 linkIndex = range(4)
1609 linkIndexS9 = random.sample(linkIndex,1)[0]
1610 linkIndex.remove(linkIndexS9)
1611 linkIndexS10 = random.sample(linkIndex,1)[0]
1612 main.randomLink1 = link1End2top[linkIndexS9]
1613 main.randomLink2 = link2End2top[linkIndexS10]
1614 main.randomLink3 = random.sample(link1End2bot,1)[0]
1615 main.randomLink4 = random.sample(link2End2bot,1)[0]
kelvin-onlab77d6c302015-03-31 11:33:32 -07001616 # main.Mininet1.link( END1=link1End1, END2=main.randomLink1, OPTION="down" )
1617 # main.Mininet1.link( END1=link2End1, END2=main.randomLink2, OPTION="down" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001618 main.Mininet1.link( END1=link1End1, END2=main.randomLink3, OPTION="down" )
1619 main.Mininet1.link( END1=link2End1, END2=main.randomLink4, OPTION="down" )
kelvin-onlabd878fc22015-03-27 13:33:41 -07001620
kelvin-onlab65a72d22015-03-26 13:46:32 -07001621 time.sleep( link_sleep )
1622
1623 topology_output = main.ONOScli2.topology()
1624 linkDown = main.ONOSbench.checkStatus(
1625 topology_output, main.numMNswitches, str(
1626 int( main.numMNlinks ) - 8 ))
1627 utilities.assert_equals(
1628 expect=main.TRUE,
1629 actual=linkDown,
1630 onpass="Link Down discovered properly",
1631 onfail="Link down was not discovered in " +
1632 str( link_sleep ) +
1633 " seconds" )
1634
1635 main.step( "Verify Ping across all hosts" )
1636 pingResultLinkDown = main.FALSE
1637 time1 = time.time()
1638 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout)
1639 time2 = time.time()
1640 timeDiff = round( ( time2 - time1 ), 2 )
1641 main.log.report(
1642 "Time taken for Ping All: " +
1643 str( timeDiff ) +
1644 " seconds" )
1645 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1646 onpass="PING ALL PASS",
1647 onfail="PING ALL FAIL" )
1648
1649 caseResult74 = linkDown and pingResultLinkDown
1650 utilities.assert_equals( expect=main.TRUE, actual=caseResult74,
1651 onpass="Random Link cut Test PASS",
1652 onfail="Random Link cut Test FAIL" )
1653
1654 def CASE84( self, main ):
1655 """
1656 Bring the core links up that are down and verify ping all ( Host Intents-Spine Topo )
1657 """
1658 import random
1659 link1End1 = main.params[ 'SPINECORELINKS' ][ 'linkS9' ]
1660 link2End1 = main.params[ 'SPINECORELINKS' ][ 'linkS10' ]
1661 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1662 main.log.report(
1663 "Bring the core links up that are down and verify ping all (Host Intents-Spine Topo" )
1664 main.log.report(
1665 "__________________________________________________________________" )
1666 main.case(
1667 "Host intents - Bring the core links up that are down and verify ping all" )
1668
kelvin-onlab77d6c302015-03-31 11:33:32 -07001669 #main.Mininet1.link( END1=link1End1, END2=main.randomLink1, OPTION="up" )
1670 #main.Mininet1.link( END1=link2End1, END2=main.randomLink2, OPTION="up" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001671 main.Mininet1.link( END1=link1End1, END2=main.randomLink3, OPTION="up" )
1672 main.Mininet1.link( END1=link2End1, END2=main.randomLink4, OPTION="up" )
1673
1674 time.sleep( link_sleep )
1675 topology_output = main.ONOScli2.topology()
1676 linkUp = main.ONOSbench.checkStatus(
1677 topology_output,
1678 main.numMNswitches,
1679 str( main.numMNlinks ) )
1680 utilities.assert_equals(
1681 expect=main.TRUE,
1682 actual=linkUp,
1683 onpass="Link up discovered properly",
1684 onfail="Link up was not discovered in " +
1685 str( link_sleep ) +
1686 " seconds" )
1687
1688 main.step( "Verify Ping across all hosts" )
1689 pingResultLinkUp = main.FALSE
1690 time1 = time.time()
kelvin-onlab77d6c302015-03-31 11:33:32 -07001691 pingResultLinkUp = main.Mininet1.pingall(timeout = main.pingTimeout)
kelvin-onlab65a72d22015-03-26 13:46:32 -07001692 time2 = time.time()
1693 timeDiff = round( ( time2 - time1 ), 2 )
1694 main.log.report(
1695 "Time taken for Ping All: " +
1696 str( timeDiff ) +
1697 " seconds" )
1698 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1699 onpass="PING ALL PASS",
1700 onfail="PING ALL FAIL" )
1701
1702 caseResult84 = linkUp and pingResultLinkUp
1703 utilities.assert_equals( expect=main.TRUE, actual=caseResult84,
1704 onpass="Link Up Test PASS",
1705 onfail="Link Up Test FAIL" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001706
1707 def CASE90( self ):
kelvin-onlab8a832582015-01-16 17:06:11 -08001708 """
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001709 Install 600 point intents and verify ping all (Att Topology)
kelvin-onlab8a832582015-01-16 17:06:11 -08001710 """
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001711 main.log.report( "Add 600 point intents and verify pingall (Att Topology)" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001712 main.log.report( "_______________________________________" )
1713 import itertools
1714 import time
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001715 main.case( "Install 600 point intents" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001716 main.step( "Add point Intents" )
1717 intentResult = main.TRUE
1718 deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) )
1719
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001720 intentIdList = []
Hari Krishnab35c6d02015-03-18 11:13:51 -07001721 time1 = time.time()
Hari Krishnab35c6d02015-03-18 11:13:51 -07001722 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1723 pool = []
1724 for cli in main.CLIs:
1725 if i >= len( deviceCombos ):
1726 break
1727 t = main.Thread( target=cli.addPointIntent,
1728 threadID=main.threadID,
1729 name="addPointIntent",
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001730 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
Hari Krishnab35c6d02015-03-18 11:13:51 -07001731 pool.append(t)
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001732 #time.sleep(1)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001733 t.start()
1734 i = i + 1
1735 main.threadID = main.threadID + 1
1736 for thread in pool:
1737 thread.join()
1738 intentIdList.append(thread.result)
1739 time2 = time.time()
1740 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1741 intentResult = main.TRUE
1742 intentsJson = main.ONOScli2.intents()
1743 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1744 intentsJson = intentsJson)
1745 print getIntentStateResult
1746 # Takes awhile for all the onos to get the intents
1747 time.sleep(30)
kelvin-onlab8a832582015-01-16 17:06:11 -08001748 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001749 pingResult = main.FALSE
1750 time1 = time.time()
Hari Krishnab35c6d02015-03-18 11:13:51 -07001751 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001752 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001753 timeDiff = round( ( time2 - time1 ), 2 )
1754 main.log.report(
1755 "Time taken for Ping All: " +
1756 str( timeDiff ) +
1757 " seconds" )
1758 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1759 onpass="PING ALL PASS",
1760 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001761
kelvin-onlab65a72d22015-03-26 13:46:32 -07001762 case90Result = ( intentResult and pingResult )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001763
kelvin-onlab8a832582015-01-16 17:06:11 -08001764 utilities.assert_equals(
1765 expect=main.TRUE,
kelvin-onlab65a72d22015-03-26 13:46:32 -07001766 actual=case90Result,
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001767 onpass="Install 600 point Intents and Ping All test PASS",
1768 onfail="Install 600 point Intents and Ping All test FAIL" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001769
1770 def CASE91( self ):
1771 """
1772 Install ###$$$ point intents and verify ping all (Chordal Topology)
1773 """
1774 main.log.report( "Add ###$$$ point intents and verify pingall (Chordal Topology)" )
1775 main.log.report( "_______________________________________" )
1776 import itertools
1777 import time
1778 main.case( "Install ###$$$ point intents" )
1779 main.step( "Add point Intents" )
1780 intentResult = main.TRUE
1781 deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) )
1782
1783 intentIdList = []
1784 time1 = time.time()
1785 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1786 pool = []
1787 for cli in main.CLIs:
1788 if i >= len( deviceCombos ):
1789 break
1790 t = main.Thread( target=cli.addPointIntent,
1791 threadID=main.threadID,
1792 name="addPointIntent",
1793 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
1794 pool.append(t)
1795 #time.sleep(1)
1796 t.start()
1797 i = i + 1
1798 main.threadID = main.threadID + 1
1799 for thread in pool:
1800 thread.join()
1801 intentIdList.append(thread.result)
1802 time2 = time.time()
1803 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1804 intentResult = main.TRUE
1805 intentsJson = main.ONOScli2.intents()
1806 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1807 intentsJson = intentsJson)
1808 print getIntentStateResult
1809 # Takes awhile for all the onos to get the intents
1810 time.sleep(30)
1811 main.step( "Verify Ping across all hosts" )
1812 pingResult = main.FALSE
1813 time1 = time.time()
1814 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
1815 time2 = time.time()
1816 timeDiff = round( ( time2 - time1 ), 2 )
1817 main.log.report(
1818 "Time taken for Ping All: " +
1819 str( timeDiff ) +
1820 " seconds" )
1821 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1822 onpass="PING ALL PASS",
1823 onfail="PING ALL FAIL" )
1824
kelvin-onlab65a72d22015-03-26 13:46:32 -07001825 case91Result = ( intentResult and pingResult )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001826
1827 utilities.assert_equals(
1828 expect=main.TRUE,
kelvin-onlabd878fc22015-03-27 13:33:41 -07001829 actual=case91Result,
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001830 onpass="Install ###$$$ point Intents and Ping All test PASS",
1831 onfail="Install ###$$$ point Intents and Ping All test FAIL" )
1832
1833 def CASE92( self ):
1834 """
kelvin-onlab77d6c302015-03-31 11:33:32 -07001835 Install 4556 point intents and verify ping all (Spine Topology)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001836 """
kelvin-onlab77d6c302015-03-31 11:33:32 -07001837 main.log.report( "Add 4556 point intents and verify pingall (Spine Topology)" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001838 main.log.report( "_______________________________________" )
1839 import itertools
1840 import time
kelvin-onlab77d6c302015-03-31 11:33:32 -07001841 main.case( "Install 4556 point intents" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001842 main.step( "Add point Intents" )
1843 intentResult = main.TRUE
kelvin-onlab77d6c302015-03-31 11:33:32 -07001844 main.pingTimeout = 600
1845 for i in range(len(main.hostMACs)):
1846 main.MACsDict[main.deviceDPIDs[i+10]] = main.hostMACs[i].split('/')[0]
1847 print main.MACsDict
1848 deviceCombos = list( itertools.permutations( main.deviceDPIDs[10:], 2 ) )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001849
1850 intentIdList = []
1851 time1 = time.time()
1852 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1853 pool = []
1854 for cli in main.CLIs:
1855 if i >= len( deviceCombos ):
1856 break
1857 t = main.Thread( target=cli.addPointIntent,
1858 threadID=main.threadID,
1859 name="addPointIntent",
1860 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
1861 pool.append(t)
1862 #time.sleep(1)
1863 t.start()
1864 i = i + 1
1865 main.threadID = main.threadID + 1
1866 for thread in pool:
1867 thread.join()
1868 intentIdList.append(thread.result)
1869 time2 = time.time()
1870 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1871 intentResult = main.TRUE
1872 intentsJson = main.ONOScli2.intents()
1873 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1874 intentsJson = intentsJson)
kelvin-onlab77d6c302015-03-31 11:33:32 -07001875 #print getIntentStateResult
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001876 # Takes awhile for all the onos to get the intents
kelvin-onlab77d6c302015-03-31 11:33:32 -07001877 time.sleep(60)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001878 main.step( "Verify Ping across all hosts" )
1879 pingResult = main.FALSE
1880 time1 = time.time()
1881 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
1882 time2 = time.time()
1883 timeDiff = round( ( time2 - time1 ), 2 )
1884 main.log.report(
1885 "Time taken for Ping All: " +
1886 str( timeDiff ) +
1887 " seconds" )
1888 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1889 onpass="PING ALL PASS",
1890 onfail="PING ALL FAIL" )
1891
kelvin-onlab65a72d22015-03-26 13:46:32 -07001892 case92Result = ( intentResult and pingResult )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001893
1894 utilities.assert_equals(
1895 expect=main.TRUE,
kelvin-onlab65a72d22015-03-26 13:46:32 -07001896 actual=case92Result,
kelvin-onlab77d6c302015-03-31 11:33:32 -07001897 onpass="Install 4556 point Intents and Ping All test PASS",
1898 onfail="Install 4556 point Intents and Ping All test FAIL" )
1899
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001900 def CASE93( self ):
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001901 """
kelvin-onlab77d6c302015-03-31 11:33:32 -07001902 Install multi-single point intents and verify Ping all works
1903 for att topology
1904 """
1905 import copy
1906 import time
1907 main.log.report( "Install multi-single point intents and verify Ping all" )
1908 main.log.report( "___________________________________________" )
1909 main.case( "Install multi-single point intents and Ping all" )
1910 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
1911 portIngressList = ['1']*(len(deviceDPIDsCopy) - 1)
1912 intentIdList = []
1913 print "MACsDict", main.MACsDict
1914 time1 = time.time()
1915 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
1916 pool = []
1917 for cli in main.CLIs:
1918 egressDevice = deviceDPIDsCopy[i]
1919 ingressDeviceList = copy.copy(deviceDPIDsCopy)
1920 ingressDeviceList.remove(egressDevice)
1921 if i >= len( deviceDPIDsCopy ):
1922 break
1923 t = main.Thread( target=cli.addMultipointToSinglepointIntent,
1924 threadID=main.threadID,
1925 name="addMultipointToSinglepointIntent",
1926 args =[ingressDeviceList,egressDevice,portIngressList,'1','IPV4','',main.MACsDict.get(egressDevice)])
1927 pool.append(t)
1928 #time.sleep(1)
1929 t.start()
1930 i = i + 1
1931 main.threadID = main.threadID + 1
1932 for thread in pool:
1933 thread.join()
1934 intentIdList.append(thread.result)
1935 time2 = time.time()
1936 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1937 time.sleep(5)
1938 main.step( "Verify Ping across all hosts" )
1939 pingResult = main.FALSE
1940 time1 = time.time()
1941 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
1942 time2 = time.time()
1943 timeDiff = round( ( time2 - time1 ), 2 )
1944 main.log.report(
1945 "Time taken for Ping All: " +
1946 str( timeDiff ) +
1947 " seconds" )
1948
1949 case93Result = pingResult
1950 utilities.assert_equals(
1951 expect=main.TRUE,
1952 actual=case93Result,
1953 onpass="Install 25 multi to single point Intents and Ping All test PASS",
1954 onfail="Install 25 multi to single point Intents and Ping All test FAIL" )
1955
kelvin-onlab20c712a2015-03-31 12:55:34 -07001956 def CASE94( self ):
1957 """
1958 Install multi-single point intents and verify Ping all works
1959 for spine topology
1960 """
1961 import copy
1962 import time
1963 main.log.report( "Install multi-single point intents and verify Ping all" )
1964 main.log.report( "___________________________________________" )
1965 main.case( "Install multi-single point intents and Ping all" )
1966 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
1967 portIngressList = ['1']*(len(deviceDPIDsCopy) - 1)
1968 intentIdList = []
1969 print "MACsDict", main.MACsDict
1970 time1 = time.time()
1971 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
1972 pool = []
1973 for cli in main.CLIs:
1974 egressDevice = deviceDPIDsCopy[i]
1975 ingressDeviceList = copy.copy(deviceDPIDsCopy)
1976 ingressDeviceList.remove(egressDevice)
1977 if i >= len( deviceDPIDsCopy ):
1978 break
1979 t = main.Thread( target=cli.addMultipointToSinglepointIntent,
1980 threadID=main.threadID,
1981 name="addMultipointToSinglepointIntent",
1982 args =[ingressDeviceList,egressDevice,portIngressList,'1','IPV4','',main.MACsDict.get(egressDevice)])
1983 pool.append(t)
1984 #time.sleep(1)
1985 t.start()
1986 i = i + 1
1987 main.threadID = main.threadID + 1
1988 for thread in pool:
1989 thread.join()
1990 intentIdList.append(thread.result)
1991 time2 = time.time()
1992 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1993 time.sleep(5)
1994 main.step( "Verify Ping across all hosts" )
1995 pingResult = main.FALSE
1996 time1 = time.time()
1997 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
1998 time2 = time.time()
1999 timeDiff = round( ( time2 - time1 ), 2 )
2000 main.log.report(
2001 "Time taken for Ping All: " +
2002 str( timeDiff ) +
2003 " seconds" )
2004
2005 case94Result = pingResult
2006 utilities.assert_equals(
2007 expect=main.TRUE,
2008 actual=case94Result,
2009 onpass="Install 25 multi to single point Intents and Ping All test PASS",
2010 onfail="Install 25 multi to single point Intents and Ping All test FAIL" )
kelvin-onlab77d6c302015-03-31 11:33:32 -07002011
2012
2013 def CASE96( self ):
2014 """
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002015 Install single-multi point intents and verify Ping all works
2016 for att topology
2017 """
2018 import copy
2019 main.log.report( "Install single-multi point intents and verify Ping all" )
2020 main.log.report( "___________________________________________" )
2021 main.case( "Install single-multi point intents and Ping all" )
2022 deviceLinksCopy = copy.copy( main.deviceLinks )
2023 main.step( "Install single-multi point intents" )
2024 for i in range( len( deviceLinksCopy ) ):
2025 pointLink = str(
2026 deviceLinksCopy[ i ] ).replace(
2027 "src=",
2028 "" ).replace(
2029 "dst=",
2030 "" ).split( ',' )
2031 point1 = pointLink[ 0 ].split( '/' )
2032 point2 = pointLink[ 1 ].split( '/' )
2033 installResult = main.ONOScli1.addPointIntent(
2034 point1[ 0 ], point2[ 0 ], int(
2035 point1[ 1 ] ), int(
2036 point2[ 1 ] ) )
2037 if installResult == main.TRUE:
2038 print "Installed Point intent between :", point1[ 0 ], int( point1[ 1 ] ), point2[ 0 ], int( point2[ 1 ] )
2039
2040 main.step( "Obtain the intent id's" )
2041 intentsList = main.ONOScli1.getAllIntentIds()
2042 ansi_escape = re.compile( r'\x1b[^m]*m' )
2043 intentsList = ansi_escape.sub( '', intentsList )
2044 intentsList = intentsList.replace(
2045 " onos:intents | grep id=",
2046 "" ).replace(
2047 "id=",
2048 "" ).replace(
2049 "\r\r",
2050 "" )
2051 intentsList = intentsList.splitlines()
2052 intentsList = intentsList[ 1: ]
2053 intentIdList = []
2054 for i in range( len( intentsList ) ):
2055 intentsTemp = intentsList[ i ].split( ',' )
2056 intentIdList.append( intentsTemp[ 0 ] )
2057 print "Intent IDs: ", intentIdList
2058 print "Total Intents installed: ", len( intentIdList )
2059
2060 main.step( "Verify Ping across all hosts" )
2061 pingResult = main.FALSE
2062 time1 = time.time()
2063 pingResult = main.Mininet1.pingall()
2064 time2 = time.time()
2065 timeDiff = round( ( time2 - time1 ), 2 )
2066 main.log.report(
2067 "Time taken for Ping All: " +
2068 str( timeDiff ) +
2069 " seconds" )
2070 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
2071 onpass="PING ALL PASS",
2072 onfail="PING ALL FAIL" )
2073
2074 case8_result = installResult and pingResult
2075 utilities.assert_equals(
2076 expect=main.TRUE,
2077 actual=case8_result,
2078 onpass="Ping all test after Point intents addition successful",
2079 onfail="Ping all test after Point intents addition failed" )
2080
kelvin-onlab77d6c302015-03-31 11:33:32 -07002081 def CASE97( self ):
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002082 """
2083 Install single-multi point intents and verify Ping all works
2084 """
2085 import copy
2086 main.log.report( "Install single-multi point intents and verify Ping all" )
2087 main.log.report( "___________________________________________" )
2088 main.case( "Install single-multi point intents and Ping all" )
2089 deviceLinksCopy = copy.copy( main.deviceLinks )
2090 main.step( "Install single-multi point intents" )
2091 for i in range( len( deviceLinksCopy ) ):
2092 pointLink = str(
2093 deviceLinksCopy[ i ] ).replace(
2094 "src=",
2095 "" ).replace(
2096 "dst=",
2097 "" ).split( ',' )
2098 point1 = pointLink[ 0 ].split( '/' )
2099 point2 = pointLink[ 1 ].split( '/' )
2100 installResult = main.ONOScli1.addPointIntent(
2101 point1[ 0 ], point2[ 0 ], int(
2102 point1[ 1 ] ), int(
2103 point2[ 1 ] ) )
2104 if installResult == main.TRUE:
2105 print "Installed Point intent between :", point1[ 0 ], int( point1[ 1 ] ), point2[ 0 ], int( point2[ 1 ] )
2106
2107 main.step( "Obtain the intent id's" )
2108 intentsList = main.ONOScli1.getAllIntentIds()
2109 ansi_escape = re.compile( r'\x1b[^m]*m' )
2110 intentsList = ansi_escape.sub( '', intentsList )
2111 intentsList = intentsList.replace(
2112 " onos:intents | grep id=",
2113 "" ).replace(
2114 "id=",
2115 "" ).replace(
2116 "\r\r",
2117 "" )
2118 intentsList = intentsList.splitlines()
2119 intentsList = intentsList[ 1: ]
2120 intentIdList = []
2121 for i in range( len( intentsList ) ):
2122 intentsTemp = intentsList[ i ].split( ',' )
2123 intentIdList.append( intentsTemp[ 0 ] )
2124 print "Intent IDs: ", intentIdList
2125 print "Total Intents installed: ", len( intentIdList )
2126
2127 main.step( "Verify Ping across all hosts" )
2128 pingResult = main.FALSE
2129 time1 = time.time()
2130 pingResult = main.Mininet1.pingall()
2131 time2 = time.time()
2132 timeDiff = round( ( time2 - time1 ), 2 )
2133 main.log.report(
2134 "Time taken for Ping All: " +
2135 str( timeDiff ) +
2136 " seconds" )
2137 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
2138 onpass="PING ALL PASS",
2139 onfail="PING ALL FAIL" )
2140
2141 case8_result = installResult and pingResult
2142 utilities.assert_equals(
2143 expect=main.TRUE,
2144 actual=case8_result,
2145 onpass="Ping all test after Point intents addition successful",
2146 onfail="Ping all test after Point intents addition failed" )
2147
kelvin-onlab8a832582015-01-16 17:06:11 -08002148 def CASE10( self ):
kelvin-onlab7642bb12015-02-27 13:48:17 -08002149 import time
kelvin-onlab8a832582015-01-16 17:06:11 -08002150 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002151 Remove all Intents
kelvin-onlab8a832582015-01-16 17:06:11 -08002152 """
2153 main.log.report( "Remove all intents that were installed previously" )
2154 main.log.report( "______________________________________________" )
2155 main.log.info( "Remove all intents" )
2156 main.case( "Removing intents" )
2157 main.step( "Obtain the intent id's first" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002158 intentsList = main.ONOScli1.getAllIntentIds()
kelvin-onlab8a832582015-01-16 17:06:11 -08002159 ansi_escape = re.compile( r'\x1b[^m]*m' )
2160 intentsList = ansi_escape.sub( '', intentsList )
2161 intentsList = intentsList.replace(
2162 " onos:intents | grep id=",
2163 "" ).replace(
2164 "id=",
2165 "" ).replace(
2166 "\r\r",
2167 "" )
2168 intentsList = intentsList.splitlines()
2169 intentsList = intentsList[ 1: ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002170 intentIdList = []
2171 step1Result = main.TRUE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002172 moreIntents = main.TRUE
2173 removeIntentCount = 0
kelvin-onlab65a72d22015-03-26 13:46:32 -07002174 intentsCount = len(intentsList)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002175 print "Current number of intents" , len(intentsList)
kelvin-onlab8a832582015-01-16 17:06:11 -08002176 if ( len( intentsList ) > 1 ):
kelvin-onlab54400a92015-02-26 18:05:51 -08002177 results = main.TRUE
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002178 main.log.info("Removing intent...")
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002179 while moreIntents:
Hari Krishnab35c6d02015-03-18 11:13:51 -07002180 if removeIntentCount == 5:
2181 break
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002182 removeIntentCount = removeIntentCount + 1
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002183 intentsList1 = main.ONOScli1.getAllIntentIds()
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002184 if len( intentsList1 ) == 0:
2185 break
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002186 ansi_escape = re.compile( r'\x1b[^m]*m' )
2187 intentsList1 = ansi_escape.sub( '', intentsList1 )
2188 intentsList1 = intentsList1.replace(
2189 " onos:intents | grep id=",
2190 "" ).replace(
2191 " state=",
2192 "" ).replace(
2193 "\r\r",
2194 "" )
2195 intentsList1 = intentsList1.splitlines()
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002196 intentsList1 = intentsList1[ 1: ]
2197 print "Round %d intents to remove: " %(removeIntentCount)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002198 print intentsList1
2199 intentIdList1 = []
Hari Krishnab35c6d02015-03-18 11:13:51 -07002200 if ( len( intentsList1 ) > 0 ):
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002201 moreIntents = main.TRUE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002202 for i in range( len( intentsList1 ) ):
2203 intentsTemp1 = intentsList1[ i ].split( ',' )
2204 intentIdList1.append( intentsTemp1[ 0 ].split('=')[1] )
2205 print "Leftover Intent IDs: ", intentIdList1
2206 print len(intentIdList1)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07002207 time1 = time.time()
2208 for i in xrange( 0, len( intentIdList1 ), int(main.numCtrls) ):
2209 pool = []
2210 for cli in main.CLIs:
2211 if i >= len( intentIdList1 ):
2212 break
2213 t = main.Thread( target=cli.removeIntent,
2214 threadID=main.threadID,
2215 name="removeIntent",
2216 args=[intentIdList1[i],'org.onosproject.cli',True,False])
2217 pool.append(t)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07002218 t.start()
2219 i = i + 1
2220 main.threadID = main.threadID + 1
2221 for thread in pool:
2222 thread.join()
2223 intentIdList.append(thread.result)
2224 time2 = time.time()
2225 main.log.info("Time for removing host intents: %2f seconds" %(time2-time1))
Hari Krishnab35c6d02015-03-18 11:13:51 -07002226 time.sleep(10)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002227 else:
Hari Krishnaef1bd4e2015-03-12 16:55:30 -07002228 time.sleep(15)
Hari Krishnab35c6d02015-03-18 11:13:51 -07002229 if len( main.ONOScli1.intents()):
Hari Krishnaef1bd4e2015-03-12 16:55:30 -07002230 continue
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002231 break
kelvin-onlab36c02b12015-03-11 11:25:55 -07002232
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002233 else:
kelvin-onlab65a72d22015-03-26 13:46:32 -07002234 print "Removed %d intents" %(intentsCount)
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002235 step1Result = main.TRUE
2236 else:
2237 print "No Intent IDs found in Intents list: ", intentsList
2238 step1Result = main.FALSE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002239
kelvin-onlabdc8719b2015-03-02 14:01:52 -08002240 print main.ONOScli1.intents()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002241 caseResult10 = step1Result
2242 utilities.assert_equals( expect=main.TRUE, actual=caseResult10,
kelvin-onlab8a832582015-01-16 17:06:11 -08002243 onpass="Intent removal test successful",
2244 onfail="Intent removal test failed" )
Hari Krishna22c3d412015-02-17 16:48:12 -08002245
2246 def CASE11( self, main ):
2247 """
2248 Enable onos-app-ifwd, Verify Intent based Reactive forwarding through ping all and Disable it
2249 """
2250 import re
2251 import copy
2252 import time
2253
kelvin-onlab54400a92015-02-26 18:05:51 -08002254 Thread = imp.load_source('Thread','/home/admin/ONLabTest/TestON/tests/OnosCHO/Thread.py')
2255 threadID = 0
2256
Hari Krishna22c3d412015-02-17 16:48:12 -08002257 main.log.report( "Enable Intent based Reactive forwarding and Verify ping all" )
2258 main.log.report( "_____________________________________________________" )
2259 main.case( "Enable Intent based Reactive forwarding and Verify ping all" )
2260 main.step( "Enable intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08002261 installResult = main.FALSE
2262 feature = "onos-app-ifwd"
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002263
kelvin-onlab54400a92015-02-26 18:05:51 -08002264 pool = []
2265 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002266 for cli,feature in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -08002267 t = main.Thread(target=cli,threadID=threadID,
2268 name="featureInstall",args=[feature])
2269 pool.append(t)
2270 t.start()
2271 threadID = threadID + 1
2272
2273 results = []
2274 for thread in pool:
2275 thread.join()
2276 results.append(thread.result)
2277 time2 = time.time()
2278
2279 if( all(result == main.TRUE for result in results) == False):
2280 main.log.info("Did not install onos-app-ifwd feature properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -07002281 #main.cleanup()
2282 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -08002283 else:
2284 main.log.info("Successful feature:install onos-app-ifwd")
2285 installResult = main.TRUE
2286 main.log.info("Time for feature:install onos-app-ifwd: %2f seconds" %(time2-time1))
2287
Hari Krishna22c3d412015-02-17 16:48:12 -08002288 main.step( "Verify Pingall" )
2289 ping_result = main.FALSE
2290 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -08002291 ping_result = main.Mininet1.pingall(timeout=600)
Hari Krishna22c3d412015-02-17 16:48:12 -08002292 time2 = time.time()
2293 timeDiff = round( ( time2 - time1 ), 2 )
2294 main.log.report(
2295 "Time taken for Ping All: " +
2296 str( timeDiff ) +
2297 " seconds" )
kelvin-onlab54400a92015-02-26 18:05:51 -08002298
Hari Krishna22c3d412015-02-17 16:48:12 -08002299 if ping_result == main.TRUE:
2300 main.log.report( "Pingall Test in Reactive mode successful" )
2301 else:
2302 main.log.report( "Pingall Test in Reactive mode failed" )
2303
2304 main.step( "Disable Intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08002305 uninstallResult = main.FALSE
2306
kelvin-onlab54400a92015-02-26 18:05:51 -08002307 pool = []
2308 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002309 for cli,feature in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -08002310 t = main.Thread(target=cli,threadID=threadID,
2311 name="featureUninstall",args=[feature])
2312 pool.append(t)
2313 t.start()
2314 threadID = threadID + 1
2315
2316 results = []
2317 for thread in pool:
2318 thread.join()
2319 results.append(thread.result)
2320 time2 = time.time()
2321
2322 if( all(result == main.TRUE for result in results) == False):
2323 main.log.info("Did not uninstall onos-app-ifwd feature properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -07002324 uninstallResult = main.FALSE
2325 #main.cleanup()
2326 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -08002327 else:
2328 main.log.info("Successful feature:uninstall onos-app-ifwd")
2329 uninstallResult = main.TRUE
2330 main.log.info("Time for feature:uninstall onos-app-ifwd: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -08002331
2332 # Waiting for reative flows to be cleared.
2333 time.sleep( 10 )
2334
2335 case11Result = installResult and ping_result and uninstallResult
2336 utilities.assert_equals( expect=main.TRUE, actual=case11Result,
2337 onpass="Intent based Reactive forwarding Pingall test PASS",
2338 onfail="Intent based Reactive forwarding Pingall test FAIL" )
2339
Hari Krishnab35c6d02015-03-18 11:13:51 -07002340 def CASE99(self):
2341 import time
2342 # WORK AROUND FOR ONOS-581. STOP ONOS BEFORE ASSIGNING CONTROLLERS AT MININET & START ONCE DONE
2343 main.step( "Stop ONOS on all Nodes" )
2344 stopResult = main.TRUE
2345 for i in range( 1, int( main.numCtrls ) + 1 ):
2346 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
2347 main.log.info( "Stopping ONOS Node IP: " + ONOS_ip )
2348 sresult = main.ONOSbench.onosStop( ONOS_ip )
2349 utilities.assert_equals( expect=main.TRUE, actual=sresult,
2350 onpass="Test step PASS",
2351 onfail="Test step FAIL" )
2352 stopResult = ( stopResult and sresult )
2353
2354 main.step( "Start ONOS on all Nodes" )
2355 startResult = main.TRUE
2356 for i in range( 1, int( main.numCtrls ) + 1 ):
2357 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
2358 main.log.info( "Starting ONOS Node IP: " + ONOS_ip )
2359 sresult = main.ONOSbench.onosStart( ONOS_ip )
2360 utilities.assert_equals( expect=main.TRUE, actual=sresult,
2361 onpass="Test step PASS",
2362 onfail="Test step FAIL" )
2363 startResult = ( startResult and sresult )
2364
2365 main.step( "Start ONOS CLI on all nodes" )
2366 cliResult = main.TRUE
2367 time.sleep( 30 )
2368 main.log.step(" Start ONOS cli using thread ")
2369 pool = []
2370 time1 = time.time()
2371 for i in range( int( main.numCtrls ) ):
2372 t = main.Thread(target=main.CLIs[i].startOnosCli,
2373 threadID=main.threadID,
2374 name="startOnosCli",
2375 args=[main.nodes[i].ip_address])
2376 pool.append(t)
2377 t.start()
2378 main.threadID = main.threadID + 1
2379 for t in pool:
2380 t.join()
2381 cliResult = cliResult and t.result
2382 time2 = time.time()
2383
2384 if not cliResult:
2385 main.log.info("ONOS CLI did not start up properly")
2386 #main.cleanup()
2387 #main.exit()
2388 else:
2389 main.log.info("Successful CLI startup")
2390 main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
2391
2392 case99Result = ( startResult and cliResult )
2393 time.sleep(30)
2394 utilities.assert_equals(
2395 expect=main.TRUE,
2396 actual=case99Result,
2397 onpass="Starting new Chordal topology test PASS",
2398 onfail="Starting new Chordal topology test FAIL" )
2399
2400
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002401
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002402