blob: 1bd069673c0215760b46da4433f7eb6732193d6c [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
497
kelvin-onlab54400a92015-02-26 18:05:51 -0800498 #time.sleep(300)
Hari Krishnab35c6d02015-03-18 11:13:51 -0700499 #main.cleanup()
500 #main.exit()
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800501
kelvin-onlab8a832582015-01-16 17:06:11 -0800502 # just returning TRUE for now as this one just collects data
Hari Krishnab35c6d02015-03-18 11:13:51 -0700503 case3Result = topoResult
Hari Krishna22c3d412015-02-17 16:48:12 -0800504 utilities.assert_equals( expect=main.TRUE, actual=case3Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800505 onpass="Saving ONOS topology data test PASS",
506 onfail="Saving ONOS topology data test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800507
kelvin-onlab65a72d22015-03-26 13:46:32 -0700508 def CASE40( self, main ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800509 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700510 Verify Reactive forwarding (Att Topology)
kelvin-onlab8a832582015-01-16 17:06:11 -0800511 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800512 import re
513 import copy
514 import time
Hari Krishnab35c6d02015-03-18 11:13:51 -0700515 main.log.report( "Verify Reactive forwarding (Att Topology)" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800516 main.log.report( "______________________________________________" )
517 main.case( "Enable Reactive forwarding and Verify ping all" )
518 main.step( "Enable Reactive forwarding" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800519 installResult = main.TRUE
kelvin-onlab06ade552015-03-31 18:09:27 -0700520 # Activate fwd app
521 appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700522 appCheck = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800523 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800524 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700525 t = main.Thread( target=cli.appToIDCheck,
526 name="appToIDCheck-" + str( i ),
527 args=[] )
528 pool.append( t )
kelvin-onlab54400a92015-02-26 18:05:51 -0800529 t.start()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800530 for t in pool:
531 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700532 appCheck = appCheck and t.result
533 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
534 onpass="App Ids seem to be correct",
535 onfail="Something is wrong with app Ids" )
536 if appCheck != main.TRUE:
537 main.log.warn( main.CLIs[0].apps() )
538 main.log.warn( main.CLIs[0].appIDs() )
539
540 time.sleep( 10 )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800541
kelvin-onlab8a832582015-01-16 17:06:11 -0800542 main.step( "Verify Pingall" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800543 ping_result = main.FALSE
544 time1 = time.time()
kelvin-onlab4df89f22015-04-13 18:10:23 -0700545 ping_result = main.Mininet1.pingall( timeout=main.pingTimeout )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800546 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800547 timeDiff = round( ( time2 - time1 ), 2 )
548 main.log.report(
549 "Time taken for Ping All: " +
550 str( timeDiff ) +
551 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800552
553 if ping_result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800554 main.log.report( "Pingall Test in Reactive mode successful" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800555 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800556 main.log.report( "Pingall Test in Reactive mode failed" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800557
kelvin-onlab8a832582015-01-16 17:06:11 -0800558 main.step( "Disable Reactive forwarding" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700559
560 main.log.info( "Uninstall reactive forwarding app" )
561 appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800562 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800563 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700564 t = main.Thread( target=cli.appToIDCheck,
565 name="appToIDCheck-" + str( i ),
566 args=[] )
567 pool.append( t )
kelvin-onlab54400a92015-02-26 18:05:51 -0800568 t.start()
kelvin-onlab06ade552015-03-31 18:09:27 -0700569
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800570 for t in pool:
571 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700572 appCheck = appCheck and t.result
573 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
574 onpass="App Ids seem to be correct",
575 onfail="Something is wrong with app Ids" )
576 if appCheck != main.TRUE:
577 main.log.warn( main.CLIs[0].apps() )
578 main.log.warn( main.CLIs[0].appIDs() )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800579
kelvin-onlab8a832582015-01-16 17:06:11 -0800580 # Waiting for reative flows to be cleared.
Hari Krishna0ce0e152015-06-23 09:55:29 -0700581 time.sleep( 30 )
kelvin-onlab06ade552015-03-31 18:09:27 -0700582 case40Result = installResult and uninstallResult and ping_result
583 utilities.assert_equals( expect=main.TRUE, actual=case40Result,
Hari Krishnab35c6d02015-03-18 11:13:51 -0700584 onpass="Reactive Mode Pingall test PASS",
585 onfail="Reactive Mode Pingall test FAIL" )
586
587 def CASE41( self, main ):
588 """
589 Verify Reactive forwarding (Chordal Topology)
590 """
591 import re
592 import copy
593 import time
594 main.log.report( "Verify Reactive forwarding (Chordal Topology)" )
595 main.log.report( "______________________________________________" )
596 main.case( "Enable Reactive forwarding and Verify ping all" )
597 main.step( "Enable Reactive forwarding" )
598 installResult = main.TRUE
kelvin-onlab06ade552015-03-31 18:09:27 -0700599 # Activate fwd app
600 appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" )
601
602 appCheck = main.TRUE
Hari Krishnab35c6d02015-03-18 11:13:51 -0700603 pool = []
Hari Krishnab35c6d02015-03-18 11:13:51 -0700604 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700605 t = main.Thread( target=cli.appToIDCheck,
606 name="appToIDCheck-" + str( i ),
607 args=[] )
608 pool.append( t )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700609 t.start()
Hari Krishnab35c6d02015-03-18 11:13:51 -0700610 for t in pool:
611 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700612 appCheck = appCheck and t.result
613 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
614 onpass="App Ids seem to be correct",
615 onfail="Something is wrong with app Ids" )
616 if appCheck != main.TRUE:
617 main.log.warn( main.CLIs[0].apps() )
618 main.log.warn( main.CLIs[0].appIDs() )
619
620 time.sleep( 10 )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700621
622 main.step( "Verify Pingall" )
623 ping_result = main.FALSE
624 time1 = time.time()
kelvin-onlab4df89f22015-04-13 18:10:23 -0700625 ping_result = main.Mininet1.pingall( timeout=main.pingTimeout )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700626 time2 = time.time()
627 timeDiff = round( ( time2 - time1 ), 2 )
628 main.log.report(
629 "Time taken for Ping All: " +
630 str( timeDiff ) +
631 " seconds" )
632
633 if ping_result == main.TRUE:
634 main.log.report( "Pingall Test in Reactive mode successful" )
635 else:
636 main.log.report( "Pingall Test in Reactive mode failed" )
637
638 main.step( "Disable Reactive forwarding" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700639
640 main.log.info( "Uninstall reactive forwarding app" )
641 appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700642 pool = []
Hari Krishnab35c6d02015-03-18 11:13:51 -0700643 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700644 t = main.Thread( target=cli.appToIDCheck,
645 name="appToIDCheck-" + str( i ),
646 args=[] )
647 pool.append( t )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700648 t.start()
kelvin-onlab06ade552015-03-31 18:09:27 -0700649
Hari Krishnab35c6d02015-03-18 11:13:51 -0700650 for t in pool:
651 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700652 appCheck = appCheck and t.result
653 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
654 onpass="App Ids seem to be correct",
655 onfail="Something is wrong with app Ids" )
656 if appCheck != main.TRUE:
657 main.log.warn( main.CLIs[0].apps() )
658 main.log.warn( main.CLIs[0].appIDs() )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700659
660 # Waiting for reative flows to be cleared.
Hari Krishna0ce0e152015-06-23 09:55:29 -0700661 time.sleep( 30 )
kelvin-onlab06ade552015-03-31 18:09:27 -0700662 case41Result = installResult and uninstallResult and ping_result
663 utilities.assert_equals( expect=main.TRUE, actual=case41Result,
Hari Krishnab35c6d02015-03-18 11:13:51 -0700664 onpass="Reactive Mode Pingall test PASS",
665 onfail="Reactive Mode Pingall test FAIL" )
666
667 def CASE42( self, main ):
668 """
669 Verify Reactive forwarding (Spine Topology)
670 """
671 import re
672 import copy
673 import time
674 main.log.report( "Verify Reactive forwarding (Spine Topology)" )
675 main.log.report( "______________________________________________" )
676 main.case( "Enable Reactive forwarding and Verify ping all" )
677 main.step( "Enable Reactive forwarding" )
678 installResult = main.TRUE
kelvin-onlab06ade552015-03-31 18:09:27 -0700679 # Activate fwd app
680 appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" )
681
682 appCheck = main.TRUE
Hari Krishnab35c6d02015-03-18 11:13:51 -0700683 pool = []
Hari Krishnab35c6d02015-03-18 11:13:51 -0700684 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700685 t = main.Thread( target=cli.appToIDCheck,
686 name="appToIDCheck-" + str( i ),
687 args=[] )
688 pool.append( t )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700689 t.start()
Hari Krishnab35c6d02015-03-18 11:13:51 -0700690 for t in pool:
691 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700692 appCheck = appCheck and t.result
693 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
694 onpass="App Ids seem to be correct",
695 onfail="Something is wrong with app Ids" )
696 if appCheck != main.TRUE:
697 main.log.warn( main.CLIs[0].apps() )
698 main.log.warn( main.CLIs[0].appIDs() )
699
700 time.sleep( 10 )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700701
702 main.step( "Verify Pingall" )
703 ping_result = main.FALSE
704 time1 = time.time()
kelvin-onlab4df89f22015-04-13 18:10:23 -0700705 ping_result = main.Mininet1.pingall( timeout=main.pingTimeout )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700706 time2 = time.time()
707 timeDiff = round( ( time2 - time1 ), 2 )
708 main.log.report(
709 "Time taken for Ping All: " +
710 str( timeDiff ) +
711 " seconds" )
712
713 if ping_result == main.TRUE:
714 main.log.report( "Pingall Test in Reactive mode successful" )
715 else:
716 main.log.report( "Pingall Test in Reactive mode failed" )
717
718 main.step( "Disable Reactive forwarding" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700719
720 main.log.info( "Uninstall reactive forwarding app" )
721 appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700722 pool = []
Hari Krishnab35c6d02015-03-18 11:13:51 -0700723 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700724 t = main.Thread( target=cli.appToIDCheck,
725 name="appToIDCheck-" + str( i ),
726 args=[] )
727 pool.append( t )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700728 t.start()
kelvin-onlab06ade552015-03-31 18:09:27 -0700729
Hari Krishnab35c6d02015-03-18 11:13:51 -0700730 for t in pool:
731 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700732 appCheck = appCheck and t.result
733 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
734 onpass="App Ids seem to be correct",
735 onfail="Something is wrong with app Ids" )
736 if appCheck != main.TRUE:
737 main.log.warn( main.CLIs[0].apps() )
738 main.log.warn( main.CLIs[0].appIDs() )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700739
740 # Waiting for reative flows to be cleared.
Hari Krishna0ce0e152015-06-23 09:55:29 -0700741 time.sleep( 30 )
kelvin-onlab06ade552015-03-31 18:09:27 -0700742 case42Result = installResult and uninstallResult and ping_result
743 utilities.assert_equals( expect=main.TRUE, actual=case42Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800744 onpass="Reactive Mode Pingall test PASS",
745 onfail="Reactive Mode Pingall test FAIL" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700746
kelvin-onlab8a832582015-01-16 17:06:11 -0800747 def CASE5( self, main ):
748 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800749 Compare current ONOS topology with reference data
kelvin-onlab8a832582015-01-16 17:06:11 -0800750 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800751 import re
kelvin-onlab54400a92015-02-26 18:05:51 -0800752
Hari Krishna22c3d412015-02-17 16:48:12 -0800753 devicesDPIDTemp = []
754 hostMACsTemp = []
755 deviceLinksTemp = []
756 deviceActiveLinksCountTemp = []
757 devicePortsEnabledCountTemp = []
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800758
kelvin-onlab8a832582015-01-16 17:06:11 -0800759 main.log.report(
760 "Compare ONOS topology with reference data in Stores" )
761 main.log.report( "__________________________________________________" )
762 main.case( "Compare ONOS topology with reference data" )
763
764 main.step( "Compare current Device ports enabled with reference" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800765 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800766 for i in xrange( 1,(main.numMNswitches + 1), int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800767 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800768 for cli in main.CLIs:
kelvin-onlabc44f0192015-04-02 22:08:41 -0700769 if i >= main.numMNswitches + 1:
770 break
kelvin-onlab54400a92015-02-26 18:05:51 -0800771 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800772 t = main.Thread(target = cli.getDevicePortsEnabledCount,
773 threadID = main.threadID,
774 name = "getDevicePortsEnabledCount",
775 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800776 t.start()
777 pool.append(t)
778 i = i + 1
779 main.threadID = main.threadID + 1
780 for thread in pool:
781 thread.join()
782 portResult = thread.result
Hari Krishna0ce0e152015-06-23 09:55:29 -0700783 #portTemp = re.split( r'\t+', portResult )
784 #portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
785 devicePortsEnabledCountTemp.append( portResult )
786
kelvin-onlab54400a92015-02-26 18:05:51 -0800787 time2 = time.time()
788 main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800789 main.log.info (
790 "Device Enabled ports EXPECTED: %s" %
791 str( main.devicePortsEnabledCount ) )
792 main.log.info (
793 "Device Enabled ports ACTUAL: %s" %
794 str( devicePortsEnabledCountTemp ) )
kelvin-onlab54400a92015-02-26 18:05:51 -0800795
Hari Krishna22c3d412015-02-17 16:48:12 -0800796 if ( cmp( main.devicePortsEnabledCount,
797 devicePortsEnabledCountTemp ) == 0 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800798 stepResult1 = main.TRUE
799 else:
800 stepResult1 = main.FALSE
801
kelvin-onlab8a832582015-01-16 17:06:11 -0800802 main.step( "Compare Device active links with reference" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800803 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800804 for i in xrange( 1, ( main.numMNswitches + 1) , int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800805 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800806 for cli in main.CLIs:
Hari Krishna0ce0e152015-06-23 09:55:29 -0700807 if i >= main.numMNswitches + 1:
808 break
kelvin-onlab54400a92015-02-26 18:05:51 -0800809 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800810 t = main.Thread(target = cli.getDeviceLinksActiveCount,
811 threadID = main.threadID,
Hari Krishna0ce0e152015-06-23 09:55:29 -0700812 name = "getDeviceLinksActiveCount",
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800813 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800814 t.start()
815 pool.append(t)
816 i = i + 1
817 main.threadID = main.threadID + 1
818 for thread in pool:
819 thread.join()
820 linkCountResult = thread.result
Hari Krishna0ce0e152015-06-23 09:55:29 -0700821 #linkCountTemp = re.split( r'\t+', linkCountResult )
822 #linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
823 deviceActiveLinksCountTemp.append( linkCountResult )
824
kelvin-onlab54400a92015-02-26 18:05:51 -0800825 time2 = time.time()
826 main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800827 main.log.info (
828 "Device Active links EXPECTED: %s" %
829 str( main.deviceActiveLinksCount ) )
830 main.log.info (
831 "Device Active links ACTUAL: %s" % str( deviceActiveLinksCountTemp ) )
832 if ( cmp( main.deviceActiveLinksCount, deviceActiveLinksCountTemp ) == 0 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800833 stepResult2 = main.TRUE
834 else:
835 stepResult2 = main.FALSE
836
kelvin-onlab8a832582015-01-16 17:06:11 -0800837 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800838 place holder for comparing devices, hosts, paths and intents if required.
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800839 Links and ports data would be incorrect with out devices anyways.
kelvin-onlab8a832582015-01-16 17:06:11 -0800840 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800841 case5Result = ( stepResult1 and stepResult2 )
842 utilities.assert_equals( expect=main.TRUE, actual=case5Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800843 onpass="Compare Topology test PASS",
844 onfail="Compare Topology test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800845
kelvin-onlab65a72d22015-03-26 13:46:32 -0700846 def CASE60( self ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800847 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700848 Install 300 host intents and verify ping all (Att Topology)
kelvin-onlab8a832582015-01-16 17:06:11 -0800849 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700850 main.log.report( "Add 300 host intents and verify pingall (Att Topology)" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800851 main.log.report( "_______________________________________" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800852 import itertools
Hari Krishnaef1bd4e2015-03-12 16:55:30 -0700853 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800854 main.case( "Install 300 host intents" )
855 main.step( "Add host Intents" )
856 intentResult = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800857 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800858
kelvin-onlab54400a92015-02-26 18:05:51 -0800859 intentIdList = []
860 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800861 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800862 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800863 for cli in main.CLIs:
864 if i >= len( hostCombos ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800865 break
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800866 t = main.Thread( target=cli.addHostIntent,
867 threadID=main.threadID,
kelvin-onlab54400a92015-02-26 18:05:51 -0800868 name="addHostIntent",
869 args=[hostCombos[i][0],hostCombos[i][1]])
870 pool.append(t)
871 t.start()
872 i = i + 1
873 main.threadID = main.threadID + 1
874 for thread in pool:
875 thread.join()
876 intentIdList.append(thread.result)
877 time2 = time.time()
kelvin-onlabadfc8db2015-03-24 15:52:48 -0700878 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
879
kelvin-onlab54400a92015-02-26 18:05:51 -0800880 intentResult = main.TRUE
881 intentsJson = main.ONOScli2.intents()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800882 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
kelvin-onlab54400a92015-02-26 18:05:51 -0800883 intentsJson = intentsJson)
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -0700884 print "len of intent ID", str(len(intentIdList))
885 print "len of intent state results", str(len(getIntentStateResult))
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800886 print getIntentStateResult
Hari Krishnab35c6d02015-03-18 11:13:51 -0700887 # Takes awhile for all the onos to get the intents
Hari Krishna0ce0e152015-06-23 09:55:29 -0700888 time.sleep( 30 )
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -0700889 """intentState = main.TRUE
890 for i in getIntentStateResult:
891 if getIntentStateResult.get( 'state' ) != 'INSTALLED':
892 """
893
894
kelvin-onlab8a832582015-01-16 17:06:11 -0800895 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800896 pingResult = main.FALSE
897 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -0700898 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800899 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800900 timeDiff = round( ( time2 - time1 ), 2 )
901 main.log.report(
902 "Time taken for Ping All: " +
903 str( timeDiff ) +
904 " seconds" )
905 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
906 onpass="PING ALL PASS",
907 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800908
kelvin-onlab65a72d22015-03-26 13:46:32 -0700909 case60Result = ( intentResult and pingResult )
kelvin-onlab54400a92015-02-26 18:05:51 -0800910
kelvin-onlab8a832582015-01-16 17:06:11 -0800911 utilities.assert_equals(
912 expect=main.TRUE,
kelvin-onlab65a72d22015-03-26 13:46:32 -0700913 actual=case60Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800914 onpass="Install 300 Host Intents and Ping All test PASS",
915 onfail="Install 300 Host Intents and Ping All test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800916
kelvin-onlab65a72d22015-03-26 13:46:32 -0700917 def CASE61( self ):
918 """
919 Install 600 host intents and verify ping all for Chordal Topology
920 """
921 main.log.report( "Add 600 host intents and verify pingall (Chordal Topo)" )
922 main.log.report( "_______________________________________" )
923 import itertools
924
925 main.case( "Install 600 host intents" )
926 main.step( "Add host Intents" )
927 intentResult = main.TRUE
928 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
929
930 intentIdList = []
931 time1 = time.time()
932
933 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
934 pool = []
935 for cli in main.CLIs:
936 if i >= len( hostCombos ):
937 break
938 t = main.Thread( target=cli.addHostIntent,
939 threadID=main.threadID,
940 name="addHostIntent",
941 args=[hostCombos[i][0],hostCombos[i][1]])
942 pool.append(t)
943 t.start()
944 i = i + 1
945 main.threadID = main.threadID + 1
946 for thread in pool:
947 thread.join()
948 intentIdList.append(thread.result)
949 time2 = time.time()
950 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
951 intentResult = main.TRUE
952 intentsJson = main.ONOScli2.intents()
953 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
954 intentsJson = intentsJson)
955 print getIntentStateResult
956
957 main.step( "Verify Ping across all hosts" )
958 pingResult = main.FALSE
959 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -0700960 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlab65a72d22015-03-26 13:46:32 -0700961 time2 = time.time()
962 timeDiff = round( ( time2 - time1 ), 2 )
963 main.log.report(
964 "Time taken for Ping All: " +
965 str( timeDiff ) +
966 " seconds" )
967 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
968 onpass="PING ALL PASS",
969 onfail="PING ALL FAIL" )
970
971 case14Result = ( intentResult and pingResult )
972
973 utilities.assert_equals(
974 expect=main.TRUE,
975 actual=case14Result,
976 onpass="Install 300 Host Intents and Ping All test PASS",
977 onfail="Install 300 Host Intents and Ping All test FAIL" )
978
979 def CASE62( self ):
980 """
981 Install 2278 host intents and verify ping all for Spine Topology
982 """
983 main.log.report( "Add 2278 host intents and verify pingall (Spine Topo)" )
984 main.log.report( "_______________________________________" )
985 import itertools
986
987 main.case( "Install 2278 host intents" )
988 main.step( "Add host Intents" )
989 intentResult = main.TRUE
990 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
991 main.pingTimeout = 300
992 intentIdList = []
993 time1 = time.time()
994 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
995 pool = []
996 for cli in main.CLIs:
997 if i >= len( hostCombos ):
998 break
999 t = main.Thread( target=cli.addHostIntent,
1000 threadID=main.threadID,
1001 name="addHostIntent",
1002 args=[hostCombos[i][0],hostCombos[i][1]])
1003 pool.append(t)
1004 t.start()
1005 i = i + 1
1006 main.threadID = main.threadID + 1
1007 for thread in pool:
1008 thread.join()
1009 intentIdList.append(thread.result)
1010 time2 = time.time()
1011 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
1012 intentResult = main.TRUE
1013 intentsJson = main.ONOScli2.intents()
1014 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1015 intentsJson = intentsJson)
1016 print getIntentStateResult
1017
1018 main.step( "Verify Ping across all hosts" )
1019 pingResult = main.FALSE
1020 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001021 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlab65a72d22015-03-26 13:46:32 -07001022 time2 = time.time()
1023 timeDiff = round( ( time2 - time1 ), 2 )
1024 main.log.report(
1025 "Time taken for Ping All: " +
1026 str( timeDiff ) +
1027 " seconds" )
1028 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1029 onpass="PING ALL PASS",
1030 onfail="PING ALL FAIL" )
1031
1032 case15Result = ( intentResult and pingResult )
1033
1034 utilities.assert_equals(
1035 expect=main.TRUE,
1036 actual=case15Result,
1037 onpass="Install 2278 Host Intents and Ping All test PASS",
1038 onfail="Install 2278 Host Intents and Ping All test FAIL" )
1039
kelvin-onlab8a832582015-01-16 17:06:11 -08001040 def CASE70( self, main ):
1041 """
Hari Krishnab35c6d02015-03-18 11:13:51 -07001042 Randomly bring some core links down and verify ping all ( Host Intents-Att Topo)
kelvin-onlab8a832582015-01-16 17:06:11 -08001043 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001044 import random
Hari Krishna22c3d412015-02-17 16:48:12 -08001045 main.randomLink1 = []
1046 main.randomLink2 = []
1047 main.randomLink3 = []
kelvin-onlab65a72d22015-03-26 13:46:32 -07001048 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1049 link1End2 = main.params[ 'ATTCORELINKS' ][ 'linkS3b' ].split( ',' )
1050 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1051 link2End2 = main.params[ 'ATTCORELINKS' ][ 'linkS14b' ].split( ',' )
1052 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
1053 link3End2 = main.params[ 'ATTCORELINKS' ][ 'linkS18b' ].split( ',' )
1054 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001055 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001056
Hari Krishnab35c6d02015-03-18 11:13:51 -07001057 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Att Topo)" )
1058 main.log.report( "___________________________________________________________________________" )
Hari Krishnad97213e2015-01-24 19:30:14 -08001059 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
1060 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001061 if ( int( switchLinksToToggle ) ==
1062 0 or int( switchLinksToToggle ) > 5 ):
Hari Krishna46997e02015-01-27 11:23:07 -08001063 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 -07001064 #main.cleanup()
1065 #main.exit()
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001066 else:
Hari Krishnad97213e2015-01-24 19:30:14 -08001067 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 -08001068
kelvin-onlab8a832582015-01-16 17:06:11 -08001069 main.step( "Cut links on Core devices using user provided range" )
Hari Krishna22c3d412015-02-17 16:48:12 -08001070 main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
1071 main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
1072 main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001073 for i in range( int( switchLinksToToggle ) ):
1074 main.Mininet1.link(
1075 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001076 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001077 OPTION="down" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001078 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001079 main.Mininet1.link(
1080 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001081 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001082 OPTION="down" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001083 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001084 main.Mininet1.link(
1085 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001086 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001087 OPTION="down" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001088 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001089
1090 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001091 linkDown = main.ONOSbench.checkStatus(
Hari Krishna22c3d412015-02-17 16:48:12 -08001092 topology_output, main.numMNswitches, str(
1093 int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001094 utilities.assert_equals(
1095 expect=main.TRUE,
1096 actual=linkDown,
1097 onpass="Link Down discovered properly",
1098 onfail="Link down was not discovered in " +
1099 str( link_sleep ) +
1100 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001101
kelvin-onlab8a832582015-01-16 17:06:11 -08001102 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001103 pingResultLinkDown = main.FALSE
1104 time1 = time.time()
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001105 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001106 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001107 timeDiff = round( ( time2 - time1 ), 2 )
1108 main.log.report(
1109 "Time taken for Ping All: " +
1110 str( timeDiff ) +
1111 " seconds" )
1112 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1113 onpass="PING ALL PASS",
1114 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001115
Hari Krishna22c3d412015-02-17 16:48:12 -08001116 caseResult70 = linkDown and pingResultLinkDown
1117 utilities.assert_equals( expect=main.TRUE, actual=caseResult70,
kelvin-onlab8a832582015-01-16 17:06:11 -08001118 onpass="Random Link cut Test PASS",
1119 onfail="Random Link cut Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001120
kelvin-onlab8a832582015-01-16 17:06:11 -08001121 def CASE80( self, main ):
1122 """
Hari Krishnab35c6d02015-03-18 11:13:51 -07001123 Bring the core links up that are down and verify ping all ( Host Intents-Att Topo )
kelvin-onlab8a832582015-01-16 17:06:11 -08001124 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001125 import random
kelvin-onlab65a72d22015-03-26 13:46:32 -07001126 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1127 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1128 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001129 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001130 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001131
kelvin-onlab8a832582015-01-16 17:06:11 -08001132 main.log.report(
Hari Krishnab35c6d02015-03-18 11:13:51 -07001133 "Bring the core links up that are down and verify ping all (Host Intents-Att Topo" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001134 main.log.report(
1135 "__________________________________________________________________" )
1136 main.case(
1137 "Host intents - Bring the core links up that are down and verify ping all" )
1138 main.step( "Bring randomly cut links on Core devices up" )
1139 for i in range( int( switchLinksToToggle ) ):
1140 main.Mininet1.link(
1141 END1=link1End1,
kelvin-onlab54400a92015-02-26 18:05:51 -08001142 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001143 OPTION="up" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001144 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001145 main.Mininet1.link(
1146 END1=link2End1,
kelvin-onlab54400a92015-02-26 18:05:51 -08001147 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001148 OPTION="up" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001149 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001150 main.Mininet1.link(
1151 END1=link3End1,
kelvin-onlab54400a92015-02-26 18:05:51 -08001152 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001153 OPTION="up" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001154 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001155
1156 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001157 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -08001158 topology_output,
Hari Krishna22c3d412015-02-17 16:48:12 -08001159 main.numMNswitches,
1160 str( main.numMNlinks ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001161 utilities.assert_equals(
1162 expect=main.TRUE,
1163 actual=linkUp,
1164 onpass="Link up discovered properly",
1165 onfail="Link up was not discovered in " +
1166 str( link_sleep ) +
1167 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001168
kelvin-onlab8a832582015-01-16 17:06:11 -08001169 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001170 pingResultLinkUp = main.FALSE
1171 time1 = time.time()
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001172 pingResultLinkUp = main.Mininet1.pingall( timeout=main.pingTimeout )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001173 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001174 timeDiff = round( ( time2 - time1 ), 2 )
1175 main.log.report(
1176 "Time taken for Ping All: " +
1177 str( timeDiff ) +
1178 " seconds" )
1179 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1180 onpass="PING ALL PASS",
1181 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001182
Hari Krishna22c3d412015-02-17 16:48:12 -08001183 caseResult80 = linkUp and pingResultLinkUp
1184 utilities.assert_equals( expect=main.TRUE, actual=caseResult80,
kelvin-onlab8a832582015-01-16 17:06:11 -08001185 onpass="Link Up Test PASS",
1186 onfail="Link Up Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001187
kelvin-onlab8a832582015-01-16 17:06:11 -08001188 def CASE71( self, main ):
1189 """
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001190 Randomly bring some core links down and verify ping all ( Point Intents-Att Topo)
kelvin-onlab8a832582015-01-16 17:06:11 -08001191 """
kelvin8ec71442015-01-15 16:57:00 -08001192 import random
Hari Krishna22c3d412015-02-17 16:48:12 -08001193 main.randomLink1 = []
1194 main.randomLink2 = []
1195 main.randomLink3 = []
kelvin-onlab65a72d22015-03-26 13:46:32 -07001196 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1197 link1End2 = main.params[ 'ATTCORELINKS' ][ 'linkS3b' ].split( ',' )
1198 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1199 link2End2 = main.params[ 'ATTCORELINKS' ][ 'linkS14b' ].split( ',' )
1200 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
1201 link3End2 = main.params[ 'ATTCORELINKS' ][ 'linkS18b' ].split( ',' )
1202 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001203 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin8ec71442015-01-15 16:57:00 -08001204
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001205 main.log.report( "Randomly bring some core links down and verify ping all (Point Intents-Att Topo)" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001206 main.log.report( "___________________________________________________________________________" )
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001207 main.case( "Point intents - Randomly bring some core links down and verify ping all" )
Hari Krishnad97213e2015-01-24 19:30:14 -08001208 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001209 if ( int( switchLinksToToggle ) ==
1210 0 or int( switchLinksToToggle ) > 5 ):
kelvin-onlab65a72d22015-03-26 13:46:32 -07001211 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 -07001212 #main.cleanup()
1213 #main.exit()
kelvin8ec71442015-01-15 16:57:00 -08001214 else:
kelvin-onlab65a72d22015-03-26 13:46:32 -07001215 main.log.info( "User provided Core switch links range to toggle is correct, proceeding to run the test" )
kelvin8ec71442015-01-15 16:57:00 -08001216
kelvin-onlab8a832582015-01-16 17:06:11 -08001217 main.step( "Cut links on Core devices using user provided range" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001218 main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
1219 main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
1220 main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001221 for i in range( int( switchLinksToToggle ) ):
1222 main.Mininet1.link(
1223 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001224 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001225 OPTION="down" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001226 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001227 main.Mininet1.link(
1228 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001229 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001230 OPTION="down" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001231 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001232 main.Mininet1.link(
1233 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001234 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001235 OPTION="down" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001236 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -08001237
1238 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001239 linkDown = main.ONOSbench.checkStatus(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001240 topology_output, main.numMNswitches, str(
1241 int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001242 utilities.assert_equals(
1243 expect=main.TRUE,
1244 actual=linkDown,
1245 onpass="Link Down discovered properly",
1246 onfail="Link down was not discovered in " +
1247 str( link_sleep ) +
1248 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -08001249
kelvin-onlab8a832582015-01-16 17:06:11 -08001250 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -08001251 pingResultLinkDown = main.FALSE
1252 time1 = time.time()
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001253 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout)
kelvin8ec71442015-01-15 16:57:00 -08001254 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001255 timeDiff = round( ( time2 - time1 ), 2 )
1256 main.log.report(
1257 "Time taken for Ping All: " +
1258 str( timeDiff ) +
1259 " seconds" )
1260 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1261 onpass="PING ALL PASS",
1262 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001263
kelvin-onlab65a72d22015-03-26 13:46:32 -07001264 caseResult71 = linkDown and pingResultLinkDown
1265 utilities.assert_equals( expect=main.TRUE, actual=caseResult71,
kelvin-onlab8a832582015-01-16 17:06:11 -08001266 onpass="Random Link cut Test PASS",
1267 onfail="Random Link cut Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001268
kelvin-onlab8a832582015-01-16 17:06:11 -08001269 def CASE81( self, main ):
1270 """
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001271 Bring the core links up that are down and verify ping all ( Point Intents-Att Topo )
kelvin-onlab8a832582015-01-16 17:06:11 -08001272 """
kelvin8ec71442015-01-15 16:57:00 -08001273 import random
kelvin-onlab65a72d22015-03-26 13:46:32 -07001274 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1275 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1276 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001277 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001278 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
kelvin8ec71442015-01-15 16:57:00 -08001279
kelvin-onlab8a832582015-01-16 17:06:11 -08001280 main.log.report(
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001281 "Bring the core links up that are down and verify ping all ( Point Intents-Att Topo" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001282 main.log.report(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001283 "__________________________________________________________________" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001284 main.case(
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001285 "Point intents - Bring the core links up that are down and verify ping all" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001286 main.step( "Bring randomly cut links on Core devices up" )
1287 for i in range( int( switchLinksToToggle ) ):
1288 main.Mininet1.link(
1289 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001290 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001291 OPTION="up" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001292 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001293 main.Mininet1.link(
1294 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001295 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001296 OPTION="up" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001297 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001298 main.Mininet1.link(
1299 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001300 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001301 OPTION="up" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001302 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -08001303
1304 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001305 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -08001306 topology_output,
Hari Krishna22c3d412015-02-17 16:48:12 -08001307 main.numMNswitches,
1308 str( main.numMNlinks ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001309 utilities.assert_equals(
1310 expect=main.TRUE,
1311 actual=linkUp,
1312 onpass="Link up discovered properly",
1313 onfail="Link up was not discovered in " +
1314 str( link_sleep ) +
1315 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -08001316
kelvin-onlab8a832582015-01-16 17:06:11 -08001317 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -08001318 pingResultLinkUp = main.FALSE
1319 time1 = time.time()
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001320 pingResultLinkUp = main.Mininet1.pingall(timeout = main.pingTimeout )
kelvin8ec71442015-01-15 16:57:00 -08001321 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001322 timeDiff = round( ( time2 - time1 ), 2 )
1323 main.log.report(
1324 "Time taken for Ping All: " +
1325 str( timeDiff ) +
1326 " seconds" )
1327 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1328 onpass="PING ALL PASS",
1329 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001330
Hari Krishna22c3d412015-02-17 16:48:12 -08001331 caseResult81 = linkUp and pingResultLinkUp
1332 utilities.assert_equals( expect=main.TRUE, actual=caseResult81,
kelvin-onlab8a832582015-01-16 17:06:11 -08001333 onpass="Link Up Test PASS",
1334 onfail="Link Up Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001335
Hari Krishnab35c6d02015-03-18 11:13:51 -07001336 def CASE72( self, main ):
1337 """
1338 Randomly bring some links down and verify ping all ( Host Intents-Chordal Topo)
1339 """
1340 import random
1341 import itertools
1342 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1343
1344 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Chordal Topo)" )
1345 main.log.report( "___________________________________________________________________________" )
1346 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
1347 switches = []
1348 switchesComb = []
1349 for i in range( main.numMNswitches ):
1350 switches.append('s%d'%(i+1))
1351 switchesLinksComb = list(itertools.combinations(switches,2))
1352 main.randomLinks = random.sample(switchesLinksComb, 5 )
1353 print main.randomLinks
1354 main.step( "Cut links on random devices" )
1355
1356 for switch in main.randomLinks:
1357 main.Mininet1.link(
1358 END1=switch[0],
1359 END2=switch[1],
1360 OPTION="down")
Hari Krishna0ce0e152015-06-23 09:55:29 -07001361 time.sleep( link_sleep )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001362
1363 topology_output = main.ONOScli2.topology()
1364 linkDown = main.ONOSbench.checkStatus(
1365 topology_output, main.numMNswitches, str(
1366 int( main.numMNlinks ) - 5 * 2 ) )
1367 utilities.assert_equals(
1368 expect=main.TRUE,
1369 actual=linkDown,
1370 onpass="Link Down discovered properly",
1371 onfail="Link down was not discovered in " +
1372 str( link_sleep ) +
1373 " seconds" )
1374
1375 main.step( "Verify Ping across all hosts" )
1376 pingResultLinkDown = main.FALSE
1377 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001378 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001379 time2 = time.time()
1380 timeDiff = round( ( time2 - time1 ), 2 )
1381 main.log.report(
1382 "Time taken for Ping All: " +
1383 str( timeDiff ) +
1384 " seconds" )
1385 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1386 onpass="PING ALL PASS",
1387 onfail="PING ALL FAIL" )
1388
kelvin-onlab65a72d22015-03-26 13:46:32 -07001389 caseResult71 = pingResultLinkDown
1390 utilities.assert_equals( expect=main.TRUE, actual=caseResult71,
Hari Krishnab35c6d02015-03-18 11:13:51 -07001391 onpass="Random Link cut Test PASS",
1392 onfail="Random Link cut Test FAIL" )
1393
1394 def CASE82( self, main ):
1395 """
1396 Bring the core links up that are down and verify ping all ( Host Intents Chordal Topo )
1397 """
1398 import random
1399 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1400
1401 main.log.report(
1402 "Bring the core links up that are down and verify ping all (Host Intents-Chordal Topo" )
1403 main.log.report(
1404 "__________________________________________________________________" )
1405 main.case(
1406 "Host intents - Bring the core links up that are down and verify ping all" )
1407 main.step( "Bring randomly cut links on devices up" )
1408
1409 for switch in main.randomLinks:
1410 main.Mininet1.link(
1411 END1=switch[0],
1412 END2=switch[1],
1413 OPTION="up")
Hari Krishna0ce0e152015-06-23 09:55:29 -07001414 time.sleep( link_sleep )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001415
1416 topology_output = main.ONOScli2.topology()
1417 linkUp = main.ONOSbench.checkStatus(
1418 topology_output,
1419 main.numMNswitches,
1420 str( main.numMNlinks ) )
1421 utilities.assert_equals(
1422 expect=main.TRUE,
1423 actual=linkUp,
1424 onpass="Link up discovered properly",
1425 onfail="Link up was not discovered in " +
1426 str( link_sleep ) +
1427 " seconds" )
1428
1429 main.step( "Verify Ping across all hosts" )
1430 pingResultLinkUp = main.FALSE
1431 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001432 pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001433 time2 = time.time()
1434 timeDiff = round( ( time2 - time1 ), 2 )
1435 main.log.report(
1436 "Time taken for Ping All: " +
1437 str( timeDiff ) +
1438 " seconds" )
1439 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1440 onpass="PING ALL PASS",
1441 onfail="PING ALL FAIL" )
1442
1443 caseResult82 = linkUp and pingResultLinkUp
1444 utilities.assert_equals( expect=main.TRUE, actual=caseResult82,
1445 onpass="Link Up Test PASS",
1446 onfail="Link Up Test FAIL" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001447
Hari Krishnab35c6d02015-03-18 11:13:51 -07001448 def CASE73( self, main ):
1449 """
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001450 Randomly bring some links down and verify ping all ( Point Intents-Chordal Topo)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001451 """
1452 import random
kelvin-onlab65a72d22015-03-26 13:46:32 -07001453 import itertools
Hari Krishnab35c6d02015-03-18 11:13:51 -07001454 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001455
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001456 main.log.report( "Randomly bring some core links down and verify ping all ( Point Intents-Chordal Topo)" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001457 main.log.report( "___________________________________________________________________________" )
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001458 main.case( "Point intents - Randomly bring some core links down and verify ping all" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001459 switches = []
1460 switchesComb = []
1461 for i in range( main.numMNswitches ):
1462 switches.append('s%d'%(i+1))
1463 switchesLinksComb = list(itertools.combinations(switches,2))
1464 main.randomLinks = random.sample(switchesLinksComb, 5 )
1465 print main.randomLinks
1466 main.step( "Cut links on random devices" )
1467
1468 for switch in main.randomLinks:
Hari Krishnab35c6d02015-03-18 11:13:51 -07001469 main.Mininet1.link(
1470 END1=switch[0],
1471 END2=switch[1],
kelvin-onlab65a72d22015-03-26 13:46:32 -07001472 OPTION="down")
Hari Krishna0ce0e152015-06-23 09:55:29 -07001473 time.sleep( link_sleep )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001474
1475 topology_output = main.ONOScli2.topology()
1476 linkDown = main.ONOSbench.checkStatus(
1477 topology_output, main.numMNswitches, str(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001478 int( main.numMNlinks ) - 5 * 2 ) )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001479 utilities.assert_equals(
1480 expect=main.TRUE,
1481 actual=linkDown,
1482 onpass="Link Down discovered properly",
1483 onfail="Link down was not discovered in " +
1484 str( link_sleep ) +
1485 " seconds" )
1486
1487 main.step( "Verify Ping across all hosts" )
1488 pingResultLinkDown = main.FALSE
1489 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001490 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001491 time2 = time.time()
1492 timeDiff = round( ( time2 - time1 ), 2 )
1493 main.log.report(
1494 "Time taken for Ping All: " +
1495 str( timeDiff ) +
1496 " seconds" )
1497 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1498 onpass="PING ALL PASS",
1499 onfail="PING ALL FAIL" )
1500
kelvin-onlab65a72d22015-03-26 13:46:32 -07001501 caseResult73 = pingResultLinkDown
Hari Krishnab35c6d02015-03-18 11:13:51 -07001502 utilities.assert_equals( expect=main.TRUE, actual=caseResult73,
1503 onpass="Random Link cut Test PASS",
1504 onfail="Random Link cut Test FAIL" )
1505
1506 def CASE83( self, main ):
1507 """
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001508 Bring the core links up that are down and verify ping all ( Point Intents Chordal Topo )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001509 """
1510 import random
Hari Krishnab35c6d02015-03-18 11:13:51 -07001511 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001512
Hari Krishnab35c6d02015-03-18 11:13:51 -07001513 main.log.report(
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001514 "Bring the core links up that are down and verify ping all ( Point Intents-Chordal Topo" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001515 main.log.report(
1516 "__________________________________________________________________" )
1517 main.case(
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001518 "Point intents - Bring the core links up that are down and verify ping all" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001519 main.step( "Bring randomly cut links on devices up" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001520
kelvin-onlab65a72d22015-03-26 13:46:32 -07001521 for switch in main.randomLinks:
Hari Krishnab35c6d02015-03-18 11:13:51 -07001522 main.Mininet1.link(
1523 END1=switch[0],
1524 END2=switch[1],
1525 OPTION="up")
Hari Krishna0ce0e152015-06-23 09:55:29 -07001526 time.sleep( link_sleep )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001527
1528 topology_output = main.ONOScli2.topology()
1529 linkUp = main.ONOSbench.checkStatus(
1530 topology_output,
1531 main.numMNswitches,
1532 str( main.numMNlinks ) )
1533 utilities.assert_equals(
1534 expect=main.TRUE,
1535 actual=linkUp,
1536 onpass="Link up discovered properly",
1537 onfail="Link up was not discovered in " +
1538 str( link_sleep ) +
1539 " seconds" )
1540
1541 main.step( "Verify Ping across all hosts" )
1542 pingResultLinkUp = main.FALSE
1543 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001544 pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001545 time2 = time.time()
1546 timeDiff = round( ( time2 - time1 ), 2 )
1547 main.log.report(
1548 "Time taken for Ping All: " +
1549 str( timeDiff ) +
1550 " seconds" )
1551 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1552 onpass="PING ALL PASS",
1553 onfail="PING ALL FAIL" )
1554
1555 caseResult83 = linkUp and pingResultLinkUp
1556 utilities.assert_equals( expect=main.TRUE, actual=caseResult83,
1557 onpass="Link Up Test PASS",
1558 onfail="Link Up Test FAIL" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001559
1560 def CASE74( self, main ):
1561 """
1562 Randomly bring some core links down and verify ping all ( Host Intents-Spine Topo)
1563 """
1564 import random
1565 main.randomLink1 = []
1566 main.randomLink2 = []
1567 main.randomLink3 = []
1568 main.randomLink4 = []
1569 link1End1 = main.params[ 'SPINECORELINKS' ][ 'linkS9' ]
1570 link1End2top = main.params[ 'SPINECORELINKS' ][ 'linkS9top' ].split( ',' )
1571 link1End2bot = main.params[ 'SPINECORELINKS' ][ 'linkS9bot' ].split( ',' )
1572 link2End1 = main.params[ 'SPINECORELINKS' ][ 'linkS10' ]
1573 link2End2top = main.params[ 'SPINECORELINKS' ][ 'linkS10top' ].split( ',' )
1574 link2End2bot = main.params[ 'SPINECORELINKS' ][ 'linkS10bot' ].split( ',' )
1575 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1576 main.pingTimeout = 400
1577
1578 main.log.report( "Bring some core links down and verify ping all (Host Intents-Spine Topo)" )
1579 main.log.report( "___________________________________________________________________________" )
1580
1581 linkIndex = range(4)
1582 linkIndexS9 = random.sample(linkIndex,1)[0]
1583 linkIndex.remove(linkIndexS9)
1584 linkIndexS10 = random.sample(linkIndex,1)[0]
1585 main.randomLink1 = link1End2top[linkIndexS9]
1586 main.randomLink2 = link2End2top[linkIndexS10]
1587 main.randomLink3 = random.sample(link1End2bot,1)[0]
1588 main.randomLink4 = random.sample(link2End2bot,1)[0]
kelvin-onlab77d6c302015-03-31 11:33:32 -07001589 # main.Mininet1.link( END1=link1End1, END2=main.randomLink1, OPTION="down" )
1590 # main.Mininet1.link( END1=link2End1, END2=main.randomLink2, OPTION="down" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001591 main.Mininet1.link( END1=link1End1, END2=main.randomLink3, OPTION="down" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001592 time.sleep( link_sleep )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001593 main.Mininet1.link( END1=link2End1, END2=main.randomLink4, OPTION="down" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001594 time.sleep( link_sleep )
1595
1596 topology_output = main.ONOScli2.topology()
1597 linkDown = main.ONOSbench.checkStatus(
1598 topology_output, main.numMNswitches, str(
1599 int( main.numMNlinks ) - 8 ))
1600 utilities.assert_equals(
1601 expect=main.TRUE,
1602 actual=linkDown,
1603 onpass="Link Down discovered properly",
1604 onfail="Link down was not discovered in " +
1605 str( link_sleep ) +
1606 " seconds" )
1607
1608 main.step( "Verify Ping across all hosts" )
1609 pingResultLinkDown = main.FALSE
1610 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001611 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlab65a72d22015-03-26 13:46:32 -07001612 time2 = time.time()
1613 timeDiff = round( ( time2 - time1 ), 2 )
1614 main.log.report(
1615 "Time taken for Ping All: " +
1616 str( timeDiff ) +
1617 " seconds" )
1618 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1619 onpass="PING ALL PASS",
1620 onfail="PING ALL FAIL" )
1621
1622 caseResult74 = linkDown and pingResultLinkDown
1623 utilities.assert_equals( expect=main.TRUE, actual=caseResult74,
1624 onpass="Random Link cut Test PASS",
1625 onfail="Random Link cut Test FAIL" )
1626
1627 def CASE84( self, main ):
1628 """
1629 Bring the core links up that are down and verify ping all ( Host Intents-Spine Topo )
1630 """
1631 import random
1632 link1End1 = main.params[ 'SPINECORELINKS' ][ 'linkS9' ]
1633 link2End1 = main.params[ 'SPINECORELINKS' ][ 'linkS10' ]
1634 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1635 main.log.report(
1636 "Bring the core links up that are down and verify ping all (Host Intents-Spine Topo" )
1637 main.log.report(
1638 "__________________________________________________________________" )
1639 main.case(
1640 "Host intents - Bring the core links up that are down and verify ping all" )
1641
kelvin-onlab77d6c302015-03-31 11:33:32 -07001642 #main.Mininet1.link( END1=link1End1, END2=main.randomLink1, OPTION="up" )
1643 #main.Mininet1.link( END1=link2End1, END2=main.randomLink2, OPTION="up" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001644 main.Mininet1.link( END1=link1End1, END2=main.randomLink3, OPTION="up" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001645 time.sleep( link_sleep )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001646 main.Mininet1.link( END1=link2End1, END2=main.randomLink4, OPTION="up" )
1647 time.sleep( link_sleep )
1648
kelvin-onlab65a72d22015-03-26 13:46:32 -07001649 topology_output = main.ONOScli2.topology()
1650 linkUp = main.ONOSbench.checkStatus(
1651 topology_output,
1652 main.numMNswitches,
1653 str( main.numMNlinks ) )
1654 utilities.assert_equals(
1655 expect=main.TRUE,
1656 actual=linkUp,
1657 onpass="Link up discovered properly",
1658 onfail="Link up was not discovered in " +
1659 str( link_sleep ) +
1660 " seconds" )
1661
1662 main.step( "Verify Ping across all hosts" )
1663 pingResultLinkUp = main.FALSE
1664 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001665 pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlab65a72d22015-03-26 13:46:32 -07001666 time2 = time.time()
1667 timeDiff = round( ( time2 - time1 ), 2 )
1668 main.log.report(
1669 "Time taken for Ping All: " +
1670 str( timeDiff ) +
1671 " seconds" )
1672 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1673 onpass="PING ALL PASS",
1674 onfail="PING ALL FAIL" )
1675
1676 caseResult84 = linkUp and pingResultLinkUp
1677 utilities.assert_equals( expect=main.TRUE, actual=caseResult84,
1678 onpass="Link Up Test PASS",
1679 onfail="Link Up Test FAIL" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001680
1681 def CASE90( self ):
kelvin-onlab8a832582015-01-16 17:06:11 -08001682 """
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001683 Install 600 point intents and verify ping all (Att Topology)
kelvin-onlab8a832582015-01-16 17:06:11 -08001684 """
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001685 main.log.report( "Add 600 point intents and verify pingall (Att Topology)" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001686 main.log.report( "_______________________________________" )
1687 import itertools
1688 import time
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001689 main.case( "Install 600 point intents" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001690 main.step( "Add point Intents" )
1691 intentResult = main.TRUE
1692 deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) )
1693
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001694 intentIdList = []
Hari Krishnab35c6d02015-03-18 11:13:51 -07001695 time1 = time.time()
Hari Krishnab35c6d02015-03-18 11:13:51 -07001696 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1697 pool = []
1698 for cli in main.CLIs:
1699 if i >= len( deviceCombos ):
1700 break
1701 t = main.Thread( target=cli.addPointIntent,
1702 threadID=main.threadID,
1703 name="addPointIntent",
Hari Krishna0ce0e152015-06-23 09:55:29 -07001704 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4",main.MACsDict.get(deviceCombos[i][0]),main.MACsDict.get(deviceCombos[i][1])])
1705 pool.append(t)
1706 #time.sleep(1)
1707 t.start()
1708 i = i + 1
1709 main.threadID = main.threadID + 1
1710 for thread in pool:
1711 thread.join()
1712 intentIdList.append(thread.result)
1713 time2 = time.time()
1714 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1715 intentResult = main.TRUE
1716 intentsJson = main.ONOScli2.intents()
1717 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1718 intentsJson = intentsJson)
1719 print getIntentStateResult
1720 # Takes awhile for all the onos to get the intents
1721 time.sleep(60)
1722 main.step( "Verify Ping across all hosts" )
1723 pingResult = main.FALSE
1724 time1 = time.time()
1725 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
1726 time2 = time.time()
1727 timeDiff = round( ( time2 - time1 ), 2 )
1728 main.log.report(
1729 "Time taken for Ping All: " +
1730 str( timeDiff ) +
1731 " seconds" )
1732 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1733 onpass="PING tALL PASS",
1734 onfail="PING ALL FAIL" )
1735
1736 case90Result = ( intentResult and pingResult )
1737
1738 utilities.assert_equals(
1739 expect=main.TRUE,
1740 actual=case90Result,
1741 onpass="Install 600 point Intents and Ping All test PASS",
1742 onfail="Install 600 point Intents and Ping All test FAIL" )
1743
1744 def CASE91( self ):
1745 """
1746 Install 600 point intents and verify ping all (Chordal Topology)
1747 """
1748 main.log.report( "Add 600 point intents and verify pingall (Chordal Topology)" )
1749 main.log.report( "_______________________________________" )
1750 import itertools
1751 import time
1752 main.case( "Install 600 point intents" )
1753 main.step( "Add point Intents" )
1754 intentResult = main.TRUE
1755 deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) )
1756
1757 intentIdList = []
1758 time1 = time.time()
1759 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1760 pool = []
1761 for cli in main.CLIs:
1762 if i >= len( deviceCombos ):
1763 break
1764 t = main.Thread( target=cli.addPointIntent,
1765 threadID=main.threadID,
1766 name="addPointIntent",
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001767 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
Hari Krishnab35c6d02015-03-18 11:13:51 -07001768 pool.append(t)
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001769 #time.sleep(1)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001770 t.start()
1771 i = i + 1
1772 main.threadID = main.threadID + 1
1773 for thread in pool:
1774 thread.join()
1775 intentIdList.append(thread.result)
1776 time2 = time.time()
1777 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1778 intentResult = main.TRUE
1779 intentsJson = main.ONOScli2.intents()
1780 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1781 intentsJson = intentsJson)
1782 print getIntentStateResult
1783 # Takes awhile for all the onos to get the intents
1784 time.sleep(30)
kelvin-onlab8a832582015-01-16 17:06:11 -08001785 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001786 pingResult = main.FALSE
1787 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001788 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001789 time2 = time.time()
1790 timeDiff = round( ( time2 - time1 ), 2 )
1791 main.log.report(
1792 "Time taken for Ping All: " +
1793 str( timeDiff ) +
1794 " seconds" )
1795 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1796 onpass="PING ALL PASS",
1797 onfail="PING ALL FAIL" )
1798
kelvin-onlab65a72d22015-03-26 13:46:32 -07001799 case91Result = ( intentResult and pingResult )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001800
1801 utilities.assert_equals(
1802 expect=main.TRUE,
kelvin-onlabd878fc22015-03-27 13:33:41 -07001803 actual=case91Result,
Hari Krishna0ce0e152015-06-23 09:55:29 -07001804 onpass="Install 600 point Intents and Ping All test PASS",
1805 onfail="Install 600 point Intents and Ping All test FAIL" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001806
1807 def CASE92( self ):
1808 """
kelvin-onlab77d6c302015-03-31 11:33:32 -07001809 Install 4556 point intents and verify ping all (Spine Topology)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001810 """
kelvin-onlab77d6c302015-03-31 11:33:32 -07001811 main.log.report( "Add 4556 point intents and verify pingall (Spine Topology)" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001812 main.log.report( "_______________________________________" )
1813 import itertools
1814 import time
kelvin-onlab77d6c302015-03-31 11:33:32 -07001815 main.case( "Install 4556 point intents" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001816 main.step( "Add point Intents" )
1817 intentResult = main.TRUE
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001818 main.pingTimeout = 600
kelvin-onlab77d6c302015-03-31 11:33:32 -07001819 for i in range(len(main.hostMACs)):
1820 main.MACsDict[main.deviceDPIDs[i+10]] = main.hostMACs[i].split('/')[0]
1821 print main.MACsDict
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001822 deviceCombos = list( itertools.permutations( main.deviceDPIDs[10:], 2 ) )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001823 intentIdList = []
1824 time1 = time.time()
1825 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1826 pool = []
1827 for cli in main.CLIs:
1828 if i >= len( deviceCombos ):
1829 break
1830 t = main.Thread( target=cli.addPointIntent,
1831 threadID=main.threadID,
1832 name="addPointIntent",
1833 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
1834 pool.append(t)
1835 #time.sleep(1)
1836 t.start()
1837 i = i + 1
1838 main.threadID = main.threadID + 1
1839 for thread in pool:
1840 thread.join()
1841 intentIdList.append(thread.result)
1842 time2 = time.time()
1843 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1844 intentResult = main.TRUE
1845 intentsJson = main.ONOScli2.intents()
1846 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1847 intentsJson = intentsJson)
kelvin-onlab77d6c302015-03-31 11:33:32 -07001848 #print getIntentStateResult
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001849 # Takes awhile for all the onos to get the intents
kelvin-onlab77d6c302015-03-31 11:33:32 -07001850 time.sleep(60)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001851 main.step( "Verify Ping across all hosts" )
1852 pingResult = main.FALSE
1853 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001854 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001855 time2 = time.time()
1856 timeDiff = round( ( time2 - time1 ), 2 )
1857 main.log.report(
1858 "Time taken for Ping All: " +
1859 str( timeDiff ) +
1860 " seconds" )
1861 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1862 onpass="PING ALL PASS",
1863 onfail="PING ALL FAIL" )
1864
kelvin-onlab65a72d22015-03-26 13:46:32 -07001865 case92Result = ( intentResult and pingResult )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001866
1867 utilities.assert_equals(
1868 expect=main.TRUE,
kelvin-onlab65a72d22015-03-26 13:46:32 -07001869 actual=case92Result,
kelvin-onlab77d6c302015-03-31 11:33:32 -07001870 onpass="Install 4556 point Intents and Ping All test PASS",
1871 onfail="Install 4556 point Intents and Ping All test FAIL" )
1872
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001873 def CASE93( self ):
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001874 """
kelvin-onlab77d6c302015-03-31 11:33:32 -07001875 Install multi-single point intents and verify Ping all works
1876 for att topology
1877 """
1878 import copy
1879 import time
1880 main.log.report( "Install multi-single point intents and verify Ping all" )
1881 main.log.report( "___________________________________________" )
1882 main.case( "Install multi-single point intents and Ping all" )
1883 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
1884 portIngressList = ['1']*(len(deviceDPIDsCopy) - 1)
1885 intentIdList = []
1886 print "MACsDict", main.MACsDict
1887 time1 = time.time()
1888 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
1889 pool = []
1890 for cli in main.CLIs:
1891 egressDevice = deviceDPIDsCopy[i]
1892 ingressDeviceList = copy.copy(deviceDPIDsCopy)
1893 ingressDeviceList.remove(egressDevice)
1894 if i >= len( deviceDPIDsCopy ):
1895 break
1896 t = main.Thread( target=cli.addMultipointToSinglepointIntent,
1897 threadID=main.threadID,
1898 name="addMultipointToSinglepointIntent",
1899 args =[ingressDeviceList,egressDevice,portIngressList,'1','IPV4','',main.MACsDict.get(egressDevice)])
1900 pool.append(t)
1901 #time.sleep(1)
1902 t.start()
1903 i = i + 1
1904 main.threadID = main.threadID + 1
1905 for thread in pool:
1906 thread.join()
1907 intentIdList.append(thread.result)
1908 time2 = time.time()
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001909 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1910 time.sleep(30)
1911 print "getting all intents ID"
1912 intentIdTemp = main.ONOScli1.getAllIntentsId()
1913 print intentIdTemp
1914 print len(intentIdList)
kelvin-onlab06ade552015-03-31 18:09:27 -07001915 print intentIdList
kelvin-onlab4df89f22015-04-13 18:10:23 -07001916 checkIntentStateResult = main.TRUE
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001917 print "Checking intents state"
kelvin-onlab4df89f22015-04-13 18:10:23 -07001918 checkIntentStateResult = main.ONOScli1.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
1919 checkIntentStateResult = main.ONOScli2.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
1920 checkIntentStateResult = main.ONOScli3.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
1921 checkIntentStateResult = main.ONOScli4.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
1922 checkIntentStateResult = main.ONOScli5.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
1923
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001924 if checkIntentStateResult:
1925 main.log.info( "All intents are installed correctly " )
kelvin-onlab4df89f22015-04-13 18:10:23 -07001926
1927 print "Checking flows state "
1928 checkFlowsState = main.ONOScli1.checkFlowsState()
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001929 time.sleep(50)
kelvin-onlab77d6c302015-03-31 11:33:32 -07001930 main.step( "Verify Ping across all hosts" )
1931 pingResult = main.FALSE
1932 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001933 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlab77d6c302015-03-31 11:33:32 -07001934 time2 = time.time()
1935 timeDiff = round( ( time2 - time1 ), 2 )
1936 main.log.report(
1937 "Time taken for Ping All: " +
1938 str( timeDiff ) +
1939 " seconds" )
kelvin-onlab4df89f22015-04-13 18:10:23 -07001940 checkFlowsState = main.ONOScli1.checkFlowsState()
kelvin-onlab77d6c302015-03-31 11:33:32 -07001941 case93Result = pingResult
1942 utilities.assert_equals(
1943 expect=main.TRUE,
1944 actual=case93Result,
1945 onpass="Install 25 multi to single point Intents and Ping All test PASS",
1946 onfail="Install 25 multi to single point Intents and Ping All test FAIL" )
1947
kelvin-onlab20c712a2015-03-31 12:55:34 -07001948 def CASE94( self ):
1949 """
1950 Install multi-single point intents and verify Ping all works
kelvin-onlabd9a8ed32015-04-03 13:55:28 -07001951 for Chordal topology
kelvin-onlab20c712a2015-03-31 12:55:34 -07001952 """
1953 import copy
1954 import time
1955 main.log.report( "Install multi-single point intents and verify Ping all" )
1956 main.log.report( "___________________________________________" )
1957 main.case( "Install multi-single point intents and Ping all" )
1958 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
1959 portIngressList = ['1']*(len(deviceDPIDsCopy) - 1)
1960 intentIdList = []
1961 print "MACsDict", main.MACsDict
1962 time1 = time.time()
1963 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
1964 pool = []
1965 for cli in main.CLIs:
1966 egressDevice = deviceDPIDsCopy[i]
1967 ingressDeviceList = copy.copy(deviceDPIDsCopy)
1968 ingressDeviceList.remove(egressDevice)
1969 if i >= len( deviceDPIDsCopy ):
1970 break
1971 t = main.Thread( target=cli.addMultipointToSinglepointIntent,
1972 threadID=main.threadID,
1973 name="addMultipointToSinglepointIntent",
1974 args =[ingressDeviceList,egressDevice,portIngressList,'1','IPV4','',main.MACsDict.get(egressDevice)])
1975 pool.append(t)
1976 #time.sleep(1)
1977 t.start()
1978 i = i + 1
1979 main.threadID = main.threadID + 1
1980 for thread in pool:
1981 thread.join()
1982 intentIdList.append(thread.result)
1983 time2 = time.time()
1984 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1985 time.sleep(5)
1986 main.step( "Verify Ping across all hosts" )
1987 pingResult = main.FALSE
1988 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001989 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlab20c712a2015-03-31 12:55:34 -07001990 time2 = time.time()
1991 timeDiff = round( ( time2 - time1 ), 2 )
1992 main.log.report(
1993 "Time taken for Ping All: " +
1994 str( timeDiff ) +
1995 " seconds" )
1996
1997 case94Result = pingResult
1998 utilities.assert_equals(
1999 expect=main.TRUE,
2000 actual=case94Result,
2001 onpass="Install 25 multi to single point Intents and Ping All test PASS",
2002 onfail="Install 25 multi to single point Intents and Ping All test FAIL" )
kelvin-onlab06ade552015-03-31 18:09:27 -07002003
2004 #def CASE95 multi-single point intent for Spine
2005
kelvin-onlab77d6c302015-03-31 11:33:32 -07002006 def CASE96( self ):
2007 """
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002008 Install single-multi point intents and verify Ping all works
2009 for att topology
2010 """
2011 import copy
2012 main.log.report( "Install single-multi point intents and verify Ping all" )
2013 main.log.report( "___________________________________________" )
2014 main.case( "Install single-multi point intents and Ping all" )
kelvin-onlab06ade552015-03-31 18:09:27 -07002015 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
2016 portEgressList = ['1']*(len(deviceDPIDsCopy) - 1)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002017 intentIdList = []
kelvin-onlab06ade552015-03-31 18:09:27 -07002018 print "MACsDict", main.MACsDict
2019 time1 = time.time()
2020 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
2021 pool = []
2022 for cli in main.CLIs:
2023 ingressDevice = deviceDPIDsCopy[i]
2024 egressDeviceList = copy.copy(deviceDPIDsCopy)
2025 egressDeviceList.remove(ingressDevice)
2026 if i >= len( deviceDPIDsCopy ):
2027 break
2028 t = main.Thread( target=cli.addSinglepointToMultipointIntent,
2029 threadID=main.threadID,
2030 name="addSinglepointToMultipointIntent",
2031 args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',main.MACsDict.get(ingressDevice)])
2032 pool.append(t)
2033 #time.sleep(1)
2034 t.start()
2035 i = i + 1
2036 main.threadID = main.threadID + 1
2037 for thread in pool:
2038 thread.join()
2039 intentIdList.append(thread.result)
2040 time2 = time.time()
2041 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
2042 time.sleep(5)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002043 main.step( "Verify Ping across all hosts" )
2044 pingResult = main.FALSE
2045 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07002046 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002047 time2 = time.time()
2048 timeDiff = round( ( time2 - time1 ), 2 )
2049 main.log.report(
2050 "Time taken for Ping All: " +
2051 str( timeDiff ) +
2052 " seconds" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002053
kelvin-onlab06ade552015-03-31 18:09:27 -07002054 case96Result = pingResult
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002055 utilities.assert_equals(
2056 expect=main.TRUE,
kelvin-onlab06ade552015-03-31 18:09:27 -07002057 actual=case96Result,
2058 onpass="Install 25 single to multi point Intents and Ping All test PASS",
2059 onfail="Install 25 single to multi point Intents and Ping All test FAIL" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002060
kelvin-onlab77d6c302015-03-31 11:33:32 -07002061 def CASE97( self ):
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002062 """
2063 Install single-multi point intents and verify Ping all works
kelvin-onlab06ade552015-03-31 18:09:27 -07002064 for Chordal topology
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002065 """
2066 import copy
2067 main.log.report( "Install single-multi point intents and verify Ping all" )
2068 main.log.report( "___________________________________________" )
2069 main.case( "Install single-multi point intents and Ping all" )
kelvin-onlab06ade552015-03-31 18:09:27 -07002070 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
2071 portEgressList = ['1']*(len(deviceDPIDsCopy) - 1)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002072 intentIdList = []
kelvin-onlab06ade552015-03-31 18:09:27 -07002073 print "MACsDict", main.MACsDict
2074 time1 = time.time()
2075 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
2076 pool = []
2077 for cli in main.CLIs:
2078 ingressDevice = deviceDPIDsCopy[i]
2079 egressDeviceList = copy.copy(deviceDPIDsCopy)
2080 egressDeviceList.remove(ingressDevice)
2081 if i >= len( deviceDPIDsCopy ):
2082 break
2083 t = main.Thread( target=cli.addSinglepointToMultipointIntent,
2084 threadID=main.threadID,
2085 name="addSinglepointToMultipointIntent",
2086 args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',main.MACsDict.get(ingressDevice),''])
2087 pool.append(t)
2088 #time.sleep(1)
2089 t.start()
2090 i = i + 1
2091 main.threadID = main.threadID + 1
2092 for thread in pool:
2093 thread.join()
2094 intentIdList.append(thread.result)
2095 time2 = time.time()
2096 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
2097 time.sleep(5)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002098 main.step( "Verify Ping across all hosts" )
2099 pingResult = main.FALSE
2100 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07002101 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002102 time2 = time.time()
2103 timeDiff = round( ( time2 - time1 ), 2 )
2104 main.log.report(
2105 "Time taken for Ping All: " +
2106 str( timeDiff ) +
2107 " seconds" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002108
kelvin-onlab06ade552015-03-31 18:09:27 -07002109 case97Result = pingResult
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002110 utilities.assert_equals(
2111 expect=main.TRUE,
kelvin-onlab06ade552015-03-31 18:09:27 -07002112 actual=case97Result,
2113 onpass="Install 25 single to multi point Intents and Ping All test PASS",
2114 onfail="Install 25 single to multi point Intents and Ping All test FAIL" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002115
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07002116 def CASE98( self ):
2117 """
2118 Install single-multi point intents and verify Ping all works
2119 for Spine topology
2120 """
2121 import copy
2122 main.log.report( "Install single-multi point intents and verify Ping all" )
2123 main.log.report( "___________________________________________" )
2124 main.case( "Install single-multi point intents and Ping all" )
2125 deviceDPIDsCopy = copy.copy( main.deviceDPIDs )
2126 deviceDPIDsCopy = deviceDPIDsCopy[ 10: ]
2127 portEgressList = [ '1' ]*(len(deviceDPIDsCopy) - 1)
2128 intentIdList = []
2129 MACsDictCopy = {}
2130 for i in range( len( deviceDPIDsCopy ) ):
2131 MACsDictCopy[ deviceDPIDsCopy[ i ] ] = main.hostMACs[i].split( '/' )[ 0 ]
2132
2133 print "deviceDPIDsCopy", deviceDPIDsCopy
2134 print ""
2135 print "MACsDictCopy", MACsDictCopy
2136 time1 = time.time()
2137 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
2138 pool = []
2139 for cli in main.CLIs:
2140 if i >= len( deviceDPIDsCopy ):
2141 break
2142 ingressDevice = deviceDPIDsCopy[i]
2143 egressDeviceList = copy.copy(deviceDPIDsCopy)
2144 egressDeviceList.remove(ingressDevice)
2145 t = main.Thread( target=cli.addSinglepointToMultipointIntent,
2146 threadID=main.threadID,
2147 name="addSinglepointToMultipointIntent",
2148 args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',MACsDictCopy.get(ingressDevice),''])
2149 pool.append(t)
2150 #time.sleep(1)
2151 t.start()
2152 i = i + 1
2153 main.threadID = main.threadID + 1
2154 for thread in pool:
2155 thread.join()
2156 intentIdList.append(thread.result)
2157 time2 = time.time()
2158 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
2159 time.sleep(5)
2160 main.step( "Verify Ping across all hosts" )
2161 pingResult = main.FALSE
2162 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07002163 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07002164 time2 = time.time()
2165 timeDiff = round( ( time2 - time1 ), 2 )
2166 main.log.report(
2167 "Time taken for Ping All: " +
2168 str( timeDiff ) +
2169 " seconds" )
2170
2171 case98Result = pingResult
2172 utilities.assert_equals(
2173 expect=main.TRUE,
2174 actual=case98Result,
2175 onpass="Install 25 single to multi point Intents and Ping All test PASS",
2176 onfail="Install 25 single to multi point Intents and Ping All test FAIL" )
2177
kelvin-onlab8a832582015-01-16 17:06:11 -08002178 def CASE10( self ):
kelvin-onlab7642bb12015-02-27 13:48:17 -08002179 import time
kelvin-onlab8a832582015-01-16 17:06:11 -08002180 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002181 Remove all Intents
kelvin-onlab8a832582015-01-16 17:06:11 -08002182 """
2183 main.log.report( "Remove all intents that were installed previously" )
2184 main.log.report( "______________________________________________" )
2185 main.log.info( "Remove all intents" )
2186 main.case( "Removing intents" )
2187 main.step( "Obtain the intent id's first" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002188 intentsList = main.ONOScli1.getAllIntentIds()
kelvin-onlab8a832582015-01-16 17:06:11 -08002189 ansi_escape = re.compile( r'\x1b[^m]*m' )
2190 intentsList = ansi_escape.sub( '', intentsList )
2191 intentsList = intentsList.replace(
2192 " onos:intents | grep id=",
2193 "" ).replace(
2194 "id=",
2195 "" ).replace(
2196 "\r\r",
2197 "" )
2198 intentsList = intentsList.splitlines()
Hari Krishna0ce0e152015-06-23 09:55:29 -07002199 #intentsList = intentsList[ 1: ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002200 intentIdList = []
2201 step1Result = main.TRUE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002202 moreIntents = main.TRUE
2203 removeIntentCount = 0
kelvin-onlab65a72d22015-03-26 13:46:32 -07002204 intentsCount = len(intentsList)
Hari Krishna0ce0e152015-06-23 09:55:29 -07002205 main.log.info ( "Current number of intents: " + str(intentsCount) )
kelvin-onlab8a832582015-01-16 17:06:11 -08002206 if ( len( intentsList ) > 1 ):
kelvin-onlab54400a92015-02-26 18:05:51 -08002207 results = main.TRUE
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002208 main.log.info("Removing intent...")
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002209 while moreIntents:
Hari Krishna0ce0e152015-06-23 09:55:29 -07002210 #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 -07002211 if removeIntentCount == 5:
2212 break
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002213 removeIntentCount = removeIntentCount + 1
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002214 intentsList1 = main.ONOScli1.getAllIntentIds()
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002215 if len( intentsList1 ) == 0:
2216 break
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002217 ansi_escape = re.compile( r'\x1b[^m]*m' )
2218 intentsList1 = ansi_escape.sub( '', intentsList1 )
2219 intentsList1 = intentsList1.replace(
2220 " onos:intents | grep id=",
2221 "" ).replace(
2222 " state=",
2223 "" ).replace(
2224 "\r\r",
2225 "" )
2226 intentsList1 = intentsList1.splitlines()
Hari Krishna0ce0e152015-06-23 09:55:29 -07002227 #intentsList1 = intentsList1[ 1: ]
2228 main.log.info ( "Round %d intents to remove: " %(removeIntentCount) )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002229 print intentsList1
2230 intentIdList1 = []
Hari Krishnab35c6d02015-03-18 11:13:51 -07002231 if ( len( intentsList1 ) > 0 ):
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002232 moreIntents = main.TRUE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002233 for i in range( len( intentsList1 ) ):
2234 intentsTemp1 = intentsList1[ i ].split( ',' )
2235 intentIdList1.append( intentsTemp1[ 0 ].split('=')[1] )
Hari Krishna0ce0e152015-06-23 09:55:29 -07002236 main.log.info ( "Leftover Intent IDs: " + str(intentIdList1) )
2237 main.log.info ( "Length of Leftover Intents list: " + str(len(intentIdList1)) )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07002238 time1 = time.time()
2239 for i in xrange( 0, len( intentIdList1 ), int(main.numCtrls) ):
2240 pool = []
2241 for cli in main.CLIs:
2242 if i >= len( intentIdList1 ):
2243 break
2244 t = main.Thread( target=cli.removeIntent,
2245 threadID=main.threadID,
2246 name="removeIntent",
Hari Krishna0ce0e152015-06-23 09:55:29 -07002247 args=[intentIdList1[i],'org.onosproject.cli',False,False])
kelvin-onlabadfc8db2015-03-24 15:52:48 -07002248 pool.append(t)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07002249 t.start()
2250 i = i + 1
2251 main.threadID = main.threadID + 1
2252 for thread in pool:
2253 thread.join()
2254 intentIdList.append(thread.result)
Hari Krishna0ce0e152015-06-23 09:55:29 -07002255 #time.sleep(2)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07002256 time2 = time.time()
2257 main.log.info("Time for removing host intents: %2f seconds" %(time2-time1))
Hari Krishnab35c6d02015-03-18 11:13:51 -07002258 time.sleep(10)
Hari Krishna0ce0e152015-06-23 09:55:29 -07002259 main.log.info("Purging WITHDRAWN Intents")
2260 purgeResult = main.TRUE
2261 for i in range( int( main.numCtrls) ):
2262 t = main.Thread( target=main.CLIs[i].purgeIntents,
2263 threadID=main.threadID,
2264 name="purgeIntents",
2265 args=[ ] )
2266 pool.append(t)
2267 t.start()
2268 main.threadID = main.threadID + 1
2269 for t in pool:
2270 t.join()
2271 purgeResult = purgeResult and t.result
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002272 else:
Hari Krishna0ce0e152015-06-23 09:55:29 -07002273 time.sleep(10)
Hari Krishnab35c6d02015-03-18 11:13:51 -07002274 if len( main.ONOScli1.intents()):
Hari Krishnaef1bd4e2015-03-12 16:55:30 -07002275 continue
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002276 break
Hari Krishna0ce0e152015-06-23 09:55:29 -07002277 time.sleep(10)
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002278 else:
kelvin-onlab65a72d22015-03-26 13:46:32 -07002279 print "Removed %d intents" %(intentsCount)
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002280 step1Result = main.TRUE
2281 else:
2282 print "No Intent IDs found in Intents list: ", intentsList
2283 step1Result = main.FALSE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002284
kelvin-onlabdc8719b2015-03-02 14:01:52 -08002285 print main.ONOScli1.intents()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002286 caseResult10 = step1Result
2287 utilities.assert_equals( expect=main.TRUE, actual=caseResult10,
kelvin-onlab8a832582015-01-16 17:06:11 -08002288 onpass="Intent removal test successful",
2289 onfail="Intent removal test failed" )
Hari Krishna22c3d412015-02-17 16:48:12 -08002290
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07002291 def CASE12( self, main ):
Hari Krishna22c3d412015-02-17 16:48:12 -08002292 """
2293 Enable onos-app-ifwd, Verify Intent based Reactive forwarding through ping all and Disable it
2294 """
2295 import re
2296 import copy
2297 import time
2298
kelvin-onlab54400a92015-02-26 18:05:51 -08002299 Thread = imp.load_source('Thread','/home/admin/ONLabTest/TestON/tests/OnosCHO/Thread.py')
2300 threadID = 0
2301
Hari Krishna22c3d412015-02-17 16:48:12 -08002302 main.log.report( "Enable Intent based Reactive forwarding and Verify ping all" )
2303 main.log.report( "_____________________________________________________" )
2304 main.case( "Enable Intent based Reactive forwarding and Verify ping all" )
2305 main.step( "Enable intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08002306 installResult = main.FALSE
2307 feature = "onos-app-ifwd"
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002308
kelvin-onlab54400a92015-02-26 18:05:51 -08002309 pool = []
2310 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002311 for cli,feature in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -08002312 t = main.Thread(target=cli,threadID=threadID,
2313 name="featureInstall",args=[feature])
2314 pool.append(t)
2315 t.start()
2316 threadID = threadID + 1
2317
2318 results = []
2319 for thread in pool:
2320 thread.join()
2321 results.append(thread.result)
2322 time2 = time.time()
2323
2324 if( all(result == main.TRUE for result in results) == False):
2325 main.log.info("Did not install onos-app-ifwd feature properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -07002326 #main.cleanup()
2327 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -08002328 else:
2329 main.log.info("Successful feature:install onos-app-ifwd")
2330 installResult = main.TRUE
2331 main.log.info("Time for feature:install onos-app-ifwd: %2f seconds" %(time2-time1))
2332
Hari Krishna22c3d412015-02-17 16:48:12 -08002333 main.step( "Verify Pingall" )
2334 ping_result = main.FALSE
2335 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -08002336 ping_result = main.Mininet1.pingall(timeout=600)
Hari Krishna22c3d412015-02-17 16:48:12 -08002337 time2 = time.time()
2338 timeDiff = round( ( time2 - time1 ), 2 )
2339 main.log.report(
2340 "Time taken for Ping All: " +
2341 str( timeDiff ) +
2342 " seconds" )
kelvin-onlab54400a92015-02-26 18:05:51 -08002343
Hari Krishna22c3d412015-02-17 16:48:12 -08002344 if ping_result == main.TRUE:
2345 main.log.report( "Pingall Test in Reactive mode successful" )
2346 else:
2347 main.log.report( "Pingall Test in Reactive mode failed" )
2348
2349 main.step( "Disable Intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08002350 uninstallResult = main.FALSE
2351
kelvin-onlab54400a92015-02-26 18:05:51 -08002352 pool = []
2353 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002354 for cli,feature in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -08002355 t = main.Thread(target=cli,threadID=threadID,
2356 name="featureUninstall",args=[feature])
2357 pool.append(t)
2358 t.start()
2359 threadID = threadID + 1
2360
2361 results = []
2362 for thread in pool:
2363 thread.join()
2364 results.append(thread.result)
2365 time2 = time.time()
2366
2367 if( all(result == main.TRUE for result in results) == False):
2368 main.log.info("Did not uninstall onos-app-ifwd feature properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -07002369 uninstallResult = main.FALSE
2370 #main.cleanup()
2371 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -08002372 else:
2373 main.log.info("Successful feature:uninstall onos-app-ifwd")
2374 uninstallResult = main.TRUE
2375 main.log.info("Time for feature:uninstall onos-app-ifwd: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -08002376
2377 # Waiting for reative flows to be cleared.
2378 time.sleep( 10 )
2379
2380 case11Result = installResult and ping_result and uninstallResult
2381 utilities.assert_equals( expect=main.TRUE, actual=case11Result,
2382 onpass="Intent based Reactive forwarding Pingall test PASS",
2383 onfail="Intent based Reactive forwarding Pingall test FAIL" )
2384
Hari Krishnab35c6d02015-03-18 11:13:51 -07002385 def CASE99(self):
2386 import time
2387 # WORK AROUND FOR ONOS-581. STOP ONOS BEFORE ASSIGNING CONTROLLERS AT MININET & START ONCE DONE
2388 main.step( "Stop ONOS on all Nodes" )
2389 stopResult = main.TRUE
2390 for i in range( 1, int( main.numCtrls ) + 1 ):
2391 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
2392 main.log.info( "Stopping ONOS Node IP: " + ONOS_ip )
2393 sresult = main.ONOSbench.onosStop( ONOS_ip )
2394 utilities.assert_equals( expect=main.TRUE, actual=sresult,
2395 onpass="Test step PASS",
2396 onfail="Test step FAIL" )
2397 stopResult = ( stopResult and sresult )
2398
2399 main.step( "Start ONOS on all Nodes" )
2400 startResult = main.TRUE
2401 for i in range( 1, int( main.numCtrls ) + 1 ):
2402 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
2403 main.log.info( "Starting ONOS Node IP: " + ONOS_ip )
2404 sresult = main.ONOSbench.onosStart( ONOS_ip )
2405 utilities.assert_equals( expect=main.TRUE, actual=sresult,
2406 onpass="Test step PASS",
2407 onfail="Test step FAIL" )
2408 startResult = ( startResult and sresult )
2409
2410 main.step( "Start ONOS CLI on all nodes" )
2411 cliResult = main.TRUE
2412 time.sleep( 30 )
2413 main.log.step(" Start ONOS cli using thread ")
2414 pool = []
2415 time1 = time.time()
2416 for i in range( int( main.numCtrls ) ):
2417 t = main.Thread(target=main.CLIs[i].startOnosCli,
2418 threadID=main.threadID,
2419 name="startOnosCli",
2420 args=[main.nodes[i].ip_address])
2421 pool.append(t)
2422 t.start()
2423 main.threadID = main.threadID + 1
2424 for t in pool:
2425 t.join()
2426 cliResult = cliResult and t.result
2427 time2 = time.time()
2428
2429 if not cliResult:
2430 main.log.info("ONOS CLI did not start up properly")
2431 #main.cleanup()
2432 #main.exit()
2433 else:
2434 main.log.info("Successful CLI startup")
2435 main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
2436
2437 case99Result = ( startResult and cliResult )
2438 time.sleep(30)
2439 utilities.assert_equals(
2440 expect=main.TRUE,
2441 actual=case99Result,
2442 onpass="Starting new Chordal topology test PASS",
2443 onfail="Starting new Chordal topology test FAIL" )
2444
2445
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002446
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002447
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07002448