blob: b48c44f91333da22b3a2286ad2c7d51ce733fa32 [file] [log] [blame]
kelvin-onlab65a72d22015-03-26 13:46:32 -07001
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002import sys
3import os
4import re
5import time
6import json
7import itertools
8
kelvin8ec71442015-01-15 16:57:00 -08009
Hari Krishnaa43d4e92014-12-19 13:22:40 -080010class OnosCHO:
kelvin8ec71442015-01-15 16:57:00 -080011
kelvin-onlab8a832582015-01-16 17:06:11 -080012 def __init__( self ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -080013 self.default = ''
kelvin8ec71442015-01-15 16:57:00 -080014
kelvin-onlab8a832582015-01-16 17:06:11 -080015 def CASE1( self, main ):
16 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -080017 Startup sequence:
18 git pull
19 mvn clean install
20 onos-package
21 cell <name>
22 onos-verify-cell
23 onos-install -f
24 onos-wait-for-start
kelvin-onlab8a832582015-01-16 17:06:11 -080025 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -080026 import time
kelvin-onlab78f7d2d2015-03-02 17:37:35 -080027
28 global intentState
kelvin-onlab54400a92015-02-26 18:05:51 -080029 main.threadID = 0
30 main.pingTimeout = 300
Hari Krishna22c3d412015-02-17 16:48:12 -080031 main.numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ]
32 main.ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
33 main.ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
34 main.ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
35 main.ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ]
36 main.ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ]
37 main.ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
38 main.ONOS2_port = main.params[ 'CTRL' ][ 'port2' ]
39 main.ONOS3_port = main.params[ 'CTRL' ][ 'port3' ]
40 main.ONOS4_port = main.params[ 'CTRL' ][ 'port4' ]
41 main.ONOS5_port = main.params[ 'CTRL' ][ 'port5' ]
kelvin-onlab8a832582015-01-16 17:06:11 -080042 cell_name = main.params[ 'ENV' ][ 'cellName' ]
43 git_pull = main.params[ 'GIT' ][ 'autoPull' ]
kelvin-onlab8a832582015-01-16 17:06:11 -080044 git_branch = main.params[ 'GIT' ][ 'branch' ]
Hari Krishnab35c6d02015-03-18 11:13:51 -070045 main.newTopo = ""
kelvin-onlab78f7d2d2015-03-02 17:37:35 -080046 main.CLIs = []
47 main.nodes = []
48 for i in range( 1, int(main.numCtrls) + 1 ):
49 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
50 main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
51
kelvin-onlab8a832582015-01-16 17:06:11 -080052 main.case( "Set up test environment" )
53 main.log.report( "Set up test environment" )
54 main.log.report( "_______________________" )
55
56 main.step( "Git checkout and pull " + git_branch )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080057 if git_pull == 'on':
Hari Krishnad97213e2015-01-24 19:30:14 -080058 checkout_result = main.ONOSbench.gitCheckout( git_branch )
59 pull_result = main.ONOSbench.gitPull()
kelvin-onlab8a832582015-01-16 17:06:11 -080060 cp_result = ( checkout_result and pull_result )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080061 else:
62 checkout_result = main.TRUE
63 pull_result = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -080064 main.log.info( "Skipped git checkout and pull" )
65 cp_result = ( checkout_result and pull_result )
66 utilities.assert_equals( expect=main.TRUE, actual=cp_result,
67 onpass="Test step PASS",
68 onfail="Test step FAIL" )
69
70 main.step( "mvn clean & install" )
Hari Krishna22c3d412015-02-17 16:48:12 -080071 if git_pull == 'on':
72 mvn_result = main.ONOSbench.cleanInstall()
73 utilities.assert_equals( expect=main.TRUE, actual=mvn_result,
kelvin-onlab8a832582015-01-16 17:06:11 -080074 onpass="Test step PASS",
75 onfail="Test step FAIL" )
Hari Krishna22c3d412015-02-17 16:48:12 -080076 else:
77 mvn_result = main.TRUE
78 main.log.info("Skipped mvn clean install as git pull is disabled in params file")
Hari Krishnaa43d4e92014-12-19 13:22:40 -080079
Hari Krishnad97213e2015-01-24 19:30:14 -080080 main.ONOSbench.getVersion( report=True )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080081
kelvin-onlab8a832582015-01-16 17:06:11 -080082 main.step( "Apply Cell environment for ONOS" )
Hari Krishnad97213e2015-01-24 19:30:14 -080083 cell_result = main.ONOSbench.setCell( cell_name )
kelvin-onlab8a832582015-01-16 17:06:11 -080084 utilities.assert_equals( expect=main.TRUE, actual=cell_result,
85 onpass="Test step PASS",
86 onfail="Test step FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080087
kelvin-onlab8a832582015-01-16 17:06:11 -080088 main.step( "Create ONOS package" )
Hari Krishnad97213e2015-01-24 19:30:14 -080089 packageResult = main.ONOSbench.onosPackage()
kelvin-onlab8a832582015-01-16 17:06:11 -080090 utilities.assert_equals( expect=main.TRUE, actual=packageResult,
91 onpass="Test step PASS",
92 onfail="Test step FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080093
kelvin-onlab8a832582015-01-16 17:06:11 -080094 main.step( "Uninstall ONOS package on all Nodes" )
95 uninstallResult = main.TRUE
Hari Krishna22c3d412015-02-17 16:48:12 -080096 for i in range( 1, int( main.numCtrls ) + 1 ):
kelvin-onlab8a832582015-01-16 17:06:11 -080097 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
kelvin-onlab54400a92015-02-26 18:05:51 -080098 main.log.info( "Uninstalling package on ONOS Node IP: " + ONOS_ip )
Hari Krishnad97213e2015-01-24 19:30:14 -080099 u_result = main.ONOSbench.onosUninstall( ONOS_ip )
kelvin-onlab8a832582015-01-16 17:06:11 -0800100 utilities.assert_equals( expect=main.TRUE, actual=u_result,
101 onpass="Test step PASS",
102 onfail="Test step FAIL" )
103 uninstallResult = ( uninstallResult and u_result )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800104
Hari Krishnab35c6d02015-03-18 11:13:51 -0700105 #main.step( "Removing copy-cat logs from ONOS nodes" )
106 #main.ONOSbench.onosRemoveRaftLogs()
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800107
kelvin-onlab8a832582015-01-16 17:06:11 -0800108 main.step( "Install ONOS package on all Nodes" )
109 installResult = main.TRUE
Hari Krishna22c3d412015-02-17 16:48:12 -0800110 for i in range( 1, int( main.numCtrls ) + 1 ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800111 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
112 main.log.info( "Intsalling package on ONOS Node IP: " + ONOS_ip )
Hari Krishnad97213e2015-01-24 19:30:14 -0800113 i_result = main.ONOSbench.onosInstall( node=ONOS_ip )
kelvin-onlab8a832582015-01-16 17:06:11 -0800114 utilities.assert_equals( expect=main.TRUE, actual=i_result,
115 onpass="Test step PASS",
116 onfail="Test step FAIL" )
117 installResult = ( installResult and i_result )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800118
kelvin-onlab8a832582015-01-16 17:06:11 -0800119 main.step( "Verify ONOS nodes UP status" )
120 statusResult = main.TRUE
Hari Krishna22c3d412015-02-17 16:48:12 -0800121 for i in range( 1, int( main.numCtrls ) + 1 ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800122 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
123 main.log.info( "ONOS Node " + ONOS_ip + " status:" )
Hari Krishnad97213e2015-01-24 19:30:14 -0800124 onos_status = main.ONOSbench.onosStatus( node=ONOS_ip )
kelvin-onlab8a832582015-01-16 17:06:11 -0800125 utilities.assert_equals( expect=main.TRUE, actual=onos_status,
126 onpass="Test step PASS",
127 onfail="Test step FAIL" )
128 statusResult = ( statusResult and onos_status )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700129
kelvin-onlab8a832582015-01-16 17:06:11 -0800130 main.step( "Start ONOS CLI on all nodes" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800131 cliResult = main.TRUE
kelvin8ec71442015-01-15 16:57:00 -0800132 karafTimeout = "3600000"
kelvin-onlab8a832582015-01-16 17:06:11 -0800133 # need to wait here for sometime. This will be removed once ONOS is
134 # stable enough
kelvin-onlab54400a92015-02-26 18:05:51 -0800135 time.sleep( 25 )
kelvin-onlab54400a92015-02-26 18:05:51 -0800136 main.log.step(" Start ONOS cli using thread ")
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800137 startCliResult = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800138 pool = []
139 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800140 for i in range( int( main.numCtrls) ):
141 t = main.Thread( target=main.CLIs[i].startOnosCli,
142 threadID=main.threadID,
143 name="startOnosCli",
144 args=[ main.nodes[i].ip_address ] )
kelvin-onlab54400a92015-02-26 18:05:51 -0800145 pool.append(t)
146 t.start()
147 main.threadID = main.threadID + 1
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800148 for t in pool:
149 t.join()
150 startCliResult = startCliResult and t.result
kelvin-onlab54400a92015-02-26 18:05:51 -0800151 time2 = time.time()
152
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800153 if not startCliResult:
kelvin-onlab54400a92015-02-26 18:05:51 -0800154 main.log.info("ONOS CLI did not start up properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -0700155 #main.cleanup()
156 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -0800157 else:
158 main.log.info("Successful CLI startup")
159 startCliResult = main.TRUE
160 case1Result = installResult and uninstallResult and statusResult and startCliResult
161
162 main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
kelvin-onlab8a832582015-01-16 17:06:11 -0800163 utilities.assert_equals( expect=main.TRUE, actual=case1Result,
164 onpass="Set up test environment PASS",
165 onfail="Set up test environment FAIL" )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700166
kelvin-onlab65a72d22015-03-26 13:46:32 -0700167 def CASE20( self, main ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800168 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700169 This test script Loads a new Topology (Att) on CHO setup and balances all switches
kelvin-onlab8a832582015-01-16 17:06:11 -0800170 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800171 import re
172 import time
173 import copy
Hari Krishnab35c6d02015-03-18 11:13:51 -0700174
Hari Krishna22c3d412015-02-17 16:48:12 -0800175 main.numMNswitches = int ( main.params[ 'TOPO1' ][ 'numSwitches' ] )
176 main.numMNlinks = int ( main.params[ 'TOPO1' ][ 'numLinks' ] )
177 main.numMNhosts = int ( main.params[ 'TOPO1' ][ 'numHosts' ] )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700178 main.pingTimeout = 60
kelvin-onlab8a832582015-01-16 17:06:11 -0800179 main.log.report(
Hari Krishnab35c6d02015-03-18 11:13:51 -0700180 "Load Att topology and Balance all Mininet switches across controllers" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800181 main.log.report(
Hari Krishnab35c6d02015-03-18 11:13:51 -0700182 "________________________________________________________________________" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800183 main.case(
184 "Assign and Balance all Mininet switches across controllers" )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700185 main.step( "Stop any previous Mininet network topology" )
186 cliResult = main.TRUE
187 if main.newTopo == main.params['TOPO3']['topo']:
188 stopStatus = main.Mininet1.stopNet( fileName = "topoSpine" )
189
190 main.step( "Start Mininet with Att topology" )
191 main.newTopo = main.params['TOPO1']['topo']
192 startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
193
kelvin-onlab8a832582015-01-16 17:06:11 -0800194 main.step( "Assign switches to controllers" )
Hari Krishna22c3d412015-02-17 16:48:12 -0800195 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
Hari Krishnad97213e2015-01-24 19:30:14 -0800196 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800197 sw=str( i ),
Hari Krishna22c3d412015-02-17 16:48:12 -0800198 count=int( main.numCtrls ),
199 ip1=main.ONOS1_ip,
200 port1=main.ONOS1_port,
201 ip2=main.ONOS2_ip,
202 port2=main.ONOS2_port,
203 ip3=main.ONOS3_ip,
204 port3=main.ONOS3_port,
205 ip4=main.ONOS4_ip,
206 port4=main.ONOS4_port,
207 ip5=main.ONOS5_ip,
208 port5=main.ONOS5_port )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800209
210 switch_mastership = main.TRUE
Hari Krishna22c3d412015-02-17 16:48:12 -0800211 for i in range( 1, ( main.numMNswitches + 1 ) ):
Hari Krishnad97213e2015-01-24 19:30:14 -0800212 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800213 print( "Response is " + str( response ) )
Hari Krishna22c3d412015-02-17 16:48:12 -0800214 if re.search( "tcp:" + main.ONOS1_ip, response ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800215 switch_mastership = switch_mastership and main.TRUE
216 else:
217 switch_mastership = main.FALSE
218
219 if switch_mastership == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800220 main.log.report( "Controller assignment successfull" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800221 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800222 main.log.report( "Controller assignment failed" )
kelvin-onlab77d6c302015-03-31 11:33:32 -0700223
224 """topoFailed = main.FALSE
225 checkCount = 0
226 while(topoFailed == main.FALSE):
227 topology_output = main.ONOScli1.topology()
228 topology_result = main.ONOSbench.getTopology( topology_output )
229 numOnosDevices = topology_result[ 'deviceCount' ]
230 numOnosLinks = topology_result[ 'linkCount' ]
231 if ( ( main.numMNswitches == int(numOnosDevices) ) and ( main.numMNlinks >= int(numOnosLinks) ) ):
232 main.log.info("Att topology is now ready!")
233 break
234 else:
235 main.log.info("Att topology is not ready yet!")
236 checkCount = checkCount + 1
237 time.sleep(2)
238 if checkCount == 10:
239 topoFailed = main.TRUE
240 if topoFailed:
241 main.log.info("Att topology failed to start correctly")
Hari Krishnab35c6d02015-03-18 11:13:51 -0700242 """
kelvin-onlab77d6c302015-03-31 11:33:32 -0700243 time.sleep(15)
244 #Don't balance master for now..
Hari Krishnab35c6d02015-03-18 11:13:51 -0700245 main.step( "Balance devices across controllers" )
246 for i in range( int( main.numCtrls ) ):
247 balanceResult = main.ONOScli1.balanceMasters()
kelvin-onlab8a832582015-01-16 17:06:11 -0800248 # giving some breathing time for ONOS to complete re-balance
Hari Krishnab35c6d02015-03-18 11:13:51 -0700249 time.sleep( 3 )
kelvin-onlab77d6c302015-03-31 11:33:32 -0700250 topology_output = main.ONOScli1.topology()
251 topology_result = main.ONOSbench.getTopology( topology_output )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700252 case2Result = ( switch_mastership and startStatus )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700253 utilities.assert_equals(
254 expect=main.TRUE,
255 actual=case2Result,
256 onpass="Starting new Att topology test PASS",
257 onfail="Starting new Att topology test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800258
kelvin-onlab65a72d22015-03-26 13:46:32 -0700259 def CASE21( self, main ):
260 """
261 This test script Loads a new Topology (Chordal) on CHO setup and balances all switches
262 """
263 import re
264 import time
265 import copy
266
267 main.newTopo = main.params['TOPO2']['topo']
268 main.numMNswitches = int ( main.params[ 'TOPO2' ][ 'numSwitches' ] )
269 main.numMNlinks = int ( main.params[ 'TOPO2' ][ 'numLinks' ] )
270 main.numMNhosts = int ( main.params[ 'TOPO2' ][ 'numHosts' ] )
271 main.pingTimeout = 120
272 main.log.report(
273 "Load Chordal topology and Balance all Mininet switches across controllers" )
274 main.log.report(
275 "________________________________________________________________________" )
276 main.case(
277 "Assign and Balance all Mininet switches across controllers" )
278 main.step( "Stop any previous Mininet network topology" )
kelvin-onlabb9408212015-04-01 13:34:04 -0700279 stopStatus = main.Mininet1.stopNet(fileName = "topoChordal" )
kelvin-onlab65a72d22015-03-26 13:46:32 -0700280 #time.sleep(10)
281 main.step( "Start Mininet with Chordal topology" )
282 startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
283 time.sleep(15)
284 main.step( "Assign switches to controllers" )
285 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
286 main.Mininet1.assignSwController(
287 sw=str( i ),
288 count=int( main.numCtrls ),
289 ip1=main.ONOS1_ip,
290 port1=main.ONOS1_port,
291 ip2=main.ONOS2_ip,
292 port2=main.ONOS2_port,
293 ip3=main.ONOS3_ip,
294 port3=main.ONOS3_port,
295 ip4=main.ONOS4_ip,
296 port4=main.ONOS4_port,
297 ip5=main.ONOS5_ip,
298 port5=main.ONOS5_port )
299
300 switch_mastership = main.TRUE
301 for i in range( 1, ( main.numMNswitches + 1 ) ):
302 response = main.Mininet1.getSwController( "s" + str( i ) )
303 print( "Response is " + str( response ) )
304 if re.search( "tcp:" + main.ONOS1_ip, response ):
305 switch_mastership = switch_mastership and main.TRUE
306 else:
307 switch_mastership = main.FALSE
308
309 if switch_mastership == main.TRUE:
310 main.log.report( "Controller assignment successfull" )
311 else:
312 main.log.report( "Controller assignment failed" )
313 time.sleep( 5 )
314
315 #Don't balance master for now..
316 """
317 main.step( "Balance devices across controllers" )
318 for i in range( int( main.numCtrls ) ):
319 balanceResult = main.ONOScli1.balanceMasters()
320 # giving some breathing time for ONOS to complete re-balance
321 time.sleep( 3 )
322 """
323 case21Result = switch_mastership
324 time.sleep(30)
325 utilities.assert_equals(
326 expect=main.TRUE,
327 actual=case21Result,
328 onpass="Starting new Chordal topology test PASS",
329 onfail="Starting new Chordal topology test FAIL" )
330
331 def CASE22( self, main ):
332 """
333 This test script Loads a new Topology (Spine) on CHO setup and balances all switches
334 """
335 import re
336 import time
337 import copy
338
339 main.newTopo = main.params['TOPO3']['topo']
340 main.numMNswitches = int ( main.params[ 'TOPO3' ][ 'numSwitches' ] )
341 main.numMNlinks = int ( main.params[ 'TOPO3' ][ 'numLinks' ] )
342 main.numMNhosts = int ( main.params[ 'TOPO3' ][ 'numHosts' ] )
343 main.pingTimeout = 400
344
345 main.log.report(
346 "Load Spine and Leaf topology and Balance all Mininet switches across controllers" )
347 main.log.report(
348 "________________________________________________________________________" )
349 # need to wait here for sometime until ONOS bootup
350 main.case(
351 "Assign and Balance all Mininet switches across controllers" )
352 main.step( "Stop any previous Mininet network topology" )
kelvin-onlabb9408212015-04-01 13:34:04 -0700353 stopStatus = main.Mininet1.stopNet(fileName = "topoSpine" )
kelvin-onlab65a72d22015-03-26 13:46:32 -0700354 main.step( "Start Mininet with Spine topology" )
355 startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
356 time.sleep(20)
357 main.step( "Assign switches to controllers" )
358 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
359 main.Mininet1.assignSwController(
360 sw=str( i ),
361 count= 1,
362 ip1=main.ONOS1_ip,
363 port1=main.ONOS1_port,
364 ip2=main.ONOS2_ip,
365 port2=main.ONOS2_port,
366 ip3=main.ONOS3_ip,
367 port3=main.ONOS3_port,
368 ip4=main.ONOS4_ip,
369 port4=main.ONOS4_port,
370 ip5=main.ONOS5_ip,
371 port5=main.ONOS5_port )
372
373 switch_mastership = main.TRUE
374 for i in range( 1, ( main.numMNswitches + 1 ) ):
375 response = main.Mininet1.getSwController( "s" + str( i ) )
376 print( "Response is " + str( response ) )
377 if re.search( "tcp:" + main.ONOS1_ip, response ):
378 switch_mastership = switch_mastership and main.TRUE
379 else:
380 switch_mastership = main.FALSE
381
382 if switch_mastership == main.TRUE:
383 main.log.report( "Controller assignment successfull" )
384 else:
385 main.log.report( "Controller assignment failed" )
386 time.sleep( 5 )
387 """
388 main.step( "Balance devices across controllers" )
389
390 for i in range( int( main.numCtrls ) ):
391 balanceResult = main.ONOScli1.balanceMasters()
392 # giving some breathing time for ONOS to complete re-balance
393 time.sleep( 3 )
394
395 main.step( "Balance devices across controllers" )
396 for i in range( int( main.numCtrls ) ):
397 balanceResult = main.ONOScli1.balanceMasters()
398 # giving some breathing time for ONOS to complete re-balance
399 time.sleep( 3 )
400 """
401 case22Result = switch_mastership
402 time.sleep(30)
403 utilities.assert_equals(
404 expect=main.TRUE,
405 actual=case22Result,
406 onpass="Starting new Spine topology test PASS",
407 onfail="Starting new Spine topology test FAIL" )
408
kelvin-onlab8a832582015-01-16 17:06:11 -0800409 def CASE3( self, main ):
410 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800411 This Test case will be extended to collect and store more data related
412 ONOS state.
kelvin-onlab8a832582015-01-16 17:06:11 -0800413 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800414 import re
415 import copy
Hari Krishna22c3d412015-02-17 16:48:12 -0800416 main.deviceDPIDs = []
417 main.hostMACs = []
418 main.deviceLinks = []
419 main.deviceActiveLinksCount = []
420 main.devicePortsEnabledCount = []
kelvin-onlab54400a92015-02-26 18:05:51 -0800421
kelvin-onlab8a832582015-01-16 17:06:11 -0800422 main.log.report(
423 "Collect and Store topology details from ONOS before running any Tests" )
424 main.log.report(
425 "____________________________________________________________________" )
Hari Krishna5afb4cc2015-03-23 15:35:15 -0700426 main.case( "Collect and Store Topology Details from ONOS" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800427 main.step( "Collect and store current number of switches and links" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800428 topology_output = main.ONOScli1.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800429 topology_result = main.ONOSbench.getTopology( topology_output )
Hari Krishnaef1bd4e2015-03-12 16:55:30 -0700430 numOnosDevices = topology_result[ 'deviceCount' ]
431 numOnosLinks = topology_result[ 'linkCount' ]
Hari Krishnab35c6d02015-03-18 11:13:51 -0700432 topoResult = main.TRUE
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800433
kelvin-onlab54400a92015-02-26 18:05:51 -0800434 if ( ( main.numMNswitches == int(numOnosDevices) ) and ( main.numMNlinks >= int(numOnosLinks) ) ):
Hari Krishna22c3d412015-02-17 16:48:12 -0800435 main.step( "Store Device DPIDs" )
436 for i in range( 1, (main.numMNswitches+1) ):
437 main.deviceDPIDs.append( "of:00000000000000" + format( i, '02x' ) )
438 print "Device DPIDs in Store: \n", str( main.deviceDPIDs )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800439
Hari Krishna22c3d412015-02-17 16:48:12 -0800440 main.step( "Store Host MACs" )
441 for i in range( 1, ( main.numMNhosts + 1 ) ):
442 main.hostMACs.append( "00:00:00:00:00:" + format( i, '02x' ) + "/-1" )
443 print "Host MACs in Store: \n", str( main.hostMACs )
Hari Krishna5afb4cc2015-03-23 15:35:15 -0700444 main.MACsDict = {}
kelvin-onlab65a72d22015-03-26 13:46:32 -0700445 print "Creating dictionary of DPID and HostMacs"
446 for i in range(len(main.hostMACs)):
Hari Krishna5afb4cc2015-03-23 15:35:15 -0700447 main.MACsDict[main.deviceDPIDs[i]] = main.hostMACs[i].split('/')[0]
448 print main.MACsDict
Hari Krishna22c3d412015-02-17 16:48:12 -0800449 main.step( "Collect and store all Devices Links" )
450 linksResult = main.ONOScli1.links( jsonFormat=False )
451 ansi_escape = re.compile( r'\x1b[^m]*m' )
452 linksResult = ansi_escape.sub( '', linksResult )
453 linksResult = linksResult.replace( " links", "" ).replace( "\r\r", "" )
454 linksResult = linksResult.splitlines()
455 linksResult = linksResult[ 1: ]
456 main.deviceLinks = copy.copy( linksResult )
457 print "Device Links Stored: \n", str( main.deviceLinks )
458 # this will be asserted to check with the params provided count of
459 # links
460 print "Length of Links Store", len( main.deviceLinks )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800461
Hari Krishna22c3d412015-02-17 16:48:12 -0800462 main.step( "Collect and store each Device ports enabled Count" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800463 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800464 for i in xrange(1,(main.numMNswitches + 1), int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800465 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800466 for cli in main.CLIs:
kelvin-onlabfbcd82f2015-04-02 12:06:00 -0700467 if i >= len( main.numMNswitches ) + 1:
468 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-onlabfbcd82f2015-04-02 12:06:00 -0700491 if i >= len( main.numMNswitches ) + 1:
492 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-onlab54400a92015-02-26 18:05:51 -0800791 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800792 t = main.Thread(target = cli.getDevicePortsEnabledCount,
793 threadID = main.threadID,
794 name = "getDevicePortsEnabledCount",
795 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800796 t.start()
797 pool.append(t)
798 i = i + 1
799 main.threadID = main.threadID + 1
800 for thread in pool:
801 thread.join()
802 portResult = thread.result
803 portTemp = re.split( r'\t+', portResult )
804 portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
805 devicePortsEnabledCountTemp.append( portCount )
806 print "Device Enabled Port Counts Stored: \n", str( main.devicePortsEnabledCount )
807 time2 = time.time()
808 main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800809 main.log.info (
810 "Device Enabled ports EXPECTED: %s" %
811 str( main.devicePortsEnabledCount ) )
812 main.log.info (
813 "Device Enabled ports ACTUAL: %s" %
814 str( devicePortsEnabledCountTemp ) )
kelvin-onlab54400a92015-02-26 18:05:51 -0800815
Hari Krishna22c3d412015-02-17 16:48:12 -0800816 if ( cmp( main.devicePortsEnabledCount,
817 devicePortsEnabledCountTemp ) == 0 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800818 stepResult1 = main.TRUE
819 else:
820 stepResult1 = main.FALSE
821
kelvin-onlab8a832582015-01-16 17:06:11 -0800822 main.step( "Compare Device active links with reference" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800823 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800824 for i in xrange( 1, ( main.numMNswitches + 1) , int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800825 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800826 for cli in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -0800827 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800828 t = main.Thread(target = cli.getDeviceLinksActiveCount,
829 threadID = main.threadID,
830 name = "getDevicePortsEnabledCount",
831 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800832 t.start()
833 pool.append(t)
834 i = i + 1
835 main.threadID = main.threadID + 1
836 for thread in pool:
837 thread.join()
838 linkCountResult = thread.result
839 linkCountTemp = re.split( r'\t+', linkCountResult )
840 linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
841 deviceActiveLinksCountTemp.append( linkCount )
842 print "Device Active Links Count Stored: \n", str( main.deviceActiveLinksCount )
843 time2 = time.time()
844 main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800845 main.log.info (
846 "Device Active links EXPECTED: %s" %
847 str( main.deviceActiveLinksCount ) )
848 main.log.info (
849 "Device Active links ACTUAL: %s" % str( deviceActiveLinksCountTemp ) )
850 if ( cmp( main.deviceActiveLinksCount, deviceActiveLinksCountTemp ) == 0 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800851 stepResult2 = main.TRUE
852 else:
853 stepResult2 = main.FALSE
854
kelvin-onlab8a832582015-01-16 17:06:11 -0800855 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800856 place holder for comparing devices, hosts, paths and intents if required.
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800857 Links and ports data would be incorrect with out devices anyways.
kelvin-onlab8a832582015-01-16 17:06:11 -0800858 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800859 case5Result = ( stepResult1 and stepResult2 )
860 utilities.assert_equals( expect=main.TRUE, actual=case5Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800861 onpass="Compare Topology test PASS",
862 onfail="Compare Topology test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800863
kelvin-onlab65a72d22015-03-26 13:46:32 -0700864 def CASE60( self ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800865 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700866 Install 300 host intents and verify ping all (Att Topology)
kelvin-onlab8a832582015-01-16 17:06:11 -0800867 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700868 main.log.report( "Add 300 host intents and verify pingall (Att Topology)" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800869 main.log.report( "_______________________________________" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800870 import itertools
Hari Krishnaef1bd4e2015-03-12 16:55:30 -0700871 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800872 main.case( "Install 300 host intents" )
873 main.step( "Add host Intents" )
874 intentResult = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800875 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800876
kelvin-onlab54400a92015-02-26 18:05:51 -0800877 intentIdList = []
878 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800879 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800880 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800881 for cli in main.CLIs:
882 if i >= len( hostCombos ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800883 break
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800884 t = main.Thread( target=cli.addHostIntent,
885 threadID=main.threadID,
kelvin-onlab54400a92015-02-26 18:05:51 -0800886 name="addHostIntent",
887 args=[hostCombos[i][0],hostCombos[i][1]])
888 pool.append(t)
889 t.start()
890 i = i + 1
891 main.threadID = main.threadID + 1
892 for thread in pool:
893 thread.join()
894 intentIdList.append(thread.result)
895 time2 = time.time()
kelvin-onlabadfc8db2015-03-24 15:52:48 -0700896 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
897
kelvin-onlab54400a92015-02-26 18:05:51 -0800898 intentResult = main.TRUE
899 intentsJson = main.ONOScli2.intents()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800900 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
kelvin-onlab54400a92015-02-26 18:05:51 -0800901 intentsJson = intentsJson)
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800902 print getIntentStateResult
Hari Krishnab35c6d02015-03-18 11:13:51 -0700903 # Takes awhile for all the onos to get the intents
Hari Krishnaef1bd4e2015-03-12 16:55:30 -0700904 time.sleep(30)
kelvin-onlab8a832582015-01-16 17:06:11 -0800905 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800906 pingResult = main.FALSE
907 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -0700908 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800909 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800910 timeDiff = round( ( time2 - time1 ), 2 )
911 main.log.report(
912 "Time taken for Ping All: " +
913 str( timeDiff ) +
914 " seconds" )
915 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
916 onpass="PING ALL PASS",
917 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800918
kelvin-onlab65a72d22015-03-26 13:46:32 -0700919 case60Result = ( intentResult and pingResult )
kelvin-onlab54400a92015-02-26 18:05:51 -0800920
kelvin-onlab8a832582015-01-16 17:06:11 -0800921 utilities.assert_equals(
922 expect=main.TRUE,
kelvin-onlab65a72d22015-03-26 13:46:32 -0700923 actual=case60Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800924 onpass="Install 300 Host Intents and Ping All test PASS",
925 onfail="Install 300 Host Intents and Ping All test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800926
kelvin-onlab65a72d22015-03-26 13:46:32 -0700927 def CASE61( self ):
928 """
929 Install 600 host intents and verify ping all for Chordal Topology
930 """
931 main.log.report( "Add 600 host intents and verify pingall (Chordal Topo)" )
932 main.log.report( "_______________________________________" )
933 import itertools
934
935 main.case( "Install 600 host intents" )
936 main.step( "Add host Intents" )
937 intentResult = main.TRUE
938 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
939
940 intentIdList = []
941 time1 = time.time()
942
943 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
944 pool = []
945 for cli in main.CLIs:
946 if i >= len( hostCombos ):
947 break
948 t = main.Thread( target=cli.addHostIntent,
949 threadID=main.threadID,
950 name="addHostIntent",
951 args=[hostCombos[i][0],hostCombos[i][1]])
952 pool.append(t)
953 t.start()
954 i = i + 1
955 main.threadID = main.threadID + 1
956 for thread in pool:
957 thread.join()
958 intentIdList.append(thread.result)
959 time2 = time.time()
960 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
961 intentResult = main.TRUE
962 intentsJson = main.ONOScli2.intents()
963 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
964 intentsJson = intentsJson)
965 print getIntentStateResult
966
967 main.step( "Verify Ping across all hosts" )
968 pingResult = main.FALSE
969 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -0700970 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin-onlab65a72d22015-03-26 13:46:32 -0700971 time2 = time.time()
972 timeDiff = round( ( time2 - time1 ), 2 )
973 main.log.report(
974 "Time taken for Ping All: " +
975 str( timeDiff ) +
976 " seconds" )
977 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
978 onpass="PING ALL PASS",
979 onfail="PING ALL FAIL" )
980
981 case14Result = ( intentResult and pingResult )
982
983 utilities.assert_equals(
984 expect=main.TRUE,
985 actual=case14Result,
986 onpass="Install 300 Host Intents and Ping All test PASS",
987 onfail="Install 300 Host Intents and Ping All test FAIL" )
988
989 def CASE62( self ):
990 """
991 Install 2278 host intents and verify ping all for Spine Topology
992 """
993 main.log.report( "Add 2278 host intents and verify pingall (Spine Topo)" )
994 main.log.report( "_______________________________________" )
995 import itertools
996
997 main.case( "Install 2278 host intents" )
998 main.step( "Add host Intents" )
999 intentResult = main.TRUE
1000 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
1001 main.pingTimeout = 300
1002 intentIdList = []
1003 time1 = time.time()
1004 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
1005 pool = []
1006 for cli in main.CLIs:
1007 if i >= len( hostCombos ):
1008 break
1009 t = main.Thread( target=cli.addHostIntent,
1010 threadID=main.threadID,
1011 name="addHostIntent",
1012 args=[hostCombos[i][0],hostCombos[i][1]])
1013 pool.append(t)
1014 t.start()
1015 i = i + 1
1016 main.threadID = main.threadID + 1
1017 for thread in pool:
1018 thread.join()
1019 intentIdList.append(thread.result)
1020 time2 = time.time()
1021 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
1022 intentResult = main.TRUE
1023 intentsJson = main.ONOScli2.intents()
1024 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1025 intentsJson = intentsJson)
1026 print getIntentStateResult
1027
1028 main.step( "Verify Ping across all hosts" )
1029 pingResult = main.FALSE
1030 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001031 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin-onlab65a72d22015-03-26 13:46:32 -07001032 time2 = time.time()
1033 timeDiff = round( ( time2 - time1 ), 2 )
1034 main.log.report(
1035 "Time taken for Ping All: " +
1036 str( timeDiff ) +
1037 " seconds" )
1038 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1039 onpass="PING ALL PASS",
1040 onfail="PING ALL FAIL" )
1041
1042 case15Result = ( intentResult and pingResult )
1043
1044 utilities.assert_equals(
1045 expect=main.TRUE,
1046 actual=case15Result,
1047 onpass="Install 2278 Host Intents and Ping All test PASS",
1048 onfail="Install 2278 Host Intents and Ping All test FAIL" )
1049
kelvin-onlab8a832582015-01-16 17:06:11 -08001050 def CASE70( self, main ):
1051 """
Hari Krishnab35c6d02015-03-18 11:13:51 -07001052 Randomly bring some core links down and verify ping all ( Host Intents-Att Topo)
kelvin-onlab8a832582015-01-16 17:06:11 -08001053 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001054 import random
Hari Krishna22c3d412015-02-17 16:48:12 -08001055 main.randomLink1 = []
1056 main.randomLink2 = []
1057 main.randomLink3 = []
kelvin-onlab65a72d22015-03-26 13:46:32 -07001058 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1059 link1End2 = main.params[ 'ATTCORELINKS' ][ 'linkS3b' ].split( ',' )
1060 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1061 link2End2 = main.params[ 'ATTCORELINKS' ][ 'linkS14b' ].split( ',' )
1062 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
1063 link3End2 = main.params[ 'ATTCORELINKS' ][ 'linkS18b' ].split( ',' )
1064 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001065 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001066
Hari Krishnab35c6d02015-03-18 11:13:51 -07001067 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Att Topo)" )
1068 main.log.report( "___________________________________________________________________________" )
Hari Krishnad97213e2015-01-24 19:30:14 -08001069 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
1070 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001071 if ( int( switchLinksToToggle ) ==
1072 0 or int( switchLinksToToggle ) > 5 ):
Hari Krishna46997e02015-01-27 11:23:07 -08001073 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 -07001074 #main.cleanup()
1075 #main.exit()
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001076 else:
Hari Krishnad97213e2015-01-24 19:30:14 -08001077 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 -08001078
kelvin-onlab8a832582015-01-16 17:06:11 -08001079 main.step( "Cut links on Core devices using user provided range" )
Hari Krishna22c3d412015-02-17 16:48:12 -08001080 main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
1081 main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
1082 main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001083 for i in range( int( switchLinksToToggle ) ):
1084 main.Mininet1.link(
1085 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001086 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001087 OPTION="down" )
1088 main.Mininet1.link(
1089 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001090 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001091 OPTION="down" )
1092 main.Mininet1.link(
1093 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001094 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001095 OPTION="down" )
1096 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001097
1098 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001099 linkDown = main.ONOSbench.checkStatus(
Hari Krishna22c3d412015-02-17 16:48:12 -08001100 topology_output, main.numMNswitches, str(
1101 int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001102 utilities.assert_equals(
1103 expect=main.TRUE,
1104 actual=linkDown,
1105 onpass="Link Down discovered properly",
1106 onfail="Link down was not discovered in " +
1107 str( link_sleep ) +
1108 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001109
kelvin-onlab8a832582015-01-16 17:06:11 -08001110 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001111 pingResultLinkDown = main.FALSE
1112 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001113 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001114 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001115 timeDiff = round( ( time2 - time1 ), 2 )
1116 main.log.report(
1117 "Time taken for Ping All: " +
1118 str( timeDiff ) +
1119 " seconds" )
1120 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1121 onpass="PING ALL PASS",
1122 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001123
Hari Krishna22c3d412015-02-17 16:48:12 -08001124 caseResult70 = linkDown and pingResultLinkDown
1125 utilities.assert_equals( expect=main.TRUE, actual=caseResult70,
kelvin-onlab8a832582015-01-16 17:06:11 -08001126 onpass="Random Link cut Test PASS",
1127 onfail="Random Link cut Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001128
kelvin-onlab8a832582015-01-16 17:06:11 -08001129 def CASE80( self, main ):
1130 """
Hari Krishnab35c6d02015-03-18 11:13:51 -07001131 Bring the core links up that are down and verify ping all ( Host Intents-Att Topo )
kelvin-onlab8a832582015-01-16 17:06:11 -08001132 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001133 import random
kelvin-onlab65a72d22015-03-26 13:46:32 -07001134 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1135 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1136 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001137 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001138 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001139
kelvin-onlab8a832582015-01-16 17:06:11 -08001140 main.log.report(
Hari Krishnab35c6d02015-03-18 11:13:51 -07001141 "Bring the core links up that are down and verify ping all (Host Intents-Att Topo" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001142 main.log.report(
1143 "__________________________________________________________________" )
1144 main.case(
1145 "Host intents - Bring the core links up that are down and verify ping all" )
1146 main.step( "Bring randomly cut links on Core devices up" )
1147 for i in range( int( switchLinksToToggle ) ):
1148 main.Mininet1.link(
1149 END1=link1End1,
kelvin-onlab54400a92015-02-26 18:05:51 -08001150 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001151 OPTION="up" )
1152 main.Mininet1.link(
1153 END1=link2End1,
kelvin-onlab54400a92015-02-26 18:05:51 -08001154 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001155 OPTION="up" )
1156 main.Mininet1.link(
1157 END1=link3End1,
kelvin-onlab54400a92015-02-26 18:05:51 -08001158 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001159 OPTION="up" )
1160 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001161
1162 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001163 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -08001164 topology_output,
Hari Krishna22c3d412015-02-17 16:48:12 -08001165 main.numMNswitches,
1166 str( main.numMNlinks ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001167 utilities.assert_equals(
1168 expect=main.TRUE,
1169 actual=linkUp,
1170 onpass="Link up discovered properly",
1171 onfail="Link up was not discovered in " +
1172 str( link_sleep ) +
1173 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001174
kelvin-onlab8a832582015-01-16 17:06:11 -08001175 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001176 pingResultLinkUp = main.FALSE
1177 time1 = time.time()
1178 pingResultLinkUp = main.Mininet1.pingall()
1179 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001180 timeDiff = round( ( time2 - time1 ), 2 )
1181 main.log.report(
1182 "Time taken for Ping All: " +
1183 str( timeDiff ) +
1184 " seconds" )
1185 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1186 onpass="PING ALL PASS",
1187 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001188
Hari Krishna22c3d412015-02-17 16:48:12 -08001189 caseResult80 = linkUp and pingResultLinkUp
1190 utilities.assert_equals( expect=main.TRUE, actual=caseResult80,
kelvin-onlab8a832582015-01-16 17:06:11 -08001191 onpass="Link Up Test PASS",
1192 onfail="Link Up Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001193
kelvin-onlab8a832582015-01-16 17:06:11 -08001194 def CASE71( self, main ):
1195 """
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001196 Randomly bring some core links down and verify ping all ( Point Intents-Att Topo)
kelvin-onlab8a832582015-01-16 17:06:11 -08001197 """
kelvin8ec71442015-01-15 16:57:00 -08001198 import random
Hari Krishna22c3d412015-02-17 16:48:12 -08001199 main.randomLink1 = []
1200 main.randomLink2 = []
1201 main.randomLink3 = []
kelvin-onlab65a72d22015-03-26 13:46:32 -07001202 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1203 link1End2 = main.params[ 'ATTCORELINKS' ][ 'linkS3b' ].split( ',' )
1204 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1205 link2End2 = main.params[ 'ATTCORELINKS' ][ 'linkS14b' ].split( ',' )
1206 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
1207 link3End2 = main.params[ 'ATTCORELINKS' ][ 'linkS18b' ].split( ',' )
1208 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001209 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin8ec71442015-01-15 16:57:00 -08001210
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001211 main.log.report( "Randomly bring some core links down and verify ping all (Point Intents-Att Topo)" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001212 main.log.report( "___________________________________________________________________________" )
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001213 main.case( "Point intents - Randomly bring some core links down and verify ping all" )
Hari Krishnad97213e2015-01-24 19:30:14 -08001214 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001215 if ( int( switchLinksToToggle ) ==
1216 0 or int( switchLinksToToggle ) > 5 ):
kelvin-onlab65a72d22015-03-26 13:46:32 -07001217 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 -07001218 #main.cleanup()
1219 #main.exit()
kelvin8ec71442015-01-15 16:57:00 -08001220 else:
kelvin-onlab65a72d22015-03-26 13:46:32 -07001221 main.log.info( "User provided Core switch links range to toggle is correct, proceeding to run the test" )
kelvin8ec71442015-01-15 16:57:00 -08001222
kelvin-onlab8a832582015-01-16 17:06:11 -08001223 main.step( "Cut links on Core devices using user provided range" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001224 main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
1225 main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
1226 main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001227 for i in range( int( switchLinksToToggle ) ):
1228 main.Mininet1.link(
1229 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001230 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001231 OPTION="down" )
1232 main.Mininet1.link(
1233 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001234 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001235 OPTION="down" )
1236 main.Mininet1.link(
1237 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001238 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001239 OPTION="down" )
1240 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -08001241
1242 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001243 linkDown = main.ONOSbench.checkStatus(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001244 topology_output, main.numMNswitches, str(
1245 int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001246 utilities.assert_equals(
1247 expect=main.TRUE,
1248 actual=linkDown,
1249 onpass="Link Down discovered properly",
1250 onfail="Link down was not discovered in " +
1251 str( link_sleep ) +
1252 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -08001253
kelvin-onlab8a832582015-01-16 17:06:11 -08001254 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -08001255 pingResultLinkDown = main.FALSE
1256 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001257 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin8ec71442015-01-15 16:57:00 -08001258 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001259 timeDiff = round( ( time2 - time1 ), 2 )
1260 main.log.report(
1261 "Time taken for Ping All: " +
1262 str( timeDiff ) +
1263 " seconds" )
1264 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1265 onpass="PING ALL PASS",
1266 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001267
kelvin-onlab65a72d22015-03-26 13:46:32 -07001268 caseResult71 = linkDown and pingResultLinkDown
1269 utilities.assert_equals( expect=main.TRUE, actual=caseResult71,
kelvin-onlab8a832582015-01-16 17:06:11 -08001270 onpass="Random Link cut Test PASS",
1271 onfail="Random Link cut Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001272
kelvin-onlab8a832582015-01-16 17:06:11 -08001273 def CASE81( self, main ):
1274 """
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001275 Bring the core links up that are down and verify ping all ( Point Intents-Att Topo )
kelvin-onlab8a832582015-01-16 17:06:11 -08001276 """
kelvin8ec71442015-01-15 16:57:00 -08001277 import random
kelvin-onlab65a72d22015-03-26 13:46:32 -07001278 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1279 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1280 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001281 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001282 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
kelvin8ec71442015-01-15 16:57:00 -08001283
kelvin-onlab8a832582015-01-16 17:06:11 -08001284 main.log.report(
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001285 "Bring the core links up that are down and verify ping all ( Point Intents-Att Topo" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001286 main.log.report(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001287 "__________________________________________________________________" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001288 main.case(
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001289 "Point intents - Bring the core links up that are down and verify ping all" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001290 main.step( "Bring randomly cut links on Core devices up" )
1291 for i in range( int( switchLinksToToggle ) ):
1292 main.Mininet1.link(
1293 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001294 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001295 OPTION="up" )
1296 main.Mininet1.link(
1297 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001298 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001299 OPTION="up" )
1300 main.Mininet1.link(
1301 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001302 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001303 OPTION="up" )
1304 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -08001305
1306 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001307 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -08001308 topology_output,
Hari Krishna22c3d412015-02-17 16:48:12 -08001309 main.numMNswitches,
1310 str( main.numMNlinks ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001311 utilities.assert_equals(
1312 expect=main.TRUE,
1313 actual=linkUp,
1314 onpass="Link up discovered properly",
1315 onfail="Link up was not discovered in " +
1316 str( link_sleep ) +
1317 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -08001318
kelvin-onlab8a832582015-01-16 17:06:11 -08001319 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -08001320 pingResultLinkUp = main.FALSE
1321 time1 = time.time()
kelvin-onlab77d6c302015-03-31 11:33:32 -07001322 pingResultLinkUp = main.Mininet1.pingall(timeout = main.pingTimeout)
kelvin8ec71442015-01-15 16:57:00 -08001323 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001324 timeDiff = round( ( time2 - time1 ), 2 )
1325 main.log.report(
1326 "Time taken for Ping All: " +
1327 str( timeDiff ) +
1328 " seconds" )
1329 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1330 onpass="PING ALL PASS",
1331 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001332
Hari Krishna22c3d412015-02-17 16:48:12 -08001333 caseResult81 = linkUp and pingResultLinkUp
1334 utilities.assert_equals( expect=main.TRUE, actual=caseResult81,
kelvin-onlab8a832582015-01-16 17:06:11 -08001335 onpass="Link Up Test PASS",
1336 onfail="Link Up Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001337
Hari Krishnab35c6d02015-03-18 11:13:51 -07001338 def CASE72( self, main ):
1339 """
1340 Randomly bring some links down and verify ping all ( Host Intents-Chordal Topo)
1341 """
1342 import random
1343 import itertools
1344 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1345
1346 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Chordal Topo)" )
1347 main.log.report( "___________________________________________________________________________" )
1348 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
1349 switches = []
1350 switchesComb = []
1351 for i in range( main.numMNswitches ):
1352 switches.append('s%d'%(i+1))
1353 switchesLinksComb = list(itertools.combinations(switches,2))
1354 main.randomLinks = random.sample(switchesLinksComb, 5 )
1355 print main.randomLinks
1356 main.step( "Cut links on random devices" )
1357
1358 for switch in main.randomLinks:
1359 main.Mininet1.link(
1360 END1=switch[0],
1361 END2=switch[1],
1362 OPTION="down")
1363 time.sleep( link_sleep )
1364
1365 topology_output = main.ONOScli2.topology()
1366 linkDown = main.ONOSbench.checkStatus(
1367 topology_output, main.numMNswitches, str(
1368 int( main.numMNlinks ) - 5 * 2 ) )
1369 utilities.assert_equals(
1370 expect=main.TRUE,
1371 actual=linkDown,
1372 onpass="Link Down discovered properly",
1373 onfail="Link down was not discovered in " +
1374 str( link_sleep ) +
1375 " seconds" )
1376
1377 main.step( "Verify Ping across all hosts" )
1378 pingResultLinkDown = main.FALSE
1379 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001380 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001381 time2 = time.time()
1382 timeDiff = round( ( time2 - time1 ), 2 )
1383 main.log.report(
1384 "Time taken for Ping All: " +
1385 str( timeDiff ) +
1386 " seconds" )
1387 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1388 onpass="PING ALL PASS",
1389 onfail="PING ALL FAIL" )
1390
kelvin-onlab65a72d22015-03-26 13:46:32 -07001391 caseResult71 = pingResultLinkDown
1392 utilities.assert_equals( expect=main.TRUE, actual=caseResult71,
Hari Krishnab35c6d02015-03-18 11:13:51 -07001393 onpass="Random Link cut Test PASS",
1394 onfail="Random Link cut Test FAIL" )
1395
1396 def CASE82( self, main ):
1397 """
1398 Bring the core links up that are down and verify ping all ( Host Intents Chordal Topo )
1399 """
1400 import random
1401 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1402
1403 main.log.report(
1404 "Bring the core links up that are down and verify ping all (Host Intents-Chordal Topo" )
1405 main.log.report(
1406 "__________________________________________________________________" )
1407 main.case(
1408 "Host intents - Bring the core links up that are down and verify ping all" )
1409 main.step( "Bring randomly cut links on devices up" )
1410
1411 for switch in main.randomLinks:
1412 main.Mininet1.link(
1413 END1=switch[0],
1414 END2=switch[1],
1415 OPTION="up")
1416
1417 time.sleep( link_sleep )
1418
1419 topology_output = main.ONOScli2.topology()
1420 linkUp = main.ONOSbench.checkStatus(
1421 topology_output,
1422 main.numMNswitches,
1423 str( main.numMNlinks ) )
1424 utilities.assert_equals(
1425 expect=main.TRUE,
1426 actual=linkUp,
1427 onpass="Link up discovered properly",
1428 onfail="Link up was not discovered in " +
1429 str( link_sleep ) +
1430 " seconds" )
1431
1432 main.step( "Verify Ping across all hosts" )
1433 pingResultLinkUp = main.FALSE
1434 time1 = time.time()
kelvin-onlab77d6c302015-03-31 11:33:32 -07001435 pingResultLinkUp = main.Mininet1.pingall(timeout = main.pingTimeout)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001436 time2 = time.time()
1437 timeDiff = round( ( time2 - time1 ), 2 )
1438 main.log.report(
1439 "Time taken for Ping All: " +
1440 str( timeDiff ) +
1441 " seconds" )
1442 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1443 onpass="PING ALL PASS",
1444 onfail="PING ALL FAIL" )
1445
1446 caseResult82 = linkUp and pingResultLinkUp
1447 utilities.assert_equals( expect=main.TRUE, actual=caseResult82,
1448 onpass="Link Up Test PASS",
1449 onfail="Link Up Test FAIL" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001450
Hari Krishnab35c6d02015-03-18 11:13:51 -07001451 def CASE73( self, main ):
1452 """
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001453 Randomly bring some links down and verify ping all ( Point Intents-Chordal Topo)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001454 """
1455 import random
kelvin-onlab65a72d22015-03-26 13:46:32 -07001456 import itertools
Hari Krishnab35c6d02015-03-18 11:13:51 -07001457 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001458
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001459 main.log.report( "Randomly bring some core links down and verify ping all ( Point Intents-Chordal Topo)" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001460 main.log.report( "___________________________________________________________________________" )
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001461 main.case( "Point intents - Randomly bring some core links down and verify ping all" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001462 switches = []
1463 switchesComb = []
1464 for i in range( main.numMNswitches ):
1465 switches.append('s%d'%(i+1))
1466 switchesLinksComb = list(itertools.combinations(switches,2))
1467 main.randomLinks = random.sample(switchesLinksComb, 5 )
1468 print main.randomLinks
1469 main.step( "Cut links on random devices" )
1470
1471 for switch in main.randomLinks:
Hari Krishnab35c6d02015-03-18 11:13:51 -07001472 main.Mininet1.link(
1473 END1=switch[0],
1474 END2=switch[1],
kelvin-onlab65a72d22015-03-26 13:46:32 -07001475 OPTION="down")
Hari Krishnab35c6d02015-03-18 11:13:51 -07001476 time.sleep( link_sleep )
1477
1478 topology_output = main.ONOScli2.topology()
1479 linkDown = main.ONOSbench.checkStatus(
1480 topology_output, main.numMNswitches, str(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001481 int( main.numMNlinks ) - 5 * 2 ) )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001482 utilities.assert_equals(
1483 expect=main.TRUE,
1484 actual=linkDown,
1485 onpass="Link Down discovered properly",
1486 onfail="Link down was not discovered in " +
1487 str( link_sleep ) +
1488 " seconds" )
1489
1490 main.step( "Verify Ping across all hosts" )
1491 pingResultLinkDown = main.FALSE
1492 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001493 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001494 time2 = time.time()
1495 timeDiff = round( ( time2 - time1 ), 2 )
1496 main.log.report(
1497 "Time taken for Ping All: " +
1498 str( timeDiff ) +
1499 " seconds" )
1500 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1501 onpass="PING ALL PASS",
1502 onfail="PING ALL FAIL" )
1503
kelvin-onlab65a72d22015-03-26 13:46:32 -07001504 caseResult73 = pingResultLinkDown
Hari Krishnab35c6d02015-03-18 11:13:51 -07001505 utilities.assert_equals( expect=main.TRUE, actual=caseResult73,
1506 onpass="Random Link cut Test PASS",
1507 onfail="Random Link cut Test FAIL" )
1508
1509 def CASE83( self, main ):
1510 """
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001511 Bring the core links up that are down and verify ping all ( Point Intents Chordal Topo )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001512 """
1513 import random
Hari Krishnab35c6d02015-03-18 11:13:51 -07001514 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001515
Hari Krishnab35c6d02015-03-18 11:13:51 -07001516 main.log.report(
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001517 "Bring the core links up that are down and verify ping all ( Point Intents-Chordal Topo" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001518 main.log.report(
1519 "__________________________________________________________________" )
1520 main.case(
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001521 "Point intents - Bring the core links up that are down and verify ping all" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001522 main.step( "Bring randomly cut links on devices up" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001523
kelvin-onlab65a72d22015-03-26 13:46:32 -07001524 for switch in main.randomLinks:
Hari Krishnab35c6d02015-03-18 11:13:51 -07001525 main.Mininet1.link(
1526 END1=switch[0],
1527 END2=switch[1],
1528 OPTION="up")
kelvin-onlab65a72d22015-03-26 13:46:32 -07001529
Hari Krishnab35c6d02015-03-18 11:13:51 -07001530 time.sleep( link_sleep )
1531
1532 topology_output = main.ONOScli2.topology()
1533 linkUp = main.ONOSbench.checkStatus(
1534 topology_output,
1535 main.numMNswitches,
1536 str( main.numMNlinks ) )
1537 utilities.assert_equals(
1538 expect=main.TRUE,
1539 actual=linkUp,
1540 onpass="Link up discovered properly",
1541 onfail="Link up was not discovered in " +
1542 str( link_sleep ) +
1543 " seconds" )
1544
1545 main.step( "Verify Ping across all hosts" )
1546 pingResultLinkUp = main.FALSE
1547 time1 = time.time()
kelvin-onlab77d6c302015-03-31 11:33:32 -07001548 pingResultLinkUp = main.Mininet1.pingall(timeout = main.pingTimeout)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001549 time2 = time.time()
1550 timeDiff = round( ( time2 - time1 ), 2 )
1551 main.log.report(
1552 "Time taken for Ping All: " +
1553 str( timeDiff ) +
1554 " seconds" )
1555 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1556 onpass="PING ALL PASS",
1557 onfail="PING ALL FAIL" )
1558
1559 caseResult83 = linkUp and pingResultLinkUp
1560 utilities.assert_equals( expect=main.TRUE, actual=caseResult83,
1561 onpass="Link Up Test PASS",
1562 onfail="Link Up Test FAIL" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001563
1564 def CASE74( self, main ):
1565 """
1566 Randomly bring some core links down and verify ping all ( Host Intents-Spine Topo)
1567 """
1568 import random
1569 main.randomLink1 = []
1570 main.randomLink2 = []
1571 main.randomLink3 = []
1572 main.randomLink4 = []
1573 link1End1 = main.params[ 'SPINECORELINKS' ][ 'linkS9' ]
1574 link1End2top = main.params[ 'SPINECORELINKS' ][ 'linkS9top' ].split( ',' )
1575 link1End2bot = main.params[ 'SPINECORELINKS' ][ 'linkS9bot' ].split( ',' )
1576 link2End1 = main.params[ 'SPINECORELINKS' ][ 'linkS10' ]
1577 link2End2top = main.params[ 'SPINECORELINKS' ][ 'linkS10top' ].split( ',' )
1578 link2End2bot = main.params[ 'SPINECORELINKS' ][ 'linkS10bot' ].split( ',' )
1579 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1580 main.pingTimeout = 400
1581
1582 main.log.report( "Bring some core links down and verify ping all (Host Intents-Spine Topo)" )
1583 main.log.report( "___________________________________________________________________________" )
1584
1585 linkIndex = range(4)
1586 linkIndexS9 = random.sample(linkIndex,1)[0]
1587 linkIndex.remove(linkIndexS9)
1588 linkIndexS10 = random.sample(linkIndex,1)[0]
1589 main.randomLink1 = link1End2top[linkIndexS9]
1590 main.randomLink2 = link2End2top[linkIndexS10]
1591 main.randomLink3 = random.sample(link1End2bot,1)[0]
1592 main.randomLink4 = random.sample(link2End2bot,1)[0]
kelvin-onlab77d6c302015-03-31 11:33:32 -07001593 # main.Mininet1.link( END1=link1End1, END2=main.randomLink1, OPTION="down" )
1594 # main.Mininet1.link( END1=link2End1, END2=main.randomLink2, OPTION="down" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001595 main.Mininet1.link( END1=link1End1, END2=main.randomLink3, OPTION="down" )
1596 main.Mininet1.link( END1=link2End1, END2=main.randomLink4, OPTION="down" )
kelvin-onlabd878fc22015-03-27 13:33:41 -07001597
kelvin-onlab65a72d22015-03-26 13:46:32 -07001598 time.sleep( link_sleep )
1599
1600 topology_output = main.ONOScli2.topology()
1601 linkDown = main.ONOSbench.checkStatus(
1602 topology_output, main.numMNswitches, str(
1603 int( main.numMNlinks ) - 8 ))
1604 utilities.assert_equals(
1605 expect=main.TRUE,
1606 actual=linkDown,
1607 onpass="Link Down discovered properly",
1608 onfail="Link down was not discovered in " +
1609 str( link_sleep ) +
1610 " seconds" )
1611
1612 main.step( "Verify Ping across all hosts" )
1613 pingResultLinkDown = main.FALSE
1614 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001615 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin-onlab65a72d22015-03-26 13:46:32 -07001616 time2 = time.time()
1617 timeDiff = round( ( time2 - time1 ), 2 )
1618 main.log.report(
1619 "Time taken for Ping All: " +
1620 str( timeDiff ) +
1621 " seconds" )
1622 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1623 onpass="PING ALL PASS",
1624 onfail="PING ALL FAIL" )
1625
1626 caseResult74 = linkDown and pingResultLinkDown
1627 utilities.assert_equals( expect=main.TRUE, actual=caseResult74,
1628 onpass="Random Link cut Test PASS",
1629 onfail="Random Link cut Test FAIL" )
1630
1631 def CASE84( self, main ):
1632 """
1633 Bring the core links up that are down and verify ping all ( Host Intents-Spine Topo )
1634 """
1635 import random
1636 link1End1 = main.params[ 'SPINECORELINKS' ][ 'linkS9' ]
1637 link2End1 = main.params[ 'SPINECORELINKS' ][ 'linkS10' ]
1638 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1639 main.log.report(
1640 "Bring the core links up that are down and verify ping all (Host Intents-Spine Topo" )
1641 main.log.report(
1642 "__________________________________________________________________" )
1643 main.case(
1644 "Host intents - Bring the core links up that are down and verify ping all" )
1645
kelvin-onlab77d6c302015-03-31 11:33:32 -07001646 #main.Mininet1.link( END1=link1End1, END2=main.randomLink1, OPTION="up" )
1647 #main.Mininet1.link( END1=link2End1, END2=main.randomLink2, OPTION="up" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001648 main.Mininet1.link( END1=link1End1, END2=main.randomLink3, OPTION="up" )
1649 main.Mininet1.link( END1=link2End1, END2=main.randomLink4, OPTION="up" )
1650
1651 time.sleep( link_sleep )
1652 topology_output = main.ONOScli2.topology()
1653 linkUp = main.ONOSbench.checkStatus(
1654 topology_output,
1655 main.numMNswitches,
1656 str( main.numMNlinks ) )
1657 utilities.assert_equals(
1658 expect=main.TRUE,
1659 actual=linkUp,
1660 onpass="Link up discovered properly",
1661 onfail="Link up was not discovered in " +
1662 str( link_sleep ) +
1663 " seconds" )
1664
1665 main.step( "Verify Ping across all hosts" )
1666 pingResultLinkUp = main.FALSE
1667 time1 = time.time()
kelvin-onlab77d6c302015-03-31 11:33:32 -07001668 pingResultLinkUp = main.Mininet1.pingall(timeout = main.pingTimeout)
kelvin-onlab65a72d22015-03-26 13:46:32 -07001669 time2 = time.time()
1670 timeDiff = round( ( time2 - time1 ), 2 )
1671 main.log.report(
1672 "Time taken for Ping All: " +
1673 str( timeDiff ) +
1674 " seconds" )
1675 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1676 onpass="PING ALL PASS",
1677 onfail="PING ALL FAIL" )
1678
1679 caseResult84 = linkUp and pingResultLinkUp
1680 utilities.assert_equals( expect=main.TRUE, actual=caseResult84,
1681 onpass="Link Up Test PASS",
1682 onfail="Link Up Test FAIL" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001683
1684 def CASE90( self ):
kelvin-onlab8a832582015-01-16 17:06:11 -08001685 """
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001686 Install 600 point intents and verify ping all (Att Topology)
kelvin-onlab8a832582015-01-16 17:06:11 -08001687 """
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001688 main.log.report( "Add 600 point intents and verify pingall (Att Topology)" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001689 main.log.report( "_______________________________________" )
1690 import itertools
1691 import time
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001692 main.case( "Install 600 point intents" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001693 main.step( "Add point Intents" )
1694 intentResult = main.TRUE
1695 deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) )
1696
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001697 intentIdList = []
Hari Krishnab35c6d02015-03-18 11:13:51 -07001698 time1 = time.time()
Hari Krishnab35c6d02015-03-18 11:13:51 -07001699 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1700 pool = []
1701 for cli in main.CLIs:
1702 if i >= len( deviceCombos ):
1703 break
1704 t = main.Thread( target=cli.addPointIntent,
1705 threadID=main.threadID,
1706 name="addPointIntent",
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001707 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
Hari Krishnab35c6d02015-03-18 11:13:51 -07001708 pool.append(t)
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001709 #time.sleep(1)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001710 t.start()
1711 i = i + 1
1712 main.threadID = main.threadID + 1
1713 for thread in pool:
1714 thread.join()
1715 intentIdList.append(thread.result)
1716 time2 = time.time()
1717 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1718 intentResult = main.TRUE
1719 intentsJson = main.ONOScli2.intents()
1720 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1721 intentsJson = intentsJson)
1722 print getIntentStateResult
1723 # Takes awhile for all the onos to get the intents
1724 time.sleep(30)
kelvin-onlab8a832582015-01-16 17:06:11 -08001725 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001726 pingResult = main.FALSE
1727 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001728 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001729 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001730 timeDiff = round( ( time2 - time1 ), 2 )
1731 main.log.report(
1732 "Time taken for Ping All: " +
1733 str( timeDiff ) +
1734 " seconds" )
1735 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1736 onpass="PING ALL PASS",
1737 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001738
kelvin-onlab65a72d22015-03-26 13:46:32 -07001739 case90Result = ( intentResult and pingResult )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001740
kelvin-onlab8a832582015-01-16 17:06:11 -08001741 utilities.assert_equals(
1742 expect=main.TRUE,
kelvin-onlab65a72d22015-03-26 13:46:32 -07001743 actual=case90Result,
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001744 onpass="Install 600 point Intents and Ping All test PASS",
1745 onfail="Install 600 point Intents and Ping All test FAIL" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001746
1747 def CASE91( self ):
1748 """
1749 Install ###$$$ point intents and verify ping all (Chordal Topology)
1750 """
1751 main.log.report( "Add ###$$$ point intents and verify pingall (Chordal Topology)" )
1752 main.log.report( "_______________________________________" )
1753 import itertools
1754 import time
1755 main.case( "Install ###$$$ point intents" )
1756 main.step( "Add point Intents" )
1757 intentResult = main.TRUE
1758 deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) )
1759
1760 intentIdList = []
1761 time1 = time.time()
1762 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1763 pool = []
1764 for cli in main.CLIs:
1765 if i >= len( deviceCombos ):
1766 break
1767 t = main.Thread( target=cli.addPointIntent,
1768 threadID=main.threadID,
1769 name="addPointIntent",
1770 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
1771 pool.append(t)
1772 #time.sleep(1)
1773 t.start()
1774 i = i + 1
1775 main.threadID = main.threadID + 1
1776 for thread in pool:
1777 thread.join()
1778 intentIdList.append(thread.result)
1779 time2 = time.time()
1780 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1781 intentResult = main.TRUE
1782 intentsJson = main.ONOScli2.intents()
1783 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1784 intentsJson = intentsJson)
1785 print getIntentStateResult
1786 # Takes awhile for all the onos to get the intents
1787 time.sleep(30)
1788 main.step( "Verify Ping across all hosts" )
1789 pingResult = main.FALSE
1790 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001791 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001792 time2 = time.time()
1793 timeDiff = round( ( time2 - time1 ), 2 )
1794 main.log.report(
1795 "Time taken for Ping All: " +
1796 str( timeDiff ) +
1797 " seconds" )
1798 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1799 onpass="PING ALL PASS",
1800 onfail="PING ALL FAIL" )
1801
kelvin-onlab65a72d22015-03-26 13:46:32 -07001802 case91Result = ( intentResult and pingResult )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001803
1804 utilities.assert_equals(
1805 expect=main.TRUE,
kelvin-onlabd878fc22015-03-27 13:33:41 -07001806 actual=case91Result,
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001807 onpass="Install ###$$$ point Intents and Ping All test PASS",
1808 onfail="Install ###$$$ point Intents and Ping All test FAIL" )
1809
1810 def CASE92( self ):
1811 """
kelvin-onlab77d6c302015-03-31 11:33:32 -07001812 Install 4556 point intents and verify ping all (Spine Topology)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001813 """
kelvin-onlab77d6c302015-03-31 11:33:32 -07001814 main.log.report( "Add 4556 point intents and verify pingall (Spine Topology)" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001815 main.log.report( "_______________________________________" )
1816 import itertools
1817 import time
kelvin-onlab77d6c302015-03-31 11:33:32 -07001818 main.case( "Install 4556 point intents" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001819 main.step( "Add point Intents" )
1820 intentResult = main.TRUE
kelvin-onlab77d6c302015-03-31 11:33:32 -07001821 main.pingTimeout = 600
1822 for i in range(len(main.hostMACs)):
1823 main.MACsDict[main.deviceDPIDs[i+10]] = main.hostMACs[i].split('/')[0]
1824 print main.MACsDict
1825 deviceCombos = list( itertools.permutations( main.deviceDPIDs[10:], 2 ) )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001826
1827 intentIdList = []
1828 time1 = time.time()
1829 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1830 pool = []
1831 for cli in main.CLIs:
1832 if i >= len( deviceCombos ):
1833 break
1834 t = main.Thread( target=cli.addPointIntent,
1835 threadID=main.threadID,
1836 name="addPointIntent",
1837 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
1838 pool.append(t)
1839 #time.sleep(1)
1840 t.start()
1841 i = i + 1
1842 main.threadID = main.threadID + 1
1843 for thread in pool:
1844 thread.join()
1845 intentIdList.append(thread.result)
1846 time2 = time.time()
1847 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1848 intentResult = main.TRUE
1849 intentsJson = main.ONOScli2.intents()
1850 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1851 intentsJson = intentsJson)
kelvin-onlab77d6c302015-03-31 11:33:32 -07001852 #print getIntentStateResult
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001853 # Takes awhile for all the onos to get the intents
kelvin-onlab77d6c302015-03-31 11:33:32 -07001854 time.sleep(60)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001855 main.step( "Verify Ping across all hosts" )
1856 pingResult = main.FALSE
1857 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001858 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001859 time2 = time.time()
1860 timeDiff = round( ( time2 - time1 ), 2 )
1861 main.log.report(
1862 "Time taken for Ping All: " +
1863 str( timeDiff ) +
1864 " seconds" )
1865 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1866 onpass="PING ALL PASS",
1867 onfail="PING ALL FAIL" )
1868
kelvin-onlab65a72d22015-03-26 13:46:32 -07001869 case92Result = ( intentResult and pingResult )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001870
1871 utilities.assert_equals(
1872 expect=main.TRUE,
kelvin-onlab65a72d22015-03-26 13:46:32 -07001873 actual=case92Result,
kelvin-onlab77d6c302015-03-31 11:33:32 -07001874 onpass="Install 4556 point Intents and Ping All test PASS",
1875 onfail="Install 4556 point Intents and Ping All test FAIL" )
1876
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001877 def CASE93( self ):
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001878 """
kelvin-onlab77d6c302015-03-31 11:33:32 -07001879 Install multi-single point intents and verify Ping all works
1880 for att topology
1881 """
1882 import copy
1883 import time
1884 main.log.report( "Install multi-single point intents and verify Ping all" )
1885 main.log.report( "___________________________________________" )
1886 main.case( "Install multi-single point intents and Ping all" )
1887 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
1888 portIngressList = ['1']*(len(deviceDPIDsCopy) - 1)
1889 intentIdList = []
1890 print "MACsDict", main.MACsDict
1891 time1 = time.time()
1892 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
1893 pool = []
1894 for cli in main.CLIs:
1895 egressDevice = deviceDPIDsCopy[i]
1896 ingressDeviceList = copy.copy(deviceDPIDsCopy)
1897 ingressDeviceList.remove(egressDevice)
1898 if i >= len( deviceDPIDsCopy ):
1899 break
1900 t = main.Thread( target=cli.addMultipointToSinglepointIntent,
1901 threadID=main.threadID,
1902 name="addMultipointToSinglepointIntent",
1903 args =[ingressDeviceList,egressDevice,portIngressList,'1','IPV4','',main.MACsDict.get(egressDevice)])
1904 pool.append(t)
1905 #time.sleep(1)
1906 t.start()
1907 i = i + 1
1908 main.threadID = main.threadID + 1
1909 for thread in pool:
1910 thread.join()
1911 intentIdList.append(thread.result)
1912 time2 = time.time()
1913 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
kelvin-onlab06ade552015-03-31 18:09:27 -07001914 print intentIdList
kelvin-onlab77d6c302015-03-31 11:33:32 -07001915 time.sleep(5)
1916 main.step( "Verify Ping across all hosts" )
1917 pingResult = main.FALSE
1918 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001919 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin-onlab77d6c302015-03-31 11:33:32 -07001920 time2 = time.time()
1921 timeDiff = round( ( time2 - time1 ), 2 )
1922 main.log.report(
1923 "Time taken for Ping All: " +
1924 str( timeDiff ) +
1925 " seconds" )
1926
1927 case93Result = pingResult
1928 utilities.assert_equals(
1929 expect=main.TRUE,
1930 actual=case93Result,
1931 onpass="Install 25 multi to single point Intents and Ping All test PASS",
1932 onfail="Install 25 multi to single point Intents and Ping All test FAIL" )
1933
kelvin-onlab20c712a2015-03-31 12:55:34 -07001934 def CASE94( self ):
1935 """
1936 Install multi-single point intents and verify Ping all works
1937 for spine topology
1938 """
1939 import copy
1940 import time
1941 main.log.report( "Install multi-single point intents and verify Ping all" )
1942 main.log.report( "___________________________________________" )
1943 main.case( "Install multi-single point intents and Ping all" )
1944 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
1945 portIngressList = ['1']*(len(deviceDPIDsCopy) - 1)
1946 intentIdList = []
1947 print "MACsDict", main.MACsDict
1948 time1 = time.time()
1949 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
1950 pool = []
1951 for cli in main.CLIs:
1952 egressDevice = deviceDPIDsCopy[i]
1953 ingressDeviceList = copy.copy(deviceDPIDsCopy)
1954 ingressDeviceList.remove(egressDevice)
1955 if i >= len( deviceDPIDsCopy ):
1956 break
1957 t = main.Thread( target=cli.addMultipointToSinglepointIntent,
1958 threadID=main.threadID,
1959 name="addMultipointToSinglepointIntent",
1960 args =[ingressDeviceList,egressDevice,portIngressList,'1','IPV4','',main.MACsDict.get(egressDevice)])
1961 pool.append(t)
1962 #time.sleep(1)
1963 t.start()
1964 i = i + 1
1965 main.threadID = main.threadID + 1
1966 for thread in pool:
1967 thread.join()
1968 intentIdList.append(thread.result)
1969 time2 = time.time()
1970 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1971 time.sleep(5)
1972 main.step( "Verify Ping across all hosts" )
1973 pingResult = main.FALSE
1974 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07001975 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin-onlab20c712a2015-03-31 12:55:34 -07001976 time2 = time.time()
1977 timeDiff = round( ( time2 - time1 ), 2 )
1978 main.log.report(
1979 "Time taken for Ping All: " +
1980 str( timeDiff ) +
1981 " seconds" )
1982
1983 case94Result = pingResult
1984 utilities.assert_equals(
1985 expect=main.TRUE,
1986 actual=case94Result,
1987 onpass="Install 25 multi to single point Intents and Ping All test PASS",
1988 onfail="Install 25 multi to single point Intents and Ping All test FAIL" )
kelvin-onlab06ade552015-03-31 18:09:27 -07001989
1990 #def CASE95 multi-single point intent for Spine
1991
kelvin-onlab77d6c302015-03-31 11:33:32 -07001992 def CASE96( self ):
1993 """
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001994 Install single-multi point intents and verify Ping all works
1995 for att topology
1996 """
1997 import copy
1998 main.log.report( "Install single-multi point intents and verify Ping all" )
1999 main.log.report( "___________________________________________" )
2000 main.case( "Install single-multi point intents and Ping all" )
kelvin-onlab06ade552015-03-31 18:09:27 -07002001 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
2002 portEgressList = ['1']*(len(deviceDPIDsCopy) - 1)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002003 intentIdList = []
kelvin-onlab06ade552015-03-31 18:09:27 -07002004 print "MACsDict", main.MACsDict
2005 time1 = time.time()
2006 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
2007 pool = []
2008 for cli in main.CLIs:
2009 ingressDevice = deviceDPIDsCopy[i]
2010 egressDeviceList = copy.copy(deviceDPIDsCopy)
2011 egressDeviceList.remove(ingressDevice)
2012 if i >= len( deviceDPIDsCopy ):
2013 break
2014 t = main.Thread( target=cli.addSinglepointToMultipointIntent,
2015 threadID=main.threadID,
2016 name="addSinglepointToMultipointIntent",
2017 args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',main.MACsDict.get(ingressDevice)])
2018 pool.append(t)
2019 #time.sleep(1)
2020 t.start()
2021 i = i + 1
2022 main.threadID = main.threadID + 1
2023 for thread in pool:
2024 thread.join()
2025 intentIdList.append(thread.result)
2026 time2 = time.time()
2027 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
2028 time.sleep(5)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002029 main.step( "Verify Ping across all hosts" )
2030 pingResult = main.FALSE
2031 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07002032 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002033 time2 = time.time()
2034 timeDiff = round( ( time2 - time1 ), 2 )
2035 main.log.report(
2036 "Time taken for Ping All: " +
2037 str( timeDiff ) +
2038 " seconds" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002039
kelvin-onlab06ade552015-03-31 18:09:27 -07002040 case96Result = pingResult
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002041 utilities.assert_equals(
2042 expect=main.TRUE,
kelvin-onlab06ade552015-03-31 18:09:27 -07002043 actual=case96Result,
2044 onpass="Install 25 single to multi point Intents and Ping All test PASS",
2045 onfail="Install 25 single to multi point Intents and Ping All test FAIL" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002046
kelvin-onlab77d6c302015-03-31 11:33:32 -07002047 def CASE97( self ):
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002048 """
2049 Install single-multi point intents and verify Ping all works
kelvin-onlab06ade552015-03-31 18:09:27 -07002050 for Chordal topology
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002051 """
2052 import copy
2053 main.log.report( "Install single-multi point intents and verify Ping all" )
2054 main.log.report( "___________________________________________" )
2055 main.case( "Install single-multi point intents and Ping all" )
kelvin-onlab06ade552015-03-31 18:09:27 -07002056 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
2057 portEgressList = ['1']*(len(deviceDPIDsCopy) - 1)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002058 intentIdList = []
kelvin-onlab06ade552015-03-31 18:09:27 -07002059 print "MACsDict", main.MACsDict
2060 time1 = time.time()
2061 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
2062 pool = []
2063 for cli in main.CLIs:
2064 ingressDevice = deviceDPIDsCopy[i]
2065 egressDeviceList = copy.copy(deviceDPIDsCopy)
2066 egressDeviceList.remove(ingressDevice)
2067 if i >= len( deviceDPIDsCopy ):
2068 break
2069 t = main.Thread( target=cli.addSinglepointToMultipointIntent,
2070 threadID=main.threadID,
2071 name="addSinglepointToMultipointIntent",
2072 args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',main.MACsDict.get(ingressDevice),''])
2073 pool.append(t)
2074 #time.sleep(1)
2075 t.start()
2076 i = i + 1
2077 main.threadID = main.threadID + 1
2078 for thread in pool:
2079 thread.join()
2080 intentIdList.append(thread.result)
2081 time2 = time.time()
2082 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
2083 time.sleep(5)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002084 main.step( "Verify Ping across all hosts" )
2085 pingResult = main.FALSE
2086 time1 = time.time()
kelvin-onlab38143812015-04-01 15:03:01 -07002087 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=True)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002088 time2 = time.time()
2089 timeDiff = round( ( time2 - time1 ), 2 )
2090 main.log.report(
2091 "Time taken for Ping All: " +
2092 str( timeDiff ) +
2093 " seconds" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002094
kelvin-onlab06ade552015-03-31 18:09:27 -07002095 case97Result = pingResult
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002096 utilities.assert_equals(
2097 expect=main.TRUE,
kelvin-onlab06ade552015-03-31 18:09:27 -07002098 actual=case97Result,
2099 onpass="Install 25 single to multi point Intents and Ping All test PASS",
2100 onfail="Install 25 single to multi point Intents and Ping All test FAIL" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002101
kelvin-onlab8a832582015-01-16 17:06:11 -08002102 def CASE10( self ):
kelvin-onlab7642bb12015-02-27 13:48:17 -08002103 import time
kelvin-onlab8a832582015-01-16 17:06:11 -08002104 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002105 Remove all Intents
kelvin-onlab8a832582015-01-16 17:06:11 -08002106 """
2107 main.log.report( "Remove all intents that were installed previously" )
2108 main.log.report( "______________________________________________" )
2109 main.log.info( "Remove all intents" )
2110 main.case( "Removing intents" )
2111 main.step( "Obtain the intent id's first" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002112 intentsList = main.ONOScli1.getAllIntentIds()
kelvin-onlab8a832582015-01-16 17:06:11 -08002113 ansi_escape = re.compile( r'\x1b[^m]*m' )
2114 intentsList = ansi_escape.sub( '', intentsList )
2115 intentsList = intentsList.replace(
2116 " onos:intents | grep id=",
2117 "" ).replace(
2118 "id=",
2119 "" ).replace(
2120 "\r\r",
2121 "" )
2122 intentsList = intentsList.splitlines()
2123 intentsList = intentsList[ 1: ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002124 intentIdList = []
2125 step1Result = main.TRUE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002126 moreIntents = main.TRUE
2127 removeIntentCount = 0
kelvin-onlab65a72d22015-03-26 13:46:32 -07002128 intentsCount = len(intentsList)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002129 print "Current number of intents" , len(intentsList)
kelvin-onlab8a832582015-01-16 17:06:11 -08002130 if ( len( intentsList ) > 1 ):
kelvin-onlab54400a92015-02-26 18:05:51 -08002131 results = main.TRUE
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002132 main.log.info("Removing intent...")
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002133 while moreIntents:
Hari Krishnab35c6d02015-03-18 11:13:51 -07002134 if removeIntentCount == 5:
2135 break
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002136 removeIntentCount = removeIntentCount + 1
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002137 intentsList1 = main.ONOScli1.getAllIntentIds()
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002138 if len( intentsList1 ) == 0:
2139 break
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002140 ansi_escape = re.compile( r'\x1b[^m]*m' )
2141 intentsList1 = ansi_escape.sub( '', intentsList1 )
2142 intentsList1 = intentsList1.replace(
2143 " onos:intents | grep id=",
2144 "" ).replace(
2145 " state=",
2146 "" ).replace(
2147 "\r\r",
2148 "" )
2149 intentsList1 = intentsList1.splitlines()
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002150 intentsList1 = intentsList1[ 1: ]
2151 print "Round %d intents to remove: " %(removeIntentCount)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002152 print intentsList1
2153 intentIdList1 = []
Hari Krishnab35c6d02015-03-18 11:13:51 -07002154 if ( len( intentsList1 ) > 0 ):
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002155 moreIntents = main.TRUE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002156 for i in range( len( intentsList1 ) ):
2157 intentsTemp1 = intentsList1[ i ].split( ',' )
2158 intentIdList1.append( intentsTemp1[ 0 ].split('=')[1] )
2159 print "Leftover Intent IDs: ", intentIdList1
2160 print len(intentIdList1)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07002161 time1 = time.time()
2162 for i in xrange( 0, len( intentIdList1 ), int(main.numCtrls) ):
2163 pool = []
2164 for cli in main.CLIs:
2165 if i >= len( intentIdList1 ):
2166 break
2167 t = main.Thread( target=cli.removeIntent,
2168 threadID=main.threadID,
2169 name="removeIntent",
2170 args=[intentIdList1[i],'org.onosproject.cli',True,False])
2171 pool.append(t)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07002172 t.start()
2173 i = i + 1
2174 main.threadID = main.threadID + 1
2175 for thread in pool:
2176 thread.join()
2177 intentIdList.append(thread.result)
2178 time2 = time.time()
2179 main.log.info("Time for removing host intents: %2f seconds" %(time2-time1))
Hari Krishnab35c6d02015-03-18 11:13:51 -07002180 time.sleep(10)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002181 else:
Hari Krishnaef1bd4e2015-03-12 16:55:30 -07002182 time.sleep(15)
Hari Krishnab35c6d02015-03-18 11:13:51 -07002183 if len( main.ONOScli1.intents()):
Hari Krishnaef1bd4e2015-03-12 16:55:30 -07002184 continue
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002185 break
kelvin-onlab36c02b12015-03-11 11:25:55 -07002186
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002187 else:
kelvin-onlab65a72d22015-03-26 13:46:32 -07002188 print "Removed %d intents" %(intentsCount)
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002189 step1Result = main.TRUE
2190 else:
2191 print "No Intent IDs found in Intents list: ", intentsList
2192 step1Result = main.FALSE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002193
kelvin-onlabdc8719b2015-03-02 14:01:52 -08002194 print main.ONOScli1.intents()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002195 caseResult10 = step1Result
2196 utilities.assert_equals( expect=main.TRUE, actual=caseResult10,
kelvin-onlab8a832582015-01-16 17:06:11 -08002197 onpass="Intent removal test successful",
2198 onfail="Intent removal test failed" )
Hari Krishna22c3d412015-02-17 16:48:12 -08002199
2200 def CASE11( self, main ):
2201 """
2202 Enable onos-app-ifwd, Verify Intent based Reactive forwarding through ping all and Disable it
2203 """
2204 import re
2205 import copy
2206 import time
2207
kelvin-onlab54400a92015-02-26 18:05:51 -08002208 Thread = imp.load_source('Thread','/home/admin/ONLabTest/TestON/tests/OnosCHO/Thread.py')
2209 threadID = 0
2210
Hari Krishna22c3d412015-02-17 16:48:12 -08002211 main.log.report( "Enable Intent based Reactive forwarding and Verify ping all" )
2212 main.log.report( "_____________________________________________________" )
2213 main.case( "Enable Intent based Reactive forwarding and Verify ping all" )
2214 main.step( "Enable intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08002215 installResult = main.FALSE
2216 feature = "onos-app-ifwd"
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002217
kelvin-onlab54400a92015-02-26 18:05:51 -08002218 pool = []
2219 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002220 for cli,feature in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -08002221 t = main.Thread(target=cli,threadID=threadID,
2222 name="featureInstall",args=[feature])
2223 pool.append(t)
2224 t.start()
2225 threadID = threadID + 1
2226
2227 results = []
2228 for thread in pool:
2229 thread.join()
2230 results.append(thread.result)
2231 time2 = time.time()
2232
2233 if( all(result == main.TRUE for result in results) == False):
2234 main.log.info("Did not install onos-app-ifwd feature properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -07002235 #main.cleanup()
2236 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -08002237 else:
2238 main.log.info("Successful feature:install onos-app-ifwd")
2239 installResult = main.TRUE
2240 main.log.info("Time for feature:install onos-app-ifwd: %2f seconds" %(time2-time1))
2241
Hari Krishna22c3d412015-02-17 16:48:12 -08002242 main.step( "Verify Pingall" )
2243 ping_result = main.FALSE
2244 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -08002245 ping_result = main.Mininet1.pingall(timeout=600)
Hari Krishna22c3d412015-02-17 16:48:12 -08002246 time2 = time.time()
2247 timeDiff = round( ( time2 - time1 ), 2 )
2248 main.log.report(
2249 "Time taken for Ping All: " +
2250 str( timeDiff ) +
2251 " seconds" )
kelvin-onlab54400a92015-02-26 18:05:51 -08002252
Hari Krishna22c3d412015-02-17 16:48:12 -08002253 if ping_result == main.TRUE:
2254 main.log.report( "Pingall Test in Reactive mode successful" )
2255 else:
2256 main.log.report( "Pingall Test in Reactive mode failed" )
2257
2258 main.step( "Disable Intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08002259 uninstallResult = main.FALSE
2260
kelvin-onlab54400a92015-02-26 18:05:51 -08002261 pool = []
2262 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002263 for cli,feature in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -08002264 t = main.Thread(target=cli,threadID=threadID,
2265 name="featureUninstall",args=[feature])
2266 pool.append(t)
2267 t.start()
2268 threadID = threadID + 1
2269
2270 results = []
2271 for thread in pool:
2272 thread.join()
2273 results.append(thread.result)
2274 time2 = time.time()
2275
2276 if( all(result == main.TRUE for result in results) == False):
2277 main.log.info("Did not uninstall onos-app-ifwd feature properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -07002278 uninstallResult = main.FALSE
2279 #main.cleanup()
2280 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -08002281 else:
2282 main.log.info("Successful feature:uninstall onos-app-ifwd")
2283 uninstallResult = main.TRUE
2284 main.log.info("Time for feature:uninstall onos-app-ifwd: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -08002285
2286 # Waiting for reative flows to be cleared.
2287 time.sleep( 10 )
2288
2289 case11Result = installResult and ping_result and uninstallResult
2290 utilities.assert_equals( expect=main.TRUE, actual=case11Result,
2291 onpass="Intent based Reactive forwarding Pingall test PASS",
2292 onfail="Intent based Reactive forwarding Pingall test FAIL" )
2293
Hari Krishnab35c6d02015-03-18 11:13:51 -07002294 def CASE99(self):
2295 import time
2296 # WORK AROUND FOR ONOS-581. STOP ONOS BEFORE ASSIGNING CONTROLLERS AT MININET & START ONCE DONE
2297 main.step( "Stop ONOS on all Nodes" )
2298 stopResult = main.TRUE
2299 for i in range( 1, int( main.numCtrls ) + 1 ):
2300 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
2301 main.log.info( "Stopping ONOS Node IP: " + ONOS_ip )
2302 sresult = main.ONOSbench.onosStop( ONOS_ip )
2303 utilities.assert_equals( expect=main.TRUE, actual=sresult,
2304 onpass="Test step PASS",
2305 onfail="Test step FAIL" )
2306 stopResult = ( stopResult and sresult )
2307
2308 main.step( "Start ONOS on all Nodes" )
2309 startResult = main.TRUE
2310 for i in range( 1, int( main.numCtrls ) + 1 ):
2311 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
2312 main.log.info( "Starting ONOS Node IP: " + ONOS_ip )
2313 sresult = main.ONOSbench.onosStart( ONOS_ip )
2314 utilities.assert_equals( expect=main.TRUE, actual=sresult,
2315 onpass="Test step PASS",
2316 onfail="Test step FAIL" )
2317 startResult = ( startResult and sresult )
2318
2319 main.step( "Start ONOS CLI on all nodes" )
2320 cliResult = main.TRUE
2321 time.sleep( 30 )
2322 main.log.step(" Start ONOS cli using thread ")
2323 pool = []
2324 time1 = time.time()
2325 for i in range( int( main.numCtrls ) ):
2326 t = main.Thread(target=main.CLIs[i].startOnosCli,
2327 threadID=main.threadID,
2328 name="startOnosCli",
2329 args=[main.nodes[i].ip_address])
2330 pool.append(t)
2331 t.start()
2332 main.threadID = main.threadID + 1
2333 for t in pool:
2334 t.join()
2335 cliResult = cliResult and t.result
2336 time2 = time.time()
2337
2338 if not cliResult:
2339 main.log.info("ONOS CLI did not start up properly")
2340 #main.cleanup()
2341 #main.exit()
2342 else:
2343 main.log.info("Successful CLI startup")
2344 main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
2345
2346 case99Result = ( startResult and cliResult )
2347 time.sleep(30)
2348 utilities.assert_equals(
2349 expect=main.TRUE,
2350 actual=case99Result,
2351 onpass="Starting new Chordal topology test PASS",
2352 onfail="Starting new Chordal topology test FAIL" )
2353
2354
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002355
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002356