blob: 8c58d0435dd34f3446104dd499248505ee637024 [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' ]
Hari Krishna0ce0e152015-06-23 09:55:29 -070035 #main.ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ]
36 #main.ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ]
Hari Krishna22c3d412015-02-17 16:48:12 -080037 main.ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
38 main.ONOS2_port = main.params[ 'CTRL' ][ 'port2' ]
39 main.ONOS3_port = main.params[ 'CTRL' ][ 'port3' ]
Hari Krishna0ce0e152015-06-23 09:55:29 -070040 #main.ONOS4_port = main.params[ 'CTRL' ][ 'port4' ]
41 #main.ONOS5_port = main.params[ 'CTRL' ][ 'port5' ]
kelvin-onlab8a832582015-01-16 17:06:11 -080042 cell_name = main.params[ 'ENV' ][ 'cellName' ]
43 git_pull = main.params[ 'GIT' ][ 'autoPull' ]
kelvin-onlab8a832582015-01-16 17:06:11 -080044 git_branch = main.params[ 'GIT' ][ 'branch' ]
Hari Krishnab35c6d02015-03-18 11:13:51 -070045 main.newTopo = ""
kelvin-onlab78f7d2d2015-03-02 17:37:35 -080046 main.CLIs = []
47 main.nodes = []
48 for i in range( 1, int(main.numCtrls) + 1 ):
49 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
50 main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
51
kelvin-onlab8a832582015-01-16 17:06:11 -080052 main.case( "Set up test environment" )
53 main.log.report( "Set up test environment" )
54 main.log.report( "_______________________" )
55
56 main.step( "Git checkout and pull " + git_branch )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080057 if git_pull == 'on':
Hari Krishnad97213e2015-01-24 19:30:14 -080058 checkout_result = main.ONOSbench.gitCheckout( git_branch )
59 pull_result = main.ONOSbench.gitPull()
kelvin-onlab8a832582015-01-16 17:06:11 -080060 cp_result = ( checkout_result and pull_result )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080061 else:
62 checkout_result = main.TRUE
63 pull_result = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -080064 main.log.info( "Skipped git checkout and pull" )
65 cp_result = ( checkout_result and pull_result )
66 utilities.assert_equals( expect=main.TRUE, actual=cp_result,
67 onpass="Test step PASS",
68 onfail="Test step FAIL" )
69
70 main.step( "mvn clean & install" )
Hari Krishna22c3d412015-02-17 16:48:12 -080071 if git_pull == 'on':
72 mvn_result = main.ONOSbench.cleanInstall()
73 utilities.assert_equals( expect=main.TRUE, actual=mvn_result,
kelvin-onlab8a832582015-01-16 17:06:11 -080074 onpass="Test step PASS",
75 onfail="Test step FAIL" )
Hari Krishna22c3d412015-02-17 16:48:12 -080076 else:
77 mvn_result = main.TRUE
78 main.log.info("Skipped mvn clean install as git pull is disabled in params file")
Hari Krishnaa43d4e92014-12-19 13:22:40 -080079
Hari Krishnad97213e2015-01-24 19:30:14 -080080 main.ONOSbench.getVersion( report=True )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080081
kelvin-onlab8a832582015-01-16 17:06:11 -080082 main.step( "Apply Cell environment for ONOS" )
Hari Krishnad97213e2015-01-24 19:30:14 -080083 cell_result = main.ONOSbench.setCell( cell_name )
kelvin-onlab8a832582015-01-16 17:06:11 -080084 utilities.assert_equals( expect=main.TRUE, actual=cell_result,
85 onpass="Test step PASS",
86 onfail="Test step FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080087
kelvin-onlab8a832582015-01-16 17:06:11 -080088 main.step( "Create ONOS package" )
Hari Krishnad97213e2015-01-24 19:30:14 -080089 packageResult = main.ONOSbench.onosPackage()
kelvin-onlab8a832582015-01-16 17:06:11 -080090 utilities.assert_equals( expect=main.TRUE, actual=packageResult,
91 onpass="Test step PASS",
92 onfail="Test step FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080093
kelvin-onlab8a832582015-01-16 17:06:11 -080094 main.step( "Uninstall ONOS package on all Nodes" )
95 uninstallResult = main.TRUE
Hari Krishna22c3d412015-02-17 16:48:12 -080096 for i in range( 1, int( main.numCtrls ) + 1 ):
kelvin-onlab8a832582015-01-16 17:06:11 -080097 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
kelvin-onlab54400a92015-02-26 18:05:51 -080098 main.log.info( "Uninstalling package on ONOS Node IP: " + ONOS_ip )
Hari Krishnad97213e2015-01-24 19:30:14 -080099 u_result = main.ONOSbench.onosUninstall( ONOS_ip )
kelvin-onlab8a832582015-01-16 17:06:11 -0800100 utilities.assert_equals( expect=main.TRUE, actual=u_result,
101 onpass="Test step PASS",
102 onfail="Test step FAIL" )
103 uninstallResult = ( uninstallResult and u_result )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800104
Hari Krishnab35c6d02015-03-18 11:13:51 -0700105 #main.step( "Removing copy-cat logs from ONOS nodes" )
106 #main.ONOSbench.onosRemoveRaftLogs()
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800107
kelvin-onlab8a832582015-01-16 17:06:11 -0800108 main.step( "Install ONOS package on all Nodes" )
109 installResult = main.TRUE
Hari Krishna22c3d412015-02-17 16:48:12 -0800110 for i in range( 1, int( main.numCtrls ) + 1 ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800111 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
112 main.log.info( "Intsalling package on ONOS Node IP: " + ONOS_ip )
Hari Krishnad97213e2015-01-24 19:30:14 -0800113 i_result = main.ONOSbench.onosInstall( node=ONOS_ip )
kelvin-onlab8a832582015-01-16 17:06:11 -0800114 utilities.assert_equals( expect=main.TRUE, actual=i_result,
115 onpass="Test step PASS",
116 onfail="Test step FAIL" )
117 installResult = ( installResult and i_result )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800118
kelvin-onlab8a832582015-01-16 17:06:11 -0800119 main.step( "Verify ONOS nodes UP status" )
120 statusResult = main.TRUE
Hari Krishna22c3d412015-02-17 16:48:12 -0800121 for i in range( 1, int( main.numCtrls ) + 1 ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800122 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
123 main.log.info( "ONOS Node " + ONOS_ip + " status:" )
Hari Krishnad97213e2015-01-24 19:30:14 -0800124 onos_status = main.ONOSbench.onosStatus( node=ONOS_ip )
kelvin-onlab8a832582015-01-16 17:06:11 -0800125 utilities.assert_equals( expect=main.TRUE, actual=onos_status,
126 onpass="Test step PASS",
127 onfail="Test step FAIL" )
128 statusResult = ( statusResult and onos_status )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700129
kelvin-onlab8a832582015-01-16 17:06:11 -0800130 main.step( "Start ONOS CLI on all nodes" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800131 cliResult = main.TRUE
kelvin8ec71442015-01-15 16:57:00 -0800132 karafTimeout = "3600000"
kelvin-onlab8a832582015-01-16 17:06:11 -0800133 # need to wait here for sometime. This will be removed once ONOS is
134 # stable enough
kelvin-onlab54400a92015-02-26 18:05:51 -0800135 time.sleep( 25 )
kelvin-onlab54400a92015-02-26 18:05:51 -0800136 main.log.step(" Start ONOS cli using thread ")
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800137 startCliResult = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800138 pool = []
139 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800140 for i in range( int( main.numCtrls) ):
141 t = main.Thread( target=main.CLIs[i].startOnosCli,
142 threadID=main.threadID,
143 name="startOnosCli",
kelvin-onlabc44f0192015-04-02 22:08:41 -0700144 args=[ main.nodes[i].ip_address, karafTimeout ] )
kelvin-onlab54400a92015-02-26 18:05:51 -0800145 pool.append(t)
146 t.start()
147 main.threadID = main.threadID + 1
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800148 for t in pool:
149 t.join()
150 startCliResult = startCliResult and t.result
kelvin-onlab54400a92015-02-26 18:05:51 -0800151 time2 = time.time()
152
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800153 if not startCliResult:
kelvin-onlab54400a92015-02-26 18:05:51 -0800154 main.log.info("ONOS CLI did not start up properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -0700155 #main.cleanup()
156 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -0800157 else:
158 main.log.info("Successful CLI startup")
159 startCliResult = main.TRUE
160 case1Result = installResult and uninstallResult and statusResult and startCliResult
Hari Krishna0ce0e152015-06-23 09:55:29 -0700161 time.sleep(30)
kelvin-onlab54400a92015-02-26 18:05:51 -0800162 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 Krishna0ce0e152015-06-23 09:55:29 -0700178 main.pingTimeout = 300
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)
Hari Krishna0ce0e152015-06-23 09:55:29 -0700193 time.sleep(45)
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 Krishna0ce0e152015-06-23 09:55:29 -0700198 count=int( main.numCtrls ),
Hari Krishna22c3d412015-02-17 16:48:12 -0800199 ip1=main.ONOS1_ip,
200 port1=main.ONOS1_port,
201 ip2=main.ONOS2_ip,
202 port2=main.ONOS2_port,
203 ip3=main.ONOS3_ip,
Hari Krishna0ce0e152015-06-23 09:55:29 -0700204 port3=main.ONOS3_port )
205
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800206 switch_mastership = main.TRUE
Hari Krishna22c3d412015-02-17 16:48:12 -0800207 for i in range( 1, ( main.numMNswitches + 1 ) ):
Hari Krishnad97213e2015-01-24 19:30:14 -0800208 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800209 print( "Response is " + str( response ) )
Hari Krishna22c3d412015-02-17 16:48:12 -0800210 if re.search( "tcp:" + main.ONOS1_ip, response ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800211 switch_mastership = switch_mastership and main.TRUE
212 else:
213 switch_mastership = main.FALSE
214
215 if switch_mastership == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800216 main.log.report( "Controller assignment successfull" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800217 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800218 main.log.report( "Controller assignment failed" )
kelvin-onlab77d6c302015-03-31 11:33:32 -0700219
220 """topoFailed = main.FALSE
221 checkCount = 0
222 while(topoFailed == main.FALSE):
223 topology_output = main.ONOScli1.topology()
224 topology_result = main.ONOSbench.getTopology( topology_output )
225 numOnosDevices = topology_result[ 'deviceCount' ]
226 numOnosLinks = topology_result[ 'linkCount' ]
227 if ( ( main.numMNswitches == int(numOnosDevices) ) and ( main.numMNlinks >= int(numOnosLinks) ) ):
228 main.log.info("Att topology is now ready!")
229 break
230 else:
231 main.log.info("Att topology is not ready yet!")
232 checkCount = checkCount + 1
233 time.sleep(2)
234 if checkCount == 10:
235 topoFailed = main.TRUE
236 if topoFailed:
237 main.log.info("Att topology failed to start correctly")
Hari Krishnab35c6d02015-03-18 11:13:51 -0700238 """
Hari Krishna0ce0e152015-06-23 09:55:29 -0700239 time.sleep(45)
kelvin-onlab77d6c302015-03-31 11:33:32 -0700240 #Don't balance master for now..
Hari Krishna0ce0e152015-06-23 09:55:29 -0700241 main.step( "Balance devices across controllers" )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700242 for i in range( int( main.numCtrls ) ):
243 balanceResult = main.ONOScli1.balanceMasters()
kelvin-onlab8a832582015-01-16 17:06:11 -0800244 # giving some breathing time for ONOS to complete re-balance
Hari Krishna0ce0e152015-06-23 09:55:29 -0700245 time.sleep( 5 )
kelvin-onlab77d6c302015-03-31 11:33:32 -0700246 topology_output = main.ONOScli1.topology()
247 topology_result = main.ONOSbench.getTopology( topology_output )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700248 case2Result = ( switch_mastership and startStatus )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700249 utilities.assert_equals(
250 expect=main.TRUE,
251 actual=case2Result,
252 onpass="Starting new Att topology test PASS",
253 onfail="Starting new Att topology test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800254
kelvin-onlab65a72d22015-03-26 13:46:32 -0700255 def CASE21( self, main ):
256 """
257 This test script Loads a new Topology (Chordal) on CHO setup and balances all switches
258 """
259 import re
260 import time
261 import copy
262
263 main.newTopo = main.params['TOPO2']['topo']
264 main.numMNswitches = int ( main.params[ 'TOPO2' ][ 'numSwitches' ] )
265 main.numMNlinks = int ( main.params[ 'TOPO2' ][ 'numLinks' ] )
266 main.numMNhosts = int ( main.params[ 'TOPO2' ][ 'numHosts' ] )
Hari Krishna0ce0e152015-06-23 09:55:29 -0700267 main.pingTimeout = 300
kelvin-onlab65a72d22015-03-26 13:46:32 -0700268 main.log.report(
269 "Load Chordal topology and Balance all Mininet switches across controllers" )
270 main.log.report(
271 "________________________________________________________________________" )
272 main.case(
273 "Assign and Balance all Mininet switches across controllers" )
274 main.step( "Stop any previous Mininet network topology" )
Hari Krishna0ce0e152015-06-23 09:55:29 -0700275 stopStatus = main.Mininet1.stopNet(fileName = "topoAtt" )
276 time.sleep(10)
kelvin-onlab65a72d22015-03-26 13:46:32 -0700277 main.step( "Start Mininet with Chordal topology" )
278 startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
279 time.sleep(15)
280 main.step( "Assign switches to controllers" )
281 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
282 main.Mininet1.assignSwController(
283 sw=str( i ),
284 count=int( main.numCtrls ),
285 ip1=main.ONOS1_ip,
286 port1=main.ONOS1_port,
287 ip2=main.ONOS2_ip,
288 port2=main.ONOS2_port,
289 ip3=main.ONOS3_ip,
Hari Krishna0ce0e152015-06-23 09:55:29 -0700290 port3=main.ONOS3_port )
kelvin-onlab65a72d22015-03-26 13:46:32 -0700291
292 switch_mastership = main.TRUE
293 for i in range( 1, ( main.numMNswitches + 1 ) ):
294 response = main.Mininet1.getSwController( "s" + str( i ) )
295 print( "Response is " + str( response ) )
296 if re.search( "tcp:" + main.ONOS1_ip, response ):
297 switch_mastership = switch_mastership and main.TRUE
298 else:
299 switch_mastership = main.FALSE
300
301 if switch_mastership == main.TRUE:
302 main.log.report( "Controller assignment successfull" )
303 else:
304 main.log.report( "Controller assignment failed" )
305 time.sleep( 5 )
306
kelvin-onlab65a72d22015-03-26 13:46:32 -0700307 main.step( "Balance devices across controllers" )
308 for i in range( int( main.numCtrls ) ):
309 balanceResult = main.ONOScli1.balanceMasters()
310 # giving some breathing time for ONOS to complete re-balance
311 time.sleep( 3 )
Hari Krishna0ce0e152015-06-23 09:55:29 -0700312
kelvin-onlab65a72d22015-03-26 13:46:32 -0700313 case21Result = switch_mastership
314 time.sleep(30)
315 utilities.assert_equals(
316 expect=main.TRUE,
317 actual=case21Result,
318 onpass="Starting new Chordal topology test PASS",
319 onfail="Starting new Chordal topology test FAIL" )
320
321 def CASE22( self, main ):
322 """
323 This test script Loads a new Topology (Spine) on CHO setup and balances all switches
324 """
325 import re
326 import time
327 import copy
328
329 main.newTopo = main.params['TOPO3']['topo']
330 main.numMNswitches = int ( main.params[ 'TOPO3' ][ 'numSwitches' ] )
331 main.numMNlinks = int ( main.params[ 'TOPO3' ][ 'numLinks' ] )
332 main.numMNhosts = int ( main.params[ 'TOPO3' ][ 'numHosts' ] )
Hari Krishna0ce0e152015-06-23 09:55:29 -0700333 main.pingTimeout = 600
kelvin-onlab65a72d22015-03-26 13:46:32 -0700334
335 main.log.report(
336 "Load Spine and Leaf topology and Balance all Mininet switches across controllers" )
337 main.log.report(
338 "________________________________________________________________________" )
339 # need to wait here for sometime until ONOS bootup
340 main.case(
341 "Assign and Balance all Mininet switches across controllers" )
342 main.step( "Stop any previous Mininet network topology" )
Hari Krishna0ce0e152015-06-23 09:55:29 -0700343 stopStatus = main.Mininet1.stopNet(fileName = "topoChordal" )
kelvin-onlab65a72d22015-03-26 13:46:32 -0700344 main.step( "Start Mininet with Spine topology" )
345 startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
Hari Krishna0ce0e152015-06-23 09:55:29 -0700346 time.sleep(60)
kelvin-onlab65a72d22015-03-26 13:46:32 -0700347 main.step( "Assign switches to controllers" )
348 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
349 main.Mininet1.assignSwController(
350 sw=str( i ),
Hari Krishna0ce0e152015-06-23 09:55:29 -0700351 count=int( main.numCtrls ),
kelvin-onlab65a72d22015-03-26 13:46:32 -0700352 ip1=main.ONOS1_ip,
353 port1=main.ONOS1_port,
354 ip2=main.ONOS2_ip,
355 port2=main.ONOS2_port,
356 ip3=main.ONOS3_ip,
Hari Krishna0ce0e152015-06-23 09:55:29 -0700357 port3=main.ONOS3_port )
kelvin-onlab65a72d22015-03-26 13:46:32 -0700358
359 switch_mastership = main.TRUE
360 for i in range( 1, ( main.numMNswitches + 1 ) ):
361 response = main.Mininet1.getSwController( "s" + str( i ) )
362 print( "Response is " + str( response ) )
363 if re.search( "tcp:" + main.ONOS1_ip, response ):
364 switch_mastership = switch_mastership and main.TRUE
365 else:
366 switch_mastership = main.FALSE
367
368 if switch_mastership == main.TRUE:
369 main.log.report( "Controller assignment successfull" )
370 else:
371 main.log.report( "Controller assignment failed" )
372 time.sleep( 5 )
kelvin-onlab65a72d22015-03-26 13:46:32 -0700373
374 main.step( "Balance devices across controllers" )
375 for i in range( int( main.numCtrls ) ):
376 balanceResult = main.ONOScli1.balanceMasters()
377 # giving some breathing time for ONOS to complete re-balance
378 time.sleep( 3 )
Hari Krishna0ce0e152015-06-23 09:55:29 -0700379
kelvin-onlab65a72d22015-03-26 13:46:32 -0700380 case22Result = switch_mastership
Hari Krishna0ce0e152015-06-23 09:55:29 -0700381 time.sleep(60)
kelvin-onlab65a72d22015-03-26 13:46:32 -0700382 utilities.assert_equals(
383 expect=main.TRUE,
384 actual=case22Result,
385 onpass="Starting new Spine topology test PASS",
386 onfail="Starting new Spine topology test FAIL" )
387
kelvin-onlab8a832582015-01-16 17:06:11 -0800388 def CASE3( self, main ):
389 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800390 This Test case will be extended to collect and store more data related
391 ONOS state.
kelvin-onlab8a832582015-01-16 17:06:11 -0800392 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800393 import re
394 import copy
Hari Krishna22c3d412015-02-17 16:48:12 -0800395 main.deviceDPIDs = []
396 main.hostMACs = []
397 main.deviceLinks = []
398 main.deviceActiveLinksCount = []
399 main.devicePortsEnabledCount = []
kelvin-onlab54400a92015-02-26 18:05:51 -0800400
kelvin-onlab8a832582015-01-16 17:06:11 -0800401 main.log.report(
402 "Collect and Store topology details from ONOS before running any Tests" )
403 main.log.report(
404 "____________________________________________________________________" )
Hari Krishna5afb4cc2015-03-23 15:35:15 -0700405 main.case( "Collect and Store Topology Details from ONOS" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800406 main.step( "Collect and store current number of switches and links" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800407 topology_output = main.ONOScli1.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800408 topology_result = main.ONOSbench.getTopology( topology_output )
Hari Krishna0ce0e152015-06-23 09:55:29 -0700409 numOnosDevices = topology_result[ 'devices' ]
410 numOnosLinks = topology_result[ 'links' ]
Hari Krishnab35c6d02015-03-18 11:13:51 -0700411 topoResult = main.TRUE
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800412
kelvin-onlab54400a92015-02-26 18:05:51 -0800413 if ( ( main.numMNswitches == int(numOnosDevices) ) and ( main.numMNlinks >= int(numOnosLinks) ) ):
Hari Krishna22c3d412015-02-17 16:48:12 -0800414 main.step( "Store Device DPIDs" )
415 for i in range( 1, (main.numMNswitches+1) ):
416 main.deviceDPIDs.append( "of:00000000000000" + format( i, '02x' ) )
417 print "Device DPIDs in Store: \n", str( main.deviceDPIDs )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800418
Hari Krishna22c3d412015-02-17 16:48:12 -0800419 main.step( "Store Host MACs" )
420 for i in range( 1, ( main.numMNhosts + 1 ) ):
421 main.hostMACs.append( "00:00:00:00:00:" + format( i, '02x' ) + "/-1" )
422 print "Host MACs in Store: \n", str( main.hostMACs )
Hari Krishna5afb4cc2015-03-23 15:35:15 -0700423 main.MACsDict = {}
kelvin-onlab65a72d22015-03-26 13:46:32 -0700424 print "Creating dictionary of DPID and HostMacs"
425 for i in range(len(main.hostMACs)):
Hari Krishna5afb4cc2015-03-23 15:35:15 -0700426 main.MACsDict[main.deviceDPIDs[i]] = main.hostMACs[i].split('/')[0]
427 print main.MACsDict
Hari Krishna22c3d412015-02-17 16:48:12 -0800428 main.step( "Collect and store all Devices Links" )
429 linksResult = main.ONOScli1.links( jsonFormat=False )
430 ansi_escape = re.compile( r'\x1b[^m]*m' )
431 linksResult = ansi_escape.sub( '', linksResult )
432 linksResult = linksResult.replace( " links", "" ).replace( "\r\r", "" )
433 linksResult = linksResult.splitlines()
Hari Krishna22c3d412015-02-17 16:48:12 -0800434 main.deviceLinks = copy.copy( linksResult )
435 print "Device Links Stored: \n", str( main.deviceLinks )
436 # this will be asserted to check with the params provided count of
437 # links
438 print "Length of Links Store", len( main.deviceLinks )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800439
Hari Krishna22c3d412015-02-17 16:48:12 -0800440 main.step( "Collect and store each Device ports enabled Count" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800441 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800442 for i in xrange(1,(main.numMNswitches + 1), int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800443 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800444 for cli in main.CLIs:
kelvin-onlabc44f0192015-04-02 22:08:41 -0700445 if i >= main.numMNswitches + 1:
kelvin-onlabfbcd82f2015-04-02 12:06:00 -0700446 break
kelvin-onlab54400a92015-02-26 18:05:51 -0800447 dpid = "of:00000000000000" + format( i,'02x' )
448 t = main.Thread(target = cli.getDevicePortsEnabledCount,threadID = main.threadID, name = "getDevicePortsEnabledCount",args = [dpid])
449 t.start()
450 pool.append(t)
451 i = i + 1
452 main.threadID = main.threadID + 1
453 for thread in pool:
454 thread.join()
455 portResult = thread.result
Hari Krishna0ce0e152015-06-23 09:55:29 -0700456 #portCount = re.split( r'\t+', portResult )
457 #portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
458 main.devicePortsEnabledCount.append( portResult )
Hari Krishna22c3d412015-02-17 16:48:12 -0800459 print "Device Enabled Port Counts Stored: \n", str( main.devicePortsEnabledCount )
kelvin-onlab54400a92015-02-26 18:05:51 -0800460 time2 = time.time()
461 main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1))
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800462
Hari Krishna22c3d412015-02-17 16:48:12 -0800463 main.step( "Collect and store each Device active links Count" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800464 time1 = time.time()
465
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800466 for i in xrange( 1,( main.numMNswitches + 1 ), int( main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800467 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800468 for cli in main.CLIs:
kelvin-onlabc44f0192015-04-02 22:08:41 -0700469 if i >= main.numMNswitches + 1:
kelvin-onlabfbcd82f2015-04-02 12:06:00 -0700470 break
kelvin-onlab54400a92015-02-26 18:05:51 -0800471 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800472 t = main.Thread( target = cli.getDeviceLinksActiveCount,
473 threadID = main.threadID,
474 name = "getDevicePortsEnabledCount",
475 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800476 t.start()
477 pool.append(t)
478 i = i + 1
479 main.threadID = main.threadID + 1
480 for thread in pool:
481 thread.join()
482 linkCountResult = thread.result
Hari Krishna0ce0e152015-06-23 09:55:29 -0700483 #linkCount = re.split( r'\t+', linkCountResult )
484 #linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
485 main.deviceActiveLinksCount.append( linkCountResult )
kelvin-onlabfbcd82f2015-04-02 12:06:00 -0700486 print "Device Active Links Count Stored: \n", str( main.deviceActiveLinksCount )
kelvin-onlab54400a92015-02-26 18:05:51 -0800487 time2 = time.time()
488 main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800489
490 else:
491 main.log.info("Devices (expected): %s, Links (expected): %s" %
492 ( str( main.numMNswitches ), str( main.numMNlinks ) ) )
493 main.log.info("Devices (actual): %s, Links (actual): %s" %
494 ( numOnosDevices , numOnosLinks ) )
495 main.log.info("Topology does not match, exiting CHO test...")
Hari Krishnab35c6d02015-03-18 11:13:51 -0700496 topoResult = main.FALSE
Hari Krishnaade11a72015-07-01 17:06:46 -0700497 # It's better exit here from running the test
498 main.cleanup()
499 main.exit()
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800500
kelvin-onlab8a832582015-01-16 17:06:11 -0800501 # just returning TRUE for now as this one just collects data
Hari Krishnab35c6d02015-03-18 11:13:51 -0700502 case3Result = topoResult
Hari Krishna22c3d412015-02-17 16:48:12 -0800503 utilities.assert_equals( expect=main.TRUE, actual=case3Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800504 onpass="Saving ONOS topology data test PASS",
505 onfail="Saving ONOS topology data test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800506
kelvin-onlab65a72d22015-03-26 13:46:32 -0700507 def CASE40( self, main ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800508 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700509 Verify Reactive forwarding (Att Topology)
kelvin-onlab8a832582015-01-16 17:06:11 -0800510 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800511 import re
512 import copy
513 import time
Hari Krishnab35c6d02015-03-18 11:13:51 -0700514 main.log.report( "Verify Reactive forwarding (Att Topology)" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800515 main.log.report( "______________________________________________" )
516 main.case( "Enable Reactive forwarding and Verify ping all" )
517 main.step( "Enable Reactive forwarding" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800518 installResult = main.TRUE
kelvin-onlab06ade552015-03-31 18:09:27 -0700519 # Activate fwd app
520 appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700521 appCheck = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800522 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800523 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700524 t = main.Thread( target=cli.appToIDCheck,
525 name="appToIDCheck-" + str( i ),
526 args=[] )
527 pool.append( t )
kelvin-onlab54400a92015-02-26 18:05:51 -0800528 t.start()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800529 for t in pool:
530 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700531 appCheck = appCheck and t.result
532 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
533 onpass="App Ids seem to be correct",
534 onfail="Something is wrong with app Ids" )
535 if appCheck != main.TRUE:
536 main.log.warn( main.CLIs[0].apps() )
537 main.log.warn( main.CLIs[0].appIDs() )
538
539 time.sleep( 10 )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800540
kelvin-onlab8a832582015-01-16 17:06:11 -0800541 main.step( "Verify Pingall" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800542 ping_result = main.FALSE
543 time1 = time.time()
kelvin-onlab4df89f22015-04-13 18:10:23 -0700544 ping_result = main.Mininet1.pingall( timeout=main.pingTimeout )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800545 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800546 timeDiff = round( ( time2 - time1 ), 2 )
547 main.log.report(
548 "Time taken for Ping All: " +
549 str( timeDiff ) +
550 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800551
552 if ping_result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800553 main.log.report( "Pingall Test in Reactive mode successful" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800554 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800555 main.log.report( "Pingall Test in Reactive mode failed" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800556
kelvin-onlab8a832582015-01-16 17:06:11 -0800557 main.step( "Disable Reactive forwarding" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700558
559 main.log.info( "Uninstall reactive forwarding app" )
560 appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800561 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800562 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700563 t = main.Thread( target=cli.appToIDCheck,
564 name="appToIDCheck-" + str( i ),
565 args=[] )
566 pool.append( t )
kelvin-onlab54400a92015-02-26 18:05:51 -0800567 t.start()
kelvin-onlab06ade552015-03-31 18:09:27 -0700568
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800569 for t in pool:
570 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700571 appCheck = appCheck and t.result
572 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
573 onpass="App Ids seem to be correct",
574 onfail="Something is wrong with app Ids" )
575 if appCheck != main.TRUE:
576 main.log.warn( main.CLIs[0].apps() )
577 main.log.warn( main.CLIs[0].appIDs() )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800578
kelvin-onlab8a832582015-01-16 17:06:11 -0800579 # Waiting for reative flows to be cleared.
Hari Krishna0ce0e152015-06-23 09:55:29 -0700580 time.sleep( 30 )
kelvin-onlab06ade552015-03-31 18:09:27 -0700581 case40Result = installResult and uninstallResult and ping_result
582 utilities.assert_equals( expect=main.TRUE, actual=case40Result,
Hari Krishnab35c6d02015-03-18 11:13:51 -0700583 onpass="Reactive Mode Pingall test PASS",
584 onfail="Reactive Mode Pingall test FAIL" )
585
586 def CASE41( self, main ):
587 """
588 Verify Reactive forwarding (Chordal Topology)
589 """
590 import re
591 import copy
592 import time
593 main.log.report( "Verify Reactive forwarding (Chordal Topology)" )
594 main.log.report( "______________________________________________" )
595 main.case( "Enable Reactive forwarding and Verify ping all" )
596 main.step( "Enable Reactive forwarding" )
597 installResult = main.TRUE
kelvin-onlab06ade552015-03-31 18:09:27 -0700598 # Activate fwd app
599 appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" )
600
601 appCheck = main.TRUE
Hari Krishnab35c6d02015-03-18 11:13:51 -0700602 pool = []
Hari Krishnab35c6d02015-03-18 11:13:51 -0700603 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700604 t = main.Thread( target=cli.appToIDCheck,
605 name="appToIDCheck-" + str( i ),
606 args=[] )
607 pool.append( t )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700608 t.start()
Hari Krishnab35c6d02015-03-18 11:13:51 -0700609 for t in pool:
610 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700611 appCheck = appCheck and t.result
612 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
613 onpass="App Ids seem to be correct",
614 onfail="Something is wrong with app Ids" )
615 if appCheck != main.TRUE:
616 main.log.warn( main.CLIs[0].apps() )
617 main.log.warn( main.CLIs[0].appIDs() )
618
619 time.sleep( 10 )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700620
621 main.step( "Verify Pingall" )
622 ping_result = main.FALSE
623 time1 = time.time()
kelvin-onlab4df89f22015-04-13 18:10:23 -0700624 ping_result = main.Mininet1.pingall( timeout=main.pingTimeout )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700625 time2 = time.time()
626 timeDiff = round( ( time2 - time1 ), 2 )
627 main.log.report(
628 "Time taken for Ping All: " +
629 str( timeDiff ) +
630 " seconds" )
631
632 if ping_result == main.TRUE:
633 main.log.report( "Pingall Test in Reactive mode successful" )
634 else:
635 main.log.report( "Pingall Test in Reactive mode failed" )
636
637 main.step( "Disable Reactive forwarding" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700638
639 main.log.info( "Uninstall reactive forwarding app" )
640 appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700641 pool = []
Hari Krishnab35c6d02015-03-18 11:13:51 -0700642 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700643 t = main.Thread( target=cli.appToIDCheck,
644 name="appToIDCheck-" + str( i ),
645 args=[] )
646 pool.append( t )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700647 t.start()
kelvin-onlab06ade552015-03-31 18:09:27 -0700648
Hari Krishnab35c6d02015-03-18 11:13:51 -0700649 for t in pool:
650 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700651 appCheck = appCheck and t.result
652 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
653 onpass="App Ids seem to be correct",
654 onfail="Something is wrong with app Ids" )
655 if appCheck != main.TRUE:
656 main.log.warn( main.CLIs[0].apps() )
657 main.log.warn( main.CLIs[0].appIDs() )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700658
659 # Waiting for reative flows to be cleared.
Hari Krishna0ce0e152015-06-23 09:55:29 -0700660 time.sleep( 30 )
kelvin-onlab06ade552015-03-31 18:09:27 -0700661 case41Result = installResult and uninstallResult and ping_result
662 utilities.assert_equals( expect=main.TRUE, actual=case41Result,
Hari Krishnab35c6d02015-03-18 11:13:51 -0700663 onpass="Reactive Mode Pingall test PASS",
664 onfail="Reactive Mode Pingall test FAIL" )
665
666 def CASE42( self, main ):
667 """
668 Verify Reactive forwarding (Spine Topology)
669 """
670 import re
671 import copy
672 import time
673 main.log.report( "Verify Reactive forwarding (Spine Topology)" )
674 main.log.report( "______________________________________________" )
675 main.case( "Enable Reactive forwarding and Verify ping all" )
676 main.step( "Enable Reactive forwarding" )
677 installResult = main.TRUE
kelvin-onlab06ade552015-03-31 18:09:27 -0700678 # Activate fwd app
679 appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" )
680
681 appCheck = main.TRUE
Hari Krishnab35c6d02015-03-18 11:13:51 -0700682 pool = []
Hari Krishnab35c6d02015-03-18 11:13:51 -0700683 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700684 t = main.Thread( target=cli.appToIDCheck,
685 name="appToIDCheck-" + str( i ),
686 args=[] )
687 pool.append( t )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700688 t.start()
Hari Krishnab35c6d02015-03-18 11:13:51 -0700689 for t in pool:
690 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700691 appCheck = appCheck and t.result
692 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
693 onpass="App Ids seem to be correct",
694 onfail="Something is wrong with app Ids" )
695 if appCheck != main.TRUE:
696 main.log.warn( main.CLIs[0].apps() )
697 main.log.warn( main.CLIs[0].appIDs() )
698
699 time.sleep( 10 )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700700
701 main.step( "Verify Pingall" )
702 ping_result = main.FALSE
703 time1 = time.time()
kelvin-onlab4df89f22015-04-13 18:10:23 -0700704 ping_result = main.Mininet1.pingall( timeout=main.pingTimeout )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700705 time2 = time.time()
706 timeDiff = round( ( time2 - time1 ), 2 )
707 main.log.report(
708 "Time taken for Ping All: " +
709 str( timeDiff ) +
710 " seconds" )
711
712 if ping_result == main.TRUE:
713 main.log.report( "Pingall Test in Reactive mode successful" )
714 else:
715 main.log.report( "Pingall Test in Reactive mode failed" )
716
717 main.step( "Disable Reactive forwarding" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700718
719 main.log.info( "Uninstall reactive forwarding app" )
720 appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700721 pool = []
Hari Krishnab35c6d02015-03-18 11:13:51 -0700722 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700723 t = main.Thread( target=cli.appToIDCheck,
724 name="appToIDCheck-" + str( i ),
725 args=[] )
726 pool.append( t )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700727 t.start()
kelvin-onlab06ade552015-03-31 18:09:27 -0700728
Hari Krishnab35c6d02015-03-18 11:13:51 -0700729 for t in pool:
730 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700731 appCheck = appCheck and t.result
732 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
733 onpass="App Ids seem to be correct",
734 onfail="Something is wrong with app Ids" )
735 if appCheck != main.TRUE:
736 main.log.warn( main.CLIs[0].apps() )
737 main.log.warn( main.CLIs[0].appIDs() )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700738
739 # Waiting for reative flows to be cleared.
Hari Krishna0ce0e152015-06-23 09:55:29 -0700740 time.sleep( 30 )
kelvin-onlab06ade552015-03-31 18:09:27 -0700741 case42Result = installResult and uninstallResult and ping_result
742 utilities.assert_equals( expect=main.TRUE, actual=case42Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800743 onpass="Reactive Mode Pingall test PASS",
744 onfail="Reactive Mode Pingall test FAIL" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700745
kelvin-onlab8a832582015-01-16 17:06:11 -0800746 def CASE5( self, main ):
747 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800748 Compare current ONOS topology with reference data
kelvin-onlab8a832582015-01-16 17:06:11 -0800749 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800750 import re
kelvin-onlab54400a92015-02-26 18:05:51 -0800751
Hari Krishna22c3d412015-02-17 16:48:12 -0800752 devicesDPIDTemp = []
753 hostMACsTemp = []
754 deviceLinksTemp = []
755 deviceActiveLinksCountTemp = []
756 devicePortsEnabledCountTemp = []
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800757
kelvin-onlab8a832582015-01-16 17:06:11 -0800758 main.log.report(
759 "Compare ONOS topology with reference data in Stores" )
760 main.log.report( "__________________________________________________" )
761 main.case( "Compare ONOS topology with reference data" )
762
763 main.step( "Compare current Device ports enabled with reference" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800764 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800765 for i in xrange( 1,(main.numMNswitches + 1), int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800766 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800767 for cli in main.CLIs:
kelvin-onlabc44f0192015-04-02 22:08:41 -0700768 if i >= main.numMNswitches + 1:
769 break
kelvin-onlab54400a92015-02-26 18:05:51 -0800770 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800771 t = main.Thread(target = cli.getDevicePortsEnabledCount,
772 threadID = main.threadID,
773 name = "getDevicePortsEnabledCount",
774 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800775 t.start()
776 pool.append(t)
777 i = i + 1
778 main.threadID = main.threadID + 1
779 for thread in pool:
780 thread.join()
781 portResult = thread.result
Hari Krishna0ce0e152015-06-23 09:55:29 -0700782 #portTemp = re.split( r'\t+', portResult )
783 #portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
784 devicePortsEnabledCountTemp.append( portResult )
785
kelvin-onlab54400a92015-02-26 18:05:51 -0800786 time2 = time.time()
787 main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800788 main.log.info (
789 "Device Enabled ports EXPECTED: %s" %
790 str( main.devicePortsEnabledCount ) )
791 main.log.info (
792 "Device Enabled ports ACTUAL: %s" %
793 str( devicePortsEnabledCountTemp ) )
kelvin-onlab54400a92015-02-26 18:05:51 -0800794
Hari Krishna22c3d412015-02-17 16:48:12 -0800795 if ( cmp( main.devicePortsEnabledCount,
796 devicePortsEnabledCountTemp ) == 0 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800797 stepResult1 = main.TRUE
798 else:
799 stepResult1 = main.FALSE
800
kelvin-onlab8a832582015-01-16 17:06:11 -0800801 main.step( "Compare Device active links with reference" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800802 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800803 for i in xrange( 1, ( main.numMNswitches + 1) , int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800804 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800805 for cli in main.CLIs:
Hari Krishna0ce0e152015-06-23 09:55:29 -0700806 if i >= main.numMNswitches + 1:
807 break
kelvin-onlab54400a92015-02-26 18:05:51 -0800808 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800809 t = main.Thread(target = cli.getDeviceLinksActiveCount,
810 threadID = main.threadID,
Hari Krishna0ce0e152015-06-23 09:55:29 -0700811 name = "getDeviceLinksActiveCount",
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800812 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800813 t.start()
814 pool.append(t)
815 i = i + 1
816 main.threadID = main.threadID + 1
817 for thread in pool:
818 thread.join()
819 linkCountResult = thread.result
Hari Krishna0ce0e152015-06-23 09:55:29 -0700820 #linkCountTemp = re.split( r'\t+', linkCountResult )
821 #linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
822 deviceActiveLinksCountTemp.append( linkCountResult )
823
kelvin-onlab54400a92015-02-26 18:05:51 -0800824 time2 = time.time()
825 main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800826 main.log.info (
827 "Device Active links EXPECTED: %s" %
828 str( main.deviceActiveLinksCount ) )
829 main.log.info (
830 "Device Active links ACTUAL: %s" % str( deviceActiveLinksCountTemp ) )
831 if ( cmp( main.deviceActiveLinksCount, deviceActiveLinksCountTemp ) == 0 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800832 stepResult2 = main.TRUE
833 else:
834 stepResult2 = main.FALSE
835
kelvin-onlab8a832582015-01-16 17:06:11 -0800836 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800837 place holder for comparing devices, hosts, paths and intents if required.
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800838 Links and ports data would be incorrect with out devices anyways.
kelvin-onlab8a832582015-01-16 17:06:11 -0800839 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800840 case5Result = ( stepResult1 and stepResult2 )
841 utilities.assert_equals( expect=main.TRUE, actual=case5Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800842 onpass="Compare Topology test PASS",
843 onfail="Compare Topology test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800844
kelvin-onlab65a72d22015-03-26 13:46:32 -0700845 def CASE60( self ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800846 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700847 Install 300 host intents and verify ping all (Att Topology)
kelvin-onlab8a832582015-01-16 17:06:11 -0800848 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700849 main.log.report( "Add 300 host intents and verify pingall (Att Topology)" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800850 main.log.report( "_______________________________________" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800851 import itertools
Hari Krishnaef1bd4e2015-03-12 16:55:30 -0700852 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800853 main.case( "Install 300 host intents" )
854 main.step( "Add host Intents" )
855 intentResult = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800856 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800857
kelvin-onlab54400a92015-02-26 18:05:51 -0800858 intentIdList = []
859 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800860 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800861 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800862 for cli in main.CLIs:
863 if i >= len( hostCombos ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800864 break
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800865 t = main.Thread( target=cli.addHostIntent,
866 threadID=main.threadID,
kelvin-onlab54400a92015-02-26 18:05:51 -0800867 name="addHostIntent",
868 args=[hostCombos[i][0],hostCombos[i][1]])
869 pool.append(t)
870 t.start()
871 i = i + 1
872 main.threadID = main.threadID + 1
873 for thread in pool:
874 thread.join()
875 intentIdList.append(thread.result)
876 time2 = time.time()
kelvin-onlabadfc8db2015-03-24 15:52:48 -0700877 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
878
kelvin-onlab54400a92015-02-26 18:05:51 -0800879 intentResult = main.TRUE
880 intentsJson = main.ONOScli2.intents()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800881 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
kelvin-onlab54400a92015-02-26 18:05:51 -0800882 intentsJson = intentsJson)
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -0700883 print "len of intent ID", str(len(intentIdList))
884 print "len of intent state results", str(len(getIntentStateResult))
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800885 print getIntentStateResult
Hari Krishnab35c6d02015-03-18 11:13:51 -0700886 # Takes awhile for all the onos to get the intents
Hari Krishna0ce0e152015-06-23 09:55:29 -0700887 time.sleep( 30 )
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -0700888 """intentState = main.TRUE
889 for i in getIntentStateResult:
890 if getIntentStateResult.get( 'state' ) != 'INSTALLED':
891 """
892
893
kelvin-onlab8a832582015-01-16 17:06:11 -0800894 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800895 pingResult = main.FALSE
896 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -0700897 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800898 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800899 timeDiff = round( ( time2 - time1 ), 2 )
900 main.log.report(
901 "Time taken for Ping All: " +
902 str( timeDiff ) +
903 " seconds" )
904 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
905 onpass="PING ALL PASS",
906 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800907
kelvin-onlab65a72d22015-03-26 13:46:32 -0700908 case60Result = ( intentResult and pingResult )
kelvin-onlab54400a92015-02-26 18:05:51 -0800909
kelvin-onlab8a832582015-01-16 17:06:11 -0800910 utilities.assert_equals(
911 expect=main.TRUE,
kelvin-onlab65a72d22015-03-26 13:46:32 -0700912 actual=case60Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800913 onpass="Install 300 Host Intents and Ping All test PASS",
914 onfail="Install 300 Host Intents and Ping All test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800915
kelvin-onlab65a72d22015-03-26 13:46:32 -0700916 def CASE61( self ):
917 """
918 Install 600 host intents and verify ping all for Chordal Topology
919 """
920 main.log.report( "Add 600 host intents and verify pingall (Chordal Topo)" )
921 main.log.report( "_______________________________________" )
922 import itertools
923
924 main.case( "Install 600 host intents" )
925 main.step( "Add host Intents" )
926 intentResult = main.TRUE
927 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
928
929 intentIdList = []
930 time1 = time.time()
931
932 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
933 pool = []
934 for cli in main.CLIs:
935 if i >= len( hostCombos ):
936 break
937 t = main.Thread( target=cli.addHostIntent,
938 threadID=main.threadID,
939 name="addHostIntent",
940 args=[hostCombos[i][0],hostCombos[i][1]])
941 pool.append(t)
942 t.start()
943 i = i + 1
944 main.threadID = main.threadID + 1
945 for thread in pool:
946 thread.join()
947 intentIdList.append(thread.result)
948 time2 = time.time()
949 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
950 intentResult = main.TRUE
951 intentsJson = main.ONOScli2.intents()
952 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
953 intentsJson = intentsJson)
954 print getIntentStateResult
955
956 main.step( "Verify Ping across all hosts" )
957 pingResult = main.FALSE
958 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -0700959 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlab65a72d22015-03-26 13:46:32 -0700960 time2 = time.time()
961 timeDiff = round( ( time2 - time1 ), 2 )
962 main.log.report(
963 "Time taken for Ping All: " +
964 str( timeDiff ) +
965 " seconds" )
966 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
967 onpass="PING ALL PASS",
968 onfail="PING ALL FAIL" )
969
970 case14Result = ( intentResult and pingResult )
971
972 utilities.assert_equals(
973 expect=main.TRUE,
974 actual=case14Result,
975 onpass="Install 300 Host Intents and Ping All test PASS",
976 onfail="Install 300 Host Intents and Ping All test FAIL" )
977
978 def CASE62( self ):
979 """
980 Install 2278 host intents and verify ping all for Spine Topology
981 """
982 main.log.report( "Add 2278 host intents and verify pingall (Spine Topo)" )
983 main.log.report( "_______________________________________" )
984 import itertools
985
986 main.case( "Install 2278 host intents" )
987 main.step( "Add host Intents" )
988 intentResult = main.TRUE
989 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
990 main.pingTimeout = 300
991 intentIdList = []
992 time1 = time.time()
993 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
994 pool = []
995 for cli in main.CLIs:
996 if i >= len( hostCombos ):
997 break
998 t = main.Thread( target=cli.addHostIntent,
999 threadID=main.threadID,
1000 name="addHostIntent",
1001 args=[hostCombos[i][0],hostCombos[i][1]])
1002 pool.append(t)
1003 t.start()
1004 i = i + 1
1005 main.threadID = main.threadID + 1
1006 for thread in pool:
1007 thread.join()
1008 intentIdList.append(thread.result)
1009 time2 = time.time()
1010 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
1011 intentResult = main.TRUE
1012 intentsJson = main.ONOScli2.intents()
1013 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1014 intentsJson = intentsJson)
1015 print getIntentStateResult
1016
1017 main.step( "Verify Ping across all hosts" )
1018 pingResult = main.FALSE
1019 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001020 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlab65a72d22015-03-26 13:46:32 -07001021 time2 = time.time()
1022 timeDiff = round( ( time2 - time1 ), 2 )
1023 main.log.report(
1024 "Time taken for Ping All: " +
1025 str( timeDiff ) +
1026 " seconds" )
1027 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1028 onpass="PING ALL PASS",
1029 onfail="PING ALL FAIL" )
1030
1031 case15Result = ( intentResult and pingResult )
1032
1033 utilities.assert_equals(
1034 expect=main.TRUE,
1035 actual=case15Result,
1036 onpass="Install 2278 Host Intents and Ping All test PASS",
1037 onfail="Install 2278 Host Intents and Ping All test FAIL" )
1038
kelvin-onlab8a832582015-01-16 17:06:11 -08001039 def CASE70( self, main ):
1040 """
Hari Krishnab35c6d02015-03-18 11:13:51 -07001041 Randomly bring some core links down and verify ping all ( Host Intents-Att Topo)
kelvin-onlab8a832582015-01-16 17:06:11 -08001042 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001043 import random
Hari Krishna22c3d412015-02-17 16:48:12 -08001044 main.randomLink1 = []
1045 main.randomLink2 = []
1046 main.randomLink3 = []
kelvin-onlab65a72d22015-03-26 13:46:32 -07001047 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1048 link1End2 = main.params[ 'ATTCORELINKS' ][ 'linkS3b' ].split( ',' )
1049 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1050 link2End2 = main.params[ 'ATTCORELINKS' ][ 'linkS14b' ].split( ',' )
1051 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
1052 link3End2 = main.params[ 'ATTCORELINKS' ][ 'linkS18b' ].split( ',' )
1053 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001054 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001055
Hari Krishnab35c6d02015-03-18 11:13:51 -07001056 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Att Topo)" )
1057 main.log.report( "___________________________________________________________________________" )
Hari Krishnad97213e2015-01-24 19:30:14 -08001058 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
1059 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001060 if ( int( switchLinksToToggle ) ==
1061 0 or int( switchLinksToToggle ) > 5 ):
Hari Krishna46997e02015-01-27 11:23:07 -08001062 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 -07001063 #main.cleanup()
1064 #main.exit()
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001065 else:
Hari Krishnad97213e2015-01-24 19:30:14 -08001066 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 -08001067
kelvin-onlab8a832582015-01-16 17:06:11 -08001068 main.step( "Cut links on Core devices using user provided range" )
Hari Krishna22c3d412015-02-17 16:48:12 -08001069 main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
1070 main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
1071 main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001072 for i in range( int( switchLinksToToggle ) ):
1073 main.Mininet1.link(
1074 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001075 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001076 OPTION="down" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001077 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001078 main.Mininet1.link(
1079 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001080 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001081 OPTION="down" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001082 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001083 main.Mininet1.link(
1084 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001085 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001086 OPTION="down" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001087 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001088
1089 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001090 linkDown = main.ONOSbench.checkStatus(
Hari Krishna22c3d412015-02-17 16:48:12 -08001091 topology_output, main.numMNswitches, str(
1092 int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001093 utilities.assert_equals(
1094 expect=main.TRUE,
1095 actual=linkDown,
1096 onpass="Link Down discovered properly",
1097 onfail="Link down was not discovered in " +
1098 str( link_sleep ) +
1099 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001100
kelvin-onlab8a832582015-01-16 17:06:11 -08001101 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001102 pingResultLinkDown = main.FALSE
1103 time1 = time.time()
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001104 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001105 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001106 timeDiff = round( ( time2 - time1 ), 2 )
1107 main.log.report(
1108 "Time taken for Ping All: " +
1109 str( timeDiff ) +
1110 " seconds" )
1111 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1112 onpass="PING ALL PASS",
1113 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001114
Hari Krishna22c3d412015-02-17 16:48:12 -08001115 caseResult70 = linkDown and pingResultLinkDown
1116 utilities.assert_equals( expect=main.TRUE, actual=caseResult70,
kelvin-onlab8a832582015-01-16 17:06:11 -08001117 onpass="Random Link cut Test PASS",
1118 onfail="Random Link cut Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001119
kelvin-onlab8a832582015-01-16 17:06:11 -08001120 def CASE80( self, main ):
1121 """
Hari Krishnab35c6d02015-03-18 11:13:51 -07001122 Bring the core links up that are down and verify ping all ( Host Intents-Att Topo )
kelvin-onlab8a832582015-01-16 17:06:11 -08001123 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001124 import random
kelvin-onlab65a72d22015-03-26 13:46:32 -07001125 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1126 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1127 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001128 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001129 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001130
kelvin-onlab8a832582015-01-16 17:06:11 -08001131 main.log.report(
Hari Krishnab35c6d02015-03-18 11:13:51 -07001132 "Bring the core links up that are down and verify ping all (Host Intents-Att Topo" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001133 main.log.report(
1134 "__________________________________________________________________" )
1135 main.case(
1136 "Host intents - Bring the core links up that are down and verify ping all" )
1137 main.step( "Bring randomly cut links on Core devices up" )
1138 for i in range( int( switchLinksToToggle ) ):
1139 main.Mininet1.link(
1140 END1=link1End1,
kelvin-onlab54400a92015-02-26 18:05:51 -08001141 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001142 OPTION="up" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001143 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001144 main.Mininet1.link(
1145 END1=link2End1,
kelvin-onlab54400a92015-02-26 18:05:51 -08001146 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001147 OPTION="up" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001148 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001149 main.Mininet1.link(
1150 END1=link3End1,
kelvin-onlab54400a92015-02-26 18:05:51 -08001151 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001152 OPTION="up" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001153 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001154
1155 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001156 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -08001157 topology_output,
Hari Krishna22c3d412015-02-17 16:48:12 -08001158 main.numMNswitches,
1159 str( main.numMNlinks ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001160 utilities.assert_equals(
1161 expect=main.TRUE,
1162 actual=linkUp,
1163 onpass="Link up discovered properly",
1164 onfail="Link up was not discovered in " +
1165 str( link_sleep ) +
1166 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001167
kelvin-onlab8a832582015-01-16 17:06:11 -08001168 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001169 pingResultLinkUp = main.FALSE
1170 time1 = time.time()
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001171 pingResultLinkUp = main.Mininet1.pingall( timeout=main.pingTimeout )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001172 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001173 timeDiff = round( ( time2 - time1 ), 2 )
1174 main.log.report(
1175 "Time taken for Ping All: " +
1176 str( timeDiff ) +
1177 " seconds" )
1178 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1179 onpass="PING ALL PASS",
1180 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001181
Hari Krishna22c3d412015-02-17 16:48:12 -08001182 caseResult80 = linkUp and pingResultLinkUp
1183 utilities.assert_equals( expect=main.TRUE, actual=caseResult80,
kelvin-onlab8a832582015-01-16 17:06:11 -08001184 onpass="Link Up Test PASS",
1185 onfail="Link Up Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001186
kelvin-onlab8a832582015-01-16 17:06:11 -08001187 def CASE71( self, main ):
1188 """
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001189 Randomly bring some core links down and verify ping all ( Point Intents-Att Topo)
kelvin-onlab8a832582015-01-16 17:06:11 -08001190 """
kelvin8ec71442015-01-15 16:57:00 -08001191 import random
Hari Krishna22c3d412015-02-17 16:48:12 -08001192 main.randomLink1 = []
1193 main.randomLink2 = []
1194 main.randomLink3 = []
kelvin-onlab65a72d22015-03-26 13:46:32 -07001195 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1196 link1End2 = main.params[ 'ATTCORELINKS' ][ 'linkS3b' ].split( ',' )
1197 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1198 link2End2 = main.params[ 'ATTCORELINKS' ][ 'linkS14b' ].split( ',' )
1199 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
1200 link3End2 = main.params[ 'ATTCORELINKS' ][ 'linkS18b' ].split( ',' )
1201 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001202 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin8ec71442015-01-15 16:57:00 -08001203
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001204 main.log.report( "Randomly bring some core links down and verify ping all (Point Intents-Att Topo)" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001205 main.log.report( "___________________________________________________________________________" )
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001206 main.case( "Point intents - Randomly bring some core links down and verify ping all" )
Hari Krishnad97213e2015-01-24 19:30:14 -08001207 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001208 if ( int( switchLinksToToggle ) ==
1209 0 or int( switchLinksToToggle ) > 5 ):
kelvin-onlab65a72d22015-03-26 13:46:32 -07001210 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 -07001211 #main.cleanup()
1212 #main.exit()
kelvin8ec71442015-01-15 16:57:00 -08001213 else:
kelvin-onlab65a72d22015-03-26 13:46:32 -07001214 main.log.info( "User provided Core switch links range to toggle is correct, proceeding to run the test" )
kelvin8ec71442015-01-15 16:57:00 -08001215
kelvin-onlab8a832582015-01-16 17:06:11 -08001216 main.step( "Cut links on Core devices using user provided range" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001217 main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
1218 main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
1219 main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001220 for i in range( int( switchLinksToToggle ) ):
1221 main.Mininet1.link(
1222 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001223 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001224 OPTION="down" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001225 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001226 main.Mininet1.link(
1227 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001228 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001229 OPTION="down" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001230 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001231 main.Mininet1.link(
1232 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001233 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001234 OPTION="down" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001235 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -08001236
1237 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001238 linkDown = main.ONOSbench.checkStatus(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001239 topology_output, main.numMNswitches, str(
1240 int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001241 utilities.assert_equals(
1242 expect=main.TRUE,
1243 actual=linkDown,
1244 onpass="Link Down discovered properly",
1245 onfail="Link down was not discovered in " +
1246 str( link_sleep ) +
1247 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -08001248
kelvin-onlab8a832582015-01-16 17:06:11 -08001249 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -08001250 pingResultLinkDown = main.FALSE
1251 time1 = time.time()
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001252 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout)
kelvin8ec71442015-01-15 16:57:00 -08001253 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001254 timeDiff = round( ( time2 - time1 ), 2 )
1255 main.log.report(
1256 "Time taken for Ping All: " +
1257 str( timeDiff ) +
1258 " seconds" )
1259 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1260 onpass="PING ALL PASS",
1261 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001262
kelvin-onlab65a72d22015-03-26 13:46:32 -07001263 caseResult71 = linkDown and pingResultLinkDown
1264 utilities.assert_equals( expect=main.TRUE, actual=caseResult71,
kelvin-onlab8a832582015-01-16 17:06:11 -08001265 onpass="Random Link cut Test PASS",
1266 onfail="Random Link cut Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001267
kelvin-onlab8a832582015-01-16 17:06:11 -08001268 def CASE81( self, main ):
1269 """
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001270 Bring the core links up that are down and verify ping all ( Point Intents-Att Topo )
kelvin-onlab8a832582015-01-16 17:06:11 -08001271 """
kelvin8ec71442015-01-15 16:57:00 -08001272 import random
kelvin-onlab65a72d22015-03-26 13:46:32 -07001273 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1274 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1275 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001276 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001277 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
kelvin8ec71442015-01-15 16:57:00 -08001278
kelvin-onlab8a832582015-01-16 17:06:11 -08001279 main.log.report(
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001280 "Bring the core links up that are down and verify ping all ( Point Intents-Att Topo" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001281 main.log.report(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001282 "__________________________________________________________________" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001283 main.case(
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001284 "Point intents - Bring the core links up that are down and verify ping all" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001285 main.step( "Bring randomly cut links on Core devices up" )
1286 for i in range( int( switchLinksToToggle ) ):
1287 main.Mininet1.link(
1288 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001289 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001290 OPTION="up" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001291 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001292 main.Mininet1.link(
1293 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001294 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001295 OPTION="up" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001296 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001297 main.Mininet1.link(
1298 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001299 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001300 OPTION="up" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001301 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -08001302
1303 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001304 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -08001305 topology_output,
Hari Krishna22c3d412015-02-17 16:48:12 -08001306 main.numMNswitches,
1307 str( main.numMNlinks ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001308 utilities.assert_equals(
1309 expect=main.TRUE,
1310 actual=linkUp,
1311 onpass="Link up discovered properly",
1312 onfail="Link up was not discovered in " +
1313 str( link_sleep ) +
1314 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -08001315
kelvin-onlab8a832582015-01-16 17:06:11 -08001316 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -08001317 pingResultLinkUp = main.FALSE
1318 time1 = time.time()
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001319 pingResultLinkUp = main.Mininet1.pingall(timeout = main.pingTimeout )
kelvin8ec71442015-01-15 16:57:00 -08001320 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001321 timeDiff = round( ( time2 - time1 ), 2 )
1322 main.log.report(
1323 "Time taken for Ping All: " +
1324 str( timeDiff ) +
1325 " seconds" )
1326 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1327 onpass="PING ALL PASS",
1328 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001329
Hari Krishna22c3d412015-02-17 16:48:12 -08001330 caseResult81 = linkUp and pingResultLinkUp
1331 utilities.assert_equals( expect=main.TRUE, actual=caseResult81,
kelvin-onlab8a832582015-01-16 17:06:11 -08001332 onpass="Link Up Test PASS",
1333 onfail="Link Up Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001334
Hari Krishnab35c6d02015-03-18 11:13:51 -07001335 def CASE72( self, main ):
1336 """
1337 Randomly bring some links down and verify ping all ( Host Intents-Chordal Topo)
1338 """
1339 import random
1340 import itertools
1341 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1342
1343 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Chordal Topo)" )
1344 main.log.report( "___________________________________________________________________________" )
1345 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
1346 switches = []
1347 switchesComb = []
1348 for i in range( main.numMNswitches ):
1349 switches.append('s%d'%(i+1))
1350 switchesLinksComb = list(itertools.combinations(switches,2))
1351 main.randomLinks = random.sample(switchesLinksComb, 5 )
1352 print main.randomLinks
1353 main.step( "Cut links on random devices" )
1354
1355 for switch in main.randomLinks:
1356 main.Mininet1.link(
1357 END1=switch[0],
1358 END2=switch[1],
1359 OPTION="down")
Hari Krishna0ce0e152015-06-23 09:55:29 -07001360 time.sleep( link_sleep )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001361
1362 topology_output = main.ONOScli2.topology()
1363 linkDown = main.ONOSbench.checkStatus(
1364 topology_output, main.numMNswitches, str(
1365 int( main.numMNlinks ) - 5 * 2 ) )
1366 utilities.assert_equals(
1367 expect=main.TRUE,
1368 actual=linkDown,
1369 onpass="Link Down discovered properly",
1370 onfail="Link down was not discovered in " +
1371 str( link_sleep ) +
1372 " seconds" )
1373
1374 main.step( "Verify Ping across all hosts" )
1375 pingResultLinkDown = main.FALSE
1376 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001377 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001378 time2 = time.time()
1379 timeDiff = round( ( time2 - time1 ), 2 )
1380 main.log.report(
1381 "Time taken for Ping All: " +
1382 str( timeDiff ) +
1383 " seconds" )
1384 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1385 onpass="PING ALL PASS",
1386 onfail="PING ALL FAIL" )
1387
kelvin-onlab65a72d22015-03-26 13:46:32 -07001388 caseResult71 = pingResultLinkDown
1389 utilities.assert_equals( expect=main.TRUE, actual=caseResult71,
Hari Krishnab35c6d02015-03-18 11:13:51 -07001390 onpass="Random Link cut Test PASS",
1391 onfail="Random Link cut Test FAIL" )
1392
1393 def CASE82( self, main ):
1394 """
1395 Bring the core links up that are down and verify ping all ( Host Intents Chordal Topo )
1396 """
1397 import random
1398 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1399
1400 main.log.report(
1401 "Bring the core links up that are down and verify ping all (Host Intents-Chordal Topo" )
1402 main.log.report(
1403 "__________________________________________________________________" )
1404 main.case(
1405 "Host intents - Bring the core links up that are down and verify ping all" )
1406 main.step( "Bring randomly cut links on devices up" )
1407
1408 for switch in main.randomLinks:
1409 main.Mininet1.link(
1410 END1=switch[0],
1411 END2=switch[1],
1412 OPTION="up")
Hari Krishna0ce0e152015-06-23 09:55:29 -07001413 time.sleep( link_sleep )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001414
1415 topology_output = main.ONOScli2.topology()
1416 linkUp = main.ONOSbench.checkStatus(
1417 topology_output,
1418 main.numMNswitches,
1419 str( main.numMNlinks ) )
1420 utilities.assert_equals(
1421 expect=main.TRUE,
1422 actual=linkUp,
1423 onpass="Link up discovered properly",
1424 onfail="Link up was not discovered in " +
1425 str( link_sleep ) +
1426 " seconds" )
1427
1428 main.step( "Verify Ping across all hosts" )
1429 pingResultLinkUp = main.FALSE
1430 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001431 pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001432 time2 = time.time()
1433 timeDiff = round( ( time2 - time1 ), 2 )
1434 main.log.report(
1435 "Time taken for Ping All: " +
1436 str( timeDiff ) +
1437 " seconds" )
1438 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1439 onpass="PING ALL PASS",
1440 onfail="PING ALL FAIL" )
1441
1442 caseResult82 = linkUp and pingResultLinkUp
1443 utilities.assert_equals( expect=main.TRUE, actual=caseResult82,
1444 onpass="Link Up Test PASS",
1445 onfail="Link Up Test FAIL" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001446
Hari Krishnab35c6d02015-03-18 11:13:51 -07001447 def CASE73( self, main ):
1448 """
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001449 Randomly bring some links down and verify ping all ( Point Intents-Chordal Topo)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001450 """
1451 import random
kelvin-onlab65a72d22015-03-26 13:46:32 -07001452 import itertools
Hari Krishnab35c6d02015-03-18 11:13:51 -07001453 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001454
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001455 main.log.report( "Randomly bring some core links down and verify ping all ( Point Intents-Chordal Topo)" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001456 main.log.report( "___________________________________________________________________________" )
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001457 main.case( "Point intents - Randomly bring some core links down and verify ping all" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001458 switches = []
1459 switchesComb = []
1460 for i in range( main.numMNswitches ):
1461 switches.append('s%d'%(i+1))
1462 switchesLinksComb = list(itertools.combinations(switches,2))
1463 main.randomLinks = random.sample(switchesLinksComb, 5 )
1464 print main.randomLinks
1465 main.step( "Cut links on random devices" )
1466
1467 for switch in main.randomLinks:
Hari Krishnab35c6d02015-03-18 11:13:51 -07001468 main.Mininet1.link(
1469 END1=switch[0],
1470 END2=switch[1],
kelvin-onlab65a72d22015-03-26 13:46:32 -07001471 OPTION="down")
Hari Krishna0ce0e152015-06-23 09:55:29 -07001472 time.sleep( link_sleep )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001473
1474 topology_output = main.ONOScli2.topology()
1475 linkDown = main.ONOSbench.checkStatus(
1476 topology_output, main.numMNswitches, str(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001477 int( main.numMNlinks ) - 5 * 2 ) )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001478 utilities.assert_equals(
1479 expect=main.TRUE,
1480 actual=linkDown,
1481 onpass="Link Down discovered properly",
1482 onfail="Link down was not discovered in " +
1483 str( link_sleep ) +
1484 " seconds" )
1485
1486 main.step( "Verify Ping across all hosts" )
1487 pingResultLinkDown = main.FALSE
1488 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001489 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001490 time2 = time.time()
1491 timeDiff = round( ( time2 - time1 ), 2 )
1492 main.log.report(
1493 "Time taken for Ping All: " +
1494 str( timeDiff ) +
1495 " seconds" )
1496 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1497 onpass="PING ALL PASS",
1498 onfail="PING ALL FAIL" )
1499
kelvin-onlab65a72d22015-03-26 13:46:32 -07001500 caseResult73 = pingResultLinkDown
Hari Krishnab35c6d02015-03-18 11:13:51 -07001501 utilities.assert_equals( expect=main.TRUE, actual=caseResult73,
1502 onpass="Random Link cut Test PASS",
1503 onfail="Random Link cut Test FAIL" )
1504
1505 def CASE83( self, main ):
1506 """
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001507 Bring the core links up that are down and verify ping all ( Point Intents Chordal Topo )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001508 """
1509 import random
Hari Krishnab35c6d02015-03-18 11:13:51 -07001510 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001511
Hari Krishnab35c6d02015-03-18 11:13:51 -07001512 main.log.report(
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001513 "Bring the core links up that are down and verify ping all ( Point Intents-Chordal Topo" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001514 main.log.report(
1515 "__________________________________________________________________" )
1516 main.case(
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001517 "Point intents - Bring the core links up that are down and verify ping all" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001518 main.step( "Bring randomly cut links on devices up" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001519
kelvin-onlab65a72d22015-03-26 13:46:32 -07001520 for switch in main.randomLinks:
Hari Krishnab35c6d02015-03-18 11:13:51 -07001521 main.Mininet1.link(
1522 END1=switch[0],
1523 END2=switch[1],
1524 OPTION="up")
Hari Krishna0ce0e152015-06-23 09:55:29 -07001525 time.sleep( link_sleep )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001526
1527 topology_output = main.ONOScli2.topology()
1528 linkUp = main.ONOSbench.checkStatus(
1529 topology_output,
1530 main.numMNswitches,
1531 str( main.numMNlinks ) )
1532 utilities.assert_equals(
1533 expect=main.TRUE,
1534 actual=linkUp,
1535 onpass="Link up discovered properly",
1536 onfail="Link up was not discovered in " +
1537 str( link_sleep ) +
1538 " seconds" )
1539
1540 main.step( "Verify Ping across all hosts" )
1541 pingResultLinkUp = main.FALSE
1542 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001543 pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001544 time2 = time.time()
1545 timeDiff = round( ( time2 - time1 ), 2 )
1546 main.log.report(
1547 "Time taken for Ping All: " +
1548 str( timeDiff ) +
1549 " seconds" )
1550 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1551 onpass="PING ALL PASS",
1552 onfail="PING ALL FAIL" )
1553
1554 caseResult83 = linkUp and pingResultLinkUp
1555 utilities.assert_equals( expect=main.TRUE, actual=caseResult83,
1556 onpass="Link Up Test PASS",
1557 onfail="Link Up Test FAIL" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001558
1559 def CASE74( self, main ):
1560 """
1561 Randomly bring some core links down and verify ping all ( Host Intents-Spine Topo)
1562 """
1563 import random
1564 main.randomLink1 = []
1565 main.randomLink2 = []
1566 main.randomLink3 = []
1567 main.randomLink4 = []
1568 link1End1 = main.params[ 'SPINECORELINKS' ][ 'linkS9' ]
1569 link1End2top = main.params[ 'SPINECORELINKS' ][ 'linkS9top' ].split( ',' )
1570 link1End2bot = main.params[ 'SPINECORELINKS' ][ 'linkS9bot' ].split( ',' )
1571 link2End1 = main.params[ 'SPINECORELINKS' ][ 'linkS10' ]
1572 link2End2top = main.params[ 'SPINECORELINKS' ][ 'linkS10top' ].split( ',' )
1573 link2End2bot = main.params[ 'SPINECORELINKS' ][ 'linkS10bot' ].split( ',' )
1574 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1575 main.pingTimeout = 400
1576
1577 main.log.report( "Bring some core links down and verify ping all (Host Intents-Spine Topo)" )
1578 main.log.report( "___________________________________________________________________________" )
1579
1580 linkIndex = range(4)
1581 linkIndexS9 = random.sample(linkIndex,1)[0]
1582 linkIndex.remove(linkIndexS9)
1583 linkIndexS10 = random.sample(linkIndex,1)[0]
1584 main.randomLink1 = link1End2top[linkIndexS9]
1585 main.randomLink2 = link2End2top[linkIndexS10]
1586 main.randomLink3 = random.sample(link1End2bot,1)[0]
1587 main.randomLink4 = random.sample(link2End2bot,1)[0]
kelvin-onlab77d6c302015-03-31 11:33:32 -07001588 # main.Mininet1.link( END1=link1End1, END2=main.randomLink1, OPTION="down" )
1589 # main.Mininet1.link( END1=link2End1, END2=main.randomLink2, OPTION="down" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001590 main.Mininet1.link( END1=link1End1, END2=main.randomLink3, OPTION="down" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001591 time.sleep( link_sleep )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001592 main.Mininet1.link( END1=link2End1, END2=main.randomLink4, OPTION="down" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001593 time.sleep( link_sleep )
1594
1595 topology_output = main.ONOScli2.topology()
1596 linkDown = main.ONOSbench.checkStatus(
1597 topology_output, main.numMNswitches, str(
1598 int( main.numMNlinks ) - 8 ))
1599 utilities.assert_equals(
1600 expect=main.TRUE,
1601 actual=linkDown,
1602 onpass="Link Down discovered properly",
1603 onfail="Link down was not discovered in " +
1604 str( link_sleep ) +
1605 " seconds" )
1606
1607 main.step( "Verify Ping across all hosts" )
1608 pingResultLinkDown = main.FALSE
1609 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001610 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlab65a72d22015-03-26 13:46:32 -07001611 time2 = time.time()
1612 timeDiff = round( ( time2 - time1 ), 2 )
1613 main.log.report(
1614 "Time taken for Ping All: " +
1615 str( timeDiff ) +
1616 " seconds" )
1617 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1618 onpass="PING ALL PASS",
1619 onfail="PING ALL FAIL" )
1620
1621 caseResult74 = linkDown and pingResultLinkDown
1622 utilities.assert_equals( expect=main.TRUE, actual=caseResult74,
1623 onpass="Random Link cut Test PASS",
1624 onfail="Random Link cut Test FAIL" )
1625
1626 def CASE84( self, main ):
1627 """
1628 Bring the core links up that are down and verify ping all ( Host Intents-Spine Topo )
1629 """
1630 import random
1631 link1End1 = main.params[ 'SPINECORELINKS' ][ 'linkS9' ]
1632 link2End1 = main.params[ 'SPINECORELINKS' ][ 'linkS10' ]
1633 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1634 main.log.report(
1635 "Bring the core links up that are down and verify ping all (Host Intents-Spine Topo" )
1636 main.log.report(
1637 "__________________________________________________________________" )
1638 main.case(
1639 "Host intents - Bring the core links up that are down and verify ping all" )
1640
kelvin-onlab77d6c302015-03-31 11:33:32 -07001641 #main.Mininet1.link( END1=link1End1, END2=main.randomLink1, OPTION="up" )
1642 #main.Mininet1.link( END1=link2End1, END2=main.randomLink2, OPTION="up" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001643 main.Mininet1.link( END1=link1End1, END2=main.randomLink3, OPTION="up" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001644 time.sleep( link_sleep )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001645 main.Mininet1.link( END1=link2End1, END2=main.randomLink4, OPTION="up" )
1646 time.sleep( link_sleep )
1647
kelvin-onlab65a72d22015-03-26 13:46:32 -07001648 topology_output = main.ONOScli2.topology()
1649 linkUp = main.ONOSbench.checkStatus(
1650 topology_output,
1651 main.numMNswitches,
1652 str( main.numMNlinks ) )
1653 utilities.assert_equals(
1654 expect=main.TRUE,
1655 actual=linkUp,
1656 onpass="Link up discovered properly",
1657 onfail="Link up was not discovered in " +
1658 str( link_sleep ) +
1659 " seconds" )
1660
1661 main.step( "Verify Ping across all hosts" )
1662 pingResultLinkUp = main.FALSE
1663 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001664 pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlab65a72d22015-03-26 13:46:32 -07001665 time2 = time.time()
1666 timeDiff = round( ( time2 - time1 ), 2 )
1667 main.log.report(
1668 "Time taken for Ping All: " +
1669 str( timeDiff ) +
1670 " seconds" )
1671 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1672 onpass="PING ALL PASS",
1673 onfail="PING ALL FAIL" )
1674
1675 caseResult84 = linkUp and pingResultLinkUp
1676 utilities.assert_equals( expect=main.TRUE, actual=caseResult84,
1677 onpass="Link Up Test PASS",
1678 onfail="Link Up Test FAIL" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001679
1680 def CASE90( self ):
kelvin-onlab8a832582015-01-16 17:06:11 -08001681 """
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001682 Install 600 point intents and verify ping all (Att Topology)
kelvin-onlab8a832582015-01-16 17:06:11 -08001683 """
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001684 main.log.report( "Add 600 point intents and verify pingall (Att Topology)" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001685 main.log.report( "_______________________________________" )
1686 import itertools
1687 import time
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001688 main.case( "Install 600 point intents" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001689 main.step( "Add point Intents" )
1690 intentResult = main.TRUE
1691 deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) )
1692
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001693 intentIdList = []
Hari Krishnab35c6d02015-03-18 11:13:51 -07001694 time1 = time.time()
Hari Krishnab35c6d02015-03-18 11:13:51 -07001695 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1696 pool = []
1697 for cli in main.CLIs:
1698 if i >= len( deviceCombos ):
1699 break
1700 t = main.Thread( target=cli.addPointIntent,
1701 threadID=main.threadID,
1702 name="addPointIntent",
Hari Krishna0ce0e152015-06-23 09:55:29 -07001703 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4",main.MACsDict.get(deviceCombos[i][0]),main.MACsDict.get(deviceCombos[i][1])])
1704 pool.append(t)
1705 #time.sleep(1)
1706 t.start()
1707 i = i + 1
1708 main.threadID = main.threadID + 1
1709 for thread in pool:
1710 thread.join()
1711 intentIdList.append(thread.result)
1712 time2 = time.time()
1713 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1714 intentResult = main.TRUE
1715 intentsJson = main.ONOScli2.intents()
1716 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1717 intentsJson = intentsJson)
1718 print getIntentStateResult
1719 # Takes awhile for all the onos to get the intents
1720 time.sleep(60)
1721 main.step( "Verify Ping across all hosts" )
1722 pingResult = main.FALSE
1723 time1 = time.time()
1724 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
1725 time2 = time.time()
1726 timeDiff = round( ( time2 - time1 ), 2 )
1727 main.log.report(
1728 "Time taken for Ping All: " +
1729 str( timeDiff ) +
1730 " seconds" )
1731 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1732 onpass="PING tALL PASS",
1733 onfail="PING ALL FAIL" )
1734
1735 case90Result = ( intentResult and pingResult )
1736
1737 utilities.assert_equals(
1738 expect=main.TRUE,
1739 actual=case90Result,
1740 onpass="Install 600 point Intents and Ping All test PASS",
1741 onfail="Install 600 point Intents and Ping All test FAIL" )
1742
1743 def CASE91( self ):
1744 """
1745 Install 600 point intents and verify ping all (Chordal Topology)
1746 """
1747 main.log.report( "Add 600 point intents and verify pingall (Chordal Topology)" )
1748 main.log.report( "_______________________________________" )
1749 import itertools
1750 import time
1751 main.case( "Install 600 point intents" )
1752 main.step( "Add point Intents" )
1753 intentResult = main.TRUE
1754 deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) )
1755
1756 intentIdList = []
1757 time1 = time.time()
1758 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1759 pool = []
1760 for cli in main.CLIs:
1761 if i >= len( deviceCombos ):
1762 break
1763 t = main.Thread( target=cli.addPointIntent,
1764 threadID=main.threadID,
1765 name="addPointIntent",
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001766 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
Hari Krishnab35c6d02015-03-18 11:13:51 -07001767 pool.append(t)
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001768 #time.sleep(1)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001769 t.start()
1770 i = i + 1
1771 main.threadID = main.threadID + 1
1772 for thread in pool:
1773 thread.join()
1774 intentIdList.append(thread.result)
1775 time2 = time.time()
1776 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1777 intentResult = main.TRUE
1778 intentsJson = main.ONOScli2.intents()
1779 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1780 intentsJson = intentsJson)
1781 print getIntentStateResult
1782 # Takes awhile for all the onos to get the intents
1783 time.sleep(30)
kelvin-onlab8a832582015-01-16 17:06:11 -08001784 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001785 pingResult = main.FALSE
1786 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001787 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001788 time2 = time.time()
1789 timeDiff = round( ( time2 - time1 ), 2 )
1790 main.log.report(
1791 "Time taken for Ping All: " +
1792 str( timeDiff ) +
1793 " seconds" )
1794 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1795 onpass="PING ALL PASS",
1796 onfail="PING ALL FAIL" )
1797
kelvin-onlab65a72d22015-03-26 13:46:32 -07001798 case91Result = ( intentResult and pingResult )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001799
1800 utilities.assert_equals(
1801 expect=main.TRUE,
kelvin-onlabd878fc22015-03-27 13:33:41 -07001802 actual=case91Result,
Hari Krishna0ce0e152015-06-23 09:55:29 -07001803 onpass="Install 600 point Intents and Ping All test PASS",
1804 onfail="Install 600 point Intents and Ping All test FAIL" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001805
1806 def CASE92( self ):
1807 """
kelvin-onlab77d6c302015-03-31 11:33:32 -07001808 Install 4556 point intents and verify ping all (Spine Topology)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001809 """
kelvin-onlab77d6c302015-03-31 11:33:32 -07001810 main.log.report( "Add 4556 point intents and verify pingall (Spine Topology)" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001811 main.log.report( "_______________________________________" )
1812 import itertools
1813 import time
kelvin-onlab77d6c302015-03-31 11:33:32 -07001814 main.case( "Install 4556 point intents" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001815 main.step( "Add point Intents" )
1816 intentResult = main.TRUE
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001817 main.pingTimeout = 600
kelvin-onlab77d6c302015-03-31 11:33:32 -07001818 for i in range(len(main.hostMACs)):
1819 main.MACsDict[main.deviceDPIDs[i+10]] = main.hostMACs[i].split('/')[0]
1820 print main.MACsDict
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001821 deviceCombos = list( itertools.permutations( main.deviceDPIDs[10:], 2 ) )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001822 intentIdList = []
1823 time1 = time.time()
1824 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1825 pool = []
1826 for cli in main.CLIs:
1827 if i >= len( deviceCombos ):
1828 break
1829 t = main.Thread( target=cli.addPointIntent,
1830 threadID=main.threadID,
1831 name="addPointIntent",
1832 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
1833 pool.append(t)
1834 #time.sleep(1)
1835 t.start()
1836 i = i + 1
1837 main.threadID = main.threadID + 1
1838 for thread in pool:
1839 thread.join()
1840 intentIdList.append(thread.result)
1841 time2 = time.time()
1842 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1843 intentResult = main.TRUE
1844 intentsJson = main.ONOScli2.intents()
1845 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1846 intentsJson = intentsJson)
kelvin-onlab77d6c302015-03-31 11:33:32 -07001847 #print getIntentStateResult
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001848 # Takes awhile for all the onos to get the intents
kelvin-onlab77d6c302015-03-31 11:33:32 -07001849 time.sleep(60)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001850 main.step( "Verify Ping across all hosts" )
1851 pingResult = main.FALSE
1852 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001853 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001854 time2 = time.time()
1855 timeDiff = round( ( time2 - time1 ), 2 )
1856 main.log.report(
1857 "Time taken for Ping All: " +
1858 str( timeDiff ) +
1859 " seconds" )
1860 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1861 onpass="PING ALL PASS",
1862 onfail="PING ALL FAIL" )
1863
kelvin-onlab65a72d22015-03-26 13:46:32 -07001864 case92Result = ( intentResult and pingResult )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001865
1866 utilities.assert_equals(
1867 expect=main.TRUE,
kelvin-onlab65a72d22015-03-26 13:46:32 -07001868 actual=case92Result,
kelvin-onlab77d6c302015-03-31 11:33:32 -07001869 onpass="Install 4556 point Intents and Ping All test PASS",
1870 onfail="Install 4556 point Intents and Ping All test FAIL" )
1871
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001872 def CASE93( self ):
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001873 """
kelvin-onlab77d6c302015-03-31 11:33:32 -07001874 Install multi-single point intents and verify Ping all works
1875 for att topology
1876 """
1877 import copy
1878 import time
1879 main.log.report( "Install multi-single point intents and verify Ping all" )
1880 main.log.report( "___________________________________________" )
1881 main.case( "Install multi-single point intents and Ping all" )
1882 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
1883 portIngressList = ['1']*(len(deviceDPIDsCopy) - 1)
1884 intentIdList = []
1885 print "MACsDict", main.MACsDict
1886 time1 = time.time()
1887 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
1888 pool = []
1889 for cli in main.CLIs:
1890 egressDevice = deviceDPIDsCopy[i]
1891 ingressDeviceList = copy.copy(deviceDPIDsCopy)
1892 ingressDeviceList.remove(egressDevice)
1893 if i >= len( deviceDPIDsCopy ):
1894 break
1895 t = main.Thread( target=cli.addMultipointToSinglepointIntent,
1896 threadID=main.threadID,
1897 name="addMultipointToSinglepointIntent",
1898 args =[ingressDeviceList,egressDevice,portIngressList,'1','IPV4','',main.MACsDict.get(egressDevice)])
1899 pool.append(t)
1900 #time.sleep(1)
1901 t.start()
1902 i = i + 1
1903 main.threadID = main.threadID + 1
1904 for thread in pool:
1905 thread.join()
1906 intentIdList.append(thread.result)
1907 time2 = time.time()
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001908 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1909 time.sleep(30)
1910 print "getting all intents ID"
1911 intentIdTemp = main.ONOScli1.getAllIntentsId()
1912 print intentIdTemp
1913 print len(intentIdList)
kelvin-onlab06ade552015-03-31 18:09:27 -07001914 print intentIdList
kelvin-onlab4df89f22015-04-13 18:10:23 -07001915 checkIntentStateResult = main.TRUE
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001916 print "Checking intents state"
kelvin-onlab4df89f22015-04-13 18:10:23 -07001917 checkIntentStateResult = main.ONOScli1.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
1918 checkIntentStateResult = main.ONOScli2.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
1919 checkIntentStateResult = main.ONOScli3.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
1920 checkIntentStateResult = main.ONOScli4.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
1921 checkIntentStateResult = main.ONOScli5.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
1922
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001923 if checkIntentStateResult:
1924 main.log.info( "All intents are installed correctly " )
kelvin-onlab4df89f22015-04-13 18:10:23 -07001925
1926 print "Checking flows state "
1927 checkFlowsState = main.ONOScli1.checkFlowsState()
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001928 time.sleep(50)
kelvin-onlab77d6c302015-03-31 11:33:32 -07001929 main.step( "Verify Ping across all hosts" )
1930 pingResult = main.FALSE
1931 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001932 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlab77d6c302015-03-31 11:33:32 -07001933 time2 = time.time()
1934 timeDiff = round( ( time2 - time1 ), 2 )
1935 main.log.report(
1936 "Time taken for Ping All: " +
1937 str( timeDiff ) +
1938 " seconds" )
kelvin-onlab4df89f22015-04-13 18:10:23 -07001939 checkFlowsState = main.ONOScli1.checkFlowsState()
kelvin-onlab77d6c302015-03-31 11:33:32 -07001940 case93Result = pingResult
1941 utilities.assert_equals(
1942 expect=main.TRUE,
1943 actual=case93Result,
1944 onpass="Install 25 multi to single point Intents and Ping All test PASS",
1945 onfail="Install 25 multi to single point Intents and Ping All test FAIL" )
1946
kelvin-onlab20c712a2015-03-31 12:55:34 -07001947 def CASE94( self ):
1948 """
1949 Install multi-single point intents and verify Ping all works
kelvin-onlabd9a8ed32015-04-03 13:55:28 -07001950 for Chordal topology
kelvin-onlab20c712a2015-03-31 12:55:34 -07001951 """
1952 import copy
1953 import time
1954 main.log.report( "Install multi-single point intents and verify Ping all" )
1955 main.log.report( "___________________________________________" )
1956 main.case( "Install multi-single point intents and Ping all" )
1957 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
1958 portIngressList = ['1']*(len(deviceDPIDsCopy) - 1)
1959 intentIdList = []
1960 print "MACsDict", main.MACsDict
1961 time1 = time.time()
1962 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
1963 pool = []
1964 for cli in main.CLIs:
1965 egressDevice = deviceDPIDsCopy[i]
1966 ingressDeviceList = copy.copy(deviceDPIDsCopy)
1967 ingressDeviceList.remove(egressDevice)
1968 if i >= len( deviceDPIDsCopy ):
1969 break
1970 t = main.Thread( target=cli.addMultipointToSinglepointIntent,
1971 threadID=main.threadID,
1972 name="addMultipointToSinglepointIntent",
1973 args =[ingressDeviceList,egressDevice,portIngressList,'1','IPV4','',main.MACsDict.get(egressDevice)])
1974 pool.append(t)
1975 #time.sleep(1)
1976 t.start()
1977 i = i + 1
1978 main.threadID = main.threadID + 1
1979 for thread in pool:
1980 thread.join()
1981 intentIdList.append(thread.result)
1982 time2 = time.time()
1983 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1984 time.sleep(5)
1985 main.step( "Verify Ping across all hosts" )
1986 pingResult = main.FALSE
1987 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001988 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlab20c712a2015-03-31 12:55:34 -07001989 time2 = time.time()
1990 timeDiff = round( ( time2 - time1 ), 2 )
1991 main.log.report(
1992 "Time taken for Ping All: " +
1993 str( timeDiff ) +
1994 " seconds" )
1995
1996 case94Result = pingResult
1997 utilities.assert_equals(
1998 expect=main.TRUE,
1999 actual=case94Result,
2000 onpass="Install 25 multi to single point Intents and Ping All test PASS",
2001 onfail="Install 25 multi to single point Intents and Ping All test FAIL" )
kelvin-onlab06ade552015-03-31 18:09:27 -07002002
2003 #def CASE95 multi-single point intent for Spine
2004
kelvin-onlab77d6c302015-03-31 11:33:32 -07002005 def CASE96( self ):
2006 """
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002007 Install single-multi point intents and verify Ping all works
2008 for att topology
2009 """
2010 import copy
2011 main.log.report( "Install single-multi point intents and verify Ping all" )
2012 main.log.report( "___________________________________________" )
2013 main.case( "Install single-multi point intents and Ping all" )
kelvin-onlab06ade552015-03-31 18:09:27 -07002014 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
2015 portEgressList = ['1']*(len(deviceDPIDsCopy) - 1)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002016 intentIdList = []
kelvin-onlab06ade552015-03-31 18:09:27 -07002017 print "MACsDict", main.MACsDict
2018 time1 = time.time()
2019 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
2020 pool = []
2021 for cli in main.CLIs:
2022 ingressDevice = deviceDPIDsCopy[i]
2023 egressDeviceList = copy.copy(deviceDPIDsCopy)
2024 egressDeviceList.remove(ingressDevice)
2025 if i >= len( deviceDPIDsCopy ):
2026 break
2027 t = main.Thread( target=cli.addSinglepointToMultipointIntent,
2028 threadID=main.threadID,
2029 name="addSinglepointToMultipointIntent",
2030 args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',main.MACsDict.get(ingressDevice)])
2031 pool.append(t)
2032 #time.sleep(1)
2033 t.start()
2034 i = i + 1
2035 main.threadID = main.threadID + 1
2036 for thread in pool:
2037 thread.join()
2038 intentIdList.append(thread.result)
2039 time2 = time.time()
2040 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
2041 time.sleep(5)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002042 main.step( "Verify Ping across all hosts" )
2043 pingResult = main.FALSE
2044 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07002045 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002046 time2 = time.time()
2047 timeDiff = round( ( time2 - time1 ), 2 )
2048 main.log.report(
2049 "Time taken for Ping All: " +
2050 str( timeDiff ) +
2051 " seconds" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002052
kelvin-onlab06ade552015-03-31 18:09:27 -07002053 case96Result = pingResult
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002054 utilities.assert_equals(
2055 expect=main.TRUE,
kelvin-onlab06ade552015-03-31 18:09:27 -07002056 actual=case96Result,
2057 onpass="Install 25 single to multi point Intents and Ping All test PASS",
2058 onfail="Install 25 single to multi point Intents and Ping All test FAIL" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002059
kelvin-onlab77d6c302015-03-31 11:33:32 -07002060 def CASE97( self ):
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002061 """
2062 Install single-multi point intents and verify Ping all works
kelvin-onlab06ade552015-03-31 18:09:27 -07002063 for Chordal topology
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002064 """
2065 import copy
2066 main.log.report( "Install single-multi point intents and verify Ping all" )
2067 main.log.report( "___________________________________________" )
2068 main.case( "Install single-multi point intents and Ping all" )
kelvin-onlab06ade552015-03-31 18:09:27 -07002069 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
2070 portEgressList = ['1']*(len(deviceDPIDsCopy) - 1)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002071 intentIdList = []
kelvin-onlab06ade552015-03-31 18:09:27 -07002072 print "MACsDict", main.MACsDict
2073 time1 = time.time()
2074 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
2075 pool = []
2076 for cli in main.CLIs:
2077 ingressDevice = deviceDPIDsCopy[i]
2078 egressDeviceList = copy.copy(deviceDPIDsCopy)
2079 egressDeviceList.remove(ingressDevice)
2080 if i >= len( deviceDPIDsCopy ):
2081 break
2082 t = main.Thread( target=cli.addSinglepointToMultipointIntent,
2083 threadID=main.threadID,
2084 name="addSinglepointToMultipointIntent",
2085 args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',main.MACsDict.get(ingressDevice),''])
2086 pool.append(t)
2087 #time.sleep(1)
2088 t.start()
2089 i = i + 1
2090 main.threadID = main.threadID + 1
2091 for thread in pool:
2092 thread.join()
2093 intentIdList.append(thread.result)
2094 time2 = time.time()
2095 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
2096 time.sleep(5)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002097 main.step( "Verify Ping across all hosts" )
2098 pingResult = main.FALSE
2099 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07002100 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002101 time2 = time.time()
2102 timeDiff = round( ( time2 - time1 ), 2 )
2103 main.log.report(
2104 "Time taken for Ping All: " +
2105 str( timeDiff ) +
2106 " seconds" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002107
kelvin-onlab06ade552015-03-31 18:09:27 -07002108 case97Result = pingResult
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002109 utilities.assert_equals(
2110 expect=main.TRUE,
kelvin-onlab06ade552015-03-31 18:09:27 -07002111 actual=case97Result,
2112 onpass="Install 25 single to multi point Intents and Ping All test PASS",
2113 onfail="Install 25 single to multi point Intents and Ping All test FAIL" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002114
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07002115 def CASE98( self ):
2116 """
2117 Install single-multi point intents and verify Ping all works
2118 for Spine topology
2119 """
2120 import copy
2121 main.log.report( "Install single-multi point intents and verify Ping all" )
2122 main.log.report( "___________________________________________" )
2123 main.case( "Install single-multi point intents and Ping all" )
2124 deviceDPIDsCopy = copy.copy( main.deviceDPIDs )
2125 deviceDPIDsCopy = deviceDPIDsCopy[ 10: ]
2126 portEgressList = [ '1' ]*(len(deviceDPIDsCopy) - 1)
2127 intentIdList = []
2128 MACsDictCopy = {}
2129 for i in range( len( deviceDPIDsCopy ) ):
2130 MACsDictCopy[ deviceDPIDsCopy[ i ] ] = main.hostMACs[i].split( '/' )[ 0 ]
2131
2132 print "deviceDPIDsCopy", deviceDPIDsCopy
2133 print ""
2134 print "MACsDictCopy", MACsDictCopy
2135 time1 = time.time()
2136 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
2137 pool = []
2138 for cli in main.CLIs:
2139 if i >= len( deviceDPIDsCopy ):
2140 break
2141 ingressDevice = deviceDPIDsCopy[i]
2142 egressDeviceList = copy.copy(deviceDPIDsCopy)
2143 egressDeviceList.remove(ingressDevice)
2144 t = main.Thread( target=cli.addSinglepointToMultipointIntent,
2145 threadID=main.threadID,
2146 name="addSinglepointToMultipointIntent",
2147 args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',MACsDictCopy.get(ingressDevice),''])
2148 pool.append(t)
2149 #time.sleep(1)
2150 t.start()
2151 i = i + 1
2152 main.threadID = main.threadID + 1
2153 for thread in pool:
2154 thread.join()
2155 intentIdList.append(thread.result)
2156 time2 = time.time()
2157 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
2158 time.sleep(5)
2159 main.step( "Verify Ping across all hosts" )
2160 pingResult = main.FALSE
2161 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07002162 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07002163 time2 = time.time()
2164 timeDiff = round( ( time2 - time1 ), 2 )
2165 main.log.report(
2166 "Time taken for Ping All: " +
2167 str( timeDiff ) +
2168 " seconds" )
2169
2170 case98Result = pingResult
2171 utilities.assert_equals(
2172 expect=main.TRUE,
2173 actual=case98Result,
2174 onpass="Install 25 single to multi point Intents and Ping All test PASS",
2175 onfail="Install 25 single to multi point Intents and Ping All test FAIL" )
2176
kelvin-onlab8a832582015-01-16 17:06:11 -08002177 def CASE10( self ):
kelvin-onlab7642bb12015-02-27 13:48:17 -08002178 import time
kelvin-onlab8a832582015-01-16 17:06:11 -08002179 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002180 Remove all Intents
kelvin-onlab8a832582015-01-16 17:06:11 -08002181 """
2182 main.log.report( "Remove all intents that were installed previously" )
2183 main.log.report( "______________________________________________" )
2184 main.log.info( "Remove all intents" )
2185 main.case( "Removing intents" )
2186 main.step( "Obtain the intent id's first" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002187 intentsList = main.ONOScli1.getAllIntentIds()
kelvin-onlab8a832582015-01-16 17:06:11 -08002188 ansi_escape = re.compile( r'\x1b[^m]*m' )
2189 intentsList = ansi_escape.sub( '', intentsList )
2190 intentsList = intentsList.replace(
2191 " onos:intents | grep id=",
2192 "" ).replace(
2193 "id=",
2194 "" ).replace(
2195 "\r\r",
2196 "" )
2197 intentsList = intentsList.splitlines()
Hari Krishna0ce0e152015-06-23 09:55:29 -07002198 #intentsList = intentsList[ 1: ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002199 intentIdList = []
2200 step1Result = main.TRUE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002201 moreIntents = main.TRUE
2202 removeIntentCount = 0
kelvin-onlab65a72d22015-03-26 13:46:32 -07002203 intentsCount = len(intentsList)
Hari Krishna0ce0e152015-06-23 09:55:29 -07002204 main.log.info ( "Current number of intents: " + str(intentsCount) )
kelvin-onlab8a832582015-01-16 17:06:11 -08002205 if ( len( intentsList ) > 1 ):
kelvin-onlab54400a92015-02-26 18:05:51 -08002206 results = main.TRUE
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002207 main.log.info("Removing intent...")
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002208 while moreIntents:
Hari Krishna0ce0e152015-06-23 09:55:29 -07002209 #This is a work around for a major issue. We cycle through intents removal for up to 5 times.
Hari Krishnab35c6d02015-03-18 11:13:51 -07002210 if removeIntentCount == 5:
2211 break
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002212 removeIntentCount = removeIntentCount + 1
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002213 intentsList1 = main.ONOScli1.getAllIntentIds()
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002214 if len( intentsList1 ) == 0:
2215 break
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002216 ansi_escape = re.compile( r'\x1b[^m]*m' )
2217 intentsList1 = ansi_escape.sub( '', intentsList1 )
2218 intentsList1 = intentsList1.replace(
2219 " onos:intents | grep id=",
2220 "" ).replace(
2221 " state=",
2222 "" ).replace(
2223 "\r\r",
2224 "" )
2225 intentsList1 = intentsList1.splitlines()
Hari Krishna0ce0e152015-06-23 09:55:29 -07002226 #intentsList1 = intentsList1[ 1: ]
2227 main.log.info ( "Round %d intents to remove: " %(removeIntentCount) )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002228 print intentsList1
2229 intentIdList1 = []
Hari Krishnab35c6d02015-03-18 11:13:51 -07002230 if ( len( intentsList1 ) > 0 ):
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002231 moreIntents = main.TRUE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002232 for i in range( len( intentsList1 ) ):
2233 intentsTemp1 = intentsList1[ i ].split( ',' )
2234 intentIdList1.append( intentsTemp1[ 0 ].split('=')[1] )
Hari Krishna0ce0e152015-06-23 09:55:29 -07002235 main.log.info ( "Leftover Intent IDs: " + str(intentIdList1) )
2236 main.log.info ( "Length of Leftover Intents list: " + str(len(intentIdList1)) )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07002237 time1 = time.time()
2238 for i in xrange( 0, len( intentIdList1 ), int(main.numCtrls) ):
2239 pool = []
2240 for cli in main.CLIs:
2241 if i >= len( intentIdList1 ):
2242 break
2243 t = main.Thread( target=cli.removeIntent,
2244 threadID=main.threadID,
2245 name="removeIntent",
Hari Krishna0ce0e152015-06-23 09:55:29 -07002246 args=[intentIdList1[i],'org.onosproject.cli',False,False])
kelvin-onlabadfc8db2015-03-24 15:52:48 -07002247 pool.append(t)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07002248 t.start()
2249 i = i + 1
2250 main.threadID = main.threadID + 1
2251 for thread in pool:
2252 thread.join()
2253 intentIdList.append(thread.result)
Hari Krishna0ce0e152015-06-23 09:55:29 -07002254 #time.sleep(2)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07002255 time2 = time.time()
2256 main.log.info("Time for removing host intents: %2f seconds" %(time2-time1))
Hari Krishnab35c6d02015-03-18 11:13:51 -07002257 time.sleep(10)
Hari Krishna0ce0e152015-06-23 09:55:29 -07002258 main.log.info("Purging WITHDRAWN Intents")
Hari Krishnaade11a72015-07-01 17:06:46 -07002259 purgeResult = main.ONOScli2.purgeIntents()
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002260 else:
Hari Krishna0ce0e152015-06-23 09:55:29 -07002261 time.sleep(10)
Hari Krishnab35c6d02015-03-18 11:13:51 -07002262 if len( main.ONOScli1.intents()):
Hari Krishnaef1bd4e2015-03-12 16:55:30 -07002263 continue
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002264 break
Hari Krishna0ce0e152015-06-23 09:55:29 -07002265 time.sleep(10)
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002266 else:
kelvin-onlab65a72d22015-03-26 13:46:32 -07002267 print "Removed %d intents" %(intentsCount)
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002268 step1Result = main.TRUE
2269 else:
2270 print "No Intent IDs found in Intents list: ", intentsList
2271 step1Result = main.FALSE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002272
kelvin-onlabdc8719b2015-03-02 14:01:52 -08002273 print main.ONOScli1.intents()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002274 caseResult10 = step1Result
2275 utilities.assert_equals( expect=main.TRUE, actual=caseResult10,
kelvin-onlab8a832582015-01-16 17:06:11 -08002276 onpass="Intent removal test successful",
2277 onfail="Intent removal test failed" )
Hari Krishna22c3d412015-02-17 16:48:12 -08002278
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07002279 def CASE12( self, main ):
Hari Krishna22c3d412015-02-17 16:48:12 -08002280 """
2281 Enable onos-app-ifwd, Verify Intent based Reactive forwarding through ping all and Disable it
2282 """
2283 import re
2284 import copy
2285 import time
2286
kelvin-onlab54400a92015-02-26 18:05:51 -08002287 Thread = imp.load_source('Thread','/home/admin/ONLabTest/TestON/tests/OnosCHO/Thread.py')
2288 threadID = 0
2289
Hari Krishna22c3d412015-02-17 16:48:12 -08002290 main.log.report( "Enable Intent based Reactive forwarding and Verify ping all" )
2291 main.log.report( "_____________________________________________________" )
2292 main.case( "Enable Intent based Reactive forwarding and Verify ping all" )
2293 main.step( "Enable intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08002294 installResult = main.FALSE
2295 feature = "onos-app-ifwd"
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002296
kelvin-onlab54400a92015-02-26 18:05:51 -08002297 pool = []
2298 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002299 for cli,feature in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -08002300 t = main.Thread(target=cli,threadID=threadID,
2301 name="featureInstall",args=[feature])
2302 pool.append(t)
2303 t.start()
2304 threadID = threadID + 1
2305
2306 results = []
2307 for thread in pool:
2308 thread.join()
2309 results.append(thread.result)
2310 time2 = time.time()
2311
2312 if( all(result == main.TRUE for result in results) == False):
2313 main.log.info("Did not install onos-app-ifwd feature properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -07002314 #main.cleanup()
2315 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -08002316 else:
2317 main.log.info("Successful feature:install onos-app-ifwd")
2318 installResult = main.TRUE
2319 main.log.info("Time for feature:install onos-app-ifwd: %2f seconds" %(time2-time1))
2320
Hari Krishna22c3d412015-02-17 16:48:12 -08002321 main.step( "Verify Pingall" )
2322 ping_result = main.FALSE
2323 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -08002324 ping_result = main.Mininet1.pingall(timeout=600)
Hari Krishna22c3d412015-02-17 16:48:12 -08002325 time2 = time.time()
2326 timeDiff = round( ( time2 - time1 ), 2 )
2327 main.log.report(
2328 "Time taken for Ping All: " +
2329 str( timeDiff ) +
2330 " seconds" )
kelvin-onlab54400a92015-02-26 18:05:51 -08002331
Hari Krishna22c3d412015-02-17 16:48:12 -08002332 if ping_result == main.TRUE:
2333 main.log.report( "Pingall Test in Reactive mode successful" )
2334 else:
2335 main.log.report( "Pingall Test in Reactive mode failed" )
2336
2337 main.step( "Disable Intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08002338 uninstallResult = main.FALSE
2339
kelvin-onlab54400a92015-02-26 18:05:51 -08002340 pool = []
2341 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002342 for cli,feature in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -08002343 t = main.Thread(target=cli,threadID=threadID,
2344 name="featureUninstall",args=[feature])
2345 pool.append(t)
2346 t.start()
2347 threadID = threadID + 1
2348
2349 results = []
2350 for thread in pool:
2351 thread.join()
2352 results.append(thread.result)
2353 time2 = time.time()
2354
2355 if( all(result == main.TRUE for result in results) == False):
2356 main.log.info("Did not uninstall onos-app-ifwd feature properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -07002357 uninstallResult = main.FALSE
2358 #main.cleanup()
2359 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -08002360 else:
2361 main.log.info("Successful feature:uninstall onos-app-ifwd")
2362 uninstallResult = main.TRUE
2363 main.log.info("Time for feature:uninstall onos-app-ifwd: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -08002364
2365 # Waiting for reative flows to be cleared.
2366 time.sleep( 10 )
2367
2368 case11Result = installResult and ping_result and uninstallResult
2369 utilities.assert_equals( expect=main.TRUE, actual=case11Result,
2370 onpass="Intent based Reactive forwarding Pingall test PASS",
2371 onfail="Intent based Reactive forwarding Pingall test FAIL" )
2372
Hari Krishnab35c6d02015-03-18 11:13:51 -07002373 def CASE99(self):
2374 import time
2375 # WORK AROUND FOR ONOS-581. STOP ONOS BEFORE ASSIGNING CONTROLLERS AT MININET & START ONCE DONE
2376 main.step( "Stop ONOS on all Nodes" )
2377 stopResult = main.TRUE
2378 for i in range( 1, int( main.numCtrls ) + 1 ):
2379 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
2380 main.log.info( "Stopping ONOS Node IP: " + ONOS_ip )
2381 sresult = main.ONOSbench.onosStop( ONOS_ip )
2382 utilities.assert_equals( expect=main.TRUE, actual=sresult,
2383 onpass="Test step PASS",
2384 onfail="Test step FAIL" )
2385 stopResult = ( stopResult and sresult )
2386
2387 main.step( "Start ONOS on all Nodes" )
2388 startResult = main.TRUE
2389 for i in range( 1, int( main.numCtrls ) + 1 ):
2390 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
2391 main.log.info( "Starting ONOS Node IP: " + ONOS_ip )
2392 sresult = main.ONOSbench.onosStart( ONOS_ip )
2393 utilities.assert_equals( expect=main.TRUE, actual=sresult,
2394 onpass="Test step PASS",
2395 onfail="Test step FAIL" )
2396 startResult = ( startResult and sresult )
2397
2398 main.step( "Start ONOS CLI on all nodes" )
2399 cliResult = main.TRUE
2400 time.sleep( 30 )
2401 main.log.step(" Start ONOS cli using thread ")
2402 pool = []
2403 time1 = time.time()
2404 for i in range( int( main.numCtrls ) ):
2405 t = main.Thread(target=main.CLIs[i].startOnosCli,
2406 threadID=main.threadID,
2407 name="startOnosCli",
2408 args=[main.nodes[i].ip_address])
2409 pool.append(t)
2410 t.start()
2411 main.threadID = main.threadID + 1
2412 for t in pool:
2413 t.join()
2414 cliResult = cliResult and t.result
2415 time2 = time.time()
2416
2417 if not cliResult:
2418 main.log.info("ONOS CLI did not start up properly")
2419 #main.cleanup()
2420 #main.exit()
2421 else:
2422 main.log.info("Successful CLI startup")
2423 main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
2424
2425 case99Result = ( startResult and cliResult )
2426 time.sleep(30)
2427 utilities.assert_equals(
2428 expect=main.TRUE,
2429 actual=case99Result,
2430 onpass="Starting new Chordal topology test PASS",
2431 onfail="Starting new Chordal topology test FAIL" )
2432
2433
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002434
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002435
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07002436