blob: cd70c803c3c8f2ca6064ccd7a9d89e29cb7a9209 [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",
kelvin-onlabc44f0192015-04-02 22:08:41 -0700144 args=[ main.nodes[i].ip_address, karafTimeout ] )
kelvin-onlab54400a92015-02-26 18:05:51 -0800145 pool.append(t)
146 t.start()
147 main.threadID = main.threadID + 1
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800148 for t in pool:
149 t.join()
150 startCliResult = startCliResult and t.result
kelvin-onlab54400a92015-02-26 18:05:51 -0800151 time2 = time.time()
152
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800153 if not startCliResult:
kelvin-onlab54400a92015-02-26 18:05:51 -0800154 main.log.info("ONOS CLI did not start up properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -0700155 #main.cleanup()
156 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -0800157 else:
158 main.log.info("Successful CLI startup")
159 startCliResult = main.TRUE
160 case1Result = installResult and uninstallResult and statusResult and startCliResult
161
162 main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
kelvin-onlab8a832582015-01-16 17:06:11 -0800163 utilities.assert_equals( expect=main.TRUE, actual=case1Result,
164 onpass="Set up test environment PASS",
165 onfail="Set up test environment FAIL" )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700166
kelvin-onlab65a72d22015-03-26 13:46:32 -0700167 def CASE20( self, main ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800168 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700169 This test script Loads a new Topology (Att) on CHO setup and balances all switches
kelvin-onlab8a832582015-01-16 17:06:11 -0800170 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800171 import re
172 import time
173 import copy
Hari Krishnab35c6d02015-03-18 11:13:51 -0700174
Hari Krishna22c3d412015-02-17 16:48:12 -0800175 main.numMNswitches = int ( main.params[ 'TOPO1' ][ 'numSwitches' ] )
176 main.numMNlinks = int ( main.params[ 'TOPO1' ][ 'numLinks' ] )
177 main.numMNhosts = int ( main.params[ 'TOPO1' ][ 'numHosts' ] )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700178 main.pingTimeout = 60
kelvin-onlab8a832582015-01-16 17:06:11 -0800179 main.log.report(
Hari Krishnab35c6d02015-03-18 11:13:51 -0700180 "Load Att topology and Balance all Mininet switches across controllers" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800181 main.log.report(
Hari Krishnab35c6d02015-03-18 11:13:51 -0700182 "________________________________________________________________________" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800183 main.case(
184 "Assign and Balance all Mininet switches across controllers" )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700185 main.step( "Stop any previous Mininet network topology" )
186 cliResult = main.TRUE
187 if main.newTopo == main.params['TOPO3']['topo']:
188 stopStatus = main.Mininet1.stopNet( fileName = "topoSpine" )
189
190 main.step( "Start Mininet with Att topology" )
191 main.newTopo = main.params['TOPO1']['topo']
192 startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
193
kelvin-onlab8a832582015-01-16 17:06:11 -0800194 main.step( "Assign switches to controllers" )
Hari Krishna22c3d412015-02-17 16:48:12 -0800195 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
Hari Krishnad97213e2015-01-24 19:30:14 -0800196 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800197 sw=str( i ),
Hari Krishna22c3d412015-02-17 16:48:12 -0800198 count=int( main.numCtrls ),
199 ip1=main.ONOS1_ip,
200 port1=main.ONOS1_port,
201 ip2=main.ONOS2_ip,
202 port2=main.ONOS2_port,
203 ip3=main.ONOS3_ip,
204 port3=main.ONOS3_port,
205 ip4=main.ONOS4_ip,
206 port4=main.ONOS4_port,
207 ip5=main.ONOS5_ip,
208 port5=main.ONOS5_port )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800209
210 switch_mastership = main.TRUE
Hari Krishna22c3d412015-02-17 16:48:12 -0800211 for i in range( 1, ( main.numMNswitches + 1 ) ):
Hari Krishnad97213e2015-01-24 19:30:14 -0800212 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800213 print( "Response is " + str( response ) )
Hari Krishna22c3d412015-02-17 16:48:12 -0800214 if re.search( "tcp:" + main.ONOS1_ip, response ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800215 switch_mastership = switch_mastership and main.TRUE
216 else:
217 switch_mastership = main.FALSE
218
219 if switch_mastership == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800220 main.log.report( "Controller assignment successfull" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800221 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800222 main.log.report( "Controller assignment failed" )
kelvin-onlab77d6c302015-03-31 11:33:32 -0700223
224 """topoFailed = main.FALSE
225 checkCount = 0
226 while(topoFailed == main.FALSE):
227 topology_output = main.ONOScli1.topology()
228 topology_result = main.ONOSbench.getTopology( topology_output )
229 numOnosDevices = topology_result[ 'deviceCount' ]
230 numOnosLinks = topology_result[ 'linkCount' ]
231 if ( ( main.numMNswitches == int(numOnosDevices) ) and ( main.numMNlinks >= int(numOnosLinks) ) ):
232 main.log.info("Att topology is now ready!")
233 break
234 else:
235 main.log.info("Att topology is not ready yet!")
236 checkCount = checkCount + 1
237 time.sleep(2)
238 if checkCount == 10:
239 topoFailed = main.TRUE
240 if topoFailed:
241 main.log.info("Att topology failed to start correctly")
Hari Krishnab35c6d02015-03-18 11:13:51 -0700242 """
kelvin-onlab77d6c302015-03-31 11:33:32 -0700243 time.sleep(15)
244 #Don't balance master for now..
Hari Krishnab35c6d02015-03-18 11:13:51 -0700245 main.step( "Balance devices across controllers" )
246 for i in range( int( main.numCtrls ) ):
247 balanceResult = main.ONOScli1.balanceMasters()
kelvin-onlab8a832582015-01-16 17:06:11 -0800248 # giving some breathing time for ONOS to complete re-balance
Hari Krishnab35c6d02015-03-18 11:13:51 -0700249 time.sleep( 3 )
kelvin-onlab77d6c302015-03-31 11:33:32 -0700250 topology_output = main.ONOScli1.topology()
251 topology_result = main.ONOSbench.getTopology( topology_output )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700252 case2Result = ( switch_mastership and startStatus )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700253 utilities.assert_equals(
254 expect=main.TRUE,
255 actual=case2Result,
256 onpass="Starting new Att topology test PASS",
257 onfail="Starting new Att topology test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800258
kelvin-onlab65a72d22015-03-26 13:46:32 -0700259 def CASE21( self, main ):
260 """
261 This test script Loads a new Topology (Chordal) on CHO setup and balances all switches
262 """
263 import re
264 import time
265 import copy
266
267 main.newTopo = main.params['TOPO2']['topo']
268 main.numMNswitches = int ( main.params[ 'TOPO2' ][ 'numSwitches' ] )
269 main.numMNlinks = int ( main.params[ 'TOPO2' ][ 'numLinks' ] )
270 main.numMNhosts = int ( main.params[ 'TOPO2' ][ 'numHosts' ] )
271 main.pingTimeout = 120
272 main.log.report(
273 "Load Chordal topology and Balance all Mininet switches across controllers" )
274 main.log.report(
275 "________________________________________________________________________" )
276 main.case(
277 "Assign and Balance all Mininet switches across controllers" )
278 main.step( "Stop any previous Mininet network topology" )
kelvin-onlabb9408212015-04-01 13:34:04 -0700279 stopStatus = main.Mininet1.stopNet(fileName = "topoChordal" )
kelvin-onlab65a72d22015-03-26 13:46:32 -0700280 #time.sleep(10)
281 main.step( "Start Mininet with Chordal topology" )
282 startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
283 time.sleep(15)
284 main.step( "Assign switches to controllers" )
285 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
286 main.Mininet1.assignSwController(
287 sw=str( i ),
288 count=int( main.numCtrls ),
289 ip1=main.ONOS1_ip,
290 port1=main.ONOS1_port,
291 ip2=main.ONOS2_ip,
292 port2=main.ONOS2_port,
293 ip3=main.ONOS3_ip,
294 port3=main.ONOS3_port,
295 ip4=main.ONOS4_ip,
296 port4=main.ONOS4_port,
297 ip5=main.ONOS5_ip,
298 port5=main.ONOS5_port )
299
300 switch_mastership = main.TRUE
301 for i in range( 1, ( main.numMNswitches + 1 ) ):
302 response = main.Mininet1.getSwController( "s" + str( i ) )
303 print( "Response is " + str( response ) )
304 if re.search( "tcp:" + main.ONOS1_ip, response ):
305 switch_mastership = switch_mastership and main.TRUE
306 else:
307 switch_mastership = main.FALSE
308
309 if switch_mastership == main.TRUE:
310 main.log.report( "Controller assignment successfull" )
311 else:
312 main.log.report( "Controller assignment failed" )
313 time.sleep( 5 )
314
315 #Don't balance master for now..
316 """
317 main.step( "Balance devices across controllers" )
318 for i in range( int( main.numCtrls ) ):
319 balanceResult = main.ONOScli1.balanceMasters()
320 # giving some breathing time for ONOS to complete re-balance
321 time.sleep( 3 )
322 """
323 case21Result = switch_mastership
324 time.sleep(30)
325 utilities.assert_equals(
326 expect=main.TRUE,
327 actual=case21Result,
328 onpass="Starting new Chordal topology test PASS",
329 onfail="Starting new Chordal topology test FAIL" )
330
331 def CASE22( self, main ):
332 """
333 This test script Loads a new Topology (Spine) on CHO setup and balances all switches
334 """
335 import re
336 import time
337 import copy
338
339 main.newTopo = main.params['TOPO3']['topo']
340 main.numMNswitches = int ( main.params[ 'TOPO3' ][ 'numSwitches' ] )
341 main.numMNlinks = int ( main.params[ 'TOPO3' ][ 'numLinks' ] )
342 main.numMNhosts = int ( main.params[ 'TOPO3' ][ 'numHosts' ] )
343 main.pingTimeout = 400
344
345 main.log.report(
346 "Load Spine and Leaf topology and Balance all Mininet switches across controllers" )
347 main.log.report(
348 "________________________________________________________________________" )
349 # need to wait here for sometime until ONOS bootup
350 main.case(
351 "Assign and Balance all Mininet switches across controllers" )
352 main.step( "Stop any previous Mininet network topology" )
kelvin-onlabb9408212015-04-01 13:34:04 -0700353 stopStatus = main.Mininet1.stopNet(fileName = "topoSpine" )
kelvin-onlab65a72d22015-03-26 13:46:32 -0700354 main.step( "Start Mininet with Spine topology" )
355 startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
356 time.sleep(20)
357 main.step( "Assign switches to controllers" )
358 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
359 main.Mininet1.assignSwController(
360 sw=str( i ),
361 count= 1,
362 ip1=main.ONOS1_ip,
363 port1=main.ONOS1_port,
364 ip2=main.ONOS2_ip,
365 port2=main.ONOS2_port,
366 ip3=main.ONOS3_ip,
367 port3=main.ONOS3_port,
368 ip4=main.ONOS4_ip,
369 port4=main.ONOS4_port,
370 ip5=main.ONOS5_ip,
371 port5=main.ONOS5_port )
372
373 switch_mastership = main.TRUE
374 for i in range( 1, ( main.numMNswitches + 1 ) ):
375 response = main.Mininet1.getSwController( "s" + str( i ) )
376 print( "Response is " + str( response ) )
377 if re.search( "tcp:" + main.ONOS1_ip, response ):
378 switch_mastership = switch_mastership and main.TRUE
379 else:
380 switch_mastership = main.FALSE
381
382 if switch_mastership == main.TRUE:
383 main.log.report( "Controller assignment successfull" )
384 else:
385 main.log.report( "Controller assignment failed" )
386 time.sleep( 5 )
387 """
388 main.step( "Balance devices across controllers" )
389
390 for i in range( int( main.numCtrls ) ):
391 balanceResult = main.ONOScli1.balanceMasters()
392 # giving some breathing time for ONOS to complete re-balance
393 time.sleep( 3 )
394
395 main.step( "Balance devices across controllers" )
396 for i in range( int( main.numCtrls ) ):
397 balanceResult = main.ONOScli1.balanceMasters()
398 # giving some breathing time for ONOS to complete re-balance
399 time.sleep( 3 )
400 """
401 case22Result = switch_mastership
402 time.sleep(30)
403 utilities.assert_equals(
404 expect=main.TRUE,
405 actual=case22Result,
406 onpass="Starting new Spine topology test PASS",
407 onfail="Starting new Spine topology test FAIL" )
408
kelvin-onlab8a832582015-01-16 17:06:11 -0800409 def CASE3( self, main ):
410 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800411 This Test case will be extended to collect and store more data related
412 ONOS state.
kelvin-onlab8a832582015-01-16 17:06:11 -0800413 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800414 import re
415 import copy
Hari Krishna22c3d412015-02-17 16:48:12 -0800416 main.deviceDPIDs = []
417 main.hostMACs = []
418 main.deviceLinks = []
419 main.deviceActiveLinksCount = []
420 main.devicePortsEnabledCount = []
kelvin-onlab54400a92015-02-26 18:05:51 -0800421
kelvin-onlab8a832582015-01-16 17:06:11 -0800422 main.log.report(
423 "Collect and Store topology details from ONOS before running any Tests" )
424 main.log.report(
425 "____________________________________________________________________" )
Hari Krishna5afb4cc2015-03-23 15:35:15 -0700426 main.case( "Collect and Store Topology Details from ONOS" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800427 main.step( "Collect and store current number of switches and links" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800428 topology_output = main.ONOScli1.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800429 topology_result = main.ONOSbench.getTopology( topology_output )
Hari Krishnaef1bd4e2015-03-12 16:55:30 -0700430 numOnosDevices = topology_result[ 'deviceCount' ]
431 numOnosLinks = topology_result[ 'linkCount' ]
Hari Krishnab35c6d02015-03-18 11:13:51 -0700432 topoResult = main.TRUE
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800433
kelvin-onlab54400a92015-02-26 18:05:51 -0800434 if ( ( main.numMNswitches == int(numOnosDevices) ) and ( main.numMNlinks >= int(numOnosLinks) ) ):
Hari Krishna22c3d412015-02-17 16:48:12 -0800435 main.step( "Store Device DPIDs" )
436 for i in range( 1, (main.numMNswitches+1) ):
437 main.deviceDPIDs.append( "of:00000000000000" + format( i, '02x' ) )
438 print "Device DPIDs in Store: \n", str( main.deviceDPIDs )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800439
Hari Krishna22c3d412015-02-17 16:48:12 -0800440 main.step( "Store Host MACs" )
441 for i in range( 1, ( main.numMNhosts + 1 ) ):
442 main.hostMACs.append( "00:00:00:00:00:" + format( i, '02x' ) + "/-1" )
443 print "Host MACs in Store: \n", str( main.hostMACs )
Hari Krishna5afb4cc2015-03-23 15:35:15 -0700444 main.MACsDict = {}
kelvin-onlab65a72d22015-03-26 13:46:32 -0700445 print "Creating dictionary of DPID and HostMacs"
446 for i in range(len(main.hostMACs)):
Hari Krishna5afb4cc2015-03-23 15:35:15 -0700447 main.MACsDict[main.deviceDPIDs[i]] = main.hostMACs[i].split('/')[0]
448 print main.MACsDict
Hari Krishna22c3d412015-02-17 16:48:12 -0800449 main.step( "Collect and store all Devices Links" )
450 linksResult = main.ONOScli1.links( jsonFormat=False )
451 ansi_escape = re.compile( r'\x1b[^m]*m' )
452 linksResult = ansi_escape.sub( '', linksResult )
453 linksResult = linksResult.replace( " links", "" ).replace( "\r\r", "" )
454 linksResult = linksResult.splitlines()
455 linksResult = linksResult[ 1: ]
456 main.deviceLinks = copy.copy( linksResult )
457 print "Device Links Stored: \n", str( main.deviceLinks )
458 # this will be asserted to check with the params provided count of
459 # links
460 print "Length of Links Store", len( main.deviceLinks )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800461
Hari Krishna22c3d412015-02-17 16:48:12 -0800462 main.step( "Collect and store each Device ports enabled Count" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800463 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800464 for i in xrange(1,(main.numMNswitches + 1), int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800465 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800466 for cli in main.CLIs:
kelvin-onlabc44f0192015-04-02 22:08:41 -0700467 if i >= main.numMNswitches + 1:
kelvin-onlabfbcd82f2015-04-02 12:06:00 -0700468 break
kelvin-onlab54400a92015-02-26 18:05:51 -0800469 dpid = "of:00000000000000" + format( i,'02x' )
470 t = main.Thread(target = cli.getDevicePortsEnabledCount,threadID = main.threadID, name = "getDevicePortsEnabledCount",args = [dpid])
471 t.start()
472 pool.append(t)
473 i = i + 1
474 main.threadID = main.threadID + 1
475 for thread in pool:
476 thread.join()
477 portResult = thread.result
478 portTemp = re.split( r'\t+', portResult )
479 portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
480 main.devicePortsEnabledCount.append( portCount )
Hari Krishna22c3d412015-02-17 16:48:12 -0800481 print "Device Enabled Port Counts Stored: \n", str( main.devicePortsEnabledCount )
kelvin-onlab54400a92015-02-26 18:05:51 -0800482 time2 = time.time()
483 main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1))
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800484
Hari Krishna22c3d412015-02-17 16:48:12 -0800485 main.step( "Collect and store each Device active links Count" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800486 time1 = time.time()
487
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800488 for i in xrange( 1,( main.numMNswitches + 1 ), int( main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800489 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800490 for cli in main.CLIs:
kelvin-onlabc44f0192015-04-02 22:08:41 -0700491 if i >= main.numMNswitches + 1:
kelvin-onlabfbcd82f2015-04-02 12:06:00 -0700492 break
kelvin-onlab54400a92015-02-26 18:05:51 -0800493 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800494 t = main.Thread( target = cli.getDeviceLinksActiveCount,
495 threadID = main.threadID,
496 name = "getDevicePortsEnabledCount",
497 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800498 t.start()
499 pool.append(t)
500 i = i + 1
501 main.threadID = main.threadID + 1
502 for thread in pool:
503 thread.join()
504 linkCountResult = thread.result
505 linkCountTemp = re.split( r'\t+', linkCountResult )
506 linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
507 main.deviceActiveLinksCount.append( linkCount )
kelvin-onlabfbcd82f2015-04-02 12:06:00 -0700508 print "Device Active Links Count Stored: \n", str( main.deviceActiveLinksCount )
kelvin-onlab54400a92015-02-26 18:05:51 -0800509 time2 = time.time()
510 main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800511
512 else:
513 main.log.info("Devices (expected): %s, Links (expected): %s" %
514 ( str( main.numMNswitches ), str( main.numMNlinks ) ) )
515 main.log.info("Devices (actual): %s, Links (actual): %s" %
516 ( numOnosDevices , numOnosLinks ) )
517 main.log.info("Topology does not match, exiting CHO test...")
Hari Krishnab35c6d02015-03-18 11:13:51 -0700518 topoResult = main.FALSE
519
kelvin-onlab54400a92015-02-26 18:05:51 -0800520 #time.sleep(300)
Hari Krishnab35c6d02015-03-18 11:13:51 -0700521 #main.cleanup()
522 #main.exit()
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800523
kelvin-onlab8a832582015-01-16 17:06:11 -0800524 # just returning TRUE for now as this one just collects data
Hari Krishnab35c6d02015-03-18 11:13:51 -0700525 case3Result = topoResult
Hari Krishna22c3d412015-02-17 16:48:12 -0800526 utilities.assert_equals( expect=main.TRUE, actual=case3Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800527 onpass="Saving ONOS topology data test PASS",
528 onfail="Saving ONOS topology data test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800529
kelvin-onlab65a72d22015-03-26 13:46:32 -0700530 def CASE40( self, main ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800531 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700532 Verify Reactive forwarding (Att Topology)
kelvin-onlab8a832582015-01-16 17:06:11 -0800533 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800534 import re
535 import copy
536 import time
Hari Krishnab35c6d02015-03-18 11:13:51 -0700537 main.log.report( "Verify Reactive forwarding (Att Topology)" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800538 main.log.report( "______________________________________________" )
539 main.case( "Enable Reactive forwarding and Verify ping all" )
540 main.step( "Enable Reactive forwarding" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800541 installResult = main.TRUE
kelvin-onlab06ade552015-03-31 18:09:27 -0700542 # Activate fwd app
543 appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700544 appCheck = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800545 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800546 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700547 t = main.Thread( target=cli.appToIDCheck,
548 name="appToIDCheck-" + str( i ),
549 args=[] )
550 pool.append( t )
kelvin-onlab54400a92015-02-26 18:05:51 -0800551 t.start()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800552 for t in pool:
553 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700554 appCheck = appCheck and t.result
555 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
556 onpass="App Ids seem to be correct",
557 onfail="Something is wrong with app Ids" )
558 if appCheck != main.TRUE:
559 main.log.warn( main.CLIs[0].apps() )
560 main.log.warn( main.CLIs[0].appIDs() )
561
562 time.sleep( 10 )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800563
kelvin-onlab8a832582015-01-16 17:06:11 -0800564 main.step( "Verify Pingall" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800565 ping_result = main.FALSE
566 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -0700567 ping_result = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800568 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800569 timeDiff = round( ( time2 - time1 ), 2 )
570 main.log.report(
571 "Time taken for Ping All: " +
572 str( timeDiff ) +
573 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800574
575 if ping_result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800576 main.log.report( "Pingall Test in Reactive mode successful" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800577 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800578 main.log.report( "Pingall Test in Reactive mode failed" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800579
kelvin-onlab8a832582015-01-16 17:06:11 -0800580 main.step( "Disable Reactive forwarding" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700581
582 main.log.info( "Uninstall reactive forwarding app" )
583 appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800584 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800585 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700586 t = main.Thread( target=cli.appToIDCheck,
587 name="appToIDCheck-" + str( i ),
588 args=[] )
589 pool.append( t )
kelvin-onlab54400a92015-02-26 18:05:51 -0800590 t.start()
kelvin-onlab06ade552015-03-31 18:09:27 -0700591
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800592 for t in pool:
593 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700594 appCheck = appCheck and t.result
595 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
596 onpass="App Ids seem to be correct",
597 onfail="Something is wrong with app Ids" )
598 if appCheck != main.TRUE:
599 main.log.warn( main.CLIs[0].apps() )
600 main.log.warn( main.CLIs[0].appIDs() )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800601
kelvin-onlab8a832582015-01-16 17:06:11 -0800602 # Waiting for reative flows to be cleared.
kelvin-onlab06ade552015-03-31 18:09:27 -0700603 time.sleep( 10 )
604 case40Result = installResult and uninstallResult and ping_result
605 utilities.assert_equals( expect=main.TRUE, actual=case40Result,
Hari Krishnab35c6d02015-03-18 11:13:51 -0700606 onpass="Reactive Mode Pingall test PASS",
607 onfail="Reactive Mode Pingall test FAIL" )
608
609 def CASE41( self, main ):
610 """
611 Verify Reactive forwarding (Chordal Topology)
612 """
613 import re
614 import copy
615 import time
616 main.log.report( "Verify Reactive forwarding (Chordal Topology)" )
617 main.log.report( "______________________________________________" )
618 main.case( "Enable Reactive forwarding and Verify ping all" )
619 main.step( "Enable Reactive forwarding" )
620 installResult = main.TRUE
kelvin-onlab06ade552015-03-31 18:09:27 -0700621 # Activate fwd app
622 appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" )
623
624 appCheck = main.TRUE
Hari Krishnab35c6d02015-03-18 11:13:51 -0700625 pool = []
Hari Krishnab35c6d02015-03-18 11:13:51 -0700626 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700627 t = main.Thread( target=cli.appToIDCheck,
628 name="appToIDCheck-" + str( i ),
629 args=[] )
630 pool.append( t )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700631 t.start()
Hari Krishnab35c6d02015-03-18 11:13:51 -0700632 for t in pool:
633 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700634 appCheck = appCheck and t.result
635 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
636 onpass="App Ids seem to be correct",
637 onfail="Something is wrong with app Ids" )
638 if appCheck != main.TRUE:
639 main.log.warn( main.CLIs[0].apps() )
640 main.log.warn( main.CLIs[0].appIDs() )
641
642 time.sleep( 10 )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700643
644 main.step( "Verify Pingall" )
645 ping_result = main.FALSE
646 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -0700647 ping_result = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
Hari Krishnab35c6d02015-03-18 11:13:51 -0700648 time2 = time.time()
649 timeDiff = round( ( time2 - time1 ), 2 )
650 main.log.report(
651 "Time taken for Ping All: " +
652 str( timeDiff ) +
653 " seconds" )
654
655 if ping_result == main.TRUE:
656 main.log.report( "Pingall Test in Reactive mode successful" )
657 else:
658 main.log.report( "Pingall Test in Reactive mode failed" )
659
660 main.step( "Disable Reactive forwarding" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700661
662 main.log.info( "Uninstall reactive forwarding app" )
663 appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700664 pool = []
Hari Krishnab35c6d02015-03-18 11:13:51 -0700665 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700666 t = main.Thread( target=cli.appToIDCheck,
667 name="appToIDCheck-" + str( i ),
668 args=[] )
669 pool.append( t )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700670 t.start()
kelvin-onlab06ade552015-03-31 18:09:27 -0700671
Hari Krishnab35c6d02015-03-18 11:13:51 -0700672 for t in pool:
673 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700674 appCheck = appCheck and t.result
675 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
676 onpass="App Ids seem to be correct",
677 onfail="Something is wrong with app Ids" )
678 if appCheck != main.TRUE:
679 main.log.warn( main.CLIs[0].apps() )
680 main.log.warn( main.CLIs[0].appIDs() )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700681
682 # Waiting for reative flows to be cleared.
kelvin-onlab06ade552015-03-31 18:09:27 -0700683 time.sleep( 10 )
684 case41Result = installResult and uninstallResult and ping_result
685 utilities.assert_equals( expect=main.TRUE, actual=case41Result,
Hari Krishnab35c6d02015-03-18 11:13:51 -0700686 onpass="Reactive Mode Pingall test PASS",
687 onfail="Reactive Mode Pingall test FAIL" )
688
689 def CASE42( self, main ):
690 """
691 Verify Reactive forwarding (Spine Topology)
692 """
693 import re
694 import copy
695 import time
696 main.log.report( "Verify Reactive forwarding (Spine Topology)" )
697 main.log.report( "______________________________________________" )
698 main.case( "Enable Reactive forwarding and Verify ping all" )
699 main.step( "Enable Reactive forwarding" )
700 installResult = main.TRUE
kelvin-onlab06ade552015-03-31 18:09:27 -0700701 # Activate fwd app
702 appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" )
703
704 appCheck = main.TRUE
Hari Krishnab35c6d02015-03-18 11:13:51 -0700705 pool = []
Hari Krishnab35c6d02015-03-18 11:13:51 -0700706 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700707 t = main.Thread( target=cli.appToIDCheck,
708 name="appToIDCheck-" + str( i ),
709 args=[] )
710 pool.append( t )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700711 t.start()
Hari Krishnab35c6d02015-03-18 11:13:51 -0700712 for t in pool:
713 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700714 appCheck = appCheck and t.result
715 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
716 onpass="App Ids seem to be correct",
717 onfail="Something is wrong with app Ids" )
718 if appCheck != main.TRUE:
719 main.log.warn( main.CLIs[0].apps() )
720 main.log.warn( main.CLIs[0].appIDs() )
721
722 time.sleep( 10 )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700723
724 main.step( "Verify Pingall" )
725 ping_result = main.FALSE
726 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -0700727 ping_result = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
Hari Krishnab35c6d02015-03-18 11:13:51 -0700728 time2 = time.time()
729 timeDiff = round( ( time2 - time1 ), 2 )
730 main.log.report(
731 "Time taken for Ping All: " +
732 str( timeDiff ) +
733 " seconds" )
734
735 if ping_result == main.TRUE:
736 main.log.report( "Pingall Test in Reactive mode successful" )
737 else:
738 main.log.report( "Pingall Test in Reactive mode failed" )
739
740 main.step( "Disable Reactive forwarding" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700741
742 main.log.info( "Uninstall reactive forwarding app" )
743 appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700744 pool = []
Hari Krishnab35c6d02015-03-18 11:13:51 -0700745 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700746 t = main.Thread( target=cli.appToIDCheck,
747 name="appToIDCheck-" + str( i ),
748 args=[] )
749 pool.append( t )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700750 t.start()
kelvin-onlab06ade552015-03-31 18:09:27 -0700751
Hari Krishnab35c6d02015-03-18 11:13:51 -0700752 for t in pool:
753 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700754 appCheck = appCheck and t.result
755 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
756 onpass="App Ids seem to be correct",
757 onfail="Something is wrong with app Ids" )
758 if appCheck != main.TRUE:
759 main.log.warn( main.CLIs[0].apps() )
760 main.log.warn( main.CLIs[0].appIDs() )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700761
762 # Waiting for reative flows to be cleared.
kelvin-onlab06ade552015-03-31 18:09:27 -0700763 time.sleep( 10 )
764 case42Result = installResult and uninstallResult and ping_result
765 utilities.assert_equals( expect=main.TRUE, actual=case42Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800766 onpass="Reactive Mode Pingall test PASS",
767 onfail="Reactive Mode Pingall test FAIL" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700768
kelvin-onlab8a832582015-01-16 17:06:11 -0800769 def CASE5( self, main ):
770 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800771 Compare current ONOS topology with reference data
kelvin-onlab8a832582015-01-16 17:06:11 -0800772 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800773 import re
kelvin-onlab54400a92015-02-26 18:05:51 -0800774
Hari Krishna22c3d412015-02-17 16:48:12 -0800775 devicesDPIDTemp = []
776 hostMACsTemp = []
777 deviceLinksTemp = []
778 deviceActiveLinksCountTemp = []
779 devicePortsEnabledCountTemp = []
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800780
kelvin-onlab8a832582015-01-16 17:06:11 -0800781 main.log.report(
782 "Compare ONOS topology with reference data in Stores" )
783 main.log.report( "__________________________________________________" )
784 main.case( "Compare ONOS topology with reference data" )
785
786 main.step( "Compare current Device ports enabled with reference" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800787 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800788 for i in xrange( 1,(main.numMNswitches + 1), int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800789 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800790 for cli in main.CLIs:
kelvin-onlabc44f0192015-04-02 22:08:41 -0700791 if i >= main.numMNswitches + 1:
792 break
kelvin-onlab54400a92015-02-26 18:05:51 -0800793 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800794 t = main.Thread(target = cli.getDevicePortsEnabledCount,
795 threadID = main.threadID,
796 name = "getDevicePortsEnabledCount",
797 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800798 t.start()
799 pool.append(t)
800 i = i + 1
801 main.threadID = main.threadID + 1
802 for thread in pool:
803 thread.join()
804 portResult = thread.result
805 portTemp = re.split( r'\t+', portResult )
806 portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
807 devicePortsEnabledCountTemp.append( portCount )
808 print "Device Enabled Port Counts Stored: \n", str( main.devicePortsEnabledCount )
809 time2 = time.time()
810 main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800811 main.log.info (
812 "Device Enabled ports EXPECTED: %s" %
813 str( main.devicePortsEnabledCount ) )
814 main.log.info (
815 "Device Enabled ports ACTUAL: %s" %
816 str( devicePortsEnabledCountTemp ) )
kelvin-onlab54400a92015-02-26 18:05:51 -0800817
Hari Krishna22c3d412015-02-17 16:48:12 -0800818 if ( cmp( main.devicePortsEnabledCount,
819 devicePortsEnabledCountTemp ) == 0 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800820 stepResult1 = main.TRUE
821 else:
822 stepResult1 = main.FALSE
823
kelvin-onlab8a832582015-01-16 17:06:11 -0800824 main.step( "Compare Device active links with reference" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800825 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800826 for i in xrange( 1, ( main.numMNswitches + 1) , int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800827 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800828 for cli in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -0800829 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800830 t = main.Thread(target = cli.getDeviceLinksActiveCount,
831 threadID = main.threadID,
832 name = "getDevicePortsEnabledCount",
833 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800834 t.start()
835 pool.append(t)
836 i = i + 1
837 main.threadID = main.threadID + 1
838 for thread in pool:
839 thread.join()
840 linkCountResult = thread.result
841 linkCountTemp = re.split( r'\t+', linkCountResult )
842 linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
843 deviceActiveLinksCountTemp.append( linkCount )
844 print "Device Active Links Count Stored: \n", str( main.deviceActiveLinksCount )
845 time2 = time.time()
846 main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800847 main.log.info (
848 "Device Active links EXPECTED: %s" %
849 str( main.deviceActiveLinksCount ) )
850 main.log.info (
851 "Device Active links ACTUAL: %s" % str( deviceActiveLinksCountTemp ) )
852 if ( cmp( main.deviceActiveLinksCount, deviceActiveLinksCountTemp ) == 0 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800853 stepResult2 = main.TRUE
854 else:
855 stepResult2 = main.FALSE
856
kelvin-onlab8a832582015-01-16 17:06:11 -0800857 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800858 place holder for comparing devices, hosts, paths and intents if required.
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800859 Links and ports data would be incorrect with out devices anyways.
kelvin-onlab8a832582015-01-16 17:06:11 -0800860 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800861 case5Result = ( stepResult1 and stepResult2 )
862 utilities.assert_equals( expect=main.TRUE, actual=case5Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800863 onpass="Compare Topology test PASS",
864 onfail="Compare Topology test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800865
kelvin-onlab65a72d22015-03-26 13:46:32 -0700866 def CASE60( self ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800867 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700868 Install 300 host intents and verify ping all (Att Topology)
kelvin-onlab8a832582015-01-16 17:06:11 -0800869 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700870 main.log.report( "Add 300 host intents and verify pingall (Att Topology)" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800871 main.log.report( "_______________________________________" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800872 import itertools
Hari Krishnaef1bd4e2015-03-12 16:55:30 -0700873 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800874 main.case( "Install 300 host intents" )
875 main.step( "Add host Intents" )
876 intentResult = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800877 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800878
kelvin-onlab54400a92015-02-26 18:05:51 -0800879 intentIdList = []
880 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800881 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800882 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800883 for cli in main.CLIs:
884 if i >= len( hostCombos ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800885 break
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800886 t = main.Thread( target=cli.addHostIntent,
887 threadID=main.threadID,
kelvin-onlab54400a92015-02-26 18:05:51 -0800888 name="addHostIntent",
889 args=[hostCombos[i][0],hostCombos[i][1]])
890 pool.append(t)
891 t.start()
892 i = i + 1
893 main.threadID = main.threadID + 1
894 for thread in pool:
895 thread.join()
896 intentIdList.append(thread.result)
897 time2 = time.time()
kelvin-onlabadfc8db2015-03-24 15:52:48 -0700898 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
899
kelvin-onlab54400a92015-02-26 18:05:51 -0800900 intentResult = main.TRUE
901 intentsJson = main.ONOScli2.intents()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800902 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
kelvin-onlab54400a92015-02-26 18:05:51 -0800903 intentsJson = intentsJson)
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800904 print getIntentStateResult
Hari Krishnab35c6d02015-03-18 11:13:51 -0700905 # Takes awhile for all the onos to get the intents
Hari Krishnaef1bd4e2015-03-12 16:55:30 -0700906 time.sleep(30)
kelvin-onlab8a832582015-01-16 17:06:11 -0800907 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800908 pingResult = main.FALSE
909 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -0700910 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800911 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800912 timeDiff = round( ( time2 - time1 ), 2 )
913 main.log.report(
914 "Time taken for Ping All: " +
915 str( timeDiff ) +
916 " seconds" )
917 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
918 onpass="PING ALL PASS",
919 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800920
kelvin-onlab65a72d22015-03-26 13:46:32 -0700921 case60Result = ( intentResult and pingResult )
kelvin-onlab54400a92015-02-26 18:05:51 -0800922
kelvin-onlab8a832582015-01-16 17:06:11 -0800923 utilities.assert_equals(
924 expect=main.TRUE,
kelvin-onlab65a72d22015-03-26 13:46:32 -0700925 actual=case60Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800926 onpass="Install 300 Host Intents and Ping All test PASS",
927 onfail="Install 300 Host Intents and Ping All test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800928
kelvin-onlab65a72d22015-03-26 13:46:32 -0700929 def CASE61( self ):
930 """
931 Install 600 host intents and verify ping all for Chordal Topology
932 """
933 main.log.report( "Add 600 host intents and verify pingall (Chordal Topo)" )
934 main.log.report( "_______________________________________" )
935 import itertools
936
937 main.case( "Install 600 host intents" )
938 main.step( "Add host Intents" )
939 intentResult = main.TRUE
940 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
941
942 intentIdList = []
943 time1 = time.time()
944
945 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
946 pool = []
947 for cli in main.CLIs:
948 if i >= len( hostCombos ):
949 break
950 t = main.Thread( target=cli.addHostIntent,
951 threadID=main.threadID,
952 name="addHostIntent",
953 args=[hostCombos[i][0],hostCombos[i][1]])
954 pool.append(t)
955 t.start()
956 i = i + 1
957 main.threadID = main.threadID + 1
958 for thread in pool:
959 thread.join()
960 intentIdList.append(thread.result)
961 time2 = time.time()
962 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
963 intentResult = main.TRUE
964 intentsJson = main.ONOScli2.intents()
965 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
966 intentsJson = intentsJson)
967 print getIntentStateResult
968
969 main.step( "Verify Ping across all hosts" )
970 pingResult = main.FALSE
971 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -0700972 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin-onlab65a72d22015-03-26 13:46:32 -0700973 time2 = time.time()
974 timeDiff = round( ( time2 - time1 ), 2 )
975 main.log.report(
976 "Time taken for Ping All: " +
977 str( timeDiff ) +
978 " seconds" )
979 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
980 onpass="PING ALL PASS",
981 onfail="PING ALL FAIL" )
982
983 case14Result = ( intentResult and pingResult )
984
985 utilities.assert_equals(
986 expect=main.TRUE,
987 actual=case14Result,
988 onpass="Install 300 Host Intents and Ping All test PASS",
989 onfail="Install 300 Host Intents and Ping All test FAIL" )
990
991 def CASE62( self ):
992 """
993 Install 2278 host intents and verify ping all for Spine Topology
994 """
995 main.log.report( "Add 2278 host intents and verify pingall (Spine Topo)" )
996 main.log.report( "_______________________________________" )
997 import itertools
998
999 main.case( "Install 2278 host intents" )
1000 main.step( "Add host Intents" )
1001 intentResult = main.TRUE
1002 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
1003 main.pingTimeout = 300
1004 intentIdList = []
1005 time1 = time.time()
1006 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
1007 pool = []
1008 for cli in main.CLIs:
1009 if i >= len( hostCombos ):
1010 break
1011 t = main.Thread( target=cli.addHostIntent,
1012 threadID=main.threadID,
1013 name="addHostIntent",
1014 args=[hostCombos[i][0],hostCombos[i][1]])
1015 pool.append(t)
1016 t.start()
1017 i = i + 1
1018 main.threadID = main.threadID + 1
1019 for thread in pool:
1020 thread.join()
1021 intentIdList.append(thread.result)
1022 time2 = time.time()
1023 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
1024 intentResult = main.TRUE
1025 intentsJson = main.ONOScli2.intents()
1026 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1027 intentsJson = intentsJson)
1028 print getIntentStateResult
1029
1030 main.step( "Verify Ping across all hosts" )
1031 pingResult = main.FALSE
1032 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001033 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin-onlab65a72d22015-03-26 13:46:32 -07001034 time2 = time.time()
1035 timeDiff = round( ( time2 - time1 ), 2 )
1036 main.log.report(
1037 "Time taken for Ping All: " +
1038 str( timeDiff ) +
1039 " seconds" )
1040 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1041 onpass="PING ALL PASS",
1042 onfail="PING ALL FAIL" )
1043
1044 case15Result = ( intentResult and pingResult )
1045
1046 utilities.assert_equals(
1047 expect=main.TRUE,
1048 actual=case15Result,
1049 onpass="Install 2278 Host Intents and Ping All test PASS",
1050 onfail="Install 2278 Host Intents and Ping All test FAIL" )
1051
kelvin-onlab8a832582015-01-16 17:06:11 -08001052 def CASE70( self, main ):
1053 """
Hari Krishnab35c6d02015-03-18 11:13:51 -07001054 Randomly bring some core links down and verify ping all ( Host Intents-Att Topo)
kelvin-onlab8a832582015-01-16 17:06:11 -08001055 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001056 import random
Hari Krishna22c3d412015-02-17 16:48:12 -08001057 main.randomLink1 = []
1058 main.randomLink2 = []
1059 main.randomLink3 = []
kelvin-onlab65a72d22015-03-26 13:46:32 -07001060 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1061 link1End2 = main.params[ 'ATTCORELINKS' ][ 'linkS3b' ].split( ',' )
1062 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1063 link2End2 = main.params[ 'ATTCORELINKS' ][ 'linkS14b' ].split( ',' )
1064 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
1065 link3End2 = main.params[ 'ATTCORELINKS' ][ 'linkS18b' ].split( ',' )
1066 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001067 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001068
Hari Krishnab35c6d02015-03-18 11:13:51 -07001069 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Att Topo)" )
1070 main.log.report( "___________________________________________________________________________" )
Hari Krishnad97213e2015-01-24 19:30:14 -08001071 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
1072 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001073 if ( int( switchLinksToToggle ) ==
1074 0 or int( switchLinksToToggle ) > 5 ):
Hari Krishna46997e02015-01-27 11:23:07 -08001075 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 -07001076 #main.cleanup()
1077 #main.exit()
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001078 else:
Hari Krishnad97213e2015-01-24 19:30:14 -08001079 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 -08001080
kelvin-onlab8a832582015-01-16 17:06:11 -08001081 main.step( "Cut links on Core devices using user provided range" )
Hari Krishna22c3d412015-02-17 16:48:12 -08001082 main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
1083 main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
1084 main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001085 for i in range( int( switchLinksToToggle ) ):
1086 main.Mininet1.link(
1087 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001088 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001089 OPTION="down" )
1090 main.Mininet1.link(
1091 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001092 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001093 OPTION="down" )
1094 main.Mininet1.link(
1095 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001096 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001097 OPTION="down" )
1098 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001099
1100 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001101 linkDown = main.ONOSbench.checkStatus(
Hari Krishna22c3d412015-02-17 16:48:12 -08001102 topology_output, main.numMNswitches, str(
1103 int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001104 utilities.assert_equals(
1105 expect=main.TRUE,
1106 actual=linkDown,
1107 onpass="Link Down discovered properly",
1108 onfail="Link down was not discovered in " +
1109 str( link_sleep ) +
1110 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001111
kelvin-onlab8a832582015-01-16 17:06:11 -08001112 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001113 pingResultLinkDown = main.FALSE
1114 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001115 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001116 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001117 timeDiff = round( ( time2 - time1 ), 2 )
1118 main.log.report(
1119 "Time taken for Ping All: " +
1120 str( timeDiff ) +
1121 " seconds" )
1122 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1123 onpass="PING ALL PASS",
1124 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001125
Hari Krishna22c3d412015-02-17 16:48:12 -08001126 caseResult70 = linkDown and pingResultLinkDown
1127 utilities.assert_equals( expect=main.TRUE, actual=caseResult70,
kelvin-onlab8a832582015-01-16 17:06:11 -08001128 onpass="Random Link cut Test PASS",
1129 onfail="Random Link cut Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001130
kelvin-onlab8a832582015-01-16 17:06:11 -08001131 def CASE80( self, main ):
1132 """
Hari Krishnab35c6d02015-03-18 11:13:51 -07001133 Bring the core links up that are down and verify ping all ( Host Intents-Att Topo )
kelvin-onlab8a832582015-01-16 17:06:11 -08001134 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001135 import random
kelvin-onlab65a72d22015-03-26 13:46:32 -07001136 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1137 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1138 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001139 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001140 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001141
kelvin-onlab8a832582015-01-16 17:06:11 -08001142 main.log.report(
Hari Krishnab35c6d02015-03-18 11:13:51 -07001143 "Bring the core links up that are down and verify ping all (Host Intents-Att Topo" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001144 main.log.report(
1145 "__________________________________________________________________" )
1146 main.case(
1147 "Host intents - Bring the core links up that are down and verify ping all" )
1148 main.step( "Bring randomly cut links on Core devices up" )
1149 for i in range( int( switchLinksToToggle ) ):
1150 main.Mininet1.link(
1151 END1=link1End1,
kelvin-onlab54400a92015-02-26 18:05:51 -08001152 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001153 OPTION="up" )
1154 main.Mininet1.link(
1155 END1=link2End1,
kelvin-onlab54400a92015-02-26 18:05:51 -08001156 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001157 OPTION="up" )
1158 main.Mininet1.link(
1159 END1=link3End1,
kelvin-onlab54400a92015-02-26 18:05:51 -08001160 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001161 OPTION="up" )
1162 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001163
1164 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001165 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -08001166 topology_output,
Hari Krishna22c3d412015-02-17 16:48:12 -08001167 main.numMNswitches,
1168 str( main.numMNlinks ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001169 utilities.assert_equals(
1170 expect=main.TRUE,
1171 actual=linkUp,
1172 onpass="Link up discovered properly",
1173 onfail="Link up was not discovered in " +
1174 str( link_sleep ) +
1175 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001176
kelvin-onlab8a832582015-01-16 17:06:11 -08001177 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001178 pingResultLinkUp = main.FALSE
1179 time1 = time.time()
kelvin-onlabc44f0192015-04-02 22:08:41 -07001180 pingResultLinkUp = main.Mininet1.pingall( timeout=main.pingTimeout,shortCircuit=True )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001181 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001182 timeDiff = round( ( time2 - time1 ), 2 )
1183 main.log.report(
1184 "Time taken for Ping All: " +
1185 str( timeDiff ) +
1186 " seconds" )
1187 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1188 onpass="PING ALL PASS",
1189 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001190
Hari Krishna22c3d412015-02-17 16:48:12 -08001191 caseResult80 = linkUp and pingResultLinkUp
1192 utilities.assert_equals( expect=main.TRUE, actual=caseResult80,
kelvin-onlab8a832582015-01-16 17:06:11 -08001193 onpass="Link Up Test PASS",
1194 onfail="Link Up Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001195
kelvin-onlab8a832582015-01-16 17:06:11 -08001196 def CASE71( self, main ):
1197 """
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001198 Randomly bring some core links down and verify ping all ( Point Intents-Att Topo)
kelvin-onlab8a832582015-01-16 17:06:11 -08001199 """
kelvin8ec71442015-01-15 16:57:00 -08001200 import random
Hari Krishna22c3d412015-02-17 16:48:12 -08001201 main.randomLink1 = []
1202 main.randomLink2 = []
1203 main.randomLink3 = []
kelvin-onlab65a72d22015-03-26 13:46:32 -07001204 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1205 link1End2 = main.params[ 'ATTCORELINKS' ][ 'linkS3b' ].split( ',' )
1206 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1207 link2End2 = main.params[ 'ATTCORELINKS' ][ 'linkS14b' ].split( ',' )
1208 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
1209 link3End2 = main.params[ 'ATTCORELINKS' ][ 'linkS18b' ].split( ',' )
1210 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001211 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin8ec71442015-01-15 16:57:00 -08001212
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001213 main.log.report( "Randomly bring some core links down and verify ping all (Point Intents-Att Topo)" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001214 main.log.report( "___________________________________________________________________________" )
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001215 main.case( "Point intents - Randomly bring some core links down and verify ping all" )
Hari Krishnad97213e2015-01-24 19:30:14 -08001216 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001217 if ( int( switchLinksToToggle ) ==
1218 0 or int( switchLinksToToggle ) > 5 ):
kelvin-onlab65a72d22015-03-26 13:46:32 -07001219 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 -07001220 #main.cleanup()
1221 #main.exit()
kelvin8ec71442015-01-15 16:57:00 -08001222 else:
kelvin-onlab65a72d22015-03-26 13:46:32 -07001223 main.log.info( "User provided Core switch links range to toggle is correct, proceeding to run the test" )
kelvin8ec71442015-01-15 16:57:00 -08001224
kelvin-onlab8a832582015-01-16 17:06:11 -08001225 main.step( "Cut links on Core devices using user provided range" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001226 main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
1227 main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
1228 main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001229 for i in range( int( switchLinksToToggle ) ):
1230 main.Mininet1.link(
1231 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001232 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001233 OPTION="down" )
1234 main.Mininet1.link(
1235 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001236 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001237 OPTION="down" )
1238 main.Mininet1.link(
1239 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001240 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001241 OPTION="down" )
1242 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -08001243
1244 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001245 linkDown = main.ONOSbench.checkStatus(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001246 topology_output, main.numMNswitches, str(
1247 int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001248 utilities.assert_equals(
1249 expect=main.TRUE,
1250 actual=linkDown,
1251 onpass="Link Down discovered properly",
1252 onfail="Link down was not discovered in " +
1253 str( link_sleep ) +
1254 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -08001255
kelvin-onlab8a832582015-01-16 17:06:11 -08001256 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -08001257 pingResultLinkDown = main.FALSE
1258 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001259 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin8ec71442015-01-15 16:57:00 -08001260 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001261 timeDiff = round( ( time2 - time1 ), 2 )
1262 main.log.report(
1263 "Time taken for Ping All: " +
1264 str( timeDiff ) +
1265 " seconds" )
1266 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1267 onpass="PING ALL PASS",
1268 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001269
kelvin-onlab65a72d22015-03-26 13:46:32 -07001270 caseResult71 = linkDown and pingResultLinkDown
1271 utilities.assert_equals( expect=main.TRUE, actual=caseResult71,
kelvin-onlab8a832582015-01-16 17:06:11 -08001272 onpass="Random Link cut Test PASS",
1273 onfail="Random Link cut Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001274
kelvin-onlab8a832582015-01-16 17:06:11 -08001275 def CASE81( self, main ):
1276 """
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001277 Bring the core links up that are down and verify ping all ( Point Intents-Att Topo )
kelvin-onlab8a832582015-01-16 17:06:11 -08001278 """
kelvin8ec71442015-01-15 16:57:00 -08001279 import random
kelvin-onlab65a72d22015-03-26 13:46:32 -07001280 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1281 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1282 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001283 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001284 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
kelvin8ec71442015-01-15 16:57:00 -08001285
kelvin-onlab8a832582015-01-16 17:06:11 -08001286 main.log.report(
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001287 "Bring the core links up that are down and verify ping all ( Point Intents-Att Topo" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001288 main.log.report(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001289 "__________________________________________________________________" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001290 main.case(
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001291 "Point intents - Bring the core links up that are down and verify ping all" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001292 main.step( "Bring randomly cut links on Core devices up" )
1293 for i in range( int( switchLinksToToggle ) ):
1294 main.Mininet1.link(
1295 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001296 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001297 OPTION="up" )
1298 main.Mininet1.link(
1299 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001300 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001301 OPTION="up" )
1302 main.Mininet1.link(
1303 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001304 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001305 OPTION="up" )
1306 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -08001307
1308 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001309 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -08001310 topology_output,
Hari Krishna22c3d412015-02-17 16:48:12 -08001311 main.numMNswitches,
1312 str( main.numMNlinks ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001313 utilities.assert_equals(
1314 expect=main.TRUE,
1315 actual=linkUp,
1316 onpass="Link up discovered properly",
1317 onfail="Link up was not discovered in " +
1318 str( link_sleep ) +
1319 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -08001320
kelvin-onlab8a832582015-01-16 17:06:11 -08001321 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -08001322 pingResultLinkUp = main.FALSE
1323 time1 = time.time()
kelvin-onlabc44f0192015-04-02 22:08:41 -07001324 pingResultLinkUp = main.Mininet1.pingall(timeout = main.pingTimeout, shortCircuit = True )
kelvin8ec71442015-01-15 16:57:00 -08001325 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001326 timeDiff = round( ( time2 - time1 ), 2 )
1327 main.log.report(
1328 "Time taken for Ping All: " +
1329 str( timeDiff ) +
1330 " seconds" )
1331 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1332 onpass="PING ALL PASS",
1333 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001334
Hari Krishna22c3d412015-02-17 16:48:12 -08001335 caseResult81 = linkUp and pingResultLinkUp
1336 utilities.assert_equals( expect=main.TRUE, actual=caseResult81,
kelvin-onlab8a832582015-01-16 17:06:11 -08001337 onpass="Link Up Test PASS",
1338 onfail="Link Up Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001339
Hari Krishnab35c6d02015-03-18 11:13:51 -07001340 def CASE72( self, main ):
1341 """
1342 Randomly bring some links down and verify ping all ( Host Intents-Chordal Topo)
1343 """
1344 import random
1345 import itertools
1346 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1347
1348 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Chordal Topo)" )
1349 main.log.report( "___________________________________________________________________________" )
1350 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
1351 switches = []
1352 switchesComb = []
1353 for i in range( main.numMNswitches ):
1354 switches.append('s%d'%(i+1))
1355 switchesLinksComb = list(itertools.combinations(switches,2))
1356 main.randomLinks = random.sample(switchesLinksComb, 5 )
1357 print main.randomLinks
1358 main.step( "Cut links on random devices" )
1359
1360 for switch in main.randomLinks:
1361 main.Mininet1.link(
1362 END1=switch[0],
1363 END2=switch[1],
1364 OPTION="down")
1365 time.sleep( link_sleep )
1366
1367 topology_output = main.ONOScli2.topology()
1368 linkDown = main.ONOSbench.checkStatus(
1369 topology_output, main.numMNswitches, str(
1370 int( main.numMNlinks ) - 5 * 2 ) )
1371 utilities.assert_equals(
1372 expect=main.TRUE,
1373 actual=linkDown,
1374 onpass="Link Down discovered properly",
1375 onfail="Link down was not discovered in " +
1376 str( link_sleep ) +
1377 " seconds" )
1378
1379 main.step( "Verify Ping across all hosts" )
1380 pingResultLinkDown = main.FALSE
1381 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001382 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001383 time2 = time.time()
1384 timeDiff = round( ( time2 - time1 ), 2 )
1385 main.log.report(
1386 "Time taken for Ping All: " +
1387 str( timeDiff ) +
1388 " seconds" )
1389 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1390 onpass="PING ALL PASS",
1391 onfail="PING ALL FAIL" )
1392
kelvin-onlab65a72d22015-03-26 13:46:32 -07001393 caseResult71 = pingResultLinkDown
1394 utilities.assert_equals( expect=main.TRUE, actual=caseResult71,
Hari Krishnab35c6d02015-03-18 11:13:51 -07001395 onpass="Random Link cut Test PASS",
1396 onfail="Random Link cut Test FAIL" )
1397
1398 def CASE82( self, main ):
1399 """
1400 Bring the core links up that are down and verify ping all ( Host Intents Chordal Topo )
1401 """
1402 import random
1403 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1404
1405 main.log.report(
1406 "Bring the core links up that are down and verify ping all (Host Intents-Chordal Topo" )
1407 main.log.report(
1408 "__________________________________________________________________" )
1409 main.case(
1410 "Host intents - Bring the core links up that are down and verify ping all" )
1411 main.step( "Bring randomly cut links on devices up" )
1412
1413 for switch in main.randomLinks:
1414 main.Mininet1.link(
1415 END1=switch[0],
1416 END2=switch[1],
1417 OPTION="up")
1418
1419 time.sleep( link_sleep )
1420
1421 topology_output = main.ONOScli2.topology()
1422 linkUp = main.ONOSbench.checkStatus(
1423 topology_output,
1424 main.numMNswitches,
1425 str( main.numMNlinks ) )
1426 utilities.assert_equals(
1427 expect=main.TRUE,
1428 actual=linkUp,
1429 onpass="Link up discovered properly",
1430 onfail="Link up was not discovered in " +
1431 str( link_sleep ) +
1432 " seconds" )
1433
1434 main.step( "Verify Ping across all hosts" )
1435 pingResultLinkUp = main.FALSE
1436 time1 = time.time()
kelvin-onlabc44f0192015-04-02 22:08:41 -07001437 pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001438 time2 = time.time()
1439 timeDiff = round( ( time2 - time1 ), 2 )
1440 main.log.report(
1441 "Time taken for Ping All: " +
1442 str( timeDiff ) +
1443 " seconds" )
1444 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1445 onpass="PING ALL PASS",
1446 onfail="PING ALL FAIL" )
1447
1448 caseResult82 = linkUp and pingResultLinkUp
1449 utilities.assert_equals( expect=main.TRUE, actual=caseResult82,
1450 onpass="Link Up Test PASS",
1451 onfail="Link Up Test FAIL" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001452
Hari Krishnab35c6d02015-03-18 11:13:51 -07001453 def CASE73( self, main ):
1454 """
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001455 Randomly bring some links down and verify ping all ( Point Intents-Chordal Topo)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001456 """
1457 import random
kelvin-onlab65a72d22015-03-26 13:46:32 -07001458 import itertools
Hari Krishnab35c6d02015-03-18 11:13:51 -07001459 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001460
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001461 main.log.report( "Randomly bring some core links down and verify ping all ( Point Intents-Chordal Topo)" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001462 main.log.report( "___________________________________________________________________________" )
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001463 main.case( "Point intents - Randomly bring some core links down and verify ping all" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001464 switches = []
1465 switchesComb = []
1466 for i in range( main.numMNswitches ):
1467 switches.append('s%d'%(i+1))
1468 switchesLinksComb = list(itertools.combinations(switches,2))
1469 main.randomLinks = random.sample(switchesLinksComb, 5 )
1470 print main.randomLinks
1471 main.step( "Cut links on random devices" )
1472
1473 for switch in main.randomLinks:
Hari Krishnab35c6d02015-03-18 11:13:51 -07001474 main.Mininet1.link(
1475 END1=switch[0],
1476 END2=switch[1],
kelvin-onlab65a72d22015-03-26 13:46:32 -07001477 OPTION="down")
Hari Krishnab35c6d02015-03-18 11:13:51 -07001478 time.sleep( link_sleep )
1479
1480 topology_output = main.ONOScli2.topology()
1481 linkDown = main.ONOSbench.checkStatus(
1482 topology_output, main.numMNswitches, str(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001483 int( main.numMNlinks ) - 5 * 2 ) )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001484 utilities.assert_equals(
1485 expect=main.TRUE,
1486 actual=linkDown,
1487 onpass="Link Down discovered properly",
1488 onfail="Link down was not discovered in " +
1489 str( link_sleep ) +
1490 " seconds" )
1491
1492 main.step( "Verify Ping across all hosts" )
1493 pingResultLinkDown = main.FALSE
1494 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001495 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001496 time2 = time.time()
1497 timeDiff = round( ( time2 - time1 ), 2 )
1498 main.log.report(
1499 "Time taken for Ping All: " +
1500 str( timeDiff ) +
1501 " seconds" )
1502 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1503 onpass="PING ALL PASS",
1504 onfail="PING ALL FAIL" )
1505
kelvin-onlab65a72d22015-03-26 13:46:32 -07001506 caseResult73 = pingResultLinkDown
Hari Krishnab35c6d02015-03-18 11:13:51 -07001507 utilities.assert_equals( expect=main.TRUE, actual=caseResult73,
1508 onpass="Random Link cut Test PASS",
1509 onfail="Random Link cut Test FAIL" )
1510
1511 def CASE83( self, main ):
1512 """
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001513 Bring the core links up that are down and verify ping all ( Point Intents Chordal Topo )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001514 """
1515 import random
Hari Krishnab35c6d02015-03-18 11:13:51 -07001516 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001517
Hari Krishnab35c6d02015-03-18 11:13:51 -07001518 main.log.report(
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001519 "Bring the core links up that are down and verify ping all ( Point Intents-Chordal Topo" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001520 main.log.report(
1521 "__________________________________________________________________" )
1522 main.case(
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001523 "Point intents - Bring the core links up that are down and verify ping all" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001524 main.step( "Bring randomly cut links on devices up" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001525
kelvin-onlab65a72d22015-03-26 13:46:32 -07001526 for switch in main.randomLinks:
Hari Krishnab35c6d02015-03-18 11:13:51 -07001527 main.Mininet1.link(
1528 END1=switch[0],
1529 END2=switch[1],
1530 OPTION="up")
kelvin-onlab65a72d22015-03-26 13:46:32 -07001531
Hari Krishnab35c6d02015-03-18 11:13:51 -07001532 time.sleep( link_sleep )
1533
1534 topology_output = main.ONOScli2.topology()
1535 linkUp = main.ONOSbench.checkStatus(
1536 topology_output,
1537 main.numMNswitches,
1538 str( main.numMNlinks ) )
1539 utilities.assert_equals(
1540 expect=main.TRUE,
1541 actual=linkUp,
1542 onpass="Link up discovered properly",
1543 onfail="Link up was not discovered in " +
1544 str( link_sleep ) +
1545 " seconds" )
1546
1547 main.step( "Verify Ping across all hosts" )
1548 pingResultLinkUp = main.FALSE
1549 time1 = time.time()
kelvin-onlabc44f0192015-04-02 22:08:41 -07001550 pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001551 time2 = time.time()
1552 timeDiff = round( ( time2 - time1 ), 2 )
1553 main.log.report(
1554 "Time taken for Ping All: " +
1555 str( timeDiff ) +
1556 " seconds" )
1557 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1558 onpass="PING ALL PASS",
1559 onfail="PING ALL FAIL" )
1560
1561 caseResult83 = linkUp and pingResultLinkUp
1562 utilities.assert_equals( expect=main.TRUE, actual=caseResult83,
1563 onpass="Link Up Test PASS",
1564 onfail="Link Up Test FAIL" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001565
1566 def CASE74( self, main ):
1567 """
1568 Randomly bring some core links down and verify ping all ( Host Intents-Spine Topo)
1569 """
1570 import random
1571 main.randomLink1 = []
1572 main.randomLink2 = []
1573 main.randomLink3 = []
1574 main.randomLink4 = []
1575 link1End1 = main.params[ 'SPINECORELINKS' ][ 'linkS9' ]
1576 link1End2top = main.params[ 'SPINECORELINKS' ][ 'linkS9top' ].split( ',' )
1577 link1End2bot = main.params[ 'SPINECORELINKS' ][ 'linkS9bot' ].split( ',' )
1578 link2End1 = main.params[ 'SPINECORELINKS' ][ 'linkS10' ]
1579 link2End2top = main.params[ 'SPINECORELINKS' ][ 'linkS10top' ].split( ',' )
1580 link2End2bot = main.params[ 'SPINECORELINKS' ][ 'linkS10bot' ].split( ',' )
1581 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1582 main.pingTimeout = 400
1583
1584 main.log.report( "Bring some core links down and verify ping all (Host Intents-Spine Topo)" )
1585 main.log.report( "___________________________________________________________________________" )
1586
1587 linkIndex = range(4)
1588 linkIndexS9 = random.sample(linkIndex,1)[0]
1589 linkIndex.remove(linkIndexS9)
1590 linkIndexS10 = random.sample(linkIndex,1)[0]
1591 main.randomLink1 = link1End2top[linkIndexS9]
1592 main.randomLink2 = link2End2top[linkIndexS10]
1593 main.randomLink3 = random.sample(link1End2bot,1)[0]
1594 main.randomLink4 = random.sample(link2End2bot,1)[0]
kelvin-onlab77d6c302015-03-31 11:33:32 -07001595 # main.Mininet1.link( END1=link1End1, END2=main.randomLink1, OPTION="down" )
1596 # main.Mininet1.link( END1=link2End1, END2=main.randomLink2, OPTION="down" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001597 main.Mininet1.link( END1=link1End1, END2=main.randomLink3, OPTION="down" )
1598 main.Mininet1.link( END1=link2End1, END2=main.randomLink4, OPTION="down" )
kelvin-onlabd878fc22015-03-27 13:33:41 -07001599
kelvin-onlab65a72d22015-03-26 13:46:32 -07001600 time.sleep( link_sleep )
1601
1602 topology_output = main.ONOScli2.topology()
1603 linkDown = main.ONOSbench.checkStatus(
1604 topology_output, main.numMNswitches, str(
1605 int( main.numMNlinks ) - 8 ))
1606 utilities.assert_equals(
1607 expect=main.TRUE,
1608 actual=linkDown,
1609 onpass="Link Down discovered properly",
1610 onfail="Link down was not discovered in " +
1611 str( link_sleep ) +
1612 " seconds" )
1613
1614 main.step( "Verify Ping across all hosts" )
1615 pingResultLinkDown = main.FALSE
1616 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001617 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin-onlab65a72d22015-03-26 13:46:32 -07001618 time2 = time.time()
1619 timeDiff = round( ( time2 - time1 ), 2 )
1620 main.log.report(
1621 "Time taken for Ping All: " +
1622 str( timeDiff ) +
1623 " seconds" )
1624 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1625 onpass="PING ALL PASS",
1626 onfail="PING ALL FAIL" )
1627
1628 caseResult74 = linkDown and pingResultLinkDown
1629 utilities.assert_equals( expect=main.TRUE, actual=caseResult74,
1630 onpass="Random Link cut Test PASS",
1631 onfail="Random Link cut Test FAIL" )
1632
1633 def CASE84( self, main ):
1634 """
1635 Bring the core links up that are down and verify ping all ( Host Intents-Spine Topo )
1636 """
1637 import random
1638 link1End1 = main.params[ 'SPINECORELINKS' ][ 'linkS9' ]
1639 link2End1 = main.params[ 'SPINECORELINKS' ][ 'linkS10' ]
1640 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1641 main.log.report(
1642 "Bring the core links up that are down and verify ping all (Host Intents-Spine Topo" )
1643 main.log.report(
1644 "__________________________________________________________________" )
1645 main.case(
1646 "Host intents - Bring the core links up that are down and verify ping all" )
1647
kelvin-onlab77d6c302015-03-31 11:33:32 -07001648 #main.Mininet1.link( END1=link1End1, END2=main.randomLink1, OPTION="up" )
1649 #main.Mininet1.link( END1=link2End1, END2=main.randomLink2, OPTION="up" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001650 main.Mininet1.link( END1=link1End1, END2=main.randomLink3, OPTION="up" )
1651 main.Mininet1.link( END1=link2End1, END2=main.randomLink4, OPTION="up" )
1652
1653 time.sleep( link_sleep )
1654 topology_output = main.ONOScli2.topology()
1655 linkUp = main.ONOSbench.checkStatus(
1656 topology_output,
1657 main.numMNswitches,
1658 str( main.numMNlinks ) )
1659 utilities.assert_equals(
1660 expect=main.TRUE,
1661 actual=linkUp,
1662 onpass="Link up discovered properly",
1663 onfail="Link up was not discovered in " +
1664 str( link_sleep ) +
1665 " seconds" )
1666
1667 main.step( "Verify Ping across all hosts" )
1668 pingResultLinkUp = main.FALSE
1669 time1 = time.time()
kelvin-onlabc44f0192015-04-02 22:08:41 -07001670 pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin-onlab65a72d22015-03-26 13:46:32 -07001671 time2 = time.time()
1672 timeDiff = round( ( time2 - time1 ), 2 )
1673 main.log.report(
1674 "Time taken for Ping All: " +
1675 str( timeDiff ) +
1676 " seconds" )
1677 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1678 onpass="PING ALL PASS",
1679 onfail="PING ALL FAIL" )
1680
1681 caseResult84 = linkUp and pingResultLinkUp
1682 utilities.assert_equals( expect=main.TRUE, actual=caseResult84,
1683 onpass="Link Up Test PASS",
1684 onfail="Link Up Test FAIL" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001685
1686 def CASE90( self ):
kelvin-onlab8a832582015-01-16 17:06:11 -08001687 """
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001688 Install 600 point intents and verify ping all (Att Topology)
kelvin-onlab8a832582015-01-16 17:06:11 -08001689 """
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001690 main.log.report( "Add 600 point intents and verify pingall (Att Topology)" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001691 main.log.report( "_______________________________________" )
1692 import itertools
1693 import time
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001694 main.case( "Install 600 point intents" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001695 main.step( "Add point Intents" )
1696 intentResult = main.TRUE
1697 deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) )
1698
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001699 intentIdList = []
Hari Krishnab35c6d02015-03-18 11:13:51 -07001700 time1 = time.time()
Hari Krishnab35c6d02015-03-18 11:13:51 -07001701 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1702 pool = []
1703 for cli in main.CLIs:
1704 if i >= len( deviceCombos ):
1705 break
1706 t = main.Thread( target=cli.addPointIntent,
1707 threadID=main.threadID,
1708 name="addPointIntent",
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001709 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
Hari Krishnab35c6d02015-03-18 11:13:51 -07001710 pool.append(t)
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001711 #time.sleep(1)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001712 t.start()
1713 i = i + 1
1714 main.threadID = main.threadID + 1
1715 for thread in pool:
1716 thread.join()
1717 intentIdList.append(thread.result)
1718 time2 = time.time()
1719 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1720 intentResult = main.TRUE
1721 intentsJson = main.ONOScli2.intents()
1722 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1723 intentsJson = intentsJson)
1724 print getIntentStateResult
1725 # Takes awhile for all the onos to get the intents
1726 time.sleep(30)
kelvin-onlab8a832582015-01-16 17:06:11 -08001727 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001728 pingResult = main.FALSE
1729 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001730 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001731 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001732 timeDiff = round( ( time2 - time1 ), 2 )
1733 main.log.report(
1734 "Time taken for Ping All: " +
1735 str( timeDiff ) +
1736 " seconds" )
1737 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1738 onpass="PING ALL PASS",
1739 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001740
kelvin-onlab65a72d22015-03-26 13:46:32 -07001741 case90Result = ( intentResult and pingResult )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001742
kelvin-onlab8a832582015-01-16 17:06:11 -08001743 utilities.assert_equals(
1744 expect=main.TRUE,
kelvin-onlab65a72d22015-03-26 13:46:32 -07001745 actual=case90Result,
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001746 onpass="Install 600 point Intents and Ping All test PASS",
1747 onfail="Install 600 point Intents and Ping All test FAIL" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001748
1749 def CASE91( self ):
1750 """
1751 Install ###$$$ point intents and verify ping all (Chordal Topology)
1752 """
1753 main.log.report( "Add ###$$$ point intents and verify pingall (Chordal Topology)" )
1754 main.log.report( "_______________________________________" )
1755 import itertools
1756 import time
1757 main.case( "Install ###$$$ point intents" )
1758 main.step( "Add point Intents" )
1759 intentResult = main.TRUE
1760 deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) )
1761
1762 intentIdList = []
1763 time1 = time.time()
1764 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1765 pool = []
1766 for cli in main.CLIs:
1767 if i >= len( deviceCombos ):
1768 break
1769 t = main.Thread( target=cli.addPointIntent,
1770 threadID=main.threadID,
1771 name="addPointIntent",
1772 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
1773 pool.append(t)
1774 #time.sleep(1)
1775 t.start()
1776 i = i + 1
1777 main.threadID = main.threadID + 1
1778 for thread in pool:
1779 thread.join()
1780 intentIdList.append(thread.result)
1781 time2 = time.time()
1782 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1783 intentResult = main.TRUE
1784 intentsJson = main.ONOScli2.intents()
1785 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1786 intentsJson = intentsJson)
1787 print getIntentStateResult
1788 # Takes awhile for all the onos to get the intents
1789 time.sleep(30)
1790 main.step( "Verify Ping across all hosts" )
1791 pingResult = main.FALSE
1792 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001793 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001794 time2 = time.time()
1795 timeDiff = round( ( time2 - time1 ), 2 )
1796 main.log.report(
1797 "Time taken for Ping All: " +
1798 str( timeDiff ) +
1799 " seconds" )
1800 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1801 onpass="PING ALL PASS",
1802 onfail="PING ALL FAIL" )
1803
kelvin-onlab65a72d22015-03-26 13:46:32 -07001804 case91Result = ( intentResult and pingResult )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001805
1806 utilities.assert_equals(
1807 expect=main.TRUE,
kelvin-onlabd878fc22015-03-27 13:33:41 -07001808 actual=case91Result,
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001809 onpass="Install ###$$$ point Intents and Ping All test PASS",
1810 onfail="Install ###$$$ point Intents and Ping All test FAIL" )
1811
1812 def CASE92( self ):
1813 """
kelvin-onlab77d6c302015-03-31 11:33:32 -07001814 Install 4556 point intents and verify ping all (Spine Topology)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001815 """
kelvin-onlab77d6c302015-03-31 11:33:32 -07001816 main.log.report( "Add 4556 point intents and verify pingall (Spine Topology)" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001817 main.log.report( "_______________________________________" )
1818 import itertools
1819 import time
kelvin-onlab77d6c302015-03-31 11:33:32 -07001820 main.case( "Install 4556 point intents" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001821 main.step( "Add point Intents" )
1822 intentResult = main.TRUE
kelvin-onlab77d6c302015-03-31 11:33:32 -07001823 main.pingTimeout = 600
1824 for i in range(len(main.hostMACs)):
1825 main.MACsDict[main.deviceDPIDs[i+10]] = main.hostMACs[i].split('/')[0]
1826 print main.MACsDict
1827 deviceCombos = list( itertools.permutations( main.deviceDPIDs[10:], 2 ) )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001828
1829 intentIdList = []
1830 time1 = time.time()
1831 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1832 pool = []
1833 for cli in main.CLIs:
1834 if i >= len( deviceCombos ):
1835 break
1836 t = main.Thread( target=cli.addPointIntent,
1837 threadID=main.threadID,
1838 name="addPointIntent",
1839 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
1840 pool.append(t)
1841 #time.sleep(1)
1842 t.start()
1843 i = i + 1
1844 main.threadID = main.threadID + 1
1845 for thread in pool:
1846 thread.join()
1847 intentIdList.append(thread.result)
1848 time2 = time.time()
1849 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1850 intentResult = main.TRUE
1851 intentsJson = main.ONOScli2.intents()
1852 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1853 intentsJson = intentsJson)
kelvin-onlab77d6c302015-03-31 11:33:32 -07001854 #print getIntentStateResult
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001855 # Takes awhile for all the onos to get the intents
kelvin-onlab77d6c302015-03-31 11:33:32 -07001856 time.sleep(60)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001857 main.step( "Verify Ping across all hosts" )
1858 pingResult = main.FALSE
1859 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001860 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001861 time2 = time.time()
1862 timeDiff = round( ( time2 - time1 ), 2 )
1863 main.log.report(
1864 "Time taken for Ping All: " +
1865 str( timeDiff ) +
1866 " seconds" )
1867 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1868 onpass="PING ALL PASS",
1869 onfail="PING ALL FAIL" )
1870
kelvin-onlab65a72d22015-03-26 13:46:32 -07001871 case92Result = ( intentResult and pingResult )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001872
1873 utilities.assert_equals(
1874 expect=main.TRUE,
kelvin-onlab65a72d22015-03-26 13:46:32 -07001875 actual=case92Result,
kelvin-onlab77d6c302015-03-31 11:33:32 -07001876 onpass="Install 4556 point Intents and Ping All test PASS",
1877 onfail="Install 4556 point Intents and Ping All test FAIL" )
1878
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001879 def CASE93( self ):
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001880 """
kelvin-onlab77d6c302015-03-31 11:33:32 -07001881 Install multi-single point intents and verify Ping all works
1882 for att topology
1883 """
1884 import copy
1885 import time
1886 main.log.report( "Install multi-single point intents and verify Ping all" )
1887 main.log.report( "___________________________________________" )
1888 main.case( "Install multi-single point intents and Ping all" )
1889 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
1890 portIngressList = ['1']*(len(deviceDPIDsCopy) - 1)
1891 intentIdList = []
1892 print "MACsDict", main.MACsDict
1893 time1 = time.time()
1894 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
1895 pool = []
1896 for cli in main.CLIs:
1897 egressDevice = deviceDPIDsCopy[i]
1898 ingressDeviceList = copy.copy(deviceDPIDsCopy)
1899 ingressDeviceList.remove(egressDevice)
1900 if i >= len( deviceDPIDsCopy ):
1901 break
1902 t = main.Thread( target=cli.addMultipointToSinglepointIntent,
1903 threadID=main.threadID,
1904 name="addMultipointToSinglepointIntent",
1905 args =[ingressDeviceList,egressDevice,portIngressList,'1','IPV4','',main.MACsDict.get(egressDevice)])
1906 pool.append(t)
1907 #time.sleep(1)
1908 t.start()
1909 i = i + 1
1910 main.threadID = main.threadID + 1
1911 for thread in pool:
1912 thread.join()
1913 intentIdList.append(thread.result)
1914 time2 = time.time()
1915 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
kelvin-onlab06ade552015-03-31 18:09:27 -07001916 print intentIdList
kelvin-onlab77d6c302015-03-31 11:33:32 -07001917 time.sleep(5)
1918 main.step( "Verify Ping across all hosts" )
1919 pingResult = main.FALSE
1920 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001921 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin-onlab77d6c302015-03-31 11:33:32 -07001922 time2 = time.time()
1923 timeDiff = round( ( time2 - time1 ), 2 )
1924 main.log.report(
1925 "Time taken for Ping All: " +
1926 str( timeDiff ) +
1927 " seconds" )
1928
1929 case93Result = pingResult
1930 utilities.assert_equals(
1931 expect=main.TRUE,
1932 actual=case93Result,
1933 onpass="Install 25 multi to single point Intents and Ping All test PASS",
1934 onfail="Install 25 multi to single point Intents and Ping All test FAIL" )
1935
kelvin-onlab20c712a2015-03-31 12:55:34 -07001936 def CASE94( self ):
1937 """
1938 Install multi-single point intents and verify Ping all works
kelvin-onlabd9a8ed32015-04-03 13:55:28 -07001939 for Chordal topology
kelvin-onlab20c712a2015-03-31 12:55:34 -07001940 """
1941 import copy
1942 import time
1943 main.log.report( "Install multi-single point intents and verify Ping all" )
1944 main.log.report( "___________________________________________" )
1945 main.case( "Install multi-single point intents and Ping all" )
1946 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
1947 portIngressList = ['1']*(len(deviceDPIDsCopy) - 1)
1948 intentIdList = []
1949 print "MACsDict", main.MACsDict
1950 time1 = time.time()
1951 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
1952 pool = []
1953 for cli in main.CLIs:
1954 egressDevice = deviceDPIDsCopy[i]
1955 ingressDeviceList = copy.copy(deviceDPIDsCopy)
1956 ingressDeviceList.remove(egressDevice)
1957 if i >= len( deviceDPIDsCopy ):
1958 break
1959 t = main.Thread( target=cli.addMultipointToSinglepointIntent,
1960 threadID=main.threadID,
1961 name="addMultipointToSinglepointIntent",
1962 args =[ingressDeviceList,egressDevice,portIngressList,'1','IPV4','',main.MACsDict.get(egressDevice)])
1963 pool.append(t)
1964 #time.sleep(1)
1965 t.start()
1966 i = i + 1
1967 main.threadID = main.threadID + 1
1968 for thread in pool:
1969 thread.join()
1970 intentIdList.append(thread.result)
1971 time2 = time.time()
1972 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1973 time.sleep(5)
1974 main.step( "Verify Ping across all hosts" )
1975 pingResult = main.FALSE
1976 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001977 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin-onlab20c712a2015-03-31 12:55:34 -07001978 time2 = time.time()
1979 timeDiff = round( ( time2 - time1 ), 2 )
1980 main.log.report(
1981 "Time taken for Ping All: " +
1982 str( timeDiff ) +
1983 " seconds" )
1984
1985 case94Result = pingResult
1986 utilities.assert_equals(
1987 expect=main.TRUE,
1988 actual=case94Result,
1989 onpass="Install 25 multi to single point Intents and Ping All test PASS",
1990 onfail="Install 25 multi to single point Intents and Ping All test FAIL" )
kelvin-onlab06ade552015-03-31 18:09:27 -07001991
1992 #def CASE95 multi-single point intent for Spine
1993
kelvin-onlab77d6c302015-03-31 11:33:32 -07001994 def CASE96( self ):
1995 """
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001996 Install single-multi point intents and verify Ping all works
1997 for att topology
1998 """
1999 import copy
2000 main.log.report( "Install single-multi point intents and verify Ping all" )
2001 main.log.report( "___________________________________________" )
2002 main.case( "Install single-multi point intents and Ping all" )
kelvin-onlab06ade552015-03-31 18:09:27 -07002003 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
2004 portEgressList = ['1']*(len(deviceDPIDsCopy) - 1)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002005 intentIdList = []
kelvin-onlab06ade552015-03-31 18:09:27 -07002006 print "MACsDict", main.MACsDict
2007 time1 = time.time()
2008 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
2009 pool = []
2010 for cli in main.CLIs:
2011 ingressDevice = deviceDPIDsCopy[i]
2012 egressDeviceList = copy.copy(deviceDPIDsCopy)
2013 egressDeviceList.remove(ingressDevice)
2014 if i >= len( deviceDPIDsCopy ):
2015 break
2016 t = main.Thread( target=cli.addSinglepointToMultipointIntent,
2017 threadID=main.threadID,
2018 name="addSinglepointToMultipointIntent",
2019 args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',main.MACsDict.get(ingressDevice)])
2020 pool.append(t)
2021 #time.sleep(1)
2022 t.start()
2023 i = i + 1
2024 main.threadID = main.threadID + 1
2025 for thread in pool:
2026 thread.join()
2027 intentIdList.append(thread.result)
2028 time2 = time.time()
2029 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
2030 time.sleep(5)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002031 main.step( "Verify Ping across all hosts" )
2032 pingResult = main.FALSE
2033 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07002034 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002035 time2 = time.time()
2036 timeDiff = round( ( time2 - time1 ), 2 )
2037 main.log.report(
2038 "Time taken for Ping All: " +
2039 str( timeDiff ) +
2040 " seconds" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002041
kelvin-onlab06ade552015-03-31 18:09:27 -07002042 case96Result = pingResult
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002043 utilities.assert_equals(
2044 expect=main.TRUE,
kelvin-onlab06ade552015-03-31 18:09:27 -07002045 actual=case96Result,
2046 onpass="Install 25 single to multi point Intents and Ping All test PASS",
2047 onfail="Install 25 single to multi point Intents and Ping All test FAIL" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002048
kelvin-onlab77d6c302015-03-31 11:33:32 -07002049 def CASE97( self ):
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002050 """
2051 Install single-multi point intents and verify Ping all works
kelvin-onlab06ade552015-03-31 18:09:27 -07002052 for Chordal topology
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002053 """
2054 import copy
2055 main.log.report( "Install single-multi point intents and verify Ping all" )
2056 main.log.report( "___________________________________________" )
2057 main.case( "Install single-multi point intents and Ping all" )
kelvin-onlab06ade552015-03-31 18:09:27 -07002058 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
2059 portEgressList = ['1']*(len(deviceDPIDsCopy) - 1)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002060 intentIdList = []
kelvin-onlab06ade552015-03-31 18:09:27 -07002061 print "MACsDict", main.MACsDict
2062 time1 = time.time()
2063 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
2064 pool = []
2065 for cli in main.CLIs:
2066 ingressDevice = deviceDPIDsCopy[i]
2067 egressDeviceList = copy.copy(deviceDPIDsCopy)
2068 egressDeviceList.remove(ingressDevice)
2069 if i >= len( deviceDPIDsCopy ):
2070 break
2071 t = main.Thread( target=cli.addSinglepointToMultipointIntent,
2072 threadID=main.threadID,
2073 name="addSinglepointToMultipointIntent",
2074 args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',main.MACsDict.get(ingressDevice),''])
2075 pool.append(t)
2076 #time.sleep(1)
2077 t.start()
2078 i = i + 1
2079 main.threadID = main.threadID + 1
2080 for thread in pool:
2081 thread.join()
2082 intentIdList.append(thread.result)
2083 time2 = time.time()
2084 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
2085 time.sleep(5)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002086 main.step( "Verify Ping across all hosts" )
2087 pingResult = main.FALSE
2088 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07002089 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002090 time2 = time.time()
2091 timeDiff = round( ( time2 - time1 ), 2 )
2092 main.log.report(
2093 "Time taken for Ping All: " +
2094 str( timeDiff ) +
2095 " seconds" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002096
kelvin-onlab06ade552015-03-31 18:09:27 -07002097 case97Result = pingResult
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002098 utilities.assert_equals(
2099 expect=main.TRUE,
kelvin-onlab06ade552015-03-31 18:09:27 -07002100 actual=case97Result,
2101 onpass="Install 25 single to multi point Intents and Ping All test PASS",
2102 onfail="Install 25 single to multi point Intents and Ping All test FAIL" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002103
kelvin-onlab8a832582015-01-16 17:06:11 -08002104 def CASE10( self ):
kelvin-onlab7642bb12015-02-27 13:48:17 -08002105 import time
kelvin-onlab8a832582015-01-16 17:06:11 -08002106 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002107 Remove all Intents
kelvin-onlab8a832582015-01-16 17:06:11 -08002108 """
2109 main.log.report( "Remove all intents that were installed previously" )
2110 main.log.report( "______________________________________________" )
2111 main.log.info( "Remove all intents" )
2112 main.case( "Removing intents" )
2113 main.step( "Obtain the intent id's first" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002114 intentsList = main.ONOScli1.getAllIntentIds()
kelvin-onlab8a832582015-01-16 17:06:11 -08002115 ansi_escape = re.compile( r'\x1b[^m]*m' )
2116 intentsList = ansi_escape.sub( '', intentsList )
2117 intentsList = intentsList.replace(
2118 " onos:intents | grep id=",
2119 "" ).replace(
2120 "id=",
2121 "" ).replace(
2122 "\r\r",
2123 "" )
2124 intentsList = intentsList.splitlines()
2125 intentsList = intentsList[ 1: ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002126 intentIdList = []
2127 step1Result = main.TRUE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002128 moreIntents = main.TRUE
2129 removeIntentCount = 0
kelvin-onlab65a72d22015-03-26 13:46:32 -07002130 intentsCount = len(intentsList)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002131 print "Current number of intents" , len(intentsList)
kelvin-onlab8a832582015-01-16 17:06:11 -08002132 if ( len( intentsList ) > 1 ):
kelvin-onlab54400a92015-02-26 18:05:51 -08002133 results = main.TRUE
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002134 main.log.info("Removing intent...")
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002135 while moreIntents:
Hari Krishnab35c6d02015-03-18 11:13:51 -07002136 if removeIntentCount == 5:
2137 break
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002138 removeIntentCount = removeIntentCount + 1
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002139 intentsList1 = main.ONOScli1.getAllIntentIds()
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002140 if len( intentsList1 ) == 0:
2141 break
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002142 ansi_escape = re.compile( r'\x1b[^m]*m' )
2143 intentsList1 = ansi_escape.sub( '', intentsList1 )
2144 intentsList1 = intentsList1.replace(
2145 " onos:intents | grep id=",
2146 "" ).replace(
2147 " state=",
2148 "" ).replace(
2149 "\r\r",
2150 "" )
2151 intentsList1 = intentsList1.splitlines()
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002152 intentsList1 = intentsList1[ 1: ]
2153 print "Round %d intents to remove: " %(removeIntentCount)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002154 print intentsList1
2155 intentIdList1 = []
Hari Krishnab35c6d02015-03-18 11:13:51 -07002156 if ( len( intentsList1 ) > 0 ):
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002157 moreIntents = main.TRUE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002158 for i in range( len( intentsList1 ) ):
2159 intentsTemp1 = intentsList1[ i ].split( ',' )
2160 intentIdList1.append( intentsTemp1[ 0 ].split('=')[1] )
2161 print "Leftover Intent IDs: ", intentIdList1
2162 print len(intentIdList1)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07002163 time1 = time.time()
2164 for i in xrange( 0, len( intentIdList1 ), int(main.numCtrls) ):
2165 pool = []
2166 for cli in main.CLIs:
2167 if i >= len( intentIdList1 ):
2168 break
2169 t = main.Thread( target=cli.removeIntent,
2170 threadID=main.threadID,
2171 name="removeIntent",
2172 args=[intentIdList1[i],'org.onosproject.cli',True,False])
2173 pool.append(t)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07002174 t.start()
2175 i = i + 1
2176 main.threadID = main.threadID + 1
2177 for thread in pool:
2178 thread.join()
2179 intentIdList.append(thread.result)
2180 time2 = time.time()
2181 main.log.info("Time for removing host intents: %2f seconds" %(time2-time1))
Hari Krishnab35c6d02015-03-18 11:13:51 -07002182 time.sleep(10)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002183 else:
Hari Krishnaef1bd4e2015-03-12 16:55:30 -07002184 time.sleep(15)
Hari Krishnab35c6d02015-03-18 11:13:51 -07002185 if len( main.ONOScli1.intents()):
Hari Krishnaef1bd4e2015-03-12 16:55:30 -07002186 continue
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002187 break
kelvin-onlab36c02b12015-03-11 11:25:55 -07002188
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002189 else:
kelvin-onlab65a72d22015-03-26 13:46:32 -07002190 print "Removed %d intents" %(intentsCount)
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002191 step1Result = main.TRUE
2192 else:
2193 print "No Intent IDs found in Intents list: ", intentsList
2194 step1Result = main.FALSE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002195
kelvin-onlabdc8719b2015-03-02 14:01:52 -08002196 print main.ONOScli1.intents()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002197 caseResult10 = step1Result
2198 utilities.assert_equals( expect=main.TRUE, actual=caseResult10,
kelvin-onlab8a832582015-01-16 17:06:11 -08002199 onpass="Intent removal test successful",
2200 onfail="Intent removal test failed" )
Hari Krishna22c3d412015-02-17 16:48:12 -08002201
2202 def CASE11( self, main ):
2203 """
2204 Enable onos-app-ifwd, Verify Intent based Reactive forwarding through ping all and Disable it
2205 """
2206 import re
2207 import copy
2208 import time
2209
kelvin-onlab54400a92015-02-26 18:05:51 -08002210 Thread = imp.load_source('Thread','/home/admin/ONLabTest/TestON/tests/OnosCHO/Thread.py')
2211 threadID = 0
2212
Hari Krishna22c3d412015-02-17 16:48:12 -08002213 main.log.report( "Enable Intent based Reactive forwarding and Verify ping all" )
2214 main.log.report( "_____________________________________________________" )
2215 main.case( "Enable Intent based Reactive forwarding and Verify ping all" )
2216 main.step( "Enable intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08002217 installResult = main.FALSE
2218 feature = "onos-app-ifwd"
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002219
kelvin-onlab54400a92015-02-26 18:05:51 -08002220 pool = []
2221 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002222 for cli,feature in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -08002223 t = main.Thread(target=cli,threadID=threadID,
2224 name="featureInstall",args=[feature])
2225 pool.append(t)
2226 t.start()
2227 threadID = threadID + 1
2228
2229 results = []
2230 for thread in pool:
2231 thread.join()
2232 results.append(thread.result)
2233 time2 = time.time()
2234
2235 if( all(result == main.TRUE for result in results) == False):
2236 main.log.info("Did not install onos-app-ifwd feature properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -07002237 #main.cleanup()
2238 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -08002239 else:
2240 main.log.info("Successful feature:install onos-app-ifwd")
2241 installResult = main.TRUE
2242 main.log.info("Time for feature:install onos-app-ifwd: %2f seconds" %(time2-time1))
2243
Hari Krishna22c3d412015-02-17 16:48:12 -08002244 main.step( "Verify Pingall" )
2245 ping_result = main.FALSE
2246 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -08002247 ping_result = main.Mininet1.pingall(timeout=600)
Hari Krishna22c3d412015-02-17 16:48:12 -08002248 time2 = time.time()
2249 timeDiff = round( ( time2 - time1 ), 2 )
2250 main.log.report(
2251 "Time taken for Ping All: " +
2252 str( timeDiff ) +
2253 " seconds" )
kelvin-onlab54400a92015-02-26 18:05:51 -08002254
Hari Krishna22c3d412015-02-17 16:48:12 -08002255 if ping_result == main.TRUE:
2256 main.log.report( "Pingall Test in Reactive mode successful" )
2257 else:
2258 main.log.report( "Pingall Test in Reactive mode failed" )
2259
2260 main.step( "Disable Intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08002261 uninstallResult = main.FALSE
2262
kelvin-onlab54400a92015-02-26 18:05:51 -08002263 pool = []
2264 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002265 for cli,feature in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -08002266 t = main.Thread(target=cli,threadID=threadID,
2267 name="featureUninstall",args=[feature])
2268 pool.append(t)
2269 t.start()
2270 threadID = threadID + 1
2271
2272 results = []
2273 for thread in pool:
2274 thread.join()
2275 results.append(thread.result)
2276 time2 = time.time()
2277
2278 if( all(result == main.TRUE for result in results) == False):
2279 main.log.info("Did not uninstall onos-app-ifwd feature properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -07002280 uninstallResult = main.FALSE
2281 #main.cleanup()
2282 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -08002283 else:
2284 main.log.info("Successful feature:uninstall onos-app-ifwd")
2285 uninstallResult = main.TRUE
2286 main.log.info("Time for feature:uninstall onos-app-ifwd: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -08002287
2288 # Waiting for reative flows to be cleared.
2289 time.sleep( 10 )
2290
2291 case11Result = installResult and ping_result and uninstallResult
2292 utilities.assert_equals( expect=main.TRUE, actual=case11Result,
2293 onpass="Intent based Reactive forwarding Pingall test PASS",
2294 onfail="Intent based Reactive forwarding Pingall test FAIL" )
2295
Hari Krishnab35c6d02015-03-18 11:13:51 -07002296 def CASE99(self):
2297 import time
2298 # WORK AROUND FOR ONOS-581. STOP ONOS BEFORE ASSIGNING CONTROLLERS AT MININET & START ONCE DONE
2299 main.step( "Stop ONOS on all Nodes" )
2300 stopResult = main.TRUE
2301 for i in range( 1, int( main.numCtrls ) + 1 ):
2302 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
2303 main.log.info( "Stopping ONOS Node IP: " + ONOS_ip )
2304 sresult = main.ONOSbench.onosStop( ONOS_ip )
2305 utilities.assert_equals( expect=main.TRUE, actual=sresult,
2306 onpass="Test step PASS",
2307 onfail="Test step FAIL" )
2308 stopResult = ( stopResult and sresult )
2309
2310 main.step( "Start ONOS on all Nodes" )
2311 startResult = main.TRUE
2312 for i in range( 1, int( main.numCtrls ) + 1 ):
2313 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
2314 main.log.info( "Starting ONOS Node IP: " + ONOS_ip )
2315 sresult = main.ONOSbench.onosStart( ONOS_ip )
2316 utilities.assert_equals( expect=main.TRUE, actual=sresult,
2317 onpass="Test step PASS",
2318 onfail="Test step FAIL" )
2319 startResult = ( startResult and sresult )
2320
2321 main.step( "Start ONOS CLI on all nodes" )
2322 cliResult = main.TRUE
2323 time.sleep( 30 )
2324 main.log.step(" Start ONOS cli using thread ")
2325 pool = []
2326 time1 = time.time()
2327 for i in range( int( main.numCtrls ) ):
2328 t = main.Thread(target=main.CLIs[i].startOnosCli,
2329 threadID=main.threadID,
2330 name="startOnosCli",
2331 args=[main.nodes[i].ip_address])
2332 pool.append(t)
2333 t.start()
2334 main.threadID = main.threadID + 1
2335 for t in pool:
2336 t.join()
2337 cliResult = cliResult and t.result
2338 time2 = time.time()
2339
2340 if not cliResult:
2341 main.log.info("ONOS CLI did not start up properly")
2342 #main.cleanup()
2343 #main.exit()
2344 else:
2345 main.log.info("Successful CLI startup")
2346 main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
2347
2348 case99Result = ( startResult and cliResult )
2349 time.sleep(30)
2350 utilities.assert_equals(
2351 expect=main.TRUE,
2352 actual=case99Result,
2353 onpass="Starting new Chordal topology test PASS",
2354 onfail="Starting new Chordal topology test FAIL" )
2355
2356
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002357
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002358