blob: 27aa4508826a7b949bfd5b87353236a3bd98e5ba [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" )
kelvin-onlab9d8bf3d2015-07-06 10:49:38 -0700195 onosIps = []
196 onosPort = []
197 onosIps.append( ONOS1_ip )
198 onosIps.append( ONOS2_ip )
199 onosIps.append( ONOS3_ip )
200 onosPort.append( ONOS1_port )
201 onosPort.append( ONOS2_port )
202 onosPort.append( ONOS3_port )
203
Hari Krishna22c3d412015-02-17 16:48:12 -0800204 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
Hari Krishnad97213e2015-01-24 19:30:14 -0800205 main.Mininet1.assignSwController(
kelvin-onlab9d8bf3d2015-07-06 10:49:38 -0700206 sw="s" + str( i ),
Hari Krishna0ce0e152015-06-23 09:55:29 -0700207 count=int( main.numCtrls ),
kelvin-onlab9d8bf3d2015-07-06 10:49:38 -0700208 ip=onosIps,
209 port=onosPort )
Hari Krishna0ce0e152015-06-23 09:55:29 -0700210
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800211 switch_mastership = main.TRUE
Hari Krishna22c3d412015-02-17 16:48:12 -0800212 for i in range( 1, ( main.numMNswitches + 1 ) ):
Hari Krishnad97213e2015-01-24 19:30:14 -0800213 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800214 print( "Response is " + str( response ) )
Hari Krishna22c3d412015-02-17 16:48:12 -0800215 if re.search( "tcp:" + main.ONOS1_ip, response ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800216 switch_mastership = switch_mastership and main.TRUE
217 else:
218 switch_mastership = main.FALSE
219
220 if switch_mastership == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800221 main.log.report( "Controller assignment successfull" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800222 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800223 main.log.report( "Controller assignment failed" )
kelvin-onlab77d6c302015-03-31 11:33:32 -0700224
225 """topoFailed = main.FALSE
226 checkCount = 0
227 while(topoFailed == main.FALSE):
228 topology_output = main.ONOScli1.topology()
229 topology_result = main.ONOSbench.getTopology( topology_output )
230 numOnosDevices = topology_result[ 'deviceCount' ]
231 numOnosLinks = topology_result[ 'linkCount' ]
232 if ( ( main.numMNswitches == int(numOnosDevices) ) and ( main.numMNlinks >= int(numOnosLinks) ) ):
233 main.log.info("Att topology is now ready!")
234 break
235 else:
236 main.log.info("Att topology is not ready yet!")
237 checkCount = checkCount + 1
238 time.sleep(2)
239 if checkCount == 10:
240 topoFailed = main.TRUE
241 if topoFailed:
242 main.log.info("Att topology failed to start correctly")
Hari Krishnab35c6d02015-03-18 11:13:51 -0700243 """
Hari Krishna0ce0e152015-06-23 09:55:29 -0700244 time.sleep(45)
kelvin-onlab77d6c302015-03-31 11:33:32 -0700245 #Don't balance master for now..
Hari Krishna0ce0e152015-06-23 09:55:29 -0700246 main.step( "Balance devices across controllers" )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700247 for i in range( int( main.numCtrls ) ):
248 balanceResult = main.ONOScli1.balanceMasters()
kelvin-onlab8a832582015-01-16 17:06:11 -0800249 # giving some breathing time for ONOS to complete re-balance
Hari Krishna0ce0e152015-06-23 09:55:29 -0700250 time.sleep( 5 )
kelvin-onlab77d6c302015-03-31 11:33:32 -0700251 topology_output = main.ONOScli1.topology()
252 topology_result = main.ONOSbench.getTopology( topology_output )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700253 case2Result = ( switch_mastership and startStatus )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700254 utilities.assert_equals(
255 expect=main.TRUE,
256 actual=case2Result,
257 onpass="Starting new Att topology test PASS",
258 onfail="Starting new Att topology test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800259
kelvin-onlab65a72d22015-03-26 13:46:32 -0700260 def CASE21( self, main ):
261 """
262 This test script Loads a new Topology (Chordal) on CHO setup and balances all switches
263 """
264 import re
265 import time
266 import copy
267
268 main.newTopo = main.params['TOPO2']['topo']
269 main.numMNswitches = int ( main.params[ 'TOPO2' ][ 'numSwitches' ] )
270 main.numMNlinks = int ( main.params[ 'TOPO2' ][ 'numLinks' ] )
271 main.numMNhosts = int ( main.params[ 'TOPO2' ][ 'numHosts' ] )
Hari Krishna0ce0e152015-06-23 09:55:29 -0700272 main.pingTimeout = 300
kelvin-onlab65a72d22015-03-26 13:46:32 -0700273 main.log.report(
274 "Load Chordal topology and Balance all Mininet switches across controllers" )
275 main.log.report(
276 "________________________________________________________________________" )
277 main.case(
278 "Assign and Balance all Mininet switches across controllers" )
279 main.step( "Stop any previous Mininet network topology" )
Hari Krishna0ce0e152015-06-23 09:55:29 -0700280 stopStatus = main.Mininet1.stopNet(fileName = "topoAtt" )
281 time.sleep(10)
kelvin-onlab65a72d22015-03-26 13:46:32 -0700282 main.step( "Start Mininet with Chordal topology" )
283 startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
284 time.sleep(15)
285 main.step( "Assign switches to controllers" )
kelvin-onlab9d8bf3d2015-07-06 10:49:38 -0700286 onosIps = []
287 onosPort = []
288 onosIps.append( ONOS1_ip )
289 onosIps.append( ONOS2_ip )
290 onosIps.append( ONOS3_ip )
291 onosPort.append( ONOS1_port )
292 onosPort.append( ONOS2_port )
293 onosPort.append( ONOS3_port )
294
kelvin-onlab65a72d22015-03-26 13:46:32 -0700295 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
296 main.Mininet1.assignSwController(
kelvin-onlab9d8bf3d2015-07-06 10:49:38 -0700297 sw="s" + str( i ),
kelvin-onlab65a72d22015-03-26 13:46:32 -0700298 count=int( main.numCtrls ),
kelvin-onlab9d8bf3d2015-07-06 10:49:38 -0700299 ip=onosIps,
300 port=onosPort )
kelvin-onlab65a72d22015-03-26 13:46:32 -0700301
302 switch_mastership = main.TRUE
303 for i in range( 1, ( main.numMNswitches + 1 ) ):
304 response = main.Mininet1.getSwController( "s" + str( i ) )
305 print( "Response is " + str( response ) )
306 if re.search( "tcp:" + main.ONOS1_ip, response ):
307 switch_mastership = switch_mastership and main.TRUE
308 else:
309 switch_mastership = main.FALSE
310
311 if switch_mastership == main.TRUE:
312 main.log.report( "Controller assignment successfull" )
313 else:
314 main.log.report( "Controller assignment failed" )
315 time.sleep( 5 )
316
kelvin-onlab65a72d22015-03-26 13:46:32 -0700317 main.step( "Balance devices across controllers" )
318 for i in range( int( main.numCtrls ) ):
319 balanceResult = main.ONOScli1.balanceMasters()
320 # giving some breathing time for ONOS to complete re-balance
321 time.sleep( 3 )
Hari Krishna0ce0e152015-06-23 09:55:29 -0700322
kelvin-onlab65a72d22015-03-26 13:46:32 -0700323 case21Result = switch_mastership
324 time.sleep(30)
325 utilities.assert_equals(
326 expect=main.TRUE,
327 actual=case21Result,
328 onpass="Starting new Chordal topology test PASS",
329 onfail="Starting new Chordal topology test FAIL" )
330
331 def CASE22( self, main ):
332 """
333 This test script Loads a new Topology (Spine) on CHO setup and balances all switches
334 """
335 import re
336 import time
337 import copy
338
339 main.newTopo = main.params['TOPO3']['topo']
340 main.numMNswitches = int ( main.params[ 'TOPO3' ][ 'numSwitches' ] )
341 main.numMNlinks = int ( main.params[ 'TOPO3' ][ 'numLinks' ] )
342 main.numMNhosts = int ( main.params[ 'TOPO3' ][ 'numHosts' ] )
Hari Krishna0ce0e152015-06-23 09:55:29 -0700343 main.pingTimeout = 600
kelvin-onlab65a72d22015-03-26 13:46:32 -0700344
345 main.log.report(
346 "Load Spine and Leaf topology and Balance all Mininet switches across controllers" )
347 main.log.report(
348 "________________________________________________________________________" )
349 # need to wait here for sometime until ONOS bootup
350 main.case(
351 "Assign and Balance all Mininet switches across controllers" )
352 main.step( "Stop any previous Mininet network topology" )
Hari Krishna0ce0e152015-06-23 09:55:29 -0700353 stopStatus = main.Mininet1.stopNet(fileName = "topoChordal" )
kelvin-onlab65a72d22015-03-26 13:46:32 -0700354 main.step( "Start Mininet with Spine topology" )
355 startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
Hari Krishna0ce0e152015-06-23 09:55:29 -0700356 time.sleep(60)
kelvin-onlab65a72d22015-03-26 13:46:32 -0700357 main.step( "Assign switches to controllers" )
kelvin-onlab9d8bf3d2015-07-06 10:49:38 -0700358 onosIps = []
359 onosPort = []
360 onosIps.append( ONOS1_ip )
361 onosIps.append( ONOS2_ip )
362 onosIps.append( ONOS3_ip )
363 onosPort.append( ONOS1_port )
364 onosPort.append( ONOS2_port )
365 onosPort.append( ONOS3_port )
366
kelvin-onlab65a72d22015-03-26 13:46:32 -0700367 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
368 main.Mininet1.assignSwController(
kelvin-onlab9d8bf3d2015-07-06 10:49:38 -0700369 sw="s" + str( i ),
370 count=int( main.numCtrls ),
371 ip=onosIps,
372 port=onosPort )
kelvin-onlab65a72d22015-03-26 13:46:32 -0700373
374 switch_mastership = main.TRUE
375 for i in range( 1, ( main.numMNswitches + 1 ) ):
376 response = main.Mininet1.getSwController( "s" + str( i ) )
377 print( "Response is " + str( response ) )
378 if re.search( "tcp:" + main.ONOS1_ip, response ):
379 switch_mastership = switch_mastership and main.TRUE
380 else:
381 switch_mastership = main.FALSE
382
383 if switch_mastership == main.TRUE:
384 main.log.report( "Controller assignment successfull" )
385 else:
386 main.log.report( "Controller assignment failed" )
387 time.sleep( 5 )
kelvin-onlab65a72d22015-03-26 13:46:32 -0700388
389 main.step( "Balance devices across controllers" )
390 for i in range( int( main.numCtrls ) ):
391 balanceResult = main.ONOScli1.balanceMasters()
392 # giving some breathing time for ONOS to complete re-balance
393 time.sleep( 3 )
Hari Krishna0ce0e152015-06-23 09:55:29 -0700394
kelvin-onlab65a72d22015-03-26 13:46:32 -0700395 case22Result = switch_mastership
Hari Krishna0ce0e152015-06-23 09:55:29 -0700396 time.sleep(60)
kelvin-onlab65a72d22015-03-26 13:46:32 -0700397 utilities.assert_equals(
398 expect=main.TRUE,
399 actual=case22Result,
400 onpass="Starting new Spine topology test PASS",
401 onfail="Starting new Spine topology test FAIL" )
402
kelvin-onlab8a832582015-01-16 17:06:11 -0800403 def CASE3( self, main ):
404 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800405 This Test case will be extended to collect and store more data related
406 ONOS state.
kelvin-onlab8a832582015-01-16 17:06:11 -0800407 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800408 import re
409 import copy
Hari Krishna22c3d412015-02-17 16:48:12 -0800410 main.deviceDPIDs = []
411 main.hostMACs = []
412 main.deviceLinks = []
413 main.deviceActiveLinksCount = []
414 main.devicePortsEnabledCount = []
kelvin-onlab54400a92015-02-26 18:05:51 -0800415
kelvin-onlab8a832582015-01-16 17:06:11 -0800416 main.log.report(
417 "Collect and Store topology details from ONOS before running any Tests" )
418 main.log.report(
419 "____________________________________________________________________" )
Hari Krishna5afb4cc2015-03-23 15:35:15 -0700420 main.case( "Collect and Store Topology Details from ONOS" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800421 main.step( "Collect and store current number of switches and links" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800422 topology_output = main.ONOScli1.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800423 topology_result = main.ONOSbench.getTopology( topology_output )
Hari Krishna0ce0e152015-06-23 09:55:29 -0700424 numOnosDevices = topology_result[ 'devices' ]
425 numOnosLinks = topology_result[ 'links' ]
Hari Krishnab35c6d02015-03-18 11:13:51 -0700426 topoResult = main.TRUE
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800427
kelvin-onlab54400a92015-02-26 18:05:51 -0800428 if ( ( main.numMNswitches == int(numOnosDevices) ) and ( main.numMNlinks >= int(numOnosLinks) ) ):
Hari Krishna22c3d412015-02-17 16:48:12 -0800429 main.step( "Store Device DPIDs" )
430 for i in range( 1, (main.numMNswitches+1) ):
431 main.deviceDPIDs.append( "of:00000000000000" + format( i, '02x' ) )
432 print "Device DPIDs in Store: \n", str( main.deviceDPIDs )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800433
Hari Krishna22c3d412015-02-17 16:48:12 -0800434 main.step( "Store Host MACs" )
435 for i in range( 1, ( main.numMNhosts + 1 ) ):
436 main.hostMACs.append( "00:00:00:00:00:" + format( i, '02x' ) + "/-1" )
437 print "Host MACs in Store: \n", str( main.hostMACs )
Hari Krishna5afb4cc2015-03-23 15:35:15 -0700438 main.MACsDict = {}
kelvin-onlab65a72d22015-03-26 13:46:32 -0700439 print "Creating dictionary of DPID and HostMacs"
440 for i in range(len(main.hostMACs)):
Hari Krishna5afb4cc2015-03-23 15:35:15 -0700441 main.MACsDict[main.deviceDPIDs[i]] = main.hostMACs[i].split('/')[0]
442 print main.MACsDict
Hari Krishna22c3d412015-02-17 16:48:12 -0800443 main.step( "Collect and store all Devices Links" )
444 linksResult = main.ONOScli1.links( jsonFormat=False )
445 ansi_escape = re.compile( r'\x1b[^m]*m' )
446 linksResult = ansi_escape.sub( '', linksResult )
447 linksResult = linksResult.replace( " links", "" ).replace( "\r\r", "" )
448 linksResult = linksResult.splitlines()
Hari Krishna22c3d412015-02-17 16:48:12 -0800449 main.deviceLinks = copy.copy( linksResult )
450 print "Device Links Stored: \n", str( main.deviceLinks )
451 # this will be asserted to check with the params provided count of
452 # links
453 print "Length of Links Store", len( main.deviceLinks )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800454
Hari Krishna22c3d412015-02-17 16:48:12 -0800455 main.step( "Collect and store each Device ports enabled Count" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800456 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800457 for i in xrange(1,(main.numMNswitches + 1), int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800458 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800459 for cli in main.CLIs:
kelvin-onlabc44f0192015-04-02 22:08:41 -0700460 if i >= main.numMNswitches + 1:
kelvin-onlabfbcd82f2015-04-02 12:06:00 -0700461 break
kelvin-onlab54400a92015-02-26 18:05:51 -0800462 dpid = "of:00000000000000" + format( i,'02x' )
463 t = main.Thread(target = cli.getDevicePortsEnabledCount,threadID = main.threadID, name = "getDevicePortsEnabledCount",args = [dpid])
464 t.start()
465 pool.append(t)
466 i = i + 1
467 main.threadID = main.threadID + 1
468 for thread in pool:
469 thread.join()
470 portResult = thread.result
Hari Krishna0ce0e152015-06-23 09:55:29 -0700471 #portCount = re.split( r'\t+', portResult )
472 #portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
473 main.devicePortsEnabledCount.append( portResult )
Hari Krishna22c3d412015-02-17 16:48:12 -0800474 print "Device Enabled Port Counts Stored: \n", str( main.devicePortsEnabledCount )
kelvin-onlab54400a92015-02-26 18:05:51 -0800475 time2 = time.time()
476 main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1))
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800477
Hari Krishna22c3d412015-02-17 16:48:12 -0800478 main.step( "Collect and store each Device active links Count" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800479 time1 = time.time()
480
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800481 for i in xrange( 1,( main.numMNswitches + 1 ), int( main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800482 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800483 for cli in main.CLIs:
kelvin-onlabc44f0192015-04-02 22:08:41 -0700484 if i >= main.numMNswitches + 1:
kelvin-onlabfbcd82f2015-04-02 12:06:00 -0700485 break
kelvin-onlab54400a92015-02-26 18:05:51 -0800486 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800487 t = main.Thread( target = cli.getDeviceLinksActiveCount,
488 threadID = main.threadID,
489 name = "getDevicePortsEnabledCount",
490 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800491 t.start()
492 pool.append(t)
493 i = i + 1
494 main.threadID = main.threadID + 1
495 for thread in pool:
496 thread.join()
497 linkCountResult = thread.result
Hari Krishna0ce0e152015-06-23 09:55:29 -0700498 #linkCount = re.split( r'\t+', linkCountResult )
499 #linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
500 main.deviceActiveLinksCount.append( linkCountResult )
kelvin-onlabfbcd82f2015-04-02 12:06:00 -0700501 print "Device Active Links Count Stored: \n", str( main.deviceActiveLinksCount )
kelvin-onlab54400a92015-02-26 18:05:51 -0800502 time2 = time.time()
503 main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800504
505 else:
506 main.log.info("Devices (expected): %s, Links (expected): %s" %
507 ( str( main.numMNswitches ), str( main.numMNlinks ) ) )
508 main.log.info("Devices (actual): %s, Links (actual): %s" %
509 ( numOnosDevices , numOnosLinks ) )
510 main.log.info("Topology does not match, exiting CHO test...")
Hari Krishnab35c6d02015-03-18 11:13:51 -0700511 topoResult = main.FALSE
Hari Krishnaade11a72015-07-01 17:06:46 -0700512 # It's better exit here from running the test
513 main.cleanup()
514 main.exit()
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800515
kelvin-onlab8a832582015-01-16 17:06:11 -0800516 # just returning TRUE for now as this one just collects data
Hari Krishnab35c6d02015-03-18 11:13:51 -0700517 case3Result = topoResult
Hari Krishna22c3d412015-02-17 16:48:12 -0800518 utilities.assert_equals( expect=main.TRUE, actual=case3Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800519 onpass="Saving ONOS topology data test PASS",
520 onfail="Saving ONOS topology data test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800521
kelvin-onlab65a72d22015-03-26 13:46:32 -0700522 def CASE40( self, main ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800523 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700524 Verify Reactive forwarding (Att Topology)
kelvin-onlab8a832582015-01-16 17:06:11 -0800525 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800526 import re
527 import copy
528 import time
Hari Krishnab35c6d02015-03-18 11:13:51 -0700529 main.log.report( "Verify Reactive forwarding (Att Topology)" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800530 main.log.report( "______________________________________________" )
531 main.case( "Enable Reactive forwarding and Verify ping all" )
532 main.step( "Enable Reactive forwarding" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800533 installResult = main.TRUE
kelvin-onlab06ade552015-03-31 18:09:27 -0700534 # Activate fwd app
535 appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700536 appCheck = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800537 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800538 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700539 t = main.Thread( target=cli.appToIDCheck,
540 name="appToIDCheck-" + str( i ),
541 args=[] )
542 pool.append( t )
kelvin-onlab54400a92015-02-26 18:05:51 -0800543 t.start()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800544 for t in pool:
545 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700546 appCheck = appCheck and t.result
547 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
548 onpass="App Ids seem to be correct",
549 onfail="Something is wrong with app Ids" )
550 if appCheck != main.TRUE:
551 main.log.warn( main.CLIs[0].apps() )
552 main.log.warn( main.CLIs[0].appIDs() )
553
554 time.sleep( 10 )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800555
kelvin-onlab8a832582015-01-16 17:06:11 -0800556 main.step( "Verify Pingall" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800557 ping_result = main.FALSE
558 time1 = time.time()
kelvin-onlab4df89f22015-04-13 18:10:23 -0700559 ping_result = main.Mininet1.pingall( timeout=main.pingTimeout )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800560 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800561 timeDiff = round( ( time2 - time1 ), 2 )
562 main.log.report(
563 "Time taken for Ping All: " +
564 str( timeDiff ) +
565 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800566
567 if ping_result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800568 main.log.report( "Pingall Test in Reactive mode successful" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800569 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800570 main.log.report( "Pingall Test in Reactive mode failed" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800571
kelvin-onlab8a832582015-01-16 17:06:11 -0800572 main.step( "Disable Reactive forwarding" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700573
574 main.log.info( "Uninstall reactive forwarding app" )
575 appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800576 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800577 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700578 t = main.Thread( target=cli.appToIDCheck,
579 name="appToIDCheck-" + str( i ),
580 args=[] )
581 pool.append( t )
kelvin-onlab54400a92015-02-26 18:05:51 -0800582 t.start()
kelvin-onlab06ade552015-03-31 18:09:27 -0700583
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800584 for t in pool:
585 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700586 appCheck = appCheck and t.result
587 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
588 onpass="App Ids seem to be correct",
589 onfail="Something is wrong with app Ids" )
590 if appCheck != main.TRUE:
591 main.log.warn( main.CLIs[0].apps() )
592 main.log.warn( main.CLIs[0].appIDs() )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800593
kelvin-onlab8a832582015-01-16 17:06:11 -0800594 # Waiting for reative flows to be cleared.
Hari Krishna0ce0e152015-06-23 09:55:29 -0700595 time.sleep( 30 )
kelvin-onlab06ade552015-03-31 18:09:27 -0700596 case40Result = installResult and uninstallResult and ping_result
597 utilities.assert_equals( expect=main.TRUE, actual=case40Result,
Hari Krishnab35c6d02015-03-18 11:13:51 -0700598 onpass="Reactive Mode Pingall test PASS",
599 onfail="Reactive Mode Pingall test FAIL" )
600
601 def CASE41( self, main ):
602 """
603 Verify Reactive forwarding (Chordal Topology)
604 """
605 import re
606 import copy
607 import time
608 main.log.report( "Verify Reactive forwarding (Chordal Topology)" )
609 main.log.report( "______________________________________________" )
610 main.case( "Enable Reactive forwarding and Verify ping all" )
611 main.step( "Enable Reactive forwarding" )
612 installResult = main.TRUE
kelvin-onlab06ade552015-03-31 18:09:27 -0700613 # Activate fwd app
614 appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" )
615
616 appCheck = main.TRUE
Hari Krishnab35c6d02015-03-18 11:13:51 -0700617 pool = []
Hari Krishnab35c6d02015-03-18 11:13:51 -0700618 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700619 t = main.Thread( target=cli.appToIDCheck,
620 name="appToIDCheck-" + str( i ),
621 args=[] )
622 pool.append( t )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700623 t.start()
Hari Krishnab35c6d02015-03-18 11:13:51 -0700624 for t in pool:
625 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700626 appCheck = appCheck and t.result
627 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
628 onpass="App Ids seem to be correct",
629 onfail="Something is wrong with app Ids" )
630 if appCheck != main.TRUE:
631 main.log.warn( main.CLIs[0].apps() )
632 main.log.warn( main.CLIs[0].appIDs() )
633
634 time.sleep( 10 )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700635
636 main.step( "Verify Pingall" )
637 ping_result = main.FALSE
638 time1 = time.time()
kelvin-onlab4df89f22015-04-13 18:10:23 -0700639 ping_result = main.Mininet1.pingall( timeout=main.pingTimeout )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700640 time2 = time.time()
641 timeDiff = round( ( time2 - time1 ), 2 )
642 main.log.report(
643 "Time taken for Ping All: " +
644 str( timeDiff ) +
645 " seconds" )
646
647 if ping_result == main.TRUE:
648 main.log.report( "Pingall Test in Reactive mode successful" )
649 else:
650 main.log.report( "Pingall Test in Reactive mode failed" )
651
652 main.step( "Disable Reactive forwarding" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700653
654 main.log.info( "Uninstall reactive forwarding app" )
655 appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700656 pool = []
Hari Krishnab35c6d02015-03-18 11:13:51 -0700657 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700658 t = main.Thread( target=cli.appToIDCheck,
659 name="appToIDCheck-" + str( i ),
660 args=[] )
661 pool.append( t )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700662 t.start()
kelvin-onlab06ade552015-03-31 18:09:27 -0700663
Hari Krishnab35c6d02015-03-18 11:13:51 -0700664 for t in pool:
665 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700666 appCheck = appCheck and t.result
667 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
668 onpass="App Ids seem to be correct",
669 onfail="Something is wrong with app Ids" )
670 if appCheck != main.TRUE:
671 main.log.warn( main.CLIs[0].apps() )
672 main.log.warn( main.CLIs[0].appIDs() )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700673
674 # Waiting for reative flows to be cleared.
Hari Krishna0ce0e152015-06-23 09:55:29 -0700675 time.sleep( 30 )
kelvin-onlab06ade552015-03-31 18:09:27 -0700676 case41Result = installResult and uninstallResult and ping_result
677 utilities.assert_equals( expect=main.TRUE, actual=case41Result,
Hari Krishnab35c6d02015-03-18 11:13:51 -0700678 onpass="Reactive Mode Pingall test PASS",
679 onfail="Reactive Mode Pingall test FAIL" )
680
681 def CASE42( self, main ):
682 """
683 Verify Reactive forwarding (Spine Topology)
684 """
685 import re
686 import copy
687 import time
688 main.log.report( "Verify Reactive forwarding (Spine Topology)" )
689 main.log.report( "______________________________________________" )
690 main.case( "Enable Reactive forwarding and Verify ping all" )
691 main.step( "Enable Reactive forwarding" )
692 installResult = main.TRUE
kelvin-onlab06ade552015-03-31 18:09:27 -0700693 # Activate fwd app
694 appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" )
695
696 appCheck = main.TRUE
Hari Krishnab35c6d02015-03-18 11:13:51 -0700697 pool = []
Hari Krishnab35c6d02015-03-18 11:13:51 -0700698 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700699 t = main.Thread( target=cli.appToIDCheck,
700 name="appToIDCheck-" + str( i ),
701 args=[] )
702 pool.append( t )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700703 t.start()
Hari Krishnab35c6d02015-03-18 11:13:51 -0700704 for t in pool:
705 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700706 appCheck = appCheck and t.result
707 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
708 onpass="App Ids seem to be correct",
709 onfail="Something is wrong with app Ids" )
710 if appCheck != main.TRUE:
711 main.log.warn( main.CLIs[0].apps() )
712 main.log.warn( main.CLIs[0].appIDs() )
713
714 time.sleep( 10 )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700715
716 main.step( "Verify Pingall" )
717 ping_result = main.FALSE
718 time1 = time.time()
kelvin-onlab4df89f22015-04-13 18:10:23 -0700719 ping_result = main.Mininet1.pingall( timeout=main.pingTimeout )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700720 time2 = time.time()
721 timeDiff = round( ( time2 - time1 ), 2 )
722 main.log.report(
723 "Time taken for Ping All: " +
724 str( timeDiff ) +
725 " seconds" )
726
727 if ping_result == main.TRUE:
728 main.log.report( "Pingall Test in Reactive mode successful" )
729 else:
730 main.log.report( "Pingall Test in Reactive mode failed" )
731
732 main.step( "Disable Reactive forwarding" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700733
734 main.log.info( "Uninstall reactive forwarding app" )
735 appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700736 pool = []
Hari Krishnab35c6d02015-03-18 11:13:51 -0700737 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700738 t = main.Thread( target=cli.appToIDCheck,
739 name="appToIDCheck-" + str( i ),
740 args=[] )
741 pool.append( t )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700742 t.start()
kelvin-onlab06ade552015-03-31 18:09:27 -0700743
Hari Krishnab35c6d02015-03-18 11:13:51 -0700744 for t in pool:
745 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700746 appCheck = appCheck and t.result
747 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
748 onpass="App Ids seem to be correct",
749 onfail="Something is wrong with app Ids" )
750 if appCheck != main.TRUE:
751 main.log.warn( main.CLIs[0].apps() )
752 main.log.warn( main.CLIs[0].appIDs() )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700753
754 # Waiting for reative flows to be cleared.
Hari Krishna0ce0e152015-06-23 09:55:29 -0700755 time.sleep( 30 )
kelvin-onlab06ade552015-03-31 18:09:27 -0700756 case42Result = installResult and uninstallResult and ping_result
757 utilities.assert_equals( expect=main.TRUE, actual=case42Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800758 onpass="Reactive Mode Pingall test PASS",
759 onfail="Reactive Mode Pingall test FAIL" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700760
kelvin-onlab8a832582015-01-16 17:06:11 -0800761 def CASE5( self, main ):
762 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800763 Compare current ONOS topology with reference data
kelvin-onlab8a832582015-01-16 17:06:11 -0800764 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800765 import re
kelvin-onlab54400a92015-02-26 18:05:51 -0800766
Hari Krishna22c3d412015-02-17 16:48:12 -0800767 devicesDPIDTemp = []
768 hostMACsTemp = []
769 deviceLinksTemp = []
770 deviceActiveLinksCountTemp = []
771 devicePortsEnabledCountTemp = []
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800772
kelvin-onlab8a832582015-01-16 17:06:11 -0800773 main.log.report(
774 "Compare ONOS topology with reference data in Stores" )
775 main.log.report( "__________________________________________________" )
776 main.case( "Compare ONOS topology with reference data" )
777
778 main.step( "Compare current Device ports enabled with reference" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800779 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800780 for i in xrange( 1,(main.numMNswitches + 1), int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800781 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800782 for cli in main.CLIs:
kelvin-onlabc44f0192015-04-02 22:08:41 -0700783 if i >= main.numMNswitches + 1:
784 break
kelvin-onlab54400a92015-02-26 18:05:51 -0800785 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800786 t = main.Thread(target = cli.getDevicePortsEnabledCount,
787 threadID = main.threadID,
788 name = "getDevicePortsEnabledCount",
789 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800790 t.start()
791 pool.append(t)
792 i = i + 1
793 main.threadID = main.threadID + 1
794 for thread in pool:
795 thread.join()
796 portResult = thread.result
Hari Krishna0ce0e152015-06-23 09:55:29 -0700797 #portTemp = re.split( r'\t+', portResult )
798 #portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
799 devicePortsEnabledCountTemp.append( portResult )
800
kelvin-onlab54400a92015-02-26 18:05:51 -0800801 time2 = time.time()
802 main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800803 main.log.info (
804 "Device Enabled ports EXPECTED: %s" %
805 str( main.devicePortsEnabledCount ) )
806 main.log.info (
807 "Device Enabled ports ACTUAL: %s" %
808 str( devicePortsEnabledCountTemp ) )
kelvin-onlab54400a92015-02-26 18:05:51 -0800809
Hari Krishna22c3d412015-02-17 16:48:12 -0800810 if ( cmp( main.devicePortsEnabledCount,
811 devicePortsEnabledCountTemp ) == 0 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800812 stepResult1 = main.TRUE
813 else:
814 stepResult1 = main.FALSE
815
kelvin-onlab8a832582015-01-16 17:06:11 -0800816 main.step( "Compare Device active links with reference" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800817 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800818 for i in xrange( 1, ( main.numMNswitches + 1) , int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800819 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800820 for cli in main.CLIs:
Hari Krishna0ce0e152015-06-23 09:55:29 -0700821 if i >= main.numMNswitches + 1:
822 break
kelvin-onlab54400a92015-02-26 18:05:51 -0800823 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800824 t = main.Thread(target = cli.getDeviceLinksActiveCount,
825 threadID = main.threadID,
Hari Krishna0ce0e152015-06-23 09:55:29 -0700826 name = "getDeviceLinksActiveCount",
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800827 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800828 t.start()
829 pool.append(t)
830 i = i + 1
831 main.threadID = main.threadID + 1
832 for thread in pool:
833 thread.join()
834 linkCountResult = thread.result
Hari Krishna0ce0e152015-06-23 09:55:29 -0700835 #linkCountTemp = re.split( r'\t+', linkCountResult )
836 #linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
837 deviceActiveLinksCountTemp.append( linkCountResult )
838
kelvin-onlab54400a92015-02-26 18:05:51 -0800839 time2 = time.time()
840 main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800841 main.log.info (
842 "Device Active links EXPECTED: %s" %
843 str( main.deviceActiveLinksCount ) )
844 main.log.info (
845 "Device Active links ACTUAL: %s" % str( deviceActiveLinksCountTemp ) )
846 if ( cmp( main.deviceActiveLinksCount, deviceActiveLinksCountTemp ) == 0 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800847 stepResult2 = main.TRUE
848 else:
849 stepResult2 = main.FALSE
850
kelvin-onlab8a832582015-01-16 17:06:11 -0800851 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800852 place holder for comparing devices, hosts, paths and intents if required.
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800853 Links and ports data would be incorrect with out devices anyways.
kelvin-onlab8a832582015-01-16 17:06:11 -0800854 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800855 case5Result = ( stepResult1 and stepResult2 )
856 utilities.assert_equals( expect=main.TRUE, actual=case5Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800857 onpass="Compare Topology test PASS",
858 onfail="Compare Topology test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800859
kelvin-onlab65a72d22015-03-26 13:46:32 -0700860 def CASE60( self ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800861 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700862 Install 300 host intents and verify ping all (Att Topology)
kelvin-onlab8a832582015-01-16 17:06:11 -0800863 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700864 main.log.report( "Add 300 host intents and verify pingall (Att Topology)" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800865 main.log.report( "_______________________________________" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800866 import itertools
Hari Krishnaef1bd4e2015-03-12 16:55:30 -0700867 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800868 main.case( "Install 300 host intents" )
869 main.step( "Add host Intents" )
870 intentResult = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800871 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800872
kelvin-onlab54400a92015-02-26 18:05:51 -0800873 intentIdList = []
874 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800875 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800876 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800877 for cli in main.CLIs:
878 if i >= len( hostCombos ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800879 break
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800880 t = main.Thread( target=cli.addHostIntent,
881 threadID=main.threadID,
kelvin-onlab54400a92015-02-26 18:05:51 -0800882 name="addHostIntent",
883 args=[hostCombos[i][0],hostCombos[i][1]])
884 pool.append(t)
885 t.start()
886 i = i + 1
887 main.threadID = main.threadID + 1
888 for thread in pool:
889 thread.join()
890 intentIdList.append(thread.result)
891 time2 = time.time()
kelvin-onlabadfc8db2015-03-24 15:52:48 -0700892 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
893
kelvin-onlab54400a92015-02-26 18:05:51 -0800894 intentResult = main.TRUE
895 intentsJson = main.ONOScli2.intents()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800896 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
kelvin-onlab54400a92015-02-26 18:05:51 -0800897 intentsJson = intentsJson)
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -0700898 print "len of intent ID", str(len(intentIdList))
899 print "len of intent state results", str(len(getIntentStateResult))
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800900 print getIntentStateResult
Hari Krishnab35c6d02015-03-18 11:13:51 -0700901 # Takes awhile for all the onos to get the intents
Hari Krishna0ce0e152015-06-23 09:55:29 -0700902 time.sleep( 30 )
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -0700903 """intentState = main.TRUE
904 for i in getIntentStateResult:
905 if getIntentStateResult.get( 'state' ) != 'INSTALLED':
906 """
907
908
kelvin-onlab8a832582015-01-16 17:06:11 -0800909 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800910 pingResult = main.FALSE
911 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -0700912 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800913 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800914 timeDiff = round( ( time2 - time1 ), 2 )
915 main.log.report(
916 "Time taken for Ping All: " +
917 str( timeDiff ) +
918 " seconds" )
919 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
920 onpass="PING ALL PASS",
921 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800922
kelvin-onlab65a72d22015-03-26 13:46:32 -0700923 case60Result = ( intentResult and pingResult )
kelvin-onlab54400a92015-02-26 18:05:51 -0800924
kelvin-onlab8a832582015-01-16 17:06:11 -0800925 utilities.assert_equals(
926 expect=main.TRUE,
kelvin-onlab65a72d22015-03-26 13:46:32 -0700927 actual=case60Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800928 onpass="Install 300 Host Intents and Ping All test PASS",
929 onfail="Install 300 Host Intents and Ping All test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800930
kelvin-onlab65a72d22015-03-26 13:46:32 -0700931 def CASE61( self ):
932 """
933 Install 600 host intents and verify ping all for Chordal Topology
934 """
935 main.log.report( "Add 600 host intents and verify pingall (Chordal Topo)" )
936 main.log.report( "_______________________________________" )
937 import itertools
938
939 main.case( "Install 600 host intents" )
940 main.step( "Add host Intents" )
941 intentResult = main.TRUE
942 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
943
944 intentIdList = []
945 time1 = time.time()
946
947 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
948 pool = []
949 for cli in main.CLIs:
950 if i >= len( hostCombos ):
951 break
952 t = main.Thread( target=cli.addHostIntent,
953 threadID=main.threadID,
954 name="addHostIntent",
955 args=[hostCombos[i][0],hostCombos[i][1]])
956 pool.append(t)
957 t.start()
958 i = i + 1
959 main.threadID = main.threadID + 1
960 for thread in pool:
961 thread.join()
962 intentIdList.append(thread.result)
963 time2 = time.time()
964 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
965 intentResult = main.TRUE
966 intentsJson = main.ONOScli2.intents()
967 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
968 intentsJson = intentsJson)
969 print getIntentStateResult
970
971 main.step( "Verify Ping across all hosts" )
972 pingResult = main.FALSE
973 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -0700974 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlab65a72d22015-03-26 13:46:32 -0700975 time2 = time.time()
976 timeDiff = round( ( time2 - time1 ), 2 )
977 main.log.report(
978 "Time taken for Ping All: " +
979 str( timeDiff ) +
980 " seconds" )
981 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
982 onpass="PING ALL PASS",
983 onfail="PING ALL FAIL" )
984
985 case14Result = ( intentResult and pingResult )
986
987 utilities.assert_equals(
988 expect=main.TRUE,
989 actual=case14Result,
990 onpass="Install 300 Host Intents and Ping All test PASS",
991 onfail="Install 300 Host Intents and Ping All test FAIL" )
992
993 def CASE62( self ):
994 """
995 Install 2278 host intents and verify ping all for Spine Topology
996 """
997 main.log.report( "Add 2278 host intents and verify pingall (Spine Topo)" )
998 main.log.report( "_______________________________________" )
999 import itertools
1000
1001 main.case( "Install 2278 host intents" )
1002 main.step( "Add host Intents" )
1003 intentResult = main.TRUE
1004 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
1005 main.pingTimeout = 300
1006 intentIdList = []
1007 time1 = time.time()
1008 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
1009 pool = []
1010 for cli in main.CLIs:
1011 if i >= len( hostCombos ):
1012 break
1013 t = main.Thread( target=cli.addHostIntent,
1014 threadID=main.threadID,
1015 name="addHostIntent",
1016 args=[hostCombos[i][0],hostCombos[i][1]])
1017 pool.append(t)
1018 t.start()
1019 i = i + 1
1020 main.threadID = main.threadID + 1
1021 for thread in pool:
1022 thread.join()
1023 intentIdList.append(thread.result)
1024 time2 = time.time()
1025 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
1026 intentResult = main.TRUE
1027 intentsJson = main.ONOScli2.intents()
1028 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1029 intentsJson = intentsJson)
1030 print getIntentStateResult
1031
1032 main.step( "Verify Ping across all hosts" )
1033 pingResult = main.FALSE
1034 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001035 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlab65a72d22015-03-26 13:46:32 -07001036 time2 = time.time()
1037 timeDiff = round( ( time2 - time1 ), 2 )
1038 main.log.report(
1039 "Time taken for Ping All: " +
1040 str( timeDiff ) +
1041 " seconds" )
1042 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1043 onpass="PING ALL PASS",
1044 onfail="PING ALL FAIL" )
1045
1046 case15Result = ( intentResult and pingResult )
1047
1048 utilities.assert_equals(
1049 expect=main.TRUE,
1050 actual=case15Result,
1051 onpass="Install 2278 Host Intents and Ping All test PASS",
1052 onfail="Install 2278 Host Intents and Ping All test FAIL" )
1053
kelvin-onlab8a832582015-01-16 17:06:11 -08001054 def CASE70( self, main ):
1055 """
Hari Krishnab35c6d02015-03-18 11:13:51 -07001056 Randomly bring some core links down and verify ping all ( Host Intents-Att Topo)
kelvin-onlab8a832582015-01-16 17:06:11 -08001057 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001058 import random
Hari Krishna22c3d412015-02-17 16:48:12 -08001059 main.randomLink1 = []
1060 main.randomLink2 = []
1061 main.randomLink3 = []
kelvin-onlab65a72d22015-03-26 13:46:32 -07001062 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1063 link1End2 = main.params[ 'ATTCORELINKS' ][ 'linkS3b' ].split( ',' )
1064 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1065 link2End2 = main.params[ 'ATTCORELINKS' ][ 'linkS14b' ].split( ',' )
1066 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
1067 link3End2 = main.params[ 'ATTCORELINKS' ][ 'linkS18b' ].split( ',' )
1068 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001069 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001070
Hari Krishnab35c6d02015-03-18 11:13:51 -07001071 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Att Topo)" )
1072 main.log.report( "___________________________________________________________________________" )
Hari Krishnad97213e2015-01-24 19:30:14 -08001073 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
1074 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001075 if ( int( switchLinksToToggle ) ==
1076 0 or int( switchLinksToToggle ) > 5 ):
Hari Krishna46997e02015-01-27 11:23:07 -08001077 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 -07001078 #main.cleanup()
1079 #main.exit()
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001080 else:
Hari Krishnad97213e2015-01-24 19:30:14 -08001081 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 -08001082
kelvin-onlab8a832582015-01-16 17:06:11 -08001083 main.step( "Cut links on Core devices using user provided range" )
Hari Krishna22c3d412015-02-17 16:48:12 -08001084 main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
1085 main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
1086 main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001087 for i in range( int( switchLinksToToggle ) ):
1088 main.Mininet1.link(
1089 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001090 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001091 OPTION="down" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001092 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001093 main.Mininet1.link(
1094 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001095 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001096 OPTION="down" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001097 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001098 main.Mininet1.link(
1099 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001100 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001101 OPTION="down" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001102 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001103
1104 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001105 linkDown = main.ONOSbench.checkStatus(
Hari Krishna22c3d412015-02-17 16:48:12 -08001106 topology_output, main.numMNswitches, str(
1107 int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001108 utilities.assert_equals(
1109 expect=main.TRUE,
1110 actual=linkDown,
1111 onpass="Link Down discovered properly",
1112 onfail="Link down was not discovered in " +
1113 str( link_sleep ) +
1114 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001115
kelvin-onlab8a832582015-01-16 17:06:11 -08001116 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001117 pingResultLinkDown = main.FALSE
1118 time1 = time.time()
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001119 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001120 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001121 timeDiff = round( ( time2 - time1 ), 2 )
1122 main.log.report(
1123 "Time taken for Ping All: " +
1124 str( timeDiff ) +
1125 " seconds" )
1126 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1127 onpass="PING ALL PASS",
1128 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001129
Hari Krishna22c3d412015-02-17 16:48:12 -08001130 caseResult70 = linkDown and pingResultLinkDown
1131 utilities.assert_equals( expect=main.TRUE, actual=caseResult70,
kelvin-onlab8a832582015-01-16 17:06:11 -08001132 onpass="Random Link cut Test PASS",
1133 onfail="Random Link cut Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001134
kelvin-onlab8a832582015-01-16 17:06:11 -08001135 def CASE80( self, main ):
1136 """
Hari Krishnab35c6d02015-03-18 11:13:51 -07001137 Bring the core links up that are down and verify ping all ( Host Intents-Att Topo )
kelvin-onlab8a832582015-01-16 17:06:11 -08001138 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001139 import random
kelvin-onlab65a72d22015-03-26 13:46:32 -07001140 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1141 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1142 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001143 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001144 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001145
kelvin-onlab8a832582015-01-16 17:06:11 -08001146 main.log.report(
Hari Krishnab35c6d02015-03-18 11:13:51 -07001147 "Bring the core links up that are down and verify ping all (Host Intents-Att Topo" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001148 main.log.report(
1149 "__________________________________________________________________" )
1150 main.case(
1151 "Host intents - Bring the core links up that are down and verify ping all" )
1152 main.step( "Bring randomly cut links on Core devices up" )
1153 for i in range( int( switchLinksToToggle ) ):
1154 main.Mininet1.link(
1155 END1=link1End1,
kelvin-onlab54400a92015-02-26 18:05:51 -08001156 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001157 OPTION="up" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001158 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001159 main.Mininet1.link(
1160 END1=link2End1,
kelvin-onlab54400a92015-02-26 18:05:51 -08001161 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001162 OPTION="up" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001163 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001164 main.Mininet1.link(
1165 END1=link3End1,
kelvin-onlab54400a92015-02-26 18:05:51 -08001166 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001167 OPTION="up" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001168 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001169
1170 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001171 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -08001172 topology_output,
Hari Krishna22c3d412015-02-17 16:48:12 -08001173 main.numMNswitches,
1174 str( main.numMNlinks ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001175 utilities.assert_equals(
1176 expect=main.TRUE,
1177 actual=linkUp,
1178 onpass="Link up discovered properly",
1179 onfail="Link up was not discovered in " +
1180 str( link_sleep ) +
1181 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001182
kelvin-onlab8a832582015-01-16 17:06:11 -08001183 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001184 pingResultLinkUp = main.FALSE
1185 time1 = time.time()
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001186 pingResultLinkUp = main.Mininet1.pingall( timeout=main.pingTimeout )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001187 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001188 timeDiff = round( ( time2 - time1 ), 2 )
1189 main.log.report(
1190 "Time taken for Ping All: " +
1191 str( timeDiff ) +
1192 " seconds" )
1193 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1194 onpass="PING ALL PASS",
1195 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001196
Hari Krishna22c3d412015-02-17 16:48:12 -08001197 caseResult80 = linkUp and pingResultLinkUp
1198 utilities.assert_equals( expect=main.TRUE, actual=caseResult80,
kelvin-onlab8a832582015-01-16 17:06:11 -08001199 onpass="Link Up Test PASS",
1200 onfail="Link Up Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001201
kelvin-onlab8a832582015-01-16 17:06:11 -08001202 def CASE71( self, main ):
1203 """
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001204 Randomly bring some core links down and verify ping all ( Point Intents-Att Topo)
kelvin-onlab8a832582015-01-16 17:06:11 -08001205 """
kelvin8ec71442015-01-15 16:57:00 -08001206 import random
Hari Krishna22c3d412015-02-17 16:48:12 -08001207 main.randomLink1 = []
1208 main.randomLink2 = []
1209 main.randomLink3 = []
kelvin-onlab65a72d22015-03-26 13:46:32 -07001210 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1211 link1End2 = main.params[ 'ATTCORELINKS' ][ 'linkS3b' ].split( ',' )
1212 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1213 link2End2 = main.params[ 'ATTCORELINKS' ][ 'linkS14b' ].split( ',' )
1214 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
1215 link3End2 = main.params[ 'ATTCORELINKS' ][ 'linkS18b' ].split( ',' )
1216 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001217 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin8ec71442015-01-15 16:57:00 -08001218
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001219 main.log.report( "Randomly bring some core links down and verify ping all (Point Intents-Att Topo)" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001220 main.log.report( "___________________________________________________________________________" )
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001221 main.case( "Point intents - Randomly bring some core links down and verify ping all" )
Hari Krishnad97213e2015-01-24 19:30:14 -08001222 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001223 if ( int( switchLinksToToggle ) ==
1224 0 or int( switchLinksToToggle ) > 5 ):
kelvin-onlab65a72d22015-03-26 13:46:32 -07001225 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 -07001226 #main.cleanup()
1227 #main.exit()
kelvin8ec71442015-01-15 16:57:00 -08001228 else:
kelvin-onlab65a72d22015-03-26 13:46:32 -07001229 main.log.info( "User provided Core switch links range to toggle is correct, proceeding to run the test" )
kelvin8ec71442015-01-15 16:57:00 -08001230
kelvin-onlab8a832582015-01-16 17:06:11 -08001231 main.step( "Cut links on Core devices using user provided range" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001232 main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
1233 main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
1234 main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001235 for i in range( int( switchLinksToToggle ) ):
1236 main.Mininet1.link(
1237 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001238 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001239 OPTION="down" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001240 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001241 main.Mininet1.link(
1242 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001243 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001244 OPTION="down" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001245 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001246 main.Mininet1.link(
1247 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001248 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001249 OPTION="down" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001250 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -08001251
1252 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001253 linkDown = main.ONOSbench.checkStatus(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001254 topology_output, main.numMNswitches, str(
1255 int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001256 utilities.assert_equals(
1257 expect=main.TRUE,
1258 actual=linkDown,
1259 onpass="Link Down discovered properly",
1260 onfail="Link down was not discovered in " +
1261 str( link_sleep ) +
1262 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -08001263
kelvin-onlab8a832582015-01-16 17:06:11 -08001264 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -08001265 pingResultLinkDown = main.FALSE
1266 time1 = time.time()
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001267 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout)
kelvin8ec71442015-01-15 16:57:00 -08001268 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001269 timeDiff = round( ( time2 - time1 ), 2 )
1270 main.log.report(
1271 "Time taken for Ping All: " +
1272 str( timeDiff ) +
1273 " seconds" )
1274 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1275 onpass="PING ALL PASS",
1276 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001277
kelvin-onlab65a72d22015-03-26 13:46:32 -07001278 caseResult71 = linkDown and pingResultLinkDown
1279 utilities.assert_equals( expect=main.TRUE, actual=caseResult71,
kelvin-onlab8a832582015-01-16 17:06:11 -08001280 onpass="Random Link cut Test PASS",
1281 onfail="Random Link cut Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001282
kelvin-onlab8a832582015-01-16 17:06:11 -08001283 def CASE81( self, main ):
1284 """
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001285 Bring the core links up that are down and verify ping all ( Point Intents-Att Topo )
kelvin-onlab8a832582015-01-16 17:06:11 -08001286 """
kelvin8ec71442015-01-15 16:57:00 -08001287 import random
kelvin-onlab65a72d22015-03-26 13:46:32 -07001288 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1289 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1290 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001291 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001292 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
kelvin8ec71442015-01-15 16:57:00 -08001293
kelvin-onlab8a832582015-01-16 17:06:11 -08001294 main.log.report(
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001295 "Bring the core links up that are down and verify ping all ( Point Intents-Att Topo" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001296 main.log.report(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001297 "__________________________________________________________________" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001298 main.case(
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001299 "Point intents - Bring the core links up that are down and verify ping all" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001300 main.step( "Bring randomly cut links on Core devices up" )
1301 for i in range( int( switchLinksToToggle ) ):
1302 main.Mininet1.link(
1303 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001304 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001305 OPTION="up" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001306 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001307 main.Mininet1.link(
1308 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001309 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001310 OPTION="up" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001311 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001312 main.Mininet1.link(
1313 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001314 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001315 OPTION="up" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001316 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -08001317
1318 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001319 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -08001320 topology_output,
Hari Krishna22c3d412015-02-17 16:48:12 -08001321 main.numMNswitches,
1322 str( main.numMNlinks ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001323 utilities.assert_equals(
1324 expect=main.TRUE,
1325 actual=linkUp,
1326 onpass="Link up discovered properly",
1327 onfail="Link up was not discovered in " +
1328 str( link_sleep ) +
1329 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -08001330
kelvin-onlab8a832582015-01-16 17:06:11 -08001331 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -08001332 pingResultLinkUp = main.FALSE
1333 time1 = time.time()
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001334 pingResultLinkUp = main.Mininet1.pingall(timeout = main.pingTimeout )
kelvin8ec71442015-01-15 16:57:00 -08001335 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001336 timeDiff = round( ( time2 - time1 ), 2 )
1337 main.log.report(
1338 "Time taken for Ping All: " +
1339 str( timeDiff ) +
1340 " seconds" )
1341 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1342 onpass="PING ALL PASS",
1343 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001344
Hari Krishna22c3d412015-02-17 16:48:12 -08001345 caseResult81 = linkUp and pingResultLinkUp
1346 utilities.assert_equals( expect=main.TRUE, actual=caseResult81,
kelvin-onlab8a832582015-01-16 17:06:11 -08001347 onpass="Link Up Test PASS",
1348 onfail="Link Up Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001349
Hari Krishnab35c6d02015-03-18 11:13:51 -07001350 def CASE72( self, main ):
1351 """
1352 Randomly bring some links down and verify ping all ( Host Intents-Chordal Topo)
1353 """
1354 import random
1355 import itertools
1356 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1357
1358 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Chordal Topo)" )
1359 main.log.report( "___________________________________________________________________________" )
1360 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
1361 switches = []
1362 switchesComb = []
1363 for i in range( main.numMNswitches ):
1364 switches.append('s%d'%(i+1))
1365 switchesLinksComb = list(itertools.combinations(switches,2))
1366 main.randomLinks = random.sample(switchesLinksComb, 5 )
1367 print main.randomLinks
1368 main.step( "Cut links on random devices" )
1369
1370 for switch in main.randomLinks:
1371 main.Mininet1.link(
1372 END1=switch[0],
1373 END2=switch[1],
1374 OPTION="down")
Hari Krishna0ce0e152015-06-23 09:55:29 -07001375 time.sleep( link_sleep )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001376
1377 topology_output = main.ONOScli2.topology()
1378 linkDown = main.ONOSbench.checkStatus(
1379 topology_output, main.numMNswitches, str(
1380 int( main.numMNlinks ) - 5 * 2 ) )
1381 utilities.assert_equals(
1382 expect=main.TRUE,
1383 actual=linkDown,
1384 onpass="Link Down discovered properly",
1385 onfail="Link down was not discovered in " +
1386 str( link_sleep ) +
1387 " seconds" )
1388
1389 main.step( "Verify Ping across all hosts" )
1390 pingResultLinkDown = main.FALSE
1391 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001392 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001393 time2 = time.time()
1394 timeDiff = round( ( time2 - time1 ), 2 )
1395 main.log.report(
1396 "Time taken for Ping All: " +
1397 str( timeDiff ) +
1398 " seconds" )
1399 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1400 onpass="PING ALL PASS",
1401 onfail="PING ALL FAIL" )
1402
kelvin-onlab65a72d22015-03-26 13:46:32 -07001403 caseResult71 = pingResultLinkDown
1404 utilities.assert_equals( expect=main.TRUE, actual=caseResult71,
Hari Krishnab35c6d02015-03-18 11:13:51 -07001405 onpass="Random Link cut Test PASS",
1406 onfail="Random Link cut Test FAIL" )
1407
1408 def CASE82( self, main ):
1409 """
1410 Bring the core links up that are down and verify ping all ( Host Intents Chordal Topo )
1411 """
1412 import random
1413 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1414
1415 main.log.report(
1416 "Bring the core links up that are down and verify ping all (Host Intents-Chordal Topo" )
1417 main.log.report(
1418 "__________________________________________________________________" )
1419 main.case(
1420 "Host intents - Bring the core links up that are down and verify ping all" )
1421 main.step( "Bring randomly cut links on devices up" )
1422
1423 for switch in main.randomLinks:
1424 main.Mininet1.link(
1425 END1=switch[0],
1426 END2=switch[1],
1427 OPTION="up")
Hari Krishna0ce0e152015-06-23 09:55:29 -07001428 time.sleep( link_sleep )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001429
1430 topology_output = main.ONOScli2.topology()
1431 linkUp = main.ONOSbench.checkStatus(
1432 topology_output,
1433 main.numMNswitches,
1434 str( main.numMNlinks ) )
1435 utilities.assert_equals(
1436 expect=main.TRUE,
1437 actual=linkUp,
1438 onpass="Link up discovered properly",
1439 onfail="Link up was not discovered in " +
1440 str( link_sleep ) +
1441 " seconds" )
1442
1443 main.step( "Verify Ping across all hosts" )
1444 pingResultLinkUp = main.FALSE
1445 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001446 pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001447 time2 = time.time()
1448 timeDiff = round( ( time2 - time1 ), 2 )
1449 main.log.report(
1450 "Time taken for Ping All: " +
1451 str( timeDiff ) +
1452 " seconds" )
1453 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1454 onpass="PING ALL PASS",
1455 onfail="PING ALL FAIL" )
1456
1457 caseResult82 = linkUp and pingResultLinkUp
1458 utilities.assert_equals( expect=main.TRUE, actual=caseResult82,
1459 onpass="Link Up Test PASS",
1460 onfail="Link Up Test FAIL" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001461
Hari Krishnab35c6d02015-03-18 11:13:51 -07001462 def CASE73( self, main ):
1463 """
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001464 Randomly bring some links down and verify ping all ( Point Intents-Chordal Topo)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001465 """
1466 import random
kelvin-onlab65a72d22015-03-26 13:46:32 -07001467 import itertools
Hari Krishnab35c6d02015-03-18 11:13:51 -07001468 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001469
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001470 main.log.report( "Randomly bring some core links down and verify ping all ( Point Intents-Chordal Topo)" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001471 main.log.report( "___________________________________________________________________________" )
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001472 main.case( "Point intents - Randomly bring some core links down and verify ping all" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001473 switches = []
1474 switchesComb = []
1475 for i in range( main.numMNswitches ):
1476 switches.append('s%d'%(i+1))
1477 switchesLinksComb = list(itertools.combinations(switches,2))
1478 main.randomLinks = random.sample(switchesLinksComb, 5 )
1479 print main.randomLinks
1480 main.step( "Cut links on random devices" )
1481
1482 for switch in main.randomLinks:
Hari Krishnab35c6d02015-03-18 11:13:51 -07001483 main.Mininet1.link(
1484 END1=switch[0],
1485 END2=switch[1],
kelvin-onlab65a72d22015-03-26 13:46:32 -07001486 OPTION="down")
Hari Krishna0ce0e152015-06-23 09:55:29 -07001487 time.sleep( link_sleep )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001488
1489 topology_output = main.ONOScli2.topology()
1490 linkDown = main.ONOSbench.checkStatus(
1491 topology_output, main.numMNswitches, str(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001492 int( main.numMNlinks ) - 5 * 2 ) )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001493 utilities.assert_equals(
1494 expect=main.TRUE,
1495 actual=linkDown,
1496 onpass="Link Down discovered properly",
1497 onfail="Link down was not discovered in " +
1498 str( link_sleep ) +
1499 " seconds" )
1500
1501 main.step( "Verify Ping across all hosts" )
1502 pingResultLinkDown = main.FALSE
1503 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001504 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001505 time2 = time.time()
1506 timeDiff = round( ( time2 - time1 ), 2 )
1507 main.log.report(
1508 "Time taken for Ping All: " +
1509 str( timeDiff ) +
1510 " seconds" )
1511 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1512 onpass="PING ALL PASS",
1513 onfail="PING ALL FAIL" )
1514
kelvin-onlab65a72d22015-03-26 13:46:32 -07001515 caseResult73 = pingResultLinkDown
Hari Krishnab35c6d02015-03-18 11:13:51 -07001516 utilities.assert_equals( expect=main.TRUE, actual=caseResult73,
1517 onpass="Random Link cut Test PASS",
1518 onfail="Random Link cut Test FAIL" )
1519
1520 def CASE83( self, main ):
1521 """
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001522 Bring the core links up that are down and verify ping all ( Point Intents Chordal Topo )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001523 """
1524 import random
Hari Krishnab35c6d02015-03-18 11:13:51 -07001525 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001526
Hari Krishnab35c6d02015-03-18 11:13:51 -07001527 main.log.report(
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001528 "Bring the core links up that are down and verify ping all ( Point Intents-Chordal Topo" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001529 main.log.report(
1530 "__________________________________________________________________" )
1531 main.case(
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001532 "Point intents - Bring the core links up that are down and verify ping all" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001533 main.step( "Bring randomly cut links on devices up" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001534
kelvin-onlab65a72d22015-03-26 13:46:32 -07001535 for switch in main.randomLinks:
Hari Krishnab35c6d02015-03-18 11:13:51 -07001536 main.Mininet1.link(
1537 END1=switch[0],
1538 END2=switch[1],
1539 OPTION="up")
Hari Krishna0ce0e152015-06-23 09:55:29 -07001540 time.sleep( link_sleep )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001541
1542 topology_output = main.ONOScli2.topology()
1543 linkUp = main.ONOSbench.checkStatus(
1544 topology_output,
1545 main.numMNswitches,
1546 str( main.numMNlinks ) )
1547 utilities.assert_equals(
1548 expect=main.TRUE,
1549 actual=linkUp,
1550 onpass="Link up discovered properly",
1551 onfail="Link up was not discovered in " +
1552 str( link_sleep ) +
1553 " seconds" )
1554
1555 main.step( "Verify Ping across all hosts" )
1556 pingResultLinkUp = main.FALSE
1557 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001558 pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001559 time2 = time.time()
1560 timeDiff = round( ( time2 - time1 ), 2 )
1561 main.log.report(
1562 "Time taken for Ping All: " +
1563 str( timeDiff ) +
1564 " seconds" )
1565 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1566 onpass="PING ALL PASS",
1567 onfail="PING ALL FAIL" )
1568
1569 caseResult83 = linkUp and pingResultLinkUp
1570 utilities.assert_equals( expect=main.TRUE, actual=caseResult83,
1571 onpass="Link Up Test PASS",
1572 onfail="Link Up Test FAIL" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001573
1574 def CASE74( self, main ):
1575 """
1576 Randomly bring some core links down and verify ping all ( Host Intents-Spine Topo)
1577 """
1578 import random
1579 main.randomLink1 = []
1580 main.randomLink2 = []
1581 main.randomLink3 = []
1582 main.randomLink4 = []
1583 link1End1 = main.params[ 'SPINECORELINKS' ][ 'linkS9' ]
1584 link1End2top = main.params[ 'SPINECORELINKS' ][ 'linkS9top' ].split( ',' )
1585 link1End2bot = main.params[ 'SPINECORELINKS' ][ 'linkS9bot' ].split( ',' )
1586 link2End1 = main.params[ 'SPINECORELINKS' ][ 'linkS10' ]
1587 link2End2top = main.params[ 'SPINECORELINKS' ][ 'linkS10top' ].split( ',' )
1588 link2End2bot = main.params[ 'SPINECORELINKS' ][ 'linkS10bot' ].split( ',' )
1589 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1590 main.pingTimeout = 400
1591
1592 main.log.report( "Bring some core links down and verify ping all (Host Intents-Spine Topo)" )
1593 main.log.report( "___________________________________________________________________________" )
1594
1595 linkIndex = range(4)
1596 linkIndexS9 = random.sample(linkIndex,1)[0]
1597 linkIndex.remove(linkIndexS9)
1598 linkIndexS10 = random.sample(linkIndex,1)[0]
1599 main.randomLink1 = link1End2top[linkIndexS9]
1600 main.randomLink2 = link2End2top[linkIndexS10]
1601 main.randomLink3 = random.sample(link1End2bot,1)[0]
1602 main.randomLink4 = random.sample(link2End2bot,1)[0]
kelvin-onlab77d6c302015-03-31 11:33:32 -07001603 # main.Mininet1.link( END1=link1End1, END2=main.randomLink1, OPTION="down" )
1604 # main.Mininet1.link( END1=link2End1, END2=main.randomLink2, OPTION="down" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001605 main.Mininet1.link( END1=link1End1, END2=main.randomLink3, OPTION="down" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001606 time.sleep( link_sleep )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001607 main.Mininet1.link( END1=link2End1, END2=main.randomLink4, OPTION="down" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001608 time.sleep( link_sleep )
1609
1610 topology_output = main.ONOScli2.topology()
1611 linkDown = main.ONOSbench.checkStatus(
1612 topology_output, main.numMNswitches, str(
1613 int( main.numMNlinks ) - 8 ))
1614 utilities.assert_equals(
1615 expect=main.TRUE,
1616 actual=linkDown,
1617 onpass="Link Down discovered properly",
1618 onfail="Link down was not discovered in " +
1619 str( link_sleep ) +
1620 " seconds" )
1621
1622 main.step( "Verify Ping across all hosts" )
1623 pingResultLinkDown = main.FALSE
1624 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001625 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlab65a72d22015-03-26 13:46:32 -07001626 time2 = time.time()
1627 timeDiff = round( ( time2 - time1 ), 2 )
1628 main.log.report(
1629 "Time taken for Ping All: " +
1630 str( timeDiff ) +
1631 " seconds" )
1632 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1633 onpass="PING ALL PASS",
1634 onfail="PING ALL FAIL" )
1635
1636 caseResult74 = linkDown and pingResultLinkDown
1637 utilities.assert_equals( expect=main.TRUE, actual=caseResult74,
1638 onpass="Random Link cut Test PASS",
1639 onfail="Random Link cut Test FAIL" )
1640
1641 def CASE84( self, main ):
1642 """
1643 Bring the core links up that are down and verify ping all ( Host Intents-Spine Topo )
1644 """
1645 import random
1646 link1End1 = main.params[ 'SPINECORELINKS' ][ 'linkS9' ]
1647 link2End1 = main.params[ 'SPINECORELINKS' ][ 'linkS10' ]
1648 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1649 main.log.report(
1650 "Bring the core links up that are down and verify ping all (Host Intents-Spine Topo" )
1651 main.log.report(
1652 "__________________________________________________________________" )
1653 main.case(
1654 "Host intents - Bring the core links up that are down and verify ping all" )
1655
kelvin-onlab77d6c302015-03-31 11:33:32 -07001656 #main.Mininet1.link( END1=link1End1, END2=main.randomLink1, OPTION="up" )
1657 #main.Mininet1.link( END1=link2End1, END2=main.randomLink2, OPTION="up" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001658 main.Mininet1.link( END1=link1End1, END2=main.randomLink3, OPTION="up" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001659 time.sleep( link_sleep )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001660 main.Mininet1.link( END1=link2End1, END2=main.randomLink4, OPTION="up" )
1661 time.sleep( link_sleep )
1662
kelvin-onlab65a72d22015-03-26 13:46:32 -07001663 topology_output = main.ONOScli2.topology()
1664 linkUp = main.ONOSbench.checkStatus(
1665 topology_output,
1666 main.numMNswitches,
1667 str( main.numMNlinks ) )
1668 utilities.assert_equals(
1669 expect=main.TRUE,
1670 actual=linkUp,
1671 onpass="Link up discovered properly",
1672 onfail="Link up was not discovered in " +
1673 str( link_sleep ) +
1674 " seconds" )
1675
1676 main.step( "Verify Ping across all hosts" )
1677 pingResultLinkUp = main.FALSE
1678 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001679 pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlab65a72d22015-03-26 13:46:32 -07001680 time2 = time.time()
1681 timeDiff = round( ( time2 - time1 ), 2 )
1682 main.log.report(
1683 "Time taken for Ping All: " +
1684 str( timeDiff ) +
1685 " seconds" )
1686 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1687 onpass="PING ALL PASS",
1688 onfail="PING ALL FAIL" )
1689
1690 caseResult84 = linkUp and pingResultLinkUp
1691 utilities.assert_equals( expect=main.TRUE, actual=caseResult84,
1692 onpass="Link Up Test PASS",
1693 onfail="Link Up Test FAIL" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001694
1695 def CASE90( self ):
kelvin-onlab8a832582015-01-16 17:06:11 -08001696 """
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001697 Install 600 point intents and verify ping all (Att Topology)
kelvin-onlab8a832582015-01-16 17:06:11 -08001698 """
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001699 main.log.report( "Add 600 point intents and verify pingall (Att Topology)" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001700 main.log.report( "_______________________________________" )
1701 import itertools
1702 import time
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001703 main.case( "Install 600 point intents" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001704 main.step( "Add point Intents" )
1705 intentResult = main.TRUE
1706 deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) )
1707
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001708 intentIdList = []
Hari Krishnab35c6d02015-03-18 11:13:51 -07001709 time1 = time.time()
Hari Krishnab35c6d02015-03-18 11:13:51 -07001710 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1711 pool = []
1712 for cli in main.CLIs:
1713 if i >= len( deviceCombos ):
1714 break
1715 t = main.Thread( target=cli.addPointIntent,
1716 threadID=main.threadID,
1717 name="addPointIntent",
Hari Krishna0ce0e152015-06-23 09:55:29 -07001718 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4",main.MACsDict.get(deviceCombos[i][0]),main.MACsDict.get(deviceCombos[i][1])])
1719 pool.append(t)
1720 #time.sleep(1)
1721 t.start()
1722 i = i + 1
1723 main.threadID = main.threadID + 1
1724 for thread in pool:
1725 thread.join()
1726 intentIdList.append(thread.result)
1727 time2 = time.time()
1728 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1729 intentResult = main.TRUE
1730 intentsJson = main.ONOScli2.intents()
1731 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1732 intentsJson = intentsJson)
1733 print getIntentStateResult
1734 # Takes awhile for all the onos to get the intents
1735 time.sleep(60)
1736 main.step( "Verify Ping across all hosts" )
1737 pingResult = main.FALSE
1738 time1 = time.time()
1739 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
1740 time2 = time.time()
1741 timeDiff = round( ( time2 - time1 ), 2 )
1742 main.log.report(
1743 "Time taken for Ping All: " +
1744 str( timeDiff ) +
1745 " seconds" )
1746 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1747 onpass="PING tALL PASS",
1748 onfail="PING ALL FAIL" )
1749
1750 case90Result = ( intentResult and pingResult )
1751
1752 utilities.assert_equals(
1753 expect=main.TRUE,
1754 actual=case90Result,
1755 onpass="Install 600 point Intents and Ping All test PASS",
1756 onfail="Install 600 point Intents and Ping All test FAIL" )
1757
1758 def CASE91( self ):
1759 """
1760 Install 600 point intents and verify ping all (Chordal Topology)
1761 """
1762 main.log.report( "Add 600 point intents and verify pingall (Chordal Topology)" )
1763 main.log.report( "_______________________________________" )
1764 import itertools
1765 import time
1766 main.case( "Install 600 point intents" )
1767 main.step( "Add point Intents" )
1768 intentResult = main.TRUE
1769 deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) )
1770
1771 intentIdList = []
1772 time1 = time.time()
1773 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1774 pool = []
1775 for cli in main.CLIs:
1776 if i >= len( deviceCombos ):
1777 break
1778 t = main.Thread( target=cli.addPointIntent,
1779 threadID=main.threadID,
1780 name="addPointIntent",
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001781 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
Hari Krishnab35c6d02015-03-18 11:13:51 -07001782 pool.append(t)
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001783 #time.sleep(1)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001784 t.start()
1785 i = i + 1
1786 main.threadID = main.threadID + 1
1787 for thread in pool:
1788 thread.join()
1789 intentIdList.append(thread.result)
1790 time2 = time.time()
1791 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1792 intentResult = main.TRUE
1793 intentsJson = main.ONOScli2.intents()
1794 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1795 intentsJson = intentsJson)
1796 print getIntentStateResult
1797 # Takes awhile for all the onos to get the intents
1798 time.sleep(30)
kelvin-onlab8a832582015-01-16 17:06:11 -08001799 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001800 pingResult = main.FALSE
1801 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001802 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001803 time2 = time.time()
1804 timeDiff = round( ( time2 - time1 ), 2 )
1805 main.log.report(
1806 "Time taken for Ping All: " +
1807 str( timeDiff ) +
1808 " seconds" )
1809 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1810 onpass="PING ALL PASS",
1811 onfail="PING ALL FAIL" )
1812
kelvin-onlab65a72d22015-03-26 13:46:32 -07001813 case91Result = ( intentResult and pingResult )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001814
1815 utilities.assert_equals(
1816 expect=main.TRUE,
kelvin-onlabd878fc22015-03-27 13:33:41 -07001817 actual=case91Result,
Hari Krishna0ce0e152015-06-23 09:55:29 -07001818 onpass="Install 600 point Intents and Ping All test PASS",
1819 onfail="Install 600 point Intents and Ping All test FAIL" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001820
1821 def CASE92( self ):
1822 """
kelvin-onlab77d6c302015-03-31 11:33:32 -07001823 Install 4556 point intents and verify ping all (Spine Topology)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001824 """
kelvin-onlab77d6c302015-03-31 11:33:32 -07001825 main.log.report( "Add 4556 point intents and verify pingall (Spine Topology)" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001826 main.log.report( "_______________________________________" )
1827 import itertools
1828 import time
kelvin-onlab77d6c302015-03-31 11:33:32 -07001829 main.case( "Install 4556 point intents" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001830 main.step( "Add point Intents" )
1831 intentResult = main.TRUE
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001832 main.pingTimeout = 600
kelvin-onlab77d6c302015-03-31 11:33:32 -07001833 for i in range(len(main.hostMACs)):
1834 main.MACsDict[main.deviceDPIDs[i+10]] = main.hostMACs[i].split('/')[0]
1835 print main.MACsDict
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001836 deviceCombos = list( itertools.permutations( main.deviceDPIDs[10:], 2 ) )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001837 intentIdList = []
1838 time1 = time.time()
1839 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1840 pool = []
1841 for cli in main.CLIs:
1842 if i >= len( deviceCombos ):
1843 break
1844 t = main.Thread( target=cli.addPointIntent,
1845 threadID=main.threadID,
1846 name="addPointIntent",
1847 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
1848 pool.append(t)
1849 #time.sleep(1)
1850 t.start()
1851 i = i + 1
1852 main.threadID = main.threadID + 1
1853 for thread in pool:
1854 thread.join()
1855 intentIdList.append(thread.result)
1856 time2 = time.time()
1857 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1858 intentResult = main.TRUE
1859 intentsJson = main.ONOScli2.intents()
1860 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1861 intentsJson = intentsJson)
kelvin-onlab77d6c302015-03-31 11:33:32 -07001862 #print getIntentStateResult
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001863 # Takes awhile for all the onos to get the intents
kelvin-onlab77d6c302015-03-31 11:33:32 -07001864 time.sleep(60)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001865 main.step( "Verify Ping across all hosts" )
1866 pingResult = main.FALSE
1867 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001868 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001869 time2 = time.time()
1870 timeDiff = round( ( time2 - time1 ), 2 )
1871 main.log.report(
1872 "Time taken for Ping All: " +
1873 str( timeDiff ) +
1874 " seconds" )
1875 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1876 onpass="PING ALL PASS",
1877 onfail="PING ALL FAIL" )
1878
kelvin-onlab65a72d22015-03-26 13:46:32 -07001879 case92Result = ( intentResult and pingResult )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001880
1881 utilities.assert_equals(
1882 expect=main.TRUE,
kelvin-onlab65a72d22015-03-26 13:46:32 -07001883 actual=case92Result,
kelvin-onlab77d6c302015-03-31 11:33:32 -07001884 onpass="Install 4556 point Intents and Ping All test PASS",
1885 onfail="Install 4556 point Intents and Ping All test FAIL" )
1886
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001887 def CASE93( self ):
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001888 """
kelvin-onlab77d6c302015-03-31 11:33:32 -07001889 Install multi-single point intents and verify Ping all works
1890 for att topology
1891 """
1892 import copy
1893 import time
1894 main.log.report( "Install multi-single point intents and verify Ping all" )
1895 main.log.report( "___________________________________________" )
1896 main.case( "Install multi-single point intents and Ping all" )
1897 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
1898 portIngressList = ['1']*(len(deviceDPIDsCopy) - 1)
1899 intentIdList = []
1900 print "MACsDict", main.MACsDict
1901 time1 = time.time()
1902 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
1903 pool = []
1904 for cli in main.CLIs:
1905 egressDevice = deviceDPIDsCopy[i]
1906 ingressDeviceList = copy.copy(deviceDPIDsCopy)
1907 ingressDeviceList.remove(egressDevice)
1908 if i >= len( deviceDPIDsCopy ):
1909 break
1910 t = main.Thread( target=cli.addMultipointToSinglepointIntent,
1911 threadID=main.threadID,
1912 name="addMultipointToSinglepointIntent",
1913 args =[ingressDeviceList,egressDevice,portIngressList,'1','IPV4','',main.MACsDict.get(egressDevice)])
1914 pool.append(t)
1915 #time.sleep(1)
1916 t.start()
1917 i = i + 1
1918 main.threadID = main.threadID + 1
1919 for thread in pool:
1920 thread.join()
1921 intentIdList.append(thread.result)
1922 time2 = time.time()
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001923 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1924 time.sleep(30)
1925 print "getting all intents ID"
1926 intentIdTemp = main.ONOScli1.getAllIntentsId()
1927 print intentIdTemp
1928 print len(intentIdList)
kelvin-onlab06ade552015-03-31 18:09:27 -07001929 print intentIdList
kelvin-onlab4df89f22015-04-13 18:10:23 -07001930 checkIntentStateResult = main.TRUE
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001931 print "Checking intents state"
kelvin-onlab4df89f22015-04-13 18:10:23 -07001932 checkIntentStateResult = main.ONOScli1.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
1933 checkIntentStateResult = main.ONOScli2.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
1934 checkIntentStateResult = main.ONOScli3.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
1935 checkIntentStateResult = main.ONOScli4.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
1936 checkIntentStateResult = main.ONOScli5.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
1937
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001938 if checkIntentStateResult:
1939 main.log.info( "All intents are installed correctly " )
kelvin-onlab4df89f22015-04-13 18:10:23 -07001940
1941 print "Checking flows state "
1942 checkFlowsState = main.ONOScli1.checkFlowsState()
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001943 time.sleep(50)
kelvin-onlab77d6c302015-03-31 11:33:32 -07001944 main.step( "Verify Ping across all hosts" )
1945 pingResult = main.FALSE
1946 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001947 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlab77d6c302015-03-31 11:33:32 -07001948 time2 = time.time()
1949 timeDiff = round( ( time2 - time1 ), 2 )
1950 main.log.report(
1951 "Time taken for Ping All: " +
1952 str( timeDiff ) +
1953 " seconds" )
kelvin-onlab4df89f22015-04-13 18:10:23 -07001954 checkFlowsState = main.ONOScli1.checkFlowsState()
kelvin-onlab77d6c302015-03-31 11:33:32 -07001955 case93Result = pingResult
1956 utilities.assert_equals(
1957 expect=main.TRUE,
1958 actual=case93Result,
1959 onpass="Install 25 multi to single point Intents and Ping All test PASS",
1960 onfail="Install 25 multi to single point Intents and Ping All test FAIL" )
1961
kelvin-onlab20c712a2015-03-31 12:55:34 -07001962 def CASE94( self ):
1963 """
1964 Install multi-single point intents and verify Ping all works
kelvin-onlabd9a8ed32015-04-03 13:55:28 -07001965 for Chordal topology
kelvin-onlab20c712a2015-03-31 12:55:34 -07001966 """
1967 import copy
1968 import time
1969 main.log.report( "Install multi-single point intents and verify Ping all" )
1970 main.log.report( "___________________________________________" )
1971 main.case( "Install multi-single point intents and Ping all" )
1972 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
1973 portIngressList = ['1']*(len(deviceDPIDsCopy) - 1)
1974 intentIdList = []
1975 print "MACsDict", main.MACsDict
1976 time1 = time.time()
1977 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
1978 pool = []
1979 for cli in main.CLIs:
1980 egressDevice = deviceDPIDsCopy[i]
1981 ingressDeviceList = copy.copy(deviceDPIDsCopy)
1982 ingressDeviceList.remove(egressDevice)
1983 if i >= len( deviceDPIDsCopy ):
1984 break
1985 t = main.Thread( target=cli.addMultipointToSinglepointIntent,
1986 threadID=main.threadID,
1987 name="addMultipointToSinglepointIntent",
1988 args =[ingressDeviceList,egressDevice,portIngressList,'1','IPV4','',main.MACsDict.get(egressDevice)])
1989 pool.append(t)
1990 #time.sleep(1)
1991 t.start()
1992 i = i + 1
1993 main.threadID = main.threadID + 1
1994 for thread in pool:
1995 thread.join()
1996 intentIdList.append(thread.result)
1997 time2 = time.time()
1998 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1999 time.sleep(5)
2000 main.step( "Verify Ping across all hosts" )
2001 pingResult = main.FALSE
2002 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07002003 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlab20c712a2015-03-31 12:55:34 -07002004 time2 = time.time()
2005 timeDiff = round( ( time2 - time1 ), 2 )
2006 main.log.report(
2007 "Time taken for Ping All: " +
2008 str( timeDiff ) +
2009 " seconds" )
2010
2011 case94Result = pingResult
2012 utilities.assert_equals(
2013 expect=main.TRUE,
2014 actual=case94Result,
2015 onpass="Install 25 multi to single point Intents and Ping All test PASS",
2016 onfail="Install 25 multi to single point Intents and Ping All test FAIL" )
kelvin-onlab06ade552015-03-31 18:09:27 -07002017
2018 #def CASE95 multi-single point intent for Spine
2019
kelvin-onlab77d6c302015-03-31 11:33:32 -07002020 def CASE96( self ):
2021 """
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002022 Install single-multi point intents and verify Ping all works
2023 for att topology
2024 """
2025 import copy
2026 main.log.report( "Install single-multi point intents and verify Ping all" )
2027 main.log.report( "___________________________________________" )
2028 main.case( "Install single-multi point intents and Ping all" )
kelvin-onlab06ade552015-03-31 18:09:27 -07002029 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
2030 portEgressList = ['1']*(len(deviceDPIDsCopy) - 1)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002031 intentIdList = []
kelvin-onlab06ade552015-03-31 18:09:27 -07002032 print "MACsDict", main.MACsDict
2033 time1 = time.time()
2034 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
2035 pool = []
2036 for cli in main.CLIs:
2037 ingressDevice = deviceDPIDsCopy[i]
2038 egressDeviceList = copy.copy(deviceDPIDsCopy)
2039 egressDeviceList.remove(ingressDevice)
2040 if i >= len( deviceDPIDsCopy ):
2041 break
2042 t = main.Thread( target=cli.addSinglepointToMultipointIntent,
2043 threadID=main.threadID,
2044 name="addSinglepointToMultipointIntent",
2045 args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',main.MACsDict.get(ingressDevice)])
2046 pool.append(t)
2047 #time.sleep(1)
2048 t.start()
2049 i = i + 1
2050 main.threadID = main.threadID + 1
2051 for thread in pool:
2052 thread.join()
2053 intentIdList.append(thread.result)
2054 time2 = time.time()
2055 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
2056 time.sleep(5)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002057 main.step( "Verify Ping across all hosts" )
2058 pingResult = main.FALSE
2059 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07002060 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002061 time2 = time.time()
2062 timeDiff = round( ( time2 - time1 ), 2 )
2063 main.log.report(
2064 "Time taken for Ping All: " +
2065 str( timeDiff ) +
2066 " seconds" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002067
kelvin-onlab06ade552015-03-31 18:09:27 -07002068 case96Result = pingResult
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002069 utilities.assert_equals(
2070 expect=main.TRUE,
kelvin-onlab06ade552015-03-31 18:09:27 -07002071 actual=case96Result,
2072 onpass="Install 25 single to multi point Intents and Ping All test PASS",
2073 onfail="Install 25 single to multi point Intents and Ping All test FAIL" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002074
kelvin-onlab77d6c302015-03-31 11:33:32 -07002075 def CASE97( self ):
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002076 """
2077 Install single-multi point intents and verify Ping all works
kelvin-onlab06ade552015-03-31 18:09:27 -07002078 for Chordal topology
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002079 """
2080 import copy
2081 main.log.report( "Install single-multi point intents and verify Ping all" )
2082 main.log.report( "___________________________________________" )
2083 main.case( "Install single-multi point intents and Ping all" )
kelvin-onlab06ade552015-03-31 18:09:27 -07002084 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
2085 portEgressList = ['1']*(len(deviceDPIDsCopy) - 1)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002086 intentIdList = []
kelvin-onlab06ade552015-03-31 18:09:27 -07002087 print "MACsDict", main.MACsDict
2088 time1 = time.time()
2089 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
2090 pool = []
2091 for cli in main.CLIs:
2092 ingressDevice = deviceDPIDsCopy[i]
2093 egressDeviceList = copy.copy(deviceDPIDsCopy)
2094 egressDeviceList.remove(ingressDevice)
2095 if i >= len( deviceDPIDsCopy ):
2096 break
2097 t = main.Thread( target=cli.addSinglepointToMultipointIntent,
2098 threadID=main.threadID,
2099 name="addSinglepointToMultipointIntent",
2100 args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',main.MACsDict.get(ingressDevice),''])
2101 pool.append(t)
2102 #time.sleep(1)
2103 t.start()
2104 i = i + 1
2105 main.threadID = main.threadID + 1
2106 for thread in pool:
2107 thread.join()
2108 intentIdList.append(thread.result)
2109 time2 = time.time()
2110 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
2111 time.sleep(5)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002112 main.step( "Verify Ping across all hosts" )
2113 pingResult = main.FALSE
2114 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07002115 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002116 time2 = time.time()
2117 timeDiff = round( ( time2 - time1 ), 2 )
2118 main.log.report(
2119 "Time taken for Ping All: " +
2120 str( timeDiff ) +
2121 " seconds" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002122
kelvin-onlab06ade552015-03-31 18:09:27 -07002123 case97Result = pingResult
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002124 utilities.assert_equals(
2125 expect=main.TRUE,
kelvin-onlab06ade552015-03-31 18:09:27 -07002126 actual=case97Result,
2127 onpass="Install 25 single to multi point Intents and Ping All test PASS",
2128 onfail="Install 25 single to multi point Intents and Ping All test FAIL" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002129
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07002130 def CASE98( self ):
2131 """
2132 Install single-multi point intents and verify Ping all works
2133 for Spine topology
2134 """
2135 import copy
2136 main.log.report( "Install single-multi point intents and verify Ping all" )
2137 main.log.report( "___________________________________________" )
2138 main.case( "Install single-multi point intents and Ping all" )
2139 deviceDPIDsCopy = copy.copy( main.deviceDPIDs )
2140 deviceDPIDsCopy = deviceDPIDsCopy[ 10: ]
2141 portEgressList = [ '1' ]*(len(deviceDPIDsCopy) - 1)
2142 intentIdList = []
2143 MACsDictCopy = {}
2144 for i in range( len( deviceDPIDsCopy ) ):
2145 MACsDictCopy[ deviceDPIDsCopy[ i ] ] = main.hostMACs[i].split( '/' )[ 0 ]
2146
2147 print "deviceDPIDsCopy", deviceDPIDsCopy
2148 print ""
2149 print "MACsDictCopy", MACsDictCopy
2150 time1 = time.time()
2151 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
2152 pool = []
2153 for cli in main.CLIs:
2154 if i >= len( deviceDPIDsCopy ):
2155 break
2156 ingressDevice = deviceDPIDsCopy[i]
2157 egressDeviceList = copy.copy(deviceDPIDsCopy)
2158 egressDeviceList.remove(ingressDevice)
2159 t = main.Thread( target=cli.addSinglepointToMultipointIntent,
2160 threadID=main.threadID,
2161 name="addSinglepointToMultipointIntent",
2162 args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',MACsDictCopy.get(ingressDevice),''])
2163 pool.append(t)
2164 #time.sleep(1)
2165 t.start()
2166 i = i + 1
2167 main.threadID = main.threadID + 1
2168 for thread in pool:
2169 thread.join()
2170 intentIdList.append(thread.result)
2171 time2 = time.time()
2172 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
2173 time.sleep(5)
2174 main.step( "Verify Ping across all hosts" )
2175 pingResult = main.FALSE
2176 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07002177 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07002178 time2 = time.time()
2179 timeDiff = round( ( time2 - time1 ), 2 )
2180 main.log.report(
2181 "Time taken for Ping All: " +
2182 str( timeDiff ) +
2183 " seconds" )
2184
2185 case98Result = pingResult
2186 utilities.assert_equals(
2187 expect=main.TRUE,
2188 actual=case98Result,
2189 onpass="Install 25 single to multi point Intents and Ping All test PASS",
2190 onfail="Install 25 single to multi point Intents and Ping All test FAIL" )
2191
kelvin-onlab8a832582015-01-16 17:06:11 -08002192 def CASE10( self ):
kelvin-onlab7642bb12015-02-27 13:48:17 -08002193 import time
kelvin-onlab8a832582015-01-16 17:06:11 -08002194 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002195 Remove all Intents
kelvin-onlab8a832582015-01-16 17:06:11 -08002196 """
2197 main.log.report( "Remove all intents that were installed previously" )
2198 main.log.report( "______________________________________________" )
2199 main.log.info( "Remove all intents" )
2200 main.case( "Removing intents" )
2201 main.step( "Obtain the intent id's first" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002202 intentsList = main.ONOScli1.getAllIntentIds()
kelvin-onlab8a832582015-01-16 17:06:11 -08002203 ansi_escape = re.compile( r'\x1b[^m]*m' )
2204 intentsList = ansi_escape.sub( '', intentsList )
2205 intentsList = intentsList.replace(
2206 " onos:intents | grep id=",
2207 "" ).replace(
2208 "id=",
2209 "" ).replace(
2210 "\r\r",
2211 "" )
2212 intentsList = intentsList.splitlines()
Hari Krishna0ce0e152015-06-23 09:55:29 -07002213 #intentsList = intentsList[ 1: ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002214 intentIdList = []
2215 step1Result = main.TRUE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002216 moreIntents = main.TRUE
2217 removeIntentCount = 0
kelvin-onlab65a72d22015-03-26 13:46:32 -07002218 intentsCount = len(intentsList)
Hari Krishna0ce0e152015-06-23 09:55:29 -07002219 main.log.info ( "Current number of intents: " + str(intentsCount) )
kelvin-onlab8a832582015-01-16 17:06:11 -08002220 if ( len( intentsList ) > 1 ):
kelvin-onlab54400a92015-02-26 18:05:51 -08002221 results = main.TRUE
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002222 main.log.info("Removing intent...")
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002223 while moreIntents:
Hari Krishna0ce0e152015-06-23 09:55:29 -07002224 #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 -07002225 if removeIntentCount == 5:
2226 break
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002227 removeIntentCount = removeIntentCount + 1
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002228 intentsList1 = main.ONOScli1.getAllIntentIds()
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002229 if len( intentsList1 ) == 0:
2230 break
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002231 ansi_escape = re.compile( r'\x1b[^m]*m' )
2232 intentsList1 = ansi_escape.sub( '', intentsList1 )
2233 intentsList1 = intentsList1.replace(
2234 " onos:intents | grep id=",
2235 "" ).replace(
2236 " state=",
2237 "" ).replace(
2238 "\r\r",
2239 "" )
2240 intentsList1 = intentsList1.splitlines()
Hari Krishna0ce0e152015-06-23 09:55:29 -07002241 #intentsList1 = intentsList1[ 1: ]
2242 main.log.info ( "Round %d intents to remove: " %(removeIntentCount) )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002243 print intentsList1
2244 intentIdList1 = []
Hari Krishnab35c6d02015-03-18 11:13:51 -07002245 if ( len( intentsList1 ) > 0 ):
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002246 moreIntents = main.TRUE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002247 for i in range( len( intentsList1 ) ):
2248 intentsTemp1 = intentsList1[ i ].split( ',' )
2249 intentIdList1.append( intentsTemp1[ 0 ].split('=')[1] )
Hari Krishna0ce0e152015-06-23 09:55:29 -07002250 main.log.info ( "Leftover Intent IDs: " + str(intentIdList1) )
2251 main.log.info ( "Length of Leftover Intents list: " + str(len(intentIdList1)) )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07002252 time1 = time.time()
2253 for i in xrange( 0, len( intentIdList1 ), int(main.numCtrls) ):
2254 pool = []
2255 for cli in main.CLIs:
2256 if i >= len( intentIdList1 ):
2257 break
2258 t = main.Thread( target=cli.removeIntent,
2259 threadID=main.threadID,
2260 name="removeIntent",
Hari Krishna0ce0e152015-06-23 09:55:29 -07002261 args=[intentIdList1[i],'org.onosproject.cli',False,False])
kelvin-onlabadfc8db2015-03-24 15:52:48 -07002262 pool.append(t)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07002263 t.start()
2264 i = i + 1
2265 main.threadID = main.threadID + 1
2266 for thread in pool:
2267 thread.join()
2268 intentIdList.append(thread.result)
Hari Krishna0ce0e152015-06-23 09:55:29 -07002269 #time.sleep(2)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07002270 time2 = time.time()
2271 main.log.info("Time for removing host intents: %2f seconds" %(time2-time1))
Hari Krishnab35c6d02015-03-18 11:13:51 -07002272 time.sleep(10)
Hari Krishna0ce0e152015-06-23 09:55:29 -07002273 main.log.info("Purging WITHDRAWN Intents")
Hari Krishnaade11a72015-07-01 17:06:46 -07002274 purgeResult = main.ONOScli2.purgeIntents()
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002275 else:
Hari Krishna0ce0e152015-06-23 09:55:29 -07002276 time.sleep(10)
Hari Krishnab35c6d02015-03-18 11:13:51 -07002277 if len( main.ONOScli1.intents()):
Hari Krishnaef1bd4e2015-03-12 16:55:30 -07002278 continue
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002279 break
Hari Krishna0ce0e152015-06-23 09:55:29 -07002280 time.sleep(10)
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002281 else:
kelvin-onlab65a72d22015-03-26 13:46:32 -07002282 print "Removed %d intents" %(intentsCount)
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002283 step1Result = main.TRUE
2284 else:
2285 print "No Intent IDs found in Intents list: ", intentsList
2286 step1Result = main.FALSE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002287
kelvin-onlabdc8719b2015-03-02 14:01:52 -08002288 print main.ONOScli1.intents()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002289 caseResult10 = step1Result
2290 utilities.assert_equals( expect=main.TRUE, actual=caseResult10,
kelvin-onlab8a832582015-01-16 17:06:11 -08002291 onpass="Intent removal test successful",
2292 onfail="Intent removal test failed" )
Hari Krishna22c3d412015-02-17 16:48:12 -08002293
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07002294 def CASE12( self, main ):
Hari Krishna22c3d412015-02-17 16:48:12 -08002295 """
2296 Enable onos-app-ifwd, Verify Intent based Reactive forwarding through ping all and Disable it
2297 """
2298 import re
2299 import copy
2300 import time
2301
kelvin-onlab54400a92015-02-26 18:05:51 -08002302 Thread = imp.load_source('Thread','/home/admin/ONLabTest/TestON/tests/OnosCHO/Thread.py')
2303 threadID = 0
2304
Hari Krishna22c3d412015-02-17 16:48:12 -08002305 main.log.report( "Enable Intent based Reactive forwarding and Verify ping all" )
2306 main.log.report( "_____________________________________________________" )
2307 main.case( "Enable Intent based Reactive forwarding and Verify ping all" )
2308 main.step( "Enable intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08002309 installResult = main.FALSE
2310 feature = "onos-app-ifwd"
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002311
kelvin-onlab54400a92015-02-26 18:05:51 -08002312 pool = []
2313 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002314 for cli,feature in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -08002315 t = main.Thread(target=cli,threadID=threadID,
2316 name="featureInstall",args=[feature])
2317 pool.append(t)
2318 t.start()
2319 threadID = threadID + 1
2320
2321 results = []
2322 for thread in pool:
2323 thread.join()
2324 results.append(thread.result)
2325 time2 = time.time()
2326
2327 if( all(result == main.TRUE for result in results) == False):
2328 main.log.info("Did not install onos-app-ifwd feature properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -07002329 #main.cleanup()
2330 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -08002331 else:
2332 main.log.info("Successful feature:install onos-app-ifwd")
2333 installResult = main.TRUE
2334 main.log.info("Time for feature:install onos-app-ifwd: %2f seconds" %(time2-time1))
2335
Hari Krishna22c3d412015-02-17 16:48:12 -08002336 main.step( "Verify Pingall" )
2337 ping_result = main.FALSE
2338 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -08002339 ping_result = main.Mininet1.pingall(timeout=600)
Hari Krishna22c3d412015-02-17 16:48:12 -08002340 time2 = time.time()
2341 timeDiff = round( ( time2 - time1 ), 2 )
2342 main.log.report(
2343 "Time taken for Ping All: " +
2344 str( timeDiff ) +
2345 " seconds" )
kelvin-onlab54400a92015-02-26 18:05:51 -08002346
Hari Krishna22c3d412015-02-17 16:48:12 -08002347 if ping_result == main.TRUE:
2348 main.log.report( "Pingall Test in Reactive mode successful" )
2349 else:
2350 main.log.report( "Pingall Test in Reactive mode failed" )
2351
2352 main.step( "Disable Intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08002353 uninstallResult = main.FALSE
2354
kelvin-onlab54400a92015-02-26 18:05:51 -08002355 pool = []
2356 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002357 for cli,feature in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -08002358 t = main.Thread(target=cli,threadID=threadID,
2359 name="featureUninstall",args=[feature])
2360 pool.append(t)
2361 t.start()
2362 threadID = threadID + 1
2363
2364 results = []
2365 for thread in pool:
2366 thread.join()
2367 results.append(thread.result)
2368 time2 = time.time()
2369
2370 if( all(result == main.TRUE for result in results) == False):
2371 main.log.info("Did not uninstall onos-app-ifwd feature properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -07002372 uninstallResult = main.FALSE
2373 #main.cleanup()
2374 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -08002375 else:
2376 main.log.info("Successful feature:uninstall onos-app-ifwd")
2377 uninstallResult = main.TRUE
2378 main.log.info("Time for feature:uninstall onos-app-ifwd: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -08002379
2380 # Waiting for reative flows to be cleared.
2381 time.sleep( 10 )
2382
2383 case11Result = installResult and ping_result and uninstallResult
2384 utilities.assert_equals( expect=main.TRUE, actual=case11Result,
2385 onpass="Intent based Reactive forwarding Pingall test PASS",
2386 onfail="Intent based Reactive forwarding Pingall test FAIL" )
2387
Hari Krishnab35c6d02015-03-18 11:13:51 -07002388 def CASE99(self):
2389 import time
2390 # WORK AROUND FOR ONOS-581. STOP ONOS BEFORE ASSIGNING CONTROLLERS AT MININET & START ONCE DONE
2391 main.step( "Stop ONOS on all Nodes" )
2392 stopResult = main.TRUE
2393 for i in range( 1, int( main.numCtrls ) + 1 ):
2394 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
2395 main.log.info( "Stopping ONOS Node IP: " + ONOS_ip )
2396 sresult = main.ONOSbench.onosStop( ONOS_ip )
2397 utilities.assert_equals( expect=main.TRUE, actual=sresult,
2398 onpass="Test step PASS",
2399 onfail="Test step FAIL" )
2400 stopResult = ( stopResult and sresult )
2401
2402 main.step( "Start ONOS on all Nodes" )
2403 startResult = main.TRUE
2404 for i in range( 1, int( main.numCtrls ) + 1 ):
2405 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
2406 main.log.info( "Starting ONOS Node IP: " + ONOS_ip )
2407 sresult = main.ONOSbench.onosStart( ONOS_ip )
2408 utilities.assert_equals( expect=main.TRUE, actual=sresult,
2409 onpass="Test step PASS",
2410 onfail="Test step FAIL" )
2411 startResult = ( startResult and sresult )
2412
2413 main.step( "Start ONOS CLI on all nodes" )
2414 cliResult = main.TRUE
2415 time.sleep( 30 )
2416 main.log.step(" Start ONOS cli using thread ")
2417 pool = []
2418 time1 = time.time()
2419 for i in range( int( main.numCtrls ) ):
2420 t = main.Thread(target=main.CLIs[i].startOnosCli,
2421 threadID=main.threadID,
2422 name="startOnosCli",
2423 args=[main.nodes[i].ip_address])
2424 pool.append(t)
2425 t.start()
2426 main.threadID = main.threadID + 1
2427 for t in pool:
2428 t.join()
2429 cliResult = cliResult and t.result
2430 time2 = time.time()
2431
2432 if not cliResult:
2433 main.log.info("ONOS CLI did not start up properly")
2434 #main.cleanup()
2435 #main.exit()
2436 else:
2437 main.log.info("Successful CLI startup")
2438 main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
2439
2440 case99Result = ( startResult and cliResult )
2441 time.sleep(30)
2442 utilities.assert_equals(
2443 expect=main.TRUE,
2444 actual=case99Result,
2445 onpass="Starting new Chordal topology test PASS",
2446 onfail="Starting new Chordal topology test FAIL" )
2447
2448
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002449
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002450
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07002451